@bison-lab/payload-core 3.33.1 → 3.34.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 +15 -6
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +167 -151
- package/dist/admin.mjs.map +1 -1
- package/dist/index.d.mts +21 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +71 -6
- package/dist/index.mjs.map +1 -1
- package/dist/navigation.d.mts +2 -2
- package/dist/navigation.mjs +2 -2
- package/dist/{published-DECGVhsR.mjs → published-BltDUYZv.mjs} +26 -16
- package/dist/published-BltDUYZv.mjs.map +1 -0
- package/dist/{published-C_BV1MhL.d.mts → published-y1Nrly7r.d.mts} +18 -7
- package/dist/{published-C_BV1MhL.d.mts.map → published-y1Nrly7r.d.mts.map} +1 -1
- package/package.json +9 -4
- package/dist/published-DECGVhsR.mjs.map +0 -1
package/dist/navigation.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { EXTERNAL_HREF_MESSAGE, FOOTER_COLUMN_WIDTHS, FOOTER_MAX_COLUMNS, FOOTER_MAX_LINK_COLUMNS, FOOTER_SOCIALS, FOOTER_TWELFTHS, type FooterColumnWidth, type FooterSocial, NAVIGATION_DB_NAME, NAVIGATION_FOOTER_DB_NAME, NAVIGATION_FOOTER_SLUG, NAVIGATION_SLUG, type NavigationBar, type NavigationDoc, type NavigationFooter, type NavigationHeader, getNavigation, isValidExternalHref, normalizeFooterDesktop, validateExternalHref, validateFooterSocialUrl, validateHeaderCta };
|
|
1
|
+
import { C as NAVIGATION_FOOTER_SLUG, D as NavigationFooter, E as NavigationDoc, O as NavigationHeader, S as NAVIGATION_FOOTER_DB_NAME, T as NavigationBar, _ as validateExternalHref, a as FOOTER_MAX_LINK_COLUMNS, b as NAVIGATION_DB_NAME, c as FooterColumnWidth, d as normalizeFooterDesktop, g as isValidExternalHref, i as FOOTER_MAX_COLUMNS, l as FooterSocial, m as EXTERNAL_HREF_MESSAGE, o as FOOTER_SOCIALS, p as validateFooterSocialUrl, r as FOOTER_COLUMN_WIDTHS, s as FOOTER_TWELFTHS, t as getNavigation, u as footerDesktopTracks, v as validateHeaderCta, w as NAVIGATION_SLUG } from "./published-y1Nrly7r.mjs";
|
|
2
|
+
export { EXTERNAL_HREF_MESSAGE, FOOTER_COLUMN_WIDTHS, FOOTER_MAX_COLUMNS, FOOTER_MAX_LINK_COLUMNS, FOOTER_SOCIALS, FOOTER_TWELFTHS, type FooterColumnWidth, type FooterSocial, NAVIGATION_DB_NAME, NAVIGATION_FOOTER_DB_NAME, NAVIGATION_FOOTER_SLUG, NAVIGATION_SLUG, type NavigationBar, type NavigationDoc, type NavigationFooter, type NavigationHeader, footerDesktopTracks, getNavigation, isValidExternalHref, normalizeFooterDesktop, validateExternalHref, validateFooterSocialUrl, validateHeaderCta };
|
package/dist/navigation.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { EXTERNAL_HREF_MESSAGE, FOOTER_COLUMN_WIDTHS, FOOTER_MAX_COLUMNS, FOOTER_MAX_LINK_COLUMNS, FOOTER_SOCIALS, FOOTER_TWELFTHS, NAVIGATION_DB_NAME, NAVIGATION_FOOTER_DB_NAME, NAVIGATION_FOOTER_SLUG, NAVIGATION_SLUG, getNavigation, isValidExternalHref, normalizeFooterDesktop, validateExternalHref, validateFooterSocialUrl, validateHeaderCta };
|
|
1
|
+
import { C as validateHeaderCta, S as validateExternalHref, _ as validateFooterSocialUrl, a as NAVIGATION_FOOTER_SLUG, b as isValidExternalHref, c as FOOTER_COLUMN_WIDTHS, d as FOOTER_SOCIALS, f as FOOTER_TWELFTHS, h as normalizeFooterDesktop, i as NAVIGATION_FOOTER_DB_NAME, l as FOOTER_MAX_COLUMNS, n as NAVIGATION_DB_NAME, o as NAVIGATION_SLUG, p as footerDesktopTracks, t as getNavigation, u as FOOTER_MAX_LINK_COLUMNS, v as EXTERNAL_HREF_MESSAGE } from "./published-BltDUYZv.mjs";
|
|
2
|
+
export { EXTERNAL_HREF_MESSAGE, FOOTER_COLUMN_WIDTHS, FOOTER_MAX_COLUMNS, FOOTER_MAX_LINK_COLUMNS, FOOTER_SOCIALS, FOOTER_TWELFTHS, NAVIGATION_DB_NAME, NAVIGATION_FOOTER_DB_NAME, NAVIGATION_FOOTER_SLUG, NAVIGATION_SLUG, footerDesktopTracks, getNavigation, isValidExternalHref, normalizeFooterDesktop, validateExternalHref, validateFooterSocialUrl, validateHeaderCta };
|
|
@@ -187,7 +187,7 @@ const FOOTER_SOCIAL_LABELS = {
|
|
|
187
187
|
x: "X",
|
|
188
188
|
youtube: "YouTube"
|
|
189
189
|
};
|
|
190
|
-
/** Twelfths
|
|
190
|
+
/** Twelfths of a row. Link-column widths share this 12; the logo column does not. */
|
|
191
191
|
const FOOTER_TWELFTHS = {
|
|
192
192
|
"25": 3,
|
|
193
193
|
"33": 4,
|
|
@@ -214,32 +214,42 @@ function evenDesktop(count) {
|
|
|
214
214
|
]
|
|
215
215
|
}[count] ?? [];
|
|
216
216
|
}
|
|
217
|
-
/** Even split for the current column count. Used by the kit editor. */
|
|
217
|
+
/** Even split for the current link-column count. Used by the kit editor. */
|
|
218
218
|
function normalizeFooterDesktop(count) {
|
|
219
219
|
return evenDesktop(count);
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Desktop tracks: the logo keeps its own percent; link columns share the
|
|
223
|
+
* remaining `1fr` and are themselves percent of that leftover, not of the
|
|
224
|
+
* full footer.
|
|
225
|
+
*/
|
|
226
|
+
function footerDesktopTracks(brand, columns) {
|
|
227
|
+
const brandPercent = `${brand && brand in FOOTER_TWELFTHS ? brand : "25"}%`;
|
|
228
|
+
const links = columns.map((column) => `${column && column in FOOTER_TWELFTHS ? column : "25"}%`);
|
|
229
|
+
return {
|
|
230
|
+
brandPercent,
|
|
231
|
+
brandTemplate: `${brandPercent} minmax(0,1fr)`,
|
|
232
|
+
linksTemplate: links.join(" ") || "1fr"
|
|
233
|
+
};
|
|
234
|
+
}
|
|
221
235
|
function linkHasDestination(link) {
|
|
222
236
|
if (link.type === "external") return isValidExternalHref(link.href);
|
|
223
237
|
if (link.type === "page") return link.page != null && link.page !== "";
|
|
224
238
|
if (String(link.href ?? "").trim()) return isValidExternalHref(link.href);
|
|
225
239
|
return link.page != null && link.page !== "";
|
|
226
240
|
}
|
|
227
|
-
function brandDesktopFromSibling(siblingData) {
|
|
228
|
-
const desktop = siblingData?.brand?.desktop;
|
|
229
|
-
if (desktop && desktop in FOOTER_TWELFTHS) return desktop;
|
|
230
|
-
return "25";
|
|
231
|
-
}
|
|
232
241
|
/**
|
|
233
|
-
*
|
|
234
|
-
* section needs a labeled destination
|
|
235
|
-
* field validation. A footer with only
|
|
242
|
+
* Link-column widths must add to 100% of the space beside the logo. The
|
|
243
|
+
* logo width is independent. Each section needs a labeled destination
|
|
244
|
+
* before publish. Draft saves skip field validation. A footer with only
|
|
245
|
+
* the logo column is valid.
|
|
236
246
|
*/
|
|
237
|
-
const validateFooterColumns = (value
|
|
247
|
+
const validateFooterColumns = (value) => {
|
|
238
248
|
const columns = Array.isArray(value) ? value : [];
|
|
239
249
|
if (columns.length > 3) return "No more than three link columns. The logo column is always first.";
|
|
240
|
-
const twelfths = FOOTER_TWELFTHS[brandDesktopFromSibling(options?.siblingData)] + columns.reduce((sum, row) => sum + FOOTER_TWELFTHS[row?.desktop ?? "100"], 0);
|
|
241
|
-
if (twelfths !== 12) return `Desktop column widths add up to ${Math.round(twelfths / 12 * 100)}%. They need to add up to 100%.`;
|
|
242
250
|
if (columns.length === 0) return true;
|
|
251
|
+
const twelfths = columns.reduce((sum, row) => sum + FOOTER_TWELFTHS[row?.desktop ?? "100"], 0);
|
|
252
|
+
if (twelfths !== 12) return `Desktop column widths add up to ${Math.round(twelfths / 12 * 100)}%. They need to add up to 100% of the space beside the logo.`;
|
|
243
253
|
for (const [columnIndex, column] of columns.entries()) {
|
|
244
254
|
const sections = column.sections ?? [];
|
|
245
255
|
if (sections.length === 0) return `Column ${columnIndex + 1} needs at least one section.`;
|
|
@@ -287,7 +297,7 @@ function footerColumnsField({ pagesCollection } = {}) {
|
|
|
287
297
|
},
|
|
288
298
|
maxRows: 3,
|
|
289
299
|
validate: validateFooterColumns,
|
|
290
|
-
admin: { description: "Logo column plus up to three link columns.
|
|
300
|
+
admin: { description: "Logo column plus up to three link columns. Link-column widths add up to 100% of the space beside the logo." },
|
|
291
301
|
fields: [{
|
|
292
302
|
name: "desktop",
|
|
293
303
|
type: "select",
|
|
@@ -405,6 +415,6 @@ async function getNavigation({ payload, draft = false }) {
|
|
|
405
415
|
};
|
|
406
416
|
}
|
|
407
417
|
//#endregion
|
|
408
|
-
export { validateHeaderCta as S,
|
|
418
|
+
export { validateHeaderCta as C, validateExternalHref as S, validateFooterSocialUrl as _, NAVIGATION_FOOTER_SLUG as a, isValidExternalHref as b, FOOTER_COLUMN_WIDTHS as c, FOOTER_SOCIALS as d, FOOTER_TWELFTHS as f, validateFooterColumns as g, normalizeFooterDesktop as h, NAVIGATION_FOOTER_DB_NAME as i, FOOTER_MAX_COLUMNS as l, footerFields as m, NAVIGATION_DB_NAME as n, NAVIGATION_SLUG as o, footerDesktopTracks as p, NAVIGATION_FEATURE as r, FOOTER_COLUMNS_FIELD as s, getNavigation as t, FOOTER_MAX_LINK_COLUMNS as u, EXTERNAL_HREF_MESSAGE as v, linkField as x, headerCtaEnabled as y };
|
|
409
419
|
|
|
410
|
-
//# sourceMappingURL=published-
|
|
420
|
+
//# sourceMappingURL=published-BltDUYZv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"published-BltDUYZv.mjs","names":[],"sources":["../src/navigation/link.ts","../src/navigation/footer.ts","../src/navigation/types.ts","../src/navigation/published.ts"],"sourcesContent":["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","/**\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 {\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":";;;;;;;AAQA,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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AO;EAAG,CAAC,CACtE,CAAC;AACF,QAAO;EAAE,QAAQ,SAAS,UAAU;EAAE,QAAQ,SAAS,UAAU;EAAE,KAAK,MAAM,UAAU;EAAE"}
|
|
@@ -96,15 +96,26 @@ declare const FOOTER_MAX_COLUMNS = 4;
|
|
|
96
96
|
declare const FOOTER_MAX_LINK_COLUMNS: number;
|
|
97
97
|
declare const FOOTER_SOCIALS: readonly ["facebook", "instagram", "linkedin", "x", "youtube"];
|
|
98
98
|
type FooterSocial = (typeof FOOTER_SOCIALS)[number];
|
|
99
|
-
/** Twelfths
|
|
99
|
+
/** Twelfths of a row. Link-column widths share this 12; the logo column does not. */
|
|
100
100
|
declare const FOOTER_TWELFTHS: Record<FooterColumnWidth, number>;
|
|
101
101
|
declare const FOOTER_COLUMNS_FIELD = "@bison-lab/payload-blocks/admin#FooterColumnsField";
|
|
102
|
-
/** Even split for the current column count. Used by the kit editor. */
|
|
102
|
+
/** Even split for the current link-column count. Used by the kit editor. */
|
|
103
103
|
declare function normalizeFooterDesktop(count: number): FooterColumnWidth[];
|
|
104
104
|
/**
|
|
105
|
-
* Desktop
|
|
106
|
-
*
|
|
107
|
-
*
|
|
105
|
+
* Desktop tracks: the logo keeps its own percent; link columns share the
|
|
106
|
+
* remaining `1fr` and are themselves percent of that leftover, not of the
|
|
107
|
+
* full footer.
|
|
108
|
+
*/
|
|
109
|
+
declare function footerDesktopTracks(brand: FooterColumnWidth | null | undefined, columns: Array<FooterColumnWidth | null | undefined>): {
|
|
110
|
+
brandPercent: string;
|
|
111
|
+
brandTemplate: string;
|
|
112
|
+
linksTemplate: string;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Link-column widths must add to 100% of the space beside the logo. The
|
|
116
|
+
* logo width is independent. Each section needs a labeled destination
|
|
117
|
+
* before publish. Draft saves skip field validation. A footer with only
|
|
118
|
+
* the logo column is valid.
|
|
108
119
|
*/
|
|
109
120
|
declare const validateFooterColumns: ArrayFieldValidation;
|
|
110
121
|
declare function validateFooterSocialUrl(value: unknown): true | string;
|
|
@@ -122,5 +133,5 @@ declare function getNavigation({
|
|
|
122
133
|
draft
|
|
123
134
|
}: GetNavigationArgs): Promise<NavigationDoc>;
|
|
124
135
|
//#endregion
|
|
125
|
-
export {
|
|
126
|
-
//# sourceMappingURL=published-
|
|
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-y1Nrly7r.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"published-
|
|
1
|
+
{"version":3,"file":"published-y1Nrly7r.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;AA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,iBAAA,GAAoB,OAAA,CAAQ,aAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bison-lab/payload-core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.34.0",
|
|
4
4
|
"description": "Site-agnostic Payload CMS configuration for Bison Lab sites: the SEO tab, the Theme global, the Roles Global, the brand-assets cupboard, and the metadata and theme readers for the pages they describe",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bison-lab",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"react-colorful": "^5.8.1",
|
|
59
|
-
"@bison-lab/admin-ui": "3.33.
|
|
59
|
+
"@bison-lab/admin-ui": "3.33.2"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"@bison-lab/fonts": "^3.0.0",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@payloadcms/live-preview-react": "^3.0.0",
|
|
66
66
|
"@payloadcms/plugin-redirects": "^3.0.0",
|
|
67
67
|
"@payloadcms/plugin-seo": "^3.0.0",
|
|
68
|
+
"@payloadcms/richtext-lexical": "^3.0.0",
|
|
68
69
|
"@payloadcms/ui": "^3.0.0",
|
|
69
70
|
"payload": "^3.0.0",
|
|
70
71
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -82,6 +83,9 @@
|
|
|
82
83
|
"@payloadcms/live-preview-react": {
|
|
83
84
|
"optional": true
|
|
84
85
|
},
|
|
86
|
+
"@payloadcms/richtext-lexical": {
|
|
87
|
+
"optional": true
|
|
88
|
+
},
|
|
85
89
|
"@payloadcms/ui": {
|
|
86
90
|
"optional": true
|
|
87
91
|
},
|
|
@@ -93,6 +97,7 @@
|
|
|
93
97
|
"@payloadcms/live-preview-react": "^3.88.0",
|
|
94
98
|
"@payloadcms/plugin-redirects": "3.88.0",
|
|
95
99
|
"@payloadcms/plugin-seo": "^3.88.0",
|
|
100
|
+
"@payloadcms/richtext-lexical": "^3.88.0",
|
|
96
101
|
"@payloadcms/ui": "^3.88.0",
|
|
97
102
|
"@testing-library/jest-dom": "^6.9.1",
|
|
98
103
|
"@testing-library/react": "^16.3.2",
|
|
@@ -105,9 +110,9 @@
|
|
|
105
110
|
"tsdown": "^0.21.0",
|
|
106
111
|
"typescript": "^5.9.3",
|
|
107
112
|
"vitest": "^4.1.2",
|
|
108
|
-
"@bison-lab/fonts": "3.27.1",
|
|
109
113
|
"@bison-lab/tokens": "3.27.1",
|
|
110
|
-
"@bison-lab/
|
|
114
|
+
"@bison-lab/fonts": "3.27.1",
|
|
115
|
+
"@bison-lab/ui": "3.33.2"
|
|
111
116
|
},
|
|
112
117
|
"publishConfig": {
|
|
113
118
|
"access": "public"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"published-DECGVhsR.mjs","names":[],"sources":["../src/navigation/link.ts","../src/navigation/footer.ts","../src/navigation/types.ts","../src/navigation/published.ts"],"sourcesContent":["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, so 25 + 25 + 25 + 25 is a full row. The logo column is in this total. */\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 column count. Used by the kit editor. */\nexport function normalizeFooterDesktop(count: number): FooterColumnWidth[] {\n return evenDesktop(count);\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\nfunction brandDesktopFromSibling(siblingData: unknown): FooterColumnWidth {\n const desktop = (siblingData as { brand?: { desktop?: string | null } } | null)?.brand?.desktop;\n if (desktop && desktop in FOOTER_TWELFTHS) return desktop as FooterColumnWidth;\n return \"25\";\n}\n\n/**\n * Desktop widths (logo column plus link columns) must add to 100%. Each\n * section needs a labeled destination before publish. Draft saves skip\n * field validation. A footer with only the logo column is valid.\n */\nexport const validateFooterColumns: ArrayFieldValidation = (value, options) => {\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 const twelfths =\n FOOTER_TWELFTHS[brandDesktopFromSibling(options?.siblingData)] +\n 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%.`;\n }\n\n if (columns.length === 0) return true;\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. Desktop widths must add to 100%.\",\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","/**\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 {\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":";;;;;;;AAQA,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,KAAK;AACnG,MAAM,gBAA2B,OAAO,gBACtC,WAAW,YAA+B,KAAK;AAE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