@vectoriox/iox-ui 5.198.0 → 5.200.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 +479 -52
- 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 +704 -55
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs +5 -2
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +16659 -15146
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +653 -70
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +5 -2
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +883 -235
- package/harness-core/index.d.ts +372 -9
- 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/brand-neutrals.ts +125 -3
- package/src/design-core/colour-words.ts +48 -0
- package/src/design-core/design-settings.ts +24 -5
- package/src/design-core/design-token.model.ts +8 -0
- package/src/design-core/flavor-fixtures.generated.ts +272 -2
- package/src/design-core/flavor-spec.generated.ts +310 -40
- package/src/design-core/flavor-tokens.ts +5 -1
- package/src/design-core/menu-look.ts +23 -0
- package/src/design-core/node-classes.ts +39 -0
- package/src/design-core/public-api.ts +2 -0
- package/src/design-core/signature-move.ts +107 -0
- package/src/design-core/style-presets.ts +9 -3
- package/src/design-core/token-css.ts +59 -1
- package/src/forms-core/form-presets.ts +5 -2
- package/src/generation-core/body-mix.ts +41 -0
- package/src/generation-core/check-free.ts +17 -9
- package/src/generation-core/check-layout.ts +17 -7
- package/src/generation-core/colour-mix.ts +53 -3
- package/src/generation-core/compose-free.ts +7 -2
- package/src/generation-core/compose-site.ts +298 -78
- package/src/generation-core/composition.ts +320 -0
- package/src/generation-core/footer-mix.ts +202 -16
- package/src/generation-core/footer-sign-up.ts +51 -0
- package/src/generation-core/free-opening.ts +13 -2
- package/src/generation-core/free-wire.ts +8 -0
- package/src/generation-core/header-edit.ts +15 -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/opening-edit.ts +17 -3
- package/src/generation-core/opening-mix.ts +69 -5
- package/src/generation-core/patterns.ts +7 -0
- package/src/generation-core/plan-wire.ts +23 -5
- package/src/generation-core/public-api.ts +3 -0
- package/src/generation-core/site-build-run.ts +11 -0
- package/src/generation-core/site-plan.model.ts +6 -0
- package/src/generation-core/site-spec.generated.ts +472 -166
- package/src/generation-core/type-led.ts +4 -2
- package/src/generation-core/validate-site-plan.ts +4 -1
- package/src/harness-core/business-types.ts +31 -0
- package/src/harness-core/harness-spec.generated.ts +564 -56
- package/src/harness-core/motion.ts +19 -2
- package/src/harness-core/popup-stance.ts +56 -3
- package/src/harness-core/run-compose-context.ts +32 -6
- package/src/harness-core/starting-design.ts +15 -7
- package/styles/iox-design.css +35 -0
- package/styles/iox-forms.css +53 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { carryInto, swapParts, type PageCarry } from './carry';
|
|
2
2
|
import {
|
|
3
|
-
AnimateId, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, colorSchemeClass, DEFAULT_MENU_LOOK, DesignChoices, LinkType, MenuLook, motionLanguageForPlan, resolveDesignChoices, setColorScheme, headerBrandOf, headerGroundOf, headerInkOf, headerShapeOf,
|
|
4
|
-
columnWordOf,
|
|
3
|
+
AnimateId, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, colorSchemeClass, DEFAULT_MENU_LOOK, DesignChoices, LinkType, SignatureInput, withSignatureMove, MenuLook, motionLanguageForPlan, resolveDesignChoices, setColorScheme, headerBrandOf, headerGroundOf, headerInkOf, headerShapeOf,
|
|
4
|
+
columnWordOf, elementStyleById,
|
|
5
5
|
} from '@vectoriox/iox-ui/design-core';
|
|
6
6
|
import { fitSeoText, SEO_DESCRIPTION_MAX, SEO_TITLE_MAX, SeoRawDoc } from '@vectoriox/iox-ui/seo-core';
|
|
7
7
|
import { busyWord, channelOpensNewTab, FORM_ACTIONS_ROLE, FORM_CHANNEL_ROLE, FormPresetChannel, FormPresetDef, FormPresetField, formPresetById, FormPresetId, presetFormActions } from '@vectoriox/iox-ui/forms-core';
|
|
@@ -14,26 +14,27 @@ import {
|
|
|
14
14
|
setHeaderBehaviour, setHeaderBrand, setHeaderGround, setHeaderInk, setHeaderShape, SHOP_RECIPES, ShopRecipe, ShopRole, bindShopPart, ShopBindTarget, ACCOUNT_RECIPES, AccountRecipe, AccountRole,
|
|
15
15
|
buildConsentRecipe, canOpenAtClickedItem, ConsentActionType, ContentFieldLike, CarouselFrom, carouselQuoteLabel, CAROUSEL_QUOTE_LABELS, pickCarouselAutoBinds,
|
|
16
16
|
} from '@vectoriox/iox-ui/composite-core';
|
|
17
|
-
import { ConsentCategory } from '@vectoriox/iox-ui/consent-core';
|
|
18
17
|
|
|
19
18
|
import { EntranceMark, EntrancePart, planEntrances } from './entrances';
|
|
20
19
|
import { scrubEntranceStamps } from './text-scroll';
|
|
21
20
|
import { filmOfPlan } from './film';
|
|
22
21
|
import { checkFooter, FooterArrange, footerMixOfPlan, FooterNever, footerPattern, FooterRole, stampFooterMix } from './footer-mix';
|
|
22
|
+
import { planWrites, withTypeSignUp } from './footer-sign-up';
|
|
23
23
|
import {
|
|
24
24
|
countryLegalFacts, FOOTER_LEGAL_ROLE, FORM_LEGAL_ROLE, formAsksPersonalData, formLegalFacts, LEGAL_PAGE_SETTING, LegalContext, LegalFact, LegalFacts,
|
|
25
|
-
legalFormLine, LegalKind, legalKindsFor, legalLabel, legalRoute, legalTitle,
|
|
25
|
+
legalFormLine, LegalKind, legalKindsFor, legalLabel, legalRoute, legalTitle, measuredCategories, siteMeasures,
|
|
26
26
|
} from './legal';
|
|
27
27
|
import {
|
|
28
|
-
checkOpening, drawnOpeningMix, namedOpeningMix, OpeningContext, openingIsTypeLed, openingMix, OpeningMix, openingMixOfPlan, openingRecipe, OpeningRole, stampOpeningMix,
|
|
28
|
+
checkOpening, drawnOpeningMix, namedOpeningMix, OpeningContext, openingIsTypeLed, OpeningMedia, openingMix, OpeningMix, openingMixFromWords, openingMixOfPlan, openingRecipe, OpeningRole, stampOpeningMix,
|
|
29
29
|
stampOpeningMotion, TYPE_LED_OPTIONAL_PARTS, typeLedOpeningSection,
|
|
30
30
|
} from './opening-mix';
|
|
31
|
+
import { bodyWithColourBands, colourMixOfPlan, planDesignChoices } from './colour-mix';
|
|
31
32
|
import { checkHeader, drawnHeaderMix, HeaderContext, headerContextOfPlan, HeaderFacts, HeaderIngredient, HeaderNever, HeaderOpening, headerMix, HeaderMix, headerRecipe, HeaderRecipe, stampHeaderMix, wornHeaderOfPlan } from './header-mix';
|
|
32
|
-
import { bodyMixOfPlan, checkBody, drawnBodyMix, joinPageHeader, wearBodyMix } from './body-mix';
|
|
33
|
+
import { bodyMixOfPlan, checkBody, drawnBodyMix, joinPageHeader, joinSameGround, wearBodyMix } from './body-mix';
|
|
33
34
|
import { checkPopup, composePopup, POPUP_GLOBAL_ID } from './popup-plan';
|
|
34
35
|
import { NODE_BASELINES } from './node-baselines.generated';
|
|
35
36
|
import {
|
|
36
|
-
BindScope, CardBindTarget, parsePatternPath, PatternDirective, PatternGlobalPosition, PatternNode, PatternOpens, PatternPlaceholder, PatternRecipe, PatternTrack,
|
|
37
|
+
BindScope, CardBindTarget, parsePatternPath, PatternDirective, PatternGlobalPosition, PatternNode, PatternOpens, PatternPlaceholder, PatternRecipe, PatternScrolls, PatternTrack,
|
|
37
38
|
PriceBindTarget, SitePattern, patternById,
|
|
38
39
|
} from './patterns';
|
|
39
40
|
import { planSells, shopCategoriesOf, shopContentType, shopListsShownOn, variantNamesOf } from './shop-plan';
|
|
@@ -41,19 +42,20 @@ import { CheckLayoutContext, withShownList } from './check-layout';
|
|
|
41
42
|
import { recipeListBinds } from './recipe-fields';
|
|
42
43
|
import { assertStyleSlots, ComposeError, createSerializedNode, SerializedBinding, SerializedNode, setStyleProps, walkSerialized } from './serialized-node';
|
|
43
44
|
import { refreshSectionStamps, stampSection } from './section-stamp';
|
|
45
|
+
import { archetypeRank, BorrowedSection, BorrowKind, baseOrder, composesPage, compositionBorrows, compositionSwaps, orderPlaces, pageKindOf, sectionSkeleton, skeletonOf } from './composition';
|
|
44
46
|
import { SitePlanSourceKind, ContentFieldControl, ContentFieldPlan,
|
|
45
47
|
ContentRole, ContentTypePlan, DataSourcePlan, DEFAULT_SITE_LOCALE, FactKey, FACT_KEYS, GlobalSlot, isRtlLocale, ITEM_PAGE_ONLY_ROLES, PagePlan, PageSectionPlan, PlanDataSourceMode,
|
|
46
48
|
PlanDataSourceType, RelativeOp, roleField, SiteLocale, SitePlan, SitePlanSource, siteFactLabel, SiteBusiness, GenerationTier,
|
|
47
49
|
} from './site-plan.model';
|
|
48
50
|
import { assertValidSitePlan, nextSourceOf, routeParams } from './validate-site-plan';
|
|
49
51
|
import { PictureSupply, TypeLed, TypeLedChange, TypeLedChangeKind, typeLedRound } from './type-led';
|
|
50
|
-
import { MenuSide, NavRole, NavShape, planNavShape } from './nav-shape';
|
|
52
|
+
import { MenuSide, NavPage, NavRole, NavShape, planNavShape } from './nav-shape';
|
|
51
53
|
import { composeLayout, LayoutColourMode, layoutBandScheme, LayoutListBinding } from './compose-layout';
|
|
52
54
|
import { LayoutGalleryList, LayoutListShape, LayoutPage, LayoutPhotoShape, LayoutPhotoSource, LayoutSite, parseLayoutPhotoId } from './layout-language';
|
|
53
55
|
import { layoutMotionOf, layoutPresetOf } from './layout-look';
|
|
54
56
|
import { ComposeFreeOptions, composeFreePage, composeFreeSection } from './compose-free';
|
|
55
57
|
import { isFreeBox } from './free-opening';
|
|
56
|
-
import { FreePage } from './free-wire';
|
|
58
|
+
import { FreeNode, FreeNodeType, FreePage } from './free-wire';
|
|
57
59
|
|
|
58
60
|
/**
|
|
59
61
|
* THE composer — a Site Plan in, ordinary IOX data out (design-system plan §6b, W1). Deterministic and
|
|
@@ -140,6 +142,9 @@ export enum ComposeIssueCode {
|
|
|
140
142
|
PopupMended = 'popup-mended',
|
|
141
143
|
/** Popups PU3: the owner's popup line made no popup (a figure the owner's words do not hold, news too long): the detail says why. */
|
|
142
144
|
PopupRefused = 'popup-refused',
|
|
145
|
+
/** Composition (composition-plan.md): a pattern page borrowed a section the plan wrote on another page, or was reordered
|
|
146
|
+
* so no two neighbours share a skeleton (`composePlaces`): the detail says what. */
|
|
147
|
+
CompositionMended = 'composition-mended',
|
|
143
148
|
}
|
|
144
149
|
|
|
145
150
|
/** The issues that are a dangling link (a route the plan has no page for) and what was done about it. */
|
|
@@ -179,6 +184,9 @@ export interface ComposeContext {
|
|
|
179
184
|
/** AW12-D10: what that kind of business's footer never wears (harness-core `BusinessType.footer`) — `checkFooter`
|
|
180
185
|
* mends it, said. Absent = nothing refused. */
|
|
181
186
|
footerNever?: FooterNever;
|
|
187
|
+
/** AW12 newsletter: that kind of business's references close with a sign-up (harness-core `BusinessType.signUp`) — a
|
|
188
|
+
* footer that asks for none holds one (`withTypeSignUp`), and the type is a reason to write (`planWrites`). */
|
|
189
|
+
footerSignUp?: boolean;
|
|
182
190
|
/** HI3-D12: what that kind of business never stands its header on (harness-core `BusinessType.header`) — `checkHeader`
|
|
183
191
|
* mends it to its own ground, said. Absent = nothing refused. */
|
|
184
192
|
headerNever?: HeaderNever;
|
|
@@ -194,6 +202,14 @@ export interface ComposeContext {
|
|
|
194
202
|
/** #129: which picture slots a picture fills (the owner's, a made one, a stock one). Given, a section whose picture
|
|
195
203
|
* nothing fills is composed type-led (`type-led.ts`); absent, the plan composes exactly as it says. */
|
|
196
204
|
pictures?: PictureSupply;
|
|
205
|
+
/** Motion reach (MR-D1): what the kind of business says about its site's signature move (harness-core `signatureInputOf`,
|
|
206
|
+
* given by `businessComposeContext`) — the look is signed with design-core `withSignatureMove` before anything is
|
|
207
|
+
* stamped, so a rebuild from a kept plan signs too. Absent: the look composes as the plan writes it. */
|
|
208
|
+
signature?: SignatureInput;
|
|
209
|
+
/** Pictures first (harness `BusinessType.opening`, given by harness-core `businessComposeContext` only when a picture can
|
|
210
|
+
* come — the owner's photo, or stock where the type allows it, never against the owner's "no pictures"): the opening
|
|
211
|
+
* words a Home whose plan names no opening takes (`withTypeOpening`). Absent: the Home opens as its plan writes. */
|
|
212
|
+
opening?: ReadonlyArray<string>;
|
|
197
213
|
}
|
|
198
214
|
|
|
199
215
|
/** Where a composed layout's photos are, as the server keeps them and the screens read them (M8 gate 2): id → address. */
|
|
@@ -420,8 +436,6 @@ interface Ctx {
|
|
|
420
436
|
keepButtons?: boolean;
|
|
421
437
|
/** M1-6b: the pattern's entrance parts as stamped, for `planEntrances` once the pattern is whole. */
|
|
422
438
|
entrances?: Array<Omit<EntranceMark, 'index'>>;
|
|
423
|
-
/** #129: the content types whose items have no picture at all — an optional `@image?` of theirs is left out. */
|
|
424
|
-
pictureless?: ReadonlySet<string>;
|
|
425
439
|
}
|
|
426
440
|
|
|
427
441
|
interface ShownWhen {
|
|
@@ -513,8 +527,9 @@ function resolveScopedPath(path: string, repeater: RepeaterScope | null, ctx: Ct
|
|
|
513
527
|
const { source, typeSource } = scopeOf(parsed.scope, path, repeater, ctx, nodeId);
|
|
514
528
|
if (!parsed.role) return { source, path: parsed.field || ITEM_VALUE_PATH };
|
|
515
529
|
const type = typeSource ? contentTypeOfSource(typeSource, ctx.plan) : undefined;
|
|
516
|
-
// #129: a list whose items have no picture
|
|
517
|
-
|
|
530
|
+
// #129 × iox-ui#191: a list whose items have no picture KEEPS its picture part, bound — the shared CSS draws a card
|
|
531
|
+
// without it wherever its own item has none (iox-design.css "A row's card with no picture"), so the owner's photos,
|
|
532
|
+
// added after the build, show the moment they are saved. Never decided here, at build time.
|
|
518
533
|
const field = roleField(type, parsed.role);
|
|
519
534
|
if (field) return { source, path: field };
|
|
520
535
|
if (parsed.optional) return null;
|
|
@@ -743,8 +758,11 @@ enum DanglingFate {
|
|
|
743
758
|
Unlink = 'unlink',
|
|
744
759
|
}
|
|
745
760
|
|
|
761
|
+
/** FV1b: an address outside the site (a footer's social link, `footerSocialLinks` — https only) is an external link. */
|
|
762
|
+
const isExternalHref = (href: string): boolean => href.startsWith('https://');
|
|
763
|
+
|
|
746
764
|
function danglingFate(pn: PatternNode, ctx: Ctx): DanglingFate | null {
|
|
747
|
-
if (!pn.href || pn.href === PatternDirective.PageRoute || ctx.routes.has(pn.href)) return null;
|
|
765
|
+
if (!pn.href || pn.href === PatternDirective.PageRoute || ctx.routes.has(pn.href) || isExternalHref(pn.href)) return null;
|
|
748
766
|
if (ctx.email) return DanglingFate.Email;
|
|
749
767
|
return UNLINKED_TYPE[pn.t] || (ctx.keepButtons && pn.t === BUTTON_BLOCK) ? DanglingFate.Unlink : DanglingFate.Remove;
|
|
750
768
|
}
|
|
@@ -965,6 +983,11 @@ function composeNode(given: PatternNode, id: string, repeater: RepeaterScope | n
|
|
|
965
983
|
if (pn.opens !== PatternOpens.Lightbox) throw new ComposeError(`${id}: "opens" names the pattern's lightbox`);
|
|
966
984
|
(ctx.openers ??= []).push(id);
|
|
967
985
|
}
|
|
986
|
+
if (pn.scrolls) {
|
|
987
|
+
if (pn.scrolls !== PatternScrolls.Top) throw new ComposeError(`${id}: "scrolls" names the page's top`);
|
|
988
|
+
// A scrollTo with no target is the page's top in both renderers (actions-core `scrollsToPageTop`).
|
|
989
|
+
node.interactions = [{ id: `${id}-scrolls`, trigger: 'click', actions: [{ type: 'scrollTo', duration: 0, delay: 0, easing: 'ease' }] }];
|
|
990
|
+
}
|
|
968
991
|
|
|
969
992
|
// Images: an empty slot, or a bound one — both fall back to the DS3 empty image, never a stock URL.
|
|
970
993
|
if (pn.ph === PatternPlaceholder.Image) {
|
|
@@ -977,7 +1000,8 @@ function composeNode(given: PatternNode, id: string, repeater: RepeaterScope | n
|
|
|
977
1000
|
if (pn.href === PatternDirective.PageRoute) {
|
|
978
1001
|
writePageLink(node, stampedPageValue(`${BindScope.Page}.route`, ctx, id));
|
|
979
1002
|
} else if (pn.href && !fate) {
|
|
980
|
-
|
|
1003
|
+
if (isExternalHref(pn.href)) writeExternalLink(node, pn.href);
|
|
1004
|
+
else writePageLink(node, pn.href);
|
|
981
1005
|
} else if (fate) {
|
|
982
1006
|
if (fate === DanglingFate.Email) writeExternalLink(node, `${MAILTO}${ctx.email}`);
|
|
983
1007
|
reportDangling(fate, pn, id, words.value, ctx);
|
|
@@ -1729,6 +1753,82 @@ function composePageSeo(page: PagePlan, plan: SitePlan): SeoRawDoc {
|
|
|
1729
1753
|
return { ...(title ? { title } : {}), ...(description ? { description } : {}), ...(robots ? { robots } : {}) };
|
|
1730
1754
|
}
|
|
1731
1755
|
|
|
1756
|
+
/** A borrowed section stamped into its own placeholder and issue lists (a borrow that would add one is refused). */
|
|
1757
|
+
type BorrowStamp = (section: PageSectionPlan, id: string, sink: Pick<Ctx, 'placeholders' | 'issues'>) => SerializedNode;
|
|
1758
|
+
|
|
1759
|
+
/** A borrowed list shows its first `limit` items: the first Repeater (or a recipe holding a `limit`, the accordion's). */
|
|
1760
|
+
function cutList(root: SerializedNode, limit: number): void {
|
|
1761
|
+
let done = false;
|
|
1762
|
+
walkSerialized([root], n => {
|
|
1763
|
+
if (done) return;
|
|
1764
|
+
const held = n.props?.['limit'];
|
|
1765
|
+
if (n.type !== REPEATER && held === undefined) return;
|
|
1766
|
+
setProp(n, 'limit', typeof held === 'number' ? Math.min(held, limit) : limit);
|
|
1767
|
+
done = true;
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
/**
|
|
1772
|
+
* Composition (composition-plan.md): a pattern page's places — its own sections, then what it borrows from the plan's
|
|
1773
|
+
* other pages (`compositionBorrows`, each stamped without a placeholder or an issue, its list cut to the borrow's
|
|
1774
|
+
* `limit`), in the order nearest the archetype's in which no two neighbours share a skeleton (`orderPlaces`). Plan
|
|
1775
|
+
* sections keep their node ids (`<page>-<i>`); a borrowed one is `<page>-borrowed-<n>`. Every borrow and reorder is said.
|
|
1776
|
+
*/
|
|
1777
|
+
function composePlaces(page: PagePlan, plan: SitePlan, own: SerializedNode[], stamp: BorrowStamp, issues: ComposeIssue[]): SerializedNode[] {
|
|
1778
|
+
// A template's item page, a page kind the table names no minimum for: its plan's order as written.
|
|
1779
|
+
if (!composesPage(page)) return own;
|
|
1780
|
+
const kind = pageKindOf(page);
|
|
1781
|
+
const stamped: SerializedNode[] = [];
|
|
1782
|
+
const borrowed = compositionBorrows(page, plan, (b: BorrowedSection) => {
|
|
1783
|
+
const sink = { placeholders: [] as ComposedPlaceholder[], issues: [] as ComposeIssue[] };
|
|
1784
|
+
let root: SerializedNode;
|
|
1785
|
+
try {
|
|
1786
|
+
root = stampSection(stamp(b.section, `${page.key}-borrowed-${stamped.length}`, sink), { pattern: b.section.pattern });
|
|
1787
|
+
} catch {
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
if (sink.placeholders.length || sink.issues.length) return false;
|
|
1791
|
+
if (b.limit) cutList(root, b.limit);
|
|
1792
|
+
stamped.push(root);
|
|
1793
|
+
return true;
|
|
1794
|
+
});
|
|
1795
|
+
const last = page.sections.length - 1;
|
|
1796
|
+
const ownPlaces = page.sections.map((s, i) => ({
|
|
1797
|
+
skeleton: sectionSkeleton(s, i), rank: archetypeRank(kind, s.pattern), ask: i === last && patternById(s.pattern)?.family === 'cta',
|
|
1798
|
+
}));
|
|
1799
|
+
const borrowedPlaces = borrowed.map(b => ({ skeleton: b.skeleton, rank: archetypeRank(kind, b.section.pattern), ask: b.kind === BorrowKind.Ask }));
|
|
1800
|
+
const places = [...ownPlaces, ...borrowedPlaces];
|
|
1801
|
+
const base = baseOrder(ownPlaces, borrowedPlaces);
|
|
1802
|
+
const holdLast = places[base[base.length - 1]]?.ask === true;
|
|
1803
|
+
const order = orderPlaces(places, base, holdLast);
|
|
1804
|
+
const nodes = [...own, ...stamped];
|
|
1805
|
+
// The last mend: a sibling carrying every slot, for a pair no order clears — kept only when it stamps clean.
|
|
1806
|
+
for (const [i, swapped] of compositionSwaps(page.sections, order, places.map(p => p.skeleton), holdLast)) {
|
|
1807
|
+
const sink = { placeholders: [] as ComposedPlaceholder[], issues: [] as ComposeIssue[] };
|
|
1808
|
+
let root: SerializedNode;
|
|
1809
|
+
try {
|
|
1810
|
+
root = stampSection(stamp(swapped, nodes[i].id, sink), { pattern: swapped.pattern });
|
|
1811
|
+
} catch {
|
|
1812
|
+
continue;
|
|
1813
|
+
}
|
|
1814
|
+
if (sink.placeholders.length || sink.issues.length) continue;
|
|
1815
|
+
nodes[i] = root;
|
|
1816
|
+
places[i] = { ...places[i], skeleton: skeletonOf(swapped.pattern) };
|
|
1817
|
+
issues.push({
|
|
1818
|
+
code: ComposeIssueCode.CompositionMended, nodeId: root.id, owner: page.key,
|
|
1819
|
+
detail: `${page.name}: ${patternById(page.sections[i].pattern)?.label ?? page.sections[i].pattern} is worn as ${patternById(swapped.pattern)?.label ?? swapped.pattern} so no two neighbours share a skeleton`,
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
borrowed.forEach((b, j) => issues.push({ code: ComposeIssueCode.CompositionMended, nodeId: stamped[j].id, owner: page.key, detail: b.said }));
|
|
1823
|
+
if (order.some((v, i) => v !== base[i])) {
|
|
1824
|
+
issues.push({
|
|
1825
|
+
code: ComposeIssueCode.CompositionMended, nodeId: page.key, owner: page.key,
|
|
1826
|
+
detail: `${page.name}'s sections were reordered so no two neighbours share a skeleton (${order.map(i => places[i].skeleton).join(' · ')})`,
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
return order.map(i => nodes[i]);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1732
1832
|
function composeDataSource(ds: DataSourcePlan): ComposedDataSource {
|
|
1733
1833
|
const id = `ds-${ds.alias}`;
|
|
1734
1834
|
if (ds.type === PlanDataSourceType.Cms) {
|
|
@@ -1842,39 +1942,29 @@ function composeLayoutPage(
|
|
|
1842
1942
|
const image = type && pictureless.has(type.name) ? undefined : roleField(type, 'image');
|
|
1843
1943
|
return image ? { image, ...(roleField(type, 'title') ? { title: roleField(type, 'title')! } : {}) } : null;
|
|
1844
1944
|
},
|
|
1845
|
-
listOf: alias =>
|
|
1945
|
+
listOf: alias => layoutListBinding(alias, plan),
|
|
1846
1946
|
...(context.carry?.[page.key] ? { carry: context.carry[page.key] } : {}),
|
|
1847
1947
|
});
|
|
1848
1948
|
fillPageFacts(nodes, page, plan, placeholders);
|
|
1849
1949
|
return nodes;
|
|
1850
1950
|
}
|
|
1851
1951
|
|
|
1852
|
-
/** How a model-laid page reads one list (`layoutListBinding`) — #129: a list whose items have no picture is read as a list
|
|
1853
|
-
* without one (its cards draw no picture part). */
|
|
1854
|
-
function pageListOf(alias: string, plan: SitePlan, pictureless: ReadonlySet<string>): LayoutListBinding | null {
|
|
1855
|
-
const binding = layoutListBinding(alias, plan);
|
|
1856
|
-
const type = contentTypeOfSource(alias, plan);
|
|
1857
|
-
if (!binding || !type || !pictureless.has(type.name) || !binding.roles[ContentRole.Image]) return binding;
|
|
1858
|
-
const { [ContentRole.Image]: _none, ...roles } = binding.roles;
|
|
1859
|
-
return { ...binding, roles };
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
1952
|
/**
|
|
1863
1953
|
* FS3: a free page — the model's own nodes, stamped by `composeFreePage` in the look's pace — with the site's facts
|
|
1864
1954
|
* written in as on a composed page; a section the fall back gave back is the plan's ready-made one.
|
|
1865
1955
|
*/
|
|
1866
1956
|
function composeFreePlanPage(
|
|
1867
|
-
page: PagePlan, free: FreePage, plan: SitePlan, context: ComposeContext, placeholders: ComposedPlaceholder[],
|
|
1957
|
+
page: PagePlan, free: FreePage, plan: SitePlan, context: ComposeContext, placeholders: ComposedPlaceholder[],
|
|
1868
1958
|
readyMade: (section: PageSectionPlan, id: string, at: number) => SerializedNode,
|
|
1869
1959
|
): SerializedNode[] {
|
|
1870
|
-
const nodes = composeFreePage(free, freeOptionsOf(page, plan, context,
|
|
1960
|
+
const nodes = composeFreePage(free, freeOptionsOf(page, plan, context, readyMade));
|
|
1871
1961
|
fillPageFacts(nodes, page, plan, placeholders);
|
|
1872
1962
|
return nodes;
|
|
1873
1963
|
}
|
|
1874
1964
|
|
|
1875
1965
|
/** What the free stamp reads of the site: its language, the look's pace, the owner's pictures, the plan's lists. */
|
|
1876
1966
|
function freeOptionsOf(
|
|
1877
|
-
page: PagePlan, plan: SitePlan, context: ComposeContext,
|
|
1967
|
+
page: PagePlan, plan: SitePlan, context: ComposeContext,
|
|
1878
1968
|
readyMade?: (section: PageSectionPlan, id: string, at: number) => SerializedNode,
|
|
1879
1969
|
): ComposeFreeOptions {
|
|
1880
1970
|
const locale = plan.locale ?? DEFAULT_SITE_LOCALE;
|
|
@@ -1882,7 +1972,7 @@ function freeOptionsOf(
|
|
|
1882
1972
|
owner: page.key, locale, rtl: isRtlLocale(locale), motion: layoutMotionOf(layoutPresetOf(plan.design).id),
|
|
1883
1973
|
// iox-ui#180: a picture box is an empty picture (the build fills it), never an address.
|
|
1884
1974
|
photoSrc: id => (isFreeBox(id) ? '' : context.photoSrc?.(id) ?? ''), photoAlt: id => (isFreeBox(id) ? '' : context.photoAlt?.(id) ?? ''),
|
|
1885
|
-
listOf: alias =>
|
|
1975
|
+
listOf: alias => layoutListBinding(alias, plan),
|
|
1886
1976
|
listFields: alias => fieldsOf(listedContentType(alias, plan)),
|
|
1887
1977
|
quotes: quoteListOf(plan),
|
|
1888
1978
|
...(readyMade ? {
|
|
@@ -1936,7 +2026,9 @@ function stampLayoutSections(page: PagePlan, layout: LayoutPage, nodes: Serializ
|
|
|
1936
2026
|
* Compose a Site Plan. Throws `SitePlanError` (every issue) when the plan does not validate — the
|
|
1937
2027
|
* composer never repairs a plan. `context` carries what the composer may not read for itself (the year).
|
|
1938
2028
|
*/
|
|
1939
|
-
export function composeSite(
|
|
2029
|
+
export function composeSite(given: SitePlan, context: ComposeContext): ComposedSite {
|
|
2030
|
+
// Pictures first: a Home whose plan names no opening takes its kind of business's (when a picture can come).
|
|
2031
|
+
const plan = withTypeOpening(given, context);
|
|
1940
2032
|
if (!context?.pictures) return composeSiteOnce(plan, context, NO_TYPES);
|
|
1941
2033
|
// #129: compose, find the pictures nothing fills, compose again type-led — until a round changes nothing (an opening
|
|
1942
2034
|
// left out shows its first section's own picture, judged in the next round). Monotone: a type-led section has no
|
|
@@ -1963,6 +2055,57 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
|
|
|
1963
2055
|
}
|
|
1964
2056
|
|
|
1965
2057
|
const NO_TYPES: ReadonlySet<string> = new Set();
|
|
2058
|
+
|
|
2059
|
+
/** The pattern family whose section a Home's opening takes the place of (a hero gives it its words, slot by slot). */
|
|
2060
|
+
const HERO_FAMILY = 'hero';
|
|
2061
|
+
const PICTURE_FREE_TYPES: ReadonlySet<string> = new Set([FreeNodeType.Image, FreeNodeType.Video]);
|
|
2062
|
+
|
|
2063
|
+
/** True when a free node (or anything in it) shows a picture — the owner's photo, a box stock may fill, a film. */
|
|
2064
|
+
function freeShowsPicture(node: FreeNode): boolean {
|
|
2065
|
+
return PICTURE_FREE_TYPES.has(node.type) || (node.children ?? []).some(freeShowsPicture);
|
|
2066
|
+
}
|
|
2067
|
+
|
|
2068
|
+
/**
|
|
2069
|
+
* PICTURES FIRST (the 2026-11-28 reference baseline, gap #1: the references open on 70–100 % picture, six of eleven J10
|
|
2070
|
+
* sites opened on none). A Home whose plan names no opening (`mixes.opening`) takes its kind of business's
|
|
2071
|
+
* (`ComposeContext.opening` — harness OPENING_PICTURE, given only when a picture can come), so its first screen is a
|
|
2072
|
+
* picture the build fills: the owner's photo, a made picture or stock (`pictureTargets` finds the opening's empty image).
|
|
2073
|
+
* A free Home (FS3) whose own opening shows no picture gives its first place back to the plan's hero (the ready-made place
|
|
2074
|
+
* a fall back would give — iox-ui#180's move), which the opening is then worn over, carrying the hero's words slot by
|
|
2075
|
+
* slot; a free opening that already shows a picture, or a free Home with no hero to give, is left as the model laid it.
|
|
2076
|
+
* A plan that chose its own opening keeps it — only its free Home's picture-less opening gives way, so the choice is worn.
|
|
2077
|
+
* An opening chosen with no picture (`media:none`) is the plan's word and is never overridden.
|
|
2078
|
+
* When nothing fills the picture the type-led round opens the Home on its words, as every Home's (`typeLedRound`). The
|
|
2079
|
+
* same plan composes the same site, so a rebuild from a kept plan picks the picture up with no model call. Pure.
|
|
2080
|
+
*/
|
|
2081
|
+
export function withTypeOpening(plan: SitePlan, context: Pick<ComposeContext, 'opening'> | null | undefined): SitePlan {
|
|
2082
|
+
// A picture can come only when the run says so (`context.opening`, given by `businessComposeContext`); the plan's own
|
|
2083
|
+
// opening is then worn as chosen (the J10 free hotel and salon chose one their free Home never wore), else the type's.
|
|
2084
|
+
if (!context?.opening?.length) return plan;
|
|
2085
|
+
const own = plan.mixes?.opening?.length ? plan.mixes.opening : null;
|
|
2086
|
+
const words = own ?? context.opening;
|
|
2087
|
+
try {
|
|
2088
|
+
if (openingMixFromWords(words).media === OpeningMedia.None) return plan;
|
|
2089
|
+
} catch { return plan; }
|
|
2090
|
+
const at = plan.pages.findIndex(p => p.isHome === true || p.route === HOME_PATH);
|
|
2091
|
+
const home = plan.pages[at];
|
|
2092
|
+
if (!home) return plan;
|
|
2093
|
+
// Only a Home that opens on a hero: the opening takes the hero's place and words, never another section's.
|
|
2094
|
+
const hero = home.sections[0];
|
|
2095
|
+
if (!hero || patternById(hero.pattern)?.family !== HERO_FAMILY) return plan;
|
|
2096
|
+
let page: PagePlan = home;
|
|
2097
|
+
const first = home.free?.sections[0];
|
|
2098
|
+
if (own && !(home.free && first && !first.readyMade)) return plan;
|
|
2099
|
+
if (home.free && first && !first.readyMade) {
|
|
2100
|
+
if (freeShowsPicture(first)) return plan;
|
|
2101
|
+
const given: FreeNode = { id: first.id, type: FreeNodeType.Section, styleProps: {}, readyMade: { at: 0, pattern: hero.pattern } };
|
|
2102
|
+
page = { ...home, free: { ...home.free, sections: [given, ...home.free.sections.slice(1)] } };
|
|
2103
|
+
}
|
|
2104
|
+
const pages = [...plan.pages];
|
|
2105
|
+
pages[at] = page;
|
|
2106
|
+
return { ...plan, pages, mixes: { ...plan.mixes, opening: [...words] } };
|
|
2107
|
+
}
|
|
2108
|
+
|
|
1966
2109
|
/** The most rounds a composition takes to wear no empty picture: the opening, then its first section, then a margin. */
|
|
1967
2110
|
const TYPE_LED_ROUNDS = 4;
|
|
1968
2111
|
|
|
@@ -1974,14 +2117,17 @@ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: R
|
|
|
1974
2117
|
const routes = new Set(plan.pages.map(p => p.route));
|
|
1975
2118
|
const relatives = new Map(plan.dataSources.map(d => [d.alias, d.type === PlanDataSourceType.Relative ? { type: d.type, of: d.of, op: d.op } : { type: d.type }]));
|
|
1976
2119
|
const email = nonEmpty(plan.business.facts?.email) ? plan.business.facts!.email!.trim() : null;
|
|
1977
|
-
const base = { plan, placeholders, issues, routes, year: context.year, email, navPage: null
|
|
2120
|
+
const base = { plan, placeholders, issues, routes, year: context.year, email, navPage: null };
|
|
1978
2121
|
|
|
1979
2122
|
// AW-D42: every plan wears the look's whole motion language (a lower plan's Pro words were drawn as its own, AW-D23).
|
|
1980
|
-
|
|
2123
|
+
// CV2: the plan's design with its colour words (`planDesignChoices`) — what the build's Look step writes; MR-D1: signed
|
|
2124
|
+
// by its kind of business (a preloader or By the scroll; a Still start lifted) — the build applies it.
|
|
2125
|
+
const design = withSignatureMove(motionLanguageForPlan(planDesignChoices(plan)), context?.signature).design;
|
|
1981
2126
|
const locale = plan.locale ?? DEFAULT_SITE_LOCALE;
|
|
1982
2127
|
const rtl = isRtlLocale(locale);
|
|
1983
2128
|
// AW6: the plan's body (seams, inset cards) as the site may carry it — every mend said (`body-mended`).
|
|
1984
|
-
|
|
2129
|
+
// CV-D9: the colour's `bands.inset` is AW6's inset card, folded into the body before it is judged.
|
|
2130
|
+
const bodyMixAsked = bodyWithColourBands(bodyMixOfPlan(plan), colourMixOfPlan(plan));
|
|
1985
2131
|
const bodyChecked = bodyMixAsked ? checkBody(drawnBodyMix(bodyMixAsked).drawn, { calm: !!context?.calm }) : null;
|
|
1986
2132
|
for (const r of bodyChecked?.repairs ?? []) issues.push({ code: ComposeIssueCode.BodyMended, nodeId: 'body', owner: 'body', detail: r.said });
|
|
1987
2133
|
const body = bodyChecked?.mix ?? null;
|
|
@@ -1991,7 +2137,7 @@ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: R
|
|
|
1991
2137
|
// FS3: the model's own page. Its opening is its own (the plan's opening is never worn over it) — but a ready-made
|
|
1992
2138
|
// opening (the fall back's, or the type-led round's when nothing fills its picture, iox-ui#180) is the plan's
|
|
1993
2139
|
// section, worn as every Home's is.
|
|
1994
|
-
const stamped = composeFreePlanPage(page, page.free, plan, context, placeholders,
|
|
2140
|
+
const stamped = composeFreePlanPage(page, page.free, plan, context, placeholders, (section, id, at) =>
|
|
1995
2141
|
composePattern(patternById(section.pattern) as SitePattern, id, { ...base, owner: page.key, page, section, nextAlias },
|
|
1996
2142
|
{ level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null, scrub: design.scrub ?? null, opening: at === 0 }));
|
|
1997
2143
|
const readyOpening = page.free.sections[0]?.readyMade;
|
|
@@ -2006,9 +2152,13 @@ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: R
|
|
|
2006
2152
|
if (page.layout) {
|
|
2007
2153
|
// vectoriox/iox-ui#99: a composed page that is where the site lists the shop lists it (a stored layout too).
|
|
2008
2154
|
const layout = withShownList(page.layout, layoutListsContext(page, plan)) ?? page.layout;
|
|
2155
|
+
// A ready-made band on a composed page wears the look's By the scroll as the same pattern on a pattern page does
|
|
2156
|
+
// (found by AW-D42); the page's first screen plays on time (AW10-D8).
|
|
2157
|
+
const openingAt = layout.sections[0]?.readyMade?.at;
|
|
2009
2158
|
const stamped = stampLayoutSections(page, layout, composeLayoutPage(page, layout, plan, context, design, placeholders, (section, id) =>
|
|
2010
2159
|
composePattern(patternById(section.pattern) as SitePattern, id, { ...base, owner: page.key, page, section, nextAlias },
|
|
2011
|
-
{ level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null
|
|
2160
|
+
{ level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null, scrub: design.scrub ?? null,
|
|
2161
|
+
opening: openingAt !== undefined && page.sections[openingAt] === section }), pictureless));
|
|
2012
2162
|
// AW8: the plan's opening is the home page's first screen; a pinned or kept first place is never replaced.
|
|
2013
2163
|
const first = layout.sections[0];
|
|
2014
2164
|
const worn = wearPlanOpening(page, stamped, plan, context, design, placeholders, issues, !!(first?.pin || first?.carry),
|
|
@@ -2022,17 +2172,22 @@ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: R
|
|
|
2022
2172
|
layout: joinPageHeader(wearBodyMix(worn, body)),
|
|
2023
2173
|
};
|
|
2024
2174
|
}
|
|
2025
|
-
const
|
|
2175
|
+
const own = page.sections.map((section, i) => {
|
|
2026
2176
|
const pattern = patternById(section.pattern) as SitePattern;
|
|
2027
2177
|
const motion: SectionMotion = { level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null, scrub: design.scrub ?? null, opening: i === 0 };
|
|
2028
2178
|
// FS-D19: a free signature section stands in its place; its fall back is this pattern.
|
|
2029
2179
|
if (section.free) {
|
|
2030
|
-
const root = composeFreeSection(section.free, `${page.key}-${i}`, freeOptionsOf(page, plan, context
|
|
2180
|
+
const root = composeFreeSection(section.free, `${page.key}-${i}`, freeOptionsOf(page, plan, context));
|
|
2031
2181
|
fillPageFacts([root], page, plan, placeholders);
|
|
2032
2182
|
return root;
|
|
2033
2183
|
}
|
|
2034
2184
|
return stampSection(composePattern(pattern, `${page.key}-${i}`, { ...base, owner: page.key, page, section, nextAlias }, motion), { pattern: section.pattern });
|
|
2035
|
-
})
|
|
2185
|
+
});
|
|
2186
|
+
// Composition: what the page borrows from the plan's other pages, and the order no two neighbours share a skeleton in.
|
|
2187
|
+
const placed = composePlaces(page, plan, own, (section, id, sink) => composePattern(patternById(section.pattern) as SitePattern, id,
|
|
2188
|
+
{ ...base, ...sink, owner: page.key, page, section, nextAlias },
|
|
2189
|
+
{ level: section.enter ?? design.animate ?? null, rtl, move: design.headings ?? null, scrub: design.scrub ?? null, opening: false }), issues);
|
|
2190
|
+
const layout = wearPlanOpening(page, placed, plan, context, design, placeholders, issues, false, page.sections[0]);
|
|
2036
2191
|
const opening = schemeOfFirst(layout);
|
|
2037
2192
|
return {
|
|
2038
2193
|
key: page.key,
|
|
@@ -2043,7 +2198,9 @@ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: R
|
|
|
2043
2198
|
locale,
|
|
2044
2199
|
pageSettings: { designSystem: true, ...(opening ? { opening } : {}) },
|
|
2045
2200
|
seo: composePageSeo(page, plan),
|
|
2046
|
-
|
|
2201
|
+
// CO4: on a pattern page every two neighbours on one ground are one section space apart (the page header's join
|
|
2202
|
+
// is one case of it).
|
|
2203
|
+
layout: joinSameGround(wearBodyMix(layout, body)),
|
|
2047
2204
|
};
|
|
2048
2205
|
});
|
|
2049
2206
|
|
|
@@ -2055,11 +2212,16 @@ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: R
|
|
|
2055
2212
|
name: plan.business.name, design, tagline: plan.business.tagline, locale: plan.locale, pages: plan.pages.filter(p => p.inNav).length,
|
|
2056
2213
|
// FV1 `closing.email`: the owner's address, the fact the email line shows (none given, no such closing — said).
|
|
2057
2214
|
...(plan.business.facts?.email?.trim() ? { email: plan.business.facts.email.trim() } : {}),
|
|
2215
|
+
// FV1b `holds.social`: the owner's stated links (none: the block is left out, said).
|
|
2216
|
+
...(plan.business.social?.length ? { social: plan.business.social } : {}),
|
|
2058
2217
|
...(context?.businessType ? { type: context.businessType } : {}), ...(context?.footerNever ? { never: context.footerNever } : {}),
|
|
2059
2218
|
// AW12-D13 (iox-ui#153): the build's tier — absent, Basic, as the body's — never wears an award word.
|
|
2060
2219
|
tier: context?.tier ?? GenerationTier.Basic,
|
|
2220
|
+
// AW12-D6: a sign-up only where the site has a reason to write (a journal, events, a shop, the type, the owner's tick).
|
|
2221
|
+
writes: planWrites(plan, context?.footerSignUp),
|
|
2061
2222
|
};
|
|
2062
|
-
|
|
2223
|
+
// AW12 newsletter: the kind of business's sign-up when the plan's footer asks for none — the same plan, the same footer.
|
|
2224
|
+
const footer = checkFooter(withTypeSignUp(footerMixOfPlan(plan), { signUp: context?.footerSignUp, writes: footerContext.writes }), footerContext);
|
|
2063
2225
|
for (const r of footer.repairs) issues.push({ code: ComposeIssueCode.FooterMended, nodeId: GlobalSlot.Footer, owner: GlobalSlot.Footer, detail: r.said });
|
|
2064
2226
|
// HI1: the header is the plan's header MIX (a stored pattern id is read as one), drawn as the product draws it, checked
|
|
2065
2227
|
// against the site and arranged from the contract's header parts; each mend is said.
|
|
@@ -2083,7 +2245,7 @@ function composeSiteOnce(plan: SitePlan, context: ComposeContext, pictureless: R
|
|
|
2083
2245
|
// pages are behind its menu shows the menu at every width, on the side the mix names.
|
|
2084
2246
|
for (const [slot, pattern] of slotPatterns) {
|
|
2085
2247
|
if (!pattern.phoneMenu) continue;
|
|
2086
|
-
globals = planNavShape(globals, pattern.phoneMenu as NavShape, headerShapeOptions(slot === GlobalSlot.Header ? header.recipe : null, plan.locale), slot).globals;
|
|
2248
|
+
globals = planNavShape(globals, pattern.phoneMenu as NavShape, headerShapeOptions(slot === GlobalSlot.Header ? header.recipe : null, plan.locale, header.context.collections), slot).globals;
|
|
2087
2249
|
}
|
|
2088
2250
|
// Premium M4 (T2): a header pattern's behaviour as the page scrolls — the same edit the Header section makes.
|
|
2089
2251
|
for (const [slot, pattern] of slotPatterns) {
|
|
@@ -2168,7 +2330,8 @@ export function legalFactsOf(plan: SitePlan, context: LegalContext, nodes: Reado
|
|
|
2168
2330
|
const sells = planSells(plan);
|
|
2169
2331
|
return {
|
|
2170
2332
|
...formLegalFacts(nodes),
|
|
2171
|
-
|
|
2333
|
+
// A site that will measure its visitors is judged as one with a tracker, before one is connected.
|
|
2334
|
+
[LegalFact.Tracker]: siteMeasures(context),
|
|
2172
2335
|
[LegalFact.Sells]: sells,
|
|
2173
2336
|
// The shop ships what it sells (commerce shipping, C-D9) — no product is digital yet.
|
|
2174
2337
|
[LegalFact.PhysicalGoods]: sells,
|
|
@@ -2222,6 +2385,15 @@ function legalRow(routes: ReadonlyMap<LegalKind, string>, settings: SerializedNo
|
|
|
2222
2385
|
}
|
|
2223
2386
|
|
|
2224
2387
|
/** The legal line beside a form (AW-D15): the owner's words to edit, its links to the site's terms and privacy pages. */
|
|
2388
|
+
/** iox-ui#185: a link inside the form's legal sentence is a WORD of it — the sentence's size and leading (its words wear
|
|
2389
|
+
* `small`; the `link` element style names no size, so the link kept the Link's 16px in a 14px line and wrapped alone on
|
|
2390
|
+
* a phone). Token refs read from the contract's `small`, never a literal; only the colour and weight say "link". */
|
|
2391
|
+
const LEGAL_SENTENCE_STYLE = 'small';
|
|
2392
|
+
const LEGAL_SENTENCE_TYPE: Readonly<Record<string, string>> = (() => {
|
|
2393
|
+
const base = (elementStyleById(LEGAL_SENTENCE_STYLE)?.base ?? {}) as Record<string, string>;
|
|
2394
|
+
return Object.fromEntries((['fontSize', 'lineHeight'] as const).filter(k => typeof base[k] === 'string').map(k => [k, base[k]]));
|
|
2395
|
+
})();
|
|
2396
|
+
|
|
2225
2397
|
function formLegalLine(form: SerializedNode, routes: ReadonlyMap<LegalKind, string>, locale: string): SerializedNode | null {
|
|
2226
2398
|
if (!routes.has(LegalKind.Privacy)) return null;
|
|
2227
2399
|
const id = `${form.id}-legal`;
|
|
@@ -2230,7 +2402,7 @@ function formLegalLine(form: SerializedNode, routes: ReadonlyMap<LegalKind, stri
|
|
|
2230
2402
|
line.label = 'Legal line';
|
|
2231
2403
|
setStyleProps(line, { display: 'block', width: '100%', minHeight: 'auto' });
|
|
2232
2404
|
line.children = legalFormLine(locale, routes.has(LegalKind.Terms)).map((part, i) => ('kind' in part
|
|
2233
|
-
? legalLink(`${id}-${i}`, part.kind, routes.get(part.kind)!, locale, INLINE)
|
|
2405
|
+
? legalLink(`${id}-${i}`, part.kind, routes.get(part.kind)!, locale, { ...INLINE, ...LEGAL_SENTENCE_TYPE })
|
|
2234
2406
|
: (() => {
|
|
2235
2407
|
const words = create(`${id}-${i}`, TEXT, { content: part.text, tag: 'span' }, 'small');
|
|
2236
2408
|
setStyleProps(words, INLINE);
|
|
@@ -2246,21 +2418,78 @@ function withFormLine(form: SerializedNode, line: SerializedNode): void {
|
|
|
2246
2418
|
kids.splice(at >= 0 ? at : kids.length, 0, line);
|
|
2247
2419
|
}
|
|
2248
2420
|
|
|
2249
|
-
/**
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2421
|
+
/** What `withConsentBanner` needs: the site's language, what it measures, its privacy page, a banner the studio keeps. */
|
|
2422
|
+
export interface ConsentStampInput {
|
|
2423
|
+
readonly locale: string;
|
|
2424
|
+
readonly trackers?: LegalContext['trackers'];
|
|
2425
|
+
readonly measures?: boolean | null;
|
|
2426
|
+
readonly privacyRoute?: string | null;
|
|
2427
|
+
/** The studio keeps its own banner: its preferences dialog's id — no second banner; Cookie settings opens it. */
|
|
2428
|
+
readonly keptPreferences?: string | null;
|
|
2429
|
+
/** Also put Cookie settings in the footer's legal row when it has none (a site built before it measured). */
|
|
2430
|
+
readonly intoFooter?: boolean;
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
/** True when a global (or anything inside it) is a consent banner. */
|
|
2434
|
+
function holdsConsentBanner(globals: ReadonlyArray<SerializedNode>): boolean {
|
|
2435
|
+
let found = false;
|
|
2436
|
+
walkSerialized(globals, n => { if (!found && n.type === DIALOG && n.props['consentRole'] === true) found = true; });
|
|
2437
|
+
return found;
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
/** True when a node (or anything inside it) opens the consent preferences. */
|
|
2441
|
+
function opensPreferences(node: SerializedNode): boolean {
|
|
2442
|
+
let found = false;
|
|
2443
|
+
walkSerialized([node], n => {
|
|
2444
|
+
for (const ix of n.interactions ?? []) for (const a of (ix as { actions?: Array<{ type?: string }> }).actions ?? []) if (a.type === ConsentActionType.OpenPreferences) found = true;
|
|
2445
|
+
});
|
|
2446
|
+
return found;
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
/**
|
|
2450
|
+
* THE privacy banner stamp (consent C5, 2026-11-28: "a privacy banner on every site that measures visitors"): a site that
|
|
2451
|
+
* MEASURES (`siteMeasures`) and holds no consent banner gets the palette's banner + preferences (`buildConsentRecipe`) as
|
|
2452
|
+
* globals after the page — at build time from `composeLegal`, and LATER by the same call when a tracker is connected
|
|
2453
|
+
* after the build (the audit's `tracker-without-banner` is the detector; iox-cms calls this on that finding). With
|
|
2454
|
+
* `intoFooter`, the footer's legal row gains Cookie settings when it has none. Never a second banner; a banner the studio
|
|
2455
|
+
* keeps is linked, never replaced. Pure: a new globals array; the footer row gains its link in place.
|
|
2456
|
+
*/
|
|
2457
|
+
export function withConsentBanner(globals: ReadonlyArray<SerializedNode>, input: ConsentStampInput): { globals: SerializedNode[]; settings: SerializedNode | null; added: boolean } {
|
|
2458
|
+
const out = [...globals];
|
|
2459
|
+
if (!siteMeasures(input) || (!input.keptPreferences && holdsConsentBanner(globals))) return { globals: out, settings: null, added: false };
|
|
2460
|
+
const privacy = input.privacyRoute ?? null;
|
|
2461
|
+
const consent = buildConsentRecipe(spec => create(spec.key, spec.type, { ...(spec.props ?? {}) }, spec.elementStyle ?? null) as CompositeNode, {
|
|
2462
|
+
lang: input.locale, categories: measuredCategories(input), privacyRoute: privacy, privacyLabel: privacy ? legalTitle(LegalKind.Privacy, input.locale) : undefined,
|
|
2463
|
+
});
|
|
2464
|
+
const settings = consent.settings as SerializedNode;
|
|
2465
|
+
let added = false;
|
|
2466
|
+
if (input.keptPreferences) {
|
|
2467
|
+
// The studio keeps its own banner: the footer's Cookie settings opens ITS preferences, and no second banner.
|
|
2468
|
+
for (const ix of settings.interactions ?? []) for (const a of (ix as { actions?: Array<{ type?: string; target?: string }> }).actions ?? []) {
|
|
2469
|
+
if (a.type === ConsentActionType.OpenPreferences) a.target = input.keptPreferences;
|
|
2470
|
+
}
|
|
2471
|
+
} else {
|
|
2472
|
+
for (const root of [consent.banner, consent.preferences] as SerializedNode[]) {
|
|
2473
|
+
root.isGlobal = true;
|
|
2474
|
+
root.globalPosition = PatternGlobalPosition.After;
|
|
2475
|
+
out.push(root);
|
|
2476
|
+
}
|
|
2477
|
+
added = true;
|
|
2255
2478
|
}
|
|
2256
|
-
|
|
2479
|
+
if (input.intoFooter) {
|
|
2480
|
+
let row: SerializedNode | null = null;
|
|
2481
|
+
const footer = out.find(g => g.id === GlobalSlot.Footer);
|
|
2482
|
+
if (footer) walkSerialized([footer], n => { if (!row && n.role === FOOTER_LEGAL_ROLE) row = n; });
|
|
2483
|
+
if (row && !opensPreferences(row)) ((row as SerializedNode).children ?? ((row as SerializedNode).children = [])).push(settings);
|
|
2484
|
+
}
|
|
2485
|
+
return { globals: out, settings, added };
|
|
2257
2486
|
}
|
|
2258
2487
|
|
|
2259
2488
|
/**
|
|
2260
2489
|
* AW1 (C5): the law a site's facts call for — stamped, never asked. Each legal kind the facts need (`legalKindsFor`) is
|
|
2261
2490
|
* the studio's own page when it has one (linked, never stamped again), else an empty flagged page on a free route; the
|
|
2262
|
-
* cookie banner and its preferences are stamped as globals when
|
|
2263
|
-
* own); every footer gets the legal row (+ Cookie settings), every form that asks for personal details the legal line.
|
|
2491
|
+
* cookie banner and its preferences are stamped as globals when the site measures (`siteMeasures`: a tracker connected,
|
|
2492
|
+
* or the intent to count visitors — unless the studio keeps its own, `withConsentBanner`); every footer gets the legal row (+ Cookie settings), every form that asks for personal details the legal line.
|
|
2264
2493
|
* Pure: new globals, the stamped pages; forms and the footer gain their nodes in place.
|
|
2265
2494
|
*/
|
|
2266
2495
|
function composeLegal(plan: SitePlan, context: LegalContext, pages: ReadonlyArray<ComposedPage>, globals: SerializedNode[], footerArrange: string,
|
|
@@ -2284,28 +2513,11 @@ function composeLegal(plan: SitePlan, context: LegalContext, pages: ReadonlyArra
|
|
|
2284
2513
|
stamped.push(composeLegalPage(kind, key, route, plan, placeholders));
|
|
2285
2514
|
}
|
|
2286
2515
|
|
|
2287
|
-
const
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
const consent = buildConsentRecipe(spec => create(spec.key, spec.type, { ...(spec.props ?? {}) }, spec.elementStyle ?? null) as CompositeNode, {
|
|
2293
|
-
lang: locale, categories, privacyRoute: privacy ?? null, privacyLabel: privacy ? legalTitle(LegalKind.Privacy, locale) : undefined,
|
|
2294
|
-
});
|
|
2295
|
-
settings = consent.settings as SerializedNode;
|
|
2296
|
-
if (context.keptPreferences) {
|
|
2297
|
-
// The studio keeps its own banner: the footer's Cookie settings opens ITS preferences, and no second banner.
|
|
2298
|
-
for (const ix of settings.interactions ?? []) for (const a of (ix as { actions?: Array<{ type?: string; target?: string }> }).actions ?? []) {
|
|
2299
|
-
if (a.type === ConsentActionType.OpenPreferences) a.target = context.keptPreferences;
|
|
2300
|
-
}
|
|
2301
|
-
} else {
|
|
2302
|
-
for (const root of [consent.banner, consent.preferences] as SerializedNode[]) {
|
|
2303
|
-
root.isGlobal = true;
|
|
2304
|
-
root.globalPosition = PatternGlobalPosition.After;
|
|
2305
|
-
out.push(root);
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
}
|
|
2516
|
+
const privacy = routes.get(LegalKind.Privacy);
|
|
2517
|
+
const consent = withConsentBanner(globals, { locale, trackers: context.trackers, measures: context.measures, privacyRoute: privacy ?? null,
|
|
2518
|
+
keptPreferences: context.keptPreferences, intoFooter: false });
|
|
2519
|
+
const out = consent.globals;
|
|
2520
|
+
const settings = consent.settings;
|
|
2309
2521
|
const footer = out.find(g => g.id === GlobalSlot.Footer);
|
|
2310
2522
|
const row = footer ? legalRow(routes, settings, footerArrange, locale) : null;
|
|
2311
2523
|
// AW12-D3: a name-and-action footer keeps its legal row in its end block, above the thank-you line — the name stays last,
|
|
@@ -2337,7 +2549,9 @@ export function planHeader(plan: SitePlan, facts: HeaderFacts = {}): { recipe: H
|
|
|
2337
2549
|
|
|
2338
2550
|
/** The phone-menu options a header recipe asks for: its menu at every width and on its side (none for the defaults, so a
|
|
2339
2551
|
* stored header's edit is the one it always was). */
|
|
2340
|
-
function headerShapeOptions(recipe: HeaderRecipe | null, locale?: string
|
|
2552
|
+
function headerShapeOptions(recipe: HeaderRecipe | null, locale?: string, collections?: ReadonlyArray<{ name: string; route: string }>): {
|
|
2553
|
+
everyWidth?: boolean; menuSide?: MenuSide; look?: Partial<MenuLook>; locale?: string; collections?: NavPage[];
|
|
2554
|
+
} {
|
|
2341
2555
|
// vectoriox/iox-ui#100: the menu's words (and the names its parts are heard by) are the site's language — English
|
|
2342
2556
|
// words are the table's English, so an English header composes as it always did (R-H4).
|
|
2343
2557
|
const words = locale ? { locale } : {};
|
|
@@ -2347,6 +2561,8 @@ function headerShapeOptions(recipe: HeaderRecipe | null, locale?: string): { eve
|
|
|
2347
2561
|
return {
|
|
2348
2562
|
...(recipe.everyWidth ? { everyWidth: true } : {}), ...(recipe.menuSide === MenuSide.Start ? { menuSide: MenuSide.Start } : {}),
|
|
2349
2563
|
...(Object.keys(look).length ? { look } : {}), ...words,
|
|
2564
|
+
// HI2: a shelf's cards are the site's main collections (only a menu that shows pictures or a card needs them).
|
|
2565
|
+
...(look.shows && collections?.length ? { collections: collections.map(c => ({ label: c.name, route: c.route })) } : {}),
|
|
2350
2566
|
};
|
|
2351
2567
|
}
|
|
2352
2568
|
|
|
@@ -2402,6 +2618,9 @@ export interface NavHeaderInput {
|
|
|
2402
2618
|
* `{ frame: 'full', media: 'photo' }`; null = it opens plain). Absent: not judged — a header over the opening is kept
|
|
2403
2619
|
* as chosen (the builder knows the page; a studio with no Site Plan has no plan opening to read). */
|
|
2404
2620
|
readonly opening?: HeaderOpening | null;
|
|
2621
|
+
/** HI3-D21: the brand has a logo picture (a hanging name needs one) — the builder reads the header's own brand
|
|
2622
|
+
* (`headerSiteFor`). Absent: none known, a hanging name fits. */
|
|
2623
|
+
readonly logo?: boolean | null;
|
|
2405
2624
|
}
|
|
2406
2625
|
|
|
2407
2626
|
export interface NavHeaderOptions {
|
|
@@ -2485,7 +2704,8 @@ function navHeaderPlan(input: Omit<NavHeaderInput, 'mix' | 'asAsked'>): SitePlan
|
|
|
2485
2704
|
/** What a studio's header is judged against (`checkHeader`) — the same context `composeNavHeader` checks with. */
|
|
2486
2705
|
export function navHeaderContext(input: Omit<NavHeaderInput, 'mix' | 'asAsked'>): HeaderContext {
|
|
2487
2706
|
const { opening: _plan, ...context } = headerContextOfPlan(navHeaderPlan(input), input.shop ?? null);
|
|
2488
|
-
|
|
2707
|
+
const withLogo = input.logo === undefined || input.logo === null ? context : { ...context, logo: input.logo };
|
|
2708
|
+
return input.opening === undefined ? withLogo : { ...withLogo, opening: input.opening };
|
|
2489
2709
|
}
|
|
2490
2710
|
|
|
2491
2711
|
export function composeNavHeader(input: NavHeaderInput, options: NavHeaderOptions): ComposedNavHeader {
|
|
@@ -2512,7 +2732,7 @@ export function composeNavHeader(input: NavHeaderInput, options: NavHeaderOption
|
|
|
2512
2732
|
root.isGlobal = true;
|
|
2513
2733
|
root.globalPosition = pattern.global;
|
|
2514
2734
|
const shape = pattern.phoneMenu as NavShape | undefined;
|
|
2515
|
-
const [header, ...companions] = shape ? planNavShape([root], shape, { newId: options.newId, ...headerShapeOptions(recipe, input.locale) }, root.id).globals : [root];
|
|
2735
|
+
const [header, ...companions] = shape ? planNavShape([root], shape, { newId: options.newId, ...headerShapeOptions(recipe, input.locale, context.collections) }, root.id).globals : [root];
|
|
2516
2736
|
if (pattern.header) setHeaderBehaviour(header as unknown as CompositeNode, pattern.header.behaviour, pattern.header.edge ?? null);
|
|
2517
2737
|
stampHeaderMix(header, recipe.mix);
|
|
2518
2738
|
setHeaderInk(header as unknown as CompositeNode, headerInkOf(recipe.mix[HeaderIngredient.Ink]));
|