@vectoriox/iox-ui 5.203.0 → 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 +5165 -267
- 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 +2263 -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/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-mix.ts +3 -1
- package/src/generation-core/node-baselines.generated.ts +953 -10
- package/src/generation-core/public-api.ts +20 -0
- package/src/generation-core/site-spec.generated.ts +73 -11
- package/src/generation-core/social-links.ts +195 -2
- 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
|
@@ -104,3 +104,23 @@ export * from './layout-edits';
|
|
|
104
104
|
export * from './adjustments';
|
|
105
105
|
export * from './site-tree';
|
|
106
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,8 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9325
9385
|
"hosts": [
|
|
9326
9386
|
"wa.me",
|
|
9327
9387
|
"whatsapp.com"
|
|
9328
|
-
]
|
|
9388
|
+
],
|
|
9389
|
+
"icon": "ph-whatsapp-logo"
|
|
9329
9390
|
},
|
|
9330
9391
|
{
|
|
9331
9392
|
"id": "google",
|
|
@@ -9335,7 +9396,8 @@ export const SPEC_SITE_LAYOUT = {
|
|
|
9335
9396
|
"g.co",
|
|
9336
9397
|
"maps.app.goo.gl",
|
|
9337
9398
|
"business.google.com"
|
|
9338
|
-
]
|
|
9399
|
+
],
|
|
9400
|
+
"icon": "ph-google-logo"
|
|
9339
9401
|
}
|
|
9340
9402
|
],
|
|
9341
9403
|
"callWords": [
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { LinkType } from '@vectoriox/iox-ui/design-core';
|
|
1
2
|
import { channelHref, ChannelKind } from '@vectoriox/iox-ui/forms-core';
|
|
2
3
|
|
|
3
|
-
import { FOOTER_SOCIAL_NETWORKS, footerSocialLinks, FooterSocialLink, recognisedSocialLinks, socialLinkOf, socialLinksPart } from './footer-mix';
|
|
4
|
+
import { FOOTER_SOCIAL_NETWORKS, FooterRole, footerSocialLinks, FooterSocialLink, recognisedSocialLinks, socialLinkOf, socialLinksPart } from './footer-mix';
|
|
4
5
|
import { PatternNode } from './patterns';
|
|
5
6
|
import { FACT_KEYS } from './site-plan.model';
|
|
6
7
|
|
|
@@ -16,7 +17,9 @@ import { FACT_KEYS } from './site-plan.model';
|
|
|
16
17
|
* network, the first list winning;
|
|
17
18
|
* - `SITE_SOCIAL_FIELDS`, `siteSocialLinks`, `siteSocialPatch` — the Site settings record's fields, read and written;
|
|
18
19
|
* - `statedWhatsAppHref` — a stated WhatsApp link as the contact form's WhatsApp channel (forms-core `channelHref`);
|
|
19
|
-
* - `withFollowRow` — a contact section with the footer's social part ("Follow" and the links) beside its contact facts
|
|
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.
|
|
20
23
|
*
|
|
21
24
|
* Pure and framework-free (iox-cms imports it).
|
|
22
25
|
*/
|
|
@@ -175,3 +178,193 @@ export function withFollowRow(node: PatternNode, social: ReadonlyArray<string> |
|
|
|
175
178
|
: { ...n, c: [...(n.c ?? []), socialLinksPart(social)] };
|
|
176
179
|
return place(node, box);
|
|
177
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
|
+
}
|