@orion-studios/payload-studio 0.6.0-beta.3 → 0.6.0-beta.5

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.
@@ -1,910 +0,0 @@
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
- afterLogin: [
477
- {
478
- exportName: "AdminLoginPasswordToggle",
479
- path: clientPath
480
- }
481
- ],
482
- ...allowThemePreference ? {
483
- afterNavLinks: [
484
- {
485
- exportName: "ThemeSwitcher",
486
- path: clientPath,
487
- clientProps: {
488
- allowThemePreference,
489
- defaultTheme
490
- }
491
- }
492
- ]
493
- } : {}
494
- },
495
- meta: {
496
- titleSuffix: ` \u2014 ${brandName}`
497
- }
498
- },
499
- brandName,
500
- brandPrimary,
501
- brandSecondary,
502
- defaultTheme,
503
- wrapUsers(usersCollection) {
504
- const existingFields = usersCollection.fields || [];
505
- const hasThemePreference = existingFields.some(
506
- (field) => typeof field === "object" && field !== null && "name" in field && field.name === "themePreference"
507
- );
508
- const nextCollection = {
509
- ...usersCollection,
510
- fields: !allowThemePreference || hasThemePreference ? existingFields : [...existingFields, createThemePreferenceField(defaultTheme)]
511
- };
512
- return attachStudioBackBreadcrumbToCollection(nextCollection);
513
- },
514
- wrapPagesCollection(pagesCollection) {
515
- if (!studioEnabled) {
516
- return pagesCollection;
517
- }
518
- const collectionWithBreadcrumb = attachStudioBackBreadcrumbToCollection(pagesCollection);
519
- const existingEditMenuItems = collectionWithBreadcrumb.admin?.components?.edit?.editMenuItems;
520
- const existingViews = collectionWithBreadcrumb.admin?.components?.views;
521
- const existingEditViews = existingViews?.edit;
522
- const hasCustomEditView = Boolean(
523
- existingEditViews?.root || existingEditViews?.default && typeof existingEditViews.default === "object" && existingEditViews.default.Component
524
- );
525
- return {
526
- ...collectionWithBreadcrumb,
527
- admin: {
528
- ...collectionWithBreadcrumb.admin,
529
- components: {
530
- ...collectionWithBreadcrumb.admin?.components,
531
- edit: {
532
- ...collectionWithBreadcrumb.admin?.components?.edit,
533
- editMenuItems: appendComponent(
534
- existingEditMenuItems,
535
- {
536
- exportName: "OpenInStudioMenuItem",
537
- path: clientPath,
538
- clientProps: {
539
- pagesPathBase: pagesBasePath
540
- }
541
- },
542
- "OpenInStudioMenuItem"
543
- )
544
- },
545
- views: {
546
- ...existingViews,
547
- ...hasCustomEditView ? {} : {
548
- edit: {
549
- ...existingEditViews,
550
- default: {
551
- ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
552
- Component: {
553
- exportName: "PageEditRedirectToStudio",
554
- path: clientPath,
555
- clientProps: {
556
- pagesPathBase: pagesBasePath
557
- }
558
- }
559
- }
560
- }
561
- }
562
- }
563
- }
564
- }
565
- };
566
- },
567
- wrapMediaCollection(mediaCollection) {
568
- return attachStudioBackBreadcrumbToCollection(mediaCollection);
569
- },
570
- wrapFormsCollection(formsCollection) {
571
- return attachStudioBackBreadcrumbToCollection(formsCollection);
572
- },
573
- wrapFormSubmissionsCollection(formSubmissionsCollection) {
574
- return attachStudioBackBreadcrumbToCollection(formSubmissionsCollection);
575
- },
576
- wrapFormUploadsCollection(formUploadsCollection) {
577
- return attachStudioBackBreadcrumbToCollection(formUploadsCollection);
578
- },
579
- wrapGlobals(globals2) {
580
- const labelMap = {
581
- header: { group: "Site Design", label: "Header & Navigation" },
582
- footer: { group: "Site Design", label: "Footer" },
583
- "site-settings": { group: "Site Design", label: "Website Settings" },
584
- "social-media": { group: "Site Design", label: "Social Media" },
585
- "contact-form": { group: "Lead Forms", label: "Contact Form" }
586
- };
587
- return globals2.map((global) => {
588
- const mapping = labelMap[global.slug];
589
- if (!mapping) return global;
590
- const shouldAttachSiteSettingsEditView = studioEnabled && global.slug === "site-settings";
591
- const shouldAttachSocialMediaEditView = studioEnabled && global.slug === "social-media";
592
- const shouldAttachContactFormRedirect = studioEnabled && global.slug === "contact-form";
593
- const shouldAttachHeaderEditView = studioEnabled && global.slug === "header";
594
- const shouldAttachFooterEditView = studioEnabled && global.slug === "footer";
595
- const existingViews = global.admin?.components?.views;
596
- const existingEditViews = existingViews?.edit;
597
- const hasCustomEditView = Boolean(
598
- existingEditViews?.root || existingEditViews?.default && typeof existingEditViews.default === "object" && existingEditViews.default.Component
599
- );
600
- const nextEditViews = (() => {
601
- if (shouldAttachSiteSettingsEditView && !hasCustomEditView) {
602
- return {
603
- ...existingEditViews,
604
- default: {
605
- ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
606
- Component: {
607
- exportName: "AdminStudioSiteSettingsGlobalView",
608
- path: clientPath,
609
- clientProps: {
610
- ...studioNavClientProps,
611
- globalSlug: global.slug,
612
- mediaCollectionSlug
613
- }
614
- }
615
- }
616
- };
617
- }
618
- if (shouldAttachSocialMediaEditView && !hasCustomEditView) {
619
- return {
620
- ...existingEditViews,
621
- default: {
622
- ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
623
- Component: {
624
- exportName: "AdminStudioSocialMediaGlobalView",
625
- path: clientPath,
626
- clientProps: {
627
- ...studioNavClientProps,
628
- globalSlug: global.slug
629
- }
630
- }
631
- }
632
- };
633
- }
634
- if (shouldAttachHeaderEditView && !hasCustomEditView) {
635
- return {
636
- ...existingEditViews,
637
- default: {
638
- ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
639
- Component: {
640
- exportName: "AdminStudioHeaderGlobalView",
641
- path: clientPath,
642
- clientProps: {
643
- ...studioNavClientProps,
644
- actionHref: sitePreview?.header?.actionHref,
645
- actionLabel: sitePreview?.header?.actionLabel,
646
- globalSlug: global.slug,
647
- locationSummary: sitePreview?.locationSummary,
648
- pagesCollectionSlug
649
- }
650
- }
651
- }
652
- };
653
- }
654
- if (shouldAttachFooterEditView && !hasCustomEditView) {
655
- return {
656
- ...existingEditViews,
657
- default: {
658
- ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
659
- Component: {
660
- exportName: "AdminStudioFooterGlobalView",
661
- path: clientPath,
662
- clientProps: {
663
- ...studioNavClientProps,
664
- builtByHref: sitePreview?.footer?.builtByHref,
665
- builtByLabel: sitePreview?.footer?.builtByLabel,
666
- description: sitePreview?.footer?.description,
667
- footerCategories: sitePreview?.footer?.footerCategories,
668
- footerLinks: sitePreview?.footer?.footerLinks,
669
- globalSlug: global.slug,
670
- locationSummary: sitePreview?.locationSummary
671
- }
672
- }
673
- }
674
- };
675
- }
676
- if (shouldAttachContactFormRedirect && !hasCustomEditView) {
677
- return {
678
- ...existingEditViews,
679
- default: {
680
- ...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
681
- Component: {
682
- exportName: "StudioContactFormRedirect",
683
- path: clientPath,
684
- clientProps: {
685
- studioContactFormPath: contactFormStudioPath
686
- }
687
- }
688
- }
689
- };
690
- }
691
- return existingEditViews;
692
- })();
693
- const existingBeforeDocumentControls = global.admin?.components?.elements?.beforeDocumentControls;
694
- return {
695
- ...global,
696
- admin: {
697
- ...global.admin,
698
- group: mapping.group,
699
- components: {
700
- ...global.admin?.components,
701
- elements: {
702
- ...global.admin?.components?.elements,
703
- beforeDocumentControls: studioEnabled ? appendComponent(
704
- existingBeforeDocumentControls,
705
- studioBackBreadcrumbComponent,
706
- "StudioBackBreadcrumb"
707
- ) : existingBeforeDocumentControls
708
- },
709
- ...nextEditViews ? {
710
- views: {
711
- ...existingViews,
712
- edit: nextEditViews
713
- }
714
- } : {}
715
- }
716
- },
717
- label: mapping.label
718
- };
719
- });
720
- }
721
- };
722
- }
723
-
724
- // src/admin/helpers/withTooltips.ts
725
- var defaultTooltips = {
726
- title: "The main title displayed on this page.",
727
- slug: 'The URL-friendly name for this page (e.g., "about-us"). This appears in the web address.',
728
- template: "Choose a layout template. This controls the overall structure of the page.",
729
- parent: "Select a parent page to nest this page under. This affects the URL path.",
730
- path: "The full URL path for this page. This is automatically generated from the slug and parent.",
731
- layout: "Add and arrange content sections on your page. Each section is a building block.",
732
- metaTitle: "The title shown in search engine results and browser tabs. Keep under 60 characters.",
733
- metaDescription: "A brief summary shown in search results. Keep under 160 characters for best results.",
734
- canonicalUrl: "The preferred URL for this page. Used to prevent duplicate content in search engines.",
735
- ogImage: "The image shown when this page is shared on social media (Facebook, LinkedIn, etc.).",
736
- noIndex: "When enabled, search engines will not list this page in results.",
737
- noFollow: "When enabled, search engines will not follow links on this page.",
738
- publishedAt: "The date and time this page was first published.",
739
- alt: "Describe this image for screen readers and search engines. Be specific and concise.",
740
- navItems: "The links shown in your website's navigation menu.",
741
- copyright: "The copyright text displayed in your website footer.",
742
- contactEmail: "The email address displayed in your footer and contact sections.",
743
- contactPhone: "The phone number displayed in your footer and contact sections.",
744
- siteName: "Your website's name. Appears in browser tabs and search results.",
745
- tagline: "A short phrase describing your business. Used in SEO and site metadata.",
746
- canonicalBaseUrl: 'The base URL of your website (e.g., "https://example.com"). Used for generating canonical URLs.'
747
- };
748
- function withTooltips(fields, customTooltips) {
749
- const tooltips = { ...defaultTooltips, ...customTooltips };
750
- return fields.map((field) => addTooltipToField(field, tooltips));
751
- }
752
- function addTooltipToField(field, tooltips) {
753
- if ("name" in field && field.name && tooltips[field.name]) {
754
- const tooltip = tooltips[field.name];
755
- const admin = field.admin;
756
- if (!admin?.description) {
757
- return {
758
- ...field,
759
- admin: {
760
- ...admin,
761
- description: tooltip
762
- }
763
- };
764
- }
765
- }
766
- if ("fields" in field && Array.isArray(field.fields)) {
767
- return {
768
- ...field,
769
- fields: field.fields.map((f) => addTooltipToField(f, tooltips))
770
- };
771
- }
772
- if ("tabs" in field && Array.isArray(field.tabs)) {
773
- return {
774
- ...field,
775
- tabs: field.tabs.map((tab) => ({
776
- ...tab,
777
- fields: tab.fields ? tab.fields.map((f) => addTooltipToField(f, tooltips)) : tab.fields
778
- }))
779
- };
780
- }
781
- return field;
782
- }
783
-
784
- // src/admin/fields/headerNav.ts
785
- var createHeaderNavItemsField = () => ({
786
- name: "navItems",
787
- type: "array",
788
- labels: { singular: "Navigation Link", plural: "Navigation Links" },
789
- admin: {
790
- description: "The links displayed in your website's main navigation menu."
791
- },
792
- fields: [
793
- {
794
- name: "label",
795
- type: "text",
796
- required: true,
797
- admin: {
798
- description: "The text shown for this navigation link."
799
- }
800
- },
801
- {
802
- name: "href",
803
- type: "text",
804
- required: true,
805
- admin: {
806
- description: 'The URL this link points to (e.g., "/about" or "https://example.com").'
807
- }
808
- },
809
- {
810
- name: "parentHref",
811
- type: "text",
812
- admin: {
813
- description: "Optional parent link URL. If set to another nav item href, this item appears in that dropdown."
814
- }
815
- }
816
- ]
817
- });
818
-
819
- // src/admin/fields/socialMedia.ts
820
- 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.";
821
- function validateOptionalHttpsUrl(value) {
822
- if (value === null || value === void 0 || value === "") {
823
- return true;
824
- }
825
- if (typeof value !== "string") {
826
- return "Enter a valid URL.";
827
- }
828
- try {
829
- const url = new URL(value);
830
- if (url.protocol !== "http:" && url.protocol !== "https:") {
831
- return "Use an http:// or https:// URL.";
832
- }
833
- return true;
834
- } catch {
835
- return "Enter a valid URL (for example: https://instagram.com/yourbrand).";
836
- }
837
- }
838
- function createPlatformField(platform) {
839
- const platformLabel = SOCIAL_MEDIA_PLATFORM_LABELS[platform];
840
- const iconOptions = SOCIAL_MEDIA_ICON_OPTIONS[platform].map((option) => ({
841
- label: option.label,
842
- value: option.value
843
- }));
844
- return {
845
- name: platform,
846
- type: "group",
847
- label: platformLabel,
848
- fields: [
849
- {
850
- name: "url",
851
- type: "text",
852
- admin: {
853
- description: `Full ${platformLabel} profile URL. Leave blank to hide ${platformLabel}.`
854
- },
855
- validate: validateOptionalHttpsUrl
856
- },
857
- {
858
- name: "icon",
859
- type: "select",
860
- defaultValue: SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM[platform],
861
- options: iconOptions,
862
- admin: {
863
- description: "Pick which icon style to display for this platform."
864
- }
865
- }
866
- ]
867
- };
868
- }
869
- var createSocialMediaConnectionsField = (options = {}) => {
870
- const selectedPlatforms = Array.isArray(options.platforms) && options.platforms.length > 0 ? options.platforms : SOCIAL_MEDIA_PLATFORMS;
871
- return {
872
- name: options.name || "profiles",
873
- type: "group",
874
- label: options.label || "Social Media Profiles",
875
- admin: {
876
- description: options.description || DEFAULT_DESCRIPTION
877
- },
878
- fields: selectedPlatforms.map((platform) => createPlatformField(platform))
879
- };
880
- };
881
- var socialMediaConnectionsField = createSocialMediaConnectionsField();
882
-
883
- // src/admin/globals/socialMedia.ts
884
- var createSocialMediaGlobal = (options = {}) => ({
885
- slug: options.slug || "social-media",
886
- label: "Social Media",
887
- admin: {
888
- description: options.description || "Manage social profile links and icon variants used across your website.",
889
- group: "Site Design"
890
- },
891
- fields: [
892
- createSocialMediaConnectionsField({
893
- ...options.fieldOptions,
894
- label: "Profiles",
895
- name: "profiles"
896
- })
897
- ]
898
- });
899
-
900
- export {
901
- createThemePreferenceField,
902
- themePreferenceField,
903
- configureAdmin,
904
- withTooltips,
905
- createHeaderNavItemsField,
906
- createSocialMediaConnectionsField,
907
- socialMediaConnectionsField,
908
- createSocialMediaGlobal,
909
- admin_exports
910
- };