@vectoriox/iox-ui 5.198.0 → 5.199.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/actions-core/index.d.ts +7 -1
- package/data-core/index.d.ts +11 -3
- package/design-core/index.d.ts +26 -1
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +6 -1
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-data-core.mjs +30 -4
- package/fesm2022/vectoriox-iox-ui-data-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +65 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +10821 -10094
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +243 -38
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/generation-core/index.d.ts +463 -126
- package/harness-core/index.d.ts +93 -6
- package/package.json +1 -1
- package/src/actions-core/element-actions.ts +6 -0
- package/src/data-core/placeholder-rows.ts +29 -4
- package/src/design-core/menu-look.ts +23 -0
- package/src/design-core/node-classes.ts +39 -0
- package/src/generation-core/check-free.ts +17 -9
- package/src/generation-core/compose-free.ts +7 -2
- package/src/generation-core/compose-site.ts +167 -46
- package/src/generation-core/footer-mix.ts +161 -15
- package/src/generation-core/free-opening.ts +13 -2
- package/src/generation-core/free-wire.ts +8 -0
- package/src/generation-core/header-mix.ts +31 -2
- package/src/generation-core/legal.ts +24 -0
- package/src/generation-core/menu-shelves.ts +138 -0
- package/src/generation-core/nav-shape.ts +138 -15
- package/src/generation-core/node-baselines.generated.ts +1 -0
- package/src/generation-core/patterns.ts +7 -0
- package/src/generation-core/plan-wire.ts +1 -0
- package/src/generation-core/public-api.ts +1 -0
- package/src/generation-core/site-build-run.ts +8 -0
- package/src/generation-core/site-plan.model.ts +3 -0
- package/src/generation-core/site-spec.generated.ts +230 -70
- package/src/generation-core/validate-site-plan.ts +2 -0
- package/src/harness-core/business-types.ts +4 -0
- package/src/harness-core/harness-spec.generated.ts +189 -30
- package/src/harness-core/popup-stance.ts +56 -3
- package/src/harness-core/run-compose-context.ts +25 -5
- package/styles/iox-design.css +25 -0
|
@@ -27,6 +27,10 @@ export enum FooterIngredient {
|
|
|
27
27
|
Ground = 'ground',
|
|
28
28
|
/** AW12 (AW12-D12): how the closing name is worn. Not in the fingerprint (AW12-D14). */
|
|
29
29
|
NameStyle = 'nameStyle',
|
|
30
|
+
/** FV1b (FV-D8, FV-D11): a block just before the footer's own that belongs to it — on every page, undone with it. */
|
|
31
|
+
Before = 'before',
|
|
32
|
+
/** FV1b: how the footer folds on a phone. */
|
|
33
|
+
Phone = 'phone',
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
/** The words, by the table (a word that waits for its phase too — `footerWords` offers only the drawn ones). */
|
|
@@ -102,6 +106,26 @@ export enum FooterNameStyle {
|
|
|
102
106
|
Script = 'script',
|
|
103
107
|
}
|
|
104
108
|
|
|
109
|
+
/** FV1b: what opens the footer before its own blocks. */
|
|
110
|
+
export enum FooterBefore {
|
|
111
|
+
None = 'none',
|
|
112
|
+
/** A contact-form area (FV-D11, mdscollective · mooov). */
|
|
113
|
+
ContactForm = 'contact-form',
|
|
114
|
+
/** A sign-up band (cancan; waits for the newsletter, AW12). */
|
|
115
|
+
NewsletterBand = 'newsletter-band',
|
|
116
|
+
/** Where and when to visit, as a band. */
|
|
117
|
+
Visit = 'visit',
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** FV1b: how the footer folds on a phone. */
|
|
121
|
+
export enum FooterPhone {
|
|
122
|
+
Stack = 'stack',
|
|
123
|
+
/** The link columns fold into accordions (stroms, schlosshotel; waits — a fold only a phone wears). */
|
|
124
|
+
Accordion = 'accordion',
|
|
125
|
+
/** The sign-up comes first (8pm; waits for the newsletter, AW12). */
|
|
126
|
+
First = 'first',
|
|
127
|
+
}
|
|
128
|
+
|
|
105
129
|
/** The roles a footer's parts carry — the contract's (`site.footerParts` and the stored footers), written to the node's
|
|
106
130
|
* `role`, a class `iox-role-<role>` both renderers emit. */
|
|
107
131
|
export enum FooterRole {
|
|
@@ -126,6 +150,13 @@ export enum FooterRole {
|
|
|
126
150
|
Halves = 'footer.halves',
|
|
127
151
|
/** FV1 `closing.email`: the owner's email set large, the contact link. */
|
|
128
152
|
Email = 'footer.email',
|
|
153
|
+
/** FV1b `holds.social`: the block, and each of its links (the contract part's template). */
|
|
154
|
+
Social = 'footer.social',
|
|
155
|
+
SocialLink = 'footer.social-link',
|
|
156
|
+
/** FV1b `holds.top`: the round button that scrolls to the page's top, at the end of the copyright row. */
|
|
157
|
+
Top = 'footer.top',
|
|
158
|
+
/** FV1b `before`: the block that opens the footer (the contact-form area, the visit band). */
|
|
159
|
+
Before = 'footer.before',
|
|
129
160
|
}
|
|
130
161
|
|
|
131
162
|
|
|
@@ -138,6 +169,9 @@ export interface FooterMix {
|
|
|
138
169
|
readonly ground: string;
|
|
139
170
|
/** AW12: absent = plain (a stored or hand-made mix written before the name had a style). */
|
|
140
171
|
readonly nameStyle?: string;
|
|
172
|
+
/** FV1b: absent = none / stack (every mix written before FV1b). */
|
|
173
|
+
readonly before?: string;
|
|
174
|
+
readonly phone?: string;
|
|
141
175
|
}
|
|
142
176
|
|
|
143
177
|
export class FooterMixError extends Error {}
|
|
@@ -170,7 +204,9 @@ export function footerWait(ingredient: `${FooterIngredient}`, word: string): Foo
|
|
|
170
204
|
*/
|
|
171
205
|
export const FOOTER_ROW_HOLDS: ReadonlySet<string> = new Set(F.rules.legalAlways ? [FooterHold.Legal] : []);
|
|
172
206
|
/** The blocks of a mix the recipe lays as parts (the legal row is compose-site's). */
|
|
173
|
-
|
|
207
|
+
/** FV1b: a hold the copyright row carries at its end (the back-to-top button) — never a column of its own. */
|
|
208
|
+
const BOTTOM_HOLDS: ReadonlySet<string> = new Set([FooterHold.Top]);
|
|
209
|
+
const partHolds = (holds: ReadonlyArray<string>): string[] => holds.filter(h => !FOOTER_ROW_HOLDS.has(h) && !BOTTOM_HOLDS.has(h));
|
|
174
210
|
|
|
175
211
|
/** The words an ingredient may take — the DRAWN ones, the only ones the wire, the brief and the mender offer
|
|
176
212
|
* (ingredients.md §3.3: offering a waiting word would put its stand-in on every site that asked for it). The legal row
|
|
@@ -209,21 +245,27 @@ export function namedFooterMix(patternId: string): FooterMix | null {
|
|
|
209
245
|
|
|
210
246
|
/** The stored footer pattern a mix is exactly, else null. */
|
|
211
247
|
export function footerPatternIdOf(mix: FooterMix): string | null {
|
|
212
|
-
const key = footerTokenOf(mix) + JSON.stringify(mix.holds) + nameStyleOf(mix);
|
|
248
|
+
const key = footerTokenOf(mix) + JSON.stringify(mix.holds) + nameStyleOf(mix) + beforeOf(mix) + phoneOf(mix);
|
|
213
249
|
return Object.keys(F.named).find(id => {
|
|
214
250
|
const m = namedFooterMix(id)!;
|
|
215
|
-
return footerTokenOf(m) + JSON.stringify(m.holds) + nameStyleOf(m) === key;
|
|
251
|
+
return footerTokenOf(m) + JSON.stringify(m.holds) + nameStyleOf(m) + beforeOf(m) + phoneOf(m) === key;
|
|
216
252
|
}) ?? null;
|
|
217
253
|
}
|
|
218
254
|
|
|
219
255
|
/** The name's style of a mix (absent = plain). */
|
|
220
256
|
export const nameStyleOf = (mix: Pick<FooterMix, 'nameStyle'>): string => mix.nameStyle ?? FooterNameStyle.Plain;
|
|
257
|
+
/** FV1b: what opens the footer (absent = none) and how it folds on a phone (absent = stack). */
|
|
258
|
+
export const beforeOf = (mix: Pick<FooterMix, 'before'>): string => mix.before ?? FooterBefore.None;
|
|
259
|
+
export const phoneOf = (mix: Pick<FooterMix, 'phone'>): string => mix.phone ?? FooterPhone.Stack;
|
|
221
260
|
|
|
222
261
|
/** A mix on the wire: ONE list of `<ingredient>:<word>` words (the list wire's encoding), `holds` once per block. A plain
|
|
223
262
|
* name says nothing (`nameStyle:plain` is every mix's), so a mix stored before AW12 reads and writes the same words. */
|
|
224
263
|
export function footerMixWords(mix: FooterMix): string[] {
|
|
225
264
|
return Object.values(FooterIngredient).flatMap(k => {
|
|
226
265
|
if (k === FooterIngredient.NameStyle) return nameStyleOf(mix) === FooterNameStyle.Plain ? [] : [`${k}:${nameStyleOf(mix)}`];
|
|
266
|
+
// FV1b: nothing before and a stacked phone are every mix's, so a mix stored before FV1b reads and writes the same words.
|
|
267
|
+
if (k === FooterIngredient.Before) return beforeOf(mix) === FooterBefore.None ? [] : [`${k}:${beforeOf(mix)}`];
|
|
268
|
+
if (k === FooterIngredient.Phone) return phoneOf(mix) === FooterPhone.Stack ? [] : [`${k}:${phoneOf(mix)}`];
|
|
227
269
|
return (MANY.includes(k) ? mix[k] as ReadonlyArray<string> : [mix[k] as string]).map(w => `${k}:${w}`);
|
|
228
270
|
});
|
|
229
271
|
}
|
|
@@ -248,7 +290,8 @@ export function drawnFooterMix(mix: FooterMix): { mix: FooterMix; waited: Array<
|
|
|
248
290
|
// In the table's order, so the words that waited are said as the table reads.
|
|
249
291
|
const arrange = one(FooterIngredient.Arrange);
|
|
250
292
|
const holds = inOrder(FooterIngredient.Holds, mix.holds.map(h => drawn(FooterIngredient.Holds, h)).filter((h): h is string => !!h));
|
|
251
|
-
const out = { arrange, holds, closing: one(FooterIngredient.Closing), ground: one(FooterIngredient.Ground), nameStyle: one(FooterIngredient.NameStyle)
|
|
293
|
+
const out = { arrange, holds, closing: one(FooterIngredient.Closing), ground: one(FooterIngredient.Ground), nameStyle: one(FooterIngredient.NameStyle),
|
|
294
|
+
before: one(FooterIngredient.Before), phone: one(FooterIngredient.Phone) };
|
|
252
295
|
return { mix: waited.length ? out : mix, waited };
|
|
253
296
|
}
|
|
254
297
|
|
|
@@ -351,6 +394,12 @@ export enum FooterRepairCode {
|
|
|
351
394
|
EmailTooLong = 'email-too-long',
|
|
352
395
|
/** FV1: halves need a block in the end zone — none held: drawn as columns. */
|
|
353
396
|
HalvesEmpty = 'halves-empty',
|
|
397
|
+
/** FV1b: the social block lists the owner's stated links on a network it can name — none: left out; past
|
|
398
|
+
* `socialMax`, or on no known network: those left out. */
|
|
399
|
+
SocialWithoutLinks = 'social-without-links',
|
|
400
|
+
SocialLeftOut = 'social-left-out',
|
|
401
|
+
/** FV1b: a visit band before the footer says where and when — the visit block is not said twice. */
|
|
402
|
+
VisitBeforeTwice = 'visit-before-twice',
|
|
354
403
|
}
|
|
355
404
|
|
|
356
405
|
export interface FooterRepair {
|
|
@@ -387,6 +436,8 @@ export interface FooterContext {
|
|
|
387
436
|
never?: FooterNever | null;
|
|
388
437
|
/** FV1 `closing.email`: the owner's email (the plan's `facts.email`) — none given, the footer never closes with one. */
|
|
389
438
|
email?: string;
|
|
439
|
+
/** FV1b `holds.social`: the owner's social links as stated (the plan's `business.social`) — none, no social block. */
|
|
440
|
+
social?: ReadonlyArray<string>;
|
|
390
441
|
/** The tier the site is built at. Since AW-D42 it mends no word (every tier wears every drawn word); kept so its
|
|
391
442
|
* callers still read. */
|
|
392
443
|
tier?: `${GenerationTier}`;
|
|
@@ -449,6 +500,49 @@ function statementPhoneLines(tagline: string, ctx: FooterContext): number {
|
|
|
449
500
|
return Math.ceil((widthEm(tagline, ctx) * size) / room);
|
|
450
501
|
}
|
|
451
502
|
|
|
503
|
+
/** FV1b (FV-D10): a network the footer can name a social link by — the contract's `FOOTER.socialNetworks`. */
|
|
504
|
+
export interface FooterSocialNetwork { readonly id: string; readonly name: string; readonly hosts: ReadonlyArray<string> }
|
|
505
|
+
export const FOOTER_SOCIAL_NETWORKS = (F as unknown as { socialNetworks: ReadonlyArray<FooterSocialNetwork> }).socialNetworks;
|
|
506
|
+
|
|
507
|
+
/** One social link the footer shows: the network's name and the owner's address (https). */
|
|
508
|
+
export interface FooterSocialLink { readonly network: string; readonly name: string; readonly url: string }
|
|
509
|
+
|
|
510
|
+
/** The host an address is on, bare (no `www.` / `m.`), or null when it is no http(s) address. */
|
|
511
|
+
function socialAddress(raw: string): URL | null {
|
|
512
|
+
const word = raw.trim().replace(/[.,;:!?)\]]+$/, '').replace(/^[(\[<]+/, '');
|
|
513
|
+
if (!word) return null;
|
|
514
|
+
const scheme = /^[a-z][a-z0-9+.-]*:/i.exec(word)?.[0].toLowerCase();
|
|
515
|
+
if (scheme && scheme !== 'http:' && scheme !== 'https:') return null;
|
|
516
|
+
try {
|
|
517
|
+
const url = new URL(scheme ? word : `https://${word}`);
|
|
518
|
+
url.protocol = 'https:';
|
|
519
|
+
return url;
|
|
520
|
+
} catch {
|
|
521
|
+
return null;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* FV1b (FV-D10, rule 3 + 4): the owner's stated social addresses as the links a footer shows — each on a network the
|
|
527
|
+
* footer can name (by its host), a profile (a path past the host), once per network, in the table's order, at most
|
|
528
|
+
* `socialMax`. Everything else is `leftOut` (and said): the footer never shows a link it cannot name, and never one the
|
|
529
|
+
* owner did not state. An entry may hold several addresses (a stated line, space- or comma-separated). Pure.
|
|
530
|
+
*/
|
|
531
|
+
export function footerSocialLinks(addresses?: ReadonlyArray<string> | null): { links: FooterSocialLink[]; leftOut: string[] } {
|
|
532
|
+
const found = new Map<string, FooterSocialLink>();
|
|
533
|
+
const leftOut: string[] = [];
|
|
534
|
+
for (const raw of (addresses ?? []).flatMap(a => String(a).split(/[\s,]+/)).filter(Boolean)) {
|
|
535
|
+
const url = socialAddress(raw);
|
|
536
|
+
const host = url?.hostname.toLowerCase().replace(/^(www|m)\./, '');
|
|
537
|
+
const network = host ? FOOTER_SOCIAL_NETWORKS.find(n => n.hosts.some(h => host === h || host.endsWith(`.${h}`))) : undefined;
|
|
538
|
+
if (!url || !network || url.pathname.replace(/\/+$/, '') === '' || found.has(network.id)) { leftOut.push(raw); continue; }
|
|
539
|
+
found.set(network.id, { network: network.id, name: network.name, url: url.href });
|
|
540
|
+
}
|
|
541
|
+
const links = FOOTER_SOCIAL_NETWORKS.map(n => found.get(n.id)).filter((l): l is FooterSocialLink => !!l);
|
|
542
|
+
const max = rule('socialMax');
|
|
543
|
+
return { links: links.slice(0, max), leftOut: [...leftOut, ...links.slice(max).map(l => l.url)] };
|
|
544
|
+
}
|
|
545
|
+
|
|
452
546
|
/** True when the call word cannot stand on a phone even split over two balanced lines. */
|
|
453
547
|
function wordTooWide(word: string, ctx: FooterContext): boolean {
|
|
454
548
|
const halves = word.split(/\s+/);
|
|
@@ -491,7 +585,7 @@ export function checkFooter(given: FooterMix, ctx: FooterContext): { mix: Footer
|
|
|
491
585
|
ground = FooterGround.Inverse;
|
|
492
586
|
}
|
|
493
587
|
if (arrange === FooterArrange.Line) {
|
|
494
|
-
const kept = holds.filter(h => (F.rules.lineHolds as ReadonlyArray<string>).includes(h));
|
|
588
|
+
const kept = holds.filter(h => (F.rules.lineHolds as ReadonlyArray<string>).includes(h) || BOTTOM_HOLDS.has(h));
|
|
495
589
|
const left = holds.filter(h => !kept.includes(h));
|
|
496
590
|
if (left.length) say(FooterRepairCode.LineHolds, `a one-line footer holds only ${F.rules.lineHolds.join(' and ')}: ${left.join(' and ')} left out`);
|
|
497
591
|
holds = kept;
|
|
@@ -547,6 +641,19 @@ export function checkFooter(given: FooterMix, ctx: FooterContext): { mix: Footer
|
|
|
547
641
|
say(FooterRepairCode.EmbossNeedsBrand, `${capital(an(nameStyle))} name is a copy of the name the brand block says, and this footer has none: plain`);
|
|
548
642
|
nameStyle = FooterNameStyle.Plain;
|
|
549
643
|
}
|
|
644
|
+
if (holds.includes(FooterHold.Social)) {
|
|
645
|
+
// FV1b (rule 3 + 4, FV-D10): only the links the owner stated, each on a network the footer can name.
|
|
646
|
+
const links = footerSocialLinks(ctx.social);
|
|
647
|
+
if (!links.links.length) {
|
|
648
|
+
say(FooterRepairCode.SocialWithoutLinks, 'the social block lists the owner\'s own links and none was stated: left out');
|
|
649
|
+
holds = holds.filter(h => h !== FooterHold.Social);
|
|
650
|
+
}
|
|
651
|
+
if (links.leftOut.length) say(FooterRepairCode.SocialLeftOut, `${links.leftOut.map(a => `"${a}"`).join(', ')} left out of the social links (${links.links.length ? `past ${rule('socialMax')} or ` : ''}on no network the footer can name)`);
|
|
652
|
+
}
|
|
653
|
+
if (beforeOf(mix) === FooterBefore.Visit && holds.includes(FooterHold.Visit)) {
|
|
654
|
+
say(FooterRepairCode.VisitBeforeTwice, 'the band before the footer says where and when: the visit block is not said twice');
|
|
655
|
+
holds = holds.filter(h => h !== FooterHold.Visit);
|
|
656
|
+
}
|
|
550
657
|
if (arrange === FooterArrange.Halves && !partHolds(holds).length) {
|
|
551
658
|
say(FooterRepairCode.HalvesEmpty, 'halves need a block beside the name and the footer holds none: drawn as columns');
|
|
552
659
|
arrange = FooterArrange.Columns;
|
|
@@ -630,8 +737,20 @@ function emailLine(email: string, ctx: FooterContext): PatternNode {
|
|
|
630
737
|
return laid(part('email'), { fontSize: columnSize(widthEm(email, ctx, 'link-display'), ctx) });
|
|
631
738
|
}
|
|
632
739
|
|
|
740
|
+
/** FV1b `holds.social`: the part's template link once per stated link — the network's name, the owner's address. */
|
|
741
|
+
function socialPart(ctx: FooterContext): PatternNode {
|
|
742
|
+
const links = footerSocialLinks(ctx.social).links;
|
|
743
|
+
const fill = (n: PatternNode): PatternNode => {
|
|
744
|
+
const template = (n.c ?? []).find(k => k.role === FooterRole.SocialLink);
|
|
745
|
+
if (template) return { ...n, c: links.map(l => ({ ...template, text: l.name, href: l.url })) };
|
|
746
|
+
return n.c ? { ...n, c: n.c.map(fill) } : n;
|
|
747
|
+
};
|
|
748
|
+
return fill(part(FooterHold.Social));
|
|
749
|
+
}
|
|
750
|
+
|
|
633
751
|
/** A block it holds: how to reach the business leaves its city to the visit block when the footer holds both. */
|
|
634
|
-
function holdPart(hold: string, mix: FooterMix): PatternNode {
|
|
752
|
+
function holdPart(hold: string, mix: FooterMix, ctx: FooterContext): PatternNode {
|
|
753
|
+
if (hold === FooterHold.Social) return socialPart(ctx);
|
|
635
754
|
const node = part(hold);
|
|
636
755
|
if (hold !== FooterHold.Contact || !mix.holds.includes(FooterHold.Visit)) return node;
|
|
637
756
|
return { ...node, c: (node.c ?? []).filter(n => n.ph !== 'city') };
|
|
@@ -650,23 +769,50 @@ function bigPages(ctx: FooterContext): PatternNode[] {
|
|
|
650
769
|
return [big, { ...rest, c: (rest.c ?? []).map(n => (n.each ? { ...n, skip: rule('listBigLarge') } : n)) }];
|
|
651
770
|
}
|
|
652
771
|
|
|
772
|
+
/** FV1b `holds.top`: the copyright row — the back-to-top button at its end when the footer holds it (never a column). */
|
|
773
|
+
function bottomRow(mix: FooterMix, copyright: PatternNode, justify = 'space-between'): PatternNode {
|
|
774
|
+
if (!mix.holds.includes(FooterHold.Top)) return copyright;
|
|
775
|
+
return { t: 'Container', es: 'box', lay: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: justify, gap: GAP },
|
|
776
|
+
c: [laid(copyright, { width: 'auto' }), part(FooterHold.Top)] };
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/** FV1b `before` (FV-D11): the block that opens the footer, on every page with it — the contact-form area under the kind of
|
|
780
|
+
* business's call line, or where and when as a band — and a rule under it. */
|
|
781
|
+
function beforeBlock(mix: FooterMix, ctx: FooterContext): PatternNode[] {
|
|
782
|
+
switch (beforeOf(mix)) {
|
|
783
|
+
case FooterBefore.ContactForm: {
|
|
784
|
+
const node = part('contact-form');
|
|
785
|
+
const line = footerCallLine(ctx.type);
|
|
786
|
+
const lineHe = footerCallLine(ctx.type, 'he');
|
|
787
|
+
const c = (node.c ?? []).map(n => (n.slot === 'beforeTitle' && line ? { ...n, text: line, ...(lineHe ? { textHe: lineHe } : {}) } : n));
|
|
788
|
+
return [{ ...node, c }, part('rule')];
|
|
789
|
+
}
|
|
790
|
+
case FooterBefore.Visit:
|
|
791
|
+
return [{ t: 'Container', es: 'box', role: FooterRole.Before, lay: { display: 'flex', flexWrap: 'wrap', alignItems: 'baseline', justifyContent: 'space-between', gap: GAP },
|
|
792
|
+
c: part(FooterHold.Visit).c ?? [] }, part('rule')];
|
|
793
|
+
default:
|
|
794
|
+
return [];
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
|
|
653
798
|
/** The body: the blocks it holds, arranged. */
|
|
654
799
|
function bodyOf(mix: FooterMix, ctx: FooterContext): PatternNode[] {
|
|
655
|
-
const holds = partHolds(mix.holds).map(h => holdPart(h, mix));
|
|
800
|
+
const holds = partHolds(mix.holds).map(h => holdPart(h, mix, ctx));
|
|
656
801
|
switch (mix.arrange) {
|
|
657
802
|
case FooterArrange.Line: {
|
|
658
803
|
const row: PatternNode = { t: 'Container', es: 'box', lay: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'space-between', gap: GAP }, c: [
|
|
659
804
|
laid(part('copyright'), { width: 'auto' }),
|
|
660
805
|
...(mix.holds.includes(FooterHold.Pages) ? [part('pageRow')] : []),
|
|
806
|
+
...(mix.holds.includes(FooterHold.Top) ? [part(FooterHold.Top)] : []),
|
|
661
807
|
] };
|
|
662
808
|
return [row];
|
|
663
809
|
}
|
|
664
810
|
case FooterArrange.Centred: {
|
|
665
|
-
const blocks = partHolds(mix.holds).map(h => (h === FooterHold.Pages ? laid(part('pageRow'), { justifyContent: 'center' }) : centred(holdPart(h, mix))));
|
|
811
|
+
const blocks = partHolds(mix.holds).map(h => (h === FooterHold.Pages ? laid(part('pageRow'), { justifyContent: 'center' }) : centred(holdPart(h, mix, ctx))));
|
|
666
812
|
return [
|
|
667
813
|
{ t: 'Container', es: 'box', lay: { display: 'flex', flexDirection: 'column', gap: '28px', ...CENTRED }, c: [centred(brandPart(ctx, mix)), ...blocks] },
|
|
668
814
|
part('rule'),
|
|
669
|
-
laid(part('copyright'), { textAlign: 'center' }),
|
|
815
|
+
bottomRow(mix, laid(part('copyright'), { textAlign: 'center' }), 'center'),
|
|
670
816
|
];
|
|
671
817
|
}
|
|
672
818
|
case FooterArrange.Ruled: {
|
|
@@ -675,16 +821,16 @@ function bodyOf(mix: FooterMix, ctx: FooterContext): PatternNode[] {
|
|
|
675
821
|
const cells = [brandPart(ctx, mix), ...holds];
|
|
676
822
|
const n = Math.min(cells.length, rule('ruledCells'));
|
|
677
823
|
return [{ t: 'Container', es: 'box', role: FooterRole.Ruled, lay: { display: 'grid', gridTemplateColumns: `repeat(${n}, minmax(0, 1fr))`, gap: `${GAP} 0px` },
|
|
678
|
-
resp: { tablet: { gridTemplateColumns: 'repeat(2, minmax(0, 1fr))' }, mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: cells }, part('rule'), part('copyright')];
|
|
824
|
+
resp: { tablet: { gridTemplateColumns: 'repeat(2, minmax(0, 1fr))' }, mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: cells }, part('rule'), bottomRow(mix, part('copyright'))];
|
|
679
825
|
}
|
|
680
826
|
case FooterArrange.ListBig: {
|
|
681
|
-
const others = partHolds(mix.holds).filter(h => h !== FooterHold.Pages).map(h => holdPart(h, mix));
|
|
827
|
+
const others = partHolds(mix.holds).filter(h => h !== FooterHold.Pages).map(h => holdPart(h, mix, ctx));
|
|
682
828
|
const pages = mix.holds.includes(FooterHold.Pages) ? bigPages(ctx) : [];
|
|
683
829
|
return [{ t: 'Container', es: 'box', lay: { display: 'grid', gridTemplateColumns: 'minmax(0, 3fr) minmax(0, 2fr)', gap: GAP, alignItems: 'end' },
|
|
684
830
|
resp: { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: [
|
|
685
831
|
{ t: 'Container', es: 'box', lay: { display: 'flex', flexDirection: 'column', gap: GAP }, c: pages },
|
|
686
832
|
{ t: 'Container', es: 'box', lay: { display: 'flex', flexDirection: 'column', gap: GAP }, c: [brandPart(ctx, mix), ...others] },
|
|
687
|
-
] }, part('rule'), part('copyright')];
|
|
833
|
+
] }, part('rule'), bottomRow(mix, part('copyright'))];
|
|
688
834
|
}
|
|
689
835
|
case FooterArrange.Halves: {
|
|
690
836
|
// FV1 (footer-v2 §2, after thepopuphotel and allerstudio): the brand at the start, the blocks in columns at the
|
|
@@ -692,10 +838,10 @@ function bodyOf(mix: FooterMix, ctx: FooterContext): PatternNode[] {
|
|
|
692
838
|
const end: PatternNode = { t: 'Container', es: 'box', lay: { display: 'grid', gridTemplateColumns: `repeat(${Math.max(holds.length, 1)}, minmax(0, 1fr))`, gap: GAP },
|
|
693
839
|
resp: { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: holds };
|
|
694
840
|
return [{ t: 'Container', es: 'box', role: FooterRole.Halves, lay: { display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) minmax(0, 1fr)', gap: '0px' },
|
|
695
|
-
resp: { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: [brandPart(ctx, mix), end] }, part('rule'), part('copyright')];
|
|
841
|
+
resp: { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: [brandPart(ctx, mix), end] }, part('rule'), bottomRow(mix, part('copyright'))];
|
|
696
842
|
}
|
|
697
843
|
default:
|
|
698
|
-
return [{ t: 'Container', es: 'box', ...columnsOf(holds.length), c: [brandPart(ctx, mix), ...holds] }, part('rule'), part('copyright')];
|
|
844
|
+
return [{ t: 'Container', es: 'box', ...columnsOf(holds.length), c: [brandPart(ctx, mix), ...holds] }, part('rule'), bottomRow(mix, part('copyright'))];
|
|
699
845
|
}
|
|
700
846
|
}
|
|
701
847
|
|
|
@@ -732,7 +878,7 @@ export function footerPattern(given: FooterMix, ctx: FooterContext): SitePattern
|
|
|
732
878
|
const before = opens[mix.closing]?.() ?? [];
|
|
733
879
|
const body = mix.closing === FooterClosing.NameAndAction ? endOf(mix, ctx) : bodyOf(mix, ctx);
|
|
734
880
|
const name = mix.closing === FooterClosing.Name ? [closingName(ctx, mix)] : [];
|
|
735
|
-
const c = [...(plain ? [part('rule')] : []), ...before, ...body, ...name];
|
|
881
|
+
const c = [...(plain ? [part('rule')] : []), ...beforeBlock(mix, ctx), ...before, ...body, ...name];
|
|
736
882
|
// The contract's shell; a Section with one child does not stack it (the patterns' rule, build-spec "more than one child").
|
|
737
883
|
const { lay, ...shell } = part('section');
|
|
738
884
|
const scheme = GROUND_SCHEME[mix.ground] ?? null;
|
|
@@ -46,9 +46,20 @@ export interface FreeOpeningOffer {
|
|
|
46
46
|
|
|
47
47
|
/** What a free page's opening is offered, and whether it must open on a picture. */
|
|
48
48
|
export function freeOpeningOffer(site: FreeOpeningSite): FreeOpeningOffer {
|
|
49
|
-
|
|
49
|
+
const refused = picturesRefusedOf(site.reading);
|
|
50
|
+
if (!site.home || refused === PicturesRefused.All) return { boxes: [], opensOnPicture: false };
|
|
50
51
|
if (site.ownPhotos > 0) return { boxes: [], opensOnPicture: true };
|
|
51
|
-
return site.stockAllowed &&
|
|
52
|
+
return site.stockAllowed && refused !== PicturesRefused.Stock ? { boxes: [...FREE_OPENING_BOXES], opensOnPicture: true } : { boxes: [], opensOnPicture: false };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** What the owner ruled out of pictures: every picture, or stock only (their own photos may still stand). */
|
|
56
|
+
export enum PicturesRefused { All = 'all', Stock = 'stock' }
|
|
57
|
+
|
|
58
|
+
/** What the owner refused of pictures, read ONCE (the free offer and the build's opening ask the same): `all` — "no
|
|
59
|
+
* pictures" (`PromptLimit.NoPictures`); `stock` — "no stock photos" (only their own may stand); else null. Pure. */
|
|
60
|
+
export function picturesRefusedOf(reading: PromptReading | null | undefined): PicturesRefused | null {
|
|
61
|
+
if (promptLimitsOf(reading).includes(PromptLimit.NoPictures)) return PicturesRefused.All;
|
|
62
|
+
return refusesStock(reading) ? PicturesRefused.Stock : null;
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
/** Is a material id a picture box (`box:<shape>`)? */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { COLOR_SCHEME_TYPES, schemeOfGround } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
|
|
1
3
|
import { JsonSchema, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonText } from './json-schema';
|
|
2
4
|
import { isPlainObject, PlainObject } from './shape-check';
|
|
3
5
|
|
|
@@ -73,6 +75,12 @@ export const FREE_BUILDER_TYPE: Readonly<Record<FreeNodeType, string>> = {
|
|
|
73
75
|
[FreeNodeType.Slot]: 'Container',
|
|
74
76
|
};
|
|
75
77
|
|
|
78
|
+
/** The scheme the stamp gives a free box (iox-ui#186): the scheme its painted ground is (`schemeOfGround`), on a type that
|
|
79
|
+
* offers one — the stamp and the tree check read this ONE answer. */
|
|
80
|
+
export function freeSchemeOf(n: FreeNode): string | null {
|
|
81
|
+
return COLOR_SCHEME_TYPES.includes(FREE_BUILDER_TYPE[n.type]) ? schemeOfGround(n.styleProps?.['backgroundColor']) : null;
|
|
82
|
+
}
|
|
83
|
+
|
|
76
84
|
/** The one role a free node may carry: the heading a visitor reads first. */
|
|
77
85
|
export const FREE_LEAD_ROLE = 'lead';
|
|
78
86
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DesignChoices, designTokenRows, elementStyleFace, HeaderBrand, HeaderGround, headerGroundIsGlass, headerGroundIsOver, HeaderShape, headerShapeFloats, HeaderTrait, MenuForm, menuButtonOf, menuFormOf, menuHoverOf, MenuLook, MenuPhoneForm,
|
|
3
|
-
menuRevealOf, parseHexColor, resolveDesignChoices, resolveSchemeTokenValues, resolveTokenValues, ResolvedMode, textWidthEm, wcagContrastRatio,
|
|
3
|
+
menuRevealOf, MenuShows, menuShowsOf, parseHexColor, resolveDesignChoices, resolveSchemeTokenValues, resolveTokenValues, ResolvedMode, textWidthEm, wcagContrastRatio,
|
|
4
4
|
} from '@vectoriox/iox-ui/design-core';
|
|
5
5
|
|
|
6
|
+
import { menuCollectionsOfPlan, ShelfPlan } from './menu-shelves';
|
|
6
7
|
import { MenuSide, NavRole, NavShape } from './nav-shape';
|
|
7
8
|
import { OpeningMixError, openingMixOfPlan, OpeningRole } from './opening-mix';
|
|
8
9
|
import { calmUnder, PhotoInventory } from './photo-inventory';
|
|
@@ -295,6 +296,10 @@ export enum HeaderRepairCode {
|
|
|
295
296
|
NoLogo = 'no-logo',
|
|
296
297
|
/** HI3-D25: a kind of business that keeps its header plain never takes islands or a late name. */
|
|
297
298
|
TypeNeverShape = 'type-never-shape',
|
|
299
|
+
/** HI2: pictured cards stand in a top panel, a full screen or a mega panel — never a drawer or a card: the page names. */
|
|
300
|
+
PicturesForm = 'pictures-form',
|
|
301
|
+
/** HI2: pictured cards need the site's main collections with pictures (`menuPicturesMin`): the page names. */
|
|
302
|
+
FewCollections = 'few-collections',
|
|
298
303
|
}
|
|
299
304
|
|
|
300
305
|
export interface HeaderRepair {
|
|
@@ -342,12 +347,16 @@ export interface HeaderContext {
|
|
|
342
347
|
readonly never?: HeaderNever | null;
|
|
343
348
|
/** HI3-D21: the brand has a logo picture (a hanging name needs one). Absent: none known — a hanging name fits. */
|
|
344
349
|
readonly logo?: boolean | null;
|
|
350
|
+
/** HI2: the site's main collections with pictures (`menuCollectionsOfPlan`), in the navigation's order — what a
|
|
351
|
+
* `pictures` menu shows a card for. Absent: not judged. */
|
|
352
|
+
readonly collections?: ReadonlyArray<HeaderPage>;
|
|
345
353
|
}
|
|
346
354
|
|
|
347
355
|
const RULES = H.rules as unknown as Readonly<{
|
|
348
356
|
menuMinLinks: number; pinnedMax: number; inlineRoomPx: number; betweenNameEm: number; betweenMinPages: number;
|
|
349
357
|
overFrames: ReadonlyArray<string>; overMedia: ReadonlyArray<string>; glassFlavors: ReadonlyArray<string>;
|
|
350
358
|
glassIsOwnBar: ReadonlyArray<string>; noEdgeGrounds: ReadonlyArray<string>;
|
|
359
|
+
menuPicturesForms: ReadonlyArray<string>; menuPicturesMin: number;
|
|
351
360
|
}>;
|
|
352
361
|
/** How a laptop's bar is measured (an estimate on the look's own faces — never a guess at a page's words): the name at
|
|
353
362
|
* the brand's size, each page at the link's, the gap between them, and a button's padding around its words. */
|
|
@@ -410,6 +419,7 @@ export function checkHeader(mix: HeaderMix, ctx: HeaderContext): { mix: HeaderMi
|
|
|
410
419
|
m.action = HeaderAction.Button;
|
|
411
420
|
say(HeaderRepairCode.OneDestination, 'two actions need two places to go (the contact page and the shop): one button');
|
|
412
421
|
}
|
|
422
|
+
mendShelf(m, ctx, say);
|
|
413
423
|
mendGround(m, ctx, say);
|
|
414
424
|
mendShape(m, ctx, say);
|
|
415
425
|
return { mix: m, repairs };
|
|
@@ -443,6 +453,23 @@ function mendShape(m: HeaderMix, ctx: HeaderContext, say: (code: HeaderRepairCod
|
|
|
443
453
|
}
|
|
444
454
|
}
|
|
445
455
|
|
|
456
|
+
/** HI2 (plan §6): what the menu shows, as the site can carry it — pictured cards only in a menu wide enough to hold them
|
|
457
|
+
* beside the page names (Vonder's top panel, a full screen, a mega panel) and only for the collections the site has. */
|
|
458
|
+
function mendShelf(m: HeaderMix, ctx: HeaderContext, say: (code: HeaderRepairCode, said: string) => void): void {
|
|
459
|
+
if (menuShowsOf(m.menuShows) !== MenuShows.Pictures) return;
|
|
460
|
+
const form = menuLookOf(m).form;
|
|
461
|
+
if (!(RULES.menuPicturesForms ?? []).includes(form)) {
|
|
462
|
+
m.menuShows = MenuShows.Links;
|
|
463
|
+
say(HeaderRepairCode.PicturesForm, `pictured cards need a top panel, a full screen or a mega panel — not a ${form}: the menu shows the page names`);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
const count = ctx.collections?.length;
|
|
467
|
+
if (count !== undefined && count < RULES.menuPicturesMin) {
|
|
468
|
+
m.menuShows = MenuShows.Links;
|
|
469
|
+
say(HeaderRepairCode.FewCollections, `pictured cards need ${RULES.menuPicturesMin} collections with pictures — the site has ${count}: the menu shows the page names`);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
446
473
|
/** HI3-D12: does the home page open on a picture the header can stand over — the contract's frames and media. */
|
|
447
474
|
export function opensOnPicture(opening: HeaderOpening | null | undefined): boolean {
|
|
448
475
|
return !!opening && RULES.overFrames.includes(opening.frame) && RULES.overMedia.includes(opening.media);
|
|
@@ -708,6 +735,7 @@ export function menuLookOf(mix: HeaderMix): MenuLook {
|
|
|
708
735
|
button: menuButtonOf(mix.button),
|
|
709
736
|
hover: menuHoverOf(mix.menuHover),
|
|
710
737
|
phone: phoneFull && form !== MenuForm.Full ? MenuPhoneForm.Full : MenuPhoneForm.Drawer,
|
|
738
|
+
shows: menuShowsOf(mix.menuShows),
|
|
711
739
|
};
|
|
712
740
|
}
|
|
713
741
|
|
|
@@ -768,7 +796,7 @@ export function distinctHeader(mix: HeaderMix, taken: ReadonlyArray<string>, ctx
|
|
|
768
796
|
return { mix, repairs: [] };
|
|
769
797
|
}
|
|
770
798
|
|
|
771
|
-
type HeaderPlan = {
|
|
799
|
+
type HeaderPlan = ShelfPlan & {
|
|
772
800
|
readonly business: { readonly name: string }; readonly design?: Readonly<Partial<DesignChoices>>;
|
|
773
801
|
readonly mixes?: { readonly opening?: ReadonlyArray<string> };
|
|
774
802
|
readonly pages: ReadonlyArray<{ readonly name: string; readonly route: string; readonly inNav?: boolean; readonly isHome?: boolean; readonly sections?: ReadonlyArray<{ readonly binding?: string }> }>;
|
|
@@ -808,6 +836,7 @@ export function headerContextOfPlan(plan: HeaderPlan, shop?: string | null, fact
|
|
|
808
836
|
pages: plan.pages.filter(p => p.inNav && !p.isHome && p.route !== '/').map(p => ({ name: p.name, route: p.route })),
|
|
809
837
|
shop: shop === undefined ? shopPageOfPlan(plan) : shop,
|
|
810
838
|
opening: headerOpeningOfPlan(plan),
|
|
839
|
+
collections: menuCollectionsOfPlan(plan).map(c => ({ name: c.label, route: c.route })),
|
|
811
840
|
...(facts.never ? { never: facts.never } : {}),
|
|
812
841
|
...(facts.readableAtRest !== undefined && facts.readableAtRest !== null ? { readableAtRest: facts.readableAtRest } : {}),
|
|
813
842
|
};
|
|
@@ -173,6 +173,9 @@ export interface LegalContext {
|
|
|
173
173
|
/** ISO 3166-1 alpha-2 — the studio's country (Shop ▸ Settings; a shekel studio starts in Israel). Absent = unknown. */
|
|
174
174
|
country?: string | null;
|
|
175
175
|
trackers?: ReadonlyArray<LegalTracker>;
|
|
176
|
+
/** The site will count its visitors (the studio's or the plan's analytics intent) even before a tracker is connected:
|
|
177
|
+
* it gets its cookie banner and privacy page as a site with an analytics tracker does (`siteMeasures`). */
|
|
178
|
+
measures?: boolean | null;
|
|
176
179
|
/** The studio's own legal pages, by kind: their route. The build links them and never stamps that kind again. */
|
|
177
180
|
existing?: Readonly<Partial<Record<`${LegalKind}`, string>>>;
|
|
178
181
|
/** Every route the studio already has — a stamped legal page never takes one. */
|
|
@@ -211,3 +214,24 @@ export function legalFormLine(lang: string | null | undefined, withTerms: boolea
|
|
|
211
214
|
if (at < template.length) parts.push({ text: template.slice(at) });
|
|
212
215
|
return parts;
|
|
213
216
|
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Whether a site MEASURES its visitors (Doron 2026-11-28: "a privacy banner on every site that measures visitors") — a
|
|
220
|
+
* connected tracker, or the intent to count visitors. THE rule the build's banner, its privacy page and its categories
|
|
221
|
+
* read, so a site never measures before it asks. Pure.
|
|
222
|
+
*/
|
|
223
|
+
export function siteMeasures(context: Pick<LegalContext, 'trackers' | 'measures'> | null | undefined): boolean {
|
|
224
|
+
return (context?.trackers?.length ?? 0) > 0 || context?.measures === true;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** The categories a measuring site's banner asks a yes for, each once (Necessary never): its trackers' — or Analytics
|
|
228
|
+
* alone when it measures with none connected yet. */
|
|
229
|
+
export function measuredCategories(context: Pick<LegalContext, 'trackers' | 'measures'> | null | undefined): ConsentCategory[] {
|
|
230
|
+
const out: ConsentCategory[] = [];
|
|
231
|
+
for (const t of context?.trackers ?? []) {
|
|
232
|
+
const c = t.category as ConsentCategory;
|
|
233
|
+
if (c !== ConsentCategory.Necessary && !out.includes(c)) out.push(c);
|
|
234
|
+
}
|
|
235
|
+
if (!out.length && siteMeasures(context)) out.push(ConsentCategory.Analytics);
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { MenuTrait } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
|
|
3
|
+
import { ComposedSite, parseSampleImageRef } from './compose-site';
|
|
4
|
+
import { MENU_SHELF_RULES, NavPage, NavRole } from './nav-shape';
|
|
5
|
+
import { SerializedNode, walkSerialized } from './serialized-node';
|
|
6
|
+
import { ContentTypePlan, DataSourcePlan, PlanDataSourceMode, PlanDataSourceType, roleField, ShopResource } from './site-plan.model';
|
|
7
|
+
import { ShopSourceRole, shopSourceAliases } from './shop-plan';
|
|
8
|
+
import { pictureItemsOf } from './stock-photos';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The menu's shelves and their pictures (header-ingredients-plan.md HI2). A `pictures` menu shows a card for each of the
|
|
12
|
+
* site's main collections and a `words-card` menu one card beside its MORE row (`planNavShape`, nav-shape.ts). A card's
|
|
13
|
+
* picture is NEVER invented: the composer stamps it empty and the build fills it — once the site's own and stock pictures
|
|
14
|
+
* are placed — from the collection's first item that has a real picture, else the first picture on the card's page; a
|
|
15
|
+
* card with neither is taken away, and a shelf left with too few cards draws the page names (plan §6). Pure.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** One collection a menu may show a card for: its page and where its items' pictures are. */
|
|
19
|
+
export interface MenuCollection extends NavPage {
|
|
20
|
+
/** The items (a content type, or the shop's products) and the field holding each one's picture. */
|
|
21
|
+
readonly items: string;
|
|
22
|
+
readonly field: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const SHOP_PICTURE_FIELD = 'mainImage';
|
|
26
|
+
|
|
27
|
+
/** As much of a plan as the shelves read (a studio with no Site Plan has no sources: no collections). */
|
|
28
|
+
export interface ShelfPlan {
|
|
29
|
+
readonly pages?: ReadonlyArray<{ readonly name: string; readonly route: string; readonly inNav?: boolean; readonly isHome?: boolean; readonly sections?: ReadonlyArray<{ readonly binding?: string }> }>;
|
|
30
|
+
readonly dataSources?: ReadonlyArray<DataSourcePlan>;
|
|
31
|
+
readonly contentTypes?: ReadonlyArray<Pick<ContentTypePlan, 'name' | 'roles'>>;
|
|
32
|
+
readonly shop?: unknown;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The site's main collections, in the navigation's order: each page in the navigation (not Home) whose sections list a
|
|
37
|
+
* content type that has pictures (an `image` role) or the shop's products — the page a visitor opens to see them. ONE list
|
|
38
|
+
* for `checkHeader` (how many there are), the composer (the cards it stamps) and `dressMenuPictures` (where their
|
|
39
|
+
* pictures come from).
|
|
40
|
+
*/
|
|
41
|
+
export function menuCollectionsOfPlan(plan: ShelfPlan): MenuCollection[] {
|
|
42
|
+
const sources = new Map((plan.dataSources ?? []).map(s => [s.alias, s]));
|
|
43
|
+
const shopList = plan.shop ? shopSourceAliases(plan)[ShopSourceRole.List] : undefined;
|
|
44
|
+
const out: MenuCollection[] = [];
|
|
45
|
+
for (const page of plan.pages ?? []) {
|
|
46
|
+
if (!page.inNav || page.isHome || page.route === '/') continue;
|
|
47
|
+
for (const section of page.sections ?? []) {
|
|
48
|
+
const source = section.binding ? sources.get(section.binding) : undefined;
|
|
49
|
+
if (!source) continue;
|
|
50
|
+
if (source.alias === shopList) {
|
|
51
|
+
out.push({ label: page.name, route: page.route, items: ShopResource.Products, field: SHOP_PICTURE_FIELD });
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
if (source.type !== PlanDataSourceType.Cms || source.mode !== PlanDataSourceMode.Query) continue;
|
|
55
|
+
const type = (plan.contentTypes ?? []).find(t => t.name === source.contentType);
|
|
56
|
+
const field = roleField(type, 'image');
|
|
57
|
+
if (!type || !field) continue;
|
|
58
|
+
out.push({ label: page.name, route: page.route, items: type.name, field });
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** A value that IS a picture a visitor can see: an address, never a bundled sample's `{sampleImage:k}` or nothing. */
|
|
66
|
+
function realPicture(value: unknown): string | null {
|
|
67
|
+
const first = Array.isArray(value) ? value[0] : value;
|
|
68
|
+
return typeof first === 'string' && first.trim() && parseSampleImageRef(first) === null ? first : null;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The first picture written on a page (an Image with an address and no binding), in reading order. */
|
|
72
|
+
function pagePicture(page: ComposedSite['pages'][number] | undefined): string | null {
|
|
73
|
+
let found: string | null = null;
|
|
74
|
+
if (page) walkSerialized(page.layout, n => {
|
|
75
|
+
if (!found && n.type === 'Image' && !n.bindings?.length) found = realPicture(n.props?.['src']);
|
|
76
|
+
});
|
|
77
|
+
return found;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Where a card's picture comes from: its collection's first item with a real picture, else its page's first picture. */
|
|
81
|
+
export function menuCardPicture(site: Pick<ComposedSite, 'pages' | 'items'> & Partial<Pick<ComposedSite, 'shop'>>, collections: ReadonlyArray<MenuCollection>, route: string): string | null {
|
|
82
|
+
const collection = collections.find(c => c.route === route);
|
|
83
|
+
const items = collection ? pictureItemsOf(site)[collection.items] ?? [] : [];
|
|
84
|
+
for (const item of items) {
|
|
85
|
+
const url = realPicture(item[collection!.field]);
|
|
86
|
+
if (url) return url;
|
|
87
|
+
}
|
|
88
|
+
return pagePicture(site.pages.find(p => p.route.path === route));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Fill the menu's cards with the site's own or stock pictures (`menuCardPicture`) — run by the build after every picture
|
|
93
|
+
* is placed (iox-cms `dressWithStock`). A card with no picture is taken away; a `pictures` shelf left with fewer cards
|
|
94
|
+
* than the contract's least becomes the page names alone (the shelf's list kept, the menu's trait cleared); a MORE row
|
|
95
|
+
* left empty goes. Returns how many cards were filled. Mutates `site.globals`.
|
|
96
|
+
*/
|
|
97
|
+
export function dressMenuPictures(
|
|
98
|
+
site: Pick<ComposedSite, 'globals' | 'pages' | 'items'> & Partial<Pick<ComposedSite, 'shop'>>,
|
|
99
|
+
plan: ShelfPlan,
|
|
100
|
+
): number {
|
|
101
|
+
const collections = menuCollectionsOfPlan(plan);
|
|
102
|
+
let filled = 0;
|
|
103
|
+
const drawers: SerializedNode[] = [];
|
|
104
|
+
walkSerialized(site.globals, n => { if (n.role === NavRole.Drawer) drawers.push(n); });
|
|
105
|
+
for (const dr of drawers) {
|
|
106
|
+
walkSerialized([dr], parent => {
|
|
107
|
+
const kept = (parent.children ?? []).filter(card => {
|
|
108
|
+
if (card.role !== NavRole.DrawerCard) return true;
|
|
109
|
+
const picture = (card.children ?? []).find(c => c.role === NavRole.DrawerPicture);
|
|
110
|
+
if (!picture) return false;
|
|
111
|
+
const url = realPicture(picture.props?.['src']) ?? menuCardPicture(site, collections, String(card.props?.['pageRoute'] ?? ''));
|
|
112
|
+
if (!url) return false;
|
|
113
|
+
picture.props = { ...picture.props, src: url, alt: '' };
|
|
114
|
+
filled++;
|
|
115
|
+
return true;
|
|
116
|
+
});
|
|
117
|
+
if (parent.children) parent.children = kept;
|
|
118
|
+
});
|
|
119
|
+
unshelve(dr, MENU_SHELF_RULES.menuPicturesMin ?? 1);
|
|
120
|
+
}
|
|
121
|
+
return filled;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A shelf the pictures did not fill: a `pictures` row with too few cards is the page names alone; an empty MORE row goes. */
|
|
125
|
+
function unshelve(dr: SerializedNode, least: number): void {
|
|
126
|
+
const kids = dr.children ?? [];
|
|
127
|
+
dr.children = kids.flatMap(child => {
|
|
128
|
+
if (child.role === NavRole.DrawerShelf) {
|
|
129
|
+
const cards = (child.children ?? []).find(c => c.role === NavRole.DrawerPictures);
|
|
130
|
+
if ((cards?.children?.length ?? 0) >= Math.max(least, 1)) return [child];
|
|
131
|
+
const list = (child.children ?? []).find(c => c.role === NavRole.DrawerLinks);
|
|
132
|
+
if (dr.props) delete dr.props[MenuTrait.Shows];
|
|
133
|
+
return list ? [list] : [];
|
|
134
|
+
}
|
|
135
|
+
if (child.role === NavRole.DrawerMore && !(child.children ?? []).length) return [];
|
|
136
|
+
return [child];
|
|
137
|
+
});
|
|
138
|
+
}
|