@orion-studios/payload-studio 0.5.0-beta.113 → 0.5.0-beta.114
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/dist/admin/client.js +1915 -490
- package/dist/admin/client.mjs +1327 -445
- package/dist/admin/index.d.mts +2 -1
- package/dist/admin/index.d.ts +2 -1
- package/dist/admin/index.js +253 -50
- package/dist/admin/index.mjs +1 -1
- package/dist/admin-app/client.d.mts +1 -0
- package/dist/admin-app/client.d.ts +1 -0
- package/dist/admin-app/client.js +266 -105
- package/dist/admin-app/client.mjs +105 -456
- package/dist/admin-app/index.d.mts +2 -1
- package/dist/admin-app/index.d.ts +2 -1
- package/dist/admin-app/styles.css +351 -0
- package/dist/admin.css +9 -0
- package/dist/{chunk-DAIZDGHL.mjs → chunk-4YPHQYRR.mjs} +253 -50
- package/dist/chunk-6NE7GIVT.mjs +555 -0
- package/dist/{chunk-3T2P6SDM.mjs → chunk-XKUTZ7IU.mjs} +215 -6
- package/dist/{index-DUi_XND6.d.ts → index-Crx_MtPw.d.ts} +33 -3
- package/dist/{index-gLl_358v.d.mts → index-Cv-6qnrw.d.mts} +33 -3
- package/dist/index-D5yjivF7.d.ts +382 -0
- package/dist/index-DH9KGEZ8.d.mts +382 -0
- package/dist/{index-BzKOThsI.d.mts → index-DWmudwDm.d.mts} +1 -1
- package/dist/{index-BzKOThsI.d.ts → index-DWmudwDm.d.ts} +1 -1
- package/dist/{index-7lxTrxSG.d.mts → index-c5-qTRbH.d.mts} +7 -1
- package/dist/{index-7lxTrxSG.d.ts → index-yfpxsgUu.d.ts} +7 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +459 -56
- package/dist/index.mjs +9 -9
- package/dist/nextjs/index.mjs +2 -2
- package/dist/sitePreviewTypes-BECnq9xI.d.mts +41 -0
- package/dist/sitePreviewTypes-BECnq9xI.d.ts +41 -0
- package/dist/studio/index.d.mts +1 -1
- package/dist/studio/index.d.ts +1 -1
- package/dist/studio-pages/index.d.mts +3 -3
- package/dist/studio-pages/index.d.ts +3 -3
- package/dist/studio-pages/index.js +330 -7
- package/dist/studio-pages/index.mjs +10 -3
- package/package.json +1 -1
- package/dist/index-B7QvY3yF.d.mts +0 -245
- package/dist/index-BK03FiEM.d.ts +0 -245
- package/dist/{chunk-BET2YLAS.mjs → chunk-OTHERBGX.mjs} +3 -3
package/dist/index.js
CHANGED
|
@@ -219,13 +219,19 @@ function configureAdmin(config) {
|
|
|
219
219
|
const formSubmissionsCollectionSlug = config.studio?.forms?.submissionsCollectionSlug || "form-submissions";
|
|
220
220
|
const formUploadsCollectionSlug = config.studio?.forms?.uploadsCollectionSlug || "form-uploads";
|
|
221
221
|
const pagesCollectionSlug = config.studio?.pages?.collectionSlug || "pages";
|
|
222
|
+
const builderBasePath = config.studio?.pages?.builderBasePath || "/builder";
|
|
222
223
|
const mediaCollectionSlug = config.studio?.media?.collectionSlug || "media";
|
|
223
|
-
const
|
|
224
|
+
const globalsBasePath = "/globals";
|
|
225
|
+
const pagesBasePath = "/pages";
|
|
226
|
+
const formsBasePath = "/forms";
|
|
227
|
+
const mediaBasePath = "/media";
|
|
228
|
+
const toolsBasePath = "/tools";
|
|
229
|
+
const contactFormStudioPath = "/contact-form";
|
|
224
230
|
const configuredGlobals = config.studio?.globals || [
|
|
225
231
|
{ slug: "site-settings", label: "Website Settings" },
|
|
226
232
|
{ slug: "header", label: "Header & Navigation" },
|
|
227
233
|
{ slug: "footer", label: "Footer" },
|
|
228
|
-
{ slug: "
|
|
234
|
+
{ slug: "social-media", label: "Social Media" }
|
|
229
235
|
];
|
|
230
236
|
const globals = configuredGlobals.map((global) => {
|
|
231
237
|
if (global.slug !== "contact-form" || global.href) {
|
|
@@ -238,6 +244,7 @@ function configureAdmin(config) {
|
|
|
238
244
|
});
|
|
239
245
|
const studioSections = resolveStudioSections(config.studio?.sections || []);
|
|
240
246
|
const studioSectionViews = resolveStudioSectionViews(config.studio?.sections || []);
|
|
247
|
+
const sitePreview = config.studio?.sitePreview;
|
|
241
248
|
let cssPath;
|
|
242
249
|
const pkgDist = getPkgDistDir();
|
|
243
250
|
const sourceCssPath = import_path.default.resolve(pkgDist, "admin.css");
|
|
@@ -256,6 +263,50 @@ function configureAdmin(config) {
|
|
|
256
263
|
cssPath = sourceCssPath;
|
|
257
264
|
}
|
|
258
265
|
const clientPath = "@orion-studios/payload-studio/admin/client";
|
|
266
|
+
const studioNavClientProps = {
|
|
267
|
+
brandName,
|
|
268
|
+
formSubmissionsCollectionSlug,
|
|
269
|
+
formsCollectionSlug,
|
|
270
|
+
formsEnabled,
|
|
271
|
+
formUploadsCollectionSlug,
|
|
272
|
+
globalsBasePath,
|
|
273
|
+
globalsExtraMatchPrefixes: [contactFormStudioPath],
|
|
274
|
+
logoUrl,
|
|
275
|
+
mediaCollectionSlug,
|
|
276
|
+
pagesCollectionSlug,
|
|
277
|
+
sections: studioSections
|
|
278
|
+
};
|
|
279
|
+
const studioBackBreadcrumbComponent = {
|
|
280
|
+
exportName: "StudioBackBreadcrumb",
|
|
281
|
+
path: clientPath
|
|
282
|
+
};
|
|
283
|
+
const hasMatchingComponent = (items, exportName) => Array.isArray(items) && items.some(
|
|
284
|
+
(item) => item && typeof item === "object" && item.exportName === exportName && item.path === clientPath
|
|
285
|
+
);
|
|
286
|
+
const appendComponent = (items, component, exportName) => hasMatchingComponent(items, exportName) ? items || [] : [...items || [], component];
|
|
287
|
+
const attachStudioBackBreadcrumbToCollection = (collection) => {
|
|
288
|
+
if (!studioEnabled) {
|
|
289
|
+
return collection;
|
|
290
|
+
}
|
|
291
|
+
const existingBeforeDocumentControls = collection.admin?.components?.edit?.beforeDocumentControls;
|
|
292
|
+
return {
|
|
293
|
+
...collection,
|
|
294
|
+
admin: {
|
|
295
|
+
...collection.admin,
|
|
296
|
+
components: {
|
|
297
|
+
...collection.admin?.components,
|
|
298
|
+
edit: {
|
|
299
|
+
...collection.admin?.components?.edit,
|
|
300
|
+
beforeDocumentControls: appendComponent(
|
|
301
|
+
existingBeforeDocumentControls,
|
|
302
|
+
studioBackBreadcrumbComponent,
|
|
303
|
+
"StudioBackBreadcrumb"
|
|
304
|
+
)
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
};
|
|
259
310
|
return {
|
|
260
311
|
admin: {
|
|
261
312
|
css: cssPath,
|
|
@@ -264,19 +315,7 @@ function configureAdmin(config) {
|
|
|
264
315
|
Nav: {
|
|
265
316
|
exportName: "AdminStudioNav",
|
|
266
317
|
path: clientPath,
|
|
267
|
-
clientProps:
|
|
268
|
-
brandName,
|
|
269
|
-
logoUrl,
|
|
270
|
-
globalsBasePath: "/studio-globals",
|
|
271
|
-
globalsExtraMatchPrefixes: [contactFormStudioPath],
|
|
272
|
-
formSubmissionsCollectionSlug,
|
|
273
|
-
formsCollectionSlug,
|
|
274
|
-
formsEnabled,
|
|
275
|
-
formUploadsCollectionSlug,
|
|
276
|
-
mediaCollectionSlug,
|
|
277
|
-
pagesCollectionSlug,
|
|
278
|
-
sections: studioSections
|
|
279
|
-
}
|
|
318
|
+
clientProps: studioNavClientProps
|
|
280
319
|
}
|
|
281
320
|
} : {},
|
|
282
321
|
graphics: {
|
|
@@ -302,51 +341,64 @@ function configureAdmin(config) {
|
|
|
302
341
|
Component: {
|
|
303
342
|
exportName: studioEnabled ? "AdminStudioDashboard" : "Dashboard",
|
|
304
343
|
path: clientPath,
|
|
305
|
-
clientProps:
|
|
306
|
-
brandName,
|
|
307
|
-
logoUrl,
|
|
308
|
-
globalsBasePath: "/studio-globals",
|
|
309
|
-
globalsExtraMatchPrefixes: [contactFormStudioPath],
|
|
310
|
-
formSubmissionsCollectionSlug,
|
|
311
|
-
formsCollectionSlug,
|
|
312
|
-
formsEnabled,
|
|
313
|
-
formUploadsCollectionSlug,
|
|
314
|
-
mediaCollectionSlug,
|
|
315
|
-
pagesCollectionSlug,
|
|
316
|
-
sections: studioSections
|
|
317
|
-
}
|
|
344
|
+
clientProps: studioNavClientProps
|
|
318
345
|
}
|
|
319
346
|
},
|
|
320
347
|
...studioEnabled ? {
|
|
321
348
|
studioGlobals: {
|
|
322
|
-
path:
|
|
349
|
+
path: globalsBasePath,
|
|
323
350
|
Component: {
|
|
324
351
|
exportName: "AdminStudioGlobalsView",
|
|
325
352
|
path: clientPath,
|
|
326
353
|
clientProps: {
|
|
354
|
+
...studioNavClientProps,
|
|
327
355
|
globals,
|
|
328
|
-
globalsBasePath
|
|
356
|
+
globalsBasePath
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
studioPages: {
|
|
361
|
+
path: pagesBasePath,
|
|
362
|
+
Component: {
|
|
363
|
+
exportName: "AdminStudioPagesListView",
|
|
364
|
+
path: clientPath,
|
|
365
|
+
clientProps: {
|
|
366
|
+
...studioNavClientProps,
|
|
367
|
+
pagesCollectionSlug
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
studioPageEditor: {
|
|
372
|
+
path: `${pagesBasePath}/:id`,
|
|
373
|
+
Component: {
|
|
374
|
+
exportName: "AdminStudioPageEditView",
|
|
375
|
+
path: clientPath,
|
|
376
|
+
clientProps: {
|
|
377
|
+
...studioNavClientProps,
|
|
378
|
+
builderBasePath
|
|
329
379
|
}
|
|
330
380
|
}
|
|
331
381
|
},
|
|
332
382
|
studioContactForm: {
|
|
333
|
-
path:
|
|
383
|
+
path: contactFormStudioPath,
|
|
334
384
|
Component: {
|
|
335
385
|
exportName: "AdminStudioContactFormView",
|
|
336
386
|
path: clientPath,
|
|
337
387
|
clientProps: {
|
|
388
|
+
...studioNavClientProps,
|
|
338
389
|
globalSlug: "contact-form",
|
|
339
|
-
globalsBasePath
|
|
390
|
+
globalsBasePath
|
|
340
391
|
}
|
|
341
392
|
}
|
|
342
393
|
},
|
|
343
394
|
...formsEnabled ? {
|
|
344
395
|
studioForms: {
|
|
345
|
-
path:
|
|
396
|
+
path: formsBasePath,
|
|
346
397
|
Component: {
|
|
347
398
|
exportName: "AdminStudioFormsView",
|
|
348
399
|
path: clientPath,
|
|
349
400
|
clientProps: {
|
|
401
|
+
...studioNavClientProps,
|
|
350
402
|
formsCollectionSlug,
|
|
351
403
|
formSubmissionsCollectionSlug,
|
|
352
404
|
formUploadsCollectionSlug
|
|
@@ -354,12 +406,41 @@ function configureAdmin(config) {
|
|
|
354
406
|
}
|
|
355
407
|
}
|
|
356
408
|
} : {},
|
|
409
|
+
studioMedia: {
|
|
410
|
+
path: mediaBasePath,
|
|
411
|
+
Component: {
|
|
412
|
+
exportName: "AdminStudioMediaView",
|
|
413
|
+
path: clientPath,
|
|
414
|
+
clientProps: {
|
|
415
|
+
...studioNavClientProps,
|
|
416
|
+
mediaCollectionSlug
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
},
|
|
420
|
+
studioTools: {
|
|
421
|
+
path: toolsBasePath,
|
|
422
|
+
Component: {
|
|
423
|
+
exportName: "AdminStudioToolsView",
|
|
424
|
+
path: clientPath,
|
|
425
|
+
clientProps: {
|
|
426
|
+
...studioNavClientProps,
|
|
427
|
+
mediaCollectionSlug,
|
|
428
|
+
pagesCollectionSlug
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
},
|
|
357
432
|
...Object.fromEntries(
|
|
358
433
|
Object.entries(studioSectionViews).map(([id, view]) => [
|
|
359
434
|
id,
|
|
360
435
|
{
|
|
361
436
|
path: view.path,
|
|
362
|
-
Component:
|
|
437
|
+
Component: {
|
|
438
|
+
...view.Component,
|
|
439
|
+
clientProps: {
|
|
440
|
+
...studioNavClientProps,
|
|
441
|
+
...view.Component.clientProps || {}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
363
444
|
}
|
|
364
445
|
])
|
|
365
446
|
)
|
|
@@ -397,10 +478,76 @@ function configureAdmin(config) {
|
|
|
397
478
|
const hasThemePreference = existingFields.some(
|
|
398
479
|
(field) => typeof field === "object" && field !== null && "name" in field && field.name === "themePreference"
|
|
399
480
|
);
|
|
400
|
-
|
|
481
|
+
const nextCollection = {
|
|
401
482
|
...usersCollection,
|
|
402
483
|
fields: hasThemePreference ? existingFields : [...existingFields, createThemePreferenceField(defaultTheme)]
|
|
403
484
|
};
|
|
485
|
+
return attachStudioBackBreadcrumbToCollection(nextCollection);
|
|
486
|
+
},
|
|
487
|
+
wrapPagesCollection(pagesCollection) {
|
|
488
|
+
if (!studioEnabled) {
|
|
489
|
+
return pagesCollection;
|
|
490
|
+
}
|
|
491
|
+
const collectionWithBreadcrumb = attachStudioBackBreadcrumbToCollection(pagesCollection);
|
|
492
|
+
const existingEditMenuItems = collectionWithBreadcrumb.admin?.components?.edit?.editMenuItems;
|
|
493
|
+
const existingViews = collectionWithBreadcrumb.admin?.components?.views;
|
|
494
|
+
const existingEditViews = existingViews?.edit;
|
|
495
|
+
const hasCustomEditView = Boolean(
|
|
496
|
+
existingEditViews?.root || existingEditViews?.default && typeof existingEditViews.default === "object" && existingEditViews.default.Component
|
|
497
|
+
);
|
|
498
|
+
return {
|
|
499
|
+
...collectionWithBreadcrumb,
|
|
500
|
+
admin: {
|
|
501
|
+
...collectionWithBreadcrumb.admin,
|
|
502
|
+
components: {
|
|
503
|
+
...collectionWithBreadcrumb.admin?.components,
|
|
504
|
+
edit: {
|
|
505
|
+
...collectionWithBreadcrumb.admin?.components?.edit,
|
|
506
|
+
editMenuItems: appendComponent(
|
|
507
|
+
existingEditMenuItems,
|
|
508
|
+
{
|
|
509
|
+
exportName: "OpenInStudioMenuItem",
|
|
510
|
+
path: clientPath,
|
|
511
|
+
clientProps: {
|
|
512
|
+
pagesPathBase: pagesBasePath
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
"OpenInStudioMenuItem"
|
|
516
|
+
)
|
|
517
|
+
},
|
|
518
|
+
views: {
|
|
519
|
+
...existingViews,
|
|
520
|
+
...hasCustomEditView ? {} : {
|
|
521
|
+
edit: {
|
|
522
|
+
...existingEditViews,
|
|
523
|
+
default: {
|
|
524
|
+
...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
|
|
525
|
+
Component: {
|
|
526
|
+
exportName: "PageEditRedirectToStudio",
|
|
527
|
+
path: clientPath,
|
|
528
|
+
clientProps: {
|
|
529
|
+
pagesPathBase: pagesBasePath
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
},
|
|
540
|
+
wrapMediaCollection(mediaCollection) {
|
|
541
|
+
return attachStudioBackBreadcrumbToCollection(mediaCollection);
|
|
542
|
+
},
|
|
543
|
+
wrapFormsCollection(formsCollection) {
|
|
544
|
+
return attachStudioBackBreadcrumbToCollection(formsCollection);
|
|
545
|
+
},
|
|
546
|
+
wrapFormSubmissionsCollection(formSubmissionsCollection) {
|
|
547
|
+
return attachStudioBackBreadcrumbToCollection(formSubmissionsCollection);
|
|
548
|
+
},
|
|
549
|
+
wrapFormUploadsCollection(formUploadsCollection) {
|
|
550
|
+
return attachStudioBackBreadcrumbToCollection(formUploadsCollection);
|
|
404
551
|
},
|
|
405
552
|
wrapGlobals(globals2) {
|
|
406
553
|
const labelMap = {
|
|
@@ -414,24 +561,74 @@ function configureAdmin(config) {
|
|
|
414
561
|
const mapping = labelMap[global.slug];
|
|
415
562
|
if (!mapping) return global;
|
|
416
563
|
const shouldAttachContactFormRedirect = studioEnabled && global.slug === "contact-form";
|
|
564
|
+
const shouldAttachHeaderEditView = studioEnabled && global.slug === "header";
|
|
565
|
+
const shouldAttachFooterEditView = studioEnabled && global.slug === "footer";
|
|
417
566
|
const existingViews = global.admin?.components?.views;
|
|
418
567
|
const existingEditViews = existingViews?.edit;
|
|
419
568
|
const hasCustomContactFormEditView = Boolean(
|
|
420
569
|
existingEditViews?.root || existingEditViews?.default && typeof existingEditViews.default === "object" && existingEditViews.default.Component
|
|
421
570
|
);
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
571
|
+
const nextEditViews = (() => {
|
|
572
|
+
if (shouldAttachHeaderEditView && !hasCustomContactFormEditView) {
|
|
573
|
+
return {
|
|
574
|
+
...existingEditViews,
|
|
575
|
+
default: {
|
|
576
|
+
...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
|
|
577
|
+
Component: {
|
|
578
|
+
exportName: "AdminStudioHeaderGlobalView",
|
|
579
|
+
path: clientPath,
|
|
580
|
+
clientProps: {
|
|
581
|
+
...studioNavClientProps,
|
|
582
|
+
actionHref: sitePreview?.header?.actionHref,
|
|
583
|
+
actionLabel: sitePreview?.header?.actionLabel,
|
|
584
|
+
globalSlug: global.slug,
|
|
585
|
+
locationSummary: sitePreview?.locationSummary,
|
|
586
|
+
pagesCollectionSlug
|
|
587
|
+
}
|
|
588
|
+
}
|
|
431
589
|
}
|
|
432
|
-
}
|
|
590
|
+
};
|
|
433
591
|
}
|
|
434
|
-
|
|
592
|
+
if (shouldAttachFooterEditView && !hasCustomContactFormEditView) {
|
|
593
|
+
return {
|
|
594
|
+
...existingEditViews,
|
|
595
|
+
default: {
|
|
596
|
+
...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
|
|
597
|
+
Component: {
|
|
598
|
+
exportName: "AdminStudioFooterGlobalView",
|
|
599
|
+
path: clientPath,
|
|
600
|
+
clientProps: {
|
|
601
|
+
...studioNavClientProps,
|
|
602
|
+
builtByHref: sitePreview?.footer?.builtByHref,
|
|
603
|
+
builtByLabel: sitePreview?.footer?.builtByLabel,
|
|
604
|
+
description: sitePreview?.footer?.description,
|
|
605
|
+
footerCategories: sitePreview?.footer?.footerCategories,
|
|
606
|
+
footerLinks: sitePreview?.footer?.footerLinks,
|
|
607
|
+
globalSlug: global.slug,
|
|
608
|
+
locationSummary: sitePreview?.locationSummary
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
if (shouldAttachContactFormRedirect && !hasCustomContactFormEditView) {
|
|
615
|
+
return {
|
|
616
|
+
...existingEditViews,
|
|
617
|
+
default: {
|
|
618
|
+
...typeof existingEditViews?.default === "object" ? existingEditViews.default : {},
|
|
619
|
+
Component: {
|
|
620
|
+
exportName: "StudioContactFormRedirect",
|
|
621
|
+
path: clientPath,
|
|
622
|
+
clientProps: {
|
|
623
|
+
studioContactFormPath: contactFormStudioPath
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
return existingEditViews;
|
|
630
|
+
})();
|
|
631
|
+
const existingBeforeDocumentControls = global.admin?.components?.elements?.beforeDocumentControls;
|
|
435
632
|
return {
|
|
436
633
|
...global,
|
|
437
634
|
admin: {
|
|
@@ -439,12 +636,18 @@ function configureAdmin(config) {
|
|
|
439
636
|
group: mapping.group,
|
|
440
637
|
components: {
|
|
441
638
|
...global.admin?.components,
|
|
442
|
-
|
|
639
|
+
elements: {
|
|
640
|
+
...global.admin?.components?.elements,
|
|
641
|
+
beforeDocumentControls: studioEnabled ? appendComponent(
|
|
642
|
+
existingBeforeDocumentControls,
|
|
643
|
+
studioBackBreadcrumbComponent,
|
|
644
|
+
"StudioBackBreadcrumb"
|
|
645
|
+
) : existingBeforeDocumentControls
|
|
646
|
+
},
|
|
647
|
+
...nextEditViews ? {
|
|
443
648
|
views: {
|
|
444
649
|
...existingViews,
|
|
445
|
-
|
|
446
|
-
edit: contactFormEditViews
|
|
447
|
-
} : {}
|
|
650
|
+
edit: nextEditViews
|
|
448
651
|
}
|
|
449
652
|
} : {}
|
|
450
653
|
}
|
|
@@ -3817,14 +4020,17 @@ function resolveSocialMediaLinks(data) {
|
|
|
3817
4020
|
var studio_pages_exports = {};
|
|
3818
4021
|
__export(studio_pages_exports, {
|
|
3819
4022
|
createDefaultStudioDocument: () => createDefaultStudioDocument,
|
|
4023
|
+
createStudioPageService: () => createStudioPageService,
|
|
3820
4024
|
defaultBuilderThemeTokens: () => defaultBuilderThemeTokens,
|
|
4025
|
+
getStudioDocumentFromPage: () => getStudioDocumentFromPage,
|
|
3821
4026
|
layoutToStudioDocument: () => layoutToStudioDocument,
|
|
3822
4027
|
pageInspectorPanels: () => pageInspectorPanels,
|
|
3823
4028
|
pageNodeTypes: () => pageNodeTypes,
|
|
3824
4029
|
pagePaletteGroups: () => pagePaletteGroups,
|
|
3825
4030
|
pageStudioModuleManifest: () => pageStudioModuleManifest,
|
|
3826
4031
|
resolveBuilderThemeTokens: () => resolveBuilderThemeTokens,
|
|
3827
|
-
studioDocumentToLayout: () => studioDocumentToLayout
|
|
4032
|
+
studioDocumentToLayout: () => studioDocumentToLayout,
|
|
4033
|
+
toEditorInitialDoc: () => toEditorInitialDoc
|
|
3828
4034
|
});
|
|
3829
4035
|
|
|
3830
4036
|
// src/studio-pages/builder/settings-v2/themeTokens.ts
|
|
@@ -4201,10 +4407,207 @@ var inspectorDefinitionByBlockType = {
|
|
|
4201
4407
|
}
|
|
4202
4408
|
};
|
|
4203
4409
|
|
|
4204
|
-
// src/studio-pages/
|
|
4410
|
+
// src/studio-pages/pageService.ts
|
|
4205
4411
|
var isRecord5 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4206
|
-
var
|
|
4412
|
+
var toRecordArray = (value) => Array.isArray(value) ? value.filter((item) => isRecord5(item)) : [];
|
|
4413
|
+
var getRelationID = (value) => {
|
|
4414
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
4415
|
+
return value;
|
|
4416
|
+
}
|
|
4207
4417
|
if (!isRecord5(value)) {
|
|
4418
|
+
return null;
|
|
4419
|
+
}
|
|
4420
|
+
const id = value.id;
|
|
4421
|
+
return typeof id === "number" || typeof id === "string" ? id : null;
|
|
4422
|
+
};
|
|
4423
|
+
var asLayoutArray = (value) => toRecordArray(value);
|
|
4424
|
+
var hydrateRelationship = (valueFromStudio, valueFromLayout) => {
|
|
4425
|
+
if (isRecord5(valueFromStudio)) {
|
|
4426
|
+
return valueFromStudio;
|
|
4427
|
+
}
|
|
4428
|
+
if (!isRecord5(valueFromLayout)) {
|
|
4429
|
+
return valueFromStudio;
|
|
4430
|
+
}
|
|
4431
|
+
const studioID = getRelationID(valueFromStudio);
|
|
4432
|
+
const layoutID = getRelationID(valueFromLayout);
|
|
4433
|
+
if (studioID === null || layoutID === null || String(studioID) !== String(layoutID)) {
|
|
4434
|
+
return valueFromStudio;
|
|
4435
|
+
}
|
|
4436
|
+
return valueFromLayout;
|
|
4437
|
+
};
|
|
4438
|
+
var hydrateDocumentWithLayoutRelations = (document, layout) => {
|
|
4439
|
+
const nextNodes = document.nodes.map((node, index) => {
|
|
4440
|
+
const layoutBlock = layout[index];
|
|
4441
|
+
if (!isRecord5(layoutBlock)) {
|
|
4442
|
+
return node;
|
|
4443
|
+
}
|
|
4444
|
+
if (typeof layoutBlock.blockType !== "string" || layoutBlock.blockType !== node.type) {
|
|
4445
|
+
return node;
|
|
4446
|
+
}
|
|
4447
|
+
const nextData = { ...node.data };
|
|
4448
|
+
if (node.type === "hero") {
|
|
4449
|
+
nextData.media = hydrateRelationship(nextData.media, layoutBlock.media);
|
|
4450
|
+
}
|
|
4451
|
+
if (node.type === "media") {
|
|
4452
|
+
nextData.image = hydrateRelationship(nextData.image, layoutBlock.image);
|
|
4453
|
+
}
|
|
4454
|
+
if (node.type === "featureGrid" || node.type === "logoWall" || node.type === "beforeAfter") {
|
|
4455
|
+
const studioItems = Array.isArray(nextData.items) ? nextData.items : [];
|
|
4456
|
+
const layoutItems = Array.isArray(layoutBlock.items) ? layoutBlock.items : [];
|
|
4457
|
+
nextData.items = studioItems.map((rawStudioItem, itemIndex) => {
|
|
4458
|
+
if (!isRecord5(rawStudioItem)) {
|
|
4459
|
+
return rawStudioItem;
|
|
4460
|
+
}
|
|
4461
|
+
const layoutItem = layoutItems[itemIndex];
|
|
4462
|
+
if (!isRecord5(layoutItem)) {
|
|
4463
|
+
return rawStudioItem;
|
|
4464
|
+
}
|
|
4465
|
+
const nextItem = { ...rawStudioItem };
|
|
4466
|
+
nextItem.media = hydrateRelationship(nextItem.media, layoutItem.media);
|
|
4467
|
+
nextItem.beforeMedia = hydrateRelationship(nextItem.beforeMedia, layoutItem.beforeMedia);
|
|
4468
|
+
nextItem.afterMedia = hydrateRelationship(nextItem.afterMedia, layoutItem.afterMedia);
|
|
4469
|
+
return nextItem;
|
|
4470
|
+
});
|
|
4471
|
+
}
|
|
4472
|
+
return {
|
|
4473
|
+
...node,
|
|
4474
|
+
data: nextData
|
|
4475
|
+
};
|
|
4476
|
+
});
|
|
4477
|
+
return {
|
|
4478
|
+
...document,
|
|
4479
|
+
nodes: nextNodes
|
|
4480
|
+
};
|
|
4481
|
+
};
|
|
4482
|
+
var normalizeDocument = (document) => ({
|
|
4483
|
+
...document,
|
|
4484
|
+
schemaVersion: 1,
|
|
4485
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4486
|
+
});
|
|
4487
|
+
var normalizeLegacyHeroDefaults = (document) => {
|
|
4488
|
+
const nodes = document.nodes.map((node) => {
|
|
4489
|
+
if (node.type !== "hero" || !isRecord5(node.data)) {
|
|
4490
|
+
return node;
|
|
4491
|
+
}
|
|
4492
|
+
const nextData = { ...node.data };
|
|
4493
|
+
const heroBackgroundColor = typeof nextData.backgroundColor === "string" ? nextData.backgroundColor.trim().toLowerCase() : "";
|
|
4494
|
+
const sectionBackgroundMode = typeof nextData.sectionBackgroundMode === "string" ? nextData.sectionBackgroundMode : "none";
|
|
4495
|
+
const hasBackgroundImageURL = typeof nextData.backgroundImageURL === "string" && nextData.backgroundImageURL.trim().length > 0;
|
|
4496
|
+
const mediaRelation = getRelationID(nextData.media);
|
|
4497
|
+
if (heroBackgroundColor === "#124a37" && sectionBackgroundMode === "none" && !hasBackgroundImageURL && mediaRelation === null) {
|
|
4498
|
+
nextData.backgroundColor = "";
|
|
4499
|
+
}
|
|
4500
|
+
return {
|
|
4501
|
+
...node,
|
|
4502
|
+
data: nextData
|
|
4503
|
+
};
|
|
4504
|
+
});
|
|
4505
|
+
return {
|
|
4506
|
+
...document,
|
|
4507
|
+
nodes
|
|
4508
|
+
};
|
|
4509
|
+
};
|
|
4510
|
+
var assertCanPublish = (issues) => {
|
|
4511
|
+
const publishErrors = issues.filter((issue) => issue.severity === "error");
|
|
4512
|
+
if (publishErrors.length > 0) {
|
|
4513
|
+
throw new Error(`Cannot publish page: ${publishErrors[0].message}`);
|
|
4514
|
+
}
|
|
4515
|
+
};
|
|
4516
|
+
var getStudioDocumentFromPage = (doc) => {
|
|
4517
|
+
const title = typeof doc.title === "string" ? doc.title : void 0;
|
|
4518
|
+
const layout = asLayoutArray(doc.layout);
|
|
4519
|
+
try {
|
|
4520
|
+
const studioDocument = assertStudioDocumentV1(doc.studioDocument);
|
|
4521
|
+
if (layout.length > 0) {
|
|
4522
|
+
return hydrateDocumentWithLayoutRelations(studioDocument, layout);
|
|
4523
|
+
}
|
|
4524
|
+
return studioDocument;
|
|
4525
|
+
} catch {
|
|
4526
|
+
if (layout.length > 0) {
|
|
4527
|
+
return layoutToStudioDocument(layout, title);
|
|
4528
|
+
}
|
|
4529
|
+
return createEmptyStudioDocument(title);
|
|
4530
|
+
}
|
|
4531
|
+
};
|
|
4532
|
+
var createStudioPageService = ({
|
|
4533
|
+
collectionSlug = "pages",
|
|
4534
|
+
modules,
|
|
4535
|
+
payload,
|
|
4536
|
+
user
|
|
4537
|
+
}) => ({
|
|
4538
|
+
getPageForStudio: async (pageID) => {
|
|
4539
|
+
const page = await payload.findByID({
|
|
4540
|
+
collection: collectionSlug,
|
|
4541
|
+
depth: 2,
|
|
4542
|
+
draft: true,
|
|
4543
|
+
id: pageID,
|
|
4544
|
+
overrideAccess: false,
|
|
4545
|
+
user
|
|
4546
|
+
});
|
|
4547
|
+
const studioDocument = getStudioDocumentFromPage(page);
|
|
4548
|
+
return {
|
|
4549
|
+
id: String(page.id),
|
|
4550
|
+
slug: typeof page.slug === "string" ? page.slug : "",
|
|
4551
|
+
studioDocument,
|
|
4552
|
+
title: typeof page.title === "string" ? page.title : "Untitled Page"
|
|
4553
|
+
};
|
|
4554
|
+
},
|
|
4555
|
+
validateStudioDocument: (document) => validateStudioDocument(document, modules),
|
|
4556
|
+
saveDraft: async (pageID, document, _metadata) => {
|
|
4557
|
+
const normalizedDocument = normalizeLegacyHeroDefaults(normalizeDocument(document));
|
|
4558
|
+
const compileResult = compileStudioDocument(normalizedDocument, modules);
|
|
4559
|
+
await payload.update({
|
|
4560
|
+
collection: collectionSlug,
|
|
4561
|
+
data: {
|
|
4562
|
+
_status: "draft",
|
|
4563
|
+
layout: compileResult.layout,
|
|
4564
|
+
studioDocument: normalizedDocument,
|
|
4565
|
+
studioValidationIssues: compileResult.issues,
|
|
4566
|
+
title: normalizedDocument.title
|
|
4567
|
+
},
|
|
4568
|
+
id: pageID,
|
|
4569
|
+
overrideAccess: false,
|
|
4570
|
+
user
|
|
4571
|
+
});
|
|
4572
|
+
return {
|
|
4573
|
+
id: pageID,
|
|
4574
|
+
status: "draft"
|
|
4575
|
+
};
|
|
4576
|
+
},
|
|
4577
|
+
publish: async (pageID, document, _metadata) => {
|
|
4578
|
+
const normalizedDocument = normalizeLegacyHeroDefaults(normalizeDocument(document));
|
|
4579
|
+
const compileResult = compileStudioDocument(normalizedDocument, modules);
|
|
4580
|
+
assertCanPublish(compileResult.issues);
|
|
4581
|
+
await payload.update({
|
|
4582
|
+
collection: collectionSlug,
|
|
4583
|
+
data: {
|
|
4584
|
+
_status: "published",
|
|
4585
|
+
layout: compileResult.layout,
|
|
4586
|
+
studioDocument: normalizedDocument,
|
|
4587
|
+
studioValidationIssues: compileResult.issues,
|
|
4588
|
+
title: normalizedDocument.title
|
|
4589
|
+
},
|
|
4590
|
+
id: pageID,
|
|
4591
|
+
overrideAccess: false,
|
|
4592
|
+
user
|
|
4593
|
+
});
|
|
4594
|
+
return {
|
|
4595
|
+
id: pageID,
|
|
4596
|
+
status: "published"
|
|
4597
|
+
};
|
|
4598
|
+
}
|
|
4599
|
+
});
|
|
4600
|
+
var toEditorInitialDoc = (payloadPage) => ({
|
|
4601
|
+
layout: studioDocumentToLayout(payloadPage.studioDocument),
|
|
4602
|
+
slug: typeof payloadPage.slug === "string" ? payloadPage.slug : "",
|
|
4603
|
+
studioDocument: payloadPage.studioDocument,
|
|
4604
|
+
title: payloadPage.title
|
|
4605
|
+
});
|
|
4606
|
+
|
|
4607
|
+
// src/studio-pages/migrations.ts
|
|
4608
|
+
var isRecord6 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4609
|
+
var assertPageStudioDocumentV1 = (value) => {
|
|
4610
|
+
if (!isRecord6(value)) {
|
|
4208
4611
|
throw new Error("Studio document must be an object");
|
|
4209
4612
|
}
|
|
4210
4613
|
if (value.schemaVersion !== 1) {
|
|
@@ -4214,7 +4617,7 @@ var assertPageStudioDocumentV1 = (value) => {
|
|
|
4214
4617
|
throw new Error("Studio document nodes must be an array");
|
|
4215
4618
|
}
|
|
4216
4619
|
const nodes = value.nodes.map((node, index) => {
|
|
4217
|
-
if (!
|
|
4620
|
+
if (!isRecord6(node)) {
|
|
4218
4621
|
throw new Error(`Node at index ${index} must be an object`);
|
|
4219
4622
|
}
|
|
4220
4623
|
if (typeof node.id !== "string" || node.id.length === 0) {
|
|
@@ -4223,7 +4626,7 @@ var assertPageStudioDocumentV1 = (value) => {
|
|
|
4223
4626
|
if (typeof node.type !== "string" || node.type.length === 0) {
|
|
4224
4627
|
throw new Error(`Node at index ${index} has invalid type`);
|
|
4225
4628
|
}
|
|
4226
|
-
if (!
|
|
4629
|
+
if (!isRecord6(node.data)) {
|
|
4227
4630
|
throw new Error(`Node at index ${index} has invalid data`);
|
|
4228
4631
|
}
|
|
4229
4632
|
return {
|
|
@@ -4233,7 +4636,7 @@ var assertPageStudioDocumentV1 = (value) => {
|
|
|
4233
4636
|
};
|
|
4234
4637
|
});
|
|
4235
4638
|
return {
|
|
4236
|
-
metadata:
|
|
4639
|
+
metadata: isRecord6(value.metadata) ? value.metadata : void 0,
|
|
4237
4640
|
nodes,
|
|
4238
4641
|
schemaVersion: 1,
|
|
4239
4642
|
title: typeof value.title === "string" ? value.title : void 0,
|
package/dist/index.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
admin_exports
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
admin_app_exports
|
|
6
|
-
} from "./chunk-XVH5SCBD.mjs";
|
|
3
|
+
} from "./chunk-4YPHQYRR.mjs";
|
|
7
4
|
import {
|
|
8
5
|
blocks_exports
|
|
9
6
|
} from "./chunk-JQAHXYAM.mjs";
|
|
10
7
|
import {
|
|
11
8
|
nextjs_exports
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-OTHERBGX.mjs";
|
|
13
10
|
import "./chunk-ZTXJG4K5.mjs";
|
|
14
|
-
import {
|
|
15
|
-
studio_exports
|
|
16
|
-
} from "./chunk-ADIIWIYL.mjs";
|
|
17
11
|
import {
|
|
18
12
|
studio_pages_exports
|
|
19
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XKUTZ7IU.mjs";
|
|
20
14
|
import "./chunk-OQSEJXC4.mjs";
|
|
21
15
|
import "./chunk-PF3EBZXF.mjs";
|
|
16
|
+
import {
|
|
17
|
+
studio_exports
|
|
18
|
+
} from "./chunk-ADIIWIYL.mjs";
|
|
19
|
+
import {
|
|
20
|
+
admin_app_exports
|
|
21
|
+
} from "./chunk-XVH5SCBD.mjs";
|
|
22
22
|
import "./chunk-6BWS3CLP.mjs";
|
|
23
23
|
export {
|
|
24
24
|
admin_exports as admin,
|