@orion-studios/payload-studio 0.5.0-beta.11 → 0.5.0-beta.111

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.
Files changed (77) hide show
  1. package/README.md +54 -0
  2. package/dist/admin/client.d.mts +3 -0
  3. package/dist/admin/client.d.ts +3 -0
  4. package/dist/admin/client.js +1745 -200
  5. package/dist/admin/client.mjs +1756 -214
  6. package/dist/admin/index.d.mts +2 -1
  7. package/dist/admin/index.d.ts +2 -1
  8. package/dist/admin/index.js +424 -11
  9. package/dist/admin/index.mjs +19 -1
  10. package/dist/admin-app/client.d.mts +7 -0
  11. package/dist/admin-app/client.d.ts +7 -0
  12. package/dist/admin-app/client.js +1270 -3
  13. package/dist/admin-app/client.mjs +1172 -2
  14. package/dist/admin-app/index.d.mts +1 -1
  15. package/dist/admin-app/index.d.ts +1 -1
  16. package/dist/admin-app/index.js +167 -0
  17. package/dist/admin-app/index.mjs +13 -1
  18. package/dist/admin-app/styles.css +247 -0
  19. package/dist/admin.css +8 -0
  20. package/dist/blocks/index.js +1011 -191
  21. package/dist/blocks/index.mjs +2 -2
  22. package/dist/chunk-ADIIWIYL.mjs +322 -0
  23. package/dist/{chunk-ZLLNO5FM.mjs → chunk-BET2YLAS.mjs} +104 -15
  24. package/dist/chunk-DAIZDGHL.mjs +614 -0
  25. package/dist/chunk-GKMBYYXF.mjs +776 -0
  26. package/dist/chunk-JQAHXYAM.mjs +1829 -0
  27. package/dist/chunk-OQSEJXC4.mjs +166 -0
  28. package/dist/chunk-PF3EBZXF.mjs +326 -0
  29. package/dist/chunk-ROTPP5CU.mjs +99 -0
  30. package/dist/chunk-XVH5SCBD.mjs +234 -0
  31. package/dist/chunk-ZTXJG4K5.mjs +85 -0
  32. package/dist/index-7lxTrxSG.d.mts +128 -0
  33. package/dist/index-7lxTrxSG.d.ts +128 -0
  34. package/dist/index-B7QvY3yF.d.mts +245 -0
  35. package/dist/index-BK03FiEM.d.ts +245 -0
  36. package/dist/{index-CmR6NInu.d.ts → index-BzKOThsI.d.mts} +30 -3
  37. package/dist/{index-CmR6NInu.d.mts → index-BzKOThsI.d.ts} +30 -3
  38. package/dist/{index-DbH0Ljwp.d.mts → index-D8BNfUJb.d.mts} +17 -2
  39. package/dist/{index-DbH0Ljwp.d.ts → index-DD_E2UfJ.d.ts} +17 -2
  40. package/dist/index-DUi_XND6.d.ts +193 -0
  41. package/dist/index-gLl_358v.d.mts +193 -0
  42. package/dist/index.d.mts +6 -5
  43. package/dist/index.d.ts +6 -5
  44. package/dist/index.js +2876 -460
  45. package/dist/index.mjs +12 -10
  46. package/dist/nextjs/index.d.mts +2 -1
  47. package/dist/nextjs/index.d.ts +2 -1
  48. package/dist/nextjs/index.js +497 -16
  49. package/dist/nextjs/index.mjs +8 -3
  50. package/dist/socialMedia-C05Iy-SV.d.mts +21 -0
  51. package/dist/socialMedia-C05Iy-SV.d.ts +21 -0
  52. package/dist/studio/index.d.mts +2 -1
  53. package/dist/studio/index.d.ts +2 -1
  54. package/dist/studio/index.js +171 -5
  55. package/dist/studio/index.mjs +7 -3
  56. package/dist/studio-pages/builder.css +517 -32
  57. package/dist/studio-pages/client.d.mts +75 -1
  58. package/dist/studio-pages/client.d.ts +75 -1
  59. package/dist/studio-pages/client.js +5662 -2759
  60. package/dist/studio-pages/client.mjs +5578 -2767
  61. package/dist/studio-pages/index.d.mts +4 -2
  62. package/dist/studio-pages/index.d.ts +4 -2
  63. package/dist/studio-pages/index.js +859 -71
  64. package/dist/studio-pages/index.mjs +10 -4
  65. package/package.json +35 -13
  66. package/dist/chunk-AAOHJDNS.mjs +0 -67
  67. package/dist/chunk-ETRRXURT.mjs +0 -141
  68. package/dist/chunk-J7W5EE3B.mjs +0 -278
  69. package/dist/chunk-N67KVM2S.mjs +0 -156
  70. package/dist/chunk-NESLJZFE.mjs +0 -303
  71. package/dist/chunk-U5BSPWAD.mjs +0 -1034
  72. package/dist/index-B9N5MyjF.d.mts +0 -39
  73. package/dist/index-BallJs-K.d.mts +0 -43
  74. package/dist/index-BallJs-K.d.ts +0 -43
  75. package/dist/index-DJFhANvJ.d.mts +0 -128
  76. package/dist/index-DJFhANvJ.d.ts +0 -128
  77. package/dist/index-g8tBHLKD.d.ts +0 -39
@@ -0,0 +1,614 @@
1
+ import {
2
+ SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM,
3
+ SOCIAL_MEDIA_ICON_OPTIONS,
4
+ SOCIAL_MEDIA_PLATFORMS,
5
+ SOCIAL_MEDIA_PLATFORM_LABELS
6
+ } from "./chunk-ZTXJG4K5.mjs";
7
+ import {
8
+ __export,
9
+ __require
10
+ } from "./chunk-6BWS3CLP.mjs";
11
+
12
+ // src/admin/index.ts
13
+ var admin_exports = {};
14
+ __export(admin_exports, {
15
+ SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM: () => SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM,
16
+ SOCIAL_MEDIA_ICON_OPTIONS: () => SOCIAL_MEDIA_ICON_OPTIONS,
17
+ SOCIAL_MEDIA_PLATFORMS: () => SOCIAL_MEDIA_PLATFORMS,
18
+ SOCIAL_MEDIA_PLATFORM_LABELS: () => SOCIAL_MEDIA_PLATFORM_LABELS,
19
+ configureAdmin: () => configureAdmin,
20
+ createHeaderNavItemsField: () => createHeaderNavItemsField,
21
+ createSocialMediaConnectionsField: () => createSocialMediaConnectionsField,
22
+ createSocialMediaGlobal: () => createSocialMediaGlobal,
23
+ createThemePreferenceField: () => createThemePreferenceField,
24
+ socialMediaConnectionsField: () => socialMediaConnectionsField,
25
+ themePreferenceField: () => themePreferenceField,
26
+ withTooltips: () => withTooltips
27
+ });
28
+
29
+ // src/admin/helpers/configureAdmin.ts
30
+ import fs from "fs";
31
+ import path from "path";
32
+ import { fileURLToPath } from "url";
33
+
34
+ // src/admin/fields/themePreference.ts
35
+ var createThemePreferenceField = (defaultTheme = "brand-light") => ({
36
+ name: "themePreference",
37
+ type: "select",
38
+ defaultValue: defaultTheme,
39
+ options: [
40
+ { label: "Light", value: "light" },
41
+ { label: "Dark", value: "dark" },
42
+ { label: "Brand Light", value: "brand-light" },
43
+ { label: "Brand Dark", value: "brand-dark" }
44
+ ],
45
+ admin: {
46
+ position: "sidebar",
47
+ condition: () => false
48
+ }
49
+ });
50
+ var themePreferenceField = createThemePreferenceField("brand-light");
51
+
52
+ // src/shared/studioSections.ts
53
+ var studioRoles = /* @__PURE__ */ new Set(["admin", "editor", "client"]);
54
+ var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
55
+ var isAbsoluteExternalURL = (value) => /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value) || value.startsWith("//");
56
+ var normalizePathLikeValue = (value) => {
57
+ const trimmed = value.trim();
58
+ if (!trimmed) {
59
+ return "";
60
+ }
61
+ if (isAbsoluteExternalURL(trimmed)) {
62
+ return trimmed;
63
+ }
64
+ const withLeadingSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
65
+ const normalized = withLeadingSlash.replace(/\/+$/, "");
66
+ return normalized || "/";
67
+ };
68
+ var normalizeStringArray = (value) => {
69
+ if (!Array.isArray(value)) {
70
+ return [];
71
+ }
72
+ return value.filter((entry) => typeof entry === "string").map((entry) => normalizePathLikeValue(entry)).filter((entry) => entry.length > 0);
73
+ };
74
+ var normalizeRoles = (value) => {
75
+ if (!Array.isArray(value)) {
76
+ return void 0;
77
+ }
78
+ const roles = value.filter((entry) => typeof entry === "string" && studioRoles.has(entry));
79
+ return roles.length > 0 ? roles : void 0;
80
+ };
81
+ var normalizeCard = (value) => {
82
+ if (!isRecord(value) || typeof value.title !== "string") {
83
+ return void 0;
84
+ }
85
+ const title = value.title.trim();
86
+ if (!title) {
87
+ return void 0;
88
+ }
89
+ return {
90
+ title,
91
+ ...typeof value.description === "string" && value.description.trim().length > 0 ? { description: value.description.trim() } : {}
92
+ };
93
+ };
94
+ var resolveStudioSections = (value) => {
95
+ if (!Array.isArray(value)) {
96
+ return [];
97
+ }
98
+ const sections = [];
99
+ const seen = /* @__PURE__ */ new Set();
100
+ for (const entry of value) {
101
+ if (!isRecord(entry) || typeof entry.id !== "string" || typeof entry.label !== "string") {
102
+ continue;
103
+ }
104
+ const id = entry.id.trim();
105
+ const label = entry.label.trim();
106
+ if (!id || !label || seen.has(id)) {
107
+ continue;
108
+ }
109
+ const href = typeof entry.href === "string" && entry.href.trim().length > 0 ? normalizePathLikeValue(entry.href) : isRecord(entry.view) && typeof entry.view.path === "string" ? normalizePathLikeValue(entry.view.path) : "";
110
+ if (!href) {
111
+ continue;
112
+ }
113
+ const matchPrefixes = Array.from(/* @__PURE__ */ new Set([href, ...normalizeStringArray(entry.matchPrefixes)]));
114
+ sections.push({
115
+ id,
116
+ label,
117
+ href,
118
+ matchPrefixes,
119
+ ...normalizeRoles(entry.roles) ? { roles: normalizeRoles(entry.roles) } : {},
120
+ ...normalizeCard(entry.card) ? { card: normalizeCard(entry.card) } : {}
121
+ });
122
+ seen.add(id);
123
+ }
124
+ return sections;
125
+ };
126
+ var resolveStudioSectionViews = (value) => {
127
+ if (!Array.isArray(value)) {
128
+ return {};
129
+ }
130
+ const views = {};
131
+ for (const entry of value) {
132
+ if (!isRecord(entry) || typeof entry.id !== "string" || !isRecord(entry.view)) {
133
+ continue;
134
+ }
135
+ const id = entry.id.trim();
136
+ const view = entry.view;
137
+ const component = isRecord(view.Component) ? view.Component : null;
138
+ if (!id || typeof view.path !== "string" || !component || typeof component.exportName !== "string" || typeof component.path !== "string") {
139
+ continue;
140
+ }
141
+ const path2 = normalizePathLikeValue(view.path);
142
+ const componentPath = component.path.trim();
143
+ const exportName = component.exportName.trim();
144
+ if (!path2 || !componentPath || !exportName) {
145
+ continue;
146
+ }
147
+ views[id] = {
148
+ path: path2,
149
+ Component: {
150
+ exportName,
151
+ path: componentPath,
152
+ ...isRecord(component.clientProps) ? { clientProps: component.clientProps } : {}
153
+ }
154
+ };
155
+ }
156
+ return views;
157
+ };
158
+
159
+ // src/admin/helpers/configureAdmin.ts
160
+ function getPkgDistDir() {
161
+ try {
162
+ if (typeof import.meta?.url === "string") {
163
+ return path.dirname(fileURLToPath(import.meta.url));
164
+ }
165
+ } catch {
166
+ }
167
+ if (typeof __dirname === "string") {
168
+ return __dirname;
169
+ }
170
+ try {
171
+ const pkgJson = __require.resolve("@orion-studios/payload-studio/package.json");
172
+ return path.resolve(path.dirname(pkgJson), "dist");
173
+ } catch {
174
+ return process.cwd();
175
+ }
176
+ }
177
+ function configureAdmin(config) {
178
+ const {
179
+ brandName,
180
+ brandPrimary = "#3b82f6",
181
+ brandSecondary = "#8b5cf6",
182
+ defaultTheme = "brand-light",
183
+ logoUrl
184
+ } = config;
185
+ const studioEnabled = config.studio?.enabled ?? true;
186
+ const formsEnabled = config.studio?.forms?.enabled ?? false;
187
+ const formsCollectionSlug = config.studio?.forms?.collectionSlug || "forms";
188
+ const formSubmissionsCollectionSlug = config.studio?.forms?.submissionsCollectionSlug || "form-submissions";
189
+ const formUploadsCollectionSlug = config.studio?.forms?.uploadsCollectionSlug || "form-uploads";
190
+ const pagesCollectionSlug = config.studio?.pages?.collectionSlug || "pages";
191
+ const mediaCollectionSlug = config.studio?.media?.collectionSlug || "media";
192
+ const contactFormStudioPath = "/studio-contact-form";
193
+ const configuredGlobals = config.studio?.globals || [
194
+ { slug: "site-settings", label: "Website Settings" },
195
+ { slug: "header", label: "Header & Navigation" },
196
+ { slug: "footer", label: "Footer" },
197
+ { slug: "contact-form", label: "Contact Form" }
198
+ ];
199
+ const globals = configuredGlobals.map((global) => {
200
+ if (global.slug !== "contact-form" || global.href) {
201
+ return global;
202
+ }
203
+ return {
204
+ ...global,
205
+ href: contactFormStudioPath
206
+ };
207
+ });
208
+ const studioSections = resolveStudioSections(config.studio?.sections || []);
209
+ const studioSectionViews = resolveStudioSectionViews(config.studio?.sections || []);
210
+ let cssPath;
211
+ const pkgDist = getPkgDistDir();
212
+ const sourceCssPath = path.resolve(pkgDist, "admin.css");
213
+ if (config.basePath && fs.existsSync(sourceCssPath)) {
214
+ let css = fs.readFileSync(sourceCssPath, "utf-8");
215
+ css = css.replace("--brand-primary: #3b82f6;", `--brand-primary: ${brandPrimary};`);
216
+ css = css.replace("--brand-secondary: #8b5cf6;", `--brand-secondary: ${brandSecondary};`);
217
+ const genDir = path.resolve(config.basePath, ".generated");
218
+ if (!fs.existsSync(genDir)) {
219
+ fs.mkdirSync(genDir, { recursive: true });
220
+ }
221
+ const genPath = path.resolve(genDir, "admin.css");
222
+ fs.writeFileSync(genPath, css);
223
+ cssPath = genPath;
224
+ } else {
225
+ cssPath = sourceCssPath;
226
+ }
227
+ const clientPath = "@orion-studios/payload-studio/admin/client";
228
+ return {
229
+ admin: {
230
+ css: cssPath,
231
+ components: {
232
+ ...studioEnabled ? {
233
+ Nav: {
234
+ exportName: "AdminStudioNav",
235
+ path: clientPath,
236
+ clientProps: {
237
+ brandName,
238
+ logoUrl,
239
+ globalsBasePath: "/studio-globals",
240
+ globalsExtraMatchPrefixes: [contactFormStudioPath],
241
+ formSubmissionsCollectionSlug,
242
+ formsCollectionSlug,
243
+ formsEnabled,
244
+ formUploadsCollectionSlug,
245
+ mediaCollectionSlug,
246
+ pagesCollectionSlug,
247
+ sections: studioSections
248
+ }
249
+ }
250
+ } : {},
251
+ graphics: {
252
+ Logo: {
253
+ exportName: "Logo",
254
+ path: clientPath,
255
+ clientProps: {
256
+ brandName,
257
+ logoUrl
258
+ }
259
+ },
260
+ Icon: {
261
+ exportName: "Icon",
262
+ path: clientPath,
263
+ clientProps: {
264
+ brandName,
265
+ logoUrl
266
+ }
267
+ }
268
+ },
269
+ views: {
270
+ dashboard: {
271
+ Component: {
272
+ exportName: studioEnabled ? "AdminStudioDashboard" : "Dashboard",
273
+ path: clientPath,
274
+ clientProps: {
275
+ brandName,
276
+ logoUrl,
277
+ globalsBasePath: "/studio-globals",
278
+ globalsExtraMatchPrefixes: [contactFormStudioPath],
279
+ formSubmissionsCollectionSlug,
280
+ formsCollectionSlug,
281
+ formsEnabled,
282
+ formUploadsCollectionSlug,
283
+ mediaCollectionSlug,
284
+ pagesCollectionSlug,
285
+ sections: studioSections
286
+ }
287
+ }
288
+ },
289
+ ...studioEnabled ? {
290
+ studioGlobals: {
291
+ path: "/studio-globals",
292
+ Component: {
293
+ exportName: "AdminStudioGlobalsView",
294
+ path: clientPath,
295
+ clientProps: {
296
+ globals,
297
+ globalsBasePath: "/studio-globals"
298
+ }
299
+ }
300
+ },
301
+ studioContactForm: {
302
+ path: "/studio-contact-form",
303
+ Component: {
304
+ exportName: "AdminStudioContactFormView",
305
+ path: clientPath,
306
+ clientProps: {
307
+ globalSlug: "contact-form",
308
+ globalsBasePath: "/studio-globals"
309
+ }
310
+ }
311
+ },
312
+ ...formsEnabled ? {
313
+ studioForms: {
314
+ path: "/studio-forms",
315
+ Component: {
316
+ exportName: "AdminStudioFormsView",
317
+ path: clientPath,
318
+ clientProps: {
319
+ formsCollectionSlug,
320
+ formSubmissionsCollectionSlug,
321
+ formUploadsCollectionSlug
322
+ }
323
+ }
324
+ }
325
+ } : {},
326
+ ...Object.fromEntries(
327
+ Object.entries(studioSectionViews).map(([id, view]) => [
328
+ id,
329
+ {
330
+ path: view.path,
331
+ Component: view.Component
332
+ }
333
+ ])
334
+ )
335
+ } : {}
336
+ },
337
+ providers: [
338
+ {
339
+ exportName: "ThemeProvider",
340
+ path: clientPath,
341
+ clientProps: {
342
+ defaultTheme
343
+ }
344
+ }
345
+ ],
346
+ afterNavLinks: [
347
+ {
348
+ exportName: "ThemeSwitcher",
349
+ path: clientPath,
350
+ clientProps: {
351
+ defaultTheme
352
+ }
353
+ }
354
+ ]
355
+ },
356
+ meta: {
357
+ titleSuffix: ` \u2014 ${brandName}`
358
+ }
359
+ },
360
+ brandName,
361
+ brandPrimary,
362
+ brandSecondary,
363
+ defaultTheme,
364
+ wrapUsers(usersCollection) {
365
+ const existingFields = usersCollection.fields || [];
366
+ const hasThemePreference = existingFields.some(
367
+ (field) => typeof field === "object" && field !== null && "name" in field && field.name === "themePreference"
368
+ );
369
+ return {
370
+ ...usersCollection,
371
+ fields: hasThemePreference ? existingFields : [...existingFields, createThemePreferenceField(defaultTheme)]
372
+ };
373
+ },
374
+ wrapGlobals(globals2) {
375
+ const labelMap = {
376
+ header: { group: "Site Design", label: "Header & Navigation" },
377
+ footer: { group: "Site Design", label: "Footer" },
378
+ "site-settings": { group: "Site Design", label: "Website Settings" },
379
+ "social-media": { group: "Site Design", label: "Social Media" },
380
+ "contact-form": { group: "Lead Forms", label: "Contact Form" }
381
+ };
382
+ return globals2.map((global) => {
383
+ const mapping = labelMap[global.slug];
384
+ if (!mapping) return global;
385
+ const shouldAttachContactFormRedirect = studioEnabled && global.slug === "contact-form";
386
+ const existingViews = global.admin?.components?.views;
387
+ const existingEditViews = existingViews?.edit;
388
+ const hasCustomContactFormEditView = Boolean(
389
+ existingEditViews?.root || existingEditViews?.default && typeof existingEditViews.default === "object" && existingEditViews.default.Component
390
+ );
391
+ const contactFormEditViews = shouldAttachContactFormRedirect && !hasCustomContactFormEditView ? {
392
+ ...existingEditViews,
393
+ default: {
394
+ ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
395
+ Component: {
396
+ exportName: "StudioContactFormRedirect",
397
+ path: clientPath,
398
+ clientProps: {
399
+ studioContactFormPath: contactFormStudioPath
400
+ }
401
+ }
402
+ }
403
+ } : existingEditViews;
404
+ return {
405
+ ...global,
406
+ admin: {
407
+ ...global.admin,
408
+ group: mapping.group,
409
+ components: {
410
+ ...global.admin?.components,
411
+ ...shouldAttachContactFormRedirect ? {
412
+ views: {
413
+ ...existingViews,
414
+ ...contactFormEditViews ? {
415
+ edit: contactFormEditViews
416
+ } : {}
417
+ }
418
+ } : {}
419
+ }
420
+ },
421
+ label: mapping.label
422
+ };
423
+ });
424
+ }
425
+ };
426
+ }
427
+
428
+ // src/admin/helpers/withTooltips.ts
429
+ var defaultTooltips = {
430
+ title: "The main title displayed on this page.",
431
+ slug: 'The URL-friendly name for this page (e.g., "about-us"). This appears in the web address.',
432
+ template: "Choose a layout template. This controls the overall structure of the page.",
433
+ parent: "Select a parent page to nest this page under. This affects the URL path.",
434
+ path: "The full URL path for this page. This is automatically generated from the slug and parent.",
435
+ layout: "Add and arrange content sections on your page. Each section is a building block.",
436
+ metaTitle: "The title shown in search engine results and browser tabs. Keep under 60 characters.",
437
+ metaDescription: "A brief summary shown in search results. Keep under 160 characters for best results.",
438
+ canonicalUrl: "The preferred URL for this page. Used to prevent duplicate content in search engines.",
439
+ ogImage: "The image shown when this page is shared on social media (Facebook, LinkedIn, etc.).",
440
+ noIndex: "When enabled, search engines will not list this page in results.",
441
+ noFollow: "When enabled, search engines will not follow links on this page.",
442
+ publishedAt: "The date and time this page was first published.",
443
+ alt: "Describe this image for screen readers and search engines. Be specific and concise.",
444
+ navItems: "The links shown in your website's navigation menu.",
445
+ copyright: "The copyright text displayed in your website footer.",
446
+ contactEmail: "The email address displayed in your footer and contact sections.",
447
+ contactPhone: "The phone number displayed in your footer and contact sections.",
448
+ siteName: "Your website's name. Appears in browser tabs and search results.",
449
+ tagline: "A short phrase describing your business. Used in SEO and site metadata.",
450
+ canonicalBaseUrl: 'The base URL of your website (e.g., "https://example.com"). Used for generating canonical URLs.'
451
+ };
452
+ function withTooltips(fields, customTooltips) {
453
+ const tooltips = { ...defaultTooltips, ...customTooltips };
454
+ return fields.map((field) => addTooltipToField(field, tooltips));
455
+ }
456
+ function addTooltipToField(field, tooltips) {
457
+ if ("name" in field && field.name && tooltips[field.name]) {
458
+ const tooltip = tooltips[field.name];
459
+ const admin = field.admin;
460
+ if (!admin?.description) {
461
+ return {
462
+ ...field,
463
+ admin: {
464
+ ...admin,
465
+ description: tooltip
466
+ }
467
+ };
468
+ }
469
+ }
470
+ if ("fields" in field && Array.isArray(field.fields)) {
471
+ return {
472
+ ...field,
473
+ fields: field.fields.map((f) => addTooltipToField(f, tooltips))
474
+ };
475
+ }
476
+ if ("tabs" in field && Array.isArray(field.tabs)) {
477
+ return {
478
+ ...field,
479
+ tabs: field.tabs.map((tab) => ({
480
+ ...tab,
481
+ fields: tab.fields ? tab.fields.map((f) => addTooltipToField(f, tooltips)) : tab.fields
482
+ }))
483
+ };
484
+ }
485
+ return field;
486
+ }
487
+
488
+ // src/admin/fields/headerNav.ts
489
+ var createHeaderNavItemsField = () => ({
490
+ name: "navItems",
491
+ type: "array",
492
+ labels: { singular: "Navigation Link", plural: "Navigation Links" },
493
+ admin: {
494
+ description: "The links displayed in your website's main navigation menu."
495
+ },
496
+ fields: [
497
+ {
498
+ name: "label",
499
+ type: "text",
500
+ required: true,
501
+ admin: {
502
+ description: "The text shown for this navigation link."
503
+ }
504
+ },
505
+ {
506
+ name: "href",
507
+ type: "text",
508
+ required: true,
509
+ admin: {
510
+ description: 'The URL this link points to (e.g., "/about" or "https://example.com").'
511
+ }
512
+ },
513
+ {
514
+ name: "parentHref",
515
+ type: "text",
516
+ admin: {
517
+ description: "Optional parent link URL. If set to another nav item href, this item appears in that dropdown."
518
+ }
519
+ }
520
+ ]
521
+ });
522
+
523
+ // src/admin/fields/socialMedia.ts
524
+ var DEFAULT_DESCRIPTION = "Add profile URLs and choose one of two icon styles for each platform. Leave a URL blank to hide that profile on your site.";
525
+ function validateOptionalHttpsUrl(value) {
526
+ if (value === null || value === void 0 || value === "") {
527
+ return true;
528
+ }
529
+ if (typeof value !== "string") {
530
+ return "Enter a valid URL.";
531
+ }
532
+ try {
533
+ const url = new URL(value);
534
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
535
+ return "Use an http:// or https:// URL.";
536
+ }
537
+ return true;
538
+ } catch {
539
+ return "Enter a valid URL (for example: https://instagram.com/yourbrand).";
540
+ }
541
+ }
542
+ function createPlatformField(platform) {
543
+ const platformLabel = SOCIAL_MEDIA_PLATFORM_LABELS[platform];
544
+ const iconOptions = SOCIAL_MEDIA_ICON_OPTIONS[platform].map((option) => ({
545
+ label: option.label,
546
+ value: option.value
547
+ }));
548
+ return {
549
+ name: platform,
550
+ type: "group",
551
+ label: platformLabel,
552
+ fields: [
553
+ {
554
+ name: "url",
555
+ type: "text",
556
+ admin: {
557
+ description: `Full ${platformLabel} profile URL. Leave blank to hide ${platformLabel}.`
558
+ },
559
+ validate: validateOptionalHttpsUrl
560
+ },
561
+ {
562
+ name: "icon",
563
+ type: "select",
564
+ defaultValue: SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM[platform],
565
+ options: iconOptions,
566
+ admin: {
567
+ description: "Pick which icon style to display for this platform."
568
+ }
569
+ }
570
+ ]
571
+ };
572
+ }
573
+ var createSocialMediaConnectionsField = (options = {}) => {
574
+ const selectedPlatforms = Array.isArray(options.platforms) && options.platforms.length > 0 ? options.platforms : SOCIAL_MEDIA_PLATFORMS;
575
+ return {
576
+ name: options.name || "profiles",
577
+ type: "group",
578
+ label: options.label || "Social Media Profiles",
579
+ admin: {
580
+ description: options.description || DEFAULT_DESCRIPTION
581
+ },
582
+ fields: selectedPlatforms.map((platform) => createPlatformField(platform))
583
+ };
584
+ };
585
+ var socialMediaConnectionsField = createSocialMediaConnectionsField();
586
+
587
+ // src/admin/globals/socialMedia.ts
588
+ var createSocialMediaGlobal = (options = {}) => ({
589
+ slug: options.slug || "social-media",
590
+ label: "Social Media",
591
+ admin: {
592
+ description: options.description || "Manage social profile links and icon variants used across your website.",
593
+ group: "Site Design"
594
+ },
595
+ fields: [
596
+ createSocialMediaConnectionsField({
597
+ ...options.fieldOptions,
598
+ label: "Profiles",
599
+ name: "profiles"
600
+ })
601
+ ]
602
+ });
603
+
604
+ export {
605
+ createThemePreferenceField,
606
+ themePreferenceField,
607
+ configureAdmin,
608
+ withTooltips,
609
+ createHeaderNavItemsField,
610
+ createSocialMediaConnectionsField,
611
+ socialMediaConnectionsField,
612
+ createSocialMediaGlobal,
613
+ admin_exports
614
+ };