@orion-studios/payload-studio 0.5.0-beta.98 → 0.6.0-beta.1

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 (63) hide show
  1. package/README.md +58 -68
  2. package/dist/admin/client.d.mts +5 -0
  3. package/dist/admin/client.d.ts +5 -0
  4. package/dist/admin/client.js +4491 -736
  5. package/dist/admin/client.mjs +3367 -752
  6. package/dist/admin/index.d.mts +2 -1
  7. package/dist/admin/index.d.ts +2 -1
  8. package/dist/admin/index.js +498 -53
  9. package/dist/admin/index.mjs +2 -1
  10. package/dist/admin-app/client.d.mts +1 -0
  11. package/dist/admin-app/client.d.ts +1 -0
  12. package/dist/admin-app/client.js +285 -109
  13. package/dist/admin-app/client.mjs +59 -871
  14. package/dist/admin-app/index.d.mts +2 -1
  15. package/dist/admin-app/index.d.ts +2 -1
  16. package/dist/admin-app/index.mjs +5 -3
  17. package/dist/admin-app/styles.css +1708 -56
  18. package/dist/admin.css +158 -35
  19. package/dist/blocks/index.js +415 -200
  20. package/dist/blocks/index.mjs +2 -2
  21. package/dist/{chunk-XK3K5GRP.mjs → chunk-JQAHXYAM.mjs} +271 -67
  22. package/dist/chunk-KPIX7OSV.mjs +1051 -0
  23. package/dist/chunk-OQSEJXC4.mjs +166 -0
  24. package/dist/{chunk-XHWQJUX5.mjs → chunk-OTHERBGX.mjs} +3 -3
  25. package/dist/chunk-PF3EBZXF.mjs +326 -0
  26. package/dist/chunk-Q2HGC67S.mjs +904 -0
  27. package/dist/{chunk-XVH5SCBD.mjs → chunk-RKTIFEUY.mjs} +4 -19
  28. package/dist/chunk-W2UOCJDX.mjs +32 -0
  29. package/dist/{chunk-C4J35SPJ.mjs → chunk-XKUTZ7IU.mjs} +257 -452
  30. package/dist/{index-ZbOx4OCF.d.ts → index-52HdVLQq.d.ts} +12 -22
  31. package/dist/index-BMitiKK8.d.ts +435 -0
  32. package/dist/index-Crx_MtPw.d.ts +223 -0
  33. package/dist/index-Cv-6qnrw.d.mts +223 -0
  34. package/dist/{index-ZbOx4OCF.d.mts → index-DEQC3Dwj.d.mts} +12 -22
  35. package/dist/{index-BIwu3qIH.d.mts → index-DWmudwDm.d.mts} +2 -1
  36. package/dist/{index-BIwu3qIH.d.ts → index-DWmudwDm.d.ts} +2 -1
  37. package/dist/index-D_b24Gef.d.mts +435 -0
  38. package/dist/index.d.mts +5 -4
  39. package/dist/index.d.ts +5 -4
  40. package/dist/index.js +1968 -1198
  41. package/dist/index.mjs +10 -8
  42. package/dist/nextjs/index.js +5 -684
  43. package/dist/nextjs/index.mjs +2 -3
  44. package/dist/sitePreviewTypes-BkHCWxNW.d.mts +58 -0
  45. package/dist/sitePreviewTypes-BkHCWxNW.d.ts +58 -0
  46. package/dist/studio/index.d.mts +1 -1
  47. package/dist/studio/index.d.ts +1 -1
  48. package/dist/studio-pages/builder.css +125 -83
  49. package/dist/studio-pages/client.d.mts +58 -1
  50. package/dist/studio-pages/client.d.ts +58 -1
  51. package/dist/studio-pages/client.js +450 -241
  52. package/dist/studio-pages/client.mjs +455 -247
  53. package/dist/studio-pages/index.d.mts +3 -2
  54. package/dist/studio-pages/index.d.ts +3 -2
  55. package/dist/studio-pages/index.js +418 -183
  56. package/dist/studio-pages/index.mjs +15 -6
  57. package/package.json +19 -5
  58. package/dist/chunk-2FO2ROW4.mjs +0 -468
  59. package/dist/chunk-SIL2J5MF.mjs +0 -155
  60. package/dist/index-BFXZue5i.d.ts +0 -178
  61. package/dist/index-CoYRBbf6.d.mts +0 -178
  62. package/dist/index-R7hA134j.d.mts +0 -140
  63. package/dist/index-vjrjy0P4.d.ts +0 -140
@@ -0,0 +1,904 @@
1
+ import {
2
+ adminNavIcons
3
+ } from "./chunk-W2UOCJDX.mjs";
4
+ import {
5
+ SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM,
6
+ SOCIAL_MEDIA_ICON_OPTIONS,
7
+ SOCIAL_MEDIA_PLATFORMS,
8
+ SOCIAL_MEDIA_PLATFORM_LABELS
9
+ } from "./chunk-ZTXJG4K5.mjs";
10
+ import {
11
+ __export,
12
+ __require
13
+ } from "./chunk-6BWS3CLP.mjs";
14
+
15
+ // src/admin/index.ts
16
+ var admin_exports = {};
17
+ __export(admin_exports, {
18
+ SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM: () => SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM,
19
+ SOCIAL_MEDIA_ICON_OPTIONS: () => SOCIAL_MEDIA_ICON_OPTIONS,
20
+ SOCIAL_MEDIA_PLATFORMS: () => SOCIAL_MEDIA_PLATFORMS,
21
+ SOCIAL_MEDIA_PLATFORM_LABELS: () => SOCIAL_MEDIA_PLATFORM_LABELS,
22
+ configureAdmin: () => configureAdmin,
23
+ createHeaderNavItemsField: () => createHeaderNavItemsField,
24
+ createSocialMediaConnectionsField: () => createSocialMediaConnectionsField,
25
+ createSocialMediaGlobal: () => createSocialMediaGlobal,
26
+ createThemePreferenceField: () => createThemePreferenceField,
27
+ socialMediaConnectionsField: () => socialMediaConnectionsField,
28
+ themePreferenceField: () => themePreferenceField,
29
+ withTooltips: () => withTooltips
30
+ });
31
+
32
+ // src/admin/helpers/configureAdmin.ts
33
+ import fs from "fs";
34
+ import path from "path";
35
+ import { fileURLToPath } from "url";
36
+
37
+ // src/admin/fields/themePreference.ts
38
+ var createThemePreferenceField = (defaultTheme = "brand-light") => ({
39
+ name: "themePreference",
40
+ type: "select",
41
+ defaultValue: defaultTheme,
42
+ options: [
43
+ { label: "Light", value: "light" },
44
+ { label: "Dark", value: "dark" },
45
+ { label: "Brand Light", value: "brand-light" },
46
+ { label: "Brand Dark", value: "brand-dark" }
47
+ ],
48
+ admin: {
49
+ position: "sidebar",
50
+ condition: () => false
51
+ }
52
+ });
53
+ var themePreferenceField = createThemePreferenceField("brand-light");
54
+
55
+ // src/shared/studioSections.ts
56
+ var studioRoles = /* @__PURE__ */ new Set(["admin", "editor", "client"]);
57
+ var studioIcons = new Set(adminNavIcons);
58
+ var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
59
+ var isAbsoluteExternalURL = (value) => /^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(value) || value.startsWith("//");
60
+ var normalizePathLikeValue = (value) => {
61
+ const trimmed = value.trim();
62
+ if (!trimmed) {
63
+ return "";
64
+ }
65
+ if (isAbsoluteExternalURL(trimmed)) {
66
+ return trimmed;
67
+ }
68
+ const withLeadingSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
69
+ const normalized = withLeadingSlash.replace(/\/+$/, "");
70
+ return normalized || "/";
71
+ };
72
+ var normalizeStringArray = (value) => {
73
+ if (!Array.isArray(value)) {
74
+ return [];
75
+ }
76
+ return value.filter((entry) => typeof entry === "string").map((entry) => normalizePathLikeValue(entry)).filter((entry) => entry.length > 0);
77
+ };
78
+ var normalizeRoles = (value) => {
79
+ if (!Array.isArray(value)) {
80
+ return void 0;
81
+ }
82
+ const roles = value.filter((entry) => typeof entry === "string" && studioRoles.has(entry));
83
+ return roles.length > 0 ? roles : void 0;
84
+ };
85
+ var normalizeCard = (value) => {
86
+ if (!isRecord(value) || typeof value.title !== "string") {
87
+ return void 0;
88
+ }
89
+ const title = value.title.trim();
90
+ if (!title) {
91
+ return void 0;
92
+ }
93
+ return {
94
+ title,
95
+ ...typeof value.description === "string" && value.description.trim().length > 0 ? { description: value.description.trim() } : {}
96
+ };
97
+ };
98
+ var normalizeIcon = (value) => typeof value === "string" && studioIcons.has(value) ? value : void 0;
99
+ var resolveStudioSections = (value) => {
100
+ if (!Array.isArray(value)) {
101
+ return [];
102
+ }
103
+ const sections = [];
104
+ const seen = /* @__PURE__ */ new Set();
105
+ for (const entry of value) {
106
+ if (!isRecord(entry) || typeof entry.id !== "string" || typeof entry.label !== "string") {
107
+ continue;
108
+ }
109
+ const id = entry.id.trim();
110
+ const label = entry.label.trim();
111
+ if (!id || !label || seen.has(id)) {
112
+ continue;
113
+ }
114
+ 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) : "";
115
+ if (!href) {
116
+ continue;
117
+ }
118
+ const matchPrefixes = Array.from(/* @__PURE__ */ new Set([href, ...normalizeStringArray(entry.matchPrefixes)]));
119
+ sections.push({
120
+ id,
121
+ label,
122
+ href,
123
+ matchPrefixes,
124
+ ...normalizeIcon(entry.icon) ? { icon: normalizeIcon(entry.icon) } : {},
125
+ ...normalizeRoles(entry.roles) ? { roles: normalizeRoles(entry.roles) } : {},
126
+ ...normalizeCard(entry.card) ? { card: normalizeCard(entry.card) } : {}
127
+ });
128
+ seen.add(id);
129
+ }
130
+ return sections;
131
+ };
132
+ var resolveStudioSectionViews = (value) => {
133
+ if (!Array.isArray(value)) {
134
+ return {};
135
+ }
136
+ const views = {};
137
+ for (const entry of value) {
138
+ if (!isRecord(entry) || typeof entry.id !== "string" || !isRecord(entry.view)) {
139
+ continue;
140
+ }
141
+ const id = entry.id.trim();
142
+ const view = entry.view;
143
+ const component = isRecord(view.Component) ? view.Component : null;
144
+ if (!id || typeof view.path !== "string" || !component || typeof component.exportName !== "string" || typeof component.path !== "string") {
145
+ continue;
146
+ }
147
+ const path2 = normalizePathLikeValue(view.path);
148
+ const componentPath = component.path.trim();
149
+ const exportName = component.exportName.trim();
150
+ if (!path2 || !componentPath || !exportName) {
151
+ continue;
152
+ }
153
+ views[id] = {
154
+ path: path2,
155
+ Component: {
156
+ exportName,
157
+ path: componentPath,
158
+ ...isRecord(component.clientProps) ? { clientProps: component.clientProps } : {}
159
+ }
160
+ };
161
+ }
162
+ return views;
163
+ };
164
+
165
+ // src/admin/helpers/configureAdmin.ts
166
+ function getPkgDistDir() {
167
+ try {
168
+ if (typeof import.meta?.url === "string") {
169
+ return path.dirname(fileURLToPath(import.meta.url));
170
+ }
171
+ } catch {
172
+ }
173
+ if (typeof __dirname === "string") {
174
+ return __dirname;
175
+ }
176
+ try {
177
+ const pkgJson = __require.resolve("@orion-studios/payload-studio/package.json");
178
+ return path.resolve(path.dirname(pkgJson), "dist");
179
+ } catch {
180
+ return process.cwd();
181
+ }
182
+ }
183
+ function configureAdmin(config) {
184
+ const {
185
+ brandName,
186
+ brandPrimary = "#3b82f6",
187
+ brandSecondary = "#8b5cf6",
188
+ defaultTheme = "brand-light",
189
+ logoUrl,
190
+ allowThemePreference = false
191
+ } = config;
192
+ const studioEnabled = config.studio?.enabled ?? true;
193
+ const formsEnabled = config.studio?.forms?.enabled ?? false;
194
+ const formsCollectionSlug = config.studio?.forms?.collectionSlug || "forms";
195
+ const formSubmissionsCollectionSlug = config.studio?.forms?.submissionsCollectionSlug || "form-submissions";
196
+ const formUploadsCollectionSlug = config.studio?.forms?.uploadsCollectionSlug || "form-uploads";
197
+ const pagesCollectionSlug = config.studio?.pages?.collectionSlug || "pages";
198
+ const builderBasePath = config.studio?.pages?.builderBasePath || "/builder";
199
+ const mediaCollectionSlug = config.studio?.media?.collectionSlug || "media";
200
+ const globalsBasePath = "/site-globals";
201
+ const pagesBasePath = "/pages";
202
+ const formsBasePath = "/forms";
203
+ const mediaBasePath = "/media";
204
+ const toolsBasePath = "/tools";
205
+ const contactFormStudioPath = "/contact-form";
206
+ const configuredGlobals = config.studio?.globals || [
207
+ { slug: "site-settings", label: "Website Settings" },
208
+ { slug: "header", label: "Header & Navigation" },
209
+ { slug: "footer", label: "Footer" },
210
+ { slug: "social-media", label: "Social Media" }
211
+ ];
212
+ const globals = configuredGlobals.map((global) => {
213
+ if (global.slug !== "contact-form" || global.href) {
214
+ return global;
215
+ }
216
+ return {
217
+ ...global,
218
+ href: contactFormStudioPath
219
+ };
220
+ });
221
+ const studioSections = resolveStudioSections(config.studio?.sections || []);
222
+ const studioSectionViews = resolveStudioSectionViews(config.studio?.sections || []);
223
+ const sitePreview = config.studio?.sitePreview;
224
+ let cssPath;
225
+ const pkgDist = getPkgDistDir();
226
+ const sourceCssPath = path.resolve(pkgDist, "admin.css");
227
+ const adminAppCssPath = path.resolve(pkgDist, "admin-app", "styles.css");
228
+ const cssSources = [sourceCssPath, adminAppCssPath].filter((filePath) => fs.existsSync(filePath));
229
+ if (cssSources.length === 0) {
230
+ cssPath = sourceCssPath;
231
+ } else {
232
+ let css = cssSources.map((filePath) => fs.readFileSync(filePath, "utf-8")).join("\n\n");
233
+ css = css.replace(
234
+ "--orion-cms-brand-primary-fallback: #3b82f6;",
235
+ `--orion-cms-brand-primary-fallback: ${brandPrimary};`
236
+ );
237
+ css = css.replace(
238
+ "--orion-cms-brand-secondary-fallback: #8b5cf6;",
239
+ `--orion-cms-brand-secondary-fallback: ${brandSecondary};`
240
+ );
241
+ const outputBasePath = config.basePath || process.cwd();
242
+ const genDir = path.resolve(outputBasePath, ".generated");
243
+ if (!fs.existsSync(genDir)) {
244
+ fs.mkdirSync(genDir, { recursive: true });
245
+ }
246
+ const genPath = path.resolve(genDir, "admin.css");
247
+ fs.writeFileSync(genPath, css);
248
+ cssPath = genPath;
249
+ }
250
+ const clientPath = "@orion-studios/payload-studio/admin/client";
251
+ const studioNavClientProps = {
252
+ brandName,
253
+ formSubmissionsCollectionSlug,
254
+ formsCollectionSlug,
255
+ formsEnabled,
256
+ formUploadsCollectionSlug,
257
+ globalsBasePath,
258
+ globalsExtraMatchPrefixes: [contactFormStudioPath],
259
+ logoUrl,
260
+ mediaCollectionSlug,
261
+ pagesCollectionSlug,
262
+ sections: studioSections
263
+ };
264
+ const studioBackBreadcrumbComponent = {
265
+ exportName: "StudioBackBreadcrumb",
266
+ path: clientPath
267
+ };
268
+ const hasMatchingComponent = (items, exportName) => Array.isArray(items) && items.some(
269
+ (item) => item && typeof item === "object" && item.exportName === exportName && item.path === clientPath
270
+ );
271
+ const appendComponent = (items, component, exportName) => hasMatchingComponent(items, exportName) ? items || [] : [...items || [], component];
272
+ const attachStudioBackBreadcrumbToCollection = (collection) => {
273
+ if (!studioEnabled) {
274
+ return collection;
275
+ }
276
+ const existingBeforeDocumentControls = collection.admin?.components?.edit?.beforeDocumentControls;
277
+ return {
278
+ ...collection,
279
+ admin: {
280
+ ...collection.admin,
281
+ components: {
282
+ ...collection.admin?.components,
283
+ edit: {
284
+ ...collection.admin?.components?.edit,
285
+ beforeDocumentControls: appendComponent(
286
+ existingBeforeDocumentControls,
287
+ studioBackBreadcrumbComponent,
288
+ "StudioBackBreadcrumb"
289
+ )
290
+ }
291
+ }
292
+ }
293
+ };
294
+ };
295
+ return {
296
+ admin: {
297
+ css: cssPath,
298
+ components: {
299
+ ...studioEnabled ? {
300
+ Nav: {
301
+ exportName: "AdminStudioNav",
302
+ path: clientPath,
303
+ clientProps: studioNavClientProps
304
+ }
305
+ } : {},
306
+ graphics: {
307
+ Logo: {
308
+ exportName: "Logo",
309
+ path: clientPath,
310
+ clientProps: {
311
+ brandName,
312
+ logoUrl
313
+ }
314
+ },
315
+ Icon: {
316
+ exportName: "Icon",
317
+ path: clientPath,
318
+ clientProps: {
319
+ brandName,
320
+ logoUrl
321
+ }
322
+ }
323
+ },
324
+ views: {
325
+ dashboard: {
326
+ Component: {
327
+ exportName: studioEnabled ? "AdminStudioDashboard" : "Dashboard",
328
+ path: clientPath,
329
+ clientProps: studioNavClientProps
330
+ }
331
+ },
332
+ ...studioEnabled ? {
333
+ studioGlobals: {
334
+ path: globalsBasePath,
335
+ Component: {
336
+ exportName: "AdminStudioGlobalsView",
337
+ path: clientPath,
338
+ clientProps: {
339
+ ...studioNavClientProps,
340
+ globals,
341
+ globalsBasePath
342
+ }
343
+ }
344
+ },
345
+ studioPages: {
346
+ path: pagesBasePath,
347
+ Component: {
348
+ exportName: "AdminStudioPagesListView",
349
+ path: clientPath,
350
+ clientProps: {
351
+ ...studioNavClientProps,
352
+ pagesCollectionSlug
353
+ }
354
+ }
355
+ },
356
+ studioPageEditor: {
357
+ path: `${pagesBasePath}/:id`,
358
+ Component: {
359
+ exportName: "AdminStudioPageEditView",
360
+ path: clientPath,
361
+ clientProps: {
362
+ ...studioNavClientProps,
363
+ builderBasePath
364
+ }
365
+ }
366
+ },
367
+ studioPageNew: {
368
+ path: `${pagesBasePath}/new`,
369
+ Component: {
370
+ exportName: "AdminStudioNewPageView",
371
+ path: clientPath,
372
+ clientProps: {
373
+ ...studioNavClientProps,
374
+ pagesCollectionSlug
375
+ }
376
+ }
377
+ },
378
+ studioContactForm: {
379
+ path: contactFormStudioPath,
380
+ Component: {
381
+ exportName: "AdminStudioContactFormView",
382
+ path: clientPath,
383
+ clientProps: {
384
+ ...studioNavClientProps,
385
+ globalSlug: "contact-form",
386
+ globalsBasePath
387
+ }
388
+ }
389
+ },
390
+ ...formsEnabled ? {
391
+ studioForms: {
392
+ path: formsBasePath,
393
+ Component: {
394
+ exportName: "AdminStudioFormsView",
395
+ path: clientPath,
396
+ clientProps: {
397
+ ...studioNavClientProps,
398
+ formsCollectionSlug,
399
+ formSubmissionsCollectionSlug,
400
+ formUploadsCollectionSlug
401
+ }
402
+ }
403
+ }
404
+ } : {},
405
+ studioMedia: {
406
+ path: mediaBasePath,
407
+ Component: {
408
+ exportName: "AdminStudioMediaView",
409
+ path: clientPath,
410
+ clientProps: {
411
+ ...studioNavClientProps,
412
+ mediaCollectionSlug
413
+ }
414
+ }
415
+ },
416
+ studioMediaItem: {
417
+ path: `${mediaBasePath}/:id`,
418
+ Component: {
419
+ exportName: "AdminStudioMediaItemView",
420
+ path: clientPath,
421
+ clientProps: {
422
+ ...studioNavClientProps,
423
+ mediaCollectionSlug
424
+ }
425
+ }
426
+ },
427
+ studioTools: {
428
+ path: toolsBasePath,
429
+ Component: {
430
+ exportName: "AdminStudioToolsView",
431
+ path: clientPath,
432
+ clientProps: {
433
+ ...studioNavClientProps,
434
+ mediaCollectionSlug,
435
+ pagesCollectionSlug
436
+ }
437
+ }
438
+ },
439
+ ...Object.fromEntries(
440
+ Object.entries(studioSectionViews).map(([id, view]) => [
441
+ id,
442
+ {
443
+ path: view.path,
444
+ Component: {
445
+ ...view.Component,
446
+ clientProps: {
447
+ ...studioNavClientProps,
448
+ ...view.Component.clientProps || {}
449
+ }
450
+ }
451
+ }
452
+ ])
453
+ )
454
+ } : {}
455
+ },
456
+ providers: [
457
+ {
458
+ exportName: "ThemeProvider",
459
+ path: clientPath,
460
+ clientProps: {
461
+ allowThemePreference,
462
+ defaultTheme
463
+ }
464
+ }
465
+ ],
466
+ beforeLogin: [
467
+ {
468
+ exportName: "AdminLoginIntro",
469
+ path: clientPath,
470
+ clientProps: {
471
+ brandName,
472
+ logoUrl
473
+ }
474
+ }
475
+ ],
476
+ ...allowThemePreference ? {
477
+ afterNavLinks: [
478
+ {
479
+ exportName: "ThemeSwitcher",
480
+ path: clientPath,
481
+ clientProps: {
482
+ allowThemePreference,
483
+ defaultTheme
484
+ }
485
+ }
486
+ ]
487
+ } : {}
488
+ },
489
+ meta: {
490
+ titleSuffix: ` \u2014 ${brandName}`
491
+ }
492
+ },
493
+ brandName,
494
+ brandPrimary,
495
+ brandSecondary,
496
+ defaultTheme,
497
+ wrapUsers(usersCollection) {
498
+ const existingFields = usersCollection.fields || [];
499
+ const hasThemePreference = existingFields.some(
500
+ (field) => typeof field === "object" && field !== null && "name" in field && field.name === "themePreference"
501
+ );
502
+ const nextCollection = {
503
+ ...usersCollection,
504
+ fields: !allowThemePreference || hasThemePreference ? existingFields : [...existingFields, createThemePreferenceField(defaultTheme)]
505
+ };
506
+ return attachStudioBackBreadcrumbToCollection(nextCollection);
507
+ },
508
+ wrapPagesCollection(pagesCollection) {
509
+ if (!studioEnabled) {
510
+ return pagesCollection;
511
+ }
512
+ const collectionWithBreadcrumb = attachStudioBackBreadcrumbToCollection(pagesCollection);
513
+ const existingEditMenuItems = collectionWithBreadcrumb.admin?.components?.edit?.editMenuItems;
514
+ const existingViews = collectionWithBreadcrumb.admin?.components?.views;
515
+ const existingEditViews = existingViews?.edit;
516
+ const hasCustomEditView = Boolean(
517
+ existingEditViews?.root || existingEditViews?.default && typeof existingEditViews.default === "object" && existingEditViews.default.Component
518
+ );
519
+ return {
520
+ ...collectionWithBreadcrumb,
521
+ admin: {
522
+ ...collectionWithBreadcrumb.admin,
523
+ components: {
524
+ ...collectionWithBreadcrumb.admin?.components,
525
+ edit: {
526
+ ...collectionWithBreadcrumb.admin?.components?.edit,
527
+ editMenuItems: appendComponent(
528
+ existingEditMenuItems,
529
+ {
530
+ exportName: "OpenInStudioMenuItem",
531
+ path: clientPath,
532
+ clientProps: {
533
+ pagesPathBase: pagesBasePath
534
+ }
535
+ },
536
+ "OpenInStudioMenuItem"
537
+ )
538
+ },
539
+ views: {
540
+ ...existingViews,
541
+ ...hasCustomEditView ? {} : {
542
+ edit: {
543
+ ...existingEditViews,
544
+ default: {
545
+ ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
546
+ Component: {
547
+ exportName: "PageEditRedirectToStudio",
548
+ path: clientPath,
549
+ clientProps: {
550
+ pagesPathBase: pagesBasePath
551
+ }
552
+ }
553
+ }
554
+ }
555
+ }
556
+ }
557
+ }
558
+ }
559
+ };
560
+ },
561
+ wrapMediaCollection(mediaCollection) {
562
+ return attachStudioBackBreadcrumbToCollection(mediaCollection);
563
+ },
564
+ wrapFormsCollection(formsCollection) {
565
+ return attachStudioBackBreadcrumbToCollection(formsCollection);
566
+ },
567
+ wrapFormSubmissionsCollection(formSubmissionsCollection) {
568
+ return attachStudioBackBreadcrumbToCollection(formSubmissionsCollection);
569
+ },
570
+ wrapFormUploadsCollection(formUploadsCollection) {
571
+ return attachStudioBackBreadcrumbToCollection(formUploadsCollection);
572
+ },
573
+ wrapGlobals(globals2) {
574
+ const labelMap = {
575
+ header: { group: "Site Design", label: "Header & Navigation" },
576
+ footer: { group: "Site Design", label: "Footer" },
577
+ "site-settings": { group: "Site Design", label: "Website Settings" },
578
+ "social-media": { group: "Site Design", label: "Social Media" },
579
+ "contact-form": { group: "Lead Forms", label: "Contact Form" }
580
+ };
581
+ return globals2.map((global) => {
582
+ const mapping = labelMap[global.slug];
583
+ if (!mapping) return global;
584
+ const shouldAttachSiteSettingsEditView = studioEnabled && global.slug === "site-settings";
585
+ const shouldAttachSocialMediaEditView = studioEnabled && global.slug === "social-media";
586
+ const shouldAttachContactFormRedirect = studioEnabled && global.slug === "contact-form";
587
+ const shouldAttachHeaderEditView = studioEnabled && global.slug === "header";
588
+ const shouldAttachFooterEditView = studioEnabled && global.slug === "footer";
589
+ const existingViews = global.admin?.components?.views;
590
+ const existingEditViews = existingViews?.edit;
591
+ const hasCustomEditView = Boolean(
592
+ existingEditViews?.root || existingEditViews?.default && typeof existingEditViews.default === "object" && existingEditViews.default.Component
593
+ );
594
+ const nextEditViews = (() => {
595
+ if (shouldAttachSiteSettingsEditView && !hasCustomEditView) {
596
+ return {
597
+ ...existingEditViews,
598
+ default: {
599
+ ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
600
+ Component: {
601
+ exportName: "AdminStudioSiteSettingsGlobalView",
602
+ path: clientPath,
603
+ clientProps: {
604
+ ...studioNavClientProps,
605
+ globalSlug: global.slug,
606
+ mediaCollectionSlug
607
+ }
608
+ }
609
+ }
610
+ };
611
+ }
612
+ if (shouldAttachSocialMediaEditView && !hasCustomEditView) {
613
+ return {
614
+ ...existingEditViews,
615
+ default: {
616
+ ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
617
+ Component: {
618
+ exportName: "AdminStudioSocialMediaGlobalView",
619
+ path: clientPath,
620
+ clientProps: {
621
+ ...studioNavClientProps,
622
+ globalSlug: global.slug
623
+ }
624
+ }
625
+ }
626
+ };
627
+ }
628
+ if (shouldAttachHeaderEditView && !hasCustomEditView) {
629
+ return {
630
+ ...existingEditViews,
631
+ default: {
632
+ ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
633
+ Component: {
634
+ exportName: "AdminStudioHeaderGlobalView",
635
+ path: clientPath,
636
+ clientProps: {
637
+ ...studioNavClientProps,
638
+ actionHref: sitePreview?.header?.actionHref,
639
+ actionLabel: sitePreview?.header?.actionLabel,
640
+ globalSlug: global.slug,
641
+ locationSummary: sitePreview?.locationSummary,
642
+ pagesCollectionSlug
643
+ }
644
+ }
645
+ }
646
+ };
647
+ }
648
+ if (shouldAttachFooterEditView && !hasCustomEditView) {
649
+ return {
650
+ ...existingEditViews,
651
+ default: {
652
+ ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
653
+ Component: {
654
+ exportName: "AdminStudioFooterGlobalView",
655
+ path: clientPath,
656
+ clientProps: {
657
+ ...studioNavClientProps,
658
+ builtByHref: sitePreview?.footer?.builtByHref,
659
+ builtByLabel: sitePreview?.footer?.builtByLabel,
660
+ description: sitePreview?.footer?.description,
661
+ footerCategories: sitePreview?.footer?.footerCategories,
662
+ footerLinks: sitePreview?.footer?.footerLinks,
663
+ globalSlug: global.slug,
664
+ locationSummary: sitePreview?.locationSummary
665
+ }
666
+ }
667
+ }
668
+ };
669
+ }
670
+ if (shouldAttachContactFormRedirect && !hasCustomEditView) {
671
+ return {
672
+ ...existingEditViews,
673
+ default: {
674
+ ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
675
+ Component: {
676
+ exportName: "StudioContactFormRedirect",
677
+ path: clientPath,
678
+ clientProps: {
679
+ studioContactFormPath: contactFormStudioPath
680
+ }
681
+ }
682
+ }
683
+ };
684
+ }
685
+ return existingEditViews;
686
+ })();
687
+ const existingBeforeDocumentControls = global.admin?.components?.elements?.beforeDocumentControls;
688
+ return {
689
+ ...global,
690
+ admin: {
691
+ ...global.admin,
692
+ group: mapping.group,
693
+ components: {
694
+ ...global.admin?.components,
695
+ elements: {
696
+ ...global.admin?.components?.elements,
697
+ beforeDocumentControls: studioEnabled ? appendComponent(
698
+ existingBeforeDocumentControls,
699
+ studioBackBreadcrumbComponent,
700
+ "StudioBackBreadcrumb"
701
+ ) : existingBeforeDocumentControls
702
+ },
703
+ ...nextEditViews ? {
704
+ views: {
705
+ ...existingViews,
706
+ edit: nextEditViews
707
+ }
708
+ } : {}
709
+ }
710
+ },
711
+ label: mapping.label
712
+ };
713
+ });
714
+ }
715
+ };
716
+ }
717
+
718
+ // src/admin/helpers/withTooltips.ts
719
+ var defaultTooltips = {
720
+ title: "The main title displayed on this page.",
721
+ slug: 'The URL-friendly name for this page (e.g., "about-us"). This appears in the web address.',
722
+ template: "Choose a layout template. This controls the overall structure of the page.",
723
+ parent: "Select a parent page to nest this page under. This affects the URL path.",
724
+ path: "The full URL path for this page. This is automatically generated from the slug and parent.",
725
+ layout: "Add and arrange content sections on your page. Each section is a building block.",
726
+ metaTitle: "The title shown in search engine results and browser tabs. Keep under 60 characters.",
727
+ metaDescription: "A brief summary shown in search results. Keep under 160 characters for best results.",
728
+ canonicalUrl: "The preferred URL for this page. Used to prevent duplicate content in search engines.",
729
+ ogImage: "The image shown when this page is shared on social media (Facebook, LinkedIn, etc.).",
730
+ noIndex: "When enabled, search engines will not list this page in results.",
731
+ noFollow: "When enabled, search engines will not follow links on this page.",
732
+ publishedAt: "The date and time this page was first published.",
733
+ alt: "Describe this image for screen readers and search engines. Be specific and concise.",
734
+ navItems: "The links shown in your website's navigation menu.",
735
+ copyright: "The copyright text displayed in your website footer.",
736
+ contactEmail: "The email address displayed in your footer and contact sections.",
737
+ contactPhone: "The phone number displayed in your footer and contact sections.",
738
+ siteName: "Your website's name. Appears in browser tabs and search results.",
739
+ tagline: "A short phrase describing your business. Used in SEO and site metadata.",
740
+ canonicalBaseUrl: 'The base URL of your website (e.g., "https://example.com"). Used for generating canonical URLs.'
741
+ };
742
+ function withTooltips(fields, customTooltips) {
743
+ const tooltips = { ...defaultTooltips, ...customTooltips };
744
+ return fields.map((field) => addTooltipToField(field, tooltips));
745
+ }
746
+ function addTooltipToField(field, tooltips) {
747
+ if ("name" in field && field.name && tooltips[field.name]) {
748
+ const tooltip = tooltips[field.name];
749
+ const admin = field.admin;
750
+ if (!admin?.description) {
751
+ return {
752
+ ...field,
753
+ admin: {
754
+ ...admin,
755
+ description: tooltip
756
+ }
757
+ };
758
+ }
759
+ }
760
+ if ("fields" in field && Array.isArray(field.fields)) {
761
+ return {
762
+ ...field,
763
+ fields: field.fields.map((f) => addTooltipToField(f, tooltips))
764
+ };
765
+ }
766
+ if ("tabs" in field && Array.isArray(field.tabs)) {
767
+ return {
768
+ ...field,
769
+ tabs: field.tabs.map((tab) => ({
770
+ ...tab,
771
+ fields: tab.fields ? tab.fields.map((f) => addTooltipToField(f, tooltips)) : tab.fields
772
+ }))
773
+ };
774
+ }
775
+ return field;
776
+ }
777
+
778
+ // src/admin/fields/headerNav.ts
779
+ var createHeaderNavItemsField = () => ({
780
+ name: "navItems",
781
+ type: "array",
782
+ labels: { singular: "Navigation Link", plural: "Navigation Links" },
783
+ admin: {
784
+ description: "The links displayed in your website's main navigation menu."
785
+ },
786
+ fields: [
787
+ {
788
+ name: "label",
789
+ type: "text",
790
+ required: true,
791
+ admin: {
792
+ description: "The text shown for this navigation link."
793
+ }
794
+ },
795
+ {
796
+ name: "href",
797
+ type: "text",
798
+ required: true,
799
+ admin: {
800
+ description: 'The URL this link points to (e.g., "/about" or "https://example.com").'
801
+ }
802
+ },
803
+ {
804
+ name: "parentHref",
805
+ type: "text",
806
+ admin: {
807
+ description: "Optional parent link URL. If set to another nav item href, this item appears in that dropdown."
808
+ }
809
+ }
810
+ ]
811
+ });
812
+
813
+ // src/admin/fields/socialMedia.ts
814
+ 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.";
815
+ function validateOptionalHttpsUrl(value) {
816
+ if (value === null || value === void 0 || value === "") {
817
+ return true;
818
+ }
819
+ if (typeof value !== "string") {
820
+ return "Enter a valid URL.";
821
+ }
822
+ try {
823
+ const url = new URL(value);
824
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
825
+ return "Use an http:// or https:// URL.";
826
+ }
827
+ return true;
828
+ } catch {
829
+ return "Enter a valid URL (for example: https://instagram.com/yourbrand).";
830
+ }
831
+ }
832
+ function createPlatformField(platform) {
833
+ const platformLabel = SOCIAL_MEDIA_PLATFORM_LABELS[platform];
834
+ const iconOptions = SOCIAL_MEDIA_ICON_OPTIONS[platform].map((option) => ({
835
+ label: option.label,
836
+ value: option.value
837
+ }));
838
+ return {
839
+ name: platform,
840
+ type: "group",
841
+ label: platformLabel,
842
+ fields: [
843
+ {
844
+ name: "url",
845
+ type: "text",
846
+ admin: {
847
+ description: `Full ${platformLabel} profile URL. Leave blank to hide ${platformLabel}.`
848
+ },
849
+ validate: validateOptionalHttpsUrl
850
+ },
851
+ {
852
+ name: "icon",
853
+ type: "select",
854
+ defaultValue: SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM[platform],
855
+ options: iconOptions,
856
+ admin: {
857
+ description: "Pick which icon style to display for this platform."
858
+ }
859
+ }
860
+ ]
861
+ };
862
+ }
863
+ var createSocialMediaConnectionsField = (options = {}) => {
864
+ const selectedPlatforms = Array.isArray(options.platforms) && options.platforms.length > 0 ? options.platforms : SOCIAL_MEDIA_PLATFORMS;
865
+ return {
866
+ name: options.name || "profiles",
867
+ type: "group",
868
+ label: options.label || "Social Media Profiles",
869
+ admin: {
870
+ description: options.description || DEFAULT_DESCRIPTION
871
+ },
872
+ fields: selectedPlatforms.map((platform) => createPlatformField(platform))
873
+ };
874
+ };
875
+ var socialMediaConnectionsField = createSocialMediaConnectionsField();
876
+
877
+ // src/admin/globals/socialMedia.ts
878
+ var createSocialMediaGlobal = (options = {}) => ({
879
+ slug: options.slug || "social-media",
880
+ label: "Social Media",
881
+ admin: {
882
+ description: options.description || "Manage social profile links and icon variants used across your website.",
883
+ group: "Site Design"
884
+ },
885
+ fields: [
886
+ createSocialMediaConnectionsField({
887
+ ...options.fieldOptions,
888
+ label: "Profiles",
889
+ name: "profiles"
890
+ })
891
+ ]
892
+ });
893
+
894
+ export {
895
+ createThemePreferenceField,
896
+ themePreferenceField,
897
+ configureAdmin,
898
+ withTooltips,
899
+ createHeaderNavItemsField,
900
+ createSocialMediaConnectionsField,
901
+ socialMediaConnectionsField,
902
+ createSocialMediaGlobal,
903
+ admin_exports
904
+ };