@vectoriox/iox-ui 5.128.1 → 5.129.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.
- package/composite-core/index.d.ts +130 -2
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +328 -141
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs +21 -1
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +557 -59
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +20 -0
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/forms-core/index.d.ts +16 -1
- package/generation-core/index.d.ts +173 -13
- package/package.json +1 -1
- package/src/composite-core/consent.ts +235 -0
- package/src/composite-core/public-api.ts +1 -0
- package/src/forms-core/form-presets.ts +28 -0
- package/src/generation-core/audit-site.ts +167 -17
- package/src/generation-core/compose-site.ts +190 -8
- package/src/generation-core/legal.ts +213 -0
- package/src/generation-core/public-api.ts +1 -0
- package/src/generation-core/site-spec.generated.ts +41 -8
- package/src/generation-core/site-tree.ts +5 -1
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { ConsentCategory } from '@vectoriox/iox-ui/consent-core';
|
|
2
|
+
|
|
3
|
+
import { CompositeNode, CompositeNodeFactory, writeProp } from './composite-node';
|
|
4
|
+
import { COLUMN, recipeButton, recipePart, recipeText, ROW, WORDS, ZERO } from './recipe-parts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* THE CONSENT RECIPE (consent plan C3; award-ingredients-plan AW1, H4) — the cookie banner as ordinary builder nodes, ONE
|
|
8
|
+
* recipe for the builder's palette and generation-core's composer (each stamps it with its own node factory), so a
|
|
9
|
+
* generated site's banner and a hand-placed one are the same structure. It moved out of iox-builder (`consent-preset.ts`,
|
|
10
|
+
* literal Swiss colours) into composite-core with the other recipes; its LOOK is the site's element styles (dialog,
|
|
11
|
+
* primary / secondary / text button, card), never a colour.
|
|
12
|
+
*
|
|
13
|
+
* Banner Dialog consent.banner (`consentRole`, placement bottom, the backdrop decides nothing, ✕ = a no)
|
|
14
|
+
* › Container › Container (Heading consent.title · Text consent.body · Link consent.privacy?)
|
|
15
|
+
* · Container (Container consent.choices (ButtonBlock consent.accept · ButtonBlock consent.reject)
|
|
16
|
+
* · ButtonBlock consent.preferences?)
|
|
17
|
+
* Preferences Dialog consent.preferences-dialog › Heading · Text · a card per category (Necessary always on;
|
|
18
|
+
* Analytics / Marketing a `consent-<category>` switch) · row (Reject all | Done · Accept all)
|
|
19
|
+
* Cookie settings ButtonBlock consent.settings — reopens Preferences (the footer's legal row on a generated site)
|
|
20
|
+
*
|
|
21
|
+
* The law in the tree (CONSENT `rules`, R-H4): Accept and Reject are the SAME type on the SAME row of the first layer —
|
|
22
|
+
* Reject is never a link, never only inside Preferences; Preferences is the only quiet button, and only when two or more
|
|
23
|
+
* categories are offered (`preferencesFromCategories`); clicking the backdrop decides nothing; the ✕ records a no.
|
|
24
|
+
* The words are mechanism microcopy for the studio to edit, in the site's language — never policy (D-C7).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
export enum ConsentRole {
|
|
28
|
+
Banner = 'consent.banner',
|
|
29
|
+
Title = 'consent.title',
|
|
30
|
+
Body = 'consent.body',
|
|
31
|
+
Privacy = 'consent.privacy',
|
|
32
|
+
Choices = 'consent.choices',
|
|
33
|
+
Accept = 'consent.accept',
|
|
34
|
+
Reject = 'consent.reject',
|
|
35
|
+
Preferences = 'consent.preferences',
|
|
36
|
+
PreferencesDialog = 'consent.preferences-dialog',
|
|
37
|
+
Category = 'consent.category',
|
|
38
|
+
Settings = 'consent.settings',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const CONSENT_ROLES: ReadonlySet<string> = new Set(Object.values(ConsentRole));
|
|
42
|
+
|
|
43
|
+
/** The categories a visitor may refuse (Necessary always runs). */
|
|
44
|
+
export const CONSENT_CHOICE_CATEGORIES: ReadonlyArray<ConsentCategory> = [ConsentCategory.Analytics, ConsentCategory.Marketing];
|
|
45
|
+
|
|
46
|
+
/** CONSENT `rules.preferencesFromCategories`: Preferences is offered only with at least this many categories. */
|
|
47
|
+
export const PREFERENCES_FROM_CATEGORIES = 2;
|
|
48
|
+
|
|
49
|
+
/** The action types the banner's buttons run (actions-core's names). */
|
|
50
|
+
export enum ConsentActionType {
|
|
51
|
+
Grant = 'grantConsent',
|
|
52
|
+
Deny = 'denyConsent',
|
|
53
|
+
OpenPreferences = 'openConsentPreferences',
|
|
54
|
+
CloseDialog = 'closeDialog',
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
enum Style {
|
|
58
|
+
Dialog = 'dialog',
|
|
59
|
+
Title = 'h3',
|
|
60
|
+
Body = 'small',
|
|
61
|
+
Link = 'link',
|
|
62
|
+
Primary = 'button-primary',
|
|
63
|
+
Secondary = 'button-secondary',
|
|
64
|
+
Ghost = 'button-ghost',
|
|
65
|
+
Label = 'button-label',
|
|
66
|
+
Card = 'card',
|
|
67
|
+
Field = 'field',
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The banner's words — mechanism microcopy (never policy), in the site's language. */
|
|
71
|
+
const CONSENT_WORDS = {
|
|
72
|
+
en: {
|
|
73
|
+
title: 'Cookies on this site',
|
|
74
|
+
body: 'Analytics and marketing cookies run only if you allow them. Necessary ones always run.',
|
|
75
|
+
accept: 'Accept all', reject: 'Reject all', preferences: 'Preferences', settings: 'Cookie settings', done: 'Done',
|
|
76
|
+
prefsTitle: 'Your privacy choices',
|
|
77
|
+
prefsSub: 'Change these any time from “Cookie settings” at the foot of the site.',
|
|
78
|
+
alwaysOn: 'Always on',
|
|
79
|
+
categories: {
|
|
80
|
+
[ConsentCategory.Necessary]: { name: 'Necessary', desc: 'Keeps the site working: your session, your language, this very choice.' },
|
|
81
|
+
[ConsentCategory.Analytics]: { name: 'Analytics', desc: 'Anonymous counts of visits and pages. Off means the analytics script never loads.' },
|
|
82
|
+
[ConsentCategory.Marketing]: { name: 'Marketing', desc: 'Ads measurement and remarketing. Off means no ad cookies and no data shared.' },
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
he: {
|
|
86
|
+
title: 'עוגיות באתר הזה',
|
|
87
|
+
body: 'עוגיות לסטטיסטיקה ולשיווק פועלות רק באישורך. עוגיות הכרחיות פועלות תמיד.',
|
|
88
|
+
accept: 'לאשר הכול', reject: 'לדחות הכול', preferences: 'העדפות', settings: 'הגדרות עוגיות', done: 'סיום',
|
|
89
|
+
prefsTitle: 'הבחירות שלך לפרטיות',
|
|
90
|
+
prefsSub: 'אפשר לשנות בכל עת ב„הגדרות עוגיות” שבתחתית האתר.',
|
|
91
|
+
alwaysOn: 'תמיד פועלות',
|
|
92
|
+
categories: {
|
|
93
|
+
[ConsentCategory.Necessary]: { name: 'הכרחיות', desc: 'שומרות על פעולת האתר: החיבור, השפה והבחירה הזו.' },
|
|
94
|
+
[ConsentCategory.Analytics]: { name: 'סטטיסטיקה', desc: 'ספירה אנונימית של ביקורים ועמודים. כבוי — הסקריפט לא נטען.' },
|
|
95
|
+
[ConsentCategory.Marketing]: { name: 'שיווק', desc: 'מדידת פרסום ושיווק חוזר. כבוי — אין עוגיות פרסום ושום מידע לא משותף.' },
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
} as const;
|
|
99
|
+
|
|
100
|
+
export type ConsentRecipeWords = (typeof CONSENT_WORDS)['en'] | (typeof CONSENT_WORDS)['he'];
|
|
101
|
+
|
|
102
|
+
/** The banner's words in `lang` (English for any language it does not speak yet). */
|
|
103
|
+
export function consentRecipeWords(lang: string | null | undefined = 'en'): ConsentRecipeWords {
|
|
104
|
+
return lang === 'he' ? CONSENT_WORDS.he : CONSENT_WORDS.en;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const CONSENT_LABELS = Object.freeze({ banner: 'Consent banner', preferences: 'Consent preferences', settings: 'Cookie settings' });
|
|
108
|
+
|
|
109
|
+
export interface ConsentRecipeOptions {
|
|
110
|
+
/** The site's language (its words and the side the buttons sit on). Default English. */
|
|
111
|
+
lang?: string | null;
|
|
112
|
+
/** The categories the site's trackers need a yes for (default both). One category: no Preferences button. */
|
|
113
|
+
categories?: ReadonlyArray<ConsentCategory>;
|
|
114
|
+
/** The privacy page's route — linked from the banner when the site has one. */
|
|
115
|
+
privacyRoute?: string | null;
|
|
116
|
+
/** The privacy link's words (the page's title). */
|
|
117
|
+
privacyLabel?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface ConsentRecipe {
|
|
121
|
+
banner: CompositeNode;
|
|
122
|
+
preferences: CompositeNode;
|
|
123
|
+
/** "Cookie settings" — the way back to the choice (a footer's legal row holds it on a generated site). */
|
|
124
|
+
settings: CompositeNode;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface Wired { interactions?: unknown[] }
|
|
128
|
+
|
|
129
|
+
/** A click on `node` runs these actions in order. */
|
|
130
|
+
function onClickRun(node: CompositeNode, actions: ReadonlyArray<{ type: ConsentActionType; target?: string }>): void {
|
|
131
|
+
(node as Wired).interactions = [{
|
|
132
|
+
id: `${node.id ?? 'node'}-click`, trigger: 'click',
|
|
133
|
+
actions: actions.map(a => ({ type: a.type, target: a.target ?? 'self', duration: 0, delay: 0, easing: 'ease' })),
|
|
134
|
+
}];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** A button whose words are its own Text (the shop and account recipes' shape). */
|
|
138
|
+
function button(create: CompositeNodeFactory, key: string, role: ConsentRole | null, style: Style, words: string, label: string,
|
|
139
|
+
base: Readonly<Record<string, string>> = {}): CompositeNode {
|
|
140
|
+
const node = recipeButton(create, key, role ?? '', style, label, '', { width: 'auto', height: 'auto', flexShrink: '0', ...base });
|
|
141
|
+
node.children = [recipeText(create, `${key}-label`, null, Style.Label, words, 'Text', WORDS, 'span')];
|
|
142
|
+
return node;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** The three roots. Pure over the factory: the builder and the composer get the same tree. */
|
|
146
|
+
export function buildConsentRecipe(create: CompositeNodeFactory, options: ConsentRecipeOptions = {}): ConsentRecipe {
|
|
147
|
+
const t = consentRecipeWords(options.lang);
|
|
148
|
+
const categories = (options.categories?.length ? options.categories : CONSENT_CHOICE_CATEGORIES)
|
|
149
|
+
.filter((c, i, all) => c !== ConsentCategory.Necessary && all.indexOf(c) === i);
|
|
150
|
+
const withPreferences = categories.length >= PREFERENCES_FROM_CATEGORIES;
|
|
151
|
+
|
|
152
|
+
// ── Preferences first: the banner's buttons name it ─────────────────────────────────────────────────────────────
|
|
153
|
+
const preferences = recipePart(create, 'consent-preferences', 'Dialog', ConsentRole.PreferencesDialog, Style.Dialog, {}, CONSENT_LABELS.preferences,
|
|
154
|
+
{ width: '480px', maxWidth: '100%', display: 'flex', flexDirection: 'column', gap: '12px' });
|
|
155
|
+
writeProp(preferences, 'placement', 'center');
|
|
156
|
+
writeProp(preferences, 'closeOnBackdrop', true);
|
|
157
|
+
writeProp(preferences, 'showCloseButton', true);
|
|
158
|
+
writeProp(preferences, 'ariaLabel', t.prefsTitle);
|
|
159
|
+
const card = (key: string, category: ConsentCategory, control: CompositeNode): CompositeNode => {
|
|
160
|
+
const node = recipePart(create, key, 'Container', ConsentRole.Category, Style.Card, {}, t.categories[category].name,
|
|
161
|
+
{ ...ROW, width: '100%', alignItems: 'flex-start', gap: '12px', padding: '12px 14px 12px 14px' });
|
|
162
|
+
const text = recipePart(create, `${key}-text`, 'Container', null, null, {}, 'Words', { ...COLUMN, flexGrow: '1', width: 'auto', gap: '2px' });
|
|
163
|
+
text.children = [
|
|
164
|
+
recipeText(create, `${key}-name`, null, Style.Body, t.categories[category].name, 'Name', { ...WORDS, fontWeight: '600' }),
|
|
165
|
+
recipeText(create, `${key}-desc`, null, Style.Body, t.categories[category].desc, 'Description'),
|
|
166
|
+
];
|
|
167
|
+
node.children = [text, control];
|
|
168
|
+
return node;
|
|
169
|
+
};
|
|
170
|
+
const switchOf = (category: ConsentCategory) => recipePart(create, `consent-${category}-switch`, 'Field', null, Style.Field,
|
|
171
|
+
// The engine's consent runtime binds the switch to the decision by its name and records on change.
|
|
172
|
+
{ label: t.categories[category].name, labelHidden: true, control: 'switch', name: `consent-${category}` }, t.categories[category].name,
|
|
173
|
+
{ width: 'auto', flexShrink: '0', minHeight: 'auto', margin: ZERO });
|
|
174
|
+
const prefsReject = button(create, 'consent-preferences-reject', null, Style.Secondary, t.reject, 'Reject all');
|
|
175
|
+
onClickRun(prefsReject, [{ type: ConsentActionType.Deny }, { type: ConsentActionType.CloseDialog, target: preferences.id }]);
|
|
176
|
+
const prefsDone = button(create, 'consent-preferences-done', null, Style.Ghost, t.done, 'Done');
|
|
177
|
+
onClickRun(prefsDone, [{ type: ConsentActionType.CloseDialog, target: preferences.id }]);
|
|
178
|
+
const prefsAccept = button(create, 'consent-preferences-accept', null, Style.Primary, t.accept, 'Accept all');
|
|
179
|
+
onClickRun(prefsAccept, [{ type: ConsentActionType.Grant }, { type: ConsentActionType.CloseDialog, target: preferences.id }]);
|
|
180
|
+
const end = recipePart(create, 'consent-preferences-end', 'Container', null, null, {}, 'Done and accept', { ...ROW, gap: '8px' });
|
|
181
|
+
end.children = [prefsDone, prefsAccept];
|
|
182
|
+
const foot = recipePart(create, 'consent-preferences-foot', 'Container', null, null, {}, 'Buttons',
|
|
183
|
+
{ ...ROW, width: '100%', flexWrap: 'wrap', justifyContent: 'space-between', gap: '8px' });
|
|
184
|
+
foot.children = [prefsReject, end];
|
|
185
|
+
preferences.children = [
|
|
186
|
+
recipePart(create, 'consent-preferences-title', 'Heading', null, Style.Title, { content: t.prefsTitle, level: 'h2' }, 'Title', WORDS),
|
|
187
|
+
recipeText(create, 'consent-preferences-sub', null, Style.Body, t.prefsSub, 'Where to change it'),
|
|
188
|
+
card('consent-necessary', ConsentCategory.Necessary,
|
|
189
|
+
recipeText(create, 'consent-necessary-on', null, Style.Body, t.alwaysOn, 'Always on', { ...WORDS, flexShrink: '0', fontWeight: '600' }, 'span')),
|
|
190
|
+
...categories.map(c => card(`consent-${c}`, c, switchOf(c))),
|
|
191
|
+
foot,
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
// ── The banner ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
195
|
+
const banner = recipePart(create, 'consent-banner', 'Dialog', ConsentRole.Banner, Style.Dialog, {}, CONSENT_LABELS.banner,
|
|
196
|
+
{ width: '100%', maxWidth: '100%', display: 'flex', flexDirection: 'column', gap: '0px' });
|
|
197
|
+
writeProp(banner, 'consentRole', true);
|
|
198
|
+
writeProp(banner, 'placement', 'bottom');
|
|
199
|
+
writeProp(banner, 'closeOnBackdrop', false); // clicking away is not consent
|
|
200
|
+
writeProp(banner, 'showCloseButton', true); // the runtime records ✕ as a no
|
|
201
|
+
writeProp(banner, 'ariaLabel', t.title);
|
|
202
|
+
const words = recipePart(create, 'consent-words', 'Container', null, null, {}, 'Words', { ...COLUMN, flexGrow: '1', width: 'auto', gap: '4px' });
|
|
203
|
+
words.children = [
|
|
204
|
+
recipePart(create, 'consent-title', 'Heading', ConsentRole.Title, Style.Title, { content: t.title, level: 'h2' }, 'Title', WORDS),
|
|
205
|
+
recipeText(create, 'consent-body', ConsentRole.Body, Style.Body, t.body, 'Words', { ...WORDS, maxWidth: '560px' }),
|
|
206
|
+
...(options.privacyRoute
|
|
207
|
+
? [recipePart(create, 'consent-privacy', 'Link', ConsentRole.Privacy, Style.Link,
|
|
208
|
+
{ label: options.privacyLabel || 'Privacy policy', linkType: 'page', pageRoute: options.privacyRoute }, 'Privacy policy', WORDS)]
|
|
209
|
+
: []),
|
|
210
|
+
];
|
|
211
|
+
const accept = button(create, 'consent-accept', ConsentRole.Accept, Style.Primary, t.accept, 'Accept all');
|
|
212
|
+
onClickRun(accept, [{ type: ConsentActionType.Grant }, { type: ConsentActionType.CloseDialog, target: banner.id }]);
|
|
213
|
+
const reject = button(create, 'consent-reject', ConsentRole.Reject, Style.Secondary, t.reject, 'Reject all');
|
|
214
|
+
onClickRun(reject, [{ type: ConsentActionType.Deny }, { type: ConsentActionType.CloseDialog, target: banner.id }]);
|
|
215
|
+
const choices = recipePart(create, 'consent-choices', 'Container', ConsentRole.Choices, null, {}, 'Accept and reject', { ...ROW, gap: '8px' });
|
|
216
|
+
choices.children = [accept, reject];
|
|
217
|
+
const buttons = recipePart(create, 'consent-buttons', 'Container', null, null, {}, 'Buttons',
|
|
218
|
+
{ ...COLUMN, width: 'auto', flexShrink: '0', alignItems: 'center', gap: '6px' });
|
|
219
|
+
buttons.children = [choices];
|
|
220
|
+
if (withPreferences) {
|
|
221
|
+
const prefs = button(create, 'consent-open-preferences', ConsentRole.Preferences, Style.Ghost, t.preferences, 'Preferences');
|
|
222
|
+
onClickRun(prefs, [{ type: ConsentActionType.OpenPreferences, target: preferences.id }]);
|
|
223
|
+
buttons.children.push(prefs);
|
|
224
|
+
}
|
|
225
|
+
const row = recipePart(create, 'consent-row', 'Container', null, null, {}, 'Banner row',
|
|
226
|
+
{ ...ROW, width: '100%', flexWrap: 'wrap', justifyContent: 'space-between', gap: '16px' });
|
|
227
|
+
row.children = [words, buttons];
|
|
228
|
+
banner.children = [row];
|
|
229
|
+
|
|
230
|
+
// ── The way back ───────────────────────────────────────────────────────────────────────────────────────────────
|
|
231
|
+
const settings = button(create, 'consent-settings', ConsentRole.Settings, Style.Ghost, t.settings, CONSENT_LABELS.settings);
|
|
232
|
+
onClickRun(settings, [{ type: ConsentActionType.OpenPreferences, target: preferences.id }]);
|
|
233
|
+
|
|
234
|
+
return { banner, preferences, settings };
|
|
235
|
+
}
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import type { ChannelKind } from './channel';
|
|
10
|
+
import { STORE_ACTION } from './collect';
|
|
11
|
+
import type { SubmitAction } from './form.model';
|
|
10
12
|
|
|
11
13
|
export enum FormPresetId {
|
|
12
14
|
Contact = 'contact',
|
|
@@ -55,6 +57,10 @@ export interface FormPresetDef {
|
|
|
55
57
|
successText: string;
|
|
56
58
|
errorText: string;
|
|
57
59
|
channel?: FormPresetChannel;
|
|
60
|
+
/** What happens after the answers are stored (iox-cms#84): the steps beside `store`, which is always first. A preset
|
|
61
|
+
* that says it emails the owner carries `{ type: 'email', config: { toOwner: true } }` — the address is the studio
|
|
62
|
+
* owner's account, read by the server at delivery, never written into a page. */
|
|
63
|
+
actions?: readonly SubmitAction[];
|
|
58
64
|
/** `false`: the AI plan wire does not offer it yet (the lead preset ships in the builder in M3; generation takes it
|
|
59
65
|
* up in premium M8 — the wire's enum is model-facing and does not change before then). */
|
|
60
66
|
inPlan?: false;
|
|
@@ -79,6 +85,7 @@ export const FORM_PRESETS: readonly FormPresetDef[] = /* @__PURE__ */ Object.fre
|
|
|
79
85
|
{ label: 'Email', control: 'email', required: true },
|
|
80
86
|
{ label: 'Message', control: 'textarea', required: true, rows: 5 },
|
|
81
87
|
],
|
|
88
|
+
actions: [{ type: 'email', config: { toOwner: true } }],
|
|
82
89
|
submitLabel: 'Send message',
|
|
83
90
|
successText: 'Thanks — we’ll be in touch shortly.',
|
|
84
91
|
errorText: 'We couldn’t send your message. Please try again — your answers are still here.',
|
|
@@ -125,6 +132,7 @@ export const FORM_PRESETS: readonly FormPresetDef[] = /* @__PURE__ */ Object.fre
|
|
|
125
132
|
{ label: 'People', control: 'number', required: true },
|
|
126
133
|
{ label: 'Notes', control: 'textarea', rows: 3, help: 'Allergies, access needs, anything useful' },
|
|
127
134
|
],
|
|
135
|
+
actions: [{ type: 'email', config: { toOwner: true } }],
|
|
128
136
|
submitLabel: 'Request a booking',
|
|
129
137
|
successText: 'Request received — we’ll confirm by email.',
|
|
130
138
|
errorText: 'We couldn’t send your request. Please try again.',
|
|
@@ -156,3 +164,23 @@ export const FORM_PRESETS: readonly FormPresetDef[] = /* @__PURE__ */ Object.fre
|
|
|
156
164
|
export function formPresetById(id: string | null | undefined): FormPresetDef | undefined {
|
|
157
165
|
return FORM_PRESETS.find(p => p.id === id);
|
|
158
166
|
}
|
|
167
|
+
|
|
168
|
+
/** The config key of an email step that goes to the studio owner's account address (iox-cms#84). */
|
|
169
|
+
export const EMAIL_TO_OWNER = 'toOwner';
|
|
170
|
+
|
|
171
|
+
/** True for an email step that goes to the studio owner — ONE reading for the server's delivery and the builder's panel. */
|
|
172
|
+
export function emailsOwner(action: Pick<SubmitAction, 'type' | 'config'> | null | undefined): boolean {
|
|
173
|
+
return action?.type === 'email' && action.config?.[EMAIL_TO_OWNER] === true;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A preset's `actions` trait, as a Form stamped from it holds it: `store` first, then the preset's own steps — fresh
|
|
178
|
+
* objects every call (a stamped node is edited in place). Null when the preset has no step of its own, so the Form keeps
|
|
179
|
+
* its type's default (`[store]`). The builder's tray (`buildFormPreset`) and the composer (`stampPresetForm`) both
|
|
180
|
+
* write this — ONE recipe (R-H9).
|
|
181
|
+
*/
|
|
182
|
+
export function presetFormActions(def: Pick<FormPresetDef, 'actions'> | null | undefined): SubmitAction[] | null {
|
|
183
|
+
if (!def?.actions?.length) return null;
|
|
184
|
+
const copy = (a: SubmitAction): SubmitAction => ({ ...a, ...(a.config ? { config: { ...a.config } } : {}) });
|
|
185
|
+
return [{ ...STORE_ACTION }, ...def.actions.filter(a => a.type !== STORE_ACTION.type).map(copy)];
|
|
186
|
+
}
|
|
@@ -2,9 +2,11 @@ import { ELEMENT_ACTION_DESCRIPTORS, resolveActionAvailability } from '@vectorio
|
|
|
2
2
|
import { CheckoutGateCode, CheckoutGateRefusal, labelIn } from '@vectoriox/iox-ui/commerce-core';
|
|
3
3
|
import { ShopRole } from '@vectoriox/iox-ui/composite-core';
|
|
4
4
|
import { auditDesignContrast, DesignTokenLike } from '@vectoriox/iox-ui/design-core';
|
|
5
|
-
import {
|
|
5
|
+
import { ConsentActionType } from '@vectoriox/iox-ui/composite-core';
|
|
6
|
+
import { collectFormSpec, FORM_CHANNEL_ROLE, FORM_NODE_TYPE, isChannelFilled } from '@vectoriox/iox-ui/forms-core';
|
|
6
7
|
|
|
7
8
|
import { blocksPublish, ComposedPlaceholder, PlaceholderKind } from './compose-site';
|
|
9
|
+
import { formAsksPersonalData, isLegalKind, ISRAEL, LegalKind, legalKindBlocks, legalTitle } from './legal';
|
|
8
10
|
import { navShapeOf } from './nav-shape';
|
|
9
11
|
import { PatternGlobalPosition } from './patterns';
|
|
10
12
|
import { SerializedNode, walkSerialized } from './serialized-node';
|
|
@@ -77,7 +79,20 @@ export enum SiteFindingCode {
|
|
|
77
79
|
/** M7: a picture the build could not make (its review said no twice) and nothing stood in for: an empty box. */
|
|
78
80
|
PictureMissing = 'picture-missing',
|
|
79
81
|
NoPrivacyPage = 'no-privacy-page',
|
|
80
|
-
|
|
82
|
+
/** AW1: a legal page (privacy, cookies, terms, the accessibility statement…) still shows what belongs there — only the
|
|
83
|
+
* owner can write it. The finding names its kind (`legal`). Generalises the privacy page's own finding. */
|
|
84
|
+
LegalPagePlaceholder = 'legal-page-placeholder',
|
|
85
|
+
/** AW1 (AW-D14): a site built with the law (`siteBuiltWithLaw`) in Israel or in Hebrew has no accessibility
|
|
86
|
+
* statement — it blocks until one is written (Doron 2026-11-20: "block new, warn old"). */
|
|
87
|
+
NoAccessibilityStatement = 'no-accessibility-statement',
|
|
88
|
+
/** AW1: a site that existed before the law was stamped (an Israeli or Hebrew one) has no accessibility statement —
|
|
89
|
+
* a warning only; no existing studio's publish is stopped by this rule. */
|
|
90
|
+
AccessibilityStatementAdvised = 'accessibility-statement-advised',
|
|
91
|
+
/** AW1 (R-H4): the cookie banner's Reject is weaker than its Accept — a link, another kind of element, on another row,
|
|
92
|
+
* or only inside Preferences. Refusing must be as easy as accepting. */
|
|
93
|
+
ConsentRejectWeaker = 'consent-reject-weaker',
|
|
94
|
+
/** AW1 (R-H4): the site has a cookie banner and nothing outside it reopens the choice (Cookie settings). */
|
|
95
|
+
NoCookieSettings = 'no-cookie-settings',
|
|
81
96
|
LowContrast = 'low-contrast',
|
|
82
97
|
HeadingOrder = 'heading-order',
|
|
83
98
|
ImageWithoutAlt = 'image-without-alt',
|
|
@@ -109,7 +124,11 @@ export const FINDING_SEVERITY: Readonly<Record<SiteFindingCode, CheckSeverity>>
|
|
|
109
124
|
[SiteFindingCode.MadePicture]: CheckSeverity.Ask,
|
|
110
125
|
[SiteFindingCode.PictureMissing]: CheckSeverity.Warn,
|
|
111
126
|
[SiteFindingCode.NoPrivacyPage]: CheckSeverity.Ask,
|
|
112
|
-
[SiteFindingCode.
|
|
127
|
+
[SiteFindingCode.LegalPagePlaceholder]: CheckSeverity.Block,
|
|
128
|
+
[SiteFindingCode.NoAccessibilityStatement]: CheckSeverity.Block,
|
|
129
|
+
[SiteFindingCode.AccessibilityStatementAdvised]: CheckSeverity.Warn,
|
|
130
|
+
[SiteFindingCode.ConsentRejectWeaker]: CheckSeverity.Block,
|
|
131
|
+
[SiteFindingCode.NoCookieSettings]: CheckSeverity.Warn,
|
|
113
132
|
[SiteFindingCode.LowContrast]: CheckSeverity.Warn,
|
|
114
133
|
[SiteFindingCode.HeadingOrder]: CheckSeverity.Warn,
|
|
115
134
|
[SiteFindingCode.ImageWithoutAlt]: CheckSeverity.Warn,
|
|
@@ -140,7 +159,11 @@ const CHECK_OF: Readonly<Record<SiteFindingCode, SiteCheckId>> = {
|
|
|
140
159
|
[SiteFindingCode.MadePicture]: SiteCheckId.Facts,
|
|
141
160
|
[SiteFindingCode.PictureMissing]: SiteCheckId.Facts,
|
|
142
161
|
[SiteFindingCode.NoPrivacyPage]: SiteCheckId.Facts,
|
|
143
|
-
[SiteFindingCode.
|
|
162
|
+
[SiteFindingCode.LegalPagePlaceholder]: SiteCheckId.Facts,
|
|
163
|
+
[SiteFindingCode.NoAccessibilityStatement]: SiteCheckId.Accessibility,
|
|
164
|
+
[SiteFindingCode.AccessibilityStatementAdvised]: SiteCheckId.Accessibility,
|
|
165
|
+
[SiteFindingCode.ConsentRejectWeaker]: SiteCheckId.Consent,
|
|
166
|
+
[SiteFindingCode.NoCookieSettings]: SiteCheckId.Consent,
|
|
144
167
|
[SiteFindingCode.LowContrast]: SiteCheckId.Accessibility,
|
|
145
168
|
[SiteFindingCode.HeadingOrder]: SiteCheckId.Accessibility,
|
|
146
169
|
[SiteFindingCode.ImageWithoutAlt]: SiteCheckId.Accessibility,
|
|
@@ -162,6 +185,8 @@ export interface SiteFinding {
|
|
|
162
185
|
owner?: string;
|
|
163
186
|
/** `store-fact` / `store-contact`: the checkout gate's code (commerce-core `CheckoutGateCode`) — which fact, so a screen can open where it is answered. */
|
|
164
187
|
fact?: string;
|
|
188
|
+
/** `legal-page-placeholder`: the legal page's kind (generation-core `LegalKind`). */
|
|
189
|
+
legal?: string;
|
|
165
190
|
}
|
|
166
191
|
|
|
167
192
|
export interface SiteCheck {
|
|
@@ -183,6 +208,9 @@ export interface AuditPage {
|
|
|
183
208
|
route: string;
|
|
184
209
|
layout: ReadonlyArray<SerializedNode>;
|
|
185
210
|
seo?: unknown;
|
|
211
|
+
/** AW1: the legal kind the page says it is (`pageSettings.legal`) — how the gate finds the privacy page and the
|
|
212
|
+
* accessibility statement. A hand-built page has none (found by a word in its name or route). */
|
|
213
|
+
legal?: string | null;
|
|
186
214
|
}
|
|
187
215
|
|
|
188
216
|
/** A placeholder a build left, and whether the node still shows it (the caller compares the node's text). */
|
|
@@ -218,6 +246,13 @@ export interface SiteAuditSnapshot {
|
|
|
218
246
|
made?: ReadonlyArray<{ nodeId: string; pageId?: string; owner?: string }>;
|
|
219
247
|
/** M7: picture slots the build could not make a picture for, still empty. */
|
|
220
248
|
missing?: ReadonlyArray<{ nodeId: string; pageId?: string; owner?: string }>;
|
|
249
|
+
/** AW1: the site's language (its pages' locale). */
|
|
250
|
+
locale?: string | null;
|
|
251
|
+
/** AW1: the studio's country, ISO 3166-1 alpha-2 (Shop ▸ Settings; a shekel studio is in Israel) — null unknown. */
|
|
252
|
+
country?: string | null;
|
|
253
|
+
/** AW1: the site was built with the law — a site-build run carried the AW1 legal context (iox-cms stores it on the
|
|
254
|
+
* run as `decisions.legal`). With a page that says its legal kind, the signal `siteBuiltWithLaw` reads. */
|
|
255
|
+
legalBuilt?: boolean | null;
|
|
221
256
|
}
|
|
222
257
|
|
|
223
258
|
export interface SiteAuditOptions {
|
|
@@ -227,8 +262,13 @@ export interface SiteAuditOptions {
|
|
|
227
262
|
|
|
228
263
|
const LINKING_TYPES = new Set(['Link', 'Heading', 'Button', 'ButtonBlock', 'LinkedContainer', 'Image']);
|
|
229
264
|
const PAGE_LINK = 'page';
|
|
230
|
-
|
|
231
|
-
|
|
265
|
+
/** A hand-built site's legal pages, found by a word in their name or route (a generated page says its kind). */
|
|
266
|
+
// "מדיניות" alone is any policy (cookies, returns) — only "פרטיות" names privacy.
|
|
267
|
+
const HAND_BUILT_LEGAL: Readonly<Partial<Record<LegalKind, RegExp>>> = {
|
|
268
|
+
[LegalKind.Privacy]: /privacy|פרטיות/i,
|
|
269
|
+
[LegalKind.Accessibility]: /accessib|נגישות/i,
|
|
270
|
+
};
|
|
271
|
+
const HEBREW = 'he';
|
|
232
272
|
const MAILER = 'mailer';
|
|
233
273
|
const EMAIL_DELIVERY = 'email';
|
|
234
274
|
const LITERAL_COLOUR = /#[0-9a-f]{3,8}\b|rgba?\(|hsla?\(/i;
|
|
@@ -288,7 +328,7 @@ interface Ctx {
|
|
|
288
328
|
nodeIds: Map<string, string>;
|
|
289
329
|
}
|
|
290
330
|
|
|
291
|
-
function add(ctx: Ctx, code: SiteFindingCode, message: string, where: { pageId?: string; nodeId?: string; owner?: string; fact?: string } = {}): void {
|
|
331
|
+
function add(ctx: Ctx, code: SiteFindingCode, message: string, where: { pageId?: string; nodeId?: string; owner?: string; fact?: string; legal?: string } = {}): void {
|
|
292
332
|
ctx.out.push({ check: CHECK_OF[code], severity: FINDING_SEVERITY[code], code, message, ...where });
|
|
293
333
|
}
|
|
294
334
|
|
|
@@ -316,8 +356,8 @@ function checkForms(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArray<
|
|
|
316
356
|
if (spec?.actions.some(a => a.type === EMAIL_DELIVERY) && snapshot.connectors[MAILER] !== true) {
|
|
317
357
|
add(ctx, SiteFindingCode.EmailNeedsMailer, 'A form emails what visitors send, but Email is not connected — it is stored and never sent.', { ...where, nodeId: n.id });
|
|
318
358
|
}
|
|
359
|
+
if (formAsksPersonalData(n)) personal = true;
|
|
319
360
|
walkSerialized(n.children ?? [], f => {
|
|
320
|
-
if (f.type === FIELD_NODE_TYPE && PERSONAL_CONTROLS.has(String(f.props['control'] ?? ControlType.Text))) personal = true;
|
|
321
361
|
if (f.role === FORM_CHANNEL_ROLE && !isChannelFilled(f.props['href'])) {
|
|
322
362
|
add(ctx, SiteFindingCode.EmptyChannel, 'A form\'s second way to reach you has no number or address yet — visitors do not see it until you fill it in.', { ...where, nodeId: f.id });
|
|
323
363
|
}
|
|
@@ -326,11 +366,66 @@ function checkForms(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArray<
|
|
|
326
366
|
return personal;
|
|
327
367
|
}
|
|
328
368
|
|
|
369
|
+
interface RanAction { type?: string; target?: string; disabled?: boolean }
|
|
370
|
+
|
|
371
|
+
/** The actions a node's own interactions run, in order. */
|
|
372
|
+
function actionsOf(node: SerializedNode): RanAction[] {
|
|
373
|
+
return ((node.interactions ?? []) as Array<{ actions?: RanAction[] }>).flatMap(ix => ix?.actions ?? []);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** True when a node's own interactions run an action of `type`. */
|
|
377
|
+
function runs(node: SerializedNode, type: string): boolean {
|
|
378
|
+
return actionsOf(node).some(a => a?.type === type && !a.disabled);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** A control the banner runs an action from, and the row it sits on. */
|
|
382
|
+
interface Pressed {
|
|
383
|
+
node: SerializedNode;
|
|
384
|
+
row: SerializedNode | null;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Elements that read as a link, never a button: a Reject drawn as one is weaker than its Accept (R-H4). */
|
|
388
|
+
const LINK_LIKE: ReadonlySet<string> = new Set(['Link', 'Text']);
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* THE consent judge (AW1, CONSENT `rules` — one judge, grown here): a tracker needs a banner; a banner's Reject is never
|
|
392
|
+
* weaker than its Accept (the same kind of element, on the same row, on the first layer — never a link, never only inside
|
|
393
|
+
* Preferences); and something outside the banner reopens the choice (Cookie settings).
|
|
394
|
+
*/
|
|
329
395
|
function checkConsent(ctx: Ctx, snapshot: SiteAuditSnapshot): void {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
396
|
+
const banners: SerializedNode[] = [];
|
|
397
|
+
for (const g of snapshot.globals) walkSerialized([g], n => { if (n.type === DIALOG_TYPE && n.props['consentRole'] === true) banners.push(n); });
|
|
398
|
+
if (snapshot.trackers?.length && !banners.length) {
|
|
399
|
+
add(ctx, SiteFindingCode.TrackerWithoutBanner, `${snapshot.trackers.join(', ')} is connected, but the site has no cookie banner — it stays off for every visitor.`);
|
|
400
|
+
}
|
|
401
|
+
for (const banner of banners) {
|
|
402
|
+
const accept: Pressed[] = [];
|
|
403
|
+
const reject: Pressed[] = [];
|
|
404
|
+
walkSerialized([banner], (n, ancestors) => {
|
|
405
|
+
const row = ancestors[ancestors.length - 1] ?? null;
|
|
406
|
+
if (runs(n, ConsentActionType.Grant)) accept.push({ node: n, row });
|
|
407
|
+
if (runs(n, ConsentActionType.Deny)) reject.push({ node: n, row });
|
|
408
|
+
});
|
|
409
|
+
const weaker = !reject.length || reject.every(r => LINK_LIKE.has(r.node.type)
|
|
410
|
+
|| !accept.some(a => a.node.type === r.node.type && a.row === r.row));
|
|
411
|
+
if (weaker) {
|
|
412
|
+
add(ctx, SiteFindingCode.ConsentRejectWeaker, !reject.length
|
|
413
|
+
? 'The cookie banner has no Reject beside Accept — refusing must be as easy as accepting.'
|
|
414
|
+
: 'The cookie banner\'s Reject is weaker than its Accept — make it the same kind of button, on the same row.', { owner: 'footer', nodeId: banner.id });
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (!banners.length) return;
|
|
418
|
+
const inBanner = new Set<string>();
|
|
419
|
+
for (const b of banners) walkSerialized([b], n => inBanner.add(n.id));
|
|
420
|
+
// The preferences dialogs the banners open are part of the choice too, not a way back to it.
|
|
421
|
+
const prefs = new Set<string>();
|
|
422
|
+
for (const b of banners) walkSerialized([b], n => {
|
|
423
|
+
for (const a of actionsOf(n)) if (a.type === ConsentActionType.OpenPreferences && a.target) prefs.add(a.target);
|
|
424
|
+
});
|
|
425
|
+
for (const g of snapshot.globals) if (prefs.has(g.id)) walkSerialized([g], n => inBanner.add(n.id));
|
|
426
|
+
let reopens = false;
|
|
427
|
+
eachNode(snapshot, snapshot.pages, n => { if (!inBanner.has(n.id) && runs(n, ConsentActionType.OpenPreferences)) reopens = true; });
|
|
428
|
+
if (!reopens) add(ctx, SiteFindingCode.NoCookieSettings, 'Nothing on the site reopens the cookie choice — add Cookie settings to the footer so visitors can change their mind.');
|
|
334
429
|
}
|
|
335
430
|
|
|
336
431
|
function checkSeo(ctx: Ctx, pages: ReadonlyArray<AuditPage>): void {
|
|
@@ -361,15 +456,70 @@ function checkFacts(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArray<
|
|
|
361
456
|
for (const s of (snapshot.stock ?? []).filter(inScope)) add(ctx, SiteFindingCode.StockPhoto, 'A stock photo stands in for one of yours.', { pageId: s.pageId, nodeId: s.nodeId, owner: s.owner });
|
|
362
457
|
for (const s of (snapshot.made ?? []).filter(inScope)) add(ctx, SiteFindingCode.MadePicture, 'A picture made with AI stands in for one of yours.', { pageId: s.pageId, nodeId: s.nodeId, owner: s.owner });
|
|
363
458
|
for (const s of (snapshot.missing ?? []).filter(inScope)) add(ctx, SiteFindingCode.PictureMissing, 'A picture could not be made for this spot — add one of yours.', { pageId: s.pageId, nodeId: s.nodeId, owner: s.owner });
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
459
|
+
checkLegalPages(ctx, snapshot, pages, personal);
|
|
460
|
+
if (personal && !legalPageOf(snapshot.pages, LegalKind.Privacy)) {
|
|
461
|
+
add(ctx, SiteFindingCode.NoPrivacyPage, 'A form asks for personal details, and the site has no privacy page saying what you do with them.');
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
const isIsraeli = (snapshot: SiteAuditSnapshot): boolean => String(snapshot.country ?? '').trim().toUpperCase() === ISRAEL;
|
|
466
|
+
|
|
467
|
+
/** Israel requires an accessibility statement; a Hebrew site elsewhere is expected to carry one. */
|
|
468
|
+
const wantsAccessibilityStatement = (snapshot: SiteAuditSnapshot): boolean => isIsraeli(snapshot) || snapshot.locale === HEBREW;
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* "Block new, warn old" (Doron, 2026-11-20): is this a site the generator built WITH the law? Read from what is STORED,
|
|
472
|
+
* never a date: a site-build run that carried the AW1 legal context (`legalBuilt`), or a page that says its legal kind
|
|
473
|
+
* (`pageSettings.legal` — only AW1's composer writes it). Such a site is held until its accessibility statement is
|
|
474
|
+
* written; a site that existed before is warned only.
|
|
475
|
+
*/
|
|
476
|
+
export function siteBuiltWithLaw(snapshot: Pick<SiteAuditSnapshot, 'legalBuilt' | 'pages'>): boolean {
|
|
477
|
+
return snapshot.legalBuilt === true || snapshot.pages.some(p => isLegalKind(p.legal));
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/** The site's page of a legal kind: the one that says so, else (a hand-built site) one whose name or route says it. */
|
|
481
|
+
export function legalPageOf(pages: ReadonlyArray<AuditPage>, kind: LegalKind): AuditPage | undefined {
|
|
482
|
+
const word = HAND_BUILT_LEGAL[kind];
|
|
483
|
+
return pages.find(p => p.legal === kind) ?? (word ? pages.find(p => !isLegalKind(p.legal) && (word.test(p.route) || word.test(p.name))) : undefined);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/** The kind a page is to the gate: what it says, else the hand-built word its name or route carries. */
|
|
487
|
+
function legalKindOfAudited(page: AuditPage): LegalKind | null {
|
|
488
|
+
if (isLegalKind(page.legal)) return page.legal;
|
|
489
|
+
for (const [kind, word] of Object.entries(HAND_BUILT_LEGAL) as Array<[LegalKind, RegExp]>) if (word.test(page.route) || word.test(page.name)) return kind;
|
|
490
|
+
return null;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* AW1: a legal page that still shows what belongs there holds Publish — only the owner can write it (D-C7). The page
|
|
495
|
+
* itself, and every publish a law ties to it: a page with a personal-data form needs its privacy page written, and an
|
|
496
|
+
* Israeli site's every page needs its accessibility statement.
|
|
497
|
+
*/
|
|
498
|
+
function checkLegalPages(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArray<AuditPage>, personal: boolean): void {
|
|
499
|
+
const open = (snapshot.placeholders ?? []).filter(p => !p.filled && p.pageId);
|
|
500
|
+
const built = siteBuiltWithLaw(snapshot);
|
|
501
|
+
const tied = [
|
|
502
|
+
personal ? legalPageOf(snapshot.pages, LegalKind.Privacy) : undefined,
|
|
503
|
+
built && wantsAccessibilityStatement(snapshot) ? legalPageOf(snapshot.pages, LegalKind.Accessibility) : undefined,
|
|
504
|
+
];
|
|
505
|
+
const judged = [...new Set([...pages, ...tied.filter((p): p is AuditPage => !!p)])];
|
|
506
|
+
for (const page of judged) {
|
|
507
|
+
const kind = legalKindOfAudited(page);
|
|
508
|
+
if (!kind || !legalKindBlocks(kind) || !open.some(p => p.pageId === page.id)) continue;
|
|
509
|
+
// Warn old: a site from before the law is never held by its accessibility statement.
|
|
510
|
+
if (kind === LegalKind.Accessibility && !built) continue;
|
|
511
|
+
add(ctx, SiteFindingCode.LegalPagePlaceholder, `"${page.name || legalTitle(kind, snapshot.locale)}" still says what belongs there — only you can write it.`, { pageId: page.id, legal: kind });
|
|
369
512
|
}
|
|
370
513
|
}
|
|
371
514
|
|
|
372
515
|
function checkAccessibility(ctx: Ctx, snapshot: SiteAuditSnapshot, pages: ReadonlyArray<AuditPage>): void {
|
|
516
|
+
// AW1 (AW-D14): Israel requires an accessibility statement; a Hebrew site elsewhere is expected to carry one. Block
|
|
517
|
+
// new, warn old: only a site built with the law is held (`siteBuiltWithLaw`).
|
|
518
|
+
if (wantsAccessibilityStatement(snapshot) && !legalPageOf(snapshot.pages, LegalKind.Accessibility)) {
|
|
519
|
+
const why = isIsraeli(snapshot) ? 'Israel requires one' : 'a Hebrew site is expected to carry one';
|
|
520
|
+
if (siteBuiltWithLaw(snapshot)) add(ctx, SiteFindingCode.NoAccessibilityStatement, `The site has no accessibility statement — ${why}. Add a page for it and write what is accessible and who to contact.`);
|
|
521
|
+
else add(ctx, SiteFindingCode.AccessibilityStatementAdvised, `The site has no accessibility statement — ${why}. Add a page for it.`);
|
|
522
|
+
}
|
|
373
523
|
for (const mode of snapshot.design?.modes ?? []) {
|
|
374
524
|
const failing = auditDesignContrast(snapshot.design!.rows, mode).filter(f => !f.pass);
|
|
375
525
|
if (failing.length) add(ctx, SiteFindingCode.LowContrast, `${failing.length} text and background pair(s) are hard to read in ${mode} mode.`);
|