@vectoriox/iox-ui 5.202.1 → 5.204.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 +8 -1
- package/design-core/index.d.ts +62 -2
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +8 -1
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +121 -11
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +5443 -293
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +381 -32
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +2368 -5
- package/index.d.ts +117 -12
- package/package.json +1 -1
- package/src/actions-core/element-actions.ts +9 -0
- package/src/design-core/contrast-audit.ts +93 -11
- package/src/design-core/flavor-spec.generated.ts +19 -0
- package/src/design-core/image-alt.ts +27 -0
- package/src/design-core/public-api.ts +1 -0
- package/src/generation-core/audit-site.ts +17 -3
- package/src/generation-core/baseline-roles.ts +10 -6
- package/src/generation-core/check-free.ts +12 -2
- package/src/generation-core/check-layout.ts +3 -2
- package/src/generation-core/compose-free.ts +3 -1
- package/src/generation-core/compose-layout.ts +1 -1
- package/src/generation-core/compose-site.ts +29 -11
- package/src/generation-core/critic-calibration.ts +175 -0
- package/src/generation-core/critic-prompt.ts +153 -0
- package/src/generation-core/critic-rubric.generated.ts +24 -0
- package/src/generation-core/critic-sheet.ts +203 -0
- package/src/generation-core/critic.ts +175 -0
- package/src/generation-core/design-doc-index.ts +58 -0
- package/src/generation-core/design-motion.ts +247 -0
- package/src/generation-core/design-ops-check.ts +370 -0
- package/src/generation-core/design-ops-of.ts +200 -0
- package/src/generation-core/design-ops.model.ts +239 -0
- package/src/generation-core/design-ops.schema.ts +122 -0
- package/src/generation-core/design-ops.ts +361 -0
- package/src/generation-core/design-recipes.ts +58 -0
- package/src/generation-core/designer-brief.ts +81 -0
- package/src/generation-core/designer-direction.ts +248 -0
- package/src/generation-core/designer-estimate.ts +171 -0
- package/src/generation-core/designer-lessons.generated.ts +653 -0
- package/src/generation-core/designer-lessons.ts +153 -0
- package/src/generation-core/designer-stop.ts +94 -0
- package/src/generation-core/footer-free.ts +23 -2
- package/src/generation-core/footer-mix.ts +60 -14
- package/src/generation-core/layout-language.ts +2 -0
- package/src/generation-core/node-baselines.generated.ts +953 -10
- package/src/generation-core/public-api.ts +21 -0
- package/src/generation-core/site-spec.generated.ts +82 -10
- package/src/generation-core/social-links.ts +370 -0
- package/src/generation-core/structure-fingerprint.ts +565 -0
- package/src/generation-core/templates.ts +39 -3
- package/styles/iox-design.css +26 -1
- package/styles/iox-forms.css +22 -0
|
@@ -99,7 +99,28 @@ export * from './opening-edit';
|
|
|
99
99
|
export * from './footer-mix';
|
|
100
100
|
export * from './footer-sign-up';
|
|
101
101
|
export * from './footer-free';
|
|
102
|
+
export * from './social-links';
|
|
102
103
|
export * from './layout-edits';
|
|
103
104
|
export * from './adjustments';
|
|
104
105
|
export * from './site-tree';
|
|
105
106
|
export * from './legal';
|
|
107
|
+
export * from './design-ops.model';
|
|
108
|
+
export * from './design-ops.schema';
|
|
109
|
+
export * from './design-recipes';
|
|
110
|
+
export * from './design-doc-index';
|
|
111
|
+
export * from './design-ops-check';
|
|
112
|
+
export * from './design-ops';
|
|
113
|
+
export * from './design-ops-of';
|
|
114
|
+
export * from './critic-rubric.generated';
|
|
115
|
+
export * from './critic';
|
|
116
|
+
export * from './critic-sheet';
|
|
117
|
+
export * from './critic-prompt';
|
|
118
|
+
export * from './critic-calibration';
|
|
119
|
+
export * from './structure-fingerprint';
|
|
120
|
+
export * from './designer-lessons.generated';
|
|
121
|
+
export * from './designer-direction';
|
|
122
|
+
export * from './designer-stop';
|
|
123
|
+
export * from './designer-estimate';
|
|
124
|
+
export * from './designer-lessons';
|
|
125
|
+
export * from './designer-brief';
|
|
126
|
+
export * from './design-motion';
|
|
@@ -6349,6 +6349,18 @@ export const SPEC_SITE_TEMPLATES = {
|
|
|
6349
6349
|
"globals": {
|
|
6350
6350
|
"header": "nav.inline-cta",
|
|
6351
6351
|
"footer": "footer.three-column"
|
|
6352
|
+
},
|
|
6353
|
+
"copyHe": {
|
|
6354
|
+
"Home": "בית",
|
|
6355
|
+
"Work": "עבודות",
|
|
6356
|
+
"Portfolio": "תיק עבודות",
|
|
6357
|
+
"Project": "פרויקט",
|
|
6358
|
+
"About": "אודות",
|
|
6359
|
+
"About the studio": "על הסטודיו",
|
|
6360
|
+
"Contact": "יצירת קשר",
|
|
6361
|
+
"Projects": "פרויקטים",
|
|
6362
|
+
"Sample project {n}": "פרויקט לדוגמה {n}",
|
|
6363
|
+
"Replace this with a sentence about the project.": "החליפו את זה במשפט על הפרויקט."
|
|
6352
6364
|
}
|
|
6353
6365
|
},
|
|
6354
6366
|
"practice": {
|
|
@@ -6580,6 +6592,23 @@ export const SPEC_SITE_TEMPLATES = {
|
|
|
6580
6592
|
"globals": {
|
|
6581
6593
|
"header": "nav.inline-cta",
|
|
6582
6594
|
"footer": "footer.three-column"
|
|
6595
|
+
},
|
|
6596
|
+
"copyHe": {
|
|
6597
|
+
"Home": "בית",
|
|
6598
|
+
"See the services": "לשירותים שלנו",
|
|
6599
|
+
"Book a visit": "קביעת תור",
|
|
6600
|
+
"What we offer": "מה אנחנו מציעים",
|
|
6601
|
+
"All services": "כל השירותים",
|
|
6602
|
+
"Find a time that suits you.": "מצאו זמן שנוח לכם.",
|
|
6603
|
+
"Services": "שירותים",
|
|
6604
|
+
"Prices": "מחירון",
|
|
6605
|
+
"About": "אודות",
|
|
6606
|
+
"About us": "עלינו",
|
|
6607
|
+
"How we started": "איך התחלנו",
|
|
6608
|
+
"Contact": "יצירת קשר",
|
|
6609
|
+
"Sample service {n}": "שירות לדוגמה {n}",
|
|
6610
|
+
"Replace this with a sentence about the service.": "החליפו את זה במשפט על השירות.",
|
|
6611
|
+
"Price": "מחיר"
|
|
6583
6612
|
}
|
|
6584
6613
|
},
|
|
6585
6614
|
"place": {
|
|
@@ -6804,6 +6833,28 @@ export const SPEC_SITE_TEMPLATES = {
|
|
|
6804
6833
|
"globals": {
|
|
6805
6834
|
"header": "nav.inline-cta",
|
|
6806
6835
|
"footer": "footer.mega"
|
|
6836
|
+
},
|
|
6837
|
+
"copyHe": {
|
|
6838
|
+
"Home": "בית",
|
|
6839
|
+
"See the menu": "לתפריט",
|
|
6840
|
+
"Visit us": "בואו לבקר",
|
|
6841
|
+
"Come for": "בשביל מה באים",
|
|
6842
|
+
"From the menu": "מהתפריט",
|
|
6843
|
+
"The full menu": "התפריט המלא",
|
|
6844
|
+
"Come by": "קפצו לבקר",
|
|
6845
|
+
"We would love to see you.": "נשמח לראות אתכם.",
|
|
6846
|
+
"How to find us": "איך מגיעים אלינו",
|
|
6847
|
+
"Menu": "תפריט",
|
|
6848
|
+
"Our menu": "התפריט שלנו",
|
|
6849
|
+
"Visit": "ביקור",
|
|
6850
|
+
"Where and when": "איפה ומתי",
|
|
6851
|
+
"About": "אודות",
|
|
6852
|
+
"About us": "עלינו",
|
|
6853
|
+
"How we started": "איך התחלנו",
|
|
6854
|
+
"Contact": "יצירת קשר",
|
|
6855
|
+
"Sample item {n}": "פריט לדוגמה {n}",
|
|
6856
|
+
"Replace this with a line about the dish or the drink.": "החליפו את זה בשורה על המנה או על המשקה.",
|
|
6857
|
+
"Price": "מחיר"
|
|
6807
6858
|
}
|
|
6808
6859
|
}
|
|
6809
6860
|
} as const;
|
|
@@ -9257,7 +9308,8 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9257
9308
|
"name": "Instagram",
|
|
9258
9309
|
"hosts": [
|
|
9259
9310
|
"instagram.com"
|
|
9260
|
-
]
|
|
9311
|
+
],
|
|
9312
|
+
"icon": "ph-instagram-logo"
|
|
9261
9313
|
},
|
|
9262
9314
|
{
|
|
9263
9315
|
"id": "facebook",
|
|
@@ -9265,14 +9317,16 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9265
9317
|
"hosts": [
|
|
9266
9318
|
"facebook.com",
|
|
9267
9319
|
"fb.com"
|
|
9268
|
-
]
|
|
9320
|
+
],
|
|
9321
|
+
"icon": "ph-facebook-logo"
|
|
9269
9322
|
},
|
|
9270
9323
|
{
|
|
9271
9324
|
"id": "tiktok",
|
|
9272
9325
|
"name": "TikTok",
|
|
9273
9326
|
"hosts": [
|
|
9274
9327
|
"tiktok.com"
|
|
9275
|
-
]
|
|
9328
|
+
],
|
|
9329
|
+
"icon": "ph-tiktok-logo"
|
|
9276
9330
|
},
|
|
9277
9331
|
{
|
|
9278
9332
|
"id": "youtube",
|
|
@@ -9280,21 +9334,24 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9280
9334
|
"hosts": [
|
|
9281
9335
|
"youtube.com",
|
|
9282
9336
|
"youtu.be"
|
|
9283
|
-
]
|
|
9337
|
+
],
|
|
9338
|
+
"icon": "ph-youtube-logo"
|
|
9284
9339
|
},
|
|
9285
9340
|
{
|
|
9286
9341
|
"id": "linkedin",
|
|
9287
9342
|
"name": "LinkedIn",
|
|
9288
9343
|
"hosts": [
|
|
9289
9344
|
"linkedin.com"
|
|
9290
|
-
]
|
|
9345
|
+
],
|
|
9346
|
+
"icon": "ph-linkedin-logo"
|
|
9291
9347
|
},
|
|
9292
9348
|
{
|
|
9293
9349
|
"id": "pinterest",
|
|
9294
9350
|
"name": "Pinterest",
|
|
9295
9351
|
"hosts": [
|
|
9296
9352
|
"pinterest.com"
|
|
9297
|
-
]
|
|
9353
|
+
],
|
|
9354
|
+
"icon": "ph-pinterest-logo"
|
|
9298
9355
|
},
|
|
9299
9356
|
{
|
|
9300
9357
|
"id": "x",
|
|
@@ -9302,7 +9359,8 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9302
9359
|
"hosts": [
|
|
9303
9360
|
"x.com",
|
|
9304
9361
|
"twitter.com"
|
|
9305
|
-
]
|
|
9362
|
+
],
|
|
9363
|
+
"icon": "ph-x-logo"
|
|
9306
9364
|
},
|
|
9307
9365
|
{
|
|
9308
9366
|
"id": "threads",
|
|
@@ -9310,14 +9368,16 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9310
9368
|
"hosts": [
|
|
9311
9369
|
"threads.net",
|
|
9312
9370
|
"threads.com"
|
|
9313
|
-
]
|
|
9371
|
+
],
|
|
9372
|
+
"icon": "ph-threads-logo"
|
|
9314
9373
|
},
|
|
9315
9374
|
{
|
|
9316
9375
|
"id": "behance",
|
|
9317
9376
|
"name": "Behance",
|
|
9318
9377
|
"hosts": [
|
|
9319
9378
|
"behance.net"
|
|
9320
|
-
]
|
|
9379
|
+
],
|
|
9380
|
+
"icon": "ph-behance-logo"
|
|
9321
9381
|
},
|
|
9322
9382
|
{
|
|
9323
9383
|
"id": "whatsapp",
|
|
@@ -9325,7 +9385,19 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9325
9385
|
"hosts": [
|
|
9326
9386
|
"wa.me",
|
|
9327
9387
|
"whatsapp.com"
|
|
9328
|
-
]
|
|
9388
|
+
],
|
|
9389
|
+
"icon": "ph-whatsapp-logo"
|
|
9390
|
+
},
|
|
9391
|
+
{
|
|
9392
|
+
"id": "google",
|
|
9393
|
+
"name": "Google",
|
|
9394
|
+
"hosts": [
|
|
9395
|
+
"g.page",
|
|
9396
|
+
"g.co",
|
|
9397
|
+
"maps.app.goo.gl",
|
|
9398
|
+
"business.google.com"
|
|
9399
|
+
],
|
|
9400
|
+
"icon": "ph-google-logo"
|
|
9329
9401
|
}
|
|
9330
9402
|
],
|
|
9331
9403
|
"callWords": [
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { LinkType } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
import { channelHref, ChannelKind } from '@vectoriox/iox-ui/forms-core';
|
|
3
|
+
|
|
4
|
+
import { FOOTER_SOCIAL_NETWORKS, FooterRole, footerSocialLinks, FooterSocialLink, recognisedSocialLinks, socialLinkOf, socialLinksPart } from './footer-mix';
|
|
5
|
+
import { PatternNode } from './patterns';
|
|
6
|
+
import { FACT_KEYS } from './site-plan.model';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* THE OWNER'S SOCIAL LINKS (footer-v2-plan.md FV-D10, completed 2026-11-29 — Doron: "the website generator completely
|
|
10
|
+
* ignores social networks … they shall be in the contact area or footer"). The owner types them in the wizard (one input per
|
|
11
|
+
* network of the contract's `FOOTER.socialNetworks`) or in Site settings ▸ Socials; a typed address is STATED by definition
|
|
12
|
+
* (harness `statedFacts.social`) — never searched for, completed or guessed. This module is the ONE rule the wizard, Site
|
|
13
|
+
* settings and iox-cms share:
|
|
14
|
+
*
|
|
15
|
+
* - `ownerSocialLink` — what the owner typed under one network, as its https link, or why it is not one;
|
|
16
|
+
* - `socialLinksByNetwork` / `socialLinksList` — several lists (the reading's, the owner's, Site settings') merged, once per
|
|
17
|
+
* network, the first list winning;
|
|
18
|
+
* - `SITE_SOCIAL_FIELDS`, `siteSocialLinks`, `siteSocialPatch` — the Site settings record's fields, read and written;
|
|
19
|
+
* - `statedWhatsAppHref` — a stated WhatsApp link as the contact form's WhatsApp channel (forms-core `channelHref`);
|
|
20
|
+
* - `withFollowRow` — a contact section with the footer's social part ("Follow" and the links) beside its contact facts;
|
|
21
|
+
* - `followSiteSocials` — every follow row a saved layout holds, drawn from Site settings ▸ Socials AT RENDER (iox-ui#201):
|
|
22
|
+
* the engine and the builder both apply it, so a link changed in Site settings reaches every site, old builds included.
|
|
23
|
+
*
|
|
24
|
+
* Pure and framework-free (iox-cms imports it).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
/** Why a typed address is not the owner's link on that network — the wizard says it under the input. */
|
|
28
|
+
export enum SocialLinkRefusal {
|
|
29
|
+
/** Not a web address (and, under WhatsApp, not a phone number either). */
|
|
30
|
+
NotAnAddress = 'not-an-address',
|
|
31
|
+
/** A scheme other than https (javascript:, ftp:, mailto: …) — http is written https. */
|
|
32
|
+
NotHttps = 'not-https',
|
|
33
|
+
/** A web address on no network the footer can name. */
|
|
34
|
+
UnknownNetwork = 'unknown-network',
|
|
35
|
+
/** An address of ANOTHER network than the input it was typed in ("facebook.com/x" under Instagram). */
|
|
36
|
+
OtherNetwork = 'other-network',
|
|
37
|
+
/** The network's bare address ("instagram.com") — the owner's own page has a path. */
|
|
38
|
+
NoProfile = 'no-profile',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** What the owner typed under one network: its link, or why not. Empty input: null (nothing stated). */
|
|
42
|
+
export type OwnerSocialLink =
|
|
43
|
+
| { readonly ok: true; readonly link: FooterSocialLink }
|
|
44
|
+
| { readonly ok: false; readonly refusal: SocialLinkRefusal; readonly network?: string };
|
|
45
|
+
|
|
46
|
+
const WHATSAPP = 'whatsapp';
|
|
47
|
+
/** A phone number as typed: digits with the usual separators, an optional leading +. */
|
|
48
|
+
const PHONE = /^\+?[\d\s().-]+$/;
|
|
49
|
+
const SCHEME = /^([a-z][a-z0-9+.-]*):/i;
|
|
50
|
+
const WEB_SCHEMES: ReadonlyArray<string> = ['http', 'https'];
|
|
51
|
+
|
|
52
|
+
/** The network a host belongs to (bare: no `www.` / `m.`), or null. */
|
|
53
|
+
function networkOfHost(host: string): string | null {
|
|
54
|
+
const bare = host.toLowerCase().replace(/^(www|m)\./, '');
|
|
55
|
+
return FOOTER_SOCIAL_NETWORKS.find(n => n.hosts.some(h => bare === h || bare.endsWith(`.${h}`)))?.id ?? null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* What the owner typed under one network as its https link — or the reason it is none (said under the input). Under
|
|
60
|
+
* WhatsApp a phone number is the address too (`wa.me/<digits>`, forms-core `channelHref`: the digits as typed, with the
|
|
61
|
+
* country code). Pure.
|
|
62
|
+
*/
|
|
63
|
+
export function ownerSocialLink(network: string, typed: unknown): OwnerSocialLink | null {
|
|
64
|
+
const raw = typeof typed === 'string' ? typed.trim() : '';
|
|
65
|
+
if (!raw) return null;
|
|
66
|
+
if (network === WHATSAPP && PHONE.test(raw)) {
|
|
67
|
+
const href = channelHref(ChannelKind.WhatsApp, raw);
|
|
68
|
+
const link = href ? socialLinkOf(href) : null;
|
|
69
|
+
return link ? { ok: true, link } : { ok: false, refusal: SocialLinkRefusal.NotAnAddress };
|
|
70
|
+
}
|
|
71
|
+
const scheme = SCHEME.exec(raw)?.[1]?.toLowerCase();
|
|
72
|
+
if (scheme && !WEB_SCHEMES.includes(scheme)) return { ok: false, refusal: SocialLinkRefusal.NotHttps };
|
|
73
|
+
let host: string;
|
|
74
|
+
try {
|
|
75
|
+
host = new URL(scheme && WEB_SCHEMES.includes(scheme) ? raw : `https://${raw}`).hostname;
|
|
76
|
+
} catch {
|
|
77
|
+
return { ok: false, refusal: SocialLinkRefusal.NotAnAddress };
|
|
78
|
+
}
|
|
79
|
+
if (!host.includes('.')) return { ok: false, refusal: SocialLinkRefusal.NotAnAddress };
|
|
80
|
+
const on = networkOfHost(host);
|
|
81
|
+
if (!on) return { ok: false, refusal: SocialLinkRefusal.UnknownNetwork };
|
|
82
|
+
if (on !== network) return { ok: false, refusal: SocialLinkRefusal.OtherNetwork, network: on };
|
|
83
|
+
const link = socialLinkOf(raw);
|
|
84
|
+
return link ? { ok: true, link } : { ok: false, refusal: SocialLinkRefusal.NoProfile };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Several lists of addresses (each a stated line or a list) as ONE link per network — the FIRST list naming a network wins
|
|
89
|
+
* (pass the owner's own first), in the table's order. Unrecognised addresses are dropped (the footer could not name them
|
|
90
|
+
* either). Pure.
|
|
91
|
+
*/
|
|
92
|
+
export function socialLinksByNetwork(...lists: ReadonlyArray<ReadonlyArray<string> | null | undefined>): Partial<Record<string, string>> {
|
|
93
|
+
const out: Partial<Record<string, string>> = {};
|
|
94
|
+
for (const list of lists) {
|
|
95
|
+
for (const link of recognisedSocialLinks(list).links) if (!out[link.network]) out[link.network] = link.url;
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** `socialLinksByNetwork` as the stated list (`business.social`, `statedFacts.social`): one https address per network, in
|
|
101
|
+
* the table's order. Pure. */
|
|
102
|
+
export function socialLinksList(...lists: ReadonlyArray<ReadonlyArray<string> | null | undefined>): string[] {
|
|
103
|
+
const by = socialLinksByNetwork(...lists);
|
|
104
|
+
return FOOTER_SOCIAL_NETWORKS.map(n => by[n.id]).filter((u): u is string => !!u);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The Site settings record's field for each network (iox-cms `site` schema; Site settings ▸ Socials). The four older
|
|
109
|
+
* fields keep their names (`linkedIn`, `twitter`); every other network's field is its id. Site settings is the ONE place the
|
|
110
|
+
* links live after a build writes them back (`siteSocialPatch`).
|
|
111
|
+
*/
|
|
112
|
+
export const SITE_SOCIAL_FIELDS: Readonly<Record<string, string>> = Object.fromEntries(
|
|
113
|
+
FOOTER_SOCIAL_NETWORKS.map(n => [n.id, ({ linkedin: 'linkedIn', x: 'twitter' } as Readonly<Record<string, string>>)[n.id] ?? n.id]),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
/** The links a Site settings record holds (a WhatsApp field may hold a phone number), once per network. Pure. */
|
|
117
|
+
export function siteSocialLinks(site: Readonly<Record<string, unknown>> | null | undefined): string[] {
|
|
118
|
+
const typed = FOOTER_SOCIAL_NETWORKS.map(n => {
|
|
119
|
+
const owned = ownerSocialLink(n.id, site?.[SITE_SOCIAL_FIELDS[n.id]]);
|
|
120
|
+
return owned?.ok ? owned.link.url : '';
|
|
121
|
+
});
|
|
122
|
+
return socialLinksList(typed.filter(Boolean));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** The Site settings fields that change when the links are written back — only networks the links name and whose field
|
|
126
|
+
* holds something else (a field is never cleared). Empty: nothing to write. Pure. */
|
|
127
|
+
export function siteSocialPatch(links: ReadonlyArray<string> | null | undefined, site: Readonly<Record<string, unknown>> | null | undefined): Record<string, string> {
|
|
128
|
+
const by = socialLinksByNetwork(links);
|
|
129
|
+
const patch: Record<string, string> = {};
|
|
130
|
+
for (const [network, url] of Object.entries(by)) {
|
|
131
|
+
const field = SITE_SOCIAL_FIELDS[network];
|
|
132
|
+
const held = ownerSocialLink(network, site?.[field]);
|
|
133
|
+
if (url && !(held?.ok && held.link.url === url)) patch[field] = url;
|
|
134
|
+
}
|
|
135
|
+
return patch;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** A stated WhatsApp link (`wa.me/<number>`) as the contact form's WhatsApp channel address (forms-core `channelHref`), or
|
|
139
|
+
* '' — a whatsapp.com page that is no number is no chat. Pure. */
|
|
140
|
+
export function statedWhatsAppHref(social: ReadonlyArray<string> | null | undefined): string {
|
|
141
|
+
const url = socialLinksByNetwork(social)[WHATSAPP];
|
|
142
|
+
if (!url) return '';
|
|
143
|
+
const parsed = new URL(url);
|
|
144
|
+
const number = parsed.hostname.replace(/^www\./, '') === 'wa.me' ? parsed.pathname.slice(1) : parsed.searchParams.get('phone') ?? '';
|
|
145
|
+
return channelHref(ChannelKind.WhatsApp, number);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** The family whose sections carry the "follow" row (the contract's contact patterns). */
|
|
149
|
+
export const FOLLOW_ROW_FAMILY = 'contact';
|
|
150
|
+
|
|
151
|
+
/** Index paths (from the root) of every node that shows a contact fact (`ph: email | phone | city | address | hours`). */
|
|
152
|
+
function factPaths(node: PatternNode, at: number[] = []): number[][] {
|
|
153
|
+
const own = node.ph && (FACT_KEYS as ReadonlyArray<string>).includes(node.ph) ? [at] : [];
|
|
154
|
+
return [...own, ...(node.c ?? []).flatMap((k, i) => factPaths(k, [...at, i]))];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** The longest path every one of `paths` starts with. */
|
|
158
|
+
function commonStart(paths: ReadonlyArray<ReadonlyArray<number>>): number[] {
|
|
159
|
+
const out: number[] = [];
|
|
160
|
+
for (let i = 0; paths.every(p => i < p.length && p[i] === paths[0][i]); i++) out.push(paths[0][i]);
|
|
161
|
+
return out;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* A contact section with the owner's stated social links (Doron 2026-11-29: "in the contact area"): THE footer part
|
|
166
|
+
* (`socialLinksPart` — its "Follow" label and one link per network, the same recipe, no copy) placed in the box that holds
|
|
167
|
+
* the section's contact facts (the details column of `contact.split`, the grid of `contact.simple`), after them; a section
|
|
168
|
+
* with no fact line takes it at the end of its first box. None stated, or nothing the footer can name: the section as it
|
|
169
|
+
* was. Pure — a new node, the input never touched.
|
|
170
|
+
*/
|
|
171
|
+
export function withFollowRow(node: PatternNode, social: ReadonlyArray<string> | null | undefined): PatternNode {
|
|
172
|
+
if (!footerSocialLinks(social).links.length) return node;
|
|
173
|
+
const facts = factPaths(node);
|
|
174
|
+
const box = facts.length ? commonStart(facts.map(p => p.slice(0, -1))) : node.c?.[0]?.t === 'Container' ? [0] : null;
|
|
175
|
+
if (!box) return node;
|
|
176
|
+
const place = (n: PatternNode, path: ReadonlyArray<number>): PatternNode => path.length
|
|
177
|
+
? { ...n, c: (n.c ?? []).map((k, i) => (i === path[0] ? place(k, path.slice(1)) : k)) }
|
|
178
|
+
: { ...n, c: [...(n.c ?? []), socialLinksPart(social)] };
|
|
179
|
+
return place(node, box);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* ─── The follow row reads Site settings (iox-ui#201, lead decision 2026-11-30) ───────────────────────────────────────────
|
|
184
|
+
*
|
|
185
|
+
* A follow row is THE footer part a build stamps (`socialLinksPart`): a box with role `footer.social` whose links carry role
|
|
186
|
+
* `footer.social-link` — in the footer and in a contact section (`withFollowRow`). Its links are not the owner's words to
|
|
187
|
+
* keep: they are Site settings ▸ Socials, read when the page is drawn. Saving Socials never rewrites a footer; the renderers
|
|
188
|
+
* draw the current links instead, so a change reaches every site (old builds included) and a stale address never stays.
|
|
189
|
+
*
|
|
190
|
+
* - The FIRST `footer.social-link` is the template: every network Site settings holds becomes one copy of it — its look,
|
|
191
|
+
* states and words-box kept, its words the network's name, its address the owner's (external, a new tab), in the contract's order
|
|
192
|
+
* (`FOOTER.socialNetworks`, Google included), at most `socialMax`. A template the owner made an icon link (an Icon inside)
|
|
193
|
+
* wears each network's own glyph from the contract; one with an accessible name gets the network's name.
|
|
194
|
+
* - The owner's own edits keep working: a label, a restyled link, a link of their own added to the row (no role) stay; a row
|
|
195
|
+
* whose stamped links were all removed is theirs and is never touched.
|
|
196
|
+
* - Site settings empty: on the LIVE site the stamped links go, and a row left with no link of the owner's goes with them
|
|
197
|
+
* (label and all — never a "Follow" with nothing to follow). In the BUILDER the row stays as saved, so the owner sees where
|
|
198
|
+
* the links will show and the template survives the next save.
|
|
199
|
+
* - Site settings unread (`null` — the read failed or the studio has no record yet): the layout as saved.
|
|
200
|
+
*
|
|
201
|
+
* Pure: a new tree where something changed, the same node objects where nothing did; ids of the copies are derived from the
|
|
202
|
+
* template's (`<template>-<network>`), so a builder save and the next render agree.
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
/** A layout node as every renderer holds it (the builder's ComponentNode, the engine's layout node, a SerializedNode) —
|
|
206
|
+
* only what the follow row reads. */
|
|
207
|
+
export interface FollowRowNode {
|
|
208
|
+
id: string;
|
|
209
|
+
type: string;
|
|
210
|
+
role?: string;
|
|
211
|
+
props?: Record<string, unknown>;
|
|
212
|
+
children?: FollowRowNode[];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Where the layout is drawn: the visitor's page, or the builder's canvas (the row stays as saved when Socials is empty). */
|
|
216
|
+
export enum FollowRowView {
|
|
217
|
+
Live = 'live',
|
|
218
|
+
Edit = 'edit',
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** The roles of the follow row (the contract part `social`). */
|
|
222
|
+
export const FOLLOW_ROW_ROLE: string = FooterRole.Social;
|
|
223
|
+
export const FOLLOW_LINK_ROLE: string = FooterRole.SocialLink;
|
|
224
|
+
|
|
225
|
+
/** Where each type that can be a follow link writes its address (compose-site's link slots; a ButtonBlock links as `<a>`). */
|
|
226
|
+
const FOLLOW_URL_SLOT: Readonly<Record<string, { url: string; fixed?: Readonly<Record<string, string>> }>> = {
|
|
227
|
+
Link: { url: 'url' },
|
|
228
|
+
LinkedContainer: { url: 'url' },
|
|
229
|
+
ButtonBlock: { url: 'href', fixed: { tag: 'a' } },
|
|
230
|
+
};
|
|
231
|
+
/** A follow link opens the network in a new tab. */
|
|
232
|
+
export const FOLLOW_TARGET = '_blank';
|
|
233
|
+
const ICON_TYPE = 'Icon';
|
|
234
|
+
/** Where a child of a button-like follow link holds its words. */
|
|
235
|
+
const CHILD_WORD_PROPS: ReadonlyArray<string> = ['content', 'label', 'text'];
|
|
236
|
+
const ICON_PROP = 'iconClass';
|
|
237
|
+
/** A Phosphor class that is a weight, not a glyph (`ph`, `ph-thin` …). */
|
|
238
|
+
const PH_WEIGHT = /^ph(-(thin|light|regular|bold|fill|duotone))?$/;
|
|
239
|
+
/** The suffix a copy's id carries — stripped to find the template's own id on the next pass. */
|
|
240
|
+
const NETWORK_SUFFIX = new RegExp(`-(${FOOTER_SOCIAL_NETWORKS.map(n => n.id).join('|')})$`);
|
|
241
|
+
|
|
242
|
+
/** True when the tree holds a follow row (a stamped follow link) — a renderer reads Site settings only then. */
|
|
243
|
+
export function holdsFollowRow(nodes: ReadonlyArray<FollowRowNode> | null | undefined): boolean {
|
|
244
|
+
return (nodes ?? []).some(n => n?.role === FOLLOW_LINK_ROLE || holdsFollowRow(n?.children));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Every follow row of `roots` drawn from Site settings' links (`siteSocialLinks` of the record) — see above. Pure. */
|
|
248
|
+
export function followSiteSocials<T extends FollowRowNode>(
|
|
249
|
+
roots: ReadonlyArray<T>,
|
|
250
|
+
site: ReadonlyArray<string> | null | undefined,
|
|
251
|
+
view: FollowRowView,
|
|
252
|
+
): T[] {
|
|
253
|
+
if (site == null || !holdsFollowRow(roots)) return roots as T[];
|
|
254
|
+
const links = footerSocialLinks(site).links;
|
|
255
|
+
return splice(roots as ReadonlyArray<FollowRowNode>, n => {
|
|
256
|
+
if (!isFollowRow(n)) return undefined;
|
|
257
|
+
const row = followRow(n, links, view);
|
|
258
|
+
return row ? [row] : [];
|
|
259
|
+
}) as T[];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** `nodes` with `visit` applied top-down: `undefined` = look inside, an array = what stands in the node's place. The same
|
|
263
|
+
* array (and node objects) when nothing changed. */
|
|
264
|
+
function splice(nodes: ReadonlyArray<FollowRowNode>, visit: (n: FollowRowNode) => FollowRowNode[] | undefined): FollowRowNode[] {
|
|
265
|
+
let changed = false;
|
|
266
|
+
const out: FollowRowNode[] = [];
|
|
267
|
+
for (const n of nodes) {
|
|
268
|
+
let next = visit(n);
|
|
269
|
+
if (next === undefined) {
|
|
270
|
+
const kids = n.children ? splice(n.children, visit) : undefined;
|
|
271
|
+
next = [kids && kids !== n.children ? { ...n, children: kids } : n];
|
|
272
|
+
}
|
|
273
|
+
if (next.length !== 1 || next[0] !== n) changed = true;
|
|
274
|
+
out.push(...next);
|
|
275
|
+
}
|
|
276
|
+
return changed ? out : (nodes as FollowRowNode[]);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function firstWithRole(n: FollowRowNode, role: string): FollowRowNode | null {
|
|
280
|
+
for (const k of n.children ?? []) {
|
|
281
|
+
if (k.role === role) return k;
|
|
282
|
+
const deep = firstWithRole(k, role);
|
|
283
|
+
if (deep) return deep;
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const holdsLink = (n: FollowRowNode): boolean => (n.children ?? []).some(k => k.type in FOLLOW_URL_SLOT || holdsLink(k));
|
|
289
|
+
|
|
290
|
+
/** A row: the `footer.social` block, or (a one-line footer) the bare box its stamped links sit in. */
|
|
291
|
+
const isFollowRow = (n: FollowRowNode): boolean => n.role === FOLLOW_ROW_ROLE || (n.children ?? []).some(k => k.role === FOLLOW_LINK_ROLE);
|
|
292
|
+
|
|
293
|
+
/** Every follow row of a tree by its id (the outermost — a row is never looked inside). */
|
|
294
|
+
function followRowsById(nodes: ReadonlyArray<FollowRowNode>, out = new Map<string, FollowRowNode>()): Map<string, FollowRowNode> {
|
|
295
|
+
for (const n of nodes) {
|
|
296
|
+
if (isFollowRow(n)) out.set(n.id, n);
|
|
297
|
+
else if (n.children) followRowsById(n.children, out);
|
|
298
|
+
}
|
|
299
|
+
return out;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* What a BUILDER save writes for the follow rows the canvas drew (`followSiteSocials(…, FollowRowView.Edit)` on load):
|
|
304
|
+
* Site settings' links are shown, never written into the page — a row the canvas still holds exactly as drawn is saved as
|
|
305
|
+
* it was STORED (so a composed section's stamp still reads "as the build left it", and the next render draws it again);
|
|
306
|
+
* a row the owner changed on the canvas is theirs and is saved as they left it.
|
|
307
|
+
*
|
|
308
|
+
* `saved` — the tree as loaded; `drawn` — the drawn tree as the host serializes it (the same serializer as the save, taken
|
|
309
|
+
* right after load); `serialized` — what the save is about to write. Pure: a new tree where a row was put back.
|
|
310
|
+
*/
|
|
311
|
+
export function keepSavedFollowRows<T extends FollowRowNode>(
|
|
312
|
+
serialized: ReadonlyArray<T>,
|
|
313
|
+
drawn: ReadonlyArray<FollowRowNode>,
|
|
314
|
+
saved: ReadonlyArray<FollowRowNode>,
|
|
315
|
+
): T[] {
|
|
316
|
+
const storedRows = followRowsById(saved);
|
|
317
|
+
if (!storedRows.size) return serialized as T[];
|
|
318
|
+
const drawnRows = followRowsById(drawn);
|
|
319
|
+
return splice(serialized as ReadonlyArray<FollowRowNode>, n => {
|
|
320
|
+
if (!isFollowRow(n)) return undefined;
|
|
321
|
+
const stored = storedRows.get(n.id);
|
|
322
|
+
const asDrawn = drawnRows.get(n.id);
|
|
323
|
+
return stored && asDrawn && JSON.stringify(n) === JSON.stringify(asDrawn) ? [stored] : [n];
|
|
324
|
+
}) as T[];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/** One row drawn: the template's place takes one copy per network, every other stamped link goes; null = the row goes. */
|
|
328
|
+
function followRow(row: FollowRowNode, links: ReadonlyArray<FooterSocialLink>, view: FollowRowView): FollowRowNode | null {
|
|
329
|
+
const template = firstWithRole(row, FOLLOW_LINK_ROLE);
|
|
330
|
+
if (!template) return row;
|
|
331
|
+
if (!links.length && view === FollowRowView.Edit) return row;
|
|
332
|
+
const copies = links.map(l => followLink(template, l));
|
|
333
|
+
const next = { ...row, children: splice(row.children ?? [], n => (n.role !== FOLLOW_LINK_ROLE ? undefined : n === template ? copies : [])) };
|
|
334
|
+
return links.length || holdsLink(next) ? next : null;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** The template drawn for one network: its address (external), its words, its glyph, ids derived. */
|
|
338
|
+
function followLink(template: FollowRowNode, link: FooterSocialLink): FollowRowNode {
|
|
339
|
+
const glyph = FOOTER_SOCIAL_NETWORKS.find(n => n.id === link.network)?.icon;
|
|
340
|
+
// A button or linked box holds its words in a child: words that are the template's OWN network name become this one's.
|
|
341
|
+
const slot = FOLLOW_URL_SLOT[template.type];
|
|
342
|
+
const ownName = slot ? socialLinkOf(String(template.props?.[slot.url] ?? ''))?.name : undefined;
|
|
343
|
+
const copy = (n: FollowRowNode, top: boolean): FollowRowNode => {
|
|
344
|
+
const props: Record<string, unknown> = { ...(n.props ?? {}) };
|
|
345
|
+
if (!top && ownName) for (const k of CHILD_WORD_PROPS) if (props[k] === ownName) props[k] = link.name;
|
|
346
|
+
if (top) {
|
|
347
|
+
const slot = FOLLOW_URL_SLOT[n.type];
|
|
348
|
+
if (slot) {
|
|
349
|
+
Object.assign(props, slot.fixed ?? {});
|
|
350
|
+
props['linkType'] = LinkType.External;
|
|
351
|
+
props[slot.url] = link.url;
|
|
352
|
+
// The tester's live check (#201): a network's page opens beside the site, never in its place (rel=noopener
|
|
353
|
+
// is the renderers' — design-core / the Link component — for every `_blank`).
|
|
354
|
+
props['target'] = FOLLOW_TARGET;
|
|
355
|
+
}
|
|
356
|
+
if ('label' in props || n.type === 'Link') props['label'] = link.name;
|
|
357
|
+
if (typeof props['ariaLabel'] === 'string' && props['ariaLabel']) props['ariaLabel'] = link.name;
|
|
358
|
+
}
|
|
359
|
+
if (n.type === ICON_TYPE && glyph) props[ICON_PROP] = withGlyph(props[ICON_PROP], glyph);
|
|
360
|
+
const id = `${n.id.replace(NETWORK_SUFFIX, '')}-${link.network}`;
|
|
361
|
+
return { ...n, id, props, ...(n.children ? { children: n.children.map(k => copy(k, false)) } : {}) };
|
|
362
|
+
};
|
|
363
|
+
return copy(template, true);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** An icon class with its glyph swapped and its weight kept (`ph-thin ph-star` → `ph-thin ph-instagram-logo`). */
|
|
367
|
+
function withGlyph(current: unknown, glyph: string): string {
|
|
368
|
+
const weight = String(current ?? '').split(/\s+/).find(t => PH_WEIGHT.test(t)) ?? 'ph-thin';
|
|
369
|
+
return `${weight} ${glyph}`;
|
|
370
|
+
}
|