@vectoriox/iox-ui 5.201.0 → 5.202.1
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/design-core/index.d.ts +162 -5
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +216 -12
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +2665 -1299
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +28 -12
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +85 -1
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +968 -263
- package/harness-core/index.d.ts +21 -13
- package/index.d.ts +50 -2
- package/package.json +1 -1
- package/src/design-core/brand-neutrals.ts +50 -7
- package/src/design-core/colour-words.ts +22 -5
- package/src/design-core/design-settings.ts +5 -0
- package/src/design-core/design-token.model.ts +3 -0
- package/src/design-core/flavor-fixtures.generated.ts +38 -2
- package/src/design-core/flavor-spec.generated.ts +143 -1
- package/src/design-core/flavor-tokens.ts +6 -2
- package/src/generation-core/check-free.ts +36 -16
- package/src/generation-core/colour-mix.ts +70 -14
- package/src/generation-core/compose-site.ts +139 -27
- package/src/generation-core/fallback-memory.ts +8 -5
- package/src/generation-core/footer-free.ts +439 -0
- package/src/generation-core/footer-mix.ts +130 -36
- package/src/generation-core/free-parts.ts +3 -0
- package/src/generation-core/free-slot-words.ts +3 -0
- package/src/generation-core/free-wire.ts +10 -2
- package/src/generation-core/layout-fingerprint.ts +6 -4
- package/src/generation-core/opening-mix.ts +61 -0
- package/src/generation-core/plan-wire.ts +1 -0
- package/src/generation-core/public-api.ts +1 -0
- package/src/generation-core/redesign-run.ts +45 -2
- package/src/generation-core/site-plan.model.ts +6 -0
- package/src/generation-core/site-spec.generated.ts +599 -22
- package/src/generation-core/validate-site-plan.ts +39 -1
- package/src/harness-core/business-types.ts +3 -1
- package/src/harness-core/harness-spec.generated.ts +24 -12
- package/src/harness-core/run-compose-context.ts +8 -1
- package/styles/iox-design.css +17 -5
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { DesignTokenLike, ResolvedMode } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
|
|
3
|
+
import { FreeIssue, FreeIssueCode, freeNodeStyleIssues, freePhoneNeeds, FreeSlotOffer } from './check-free';
|
|
4
|
+
import {
|
|
5
|
+
checkFooter, FOOTER_GROUND_SCHEME, FooterArrange, FooterBefore, FooterClosing, FooterContext, FooterGround, FooterHold, FooterIngredient,
|
|
6
|
+
footerMeaning, FooterMix, footerMix, FooterNameStyle, footerPart, footerPartNode, footerPattern, FooterRepair, FooterRepairCode, FooterRole, footerTableWords,
|
|
7
|
+
footerWait, footerWordOffered, footerWords,
|
|
8
|
+
} from './footer-mix';
|
|
9
|
+
import { freeSlotOf, FreeSlotKind, freeSlotWord } from './free-slot-words';
|
|
10
|
+
import { freeStyleToSlots } from './free-slots';
|
|
11
|
+
import { expandFreeWire, FreeLayer, FreeNode, FreeNodeType, FreePage, FreePurpose, freeSchemeOf, FreeStyle, walkFree } from './free-wire';
|
|
12
|
+
import { NODE_BASELINES } from './node-baselines.generated';
|
|
13
|
+
import { PatternGlobalPosition, PatternNode, SitePattern } from './patterns';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* THE FREE FOOTER (footer-v2-plan §4, FV2; FV-D1…FV-D6, FV-D12). The footer becomes a free section in the FS3 language —
|
|
17
|
+
* Containers with the free styles, tokens for every colour, start / end only, a phone layer where a phone needs one —
|
|
18
|
+
* whose ONLY content is the FOOTER table's parts, placed as Slots `footer:<part>`: the model decides WHERE things go and how
|
|
19
|
+
* big they are, never WHAT they say (FV-D4: no word of its own). Every part is stamped by THE recipe the mix footer uses
|
|
20
|
+
* (`footerPartNode`, footer-mix.ts), the legal row is compose-site's (`legalRow`, placed where the `legal` slot stands —
|
|
21
|
+
* else appended), and the ground is a word of the table (`ground:<word>` on the Section), so the schemes keep the words
|
|
22
|
+
* readable (AA by the contrast audit). Four functions:
|
|
23
|
+
*
|
|
24
|
+
* - `checkFreeFooter` — the ten hard rules (§4), every issue at a path (`sections[0]…`, the footer as a one-section page, so
|
|
25
|
+
* the free request's repair names wire paths with `freeWirePath`);
|
|
26
|
+
* - `expandFreeFooter` — the footer as a pattern the composer stamps (the same stamper, the same nodes as the mix footer);
|
|
27
|
+
* - `footerMixFromFree` — the nearest mix, the fall back (FV-D12) and the classes the free root wears;
|
|
28
|
+
* - `freeFooterOrMix` — the free footer when it keeps the rules, else the nearest mix footer, said "Composed for you".
|
|
29
|
+
*
|
|
30
|
+
* A free footer has no sameness gate (FV-D5): its face (`freeFooterFaceOf`) is recorded, and the brief names the faces the
|
|
31
|
+
* studio's last sites wore. Pure.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/** The parts a free footer may place, by its slot's ref (`footer:<part>`). */
|
|
35
|
+
export enum FreeFooterPart {
|
|
36
|
+
Brand = 'brand',
|
|
37
|
+
Pages = 'pages',
|
|
38
|
+
Contact = 'contact',
|
|
39
|
+
Visit = 'visit',
|
|
40
|
+
Social = 'social',
|
|
41
|
+
Top = 'top',
|
|
42
|
+
/** AW12 newsletter: the sign-up block (forms-core `newsletter`), where the model lays it. */
|
|
43
|
+
Newsletter = 'newsletter',
|
|
44
|
+
Call = 'call',
|
|
45
|
+
Name = 'name',
|
|
46
|
+
Statement = 'statement',
|
|
47
|
+
Word = 'word',
|
|
48
|
+
Email = 'email',
|
|
49
|
+
ContactForm = 'contact-form',
|
|
50
|
+
/** Where the legal row goes (rule 1) — compose-site's `legalRow`, never a part. */
|
|
51
|
+
Legal = 'legal',
|
|
52
|
+
Copyright = 'copyright',
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The table word a part stands for (it is offered while the word is drawn, at the tier, and not refused by the type). */
|
|
56
|
+
interface PartWord { readonly ingredient: FooterIngredient.Holds | FooterIngredient.Closing | FooterIngredient.Before; readonly word: string }
|
|
57
|
+
const PART_WORD: Readonly<Partial<Record<FreeFooterPart, PartWord>>> = {
|
|
58
|
+
[FreeFooterPart.Pages]: { ingredient: FooterIngredient.Holds, word: FooterHold.Pages },
|
|
59
|
+
[FreeFooterPart.Contact]: { ingredient: FooterIngredient.Holds, word: FooterHold.Contact },
|
|
60
|
+
[FreeFooterPart.Visit]: { ingredient: FooterIngredient.Holds, word: FooterHold.Visit },
|
|
61
|
+
[FreeFooterPart.Social]: { ingredient: FooterIngredient.Holds, word: FooterHold.Social },
|
|
62
|
+
[FreeFooterPart.Top]: { ingredient: FooterIngredient.Holds, word: FooterHold.Top },
|
|
63
|
+
[FreeFooterPart.Newsletter]: { ingredient: FooterIngredient.Holds, word: FooterHold.Newsletter },
|
|
64
|
+
[FreeFooterPart.Call]: { ingredient: FooterIngredient.Closing, word: FooterClosing.Call },
|
|
65
|
+
[FreeFooterPart.Name]: { ingredient: FooterIngredient.Closing, word: FooterClosing.Name },
|
|
66
|
+
[FreeFooterPart.Statement]: { ingredient: FooterIngredient.Closing, word: FooterClosing.Statement },
|
|
67
|
+
[FreeFooterPart.Word]: { ingredient: FooterIngredient.Closing, word: FooterClosing.Word },
|
|
68
|
+
[FreeFooterPart.Email]: { ingredient: FooterIngredient.Closing, word: FooterClosing.Email },
|
|
69
|
+
[FreeFooterPart.ContactForm]: { ingredient: FooterIngredient.Before, word: FooterBefore.ContactForm },
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* The drawn words that are no part of their own: `name-and-action`'s end block is a layout of its own (AW12-D3) — a free
|
|
73
|
+
* footer places the name and the call as their own parts; `closing.newsletter` is the sign-up set in the call's place — a
|
|
74
|
+
* free footer places `footer:newsletter` wherever it closes; `none` is no closing. footer-free.spec holds every other drawn
|
|
75
|
+
* hold and closing to a part, so a word drawn later is offered here or named here.
|
|
76
|
+
*/
|
|
77
|
+
export const FREE_FOOTER_NO_PART: ReadonlyArray<string> = [
|
|
78
|
+
`${FooterIngredient.Closing}.${FooterClosing.NameAndAction}`, `${FooterIngredient.Closing}.${FooterClosing.Newsletter}`, `${FooterIngredient.Closing}.${FooterClosing.None}`,
|
|
79
|
+
];
|
|
80
|
+
|
|
81
|
+
/** The parts fitted to the column (the name, the call word, the email): they stand at the column's full width. */
|
|
82
|
+
const COLUMN_PARTS: ReadonlyArray<string> = [FreeFooterPart.Name, FreeFooterPart.Word, FreeFooterPart.Email];
|
|
83
|
+
/** The option every part may carry: centred through and through. */
|
|
84
|
+
export const FREE_FOOTER_CENTRED = 'align:center';
|
|
85
|
+
/** `footer:pages`' option: one row of links, not a labelled column. */
|
|
86
|
+
export const FREE_FOOTER_PAGE_ROW = 'pages:row';
|
|
87
|
+
/** The ingredient a footer Section's ground word is written under (`ground:inverse`). */
|
|
88
|
+
const GROUND = `${FooterIngredient.Ground}:`;
|
|
89
|
+
const NAME_STYLE = `${FooterIngredient.NameStyle}:`;
|
|
90
|
+
|
|
91
|
+
/** What judging and stamping a free footer reads: the site (its name, look, facts, kind, tier — `FooterContext`) and the
|
|
92
|
+
* look's token rows (what a style's token may name). */
|
|
93
|
+
export interface FreeFooterContext extends FooterContext {
|
|
94
|
+
tokens: ReadonlyArray<DesignTokenLike>;
|
|
95
|
+
modes?: ReadonlyArray<ResolvedMode>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** May a free footer place the part at all — drawn, offered at the tier, and not refused by the kind of business (rule 9). */
|
|
99
|
+
function partAllowed(part: FreeFooterPart, ctx: FooterContext): boolean {
|
|
100
|
+
const w = PART_WORD[part];
|
|
101
|
+
if (w && (!footerWords(w.ingredient).includes(w.word) || !footerWordOffered(w.ingredient, w.word, ctx.tier))) return false;
|
|
102
|
+
return !(w?.ingredient === FooterIngredient.Closing && ctx.never?.closings.includes(w.word));
|
|
103
|
+
}
|
|
104
|
+
/** Is the part offered to the model — allowed, and with the fact it shows given (R-H2: only what exists is named; rule 3). */
|
|
105
|
+
const partOffered = (part: FreeFooterPart, ctx: FooterContext): boolean => partAllowed(part, ctx) && !footerPartNode(part, ctx).leftOut;
|
|
106
|
+
/** How a part may show: `align:center` on every part, `pages:row` on the pages, `nameStyle:<word>` on the name. */
|
|
107
|
+
const partOpts = (part: FreeFooterPart, ctx: FooterContext): string[] =>
|
|
108
|
+
[FREE_FOOTER_CENTRED, ...(part === FreeFooterPart.Pages ? [FREE_FOOTER_PAGE_ROW] : []), ...(part === FreeFooterPart.Name ? nameStyleWords(ctx) : [])];
|
|
109
|
+
|
|
110
|
+
/** The name styles a free footer's name may wear (`nameStyle:<word>`), drawn and offered. */
|
|
111
|
+
const nameStyleWords = (ctx: FooterContext): string[] => footerWords(FooterIngredient.NameStyle)
|
|
112
|
+
.filter(w => footerWordOffered(FooterIngredient.NameStyle, w, ctx.tier)).map(w => `${NAME_STYLE}${w}`);
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Every part this site's free footer may place, by slot word (`footer:brand`) — the wire's `slot` enum and the brief's list
|
|
116
|
+
* (`freeSlotLine`); its options: `align:center` on every part, `pages:row` on the pages, `nameStyle:<word>` on the name.
|
|
117
|
+
*/
|
|
118
|
+
export function freeFooterSlotOffers(ctx: FooterContext): Record<string, FreeSlotOffer> {
|
|
119
|
+
const out: Record<string, FreeSlotOffer> = {};
|
|
120
|
+
for (const part of Object.values(FreeFooterPart)) {
|
|
121
|
+
if (partOffered(part, ctx)) out[freeSlotWord(FreeSlotKind.Footer, part)] = { kind: FreeSlotKind.Footer, ref: part, opts: partOpts(part, ctx) };
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** The grounds a free footer may stand on (`ground:<word>` on its Section): drawn, offered, not refused by the type. */
|
|
127
|
+
export function freeFooterGrounds(ctx: FooterContext): string[] {
|
|
128
|
+
return footerWords(FooterIngredient.Ground)
|
|
129
|
+
.filter(g => footerWordOffered(FooterIngredient.Ground, g, ctx.tier) && !ctx.never?.grounds.includes(g)).map(g => `${GROUND}${g}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** What a part shows, in the words the model reads (the brief). */
|
|
133
|
+
export function freeFooterPartMeaning(part: string): string {
|
|
134
|
+
const w = PART_WORD[part as FreeFooterPart];
|
|
135
|
+
if (w) return footerMeaning(w.ingredient, w.word);
|
|
136
|
+
return ({
|
|
137
|
+
[FreeFooterPart.Brand]: 'the business name and its line',
|
|
138
|
+
[FreeFooterPart.Legal]: 'where the legal row goes (every legal page, the accessibility statement, Cookie settings) — appended at the end when not placed',
|
|
139
|
+
[FreeFooterPart.Copyright]: 'the © line with the year and the name',
|
|
140
|
+
} as Readonly<Record<string, string>>)[part] ?? part;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ── The judge: the ten hard rules (footer-v2 §4) ──────────────────────────────────────────────────────────────────────
|
|
144
|
+
|
|
145
|
+
/** Styles a footer node never writes: what makes words hard to read on their ground (rule 5) or cuts them (rule 6). */
|
|
146
|
+
const UNREADABLE: ReadonlyArray<string> = ['color', 'opacity', 'mixBlendMode', 'filter', 'backdropFilter', 'overflow'];
|
|
147
|
+
/** The Section's own edges and air are the page's column and the look's section space (rule 6). */
|
|
148
|
+
const ON_THE_COLUMN = /^(width|minWidth|maxWidth|position|insetInline(Start|End)|top|bottom|backgroundColor|margin|padding)/;
|
|
149
|
+
const NOT_PAINTED: ReadonlyArray<string> = ['transparent'];
|
|
150
|
+
const ROOT = 'sections[0]';
|
|
151
|
+
|
|
152
|
+
/** The part a Slot places (`footer:<part>`), or null. */
|
|
153
|
+
function partOf(n: FreeNode): FreeFooterPart | null {
|
|
154
|
+
const slot = freeSlotOf(String(n.slot ?? ''));
|
|
155
|
+
return slot?.kind === FreeSlotKind.Footer && (Object.values(FreeFooterPart) as string[]).includes(slot.ref) ? slot.ref as FreeFooterPart : null;
|
|
156
|
+
}
|
|
157
|
+
/** The ground a footer Section names (absent = plain, the page's own ground). */
|
|
158
|
+
const groundWordsOf = (footer: FreeNode): string[] => (footer.opts ?? []).filter(o => o.startsWith(GROUND)).map(o => o.slice(GROUND.length));
|
|
159
|
+
const groundOf = (footer: FreeNode): string => groundWordsOf(footer)[0] ?? FooterGround.Plain;
|
|
160
|
+
const columnsOf = (v: unknown): number => {
|
|
161
|
+
const s = String(v ?? '').trim();
|
|
162
|
+
const rep = /repeat\(\s*(\d+)/.exec(s);
|
|
163
|
+
return s ? (rep ? Number(rep[1]) : s.split(/\s+(?![^(]*\))/).filter(Boolean).length) : 0;
|
|
164
|
+
};
|
|
165
|
+
const spansAll = (n: FreeNode): boolean => /^1\s*\/\s*-1$/.test(String(n.styleProps?.['gridColumn'] ?? '').trim());
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Every reason a free footer may not be stamped (§4's ten hard rules), path first, in words the model can act on in its
|
|
169
|
+
* ONE repair: (1) the legal row placed once at most — the composer appends it when not placed; (2) the © line once at most;
|
|
170
|
+
* (3)(4) only the parts this site has the facts for (`freeFooterSlotOffers`) and never a word, picture or button of its own;
|
|
171
|
+
* (5) readable — a ground is a word of the table or a scheme's own ground, no colour, opacity, blend or filter; (6) on the
|
|
172
|
+
* column — the Section keeps the page's edges and air, the name / call word / email stand at the column's full width,
|
|
173
|
+
* nothing cuts; (7) a phone layer where a phone needs one; (8) one name, one closing; (9) what the kind of business never
|
|
174
|
+
* wears; (10) no move and no hover of its own — the footer enters with the page (v1). Pure.
|
|
175
|
+
*/
|
|
176
|
+
export function checkFreeFooter(footer: FreeNode, ctx: FreeFooterContext): FreeIssue[] {
|
|
177
|
+
const issues: FreeIssue[] = [];
|
|
178
|
+
const say = (code: FreeIssueCode, path: string, message: string) => issues.push({ code, path, message });
|
|
179
|
+
if (footer?.type !== FreeNodeType.Section || footer.purpose !== FreePurpose.Footer) {
|
|
180
|
+
say(FreeIssueCode.Structure, ROOT, 'the footer is ONE Section with purpose "footer"');
|
|
181
|
+
return issues;
|
|
182
|
+
}
|
|
183
|
+
const offers = freeFooterSlotOffers(ctx);
|
|
184
|
+
const grounds = freeFooterGrounds(ctx).map(g => g.slice(GROUND.length));
|
|
185
|
+
const placed = new Map<FreeFooterPart, FreeNode>();
|
|
186
|
+
const ids = new Set<string>();
|
|
187
|
+
for (const { node, path, up } of walkFree([footer]).map(w => ({ ...w, path: w.path.replace(/^sections\[0\]/, ROOT) }))) {
|
|
188
|
+
if (!node.id || ids.has(node.id)) say(FreeIssueCode.Structure, path, node.id ? `the id "${node.id}" is used twice` : 'every node needs its own id');
|
|
189
|
+
ids.add(node.id);
|
|
190
|
+
const top = up.length === 0;
|
|
191
|
+
if (!top && node.type === FreeNodeType.Section) say(FreeIssueCode.Structure, path, 'the footer is ONE Section — use a Container inside');
|
|
192
|
+
if (!top && node.type !== FreeNodeType.Container && node.type !== FreeNodeType.Slot) {
|
|
193
|
+
say(FreeIssueCode.Words, path, `a footer places the parts it is offered (footer:<part>), never a ${node.type} of its own — every word in a footer is the owner's fact or the product's copy (FV-D4)`);
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
if (node.children?.length && node.type === FreeNodeType.Slot) say(FreeIssueCode.Structure, path, 'a Slot holds nothing — the part is placed whole');
|
|
197
|
+
issues.push(...freeNodeStyleIssues(node, path, ctx));
|
|
198
|
+
for (const [layer, style] of [['styleProps', node.styleProps], ...Object.entries(node.responsive ?? {}).map(([bp, st]) => [`responsive.${bp}`, st])] as Array<[string, FreeStyle | undefined]>) {
|
|
199
|
+
for (const prop of Object.keys(style ?? {})) {
|
|
200
|
+
if (UNREADABLE.includes(prop)) say(FreeIssueCode.Contrast, `${path}.${layer}.${prop}`, 'a footer\'s words wear their part\'s own ink on their ground — no colour, opacity, blend, filter or clipping of its own');
|
|
201
|
+
else if (top && ON_THE_COLUMN.test(prop)) say(FreeIssueCode.Style, `${path}.${layer}.${prop}`, 'the footer stands on the page\'s column — its edges, its air and its ground are the look\'s (say the ground as ground:<word>)');
|
|
202
|
+
else if (prop === 'backgroundColor' && !NOT_PAINTED.includes(String(style?.[prop]).trim()) && !freeSchemeOf({ ...node, styleProps: { backgroundColor: String(style?.[prop]) } })) {
|
|
203
|
+
say(FreeIssueCode.Contrast, `${path}.${layer}.${prop}`, 'a box in a footer stands on a scheme\'s own ground (var(--iox-inverse-bg), var(--iox-subtle-bg)) or on none, so its words read');
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
if (node.hover && Object.keys(node.hover).length) say(FreeIssueCode.Motion, `${path}.hover`, 'the parts carry their own hover — a footer box has none of its own');
|
|
208
|
+
if (node.move) say(FreeIssueCode.Motion, `${path}.move`, 'the footer enters with the page — no move of its own');
|
|
209
|
+
const needs = freePhoneNeeds(node);
|
|
210
|
+
if (needs.length) say(FreeIssueCode.Phone, `${path}.responsive`, `needs a phone layer for ${needs.join(', ')}`);
|
|
211
|
+
|
|
212
|
+
if (node.type === FreeNodeType.Slot) {
|
|
213
|
+
// A part whose fact is missing is no fault of the layout: it is left out when stamped, and said (rule 3, R-H-FV2) —
|
|
214
|
+
// a footer stored before an owner removed a fact still stands. Only a part no footer of this site may place is.
|
|
215
|
+
const part = partOf(node);
|
|
216
|
+
if (!part || !partAllowed(part, ctx)) {
|
|
217
|
+
say(FreeIssueCode.Content, `${path}.slot`, `"${node.slot ?? ''}" is not a part this footer may place — ${Object.keys(offers).join(', ')}`);
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (placed.has(part)) say(FreeIssueCode.Structure, `${path}.slot`, `the ${part} part is placed once`);
|
|
221
|
+
placed.set(part, node);
|
|
222
|
+
const opts = partOpts(part, ctx);
|
|
223
|
+
for (const [k, o] of (node.opts ?? []).entries()) if (!opts.includes(o)) say(FreeIssueCode.Content, `${path}.opts[${k}]`, `"${o}" is not how this part may show — ${opts.join(', ')}`);
|
|
224
|
+
if (COLUMN_PARTS.includes(part)) {
|
|
225
|
+
const parent = up[up.length - 1];
|
|
226
|
+
if (parent !== footer) say(FreeIssueCode.Structure, path, `the ${part} is fitted to the column — it stands in the footer Section itself, at the column's full width`);
|
|
227
|
+
else if (columnsOf(footer.styleProps?.['gridTemplateColumns']) >= 2 && !spansAll(node)) say(FreeIssueCode.Structure, `${path}.styleProps.gridColumn`, `the ${part} spans every column of the footer (gridColumn: 1 / -1)`);
|
|
228
|
+
}
|
|
229
|
+
} else if (node.slot) say(FreeIssueCode.Structure, path, 'only a Slot places a part');
|
|
230
|
+
else if (!top && node.opts?.length) say(FreeIssueCode.Structure, `${path}.opts`, 'only a Slot and the footer Section carry words of the table');
|
|
231
|
+
}
|
|
232
|
+
// (8) one closing — the name, the call, the statement, the call word or the email.
|
|
233
|
+
const closings = [...placed.keys()].filter(p => PART_WORD[p]?.ingredient === FooterIngredient.Closing);
|
|
234
|
+
if (closings.length > 1) say(FreeIssueCode.Structure, ROOT, `a footer closes once — it places ${closings.join(' and ')}`);
|
|
235
|
+
// FV-D11: the contact-form area opens the footer.
|
|
236
|
+
const form = placed.get(FreeFooterPart.ContactForm);
|
|
237
|
+
if (form && footer.children?.[0] !== form) say(FreeIssueCode.Structure, ROOT, 'the contact-form area opens the footer — the Section\'s first child');
|
|
238
|
+
// AW12-D12: a gradient or embossed name is a decorative copy of the name the brand block says.
|
|
239
|
+
const nameStyle = nameStyleOfFree(footer);
|
|
240
|
+
if ((nameStyle === FooterNameStyle.Gradient || nameStyle === FooterNameStyle.Emboss) && !placed.has(FreeFooterPart.Brand)) {
|
|
241
|
+
say(FreeIssueCode.Content, ROOT, `a ${nameStyle} name is a copy of the name the brand block says — place footer:brand too`);
|
|
242
|
+
}
|
|
243
|
+
// The ground: one word of the table, offered and not refused by the kind of business (rule 5, rule 9).
|
|
244
|
+
const named = groundWordsOf(footer);
|
|
245
|
+
const others = (footer.opts ?? []).filter(o => !o.startsWith(GROUND));
|
|
246
|
+
if (named.length > 1 || others.length) say(FreeIssueCode.Structure, `${ROOT}.opts`, `the footer Section names its ground once — ground:<word> (${grounds.join(', ')})`);
|
|
247
|
+
else if (named.length && !grounds.includes(named[0])) say(FreeIssueCode.Content, `${ROOT}.opts[0]`, `"${named[0]}" is not a ground this footer may stand on — ${grounds.join(', ')}`);
|
|
248
|
+
return issues;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** The name style a free footer's name slot asks (absent = plain). */
|
|
252
|
+
function nameStyleOfFree(footer: FreeNode): string {
|
|
253
|
+
const name = walkFree([footer]).map(w => w.node).find(n => partOf(n) === FreeFooterPart.Name);
|
|
254
|
+
return (name?.opts ?? []).find(o => o.startsWith(NAME_STYLE))?.slice(NAME_STYLE.length) ?? FooterNameStyle.Plain;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// ── The mix it is nearest (FV-D12) ────────────────────────────────────────────────────────────────────────────────────
|
|
258
|
+
|
|
259
|
+
/** The parts a free footer placed, in reading order. */
|
|
260
|
+
const partsOf = (footer: FreeNode): FreeFooterPart[] => walkFree([footer]).map(w => partOf(w.node)).filter((p): p is FreeFooterPart => !!p);
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The mix footer a free footer is nearest to: the blocks it holds, its closing, its ground, the name's style and the
|
|
264
|
+
* contact-form area, arranged as columns (centred when its Section centres). The fall back (FV-D12) stamps it through the
|
|
265
|
+
* mix footer's own judge (`checkFooter`); the free root wears it with `arrange:free` (`stampFooterMix` — the classes the
|
|
266
|
+
* name's style and the ground are drawn from). Pure.
|
|
267
|
+
*/
|
|
268
|
+
export function footerMixFromFree(footer: FreeNode): FooterMix {
|
|
269
|
+
const parts = partsOf(footer);
|
|
270
|
+
const words = (ingredient: FooterIngredient) => parts.map(p => PART_WORD[p]).filter((w): w is PartWord => w?.ingredient === ingredient).map(w => w.word);
|
|
271
|
+
const ground = groundOf(footer);
|
|
272
|
+
const nameStyle = nameStyleOfFree(footer);
|
|
273
|
+
const closing = words(FooterIngredient.Closing)[0] ?? FooterClosing.None;
|
|
274
|
+
return footerMix({
|
|
275
|
+
arrange: footer.styleProps?.['alignItems'] === 'center' ? FooterArrange.Centred : FooterArrange.Columns,
|
|
276
|
+
holds: words(FooterIngredient.Holds).filter(h => footerTableWords(FooterIngredient.Holds).includes(h)),
|
|
277
|
+
closing,
|
|
278
|
+
ground: footerTableWords(FooterIngredient.Ground).includes(ground) && !footerWait(FooterIngredient.Ground, ground) ? ground : FooterGround.Plain,
|
|
279
|
+
...(closing === FooterClosing.Name && footerTableWords(FooterIngredient.NameStyle).includes(nameStyle) ? { nameStyle } : {}),
|
|
280
|
+
...(parts.includes(FreeFooterPart.ContactForm) ? { before: FooterBefore.ContactForm } : {}),
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** A free footer's face (FV-D5, recorded and shown, never a gate): `free/<its parts in reading order>/<closing>/<ground>`. */
|
|
285
|
+
export function freeFooterFaceOf(footer: FreeNode): string {
|
|
286
|
+
const mix = footerMixFromFree(footer);
|
|
287
|
+
return [FooterArrange.Free, partsOf(footer).join('+'), mix.closing, groundOf(footer)].join('/');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ── The stamp: the footer as a pattern ────────────────────────────────────────────────────────────────────────────────
|
|
291
|
+
|
|
292
|
+
/** What the stamp needs beside the site: the page's direction (start is the right side on a right-to-left site). */
|
|
293
|
+
export interface FreeFooterStamp {
|
|
294
|
+
rtl?: boolean;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const CONTAINER_HELD = NODE_BASELINES['Container']?.styleProps ?? {};
|
|
298
|
+
|
|
299
|
+
/** A free node's styles as a pattern node's `lay` and `resp`, through the builder's controls (`freeStyleToSlots`, the free
|
|
300
|
+
* stamp's ONE table): the base on what the node holds, the tablet on the base, the phone on the tablet. */
|
|
301
|
+
function layOf(n: FreeNode, rtl: boolean, held: Readonly<Record<string, unknown>>): Pick<PatternNode, 'lay' | 'resp'> {
|
|
302
|
+
const lay = freeStyleToSlots(n.styleProps, { rtl, held });
|
|
303
|
+
let wider: Record<string, unknown> = { ...held, ...lay };
|
|
304
|
+
const resp: Record<string, Record<string, string>> = {};
|
|
305
|
+
for (const layer of [FreeLayer.Tablet, FreeLayer.Phone]) {
|
|
306
|
+
const style = n.responsive?.[layer];
|
|
307
|
+
if (!style || !Object.keys(style).length) continue;
|
|
308
|
+
resp[layer] = freeStyleToSlots(style, { rtl, held: wider });
|
|
309
|
+
wider = { ...wider, ...resp[layer] };
|
|
310
|
+
}
|
|
311
|
+
return { ...(Object.keys(lay).length ? { lay } : {}), ...(Object.keys(resp).length ? { resp } : {}) };
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* A free footer as the pattern the composer stamps — the contract's footer shell (its ground the word's scheme), its
|
|
316
|
+
* Containers with the answer's styles, each Slot a Container holding THE recipe's part (`footerPartNode`), the `legal` slot
|
|
317
|
+
* the place compose-site fills with the legal row (`FooterRole.LegalPlace`). A part whose fact is missing is left out and
|
|
318
|
+
* said (rule 3). Judge it first (`checkFreeFooter`). Pure.
|
|
319
|
+
*/
|
|
320
|
+
export function expandFreeFooter(footer: FreeNode, ctx: FooterContext, stamp: FreeFooterStamp = {}): { pattern: SitePattern; mix: FooterMix; said: FooterRepair[] } {
|
|
321
|
+
const rtl = !!stamp.rtl;
|
|
322
|
+
const said: FooterRepair[] = [];
|
|
323
|
+
const holds = partsOf(footer).map(p => PART_WORD[p]?.word).filter((w): w is string => !!w);
|
|
324
|
+
const nodeOf = (n: FreeNode): PatternNode | null => {
|
|
325
|
+
if (n.type === FreeNodeType.Slot) {
|
|
326
|
+
const part = partOf(n);
|
|
327
|
+
const opts = n.opts ?? [];
|
|
328
|
+
const wrapper: PatternNode = { t: 'Container', es: 'box', ...layOf(n, rtl, CONTAINER_HELD) };
|
|
329
|
+
// A centred legal slot says so on its place: compose-site centres the legal row it puts there.
|
|
330
|
+
if (part === FreeFooterPart.Legal) return { ...wrapper, role: FooterRole.LegalPlace, ...(opts.includes(FREE_FOOTER_CENTRED) ? { lay: { ...(wrapper.lay ?? {}), alignItems: 'center' } } : {}) };
|
|
331
|
+
const made = part ? footerPartNode(part, ctx, {
|
|
332
|
+
centred: opts.includes(FREE_FOOTER_CENTRED), row: opts.includes(FREE_FOOTER_PAGE_ROW), holds,
|
|
333
|
+
nameStyle: opts.find(o => o.startsWith(NAME_STYLE))?.slice(NAME_STYLE.length),
|
|
334
|
+
}) : { node: null };
|
|
335
|
+
if (made.leftOut) said.push(made.leftOut);
|
|
336
|
+
return made.node ? { ...wrapper, c: [made.node] } : null;
|
|
337
|
+
}
|
|
338
|
+
const scheme = freeSchemeOf(n);
|
|
339
|
+
const c = (n.children ?? []).map(nodeOf).filter((x): x is PatternNode => !!x);
|
|
340
|
+
return { t: 'Container', es: n.elementStyle || 'box', ...layOf(n, rtl, CONTAINER_HELD), ...(scheme ? { scheme } : {}), ...(c.length ? { c } : {}) };
|
|
341
|
+
};
|
|
342
|
+
const shell = footerPart('section');
|
|
343
|
+
const kids = (footer.children ?? []).map(nodeOf).filter((x): x is PatternNode => !!x);
|
|
344
|
+
const ground = groundOf(footer);
|
|
345
|
+
const scheme = FOOTER_GROUND_SCHEME[ground] ?? null;
|
|
346
|
+
const own = layOf(footer, rtl, {});
|
|
347
|
+
const node: PatternNode = {
|
|
348
|
+
...shell, lay: { ...(shell.lay ?? {}), ...(own.lay ?? {}) }, ...(own.resp ? { resp: own.resp } : {}), ...(scheme ? { scheme } : {}), c: kids,
|
|
349
|
+
};
|
|
350
|
+
const mix = { ...footerMix({ ...footerMixFromFree(footer) }), arrange: FooterArrange.Free };
|
|
351
|
+
return {
|
|
352
|
+
pattern: {
|
|
353
|
+
family: 'footer',
|
|
354
|
+
label: `Footer — laid freely (${freeFooterFaceOf(footer)})`,
|
|
355
|
+
intent: [footerMeaning(FooterIngredient.Arrange, FooterArrange.Free), footerMeaning(FooterIngredient.Ground, mix.ground)].join('; '),
|
|
356
|
+
global: PatternGlobalPosition.After,
|
|
357
|
+
node,
|
|
358
|
+
},
|
|
359
|
+
mix,
|
|
360
|
+
said,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// ── The free footer, or the nearest mix (R-H-FV3) ─────────────────────────────────────────────────────────────────────
|
|
365
|
+
|
|
366
|
+
/** The footer a site is built with: the free one when it keeps the rules, else the nearest mix footer — and what was said. */
|
|
367
|
+
export interface PlannedFooter {
|
|
368
|
+
pattern: SitePattern;
|
|
369
|
+
/** The mix the footer root wears (`stampFooterMix`): `arrange:free` for a free footer. */
|
|
370
|
+
mix: FooterMix;
|
|
371
|
+
/** True when the free footer stands. */
|
|
372
|
+
free: boolean;
|
|
373
|
+
said: FooterRepair[];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* The ONE decision (FV-D12, R-H-FV3) the build and the composer share: a free footer that keeps the hard rules is stamped
|
|
378
|
+
* (`expandFreeFooter`); one that still breaks a rule — after the free request's one repair — gives way to the nearest mix
|
|
379
|
+
* footer (`footerMixFromFree` → `checkFooter` → `footerPattern`), said `footer-composed-for-you`. The site never goes
|
|
380
|
+
* without a footer. Pure.
|
|
381
|
+
*/
|
|
382
|
+
export function freeFooterOrMix(footer: FreeNode, ctx: FreeFooterContext, stamp: FreeFooterStamp = {}): PlannedFooter {
|
|
383
|
+
const issues = checkFreeFooter(footer, ctx);
|
|
384
|
+
if (!issues.length) {
|
|
385
|
+
const free = expandFreeFooter(footer, ctx, stamp);
|
|
386
|
+
return { pattern: free.pattern, mix: free.mix, free: true, said: free.said };
|
|
387
|
+
}
|
|
388
|
+
const checked = checkFooter(footerMixFromFree(footer), ctx);
|
|
389
|
+
const why = issues.slice(0, 2).map(i => i.message).join('; ');
|
|
390
|
+
return {
|
|
391
|
+
pattern: footerPattern(checked.mix, ctx),
|
|
392
|
+
mix: checked.mix,
|
|
393
|
+
free: false,
|
|
394
|
+
said: [{ code: FooterRepairCode.ComposedForYou, said: `the footer laid freely broke a rule (${why}): composed for you` }, ...checked.repairs],
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// ── The free request ──────────────────────────────────────────────────────────────────────────────────────────────────
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* The free request's answer with its footer split off (§4a): the LAST section, when its purpose is the footer, is judged by
|
|
402
|
+
* itself (`checkFreeFooter`) and the page without it by `checkFree`. A footer section anywhere else stays in the page,
|
|
403
|
+
* where `checkFree` refuses it.
|
|
404
|
+
*/
|
|
405
|
+
export function splitFreeFooter(page: FreePage): { page: FreePage; footer: FreeNode | null } {
|
|
406
|
+
const sections = Array.isArray(page?.sections) ? page.sections : [];
|
|
407
|
+
const last = sections[sections.length - 1];
|
|
408
|
+
if (!last || last.type !== FreeNodeType.Section || last.purpose !== FreePurpose.Footer) return { page, footer: null };
|
|
409
|
+
return { page: { ...page, sections: sections.slice(0, -1) }, footer: last };
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/** A reference footer's layout (the contract's flat wire, FV-D6) as the free footer it lays — null for a row without one. */
|
|
413
|
+
export function referenceFooterLayout(layout: ReadonlyArray<Readonly<Record<string, unknown>>> | undefined): FreeNode | null {
|
|
414
|
+
if (!layout?.length) return null;
|
|
415
|
+
const { page, faults } = expandFreeWire({ read: { idea: '', why: '', followed: '' }, pictures: 'none', nodes: layout.map(n => ({ ...n })) });
|
|
416
|
+
return !faults.length && page.sections.length === 1 ? page.sections[0] : null;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* The brief's footer part (§4a): what the footer is for, the parts this site may place and their options, the grounds, the
|
|
421
|
+
* hard rules in the model's words — and the faces the studio's last sites wore, asking for another (FV-D5). The free
|
|
422
|
+
* request appends it when it asks for the footer.
|
|
423
|
+
*/
|
|
424
|
+
export function freeFooterBrief(ctx: FooterContext, worn: ReadonlyArray<string> = []): string {
|
|
425
|
+
const offers = freeFooterSlotOffers(ctx);
|
|
426
|
+
const lines = Object.entries(offers).map(([slot, o]) => `- "${slot}" (${freeFooterPartMeaning(o.ref)})${o.opts?.length ? ` · opts: ${o.opts.join(', ')}` : ''}`);
|
|
427
|
+
return [
|
|
428
|
+
'THE FOOTER — the LAST section of your answer: a Section with purpose "footer", its ground in "opts" as ONE word:',
|
|
429
|
+
` ${freeFooterGrounds(ctx).join(' · ')}.`,
|
|
430
|
+
'Inside it only Containers (with styles) and Slots placing these parts — never a Heading, Text, Button, Image or Video of',
|
|
431
|
+
'your own: every word of a footer is the owner\'s fact or the product\'s copy.',
|
|
432
|
+
...lines,
|
|
433
|
+
'Each part once; one closing at most (the name, the call, the statement, the call word or the email); the name, the call',
|
|
434
|
+
'word and the email stand in the Section itself at the column\'s full width; the contact-form area, when placed, comes',
|
|
435
|
+
'first. The Section keeps the page\'s column and air (no width, margin, padding or colour on it); no colour, opacity,',
|
|
436
|
+
'filter, move or hover anywhere in the footer; a grid of two or more columns carries its phone layer.',
|
|
437
|
+
...(worn.length ? [`The studio's last sites wore these footers — lay a different one: ${worn.join(' · ')}.`] : []),
|
|
438
|
+
].join('\n');
|
|
439
|
+
}
|