@bison-lab/payload-core 4.34.0 → 4.35.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/README.md +29 -2
- package/dist/block-library.d.mts +1 -1
- package/dist/block-library.mjs +1 -1
- package/dist/{block-thumbnails-Cg7P-dTZ.mjs → block-thumbnails-VRxpSXw1.mjs} +1 -1
- package/dist/{block-thumbnails-Cg7P-dTZ.mjs.map → block-thumbnails-VRxpSXw1.mjs.map} +1 -1
- package/dist/block-thumbnails-cli.mjs +1 -1
- package/dist/block-thumbnails.mjs +1 -1
- package/dist/{catalogue-BU3lA_kB.d.mts → catalogue-CEfYwTSK.d.mts} +1 -1
- package/dist/{catalogue-BU3lA_kB.d.mts.map → catalogue-CEfYwTSK.d.mts.map} +1 -1
- package/dist/{facet-field-D56uuPXX.d.mts → facet-field-BvQp8Hzh.d.mts} +1 -1
- package/dist/{facet-field-D56uuPXX.d.mts.map → facet-field-BvQp8Hzh.d.mts.map} +1 -1
- package/dist/{facet-field-O0_zqMJ2.mjs → facet-field-Uf8S4yL1.mjs} +1 -1
- package/dist/{facet-field-O0_zqMJ2.mjs.map → facet-field-Uf8S4yL1.mjs.map} +1 -1
- package/dist/identity-CN6EOeDM.mjs +180 -0
- package/dist/identity-CN6EOeDM.mjs.map +1 -0
- package/dist/index.d.mts +41 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +145 -8
- package/dist/index.mjs.map +1 -1
- package/dist/metadata.d.mts +14 -2
- package/dist/metadata.d.mts.map +1 -1
- package/dist/metadata.mjs +29 -3
- package/dist/metadata.mjs.map +1 -1
- package/dist/navigation.d.mts +1 -1
- package/dist/navigation.mjs +1 -1
- package/dist/og.d.mts +155 -0
- package/dist/og.d.mts.map +1 -0
- package/dist/og.mjs +282 -0
- package/dist/og.mjs.map +1 -0
- package/dist/{identity-8doWYeRn.mjs → preview-Br1SQCKn.mjs} +4 -179
- package/dist/preview-Br1SQCKn.mjs.map +1 -0
- package/dist/preview-Cgbh9eAq.d.mts +113 -0
- package/dist/preview-Cgbh9eAq.d.mts.map +1 -0
- package/dist/published-BLXCep6Z.d.mts +26 -0
- package/dist/published-BLXCep6Z.d.mts.map +1 -0
- package/dist/{published-CcW9bqLJ.mjs → published-CEuK5ym6.mjs} +1 -1
- package/dist/{published-CcW9bqLJ.mjs.map → published-CEuK5ym6.mjs.map} +1 -1
- package/dist/published-DgAzpDSG.mjs +31 -0
- package/dist/published-DgAzpDSG.mjs.map +1 -0
- package/dist/{published-DSwrPpf0.d.mts → published-Dsg-HX-v.d.mts} +1 -1
- package/dist/{published-DSwrPpf0.d.mts.map → published-Dsg-HX-v.d.mts.map} +1 -1
- package/dist/{published-niJkPGjE.mjs → published-QyTcDznE.mjs} +1 -1
- package/dist/{published-niJkPGjE.mjs.map → published-QyTcDznE.mjs.map} +1 -1
- package/dist/{root-page-key-P4m6fyWl.mjs → root-page-key-B86JwL8Z.mjs} +1 -1
- package/dist/{root-page-key-P4m6fyWl.mjs.map → root-page-key-B86JwL8Z.mjs.map} +1 -1
- package/dist/seo.mjs +1 -1
- package/dist/share-image-C8ZtIcU8.mjs +19 -0
- package/dist/share-image-C8ZtIcU8.mjs.map +1 -0
- package/dist/taxonomy.d.mts +1 -1
- package/dist/taxonomy.mjs +1 -1
- package/dist/theme.d.mts +3 -22
- package/dist/theme.d.mts.map +1 -1
- package/dist/theme.mjs +3 -28
- package/dist/theme.mjs.map +1 -1
- package/dist/{title-BM9dRBZh.d.mts → title-C8ppEDlc.d.mts} +1 -1
- package/dist/{title-BM9dRBZh.d.mts.map → title-C8ppEDlc.d.mts.map} +1 -1
- package/dist/title-DJ7C48gq.mjs +21 -0
- package/dist/title-DJ7C48gq.mjs.map +1 -0
- package/dist/{preview-D2ya2fvq.d.mts → types-D6jQql5Z.d.mts} +3 -110
- package/dist/types-D6jQql5Z.d.mts.map +1 -0
- package/dist/wireframe-cli.mjs +1 -1
- package/dist/{wireframe-_bq0ZE0o.mjs → wireframe-sJW8Q4NS.mjs} +1 -1
- package/dist/{wireframe-_bq0ZE0o.mjs.map → wireframe-sJW8Q4NS.mjs.map} +1 -1
- package/dist/wireframe.mjs +1 -1
- package/package.json +19 -5
- package/dist/identity-8doWYeRn.mjs.map +0 -1
- package/dist/preview-D2ya2fvq.d.mts.map +0 -1
- package/dist/share-image-C4ILz4p2.mjs +0 -37
- package/dist/share-image-C4ILz4p2.mjs.map +0 -1
|
@@ -1,156 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const THEME_COLOR_FIELD = "@bison-lab/payload-core/admin#ColorField";
|
|
4
|
-
const THEME_COLOR_SCALE_FIELD = "@bison-lab/payload-core/admin#ColorScaleField";
|
|
5
|
-
const THEME_LIBRARY_FIELD = "@bison-lab/payload-core/admin#LibraryField";
|
|
6
|
-
const THEME_FONT_FIELD = "@bison-lab/payload-core/admin#FontField";
|
|
7
|
-
const THEME_PAIRING_FIELD = "@bison-lab/payload-core/admin#PairingField";
|
|
8
|
-
const THEME_APPEARANCE_FIELD = "@bison-lab/payload-core/admin#AppearanceField";
|
|
9
|
-
const THEME_GREY_SCALE_FIELD = "@bison-lab/payload-core/admin#GreyScaleField";
|
|
10
|
-
const THEME_CONTRAST_REPORT = "@bison-lab/payload-core/admin#ContrastReport";
|
|
11
|
-
const THEME_SECTION_HEADING = "@bison-lab/payload-core/admin#SectionHeading";
|
|
12
|
-
const THEME_PUBLISH_FIELD = "@bison-lab/payload-core/admin#PublishChild";
|
|
13
|
-
const THEME_SAVE_BUTTON = "@bison-lab/payload-core/admin#HiddenSaveButton";
|
|
14
|
-
const THEME_DOCUMENT_CONTROLS = "@bison-lab/payload-core/admin#ThemeDocumentControls";
|
|
15
|
-
const THEME_IDENTITY_FALLBACK = "@bison-lab/payload-core/admin#IdentityFallback";
|
|
16
|
-
const LOOK_FIELD = "@bison-lab/payload-core/admin#LookField";
|
|
17
|
-
function headingSelectValue(heading) {
|
|
18
|
-
return heading ?? "";
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/theme/map.ts
|
|
22
|
-
function pick(value, fallback) {
|
|
23
|
-
return value == null ? fallback : value;
|
|
24
|
-
}
|
|
25
|
-
function headingFromDoc(heading, seed) {
|
|
26
|
-
if (heading === void 0) return seed;
|
|
27
|
-
if (heading === null || heading === "") return null;
|
|
28
|
-
return heading;
|
|
29
|
-
}
|
|
30
|
-
function hexFromColor(value, fallback) {
|
|
31
|
-
if (typeof value === "string") return value || fallback;
|
|
32
|
-
return pick(value?.hex, fallback);
|
|
33
|
-
}
|
|
34
|
-
function colorDocFromHex(hex, sourceStep = 500) {
|
|
35
|
-
return colorDocFromState(createColorScale(hex, sourceStep));
|
|
36
|
-
}
|
|
37
|
-
function colorDocFromState(state) {
|
|
38
|
-
return {
|
|
39
|
-
hex: state.hex,
|
|
40
|
-
sourceStep: state.sourceStep,
|
|
41
|
-
scale: state.scale,
|
|
42
|
-
stale: state.stale,
|
|
43
|
-
include: Array.isArray(state.include) ? "custom" : state.include,
|
|
44
|
-
includedSteps: Array.isArray(state.include) ? [...state.include] : void 0
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
function stateFromColorDoc(doc, fallbackHex = "#000000") {
|
|
48
|
-
const hex = isThemeHex(doc?.hex) ? doc.hex : fallbackHex;
|
|
49
|
-
const sourceStep = Number(doc?.sourceStep) || 500;
|
|
50
|
-
const include = includeFromDoc(doc, sourceStep);
|
|
51
|
-
return {
|
|
52
|
-
hex,
|
|
53
|
-
sourceStep,
|
|
54
|
-
scale: doc?.scale && typeof doc.scale === "object" ? doc.scale : generateColorScale(hex, sourceStep),
|
|
55
|
-
stale: Boolean(doc?.stale),
|
|
56
|
-
include
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function includeFromDoc(doc, sourceStep) {
|
|
60
|
-
if (doc?.include === "source") return "source";
|
|
61
|
-
if (doc?.include === "custom" && Array.isArray(doc.includedSteps)) {
|
|
62
|
-
const steps = doc.includedSteps.map(Number).filter((step) => SHADE_STEPS.includes(step));
|
|
63
|
-
if (!steps.includes(sourceStep)) steps.push(sourceStep);
|
|
64
|
-
return steps;
|
|
65
|
-
}
|
|
66
|
-
return "all";
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Nested Theme document → flat `ThemeConfig`. Null or missing editor
|
|
70
|
-
* fields take the seed; `darkSelector` and `fontWeights` always come from
|
|
71
|
-
* the seed. Reads the BIS-87 groups and the pre-BIS-87 flat fields.
|
|
72
|
-
*/
|
|
73
|
-
function themeConfigFromDoc(doc, seed) {
|
|
74
|
-
const brand = doc?.colors?.brand ?? doc?.brand;
|
|
75
|
-
const typography = doc?.typography ?? doc?.fonts;
|
|
76
|
-
const appearance = doc?.appearance;
|
|
77
|
-
return {
|
|
78
|
-
brandPrimary: hexFromColor(brand?.primary, seed.brandPrimary),
|
|
79
|
-
brandSecondary: hexFromColor(brand?.secondary, seed.brandSecondary),
|
|
80
|
-
brandAccent: hexFromColor(brand?.accent, seed.brandAccent),
|
|
81
|
-
brandHighlight: hexFromColor(brand?.highlight, seed.brandHighlight),
|
|
82
|
-
brandSuccess: hexFromColor(brand?.success, seed.brandSuccess),
|
|
83
|
-
brandDestructive: hexFromColor(brand?.destructive, seed.brandDestructive ?? DESTRUCTIVE_SCALE_HEX) || seed.brandDestructive || DESTRUCTIVE_SCALE_HEX,
|
|
84
|
-
greyScale: pick(doc?.colors?.greyScale ?? doc?.greyScale, seed.greyScale),
|
|
85
|
-
radius: pick(appearance?.radius ?? doc?.radius, seed.radius),
|
|
86
|
-
shadow: pick(appearance?.shadow ?? doc?.shadow, seed.shadow),
|
|
87
|
-
motion: pick(appearance?.motion ?? doc?.motion, seed.motion),
|
|
88
|
-
density: pick(appearance?.density ?? doc?.density, seed.density),
|
|
89
|
-
defaultTheme: pick(appearance?.defaultTheme ?? doc?.defaultTheme, seed.defaultTheme),
|
|
90
|
-
fontBody: pick(typography?.body, seed.fontBody),
|
|
91
|
-
fontHeading: headingFromDoc(typography?.heading, seed.fontHeading),
|
|
92
|
-
darkSelector: seed.darkSelector,
|
|
93
|
-
fontWeights: seed.fontWeights
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/** The document `seedTheme` writes so a fresh Global matches the seed config. */
|
|
97
|
-
function docFromConfig(config, destructive) {
|
|
98
|
-
const destructiveHex = destructive ?? config.brandDestructive ?? DESTRUCTIVE_SCALE_HEX;
|
|
99
|
-
return {
|
|
100
|
-
colors: {
|
|
101
|
-
brand: {
|
|
102
|
-
primary: colorDocFromHex(config.brandPrimary),
|
|
103
|
-
secondary: colorDocFromHex(config.brandSecondary),
|
|
104
|
-
accent: colorDocFromHex(config.brandAccent),
|
|
105
|
-
highlight: colorDocFromHex(config.brandHighlight),
|
|
106
|
-
success: colorDocFromHex(config.brandSuccess),
|
|
107
|
-
destructive: colorDocFromHex(destructiveHex)
|
|
108
|
-
},
|
|
109
|
-
library: [],
|
|
110
|
-
greyScale: config.greyScale
|
|
111
|
-
},
|
|
112
|
-
typography: {
|
|
113
|
-
body: config.fontBody,
|
|
114
|
-
heading: config.fontHeading
|
|
115
|
-
},
|
|
116
|
-
appearance: {
|
|
117
|
-
defaultTheme: config.defaultTheme,
|
|
118
|
-
radius: config.radius,
|
|
119
|
-
shadow: config.shadow,
|
|
120
|
-
motion: config.motion,
|
|
121
|
-
density: config.density
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function validateThemeHex(value) {
|
|
126
|
-
if (!isThemeHex(value)) return "Enter a six-digit hex colour like #1e3a5f";
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
function validateSourceIncluded(value, { siblingData }) {
|
|
130
|
-
const include = siblingData?.include;
|
|
131
|
-
if (include === "all" || include === "source") return true;
|
|
132
|
-
const source = Number(siblingData?.sourceStep);
|
|
133
|
-
const steps = Array.isArray(value) ? value.map(Number) : [];
|
|
134
|
-
if (!SHADE_STEPS.includes(source)) return true;
|
|
135
|
-
if (!steps.includes(source)) return "The source step cannot be excluded";
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
//#endregion
|
|
139
|
-
//#region src/theme/types.ts
|
|
140
|
-
const THEME_SLUG = "theme";
|
|
141
|
-
const THEME_COLORS_SLUG = "theme-colors";
|
|
142
|
-
const THEME_TYPOGRAPHY_SLUG = "theme-typography";
|
|
143
|
-
const THEME_APPEARANCE_SLUG = "theme-appearance";
|
|
144
|
-
const THEME_IDENTITY_SLUG = "theme-identity";
|
|
145
|
-
const SYSTEM_COLOR_KEYS = [
|
|
146
|
-
"primary",
|
|
147
|
-
"secondary",
|
|
148
|
-
"accent",
|
|
149
|
-
"highlight",
|
|
150
|
-
"success",
|
|
151
|
-
"destructive"
|
|
152
|
-
];
|
|
153
|
-
//#endregion
|
|
1
|
+
import { l as stateFromColorDoc, n as SYSTEM_COLOR_KEYS, p as LOOK_FIELD } from "./identity-CN6EOeDM.mjs";
|
|
2
|
+
import { SHADE_STEPS, includedShadeSteps } from "@bison-lab/tokens";
|
|
154
3
|
//#region src/theme/library.ts
|
|
155
4
|
/**
|
|
156
5
|
* Payload's array form state stores the row count (`0`, `2`, …), not the
|
|
@@ -452,30 +301,6 @@ const THEME_PREVIEW_BREAKPOINTS = [
|
|
|
452
301
|
}
|
|
453
302
|
];
|
|
454
303
|
//#endregion
|
|
455
|
-
|
|
456
|
-
function fromUpload(value, fallback) {
|
|
457
|
-
if (value && typeof value === "object") {
|
|
458
|
-
const upload = value;
|
|
459
|
-
if (upload.url) return {
|
|
460
|
-
url: upload.url,
|
|
461
|
-
alt: upload.alt ?? fallback?.alt ?? ""
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
return fallback ?? null;
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Uploaded logo, favicon, and mobile-menu mark, or the fallback the site
|
|
468
|
-
* passed into `createTheme`. Empty fields keep the fallback;
|
|
469
|
-
* `--color-primary-mark` is not a Theme field.
|
|
470
|
-
*/
|
|
471
|
-
function resolveThemeIdentity(doc, fallback) {
|
|
472
|
-
return {
|
|
473
|
-
lockup: fromUpload(doc?.logo, fallback?.lockup),
|
|
474
|
-
mark: fromUpload(doc?.logoMark, fallback?.mark),
|
|
475
|
-
favicon: fromUpload(doc?.favicon, fallback?.favicon)
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
//#endregion
|
|
479
|
-
export { THEME_CONTRAST_REPORT as A, headingSelectValue as B, themeConfigFromDoc as C, THEME_APPEARANCE_FIELD as D, LOOK_FIELD as E, THEME_LIBRARY_FIELD as F, THEME_PAIRING_FIELD as I, THEME_PUBLISH_FIELD as L, THEME_FONT_FIELD as M, THEME_GREY_SCALE_FIELD as N, THEME_COLOR_FIELD as O, THEME_IDENTITY_FALLBACK as P, THEME_SAVE_BUTTON as R, stateFromColorDoc as S, validateThemeHex as T, THEME_COLORS_SLUG as _, PAGE_EDITOR_SYSTEM_KEYS as a, THEME_TYPOGRAPHY_SLUG as b, pageEditorTokens as c, rewriteColorTokens as d, deleteLibraryColor as f, THEME_APPEARANCE_SLUG as g, SYSTEM_COLOR_KEYS as h, lookField as i, THEME_DOCUMENT_CONTROLS as j, THEME_COLOR_SCALE_FIELD as k, themeLibraryFromDoc as l, themeColorKeys as m, THEME_PREVIEW_BREAKPOINTS as n, pageEditorLooks as o, rewriteColorToken as p, colorTokenField as r, pageEditorSwatches as s, resolveThemeIdentity as t, findColorTokens as u, THEME_IDENTITY_SLUG as v, validateSourceIncluded as w, docFromConfig as x, THEME_SLUG as y, THEME_SECTION_HEADING as z };
|
|
304
|
+
export { pageEditorLooks as a, themeLibraryFromDoc as c, deleteLibraryColor as d, rewriteColorToken as f, PAGE_EDITOR_SYSTEM_KEYS as i, findColorTokens as l, colorTokenField as n, pageEditorSwatches as o, themeColorKeys as p, lookField as r, pageEditorTokens as s, THEME_PREVIEW_BREAKPOINTS as t, rewriteColorTokens as u };
|
|
480
305
|
|
|
481
|
-
//# sourceMappingURL=
|
|
306
|
+
//# sourceMappingURL=preview-Br1SQCKn.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-Br1SQCKn.mjs","names":[],"sources":["../src/theme/library.ts","../src/theme/color-tokens.ts","../src/theme/looks.ts","../src/theme/look-field.ts","../src/theme/preview.ts"],"sourcesContent":["import { SHADE_STEPS, type ShadeStep } from \"@bison-lab/tokens\";\n\nimport { SYSTEM_COLOR_KEYS, type ThemeDoc, type ThemeLibraryColorDoc } from \"./types\";\n\n/**\n * Payload's array form state stores the row count (`0`, `2`, …), not the\n * rows. A custom Field that treats that number as the list will throw\n * `rows.filter is not a function` on an empty Theme library.\n */\nexport function asLibraryRows(value: unknown): ThemeLibraryColorDoc[] {\n return Array.isArray(value) ? value : [];\n}\n\nconst STEP_SET = new Set<number>(SHADE_STEPS);\n\n/**\n * Page editors pick `coral-400`, never a raw hex. Rewrite every use of\n * `fromKey` onto `toKey` at the same step: `coral-400` → `highlight-400`.\n * A bare key (`coral`) becomes `toKey`. Anything else is left alone.\n */\nexport function rewriteColorToken(token: string, fromKey: string, toKey: string): string {\n if (token === fromKey) return toKey;\n const dash = token.lastIndexOf(\"-\");\n if (dash <= 0) return token;\n const key = token.slice(0, dash);\n const step = Number(token.slice(dash + 1));\n if (key !== fromKey || !STEP_SET.has(step)) return token;\n return `${toKey}-${step as ShadeStep}`;\n}\n\nexport function themeColorKeys(doc: ThemeDoc | null | undefined): string[] {\n const custom = asLibraryRows(doc?.colors?.library)\n .map((row) => row.key?.trim())\n .filter((key): key is string => Boolean(key));\n return [...SYSTEM_COLOR_KEYS, ...custom];\n}\n\n/**\n * Remove a custom color. Unused: omit `replacement` and the row is gone.\n * In use: pass another system or custom key; the caller rewrites page\n * tokens with `rewriteColorToken`. After this, no library row still\n * has `key`.\n */\nexport function deleteLibraryColor(doc: ThemeDoc, key: string, replacement?: string): ThemeDoc {\n const library = [...asLibraryRows(doc.colors?.library)];\n const index = library.findIndex((row) => row.key === key);\n if (index === -1) {\n throw new Error(`No custom color named ${JSON.stringify(key)}`);\n }\n library.splice(index, 1);\n const next: ThemeDoc = {\n ...doc,\n colors: { ...doc.colors, library },\n };\n if (replacement !== undefined) {\n if (replacement === key) {\n throw new Error(\"Replacement must be a different color\");\n }\n if (!themeColorKeys(next).includes(replacement)) {\n throw new Error(`Replacement ${JSON.stringify(replacement)} is not a system or remaining custom color`);\n }\n }\n return next;\n}\n","import { rewriteColorToken } from \"./library\";\n\nexport interface ColorTokenHit {\n path: string;\n token: string;\n}\n\n/**\n * A string `rewriteColorToken` would change: `coral`, `coral-400`.\n * `#FF5A2D` and `coral-ish` are not tokens.\n */\nexport function isColorToken(value: string, key: string): boolean {\n return rewriteColorToken(value, key, `\\0${key}`) !== value;\n}\n\nexport function findColorTokens(value: unknown, key: string): ColorTokenHit[] {\n const hits: ColorTokenHit[] = [];\n walk(value, \"\", (path, token) => {\n if (isColorToken(token, key)) hits.push({ path, token });\n });\n return hits;\n}\n\nexport function rewriteColorTokens<T>(value: T, fromKey: string, toKey: string): T {\n return rewriteValue(value, fromKey, toKey) as T;\n}\n\nfunction rewriteValue(value: unknown, fromKey: string, toKey: string): unknown {\n if (typeof value === \"string\") return rewriteColorToken(value, fromKey, toKey);\n if (Array.isArray(value)) return value.map((item) => rewriteValue(item, fromKey, toKey));\n if (value && typeof value === \"object\") {\n const next: Record<string, unknown> = {};\n for (const [name, child] of Object.entries(value)) {\n next[name] = rewriteValue(child, fromKey, toKey);\n }\n return next;\n }\n return value;\n}\n\nfunction walk(value: unknown, path: string, visit: (path: string, token: string) => void): void {\n if (typeof value === \"string\") {\n visit(path, value);\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((item, index) => walk(item, join(path, String(index)), visit));\n return;\n }\n if (value && typeof value === \"object\") {\n for (const [name, child] of Object.entries(value)) {\n walk(child, join(path, name), visit);\n }\n }\n}\n\nfunction join(path: string, segment: string): string {\n return path ? `${path}.${segment}` : segment;\n}\n","import { includedShadeSteps, type ShadeStep } from \"@bison-lab/tokens\";\n\nimport { stateFromColorDoc } from \"./map\";\nimport { THEME_SLUG, type ThemeColorDoc, type ThemeDoc, type ThemeLibraryColorDoc } from \"./types\";\n\n/**\n * System colors Color Settings offers as page-editor fills. Success and\n * Destructive stay off this list — they are theme chrome only.\n */\nexport const PAGE_EDITOR_SYSTEM_KEYS = [\"primary\", \"secondary\", \"accent\", \"highlight\"] as const;\n\nexport type PageEditorSystemKey = (typeof PAGE_EDITOR_SYSTEM_KEYS)[number];\n\nexport interface LookOption {\n label: string;\n value: string;\n}\n\nconst SYSTEM_LABELS: Record<PageEditorSystemKey, string> = {\n primary: \"Primary\",\n secondary: \"Secondary\",\n accent: \"Accent\",\n highlight: \"Highlight\",\n};\n\nfunction brandColor(doc: ThemeDoc | null | undefined, key: PageEditorSystemKey): ThemeColorDoc | null {\n const brand = doc?.colors?.brand ?? doc?.brand;\n const value = brand?.[key];\n if (typeof value === \"string\" || value == null) return value == null ? null : { hex: value };\n return value;\n}\n\nexport function themeLibraryFromDoc(doc: ThemeDoc | null | undefined): ThemeLibraryColorDoc[] {\n return Array.isArray(doc?.colors?.library) ? doc.colors.library : [];\n}\n\nfunction libraryRows(doc: ThemeDoc | null | undefined): ThemeLibraryColorDoc[] {\n return themeLibraryFromDoc(doc);\n}\n\nfunction titleCase(key: string): string {\n return key.charAt(0).toUpperCase() + key.slice(1);\n}\n\nfunction stepsFor(color: ThemeColorDoc | null | undefined, fallbackHex: string): ShadeStep[] {\n return includedShadeSteps(stateFromColorDoc(color, fallbackHex));\n}\n\n/**\n * Family keys a `lookField()` may offer: the page-editor system scales\n * plus every custom color on Colors. Adding Coral on Theme makes `coral`\n * appear here with no `@bison-lab/*` release.\n */\nexport function pageEditorLooks(doc: ThemeDoc | null | undefined): LookOption[] {\n const system = PAGE_EDITOR_SYSTEM_KEYS.map((value) => ({\n label: SYSTEM_LABELS[value],\n value,\n }));\n const custom = libraryRows(doc)\n .map((row) => {\n const value = row.key?.trim();\n if (!value) return null;\n return { label: row.label?.trim() || titleCase(value), value };\n })\n .filter((option): option is LookOption => option !== null);\n return [...system, ...custom];\n}\n\n/**\n * Included steps as `coral-400`. Excluded steps do not appear. System\n * scales with no stored include list offer the full 50–950 ramp.\n */\nexport function pageEditorTokens(doc: ThemeDoc | null | undefined): LookOption[] {\n const tokens: LookOption[] = [];\n for (const key of PAGE_EDITOR_SYSTEM_KEYS) {\n const label = SYSTEM_LABELS[key];\n for (const step of stepsFor(brandColor(doc, key), \"#000000\")) {\n tokens.push({ label: `${label} ${step}`, value: `${key}-${step}` });\n }\n }\n for (const row of libraryRows(doc)) {\n const key = row.key?.trim();\n if (!key) continue;\n const label = row.label?.trim() || titleCase(key);\n for (const step of stepsFor(row, row.hex ?? \"#000000\")) {\n tokens.push({ label: `${label} ${step}`, value: `${key}-${step}` });\n }\n }\n return tokens;\n}\n\n/** One included step with its stored color, for a picker that draws swatches. */\nexport interface ColorSwatch extends LookOption {\n /** The family key the token starts with (`primary`, `coral`). */\n family: string;\n /** The family's label (`Primary`, `Coral`). */\n familyLabel: string;\n step: ShadeStep;\n /** The step's HSL triplet (`330 100% 43%`), the value its CSS variable holds. */\n hsl: string;\n}\n\n/**\n * `pageEditorTokens` with each step's stored color, grouped by family in\n * the same order, so an admin picker can paint a swatch without the site's\n * Theme stylesheet.\n */\nexport function pageEditorSwatches(doc: ThemeDoc | null | undefined): ColorSwatch[] {\n const swatches: ColorSwatch[] = [];\n const push = (family: string, familyLabel: string, color: ThemeColorDoc | null | undefined, fallbackHex: string) => {\n const state = stateFromColorDoc(color, fallbackHex);\n for (const step of includedShadeSteps(state)) {\n swatches.push({\n label: `${familyLabel} ${step}`,\n value: `${family}-${step}`,\n family,\n familyLabel,\n step,\n hsl: String(state.scale[step] ?? \"\"),\n });\n }\n };\n for (const key of PAGE_EDITOR_SYSTEM_KEYS) push(key, SYSTEM_LABELS[key], brandColor(doc, key), \"#000000\");\n for (const row of libraryRows(doc)) {\n const key = row.key?.trim();\n if (!key) continue;\n push(key, row.label?.trim() || titleCase(key), row, row.hex ?? \"#000000\");\n }\n return swatches;\n}\n\nexport async function themeDocFromRequest(req: {\n payload?: {\n findGlobal?: (args: {\n slug: string;\n depth?: number;\n overrideAccess?: boolean;\n }) => Promise<ThemeDoc | null | undefined>;\n };\n}): Promise<ThemeDoc | null> {\n try {\n const doc = await req.payload?.findGlobal?.({\n slug: THEME_SLUG,\n depth: 0,\n overrideAccess: true,\n });\n return doc ?? null;\n } catch {\n return null;\n }\n}\n","import type { StaticLabel, TextField, TextFieldSingleValidation } from \"payload\";\n\nimport { LOOK_FIELD } from \"./fields\";\nimport { pageEditorLooks, pageEditorTokens, themeDocFromRequest } from \"./looks\";\n\nexport interface LookFieldOptions {\n name?: string;\n label?: StaticLabel;\n required?: boolean;\n admin?: TextField[\"admin\"];\n validate?: TextFieldSingleValidation;\n}\n\nexport type LookFieldMode = \"look\" | \"token\";\n\nexport const validateLook: TextFieldSingleValidation = async (value, { req }) => {\n if (value == null || value === \"\") return true;\n if (typeof value !== \"string\") return \"Pick a look from Theme → Colors\";\n const doc = await themeDocFromRequest(req);\n if (pageEditorLooks(doc).some((look) => look.value === value)) return true;\n return \"Pick a look from Theme → Colors\";\n};\n\nexport const validateColorToken: TextFieldSingleValidation = async (value, { req }) => {\n if (value == null || value === \"\") return true;\n if (typeof value !== \"string\") return \"Pick an included step from Theme → Colors\";\n const doc = await themeDocFromRequest(req);\n if (pageEditorTokens(doc).some((token) => token.value === value)) return true;\n return \"Pick an included step from Theme → Colors\";\n};\n\nfunction pickerField(\n defaults: { name: string; label: string; mode: LookFieldMode; validate: TextFieldSingleValidation },\n overrides: LookFieldOptions,\n): TextField {\n const { name = defaults.name, label = defaults.label, admin, required, validate = defaults.validate } = overrides;\n return {\n name,\n type: \"text\",\n label,\n required,\n validate,\n admin: {\n ...admin,\n components: { Field: LOOK_FIELD, ...admin?.components },\n custom: { mode: defaults.mode, ...admin?.custom },\n },\n };\n}\n\n/**\n * A picker any collection or global can offer. Options come from the\n * published Theme at request time: page-editor system scales plus custom\n * Colors. Payload select options are a static list, so this is a text\n * field with an admin picker — adding Coral does not need a schema change.\n */\nexport function lookField(overrides: LookFieldOptions = {}): TextField {\n return pickerField({ name: \"look\", label: \"Look\", mode: \"look\", validate: validateLook }, overrides);\n}\n\n/**\n * Included steps as `coral-400`. Excluded steps do not appear.\n */\nexport function colorTokenField(overrides: LookFieldOptions = {}): TextField {\n return pickerField(\n { name: \"color\", label: \"Color\", mode: \"token\", validate: validateColorToken },\n overrides,\n );\n}\n","/**\n * Device sizes the Theme (and, later, Pages) live-preview toolbar offers.\n * One list so the panes match.\n */\nexport const THEME_PREVIEW_BREAKPOINTS = [\n { label: \"Mobile\", name: \"mobile\", width: 375, height: 667 },\n { label: \"Tablet\", name: \"tablet\", width: 768, height: 1024 },\n { label: \"Desktop\", name: \"desktop\", width: 1440, height: 900 },\n] as const;\n"],"mappings":";;;;;;;;AASA,SAAgB,cAAc,OAAwC;AACpE,QAAO,MAAM,QAAQ,MAAM,GAAG,QAAQ,EAAE;;AAG1C,MAAM,WAAW,IAAI,IAAY,YAAY;;;;;;AAO7C,SAAgB,kBAAkB,OAAe,SAAiB,OAAuB;AACvF,KAAI,UAAU,QAAS,QAAO;CAC9B,MAAM,OAAO,MAAM,YAAY,IAAI;AACnC,KAAI,QAAQ,EAAG,QAAO;CACtB,MAAM,MAAM,MAAM,MAAM,GAAG,KAAK;CAChC,MAAM,OAAO,OAAO,MAAM,MAAM,OAAO,EAAE,CAAC;AAC1C,KAAI,QAAQ,WAAW,CAAC,SAAS,IAAI,KAAK,CAAE,QAAO;AACnD,QAAO,GAAG,MAAM,GAAG;;AAGrB,SAAgB,eAAe,KAA4C;CACzE,MAAM,SAAS,cAAc,KAAK,QAAQ,QAAQ,CAC/C,KAAK,QAAQ,IAAI,KAAK,MAAM,CAAC,CAC7B,QAAQ,QAAuB,QAAQ,IAAI,CAAC;AAC/C,QAAO,CAAC,GAAG,mBAAmB,GAAG,OAAO;;;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Q;GAClD;EACF;;;;;;;;AASH,SAAgB,UAAU,YAA8B,EAAE,EAAa;AACrE,QAAO,YAAY;EAAE,MAAM;EAAQ,OAAO;EAAQ,MAAM;EAAQ,UAAU;EAAc,EAAE,UAAU;;;;;AAMtG,SAAgB,gBAAgB,YAA8B,EAAE,EAAa;AAC3E,QAAO,YACL;EAAE,MAAM;EAAS,OAAO;EAAS,MAAM;EAAS,UAAU;EAAoB,EAC9E,UACD;;;;;;;;AC/DH,MAAa,4BAA4B;CACvC;EAAE,OAAO;EAAU,MAAM;EAAU,OAAO;EAAK,QAAQ;EAAK;CAC5D;EAAE,OAAO;EAAU,MAAM;EAAU,OAAO;EAAK,QAAQ;EAAM;CAC7D;EAAE,OAAO;EAAW,MAAM;EAAW,OAAO;EAAM,QAAQ;EAAK;CAChE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { d as ThemeDoc, m as ThemeLibraryColorDoc } from "./types-D6jQql5Z.mjs";
|
|
2
|
+
import { ShadeStep } from "@bison-lab/tokens";
|
|
3
|
+
import { StaticLabel, TextField, TextFieldSingleValidation } from "payload";
|
|
4
|
+
|
|
5
|
+
//#region src/theme/library.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Page editors pick `coral-400`, never a raw hex. Rewrite every use of
|
|
8
|
+
* `fromKey` onto `toKey` at the same step: `coral-400` → `highlight-400`.
|
|
9
|
+
* A bare key (`coral`) becomes `toKey`. Anything else is left alone.
|
|
10
|
+
*/
|
|
11
|
+
declare function rewriteColorToken(token: string, fromKey: string, toKey: string): string;
|
|
12
|
+
declare function themeColorKeys(doc: ThemeDoc | null | undefined): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Remove a custom color. Unused: omit `replacement` and the row is gone.
|
|
15
|
+
* In use: pass another system or custom key; the caller rewrites page
|
|
16
|
+
* tokens with `rewriteColorToken`. After this, no library row still
|
|
17
|
+
* has `key`.
|
|
18
|
+
*/
|
|
19
|
+
declare function deleteLibraryColor(doc: ThemeDoc, key: string, replacement?: string): ThemeDoc;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/theme/color-tokens.d.ts
|
|
22
|
+
interface ColorTokenHit {
|
|
23
|
+
path: string;
|
|
24
|
+
token: string;
|
|
25
|
+
}
|
|
26
|
+
declare function findColorTokens(value: unknown, key: string): ColorTokenHit[];
|
|
27
|
+
declare function rewriteColorTokens<T>(value: T, fromKey: string, toKey: string): T;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/theme/look-field.d.ts
|
|
30
|
+
interface LookFieldOptions {
|
|
31
|
+
name?: string;
|
|
32
|
+
label?: StaticLabel;
|
|
33
|
+
required?: boolean;
|
|
34
|
+
admin?: TextField["admin"];
|
|
35
|
+
validate?: TextFieldSingleValidation;
|
|
36
|
+
}
|
|
37
|
+
type LookFieldMode = "look" | "token";
|
|
38
|
+
/**
|
|
39
|
+
* A picker any collection or global can offer. Options come from the
|
|
40
|
+
* published Theme at request time: page-editor system scales plus custom
|
|
41
|
+
* Colors. Payload select options are a static list, so this is a text
|
|
42
|
+
* field with an admin picker — adding Coral does not need a schema change.
|
|
43
|
+
*/
|
|
44
|
+
declare function lookField(overrides?: LookFieldOptions): TextField;
|
|
45
|
+
/**
|
|
46
|
+
* Included steps as `coral-400`. Excluded steps do not appear.
|
|
47
|
+
*/
|
|
48
|
+
declare function colorTokenField(overrides?: LookFieldOptions): TextField;
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/theme/looks.d.ts
|
|
51
|
+
/**
|
|
52
|
+
* System colors Color Settings offers as page-editor fills. Success and
|
|
53
|
+
* Destructive stay off this list — they are theme chrome only.
|
|
54
|
+
*/
|
|
55
|
+
declare const PAGE_EDITOR_SYSTEM_KEYS: readonly ["primary", "secondary", "accent", "highlight"];
|
|
56
|
+
type PageEditorSystemKey = (typeof PAGE_EDITOR_SYSTEM_KEYS)[number];
|
|
57
|
+
interface LookOption {
|
|
58
|
+
label: string;
|
|
59
|
+
value: string;
|
|
60
|
+
}
|
|
61
|
+
declare function themeLibraryFromDoc(doc: ThemeDoc | null | undefined): ThemeLibraryColorDoc[];
|
|
62
|
+
/**
|
|
63
|
+
* Family keys a `lookField()` may offer: the page-editor system scales
|
|
64
|
+
* plus every custom color on Colors. Adding Coral on Theme makes `coral`
|
|
65
|
+
* appear here with no `@bison-lab/*` release.
|
|
66
|
+
*/
|
|
67
|
+
declare function pageEditorLooks(doc: ThemeDoc | null | undefined): LookOption[];
|
|
68
|
+
/**
|
|
69
|
+
* Included steps as `coral-400`. Excluded steps do not appear. System
|
|
70
|
+
* scales with no stored include list offer the full 50–950 ramp.
|
|
71
|
+
*/
|
|
72
|
+
declare function pageEditorTokens(doc: ThemeDoc | null | undefined): LookOption[];
|
|
73
|
+
/** One included step with its stored color, for a picker that draws swatches. */
|
|
74
|
+
interface ColorSwatch extends LookOption {
|
|
75
|
+
/** The family key the token starts with (`primary`, `coral`). */
|
|
76
|
+
family: string;
|
|
77
|
+
/** The family's label (`Primary`, `Coral`). */
|
|
78
|
+
familyLabel: string;
|
|
79
|
+
step: ShadeStep;
|
|
80
|
+
/** The step's HSL triplet (`330 100% 43%`), the value its CSS variable holds. */
|
|
81
|
+
hsl: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* `pageEditorTokens` with each step's stored color, grouped by family in
|
|
85
|
+
* the same order, so an admin picker can paint a swatch without the site's
|
|
86
|
+
* Theme stylesheet.
|
|
87
|
+
*/
|
|
88
|
+
declare function pageEditorSwatches(doc: ThemeDoc | null | undefined): ColorSwatch[];
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/theme/preview.d.ts
|
|
91
|
+
/**
|
|
92
|
+
* Device sizes the Theme (and, later, Pages) live-preview toolbar offers.
|
|
93
|
+
* One list so the panes match.
|
|
94
|
+
*/
|
|
95
|
+
declare const THEME_PREVIEW_BREAKPOINTS: readonly [{
|
|
96
|
+
readonly label: "Mobile";
|
|
97
|
+
readonly name: "mobile";
|
|
98
|
+
readonly width: 375;
|
|
99
|
+
readonly height: 667;
|
|
100
|
+
}, {
|
|
101
|
+
readonly label: "Tablet";
|
|
102
|
+
readonly name: "tablet";
|
|
103
|
+
readonly width: 768;
|
|
104
|
+
readonly height: 1024;
|
|
105
|
+
}, {
|
|
106
|
+
readonly label: "Desktop";
|
|
107
|
+
readonly name: "desktop";
|
|
108
|
+
readonly width: 1440;
|
|
109
|
+
readonly height: 900;
|
|
110
|
+
}];
|
|
111
|
+
//#endregion
|
|
112
|
+
export { deleteLibraryColor as _, PageEditorSystemKey as a, pageEditorTokens as c, LookFieldOptions as d, colorTokenField as f, rewriteColorTokens as g, findColorTokens as h, PAGE_EDITOR_SYSTEM_KEYS as i, themeLibraryFromDoc as l, ColorTokenHit as m, ColorSwatch as n, pageEditorLooks as o, lookField as p, LookOption as r, pageEditorSwatches as s, THEME_PREVIEW_BREAKPOINTS as t, LookFieldMode as u, rewriteColorToken as v, themeColorKeys as y };
|
|
113
|
+
//# sourceMappingURL=preview-Cgbh9eAq.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-Cgbh9eAq.d.mts","names":[],"sources":["../src/theme/library.ts","../src/theme/color-tokens.ts","../src/theme/look-field.ts","../src/theme/looks.ts","../src/theme/preview.ts"],"mappings":";;;;;;;;;;iBAoBgB,iBAAA,CAAkB,KAAA,UAAe,OAAA,UAAiB,KAAA;AAAA,iBAUlD,cAAA,CAAe,GAAA,EAAK,QAAA;AAApC;;;;;AAaA;AAbA,iBAagB,kBAAA,CAAmB,GAAA,EAAK,QAAA,EAAU,GAAA,UAAa,WAAA,YAAuB,QAAA;;;UCzCrE,aAAA;EACf,IAAA;EACA,KAAA;AAAA;AAAA,iBAWc,eAAA,CAAgB,KAAA,WAAgB,GAAA,WAAc,aAAA;AAAA,iBAQ9C,kBAAA,GAAA,CAAsB,KAAA,EAAO,CAAA,EAAG,OAAA,UAAiB,KAAA,WAAgB,CAAA;;;UClBhE,gBAAA;EACf,IAAA;EACA,KAAA,GAAQ,WAAA;EACR,QAAA;EACA,KAAA,GAAQ,SAAA;EACR,QAAA,GAAW,yBAAA;AAAA;AAAA,KAGD,aAAA;;;;AFiBZ;;;iBE0BgB,SAAA,CAAU,SAAA,GAAW,gBAAA,GAAwB,SAAA;;AFb7D;;iBEoBgB,eAAA,CAAgB,SAAA,GAAW,gBAAA,GAAwB,SAAA;;;;;;AF3CnE;cGXa,uBAAA;AAAA,KAED,mBAAA,WAA8B,uBAAA;AAAA,UAEzB,UAAA;EACf,KAAA;EACA,KAAA;AAAA;AAAA,iBAiBc,mBAAA,CAAoB,GAAA,EAAK,QAAA,sBAA8B,oBAAA;;AHFvE;;;;iBGuBgB,eAAA,CAAgB,GAAA,EAAK,QAAA,sBAA8B,UAAA;AHVnE;;;;AAAA,iBG6BgB,gBAAA,CAAiB,GAAA,EAAK,QAAA,sBAA8B,UAAA;;UAoBnD,WAAA,SAAoB,UAAA;EHjD0B;EGmD7D,MAAA;EHnD4F;EGqD5F,WAAA;EACA,IAAA,EAAM,SAAA;;EAEN,GAAA;AAAA;;;;;AFpFF;iBE4FgB,kBAAA,CAAmB,GAAA,EAAK,QAAA,sBAA8B,WAAA;;;;;;;cCvGzD,yBAAA;EAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { _ as ThemeIdentityFallback, d as ThemeDoc, g as ResolvedThemeIdentity } from "./types-D6jQql5Z.mjs";
|
|
2
|
+
import { ThemeConfig } from "@bison-lab/tokens";
|
|
3
|
+
|
|
4
|
+
//#region src/theme/published.d.ts
|
|
5
|
+
interface ThemePayload {
|
|
6
|
+
findGlobal: (args: {
|
|
7
|
+
slug: string;
|
|
8
|
+
draft?: boolean;
|
|
9
|
+
depth?: number;
|
|
10
|
+
overrideAccess?: boolean;
|
|
11
|
+
}) => Promise<ThemeDoc | null | undefined>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The Theme row, or `seed` when the Global is empty. Theme has no draft
|
|
15
|
+
* mode: `draft: false` is the live document. Access is overridden so a
|
|
16
|
+
* logged-out request still gets the colours.
|
|
17
|
+
*/
|
|
18
|
+
declare function getPublishedTheme(payload: ThemePayload, seed: ThemeConfig): Promise<ThemeConfig>;
|
|
19
|
+
/**
|
|
20
|
+
* Uploaded logo, favicon, and mobile-menu mark, or the fallback the site
|
|
21
|
+
* passed into `createTheme`. Depth 1 so the upload url is populated.
|
|
22
|
+
*/
|
|
23
|
+
declare function getPublishedIdentity(payload: ThemePayload, fallback?: ThemeIdentityFallback): Promise<ResolvedThemeIdentity>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { getPublishedIdentity as n, getPublishedTheme as r, ThemePayload as t };
|
|
26
|
+
//# sourceMappingURL=published-BLXCep6Z.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"published-BLXCep6Z.d.mts","names":[],"sources":["../src/theme/published.ts"],"mappings":";;;;UAOiB,YAAA;EACf,UAAA,GAAa,IAAA;IACX,IAAA;IACA,KAAA;IACA,KAAA;IACA,cAAA;EAAA,MACI,OAAA,CAAQ,QAAA;AAAA;;;;;;iBAQM,iBAAA,CAAkB,OAAA,EAAS,YAAA,EAAc,IAAA,EAAM,WAAA,GAAc,OAAA,CAAQ,WAAA;;AAA3F;;;iBAcsB,oBAAA,CACpB,OAAA,EAAS,YAAA,EACT,QAAA,GAAW,qBAAA,GACV,OAAA,CAAQ,qBAAA"}
|
|
@@ -417,4 +417,4 @@ async function getNavigation({ payload, draft = false }) {
|
|
|
417
417
|
//#endregion
|
|
418
418
|
export { NAVIGATION_SLUG as C, NAVIGATION_FOOTER_SLUG as S, validateExternalHref as _, FOOTER_MAX_LINK_COLUMNS as a, NAVIGATION_FEATURE as b, footerDesktopTracks as c, validateFooterColumns as d, validateFooterSocialUrl as f, linkField as g, isValidExternalHref as h, FOOTER_MAX_COLUMNS as i, footerFields as l, headerCtaEnabled as m, FOOTER_COLUMNS_FIELD as n, FOOTER_SOCIALS as o, EXTERNAL_HREF_MESSAGE as p, FOOTER_COLUMN_WIDTHS as r, FOOTER_TWELFTHS as s, getNavigation as t, normalizeFooterDesktop as u, validateHeaderCta as v, NAVIGATION_FOOTER_DB_NAME as x, NAVIGATION_DB_NAME as y };
|
|
419
419
|
|
|
420
|
-
//# sourceMappingURL=published-
|
|
420
|
+
//# sourceMappingURL=published-CEuK5ym6.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"published-CcW9bqLJ.mjs","names":[],"sources":["../src/navigation/types.ts","../src/navigation/link.ts","../src/navigation/footer.ts","../src/navigation/published.ts"],"sourcesContent":["/**\n * Public Header and Footer as two Globals so each has its own Save /\n * Publish / drafts. Bar behaviour (`bar` on Header) stays in the schema\n * with `admin.hidden`; it is not a Settings tab. Featured looks stay on\n * chrome roles (BIS-85 / SPI-89), not a Header array. The items kit\n * editor is the workspace field (BIS-119 / BIS-121). Payload's left nav\n * stays until BIS-90. The Spinal bump is SPI-99.\n */\n\nimport type { Block, GlobalConfig } from \"payload\";\n\nexport const NAVIGATION_SLUG = \"navigation\";\nexport const NAVIGATION_DB_NAME = \"nav\";\nexport const NAVIGATION_FOOTER_SLUG = \"navigation-footer\";\nexport const NAVIGATION_FOOTER_DB_NAME = \"navf\";\n\nexport const NAVIGATION_FEATURE = \"navigation\";\n\nexport interface CreateNavigationOptions {\n /**\n * Header bar blocks this site offers. The field stays a blocks array —\n * a later nav block is appended here, not a mega-menu-only shape.\n */\n blocks: Block[];\n /**\n * Preview URL for both documents. The site owns the path — this factory\n * does not invent a route.\n */\n preview?: NonNullable<NonNullable<GlobalConfig[\"admin\"]>[\"preview\"]>;\n livePreview?: NonNullable<NonNullable<GlobalConfig[\"admin\"]>[\"livePreview\"]>;\n /**\n * Component path for Payload's Preview button, as a key into the site's\n * committed `importMap.js`.\n */\n previewButton?: string;\n /** The collection a page link points into. Defaults to `pages`. */\n pagesCollection?: string;\n /** Locked footer copyright uses this name. The year stays the current year. */\n footerCopyrightName?: string;\n}\n\nexport interface NavigationHeader {\n items?: unknown;\n cta?: unknown;\n}\n\nexport interface NavigationBar {\n hideOnScroll?: boolean | null;\n viewport?: boolean | null;\n defaultMaxWidth?: (\"narrow\" | \"standard\" | \"wide\") | null;\n}\n\nexport interface NavigationFooter {\n columns?: unknown;\n brand?: unknown;\n}\n\nexport interface NavigationDoc {\n header: NavigationHeader;\n footer: NavigationFooter;\n bar: NavigationBar;\n}\n\nexport interface GetNavigationArgs {\n payload: {\n findGlobal: (args: {\n slug: string;\n draft?: boolean;\n overrideAccess?: boolean;\n depth?: number;\n }) => Promise<unknown>;\n };\n draft?: boolean;\n}\n","import type { Condition, Field, GroupField, RowField, TextFieldSingleValidation } from \"payload\";\n\n/**\n * Same import-map string as `@bison-lab/payload-blocks`. A site that\n * already generates the blocks admin map gets the picker; a missing\n * entry renders the row as nothing, so `payload generate:importmap` is\n * part of adopting this factory.\n */\nconst LINK_FIELD = \"@bison-lab/payload-blocks/admin#LinkField\";\n\ntype LinkType = \"page\" | \"external\";\n\ninterface LinkDestination {\n type?: LinkType | null;\n href?: string | null;\n}\n\nfunction linkTypeOf(link: LinkDestination | null | undefined): LinkType {\n if (link?.type === \"external\") return \"external\";\n if (link?.type === \"page\") return \"page\";\n return link?.href ? \"external\" : \"page\";\n}\n\nexport const EXTERNAL_HREF_MESSAGE =\n \"Enter a valid URL (https://…), a mailto: or tel: link, or a site path starting with /.\";\n\n/**\n * What the picker will store as an external destination: http(s) with a\n * host, mailto:/tel: with a value, or an in-site path. Rejects a bare\n * host, protocol-relative URLs, and anything that is not a link.\n */\nexport function isValidExternalHref(value: unknown): boolean {\n const raw = String(value ?? \"\").trim();\n if (!raw || /\\s/.test(raw)) return false;\n if (raw.startsWith(\"/\") && !raw.startsWith(\"//\")) return true;\n if (/^mailto:/i.test(raw)) return raw.length > \"mailto:\".length;\n if (/^tel:/i.test(raw)) return raw.length > \"tel:\".length;\n try {\n const url = new URL(raw);\n return (url.protocol === \"http:\" || url.protocol === \"https:\") && Boolean(url.hostname);\n } catch {\n return false;\n }\n}\n\nexport function validateExternalHref(value: unknown, required = false): true | string {\n const raw = String(value ?? \"\").trim();\n if (!raw) return required ? \"This field is required.\" : true;\n return isValidExternalHref(raw) ? true : EXTERNAL_HREF_MESSAGE;\n}\n\nconst whenPage: Condition = (_data, siblingData) => linkTypeOf(siblingData as LinkDestination) === \"page\";\nconst whenExternal: Condition = (_data, siblingData) =>\n linkTypeOf(siblingData as LinkDestination) === \"external\";\n\nfunction hrefValidate(required: boolean): TextFieldSingleValidation {\n return (value, { siblingData }) => {\n if (linkTypeOf(siblingData as LinkDestination) !== \"external\") return true;\n return validateExternalHref(value, required);\n };\n}\n\nfunction linkDestinationFields({\n required = false,\n pagesCollection = \"pages\",\n}: {\n required?: boolean;\n pagesCollection?: string;\n} = {}): RowField[] {\n return [\n {\n type: \"row\",\n admin: { components: { Field: LINK_FIELD } },\n fields: [\n {\n name: \"type\",\n type: \"radio\",\n label: \"Link\",\n defaultValue: \"page\",\n options: [\n { label: \"Page\", value: \"page\" },\n { label: \"URL\", value: \"external\" },\n ],\n admin: { layout: \"horizontal\" },\n },\n {\n name: \"page\",\n type: \"relationship\",\n relationTo: pagesCollection,\n required,\n filterOptions: { _status: { equals: \"published\" } },\n admin: { condition: whenPage },\n },\n {\n name: \"href\",\n type: \"text\",\n label: \"URL\",\n required,\n validate: hrefValidate(required),\n admin: {\n condition: whenExternal,\n description:\n 'A full URL (\"https://example.com\"), \"mailto:\" or \"tel:\", or a site path (\"/contact\").',\n },\n },\n ],\n },\n ];\n}\n\nfunction linkFields({\n required = false,\n pagesCollection,\n}: {\n required?: boolean;\n pagesCollection?: string;\n} = {}): Field[] {\n return [\n ...linkDestinationFields({ required, pagesCollection }),\n { name: \"label\", type: \"text\", label: \"Label\", required },\n {\n name: \"newTab\",\n type: \"checkbox\",\n label: \"Open in a new tab\",\n defaultValue: false,\n admin: {\n // Drawn by LinkField next to the destination so Header, Footer, and\n // page blocks cannot drift apart.\n hidden: true,\n },\n },\n ];\n}\n\nexport interface HeaderCtaValue {\n enabled?: boolean | null;\n type?: LinkType | null;\n page?: unknown;\n href?: string | null;\n label?: string | null;\n}\n\n/** A stored button, or a legacy row that already has a label or destination. */\nexport function headerCtaEnabled(cta: HeaderCtaValue | null | undefined): boolean {\n if (!cta) return false;\n if (cta.enabled === false) return false;\n if (cta.enabled === true) return true;\n return Boolean(cta.label || cta.page || cta.href);\n}\n\n/**\n * When the Header button is on, label and destination are required.\n * Off (or a cleared row) can save empty.\n */\nexport function validateHeaderCta(value: unknown): true | string {\n const cta = (value && typeof value === \"object\" ? value : {}) as HeaderCtaValue;\n if (!headerCtaEnabled(cta)) return true;\n if (!String(cta.label ?? \"\").trim()) return \"The Header button needs a label.\";\n const dest = linkTypeOf(cta);\n if (dest === \"external\") {\n const href = validateExternalHref(cta.href, true);\n if (href !== true) {\n return href === \"This field is required.\"\n ? \"The Header button needs a published page or a URL.\"\n : href;\n }\n }\n if (dest === \"page\" && (cta.page == null || cta.page === \"\")) {\n return \"The Header button needs a published page or a URL.\";\n }\n return true;\n}\n\nexport function linkField({\n name = \"link\",\n label,\n admin,\n required,\n pagesCollection,\n toggle,\n}: {\n name?: string;\n label?: GroupField[\"label\"];\n admin?: GroupField[\"admin\"];\n required?: boolean;\n pagesCollection?: string;\n /** Header button: an enable checkbox; children are not required unless it is on. */\n toggle?: boolean;\n} = {}): GroupField {\n return {\n name,\n type: \"group\",\n fields: toggle\n ? [\n {\n name: \"enabled\",\n type: \"checkbox\",\n label: \"Show Header button\",\n defaultValue: false,\n },\n ...linkFields({ required: false, pagesCollection }),\n ]\n : linkFields({ required, pagesCollection }),\n ...(toggle ? { validate: validateHeaderCta as NonNullable<GroupField[\"validate\"]> } : {}),\n ...(label === undefined ? {} : { label }),\n ...(admin === undefined ? {} : { admin }),\n };\n}\n\nexport function footerLinkFields({\n required = false,\n pagesCollection,\n}: {\n required?: boolean;\n pagesCollection?: string;\n} = {}): Field[] {\n return linkFields({ required, pagesCollection });\n}\n","import type { ArrayField, ArrayFieldValidation, Field, GroupField, TextField } from \"payload\";\n\nimport { footerLinkFields, isValidExternalHref, validateExternalHref } from \"./link\";\n\n/**\n * Same presets as the header mega-menu. Desktop only. Tablet is a fixed\n * 2×2 on the public footer; mobile stacks.\n */\nexport const FOOTER_COLUMN_WIDTHS = [\"25\", \"33\", \"50\", \"66\", \"75\", \"100\"] as const;\nexport type FooterColumnWidth = (typeof FOOTER_COLUMN_WIDTHS)[number];\n\n/** Logo column plus link columns. */\nexport const FOOTER_MAX_COLUMNS = 4;\n/** Link columns. The logo column is always first and is not in this count. */\nexport const FOOTER_MAX_LINK_COLUMNS = FOOTER_MAX_COLUMNS - 1;\n\nexport const FOOTER_SOCIALS = [\"facebook\", \"instagram\", \"linkedin\", \"x\", \"youtube\"] as const;\nexport type FooterSocial = (typeof FOOTER_SOCIALS)[number];\n\nconst FOOTER_SOCIAL_LABELS: Record<FooterSocial, string> = {\n facebook: \"Facebook\",\n instagram: \"Instagram\",\n linkedin: \"LinkedIn\",\n x: \"X\",\n youtube: \"YouTube\",\n};\n\n/** Twelfths of a row. Link-column widths share this 12; the logo column does not. */\nexport const FOOTER_TWELFTHS: Record<FooterColumnWidth, number> = {\n \"25\": 3,\n \"33\": 4,\n \"50\": 6,\n \"66\": 8,\n \"75\": 9,\n \"100\": 12,\n};\n\nexport const FOOTER_COLUMNS_FIELD = \"@bison-lab/payload-blocks/admin#FooterColumnsField\";\n\ninterface FooterLinkRow {\n label?: string | null;\n type?: \"page\" | \"external\" | null;\n page?: unknown;\n href?: string | null;\n}\n\ninterface FooterSectionRow {\n heading?: string | null;\n links?: FooterLinkRow[] | null;\n}\n\ninterface FooterColumnRow {\n desktop?: FooterColumnWidth | null;\n sections?: FooterSectionRow[] | null;\n}\n\nfunction evenDesktop(count: number): FooterColumnWidth[] {\n return (\n {\n 1: [\"100\"],\n 2: [\"50\", \"50\"],\n 3: [\"33\", \"33\", \"33\"],\n 4: [\"25\", \"25\", \"25\", \"25\"],\n } as Record<number, FooterColumnWidth[]>\n )[count] ?? [];\n}\n\n/** Even split for the current link-column count. Used by the kit editor. */\nexport function normalizeFooterDesktop(count: number): FooterColumnWidth[] {\n return evenDesktop(count);\n}\n\n/**\n * Desktop tracks: the logo keeps its own percent; link columns share the\n * remaining `1fr` and are themselves percent of that leftover, not of the\n * full footer.\n */\nexport function footerDesktopTracks(\n brand: FooterColumnWidth | null | undefined,\n columns: Array<FooterColumnWidth | null | undefined>,\n): {\n brandPercent: string;\n brandTemplate: string;\n linksTemplate: string;\n} {\n const width = brand && brand in FOOTER_TWELFTHS ? brand : \"25\";\n const brandPercent = `${width}%`;\n const links = columns.map((column) => `${column && column in FOOTER_TWELFTHS ? column : \"25\"}%`);\n return {\n brandPercent,\n brandTemplate: `${brandPercent} minmax(0,1fr)`,\n linksTemplate: links.join(\" \") || \"1fr\",\n };\n}\n\nfunction linkHasDestination(link: FooterLinkRow): boolean {\n if (link.type === \"external\") return isValidExternalHref(link.href);\n if (link.type === \"page\") return link.page != null && link.page !== \"\";\n if (String(link.href ?? \"\").trim()) return isValidExternalHref(link.href);\n return link.page != null && link.page !== \"\";\n}\n\n/**\n * Link-column widths must add to 100% of the space beside the logo. The\n * logo width is independent. Each section needs a labeled destination\n * before publish. Draft saves skip field validation. A footer with only\n * the logo column is valid.\n */\nexport const validateFooterColumns: ArrayFieldValidation = (value) => {\n const columns = (Array.isArray(value) ? value : []) as FooterColumnRow[];\n if (columns.length > FOOTER_MAX_LINK_COLUMNS) {\n return \"No more than three link columns. The logo column is always first.\";\n }\n\n if (columns.length === 0) return true;\n\n const twelfths = columns.reduce((sum, row) => sum + FOOTER_TWELFTHS[row?.desktop ?? \"100\"], 0);\n if (twelfths !== 12) {\n const percent = Math.round((twelfths / 12) * 100);\n return `Desktop column widths add up to ${percent}%. They need to add up to 100% of the space beside the logo.`;\n }\n\n for (const [columnIndex, column] of columns.entries()) {\n const sections = column.sections ?? [];\n if (sections.length === 0) {\n return `Column ${columnIndex + 1} needs at least one section.`;\n }\n for (const [sectionIndex, section] of sections.entries()) {\n if (!String(section.heading ?? \"\").trim()) {\n return `Column ${columnIndex + 1}, section ${sectionIndex + 1} needs a section label.`;\n }\n const links = section.links ?? [];\n if (links.length === 0) {\n return `Column ${columnIndex + 1}, section ${sectionIndex + 1} needs at least one link.`;\n }\n for (const [linkIndex, link] of links.entries()) {\n if (!String(link.label ?? \"\").trim()) {\n return `Column ${columnIndex + 1}, section ${sectionIndex + 1}, link ${linkIndex + 1} needs a label.`;\n }\n if (!linkHasDestination(link)) {\n const href = String(link.href ?? \"\").trim();\n if (href && validateExternalHref(href) !== true) {\n return `Column ${columnIndex + 1}, section ${sectionIndex + 1}, link ${linkIndex + 1} needs a valid URL.`;\n }\n return `Column ${columnIndex + 1}, section ${sectionIndex + 1}, link ${linkIndex + 1} needs a destination.`;\n }\n }\n }\n }\n\n return true;\n};\n\nexport function validateFooterSocialUrl(value: unknown): true | string {\n const raw = String(value ?? \"\").trim();\n if (!raw) return true;\n try {\n const url = new URL(raw);\n if (url.protocol === \"http:\" || url.protocol === \"https:\") return true;\n } catch {\n // not a URL\n }\n return \"Must be a valid http(s) URL.\";\n}\n\nfunction socialFields(): TextField[] {\n return FOOTER_SOCIALS.map((name) => ({\n name,\n type: \"text\",\n label: FOOTER_SOCIAL_LABELS[name],\n validate: validateFooterSocialUrl,\n }));\n}\n\nexport function footerColumnsField({\n pagesCollection,\n}: {\n pagesCollection?: string;\n} = {}): ArrayField {\n return {\n name: \"columns\",\n type: \"array\",\n dbName: \"c\",\n labels: { singular: \"Column\", plural: \"Columns\" },\n maxRows: FOOTER_MAX_LINK_COLUMNS,\n validate: validateFooterColumns,\n admin: {\n description:\n \"Logo column plus up to three link columns. Link-column widths add up to 100% of the space beside the logo.\",\n },\n fields: [\n {\n name: \"desktop\",\n type: \"select\",\n label: \"Desktop width\",\n defaultValue: \"25\",\n required: true,\n options: FOOTER_COLUMN_WIDTHS.map((value) => ({ label: `${value}%`, value })),\n },\n {\n name: \"sections\",\n type: \"array\",\n dbName: \"s\",\n labels: { singular: \"Section\", plural: \"Sections\" },\n minRows: 1,\n fields: [\n {\n name: \"heading\",\n type: \"text\",\n label: \"Section Label\",\n required: true,\n },\n {\n name: \"links\",\n type: \"array\",\n labels: { singular: \"Link\", plural: \"Links\" },\n minRows: 1,\n fields: footerLinkFields({ required: true, pagesCollection }),\n },\n ],\n },\n ],\n };\n}\n\nexport function footerBrandField(): GroupField {\n return {\n name: \"brand\",\n type: \"group\",\n label: \"Brand & social\",\n fields: [\n {\n name: \"desktop\",\n type: \"select\",\n label: \"Desktop width\",\n defaultValue: \"25\",\n required: true,\n options: FOOTER_COLUMN_WIDTHS.map((value) => ({ label: `${value}%`, value })),\n },\n {\n name: \"tagline\",\n type: \"textarea\",\n label: \"Text below the logo\",\n },\n ...socialFields(),\n ],\n };\n}\n\nexport function footerFields(options: { pagesCollection?: string } = {}): Field[] {\n return [footerColumnsField(options), footerBrandField()];\n}\n","import {\n NAVIGATION_FOOTER_SLUG,\n NAVIGATION_SLUG,\n type GetNavigationArgs,\n type NavigationBar,\n type NavigationDoc,\n type NavigationFooter,\n type NavigationHeader,\n} from \"./types\";\n\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n return value && typeof value === \"object\" ? (value as Record<string, unknown>) : null;\n}\n\nfunction headerOf(doc: unknown): NavigationHeader {\n const record = asRecord(doc);\n const header = record && \"header\" in record ? asRecord(record.header) : null;\n return header ?? {};\n}\n\nfunction footerOf(doc: unknown): NavigationFooter {\n const record = asRecord(doc);\n const footer = record && \"footer\" in record ? asRecord(record.footer) : null;\n return footer ?? {};\n}\n\nfunction barOf(doc: unknown): NavigationBar {\n const record = asRecord(doc);\n const bar = record && \"bar\" in record ? asRecord(record.bar) : null;\n return bar ?? {};\n}\n\n/**\n * Reads Header and Footer and returns one `{ header, footer, bar }`. A\n * site header does not learn two slugs. `bar` is the hidden Header group\n * (hide on scroll, viewport, default panel width). `draft: true`\n * reads the newest version; omit it (or pass false) for the published\n * documents.\n */\nexport async function getNavigation({ payload, draft = false }: GetNavigationArgs): Promise<NavigationDoc> {\n const [headerDoc, footerDoc] = await Promise.all([\n payload.findGlobal({ slug: NAVIGATION_SLUG, draft, depth: 1 }),\n payload.findGlobal({ slug: NAVIGATION_FOOTER_SLUG, draft, depth: 1 }),\n ]);\n return { header: headerOf(headerDoc), footer: footerOf(footerDoc), bar: barOf(headerDoc) };\n}\n"],"mappings":";AAWA,MAAa,kBAAkB;AAC/B,MAAa,qBAAqB;AAClC,MAAa,yBAAyB;AACtC,MAAa,4BAA4B;AAEzC,MAAa,qBAAqB;;;;;;;;;ACRlC,MAAM,aAAa;AASnB,SAAS,WAAW,MAAoD;AACtE,KAAI,MAAM,SAAS,WAAY,QAAO;AACtC,KAAI,MAAM,SAAS,OAAQ,QAAO;AAClC,QAAO,MAAM,OAAO,aAAa;;AAGnC,MAAa,wBACX;;;;;;AAOF,SAAgB,oBAAoB,OAAyB;CAC3D,MAAM,MAAM,OAAO,SAAS,GAAG,CAAC,MAAM;AACtC,KAAI,CAAC,OAAO,KAAK,KAAK,IAAI,CAAE,QAAO;AACnC,KAAI,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,WAAW,KAAK,CAAE,QAAO;AACzD,KAAI,YAAY,KAAK,IAAI,CAAE,QAAO,IAAI,SAAS;AAC/C,KAAI,SAAS,KAAK,IAAI,CAAE,QAAO,IAAI,SAAS;AAC5C,KAAI;EACF,MAAM,MAAM,IAAI,IAAI,IAAI;AACxB,UAAQ,IAAI,aAAa,WAAW,IAAI,aAAa,aAAa,QAAQ,IAAI,SAAS;SACjF;AACN,SAAO;;;AAIX,SAAgB,qBAAqB,OAAgB,WAAW,OAAsB;CACpF,MAAM,MAAM,OAAO,SAAS,GAAG,CAAC,MAAM;AACtC,KAAI,CAAC,IAAK,QAAO,WAAW,4BAA4B;AACxD,QAAO,oBAAoB,IAAI,GAAG,OAAO;;AAG3C,MAAM,YAAuB,OAAO,gBAAgB,WAAW,YAA+B,K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C;CAChD,MAAM,SAAS,SAAS,IAAI;AAE5B,SADe,UAAU,YAAY,SAAS,SAAS,OAAO,OAAO,GAAG,SACvD,EAAE;;AAGrB,SAAS,MAAM,KAA6B;CAC1C,MAAM,SAAS,SAAS,IAAI;AAE5B,SADY,UAAU,SAAS,SAAS,SAAS,OAAO,IAAI,GAAG,SACjD,EAAE;;;;;;;;;AAUlB,eAAsB,cAAc,EAAE,SAAS,QAAQ,SAAoD;CACzG,MAAM,CAAC,WAAW,aAAa,MAAM,QAAQ,IAAI,CAC/C,QAAQ,WAAW;EAAE,MAAM;EAAiB;EAAO,OAAO;EAAG,CAAC,EAC9D,QAAQ,WAAW;EAAE,MAAM;EAAwB;EAAO,OAAO;EAAG,CAAC,CACtE,CAAC;AACF,QAAO;EAAE,QAAQ,SAAS,UAAU;EAAE,QAAQ,SAAS,UAAU;EAAE,KAAK,MAAM,UAAU;EAAE"}
|
|
1
|
+
{"version":3,"file":"published-CEuK5ym6.mjs","names":[],"sources":["../src/navigation/types.ts","../src/navigation/link.ts","../src/navigation/footer.ts","../src/navigation/published.ts"],"sourcesContent":["/**\n * Public Header and Footer as two Globals so each has its own Save /\n * Publish / drafts. Bar behaviour (`bar` on Header) stays in the schema\n * with `admin.hidden`; it is not a Settings tab. Featured looks stay on\n * chrome roles (BIS-85 / SPI-89), not a Header array. The items kit\n * editor is the workspace field (BIS-119 / BIS-121). Payload's left nav\n * stays until BIS-90. The Spinal bump is SPI-99.\n */\n\nimport type { Block, GlobalConfig } from \"payload\";\n\nexport const NAVIGATION_SLUG = \"navigation\";\nexport const NAVIGATION_DB_NAME = \"nav\";\nexport const NAVIGATION_FOOTER_SLUG = \"navigation-footer\";\nexport const NAVIGATION_FOOTER_DB_NAME = \"navf\";\n\nexport const NAVIGATION_FEATURE = \"navigation\";\n\nexport interface CreateNavigationOptions {\n /**\n * Header bar blocks this site offers. The field stays a blocks array —\n * a later nav block is appended here, not a mega-menu-only shape.\n */\n blocks: Block[];\n /**\n * Preview URL for both documents. The site owns the path — this factory\n * does not invent a route.\n */\n preview?: NonNullable<NonNullable<GlobalConfig[\"admin\"]>[\"preview\"]>;\n livePreview?: NonNullable<NonNullable<GlobalConfig[\"admin\"]>[\"livePreview\"]>;\n /**\n * Component path for Payload's Preview button, as a key into the site's\n * committed `importMap.js`.\n */\n previewButton?: string;\n /** The collection a page link points into. Defaults to `pages`. */\n pagesCollection?: string;\n /** Locked footer copyright uses this name. The year stays the current year. */\n footerCopyrightName?: string;\n}\n\nexport interface NavigationHeader {\n items?: unknown;\n cta?: unknown;\n}\n\nexport interface NavigationBar {\n hideOnScroll?: boolean | null;\n viewport?: boolean | null;\n defaultMaxWidth?: (\"narrow\" | \"standard\" | \"wide\") | null;\n}\n\nexport interface NavigationFooter {\n columns?: unknown;\n brand?: unknown;\n}\n\nexport interface NavigationDoc {\n header: NavigationHeader;\n footer: NavigationFooter;\n bar: NavigationBar;\n}\n\nexport interface GetNavigationArgs {\n payload: {\n findGlobal: (args: {\n slug: string;\n draft?: boolean;\n overrideAccess?: boolean;\n depth?: number;\n }) => Promise<unknown>;\n };\n draft?: boolean;\n}\n","import type { Condition, Field, GroupField, RowField, TextFieldSingleValidation } from \"payload\";\n\n/**\n * Same import-map string as `@bison-lab/payload-blocks`. A site that\n * already generates the blocks admin map gets the picker; a missing\n * entry renders the row as nothing, so `payload generate:importmap` is\n * part of adopting this factory.\n */\nconst LINK_FIELD = \"@bison-lab/payload-blocks/admin#LinkField\";\n\ntype LinkType = \"page\" | \"external\";\n\ninterface LinkDestination {\n type?: LinkType | null;\n href?: string | null;\n}\n\nfunction linkTypeOf(link: LinkDestination | null | undefined): LinkType {\n if (link?.type === \"external\") return \"external\";\n if (link?.type === \"page\") return \"page\";\n return link?.href ? \"external\" : \"page\";\n}\n\nexport const EXTERNAL_HREF_MESSAGE =\n \"Enter a valid URL (https://…), a mailto: or tel: link, or a site path starting with /.\";\n\n/**\n * What the picker will store as an external destination: http(s) with a\n * host, mailto:/tel: with a value, or an in-site path. Rejects a bare\n * host, protocol-relative URLs, and anything that is not a link.\n */\nexport function isValidExternalHref(value: unknown): boolean {\n const raw = String(value ?? \"\").trim();\n if (!raw || /\\s/.test(raw)) return false;\n if (raw.startsWith(\"/\") && !raw.startsWith(\"//\")) return true;\n if (/^mailto:/i.test(raw)) return raw.length > \"mailto:\".length;\n if (/^tel:/i.test(raw)) return raw.length > \"tel:\".length;\n try {\n const url = new URL(raw);\n return (url.protocol === \"http:\" || url.protocol === \"https:\") && Boolean(url.hostname);\n } catch {\n return false;\n }\n}\n\nexport function validateExternalHref(value: unknown, required = false): true | string {\n const raw = String(value ?? \"\").trim();\n if (!raw) return required ? \"This field is required.\" : true;\n return isValidExternalHref(raw) ? true : EXTERNAL_HREF_MESSAGE;\n}\n\nconst whenPage: Condition = (_data, siblingData) => linkTypeOf(siblingData as LinkDestination) === \"page\";\nconst whenExternal: Condition = (_data, siblingData) =>\n linkTypeOf(siblingData as LinkDestination) === \"external\";\n\nfunction hrefValidate(required: boolean): TextFieldSingleValidation {\n return (value, { siblingData }) => {\n if (linkTypeOf(siblingData as LinkDestination) !== \"external\") return true;\n return validateExternalHref(value, required);\n };\n}\n\nfunction linkDestinationFields({\n required = false,\n pagesCollection = \"pages\",\n}: {\n required?: boolean;\n pagesCollection?: string;\n} = {}): RowField[] {\n return [\n {\n type: \"row\",\n admin: { components: { Field: LINK_FIELD } },\n fields: [\n {\n name: \"type\",\n type: \"radio\",\n label: \"Link\",\n defaultValue: \"page\",\n options: [\n { label: \"Page\", value: \"page\" },\n { label: \"URL\", value: \"external\" },\n ],\n admin: { layout: \"horizontal\" },\n },\n {\n name: \"page\",\n type: \"relationship\",\n relationTo: pagesCollection,\n required,\n filterOptions: { _status: { equals: \"published\" } },\n admin: { condition: whenPage },\n },\n {\n name: \"href\",\n type: \"text\",\n label: \"URL\",\n required,\n validate: hrefValidate(required),\n admin: {\n condition: whenExternal,\n description:\n 'A full URL (\"https://example.com\"), \"mailto:\" or \"tel:\", or a site path (\"/contact\").',\n },\n },\n ],\n },\n ];\n}\n\nfunction linkFields({\n required = false,\n pagesCollection,\n}: {\n required?: boolean;\n pagesCollection?: string;\n} = {}): Field[] {\n return [\n ...linkDestinationFields({ required, pagesCollection }),\n { name: \"label\", type: \"text\", label: \"Label\", required },\n {\n name: \"newTab\",\n type: \"checkbox\",\n label: \"Open in a new tab\",\n defaultValue: false,\n admin: {\n // Drawn by LinkField next to the destination so Header, Footer, and\n // page blocks cannot drift apart.\n hidden: true,\n },\n },\n ];\n}\n\nexport interface HeaderCtaValue {\n enabled?: boolean | null;\n type?: LinkType | null;\n page?: unknown;\n href?: string | null;\n label?: string | null;\n}\n\n/** A stored button, or a legacy row that already has a label or destination. */\nexport function headerCtaEnabled(cta: HeaderCtaValue | null | undefined): boolean {\n if (!cta) return false;\n if (cta.enabled === false) return false;\n if (cta.enabled === true) return true;\n return Boolean(cta.label || cta.page || cta.href);\n}\n\n/**\n * When the Header button is on, label and destination are required.\n * Off (or a cleared row) can save empty.\n */\nexport function validateHeaderCta(value: unknown): true | string {\n const cta = (value && typeof value === \"object\" ? value : {}) as HeaderCtaValue;\n if (!headerCtaEnabled(cta)) return true;\n if (!String(cta.label ?? \"\").trim()) return \"The Header button needs a label.\";\n const dest = linkTypeOf(cta);\n if (dest === \"external\") {\n const href = validateExternalHref(cta.href, true);\n if (href !== true) {\n return href === \"This field is required.\"\n ? \"The Header button needs a published page or a URL.\"\n : href;\n }\n }\n if (dest === \"page\" && (cta.page == null || cta.page === \"\")) {\n return \"The Header button needs a published page or a URL.\";\n }\n return true;\n}\n\nexport function linkField({\n name = \"link\",\n label,\n admin,\n required,\n pagesCollection,\n toggle,\n}: {\n name?: string;\n label?: GroupField[\"label\"];\n admin?: GroupField[\"admin\"];\n required?: boolean;\n pagesCollection?: string;\n /** Header button: an enable checkbox; children are not required unless it is on. */\n toggle?: boolean;\n} = {}): GroupField {\n return {\n name,\n type: \"group\",\n fields: toggle\n ? [\n {\n name: \"enabled\",\n type: \"checkbox\",\n label: \"Show Header button\",\n defaultValue: false,\n },\n ...linkFields({ required: false, pagesCollection }),\n ]\n : linkFields({ required, pagesCollection }),\n ...(toggle ? { validate: validateHeaderCta as NonNullable<GroupField[\"validate\"]> } : {}),\n ...(label === undefined ? {} : { label }),\n ...(admin === undefined ? {} : { admin }),\n };\n}\n\nexport function footerLinkFields({\n required = false,\n pagesCollection,\n}: {\n required?: boolean;\n pagesCollection?: string;\n} = {}): Field[] {\n return linkFields({ required, pagesCollection });\n}\n","import type { ArrayField, ArrayFieldValidation, Field, GroupField, TextField } from \"payload\";\n\nimport { footerLinkFields, isValidExternalHref, validateExternalHref } from \"./link\";\n\n/**\n * Same presets as the header mega-menu. Desktop only. Tablet is a fixed\n * 2×2 on the public footer; mobile stacks.\n */\nexport const FOOTER_COLUMN_WIDTHS = [\"25\", \"33\", \"50\", \"66\", \"75\", \"100\"] as const;\nexport type FooterColumnWidth = (typeof FOOTER_COLUMN_WIDTHS)[number];\n\n/** Logo column plus link columns. */\nexport const FOOTER_MAX_COLUMNS = 4;\n/** Link columns. The logo column is always first and is not in this count. */\nexport const FOOTER_MAX_LINK_COLUMNS = FOOTER_MAX_COLUMNS - 1;\n\nexport const FOOTER_SOCIALS = [\"facebook\", \"instagram\", \"linkedin\", \"x\", \"youtube\"] as const;\nexport type FooterSocial = (typeof FOOTER_SOCIALS)[number];\n\nconst FOOTER_SOCIAL_LABELS: Record<FooterSocial, string> = {\n facebook: \"Facebook\",\n instagram: \"Instagram\",\n linkedin: \"LinkedIn\",\n x: \"X\",\n youtube: \"YouTube\",\n};\n\n/** Twelfths of a row. Link-column widths share this 12; the logo column does not. */\nexport const FOOTER_TWELFTHS: Record<FooterColumnWidth, number> = {\n \"25\": 3,\n \"33\": 4,\n \"50\": 6,\n \"66\": 8,\n \"75\": 9,\n \"100\": 12,\n};\n\nexport const FOOTER_COLUMNS_FIELD = \"@bison-lab/payload-blocks/admin#FooterColumnsField\";\n\ninterface FooterLinkRow {\n label?: string | null;\n type?: \"page\" | \"external\" | null;\n page?: unknown;\n href?: string | null;\n}\n\ninterface FooterSectionRow {\n heading?: string | null;\n links?: FooterLinkRow[] | null;\n}\n\ninterface FooterColumnRow {\n desktop?: FooterColumnWidth | null;\n sections?: FooterSectionRow[] | null;\n}\n\nfunction evenDesktop(count: number): FooterColumnWidth[] {\n return (\n {\n 1: [\"100\"],\n 2: [\"50\", \"50\"],\n 3: [\"33\", \"33\", \"33\"],\n 4: [\"25\", \"25\", \"25\", \"25\"],\n } as Record<number, FooterColumnWidth[]>\n )[count] ?? [];\n}\n\n/** Even split for the current link-column count. Used by the kit editor. */\nexport function normalizeFooterDesktop(count: number): FooterColumnWidth[] {\n return evenDesktop(count);\n}\n\n/**\n * Desktop tracks: the logo keeps its own percent; link columns share the\n * remaining `1fr` and are themselves percent of that leftover, not of the\n * full footer.\n */\nexport function footerDesktopTracks(\n brand: FooterColumnWidth | null | undefined,\n columns: Array<FooterColumnWidth | null | undefined>,\n): {\n brandPercent: string;\n brandTemplate: string;\n linksTemplate: string;\n} {\n const width = brand && brand in FOOTER_TWELFTHS ? brand : \"25\";\n const brandPercent = `${width}%`;\n const links = columns.map((column) => `${column && column in FOOTER_TWELFTHS ? column : \"25\"}%`);\n return {\n brandPercent,\n brandTemplate: `${brandPercent} minmax(0,1fr)`,\n linksTemplate: links.join(\" \") || \"1fr\",\n };\n}\n\nfunction linkHasDestination(link: FooterLinkRow): boolean {\n if (link.type === \"external\") return isValidExternalHref(link.href);\n if (link.type === \"page\") return link.page != null && link.page !== \"\";\n if (String(link.href ?? \"\").trim()) return isValidExternalHref(link.href);\n return link.page != null && link.page !== \"\";\n}\n\n/**\n * Link-column widths must add to 100% of the space beside the logo. The\n * logo width is independent. Each section needs a labeled destination\n * before publish. Draft saves skip field validation. A footer with only\n * the logo column is valid.\n */\nexport const validateFooterColumns: ArrayFieldValidation = (value) => {\n const columns = (Array.isArray(value) ? value : []) as FooterColumnRow[];\n if (columns.length > FOOTER_MAX_LINK_COLUMNS) {\n return \"No more than three link columns. The logo column is always first.\";\n }\n\n if (columns.length === 0) return true;\n\n const twelfths = columns.reduce((sum, row) => sum + FOOTER_TWELFTHS[row?.desktop ?? \"100\"], 0);\n if (twelfths !== 12) {\n const percent = Math.round((twelfths / 12) * 100);\n return `Desktop column widths add up to ${percent}%. They need to add up to 100% of the space beside the logo.`;\n }\n\n for (const [columnIndex, column] of columns.entries()) {\n const sections = column.sections ?? [];\n if (sections.length === 0) {\n return `Column ${columnIndex + 1} needs at least one section.`;\n }\n for (const [sectionIndex, section] of sections.entries()) {\n if (!String(section.heading ?? \"\").trim()) {\n return `Column ${columnIndex + 1}, section ${sectionIndex + 1} needs a section label.`;\n }\n const links = section.links ?? [];\n if (links.length === 0) {\n return `Column ${columnIndex + 1}, section ${sectionIndex + 1} needs at least one link.`;\n }\n for (const [linkIndex, link] of links.entries()) {\n if (!String(link.label ?? \"\").trim()) {\n return `Column ${columnIndex + 1}, section ${sectionIndex + 1}, link ${linkIndex + 1} needs a label.`;\n }\n if (!linkHasDestination(link)) {\n const href = String(link.href ?? \"\").trim();\n if (href && validateExternalHref(href) !== true) {\n return `Column ${columnIndex + 1}, section ${sectionIndex + 1}, link ${linkIndex + 1} needs a valid URL.`;\n }\n return `Column ${columnIndex + 1}, section ${sectionIndex + 1}, link ${linkIndex + 1} needs a destination.`;\n }\n }\n }\n }\n\n return true;\n};\n\nexport function validateFooterSocialUrl(value: unknown): true | string {\n const raw = String(value ?? \"\").trim();\n if (!raw) return true;\n try {\n const url = new URL(raw);\n if (url.protocol === \"http:\" || url.protocol === \"https:\") return true;\n } catch {\n // not a URL\n }\n return \"Must be a valid http(s) URL.\";\n}\n\nfunction socialFields(): TextField[] {\n return FOOTER_SOCIALS.map((name) => ({\n name,\n type: \"text\",\n label: FOOTER_SOCIAL_LABELS[name],\n validate: validateFooterSocialUrl,\n }));\n}\n\nexport function footerColumnsField({\n pagesCollection,\n}: {\n pagesCollection?: string;\n} = {}): ArrayField {\n return {\n name: \"columns\",\n type: \"array\",\n dbName: \"c\",\n labels: { singular: \"Column\", plural: \"Columns\" },\n maxRows: FOOTER_MAX_LINK_COLUMNS,\n validate: validateFooterColumns,\n admin: {\n description:\n \"Logo column plus up to three link columns. Link-column widths add up to 100% of the space beside the logo.\",\n },\n fields: [\n {\n name: \"desktop\",\n type: \"select\",\n label: \"Desktop width\",\n defaultValue: \"25\",\n required: true,\n options: FOOTER_COLUMN_WIDTHS.map((value) => ({ label: `${value}%`, value })),\n },\n {\n name: \"sections\",\n type: \"array\",\n dbName: \"s\",\n labels: { singular: \"Section\", plural: \"Sections\" },\n minRows: 1,\n fields: [\n {\n name: \"heading\",\n type: \"text\",\n label: \"Section Label\",\n required: true,\n },\n {\n name: \"links\",\n type: \"array\",\n labels: { singular: \"Link\", plural: \"Links\" },\n minRows: 1,\n fields: footerLinkFields({ required: true, pagesCollection }),\n },\n ],\n },\n ],\n };\n}\n\nexport function footerBrandField(): GroupField {\n return {\n name: \"brand\",\n type: \"group\",\n label: \"Brand & social\",\n fields: [\n {\n name: \"desktop\",\n type: \"select\",\n label: \"Desktop width\",\n defaultValue: \"25\",\n required: true,\n options: FOOTER_COLUMN_WIDTHS.map((value) => ({ label: `${value}%`, value })),\n },\n {\n name: \"tagline\",\n type: \"textarea\",\n label: \"Text below the logo\",\n },\n ...socialFields(),\n ],\n };\n}\n\nexport function footerFields(options: { pagesCollection?: string } = {}): Field[] {\n return [footerColumnsField(options), footerBrandField()];\n}\n","import {\n NAVIGATION_FOOTER_SLUG,\n NAVIGATION_SLUG,\n type GetNavigationArgs,\n type NavigationBar,\n type NavigationDoc,\n type NavigationFooter,\n type NavigationHeader,\n} from \"./types\";\n\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n return value && typeof value === \"object\" ? (value as Record<string, unknown>) : null;\n}\n\nfunction headerOf(doc: unknown): NavigationHeader {\n const record = asRecord(doc);\n const header = record && \"header\" in record ? asRecord(record.header) : null;\n return header ?? {};\n}\n\nfunction footerOf(doc: unknown): NavigationFooter {\n const record = asRecord(doc);\n const footer = record && \"footer\" in record ? asRecord(record.footer) : null;\n return footer ?? {};\n}\n\nfunction barOf(doc: unknown): NavigationBar {\n const record = asRecord(doc);\n const bar = record && \"bar\" in record ? asRecord(record.bar) : null;\n return bar ?? {};\n}\n\n/**\n * Reads Header and Footer and returns one `{ header, footer, bar }`. A\n * site header does not learn two slugs. `bar` is the hidden Header group\n * (hide on scroll, viewport, default panel width). `draft: true`\n * reads the newest version; omit it (or pass false) for the published\n * documents.\n */\nexport async function getNavigation({ payload, draft = false }: GetNavigationArgs): Promise<NavigationDoc> {\n const [headerDoc, footerDoc] = await Promise.all([\n payload.findGlobal({ slug: NAVIGATION_SLUG, draft, depth: 1 }),\n payload.findGlobal({ slug: NAVIGATION_FOOTER_SLUG, draft, depth: 1 }),\n ]);\n return { header: headerOf(headerDoc), footer: footerOf(footerDoc), bar: barOf(headerDoc) };\n}\n"],"mappings":";AAWA,MAAa,kBAAkB;AAC/B,MAAa,qBAAqB;AAClC,MAAa,yBAAyB;AACtC,MAAa,4BAA4B;AAEzC,MAAa,qBAAqB;;;;;;;;;ACRlC,MAAM,aAAa;AASnB,SAAS,WAAW,MAAoD;AACtE,KAAI,MAAM,SAAS,WAAY,QAAO;AACtC,KAAI,MAAM,SAAS,OAAQ,QAAO;AAClC,QAAO,MAAM,OAAO,aAAa;;AAGnC,MAAa,wBACX;;;;;;AAOF,SAAgB,oBAAoB,OAAyB;CAC3D,MAAM,MAAM,OAAO,SAAS,GAAG,CAAC,MAAM;AACtC,KAAI,CAAC,OAAO,KAAK,KAAK,IAAI,CAAE,QAAO;AACnC,KAAI,IAAI,WAAW,IAAI,IAAI,CAAC,IAAI,WAAW,KAAK,CAAE,QAAO;AACzD,KAAI,YAAY,KAAK,IAAI,CAAE,QAAO,IAAI,SAAS;AAC/C,KAAI,SAAS,KAAK,IAAI,CAAE,QAAO,IAAI,SAAS;AAC5C,KAAI;EACF,MAAM,MAAM,IAAI,IAA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ACF;;AAGH,SAAgB,aAAa,UAAwC,EAAE,EAAW;AAChF,QAAO,CAAC,mBAAmB,QAAQ,EAAE,kBAAkB,CAAC;;;;AChP1D,SAAS,SAAS,OAAgD;AAChE,QAAO,SAAS,OAAO,UAAU,WAAY,QAAoC;;AAGnF,SAAS,SAAS,KAAgC;CAChD,MAAM,SAAS,SAAS,IAAI;AAE5B,SADe,UAAU,YAAY,SAAS,SAAS,OAAO,OAAO,GAAG,SACvD,EAAE;;AAGrB,SAAS,SAAS,KAAgC;CAChD,MAAM,SAAS,SAAS,IAAI;AAE5B,SADe,UAAU,YAAY,SAAS,SAAS,OAAO,OAAO,GAAG,SACvD,EAAE;;AAGrB,SAAS,MAAM,KAA6B;CAC1C,MAAM,SAAS,SAAS,IAAI;AAE5B,SADY,UAAU,SAAS,SAAS,SAAS,OAAO,IAAI,GAAG,SACjD,EAAE;;;;;;;;;AAUlB,eAAsB,cAAc,EAAE,SAAS,QAAQ,SAAoD;CACzG,MAAM,CAAC,WAAW,aAAa,MAAM,QAAQ,IAAI,CAC/C,QAAQ,WAAW;EAAE,MAAM;EAAiB;EAAO,OAAO;EAAG,CAAC,EAC9D,QAAQ,WAAW;EAAE,MAAM;EAAwB;EAAO,OAAO;EAAG,CAAC,CACtE,CAAC;AACF,QAAO;EAAE,QAAQ,SAAS,UAAU;EAAE,QAAQ,SAAS,UAAU;EAAE,KAAK,MAAM,UAAU;EAAE"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { t as resolveThemeIdentity, u as themeConfigFromDoc } from "./identity-CN6EOeDM.mjs";
|
|
2
|
+
//#region src/theme/published.ts
|
|
3
|
+
/**
|
|
4
|
+
* The Theme row, or `seed` when the Global is empty. Theme has no draft
|
|
5
|
+
* mode: `draft: false` is the live document. Access is overridden so a
|
|
6
|
+
* logged-out request still gets the colours.
|
|
7
|
+
*/
|
|
8
|
+
async function getPublishedTheme(payload, seed) {
|
|
9
|
+
return themeConfigFromDoc(await payload.findGlobal({
|
|
10
|
+
slug: "theme",
|
|
11
|
+
draft: false,
|
|
12
|
+
depth: 0,
|
|
13
|
+
overrideAccess: true
|
|
14
|
+
}) ?? {}, seed);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Uploaded logo, favicon, and mobile-menu mark, or the fallback the site
|
|
18
|
+
* passed into `createTheme`. Depth 1 so the upload url is populated.
|
|
19
|
+
*/
|
|
20
|
+
async function getPublishedIdentity(payload, fallback) {
|
|
21
|
+
return resolveThemeIdentity(await payload.findGlobal({
|
|
22
|
+
slug: "theme",
|
|
23
|
+
draft: false,
|
|
24
|
+
depth: 1,
|
|
25
|
+
overrideAccess: true
|
|
26
|
+
}) ?? {}, fallback);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { getPublishedTheme as n, getPublishedIdentity as t };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=published-DgAzpDSG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"published-DgAzpDSG.mjs","names":[],"sources":["../src/theme/published.ts"],"sourcesContent":["import type { ThemeConfig } from \"@bison-lab/tokens\";\n\nimport { resolveThemeIdentity, type ResolvedThemeIdentity, type ThemeIdentityFallback } from \"./identity\";\nimport { themeConfigFromDoc } from \"./map\";\nimport { THEME_SLUG } from \"./types\";\nimport type { ThemeDoc } from \"./types\";\n\nexport interface ThemePayload {\n findGlobal: (args: {\n slug: string;\n draft?: boolean;\n depth?: number;\n overrideAccess?: boolean;\n }) => Promise<ThemeDoc | null | undefined>;\n}\n\n/**\n * The Theme row, or `seed` when the Global is empty. Theme has no draft\n * mode: `draft: false` is the live document. Access is overridden so a\n * logged-out request still gets the colours.\n */\nexport async function getPublishedTheme(payload: ThemePayload, seed: ThemeConfig): Promise<ThemeConfig> {\n const doc = await payload.findGlobal({\n slug: THEME_SLUG,\n draft: false,\n depth: 0,\n overrideAccess: true,\n });\n return themeConfigFromDoc(doc ?? {}, seed);\n}\n\n/**\n * Uploaded logo, favicon, and mobile-menu mark, or the fallback the site\n * passed into `createTheme`. Depth 1 so the upload url is populated.\n */\nexport async function getPublishedIdentity(\n payload: ThemePayload,\n fallback?: ThemeIdentityFallback,\n): Promise<ResolvedThemeIdentity> {\n const doc = await payload.findGlobal({\n slug: THEME_SLUG,\n draft: false,\n depth: 1,\n overrideAccess: true,\n });\n return resolveThemeIdentity(doc ?? {}, fallback);\n}\n"],"mappings":";;;;;;;AAqBA,eAAsB,kBAAkB,SAAuB,MAAyC;AAOtG,QAAO,mBANK,MAAM,QAAQ,WAAW;EACnC,MAAA;EACA,OAAO;EACP,OAAO;EACP,gBAAgB;EACjB,CAAC,IAC+B,EAAE,EAAE,KAAK;;;;;;AAO5C,eAAsB,qBACpB,SACA,UACgC;AAOhC,QAAO,qBANK,MAAM,QAAQ,WAAW;EACnC,MAAA;EACA,OAAO;EACP,OAAO;EACP,gBAAgB;EACjB,CAAC,IACiC,EAAE,EAAE,SAAS"}
|
|
@@ -134,4 +134,4 @@ declare function getNavigation({
|
|
|
134
134
|
}: GetNavigationArgs): Promise<NavigationDoc>;
|
|
135
135
|
//#endregion
|
|
136
136
|
export { NAVIGATION_FOOTER_SLUG as C, NavigationFooter as D, NavigationDoc as E, NavigationHeader as O, NAVIGATION_FOOTER_DB_NAME as S, NavigationBar as T, validateExternalHref as _, FOOTER_MAX_LINK_COLUMNS as a, NAVIGATION_DB_NAME as b, FooterColumnWidth as c, normalizeFooterDesktop as d, validateFooterColumns as f, isValidExternalHref as g, headerCtaEnabled as h, FOOTER_MAX_COLUMNS as i, FooterSocial as l, EXTERNAL_HREF_MESSAGE as m, FOOTER_COLUMNS_FIELD as n, FOOTER_SOCIALS as o, validateFooterSocialUrl as p, FOOTER_COLUMN_WIDTHS as r, FOOTER_TWELFTHS as s, getNavigation as t, footerDesktopTracks as u, validateHeaderCta as v, NAVIGATION_SLUG as w, NAVIGATION_FEATURE as x, CreateNavigationOptions as y };
|
|
137
|
-
//# sourceMappingURL=published-
|
|
137
|
+
//# sourceMappingURL=published-Dsg-HX-v.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"published-
|
|
1
|
+
{"version":3,"file":"published-Dsg-HX-v.d.mts","names":[],"sources":["../src/navigation/types.ts","../src/navigation/link.ts","../src/navigation/footer.ts","../src/navigation/published.ts"],"mappings":";;;cAWa,eAAA;AAAA,cACA,kBAAA;AAAA,cACA,sBAAA;AAAA,cACA,yBAAA;AAAA,cAEA,kBAAA;AAAA,UAEI,uBAAA;;;;AAJjB;EASE,MAAA,EAAQ,KAAA;;;;AAPV;EAYE,OAAA,GAAU,WAAA,CAAY,WAAA,CAAY,YAAA;EAClC,WAAA,GAAc,WAAA,CAAY,WAAA,CAAY,YAAA;EAbT;;AAE/B;;EAgBE,aAAA;EAXQ;EAaR,eAAA;EARsB;EAUtB,mBAAA;AAAA;AAAA,UAGe,gBAAA;EACf,KAAA;EACA,GAAA;AAAA;AAAA,UAGe,aAAA;EACf,YAAA;EACA,QAAA;EACA,eAAA;AAAA;AAAA,UAGe,gBAAA;EACf,OAAA;EACA,KAAA;AAAA;AAAA,UAGe,aAAA;EACf,MAAA,EAAQ,gBAAA;EACR,MAAA,EAAQ,gBAAA;EACR,GAAA,EAAK,aAAA;AAAA;AAAA,UAGU,iBAAA;EACf,OAAA;IACE,UAAA,GAAa,IAAA;MACX,IAAA;MACA,KAAA;MACA,cAAA;MACA,KAAA;IAAA,MACI,OAAA;EAAA;EAER,KAAA;AAAA;;;KC9DG,QAAA;AAAA,cAaQ,qBAAA;ADZb;;;;;AAAA,iBCoBgB,mBAAA,CAAoB,KAAA;AAAA,iBAcpB,oBAAA,CAAqB,KAAA,WAAgB,QAAA;AAAA,UAyFpC,cAAA;EACf,OAAA;EACA,IAAA,GAAO,QAAA;EACP,IAAA;EACA,IAAA;EACA,KAAA;AAAA;;iBAIc,gBAAA,CAAiB,GAAA,EAAK,cAAA;;;;;iBAWtB,iBAAA,CAAkB,KAAA;;;;;AD/IlC;;cEHa,oBAAA;AAAA,KACD,iBAAA,WAA4B,oBAAA;;cAG3B,kBAAA;;cAEA,uBAAA;AAAA,cAEA,cAAA;AAAA,KACD,YAAA,WAAuB,cAAA;AFJnC;AAAA,cEea,eAAA,EAAiB,MAAA,CAAO,iBAAA;AAAA,cASxB,oBAAA;;iBA+BG,sBAAA,CAAuB,KAAA,WAAgB,iBAAA;AFtDvD;;;;;AAAA,iBE+DgB,mBAAA,CACd,KAAA,EAAO,iBAAA,qBACP,OAAA,EAAS,KAAA,CAAM,iBAAA;EAEf,YAAA;EACA,aAAA;EACA,aAAA;AAAA;AFjEF;;;;;;AAAA,cE0Fa,qBAAA,EAAuB,oBAAA;AAAA,iBA6CpB,uBAAA,CAAwB,KAAA;;;;;AF9IxC;;;;;iBG4BsB,aAAA,CAAA;EAAgB,OAAA;EAAS;AAAA,GAAiB,iBAAA,GAAoB,OAAA,CAAQ,aAAA"}
|
|
@@ -459,4 +459,4 @@ async function getSectionControls(payload, extras = blockLibraryEntriesFromConfi
|
|
|
459
459
|
//#endregion
|
|
460
460
|
export { sectionControlsOf as _, sectionControlsFromLibrary as a, BLOCK_LIBRARY_CATEGORIES as c, DEFAULT_SECTION_CONTROLS as d, HERO_SECTION_CONTROLS as f, defaultSectionControls as g, SECTION_CONTROL_LABELS as h, defaultBlockLibraryValue as i, BLOCK_LIBRARY_SLUG as l, SECTION_CONTROL_KEYS as m, getSectionControls as n, stampBlockLibrary as o, NO_SECTION_CONTROLS as p, blockLibraryCatalogue as r, validateBlockLibrary as s, blockLibraryEntriesFromConfig as t, PACKAGE_BLOCK_SLUGS as u };
|
|
461
461
|
|
|
462
|
-
//# sourceMappingURL=published-
|
|
462
|
+
//# sourceMappingURL=published-QyTcDznE.mjs.map
|