@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
@@ -21,14 +21,17 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var studio_pages_exports = {};
22
22
  __export(studio_pages_exports, {
23
23
  createDefaultStudioDocument: () => createDefaultStudioDocument,
24
+ createStudioPageService: () => createStudioPageService,
24
25
  defaultBuilderThemeTokens: () => defaultBuilderThemeTokens,
26
+ getStudioDocumentFromPage: () => getStudioDocumentFromPage,
25
27
  layoutToStudioDocument: () => layoutToStudioDocument,
26
28
  pageInspectorPanels: () => pageInspectorPanels,
27
29
  pageNodeTypes: () => pageNodeTypes,
28
30
  pagePaletteGroups: () => pagePaletteGroups,
29
31
  pageStudioModuleManifest: () => pageStudioModuleManifest,
30
32
  resolveBuilderThemeTokens: () => resolveBuilderThemeTokens,
31
- studioDocumentToLayout: () => studioDocumentToLayout
33
+ studioDocumentToLayout: () => studioDocumentToLayout,
34
+ toEditorInitialDoc: () => toEditorInitialDoc
32
35
  });
33
36
  module.exports = __toCommonJS(studio_pages_exports);
34
37
 
@@ -39,15 +42,15 @@ var sectionStyleDefaults = {
39
42
  contentGradientAngle: "135",
40
43
  contentGradientFrom: "#ffffff",
41
44
  contentGradientPreset: "none",
42
- contentGradientTo: "#f4f6f2",
45
+ contentGradientTo: "#f4f6f8",
43
46
  contentWidth: "inherit",
44
47
  sectionPaddingX: "inherit",
45
48
  sectionBackgroundColor: "#ffffff",
46
49
  sectionBackgroundMode: "none",
47
50
  sectionGradientAngle: "135",
48
- sectionGradientFrom: "#124a37",
49
- sectionGradientPreset: "forest",
50
- sectionGradientTo: "#1f684f",
51
+ sectionGradientFrom: "#334b63",
52
+ sectionGradientPreset: "slate",
53
+ sectionGradientTo: "#496582",
51
54
  sectionPaddingY: "md",
52
55
  sectionWidth: "content"
53
56
  };
@@ -65,13 +68,13 @@ var defaultBuilderBlockSettingsV2 = {
65
68
  contentGradientAngle: "135",
66
69
  contentGradientFrom: "#ffffff",
67
70
  contentGradientPreset: "none",
68
- contentGradientTo: "#f4f6f2",
71
+ contentGradientTo: "#f4f6f8",
69
72
  sectionBackgroundColor: "#ffffff",
70
73
  sectionBackgroundMode: "none",
71
74
  sectionGradientAngle: "135",
72
- sectionGradientFrom: "#124a37",
73
- sectionGradientPreset: "forest",
74
- sectionGradientTo: "#1f684f"
75
+ sectionGradientFrom: "#334b63",
76
+ sectionGradientPreset: "slate",
77
+ sectionGradientTo: "#496582"
75
78
  },
76
79
  layout: {
77
80
  contentWidth: "inherit",
@@ -132,9 +135,9 @@ var defaultBuilderItemSettingsV2 = {
132
135
  };
133
136
  var defaultBuilderThemeTokens = {
134
137
  colors: {
135
- accent: "#0d4a37",
136
- bodyText: "#13211c",
137
- headingText: "#13211c",
138
+ accent: "#334b63",
139
+ bodyText: "#425163",
140
+ headingText: "#182332",
138
141
  surface: "#ffffff"
139
142
  },
140
143
  radii: {
@@ -354,16 +357,6 @@ var resolveBuilderThemeTokens = (layers) => {
354
357
  return merge(withPage, layers.block);
355
358
  };
356
359
 
357
- // src/studio-pages/builder/settings-v2/BlockInspectorRenderer.tsx
358
- var import_react2 = require("react");
359
-
360
- // src/studio-pages/builder/ui/Accordion.tsx
361
- var import_react = require("react");
362
- var import_jsx_runtime = require("react/jsx-runtime");
363
-
364
- // src/studio-pages/builder/ui/ImageControls.tsx
365
- var import_jsx_runtime2 = require("react/jsx-runtime");
366
-
367
360
  // src/studio-pages/builder/settings-v2/inspectorSchema.ts
368
361
  var alignOptions = [
369
362
  { label: "Left", value: "left" },
@@ -371,72 +364,7 @@ var alignOptions = [
371
364
  { label: "Right", value: "right" },
372
365
  { label: "Justify", value: "justify" }
373
366
  ];
374
- var layoutFieldSet = [
375
- {
376
- group: "layout",
377
- key: "settings.layout.contentWidth",
378
- label: "Content Width",
379
- options: [
380
- { label: "Inherit Page Default", value: "inherit" },
381
- { label: "Narrow", value: "narrow" },
382
- { label: "Content", value: "content" },
383
- { label: "Wide", value: "wide" },
384
- { label: "Full", value: "full" }
385
- ],
386
- tags: ["width", "container"],
387
- type: "select"
388
- },
389
- {
390
- group: "layout",
391
- key: "settings.layout.linkVerticalPadding",
392
- label: "Keep Top and Bottom Equal",
393
- tags: ["spacing", "padding", "equal", "lock", "vertical"],
394
- type: "checkbox"
395
- },
396
- {
397
- group: "layout",
398
- key: "settings.layout.paddingTopPt",
399
- label: "Top Padding (pt)",
400
- max: 240,
401
- min: 0,
402
- tags: ["spacing", "padding", "top", "vertical"],
403
- type: "number"
404
- },
405
- {
406
- group: "layout",
407
- key: "settings.layout.paddingBottomPt",
408
- label: "Bottom Padding (pt)",
409
- max: 240,
410
- min: 0,
411
- tags: ["spacing", "padding", "bottom", "vertical"],
412
- type: "number"
413
- },
414
- {
415
- group: "layout",
416
- key: "settings.layout.linkHorizontalPadding",
417
- label: "Keep Left and Right Equal",
418
- tags: ["spacing", "padding", "equal", "lock", "horizontal"],
419
- type: "checkbox"
420
- },
421
- {
422
- group: "layout",
423
- key: "settings.layout.paddingLeftPt",
424
- label: "Left Padding (pt)",
425
- max: 240,
426
- min: 0,
427
- tags: ["spacing", "padding", "left", "horizontal"],
428
- type: "number"
429
- },
430
- {
431
- group: "layout",
432
- key: "settings.layout.paddingRightPt",
433
- label: "Right Padding (pt)",
434
- max: 240,
435
- min: 0,
436
- tags: ["spacing", "padding", "right", "horizontal"],
437
- type: "number"
438
- }
439
- ];
367
+ var layoutFieldSet = [];
440
368
  var typographyFieldSet = [
441
369
  {
442
370
  group: "typography",
@@ -493,44 +421,7 @@ var typographyFieldSet = [
493
421
  type: "select"
494
422
  }
495
423
  ];
496
- var styleFieldSet = [
497
- {
498
- group: "style",
499
- key: "settings.appearance.sectionBackgroundMode",
500
- label: "Section Background",
501
- options: [
502
- { label: "None", value: "none" },
503
- { label: "Color", value: "color" },
504
- { label: "Gradient", value: "gradient" }
505
- ],
506
- tags: ["background", "section"],
507
- type: "select"
508
- },
509
- {
510
- group: "style",
511
- key: "settings.appearance.sectionBackgroundColor",
512
- label: "Section Background Color",
513
- type: "color"
514
- },
515
- {
516
- group: "style",
517
- key: "settings.appearance.contentBackgroundMode",
518
- label: "Content Background",
519
- options: [
520
- { label: "None", value: "none" },
521
- { label: "Color", value: "color" },
522
- { label: "Gradient", value: "gradient" }
523
- ],
524
- tags: ["background", "content"],
525
- type: "select"
526
- },
527
- {
528
- group: "style",
529
- key: "settings.appearance.contentBackgroundColor",
530
- label: "Content Background Color",
531
- type: "color"
532
- }
533
- ];
424
+ var styleFieldSet = [];
534
425
  var commonAdvanced = [
535
426
  {
536
427
  group: "advanced",
@@ -631,6 +522,7 @@ var inspectorDefinitionByBlockType = {
631
522
  faq: {
632
523
  blockType: "faq",
633
524
  fields: [
525
+ { group: "basics", inlineEditable: true, key: "eyebrow", label: "Eyebrow", type: "text" },
634
526
  { group: "basics", inlineEditable: true, key: "title", label: "Title", type: "text" },
635
527
  ...layoutFieldSet,
636
528
  ...typographyFieldSet,
@@ -641,6 +533,7 @@ var inspectorDefinitionByBlockType = {
641
533
  featureGrid: {
642
534
  blockType: "featureGrid",
643
535
  fields: [
536
+ { group: "basics", inlineEditable: true, key: "eyebrow", label: "Eyebrow", type: "text" },
644
537
  { group: "basics", inlineEditable: true, key: "title", label: "Title", type: "text" },
645
538
  {
646
539
  group: "basics",
@@ -648,7 +541,11 @@ var inspectorDefinitionByBlockType = {
648
541
  label: "Variant",
649
542
  options: [
650
543
  { label: "Cards", value: "cards" },
651
- { label: "Highlight", value: "highlight" }
544
+ { label: "Highlight", value: "highlight" },
545
+ { label: "Split List", value: "splitList" },
546
+ { label: "Panels", value: "panels" },
547
+ { label: "Catalog", value: "catalog" },
548
+ { label: "Contact Split", value: "contact" }
652
549
  ],
653
550
  type: "select"
654
551
  },
@@ -663,6 +560,7 @@ var inspectorDefinitionByBlockType = {
663
560
  formEmbed: {
664
561
  blockType: "formEmbed",
665
562
  fields: [
563
+ { group: "basics", inlineEditable: true, key: "eyebrow", label: "Eyebrow", type: "text" },
666
564
  { group: "basics", inlineEditable: true, key: "title", label: "Title", type: "text" },
667
565
  { group: "basics", inlineEditable: true, key: "description", label: "Description", type: "textarea" },
668
566
  {
@@ -695,7 +593,7 @@ var inspectorDefinitionByBlockType = {
695
593
  type: "select"
696
594
  },
697
595
  {
698
- group: "layout",
596
+ group: "basics",
699
597
  key: "heroHeight",
700
598
  label: "Hero Height",
701
599
  options: [
@@ -748,6 +646,16 @@ var inspectorDefinitionByBlockType = {
748
646
  richText: {
749
647
  blockType: "richText",
750
648
  fields: [
649
+ {
650
+ group: "basics",
651
+ key: "variant",
652
+ label: "Variant",
653
+ options: [
654
+ { label: "Default", value: "default" },
655
+ { label: "Quote Banner", value: "quoteBanner" }
656
+ ],
657
+ type: "select"
658
+ },
751
659
  { group: "basics", inlineEditable: true, key: "title", label: "Title", type: "text" },
752
660
  {
753
661
  group: "basics",
@@ -799,13 +707,368 @@ var inspectorDefinitionByBlockType = {
799
707
  }
800
708
  };
801
709
 
802
- // src/studio-pages/builder/settings-v2/BlockInspectorRenderer.tsx
803
- var import_jsx_runtime3 = require("react/jsx-runtime");
710
+ // src/studio-pages/document.ts
711
+ var ensureNodeID = (value, index) => {
712
+ if (typeof value === "string" && value.trim().length > 0) {
713
+ return value.trim();
714
+ }
715
+ return `node-${index + 1}`;
716
+ };
717
+ var layoutToStudioDocument = (layout, title, metadata) => {
718
+ const nodes = layout.filter((block) => typeof block.blockType === "string").map((rawBlock, index) => {
719
+ const block = migrateBlockToSettingsV2(rawBlock);
720
+ const blockType = String(block.blockType);
721
+ const { id, blockType: _ignoredBlockType, ...data } = block;
722
+ return {
723
+ id: ensureNodeID(id, index),
724
+ type: blockType,
725
+ data
726
+ };
727
+ });
728
+ return {
729
+ metadata,
730
+ schemaVersion: 1,
731
+ title,
732
+ nodes,
733
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
734
+ };
735
+ };
736
+ var studioDocumentToLayout = (document) => document.nodes.map(
737
+ (node) => migrateBlockToSettingsV2({
738
+ id: node.id,
739
+ blockType: node.type,
740
+ ...node.data
741
+ })
742
+ );
743
+ var createDefaultStudioDocument = (title) => ({
744
+ metadata: {},
745
+ schemaVersion: 1,
746
+ title,
747
+ nodes: [],
748
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
749
+ });
804
750
 
805
- // src/studio-pages/migrations.ts
751
+ // src/studio/index.ts
806
752
  var isRecord3 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
753
+ var makeIssue = (message, path, code = "studio.invalid") => ({
754
+ code,
755
+ message,
756
+ path,
757
+ severity: "error"
758
+ });
759
+ var createEmptyStudioDocument = (title) => ({
760
+ metadata: {},
761
+ schemaVersion: 1,
762
+ title,
763
+ nodes: [],
764
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
765
+ });
766
+ function assertStudioDocumentV1(input) {
767
+ if (!isRecord3(input)) {
768
+ throw new Error("Studio document must be an object");
769
+ }
770
+ if (input.schemaVersion !== 1) {
771
+ throw new Error("Unsupported studio schemaVersion");
772
+ }
773
+ if (!Array.isArray(input.nodes)) {
774
+ throw new Error("Studio document nodes must be an array");
775
+ }
776
+ const nodes = input.nodes.map((node, index) => {
777
+ if (!isRecord3(node)) {
778
+ throw new Error(`Node at index ${index} must be an object`);
779
+ }
780
+ if (typeof node.id !== "string" || node.id.length === 0) {
781
+ throw new Error(`Node at index ${index} has invalid id`);
782
+ }
783
+ if (typeof node.type !== "string" || node.type.length === 0) {
784
+ throw new Error(`Node at index ${index} has invalid type`);
785
+ }
786
+ if (!isRecord3(node.data)) {
787
+ throw new Error(`Node at index ${index} has invalid data`);
788
+ }
789
+ return {
790
+ id: node.id,
791
+ type: node.type,
792
+ data: node.data
793
+ };
794
+ });
795
+ return {
796
+ metadata: isRecord3(input.metadata) ? input.metadata : void 0,
797
+ schemaVersion: 1,
798
+ title: typeof input.title === "string" ? input.title : void 0,
799
+ nodes,
800
+ updatedAt: typeof input.updatedAt === "string" ? input.updatedAt : void 0
801
+ };
802
+ }
803
+ function createStudioRegistry(modules) {
804
+ const moduleByID = new Map(modules.map((mod) => [mod.id, mod]));
805
+ const nodeTypes = modules.flatMap((mod) => mod.nodeTypes);
806
+ const nodeTypeByName = new Map(nodeTypes.map((definition) => [definition.type, definition]));
807
+ return {
808
+ getModuleByID: (id) => moduleByID.get(id),
809
+ getNodeTypeByName: (type) => nodeTypeByName.get(type),
810
+ listInspectorPanels: () => modules.flatMap((mod) => mod.inspectorPanels),
811
+ listModules: () => [...modules],
812
+ listPaletteGroups: () => modules.flatMap((mod) => mod.paletteGroups),
813
+ listNodeTypes: () => [...nodeTypes]
814
+ };
815
+ }
816
+ function validateStudioDocument(document, modules) {
817
+ const issues = [];
818
+ if (document.schemaVersion !== 1) {
819
+ issues.push(makeIssue("Unsupported schema version", "schemaVersion", "studio.schemaVersion"));
820
+ }
821
+ if (!Array.isArray(document.nodes)) {
822
+ issues.push(makeIssue("Nodes must be an array", "nodes", "studio.nodes"));
823
+ return issues;
824
+ }
825
+ const registry = createStudioRegistry(modules);
826
+ const nodeIDs = /* @__PURE__ */ new Set();
827
+ document.nodes.forEach((node, index) => {
828
+ if (!node.id) {
829
+ issues.push(makeIssue("Node id is required", `nodes.${index}.id`, "studio.node.id"));
830
+ }
831
+ if (nodeIDs.has(node.id)) {
832
+ issues.push(makeIssue("Node id must be unique", `nodes.${index}.id`, "studio.node.id.duplicate"));
833
+ }
834
+ nodeIDs.add(node.id);
835
+ if (!registry.getNodeTypeByName(node.type)) {
836
+ issues.push(makeIssue("Unsupported node type", `nodes.${index}.type`, "studio.node.type"));
837
+ }
838
+ });
839
+ for (const module2 of modules) {
840
+ for (const validate of module2.validators) {
841
+ issues.push(...validate(document));
842
+ }
843
+ }
844
+ return issues;
845
+ }
846
+ function compileStudioDocument(document, modules) {
847
+ const issues = validateStudioDocument(document, modules);
848
+ const compilerEntries = modules.filter((mod) => typeof mod.compiler?.compileNode === "function").map((mod) => mod.compiler?.compileNode);
849
+ const layout = document.nodes.map((node) => {
850
+ for (const compileNode of compilerEntries) {
851
+ if (!compileNode) {
852
+ continue;
853
+ }
854
+ const compiled = compileNode(node);
855
+ if (compiled) {
856
+ return compiled;
857
+ }
858
+ }
859
+ return {
860
+ id: node.id,
861
+ blockType: node.type,
862
+ ...node.data
863
+ };
864
+ });
865
+ return {
866
+ issues,
867
+ layout
868
+ };
869
+ }
870
+
871
+ // src/studio-pages/pageService.ts
872
+ var isRecord4 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
873
+ var toRecordArray = (value) => Array.isArray(value) ? value.filter((item) => isRecord4(item)) : [];
874
+ var getRelationID = (value) => {
875
+ if (typeof value === "number" || typeof value === "string") {
876
+ return value;
877
+ }
878
+ if (!isRecord4(value)) {
879
+ return null;
880
+ }
881
+ const id = value.id;
882
+ return typeof id === "number" || typeof id === "string" ? id : null;
883
+ };
884
+ var asLayoutArray = (value) => toRecordArray(value);
885
+ var hydrateRelationship = (valueFromStudio, valueFromLayout) => {
886
+ if (isRecord4(valueFromStudio)) {
887
+ return valueFromStudio;
888
+ }
889
+ if (!isRecord4(valueFromLayout)) {
890
+ return valueFromStudio;
891
+ }
892
+ const studioID = getRelationID(valueFromStudio);
893
+ const layoutID = getRelationID(valueFromLayout);
894
+ if (studioID === null || layoutID === null || String(studioID) !== String(layoutID)) {
895
+ return valueFromStudio;
896
+ }
897
+ return valueFromLayout;
898
+ };
899
+ var hydrateDocumentWithLayoutRelations = (document, layout) => {
900
+ const nextNodes = document.nodes.map((node, index) => {
901
+ const layoutBlock = layout[index];
902
+ if (!isRecord4(layoutBlock)) {
903
+ return node;
904
+ }
905
+ if (typeof layoutBlock.blockType !== "string" || layoutBlock.blockType !== node.type) {
906
+ return node;
907
+ }
908
+ const nextData = { ...node.data };
909
+ if (node.type === "hero") {
910
+ nextData.media = hydrateRelationship(nextData.media, layoutBlock.media);
911
+ }
912
+ if (node.type === "media") {
913
+ nextData.image = hydrateRelationship(nextData.image, layoutBlock.image);
914
+ }
915
+ if (node.type === "featureGrid" || node.type === "logoWall" || node.type === "beforeAfter") {
916
+ const studioItems = Array.isArray(nextData.items) ? nextData.items : [];
917
+ const layoutItems = Array.isArray(layoutBlock.items) ? layoutBlock.items : [];
918
+ nextData.items = studioItems.map((rawStudioItem, itemIndex) => {
919
+ if (!isRecord4(rawStudioItem)) {
920
+ return rawStudioItem;
921
+ }
922
+ const layoutItem = layoutItems[itemIndex];
923
+ if (!isRecord4(layoutItem)) {
924
+ return rawStudioItem;
925
+ }
926
+ const nextItem = { ...rawStudioItem };
927
+ nextItem.media = hydrateRelationship(nextItem.media, layoutItem.media);
928
+ nextItem.beforeMedia = hydrateRelationship(nextItem.beforeMedia, layoutItem.beforeMedia);
929
+ nextItem.afterMedia = hydrateRelationship(nextItem.afterMedia, layoutItem.afterMedia);
930
+ return nextItem;
931
+ });
932
+ }
933
+ return {
934
+ ...node,
935
+ data: nextData
936
+ };
937
+ });
938
+ return {
939
+ ...document,
940
+ nodes: nextNodes
941
+ };
942
+ };
943
+ var normalizeDocument = (document) => ({
944
+ ...document,
945
+ schemaVersion: 1,
946
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
947
+ });
948
+ var normalizeLegacyHeroDefaults = (document) => {
949
+ const nodes = document.nodes.map((node) => {
950
+ if (node.type !== "hero" || !isRecord4(node.data)) {
951
+ return node;
952
+ }
953
+ const nextData = { ...node.data };
954
+ const heroBackgroundColor = typeof nextData.backgroundColor === "string" ? nextData.backgroundColor.trim().toLowerCase() : "";
955
+ const sectionBackgroundMode = typeof nextData.sectionBackgroundMode === "string" ? nextData.sectionBackgroundMode : "none";
956
+ const hasBackgroundImageURL = typeof nextData.backgroundImageURL === "string" && nextData.backgroundImageURL.trim().length > 0;
957
+ const mediaRelation = getRelationID(nextData.media);
958
+ if (heroBackgroundColor === "#124a37" && sectionBackgroundMode === "none" && !hasBackgroundImageURL && mediaRelation === null) {
959
+ nextData.backgroundColor = "";
960
+ }
961
+ return {
962
+ ...node,
963
+ data: nextData
964
+ };
965
+ });
966
+ return {
967
+ ...document,
968
+ nodes
969
+ };
970
+ };
971
+ var assertCanPublish = (issues) => {
972
+ const publishErrors = issues.filter((issue) => issue.severity === "error");
973
+ if (publishErrors.length > 0) {
974
+ throw new Error(`Cannot publish page: ${publishErrors[0].message}`);
975
+ }
976
+ };
977
+ var getStudioDocumentFromPage = (doc) => {
978
+ const title = typeof doc.title === "string" ? doc.title : void 0;
979
+ const layout = asLayoutArray(doc.layout);
980
+ try {
981
+ const studioDocument = assertStudioDocumentV1(doc.studioDocument);
982
+ if (layout.length > 0) {
983
+ return hydrateDocumentWithLayoutRelations(studioDocument, layout);
984
+ }
985
+ return studioDocument;
986
+ } catch {
987
+ if (layout.length > 0) {
988
+ return layoutToStudioDocument(layout, title);
989
+ }
990
+ return createEmptyStudioDocument(title);
991
+ }
992
+ };
993
+ var createStudioPageService = ({
994
+ collectionSlug = "pages",
995
+ modules,
996
+ payload,
997
+ user
998
+ }) => ({
999
+ getPageForStudio: async (pageID) => {
1000
+ const page = await payload.findByID({
1001
+ collection: collectionSlug,
1002
+ depth: 2,
1003
+ draft: true,
1004
+ id: pageID,
1005
+ overrideAccess: false,
1006
+ user
1007
+ });
1008
+ const studioDocument = getStudioDocumentFromPage(page);
1009
+ return {
1010
+ id: String(page.id),
1011
+ slug: typeof page.slug === "string" ? page.slug : "",
1012
+ studioDocument,
1013
+ title: typeof page.title === "string" ? page.title : "Untitled Page"
1014
+ };
1015
+ },
1016
+ validateStudioDocument: (document) => validateStudioDocument(document, modules),
1017
+ saveDraft: async (pageID, document, _metadata) => {
1018
+ const normalizedDocument = normalizeLegacyHeroDefaults(normalizeDocument(document));
1019
+ const compileResult = compileStudioDocument(normalizedDocument, modules);
1020
+ await payload.update({
1021
+ collection: collectionSlug,
1022
+ data: {
1023
+ _status: "draft",
1024
+ layout: compileResult.layout,
1025
+ studioDocument: normalizedDocument,
1026
+ studioValidationIssues: compileResult.issues,
1027
+ title: normalizedDocument.title
1028
+ },
1029
+ id: pageID,
1030
+ overrideAccess: false,
1031
+ user
1032
+ });
1033
+ return {
1034
+ id: pageID,
1035
+ status: "draft"
1036
+ };
1037
+ },
1038
+ publish: async (pageID, document, _metadata) => {
1039
+ const normalizedDocument = normalizeLegacyHeroDefaults(normalizeDocument(document));
1040
+ const compileResult = compileStudioDocument(normalizedDocument, modules);
1041
+ assertCanPublish(compileResult.issues);
1042
+ await payload.update({
1043
+ collection: collectionSlug,
1044
+ data: {
1045
+ _status: "published",
1046
+ layout: compileResult.layout,
1047
+ studioDocument: normalizedDocument,
1048
+ studioValidationIssues: compileResult.issues,
1049
+ title: normalizedDocument.title
1050
+ },
1051
+ id: pageID,
1052
+ overrideAccess: false,
1053
+ user
1054
+ });
1055
+ return {
1056
+ id: pageID,
1057
+ status: "published"
1058
+ };
1059
+ }
1060
+ });
1061
+ var toEditorInitialDoc = (payloadPage) => ({
1062
+ layout: studioDocumentToLayout(payloadPage.studioDocument),
1063
+ slug: typeof payloadPage.slug === "string" ? payloadPage.slug : "",
1064
+ studioDocument: payloadPage.studioDocument,
1065
+ title: payloadPage.title
1066
+ });
1067
+
1068
+ // src/studio-pages/migrations.ts
1069
+ var isRecord5 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
807
1070
  var assertPageStudioDocumentV1 = (value) => {
808
- if (!isRecord3(value)) {
1071
+ if (!isRecord5(value)) {
809
1072
  throw new Error("Studio document must be an object");
810
1073
  }
811
1074
  if (value.schemaVersion !== 1) {
@@ -815,7 +1078,7 @@ var assertPageStudioDocumentV1 = (value) => {
815
1078
  throw new Error("Studio document nodes must be an array");
816
1079
  }
817
1080
  const nodes = value.nodes.map((node, index) => {
818
- if (!isRecord3(node)) {
1081
+ if (!isRecord5(node)) {
819
1082
  throw new Error(`Node at index ${index} must be an object`);
820
1083
  }
821
1084
  if (typeof node.id !== "string" || node.id.length === 0) {
@@ -824,7 +1087,7 @@ var assertPageStudioDocumentV1 = (value) => {
824
1087
  if (typeof node.type !== "string" || node.type.length === 0) {
825
1088
  throw new Error(`Node at index ${index} has invalid type`);
826
1089
  }
827
- if (!isRecord3(node.data)) {
1090
+ if (!isRecord5(node.data)) {
828
1091
  throw new Error(`Node at index ${index} has invalid data`);
829
1092
  }
830
1093
  return {
@@ -834,7 +1097,7 @@ var assertPageStudioDocumentV1 = (value) => {
834
1097
  };
835
1098
  });
836
1099
  return {
837
- metadata: isRecord3(value.metadata) ? value.metadata : void 0,
1100
+ metadata: isRecord5(value.metadata) ? value.metadata : void 0,
838
1101
  nodes,
839
1102
  schemaVersion: 1,
840
1103
  title: typeof value.title === "string" ? value.title : void 0,
@@ -896,11 +1159,14 @@ var defaultNodeData = {
896
1159
  }),
897
1160
  cta: {
898
1161
  ...withSectionStyleDefaults({}),
899
- backgroundColor: "#1f684f",
1162
+ backgroundColor: "",
1163
+ bullets: [],
900
1164
  buttonHref: "/contact",
901
1165
  buttonLabel: "Contact Us",
902
1166
  description: "Optional supporting copy.",
1167
+ eyebrow: "",
903
1168
  headline: "Ready to get started?",
1169
+ imageURL: "",
904
1170
  style: "light"
905
1171
  },
906
1172
  faq: {
@@ -916,6 +1182,7 @@ var defaultNodeData = {
916
1182
  { description: "Explain this point.", iconType: "badge", icon: "02", imageCornerStyle: "rounded", imageFit: "cover", imagePosition: "center", title: "Feature Two" },
917
1183
  { description: "Explain this point.", iconType: "badge", icon: "03", imageCornerStyle: "rounded", imageFit: "cover", imagePosition: "center", title: "Feature Three" }
918
1184
  ],
1185
+ subtitle: "",
919
1186
  title: "Section Title",
920
1187
  variant: "cards"
921
1188
  },
@@ -923,16 +1190,18 @@ var defaultNodeData = {
923
1190
  ...withSectionStyleDefaults({}),
924
1191
  description: "Collect lead details from visitors.",
925
1192
  formType: "quote",
1193
+ submitLabel: "Submit",
926
1194
  title: "Request a Quote"
927
1195
  },
928
1196
  hero: {
929
1197
  ...withSectionStyleDefaults({}),
930
1198
  backgroundColor: "",
1199
+ backgroundImageURL: "",
931
1200
  backgroundOverlayMode: "none",
932
1201
  backgroundOverlayOpacity: 45,
933
1202
  backgroundOverlayColor: "#000000",
934
- backgroundOverlayGradientFrom: "#0d4a37",
935
- backgroundOverlayGradientTo: "#1f684f",
1203
+ backgroundOverlayGradientFrom: "#334b63",
1204
+ backgroundOverlayGradientTo: "#496582",
936
1205
  backgroundOverlayGradientAngle: "135",
937
1206
  backgroundOverlayGradientFromStrength: 100,
938
1207
  backgroundOverlayGradientToStrength: 100,
@@ -966,11 +1235,12 @@ var defaultNodeData = {
966
1235
  { imageCornerStyle: "rounded", imageFit: "contain", imagePosition: "center", name: "Trusted Partner 2" },
967
1236
  { imageCornerStyle: "rounded", imageFit: "contain", imagePosition: "center", name: "Trusted Partner 3" }
968
1237
  ],
969
- subtitle: "Trusted by teams and homeowners across Central Texas.",
970
- title: "Trusted by Local Organizations"
1238
+ subtitle: "Show logos from trusted associations, partners, or collaborators.",
1239
+ title: "Trusted by Great Partners"
971
1240
  }),
972
1241
  richText: {
973
1242
  ...withSectionStyleDefaults({}),
1243
+ cards: [],
974
1244
  content: {
975
1245
  root: {
976
1246
  children: [
@@ -1000,6 +1270,7 @@ var defaultNodeData = {
1000
1270
  version: 1
1001
1271
  }
1002
1272
  },
1273
+ statsItems: [],
1003
1274
  title: "Section Heading",
1004
1275
  width: "normal"
1005
1276
  },
@@ -1013,9 +1284,9 @@ var defaultNodeData = {
1013
1284
  },
1014
1285
  stats: withSectionStyleDefaults({
1015
1286
  items: [
1016
- { description: "Average response time", label: "Same-Day Quotes", value: "24h" },
1017
- { description: "Projects completed", label: "Completed Jobs", value: "1,200+" },
1018
- { description: "Client satisfaction score", label: "Satisfaction", value: "4.9/5" }
1287
+ { description: "Average first response", label: "Response Time", value: "24h" },
1288
+ { description: "Client satisfaction score", label: "Satisfaction", value: "4.9/5" },
1289
+ { description: "Recent projects or clients served", label: "Recent Work", value: "150+" }
1019
1290
  ],
1020
1291
  subtitle: "Highlight measurable outcomes to build trust quickly.",
1021
1292
  title: "Performance Highlights"
@@ -1146,54 +1417,18 @@ var pageStudioModuleManifest = {
1146
1417
  { action: "publish", role: "editor" }
1147
1418
  ]
1148
1419
  };
1149
- var ensureNodeID = (inputID, index) => {
1150
- if (typeof inputID === "string" && inputID.length > 0) {
1151
- return inputID;
1152
- }
1153
- return `node-${index + 1}`;
1154
- };
1155
- var layoutToStudioDocument = (layout, title, metadata) => {
1156
- const nodes = layout.filter((block) => typeof block.blockType === "string").map((rawBlock, index) => {
1157
- const block = migrateBlockToSettingsV2(rawBlock);
1158
- const blockType = String(block.blockType);
1159
- const { id, blockType: _ignoredBlockType, ...data } = block;
1160
- return {
1161
- id: ensureNodeID(id, index),
1162
- type: blockType,
1163
- data
1164
- };
1165
- });
1166
- return {
1167
- metadata,
1168
- schemaVersion: 1,
1169
- title,
1170
- nodes,
1171
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1172
- };
1173
- };
1174
- var studioDocumentToLayout = (document) => document.nodes.map(
1175
- (node) => migrateBlockToSettingsV2({
1176
- id: node.id,
1177
- blockType: node.type,
1178
- ...node.data
1179
- })
1180
- );
1181
- var createDefaultStudioDocument = (title) => ({
1182
- metadata: {},
1183
- schemaVersion: 1,
1184
- title,
1185
- nodes: [],
1186
- updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1187
- });
1188
1420
  // Annotate the CommonJS export names for ESM import in node:
1189
1421
  0 && (module.exports = {
1190
1422
  createDefaultStudioDocument,
1423
+ createStudioPageService,
1191
1424
  defaultBuilderThemeTokens,
1425
+ getStudioDocumentFromPage,
1192
1426
  layoutToStudioDocument,
1193
1427
  pageInspectorPanels,
1194
1428
  pageNodeTypes,
1195
1429
  pagePaletteGroups,
1196
1430
  pageStudioModuleManifest,
1197
1431
  resolveBuilderThemeTokens,
1198
- studioDocumentToLayout
1432
+ studioDocumentToLayout,
1433
+ toEditorInitialDoc
1199
1434
  });