@delmaredigital/payload-puck 0.1.0

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 (128) hide show
  1. package/LICENSE +73 -0
  2. package/README.md +1580 -0
  3. package/dist/AccordionClient.d.mts +24 -0
  4. package/dist/AccordionClient.d.ts +24 -0
  5. package/dist/AccordionClient.js +786 -0
  6. package/dist/AccordionClient.js.map +1 -0
  7. package/dist/AccordionClient.mjs +784 -0
  8. package/dist/AccordionClient.mjs.map +1 -0
  9. package/dist/AnimatedWrapper.d.mts +30 -0
  10. package/dist/AnimatedWrapper.d.ts +30 -0
  11. package/dist/AnimatedWrapper.js +379 -0
  12. package/dist/AnimatedWrapper.js.map +1 -0
  13. package/dist/AnimatedWrapper.mjs +377 -0
  14. package/dist/AnimatedWrapper.mjs.map +1 -0
  15. package/dist/admin/client.d.mts +108 -0
  16. package/dist/admin/client.d.ts +108 -0
  17. package/dist/admin/client.js +177 -0
  18. package/dist/admin/client.js.map +1 -0
  19. package/dist/admin/client.mjs +173 -0
  20. package/dist/admin/client.mjs.map +1 -0
  21. package/dist/admin/index.d.mts +157 -0
  22. package/dist/admin/index.d.ts +157 -0
  23. package/dist/admin/index.js +31 -0
  24. package/dist/admin/index.js.map +1 -0
  25. package/dist/admin/index.mjs +29 -0
  26. package/dist/admin/index.mjs.map +1 -0
  27. package/dist/api/index.d.mts +460 -0
  28. package/dist/api/index.d.ts +460 -0
  29. package/dist/api/index.js +588 -0
  30. package/dist/api/index.js.map +1 -0
  31. package/dist/api/index.mjs +578 -0
  32. package/dist/api/index.mjs.map +1 -0
  33. package/dist/components/index.css +339 -0
  34. package/dist/components/index.css.map +1 -0
  35. package/dist/components/index.d.mts +222 -0
  36. package/dist/components/index.d.ts +222 -0
  37. package/dist/components/index.js +9177 -0
  38. package/dist/components/index.js.map +1 -0
  39. package/dist/components/index.mjs +9130 -0
  40. package/dist/components/index.mjs.map +1 -0
  41. package/dist/config/config.editor.css +339 -0
  42. package/dist/config/config.editor.css.map +1 -0
  43. package/dist/config/config.editor.d.mts +153 -0
  44. package/dist/config/config.editor.d.ts +153 -0
  45. package/dist/config/config.editor.js +9400 -0
  46. package/dist/config/config.editor.js.map +1 -0
  47. package/dist/config/config.editor.mjs +9368 -0
  48. package/dist/config/config.editor.mjs.map +1 -0
  49. package/dist/config/index.d.mts +68 -0
  50. package/dist/config/index.d.ts +68 -0
  51. package/dist/config/index.js +2017 -0
  52. package/dist/config/index.js.map +1 -0
  53. package/dist/config/index.mjs +1991 -0
  54. package/dist/config/index.mjs.map +1 -0
  55. package/dist/editor/index.d.mts +784 -0
  56. package/dist/editor/index.d.ts +784 -0
  57. package/dist/editor/index.js +4517 -0
  58. package/dist/editor/index.js.map +1 -0
  59. package/dist/editor/index.mjs +4483 -0
  60. package/dist/editor/index.mjs.map +1 -0
  61. package/dist/fields/index.css +339 -0
  62. package/dist/fields/index.css.map +1 -0
  63. package/dist/fields/index.d.mts +600 -0
  64. package/dist/fields/index.d.ts +600 -0
  65. package/dist/fields/index.js +7739 -0
  66. package/dist/fields/index.js.map +1 -0
  67. package/dist/fields/index.mjs +7590 -0
  68. package/dist/fields/index.mjs.map +1 -0
  69. package/dist/index-CQu6SzDg.d.mts +327 -0
  70. package/dist/index-CoUQnyC3.d.ts +327 -0
  71. package/dist/index.d.mts +6 -0
  72. package/dist/index.d.ts +6 -0
  73. package/dist/index.js +569 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/index.mjs +555 -0
  76. package/dist/index.mjs.map +1 -0
  77. package/dist/layouts/index.d.mts +96 -0
  78. package/dist/layouts/index.d.ts +96 -0
  79. package/dist/layouts/index.js +394 -0
  80. package/dist/layouts/index.js.map +1 -0
  81. package/dist/layouts/index.mjs +378 -0
  82. package/dist/layouts/index.mjs.map +1 -0
  83. package/dist/plugin/index.d.mts +289 -0
  84. package/dist/plugin/index.d.ts +289 -0
  85. package/dist/plugin/index.js +569 -0
  86. package/dist/plugin/index.js.map +1 -0
  87. package/dist/plugin/index.mjs +555 -0
  88. package/dist/plugin/index.mjs.map +1 -0
  89. package/dist/render/index.d.mts +109 -0
  90. package/dist/render/index.d.ts +109 -0
  91. package/dist/render/index.js +2146 -0
  92. package/dist/render/index.js.map +1 -0
  93. package/dist/render/index.mjs +2123 -0
  94. package/dist/render/index.mjs.map +1 -0
  95. package/dist/shared-DMAF1AcH.d.mts +545 -0
  96. package/dist/shared-DMAF1AcH.d.ts +545 -0
  97. package/dist/theme/index.d.mts +155 -0
  98. package/dist/theme/index.d.ts +155 -0
  99. package/dist/theme/index.js +201 -0
  100. package/dist/theme/index.js.map +1 -0
  101. package/dist/theme/index.mjs +186 -0
  102. package/dist/theme/index.mjs.map +1 -0
  103. package/dist/types-D7D3rZ1J.d.mts +116 -0
  104. package/dist/types-D7D3rZ1J.d.ts +116 -0
  105. package/dist/types-_6MvjyKv.d.mts +104 -0
  106. package/dist/types-_6MvjyKv.d.ts +104 -0
  107. package/dist/utils/index.d.mts +267 -0
  108. package/dist/utils/index.d.ts +267 -0
  109. package/dist/utils/index.js +426 -0
  110. package/dist/utils/index.js.map +1 -0
  111. package/dist/utils/index.mjs +412 -0
  112. package/dist/utils/index.mjs.map +1 -0
  113. package/dist/utils-DaRs9t0J.d.mts +85 -0
  114. package/dist/utils-gAvt0Vhw.d.ts +85 -0
  115. package/examples/README.md +240 -0
  116. package/examples/api/puck/pages/[id]/route.ts +64 -0
  117. package/examples/api/puck/pages/[id]/versions/route.ts +47 -0
  118. package/examples/api/puck/pages/route.ts +45 -0
  119. package/examples/app/(frontend)/page.tsx +94 -0
  120. package/examples/app/[...slug]/page.tsx +101 -0
  121. package/examples/app/pages/[id]/edit/page.tsx +148 -0
  122. package/examples/components/CustomBanner.tsx +368 -0
  123. package/examples/config/custom-config.ts +223 -0
  124. package/examples/config/payload.config.example.ts +64 -0
  125. package/examples/lib/puck-layouts.ts +258 -0
  126. package/examples/lib/puck-theme.ts +94 -0
  127. package/examples/styles/puck-theme.css +171 -0
  128. package/package.json +157 -0
@@ -0,0 +1,116 @@
1
+ import { CSSProperties, ReactNode, ComponentType } from 'react';
2
+
3
+ /**
4
+ * Layout System Types
5
+ *
6
+ * Defines the structure for page layouts that affect how content is rendered.
7
+ */
8
+
9
+ /**
10
+ * A layout option shown in the Puck editor's layout selector
11
+ */
12
+ interface LayoutOption {
13
+ /** Unique identifier for the layout */
14
+ value: string;
15
+ /** Display name in the editor */
16
+ label: string;
17
+ /** Optional description shown in the editor */
18
+ description?: string;
19
+ }
20
+ /**
21
+ * CSS class configuration for a layout
22
+ */
23
+ interface LayoutClasses {
24
+ /** Classes applied to the outermost wrapper */
25
+ wrapper?: string;
26
+ /** Classes applied to the main content container */
27
+ container?: string;
28
+ /** Classes applied to the content area */
29
+ content?: string;
30
+ }
31
+ /**
32
+ * Style configuration for a layout
33
+ */
34
+ interface LayoutStyles {
35
+ /** Styles applied to the outermost wrapper */
36
+ wrapper?: CSSProperties;
37
+ /** Styles applied to the main content container */
38
+ container?: CSSProperties;
39
+ /** Styles applied to the content area */
40
+ content?: CSSProperties;
41
+ }
42
+ /**
43
+ * Complete layout definition
44
+ */
45
+ interface LayoutDefinition extends LayoutOption {
46
+ /** CSS classes to apply */
47
+ classes?: LayoutClasses;
48
+ /** Inline styles to apply */
49
+ styles?: LayoutStyles;
50
+ /** Custom wrapper component (overrides default rendering) */
51
+ wrapper?: React.ComponentType<{
52
+ children: ReactNode;
53
+ }>;
54
+ /** Max width constraint (e.g., '1200px', '100%') */
55
+ maxWidth?: string;
56
+ /** Whether the layout uses full viewport width */
57
+ fullWidth?: boolean;
58
+ /** Additional data attributes to add */
59
+ dataAttributes?: Record<string, string>;
60
+ /**
61
+ * Header component to render above the page content.
62
+ * Shown in both the editor preview and the rendered page.
63
+ */
64
+ header?: ComponentType;
65
+ /**
66
+ * Footer component to render below the page content.
67
+ * Shown in both the editor preview and the rendered page.
68
+ */
69
+ footer?: ComponentType;
70
+ /**
71
+ * Background color/gradient for the editor preview.
72
+ * Applied to the iframe body in the Puck editor.
73
+ * @default '#ffffff'
74
+ */
75
+ editorBackground?: string;
76
+ /**
77
+ * Whether this layout uses dark mode styling in the editor preview.
78
+ * Controls text color and theme class on the iframe.
79
+ * @default false
80
+ */
81
+ editorDarkMode?: boolean;
82
+ /**
83
+ * Height of a sticky/fixed header in pixels.
84
+ * Used to add padding-top to the content area in the editor preview
85
+ * so content doesn't render behind the header.
86
+ * @example 64 // for a 64px tall sticky header
87
+ */
88
+ stickyHeaderHeight?: number;
89
+ /**
90
+ * Whether to push the footer to the bottom of the viewport.
91
+ * Uses flexbox to ensure the footer stays at the bottom even when
92
+ * page content is minimal. Set to `false` to allow footer to flow
93
+ * naturally after content.
94
+ * @default true
95
+ */
96
+ stickyFooter?: boolean;
97
+ }
98
+ /**
99
+ * Layout configuration passed to the plugin/renderer
100
+ */
101
+ interface LayoutConfig {
102
+ /** Available layouts */
103
+ layouts: LayoutDefinition[];
104
+ /** Default layout value to use */
105
+ defaultLayout?: string;
106
+ }
107
+ /**
108
+ * Props passed to a custom layout wrapper component
109
+ */
110
+ interface LayoutWrapperProps {
111
+ children: ReactNode;
112
+ layout: LayoutDefinition;
113
+ pageTitle?: string;
114
+ }
115
+
116
+ export type { LayoutDefinition as L, LayoutConfig as a, LayoutOption as b, LayoutClasses as c, LayoutStyles as d, LayoutWrapperProps as e };
@@ -0,0 +1,116 @@
1
+ import { CSSProperties, ReactNode, ComponentType } from 'react';
2
+
3
+ /**
4
+ * Layout System Types
5
+ *
6
+ * Defines the structure for page layouts that affect how content is rendered.
7
+ */
8
+
9
+ /**
10
+ * A layout option shown in the Puck editor's layout selector
11
+ */
12
+ interface LayoutOption {
13
+ /** Unique identifier for the layout */
14
+ value: string;
15
+ /** Display name in the editor */
16
+ label: string;
17
+ /** Optional description shown in the editor */
18
+ description?: string;
19
+ }
20
+ /**
21
+ * CSS class configuration for a layout
22
+ */
23
+ interface LayoutClasses {
24
+ /** Classes applied to the outermost wrapper */
25
+ wrapper?: string;
26
+ /** Classes applied to the main content container */
27
+ container?: string;
28
+ /** Classes applied to the content area */
29
+ content?: string;
30
+ }
31
+ /**
32
+ * Style configuration for a layout
33
+ */
34
+ interface LayoutStyles {
35
+ /** Styles applied to the outermost wrapper */
36
+ wrapper?: CSSProperties;
37
+ /** Styles applied to the main content container */
38
+ container?: CSSProperties;
39
+ /** Styles applied to the content area */
40
+ content?: CSSProperties;
41
+ }
42
+ /**
43
+ * Complete layout definition
44
+ */
45
+ interface LayoutDefinition extends LayoutOption {
46
+ /** CSS classes to apply */
47
+ classes?: LayoutClasses;
48
+ /** Inline styles to apply */
49
+ styles?: LayoutStyles;
50
+ /** Custom wrapper component (overrides default rendering) */
51
+ wrapper?: React.ComponentType<{
52
+ children: ReactNode;
53
+ }>;
54
+ /** Max width constraint (e.g., '1200px', '100%') */
55
+ maxWidth?: string;
56
+ /** Whether the layout uses full viewport width */
57
+ fullWidth?: boolean;
58
+ /** Additional data attributes to add */
59
+ dataAttributes?: Record<string, string>;
60
+ /**
61
+ * Header component to render above the page content.
62
+ * Shown in both the editor preview and the rendered page.
63
+ */
64
+ header?: ComponentType;
65
+ /**
66
+ * Footer component to render below the page content.
67
+ * Shown in both the editor preview and the rendered page.
68
+ */
69
+ footer?: ComponentType;
70
+ /**
71
+ * Background color/gradient for the editor preview.
72
+ * Applied to the iframe body in the Puck editor.
73
+ * @default '#ffffff'
74
+ */
75
+ editorBackground?: string;
76
+ /**
77
+ * Whether this layout uses dark mode styling in the editor preview.
78
+ * Controls text color and theme class on the iframe.
79
+ * @default false
80
+ */
81
+ editorDarkMode?: boolean;
82
+ /**
83
+ * Height of a sticky/fixed header in pixels.
84
+ * Used to add padding-top to the content area in the editor preview
85
+ * so content doesn't render behind the header.
86
+ * @example 64 // for a 64px tall sticky header
87
+ */
88
+ stickyHeaderHeight?: number;
89
+ /**
90
+ * Whether to push the footer to the bottom of the viewport.
91
+ * Uses flexbox to ensure the footer stays at the bottom even when
92
+ * page content is minimal. Set to `false` to allow footer to flow
93
+ * naturally after content.
94
+ * @default true
95
+ */
96
+ stickyFooter?: boolean;
97
+ }
98
+ /**
99
+ * Layout configuration passed to the plugin/renderer
100
+ */
101
+ interface LayoutConfig {
102
+ /** Available layouts */
103
+ layouts: LayoutDefinition[];
104
+ /** Default layout value to use */
105
+ defaultLayout?: string;
106
+ }
107
+ /**
108
+ * Props passed to a custom layout wrapper component
109
+ */
110
+ interface LayoutWrapperProps {
111
+ children: ReactNode;
112
+ layout: LayoutDefinition;
113
+ pageTitle?: string;
114
+ }
115
+
116
+ export type { LayoutDefinition as L, LayoutConfig as a, LayoutOption as b, LayoutClasses as c, LayoutStyles as d, LayoutWrapperProps as e };
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Theme Type Definitions
3
+ *
4
+ * Defines all theme-related TypeScript interfaces for the payload-puck plugin.
5
+ * These types enable consuming applications to customize button variants,
6
+ * color presets, and other visual styles.
7
+ */
8
+ /**
9
+ * Configuration for a single button variant
10
+ */
11
+ interface ButtonVariantConfig {
12
+ /** Tailwind classes for the variant */
13
+ classes: string;
14
+ /** Optional CSS variable reference for dynamic theming */
15
+ cssVariable?: string;
16
+ }
17
+ /**
18
+ * Map of button variant names to their configurations
19
+ */
20
+ interface ButtonVariantStyles {
21
+ default?: ButtonVariantConfig;
22
+ primary?: ButtonVariantConfig;
23
+ secondary?: ButtonVariantConfig;
24
+ outline?: ButtonVariantConfig;
25
+ ghost?: ButtonVariantConfig;
26
+ destructive?: ButtonVariantConfig;
27
+ link?: ButtonVariantConfig;
28
+ [key: string]: ButtonVariantConfig | undefined;
29
+ }
30
+ /**
31
+ * Color preset for the color picker
32
+ */
33
+ interface ColorPreset {
34
+ /** Hex color value (e.g., '#3b82f6') */
35
+ hex: string;
36
+ /** Display label for the preset */
37
+ label: string;
38
+ /** Optional CSS variable reference (e.g., 'var(--color-primary)') */
39
+ cssVariable?: string;
40
+ }
41
+ /**
42
+ * Background style configurations for CTA components
43
+ */
44
+ interface BackgroundStyles {
45
+ default?: string;
46
+ dark?: string;
47
+ light?: string;
48
+ [key: string]: string | undefined;
49
+ }
50
+ /**
51
+ * Theme configuration provided by consuming applications
52
+ * All properties are optional and will be merged with defaults
53
+ */
54
+ interface ThemeConfig {
55
+ /**
56
+ * Button variant styles
57
+ * Merged with default button variants
58
+ */
59
+ buttonVariants?: Partial<ButtonVariantStyles>;
60
+ /**
61
+ * CTA button variant styles
62
+ * Merged with default CTA button variants
63
+ */
64
+ ctaButtonVariants?: Partial<ButtonVariantStyles>;
65
+ /**
66
+ * CTA background styles
67
+ * Merged with default background styles
68
+ */
69
+ ctaBackgroundStyles?: Partial<BackgroundStyles>;
70
+ /**
71
+ * Color picker preset colors
72
+ * If provided, replaces defaults unless extendColorPresets is true
73
+ */
74
+ colorPresets?: ColorPreset[];
75
+ /**
76
+ * Whether to extend default color presets (true) or replace them (false)
77
+ * @default false
78
+ */
79
+ extendColorPresets?: boolean;
80
+ /**
81
+ * Focus ring color class (e.g., 'focus:ring-primary')
82
+ * @default 'focus:ring-blue-500'
83
+ */
84
+ focusRingColor?: string;
85
+ }
86
+ /**
87
+ * Fully resolved theme with all defaults applied
88
+ * This is what components receive via useTheme()
89
+ */
90
+ interface ResolvedTheme {
91
+ buttonVariants: ButtonVariantStyles;
92
+ ctaButtonVariants: ButtonVariantStyles;
93
+ ctaBackgroundStyles: BackgroundStyles;
94
+ colorPresets: ColorPreset[];
95
+ focusRingColor: string;
96
+ }
97
+ /**
98
+ * Theme context value provided by ThemeProvider
99
+ */
100
+ interface ThemeContextValue {
101
+ theme: ResolvedTheme;
102
+ }
103
+
104
+ export type { ButtonVariantStyles as B, ColorPreset as C, ResolvedTheme as R, ThemeConfig as T, BackgroundStyles as a, ButtonVariantConfig as b, ThemeContextValue as c };
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Theme Type Definitions
3
+ *
4
+ * Defines all theme-related TypeScript interfaces for the payload-puck plugin.
5
+ * These types enable consuming applications to customize button variants,
6
+ * color presets, and other visual styles.
7
+ */
8
+ /**
9
+ * Configuration for a single button variant
10
+ */
11
+ interface ButtonVariantConfig {
12
+ /** Tailwind classes for the variant */
13
+ classes: string;
14
+ /** Optional CSS variable reference for dynamic theming */
15
+ cssVariable?: string;
16
+ }
17
+ /**
18
+ * Map of button variant names to their configurations
19
+ */
20
+ interface ButtonVariantStyles {
21
+ default?: ButtonVariantConfig;
22
+ primary?: ButtonVariantConfig;
23
+ secondary?: ButtonVariantConfig;
24
+ outline?: ButtonVariantConfig;
25
+ ghost?: ButtonVariantConfig;
26
+ destructive?: ButtonVariantConfig;
27
+ link?: ButtonVariantConfig;
28
+ [key: string]: ButtonVariantConfig | undefined;
29
+ }
30
+ /**
31
+ * Color preset for the color picker
32
+ */
33
+ interface ColorPreset {
34
+ /** Hex color value (e.g., '#3b82f6') */
35
+ hex: string;
36
+ /** Display label for the preset */
37
+ label: string;
38
+ /** Optional CSS variable reference (e.g., 'var(--color-primary)') */
39
+ cssVariable?: string;
40
+ }
41
+ /**
42
+ * Background style configurations for CTA components
43
+ */
44
+ interface BackgroundStyles {
45
+ default?: string;
46
+ dark?: string;
47
+ light?: string;
48
+ [key: string]: string | undefined;
49
+ }
50
+ /**
51
+ * Theme configuration provided by consuming applications
52
+ * All properties are optional and will be merged with defaults
53
+ */
54
+ interface ThemeConfig {
55
+ /**
56
+ * Button variant styles
57
+ * Merged with default button variants
58
+ */
59
+ buttonVariants?: Partial<ButtonVariantStyles>;
60
+ /**
61
+ * CTA button variant styles
62
+ * Merged with default CTA button variants
63
+ */
64
+ ctaButtonVariants?: Partial<ButtonVariantStyles>;
65
+ /**
66
+ * CTA background styles
67
+ * Merged with default background styles
68
+ */
69
+ ctaBackgroundStyles?: Partial<BackgroundStyles>;
70
+ /**
71
+ * Color picker preset colors
72
+ * If provided, replaces defaults unless extendColorPresets is true
73
+ */
74
+ colorPresets?: ColorPreset[];
75
+ /**
76
+ * Whether to extend default color presets (true) or replace them (false)
77
+ * @default false
78
+ */
79
+ extendColorPresets?: boolean;
80
+ /**
81
+ * Focus ring color class (e.g., 'focus:ring-primary')
82
+ * @default 'focus:ring-blue-500'
83
+ */
84
+ focusRingColor?: string;
85
+ }
86
+ /**
87
+ * Fully resolved theme with all defaults applied
88
+ * This is what components receive via useTheme()
89
+ */
90
+ interface ResolvedTheme {
91
+ buttonVariants: ButtonVariantStyles;
92
+ ctaButtonVariants: ButtonVariantStyles;
93
+ ctaBackgroundStyles: BackgroundStyles;
94
+ colorPresets: ColorPreset[];
95
+ focusRingColor: string;
96
+ }
97
+ /**
98
+ * Theme context value provided by ThemeProvider
99
+ */
100
+ interface ThemeContextValue {
101
+ theme: ResolvedTheme;
102
+ }
103
+
104
+ export type { ButtonVariantStyles as B, ColorPreset as C, ResolvedTheme as R, ThemeConfig as T, BackgroundStyles as a, ButtonVariantConfig as b, ThemeContextValue as c };
@@ -0,0 +1,267 @@
1
+ import { P as PuckPageData, M as MediaObject, a as PuckRootProps } from '../index-CQu6SzDg.mjs';
2
+ import 'payload';
3
+ import '@measured/puck';
4
+ import '../types-D7D3rZ1J.mjs';
5
+ import 'react';
6
+
7
+ /**
8
+ * Migration Utility for Converting Legacy Payload CMS Pages to Puck Format
9
+ *
10
+ * This utility converts legacy Payload CMS page block structures to the
11
+ * Puck visual editor format, enabling seamless migration of existing content.
12
+ */
13
+
14
+ /**
15
+ * Legacy block from Payload CMS pages.
16
+ * Each block has a blockType discriminator and various props.
17
+ */
18
+ interface LegacyBlock {
19
+ blockType: string;
20
+ id?: string | null;
21
+ blockName?: string | null;
22
+ [key: string]: unknown;
23
+ }
24
+ /**
25
+ * Subset of Page type used for migration.
26
+ * Only includes fields relevant to content migration.
27
+ */
28
+ interface LegacyPage {
29
+ title: string;
30
+ slug: string;
31
+ pageLayout?: string;
32
+ layout?: LegacyBlock[] | null;
33
+ [key: string]: unknown;
34
+ }
35
+ /**
36
+ * Media reference in Puck format
37
+ */
38
+ interface MediaReference {
39
+ id: string | number;
40
+ url?: string;
41
+ alt?: string;
42
+ width?: number;
43
+ height?: number;
44
+ }
45
+ /**
46
+ * Puck content item structure
47
+ */
48
+ interface PuckContentItem {
49
+ type: string;
50
+ props: {
51
+ id: string;
52
+ [key: string]: unknown;
53
+ };
54
+ }
55
+ /**
56
+ * Maps legacy Payload block types (camelCase) to Puck component types (PascalCase).
57
+ * Extend this map to support additional custom block types.
58
+ */
59
+ declare const blockTypeMap: Record<string, string>;
60
+ /**
61
+ * Generates a unique ID for Puck content items.
62
+ * Uses a format compatible with Puck's internal ID scheme.
63
+ */
64
+ declare function generatePuckId(legacyId?: string | null): string;
65
+ /**
66
+ * Transforms a Payload media reference (ID or Media object) to Puck MediaReference format.
67
+ * Handles both ID-only references and full Media objects.
68
+ */
69
+ declare function transformMediaReference(media: string | number | {
70
+ id: string | number;
71
+ url?: string;
72
+ alt?: string;
73
+ width?: number;
74
+ height?: number;
75
+ } | MediaObject | null | undefined): MediaReference | null;
76
+ /**
77
+ * Transforms Lexical rich text content to a serialized string format.
78
+ * Puck stores rich text as JSON strings for the custom editors.
79
+ */
80
+ declare function transformRichText(richText: unknown): string | undefined;
81
+ /**
82
+ * Transforms an array of relationships to Puck format.
83
+ */
84
+ declare function transformRelationshipArray<T extends {
85
+ id: string | number;
86
+ title?: string;
87
+ slug?: string;
88
+ }>(relations: (string | number | T)[] | null | undefined): Array<{
89
+ id: string | number;
90
+ title: string;
91
+ slug?: string;
92
+ }> | undefined;
93
+ /**
94
+ * Transform props for a specific block type.
95
+ * Handles any block-specific transformations needed.
96
+ */
97
+ declare function transformBlockProps(block: LegacyBlock, options?: {
98
+ richTextFields?: string[];
99
+ mediaFields?: string[];
100
+ customTransformers?: Record<string, (value: unknown) => unknown>;
101
+ }): Record<string, unknown>;
102
+ /**
103
+ * Options for the migration function
104
+ */
105
+ interface MigrateLegacyOptions {
106
+ /**
107
+ * Custom block type mapping to extend or override defaults
108
+ */
109
+ blockTypeMap?: Record<string, string>;
110
+ /**
111
+ * Additional rich text field names to transform
112
+ */
113
+ richTextFields?: string[];
114
+ /**
115
+ * Additional media field names to transform
116
+ */
117
+ mediaFields?: string[];
118
+ /**
119
+ * Custom prop transformers for specific field names
120
+ */
121
+ customTransformers?: Record<string, (value: unknown) => unknown>;
122
+ /**
123
+ * Whether to skip unknown block types (default: true)
124
+ * If false, unknown blocks will throw an error
125
+ */
126
+ skipUnknownBlocks?: boolean;
127
+ /**
128
+ * Callback for handling unknown block types
129
+ */
130
+ onUnknownBlock?: (block: LegacyBlock) => PuckContentItem | null;
131
+ }
132
+ /**
133
+ * Migrates a legacy Payload CMS page to Puck format.
134
+ *
135
+ * This function:
136
+ * 1. Extracts root props (title, pageLayout, etc.)
137
+ * 2. Converts each block in the layout array to a Puck content item
138
+ * 3. Maps block types from camelCase to PascalCase using blockTypeMap
139
+ * 4. Transforms block props appropriately
140
+ *
141
+ * @param page - The legacy Page object from Payload CMS
142
+ * @param options - Migration options
143
+ * @returns PuckPageData ready for use with the Puck editor
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * const legacyPage = await payload.findByID({ collection: 'pages', id: pageId })
148
+ * const puckData = migrateLegacyToPuck(legacyPage)
149
+ * await payload.update({
150
+ * collection: 'pages',
151
+ * id: pageId,
152
+ * data: { puckData },
153
+ * })
154
+ * ```
155
+ */
156
+ declare function migrateLegacyToPuck(page: LegacyPage, options?: MigrateLegacyOptions): PuckPageData;
157
+ /**
158
+ * Migration preview result
159
+ */
160
+ interface MigrationPreview {
161
+ title: string;
162
+ slug: string;
163
+ blockCount: number;
164
+ blockTypes: string[];
165
+ warnings: string[];
166
+ unmappedBlockTypes: string[];
167
+ }
168
+ /**
169
+ * Gets a summary of a legacy page for migration preview.
170
+ * Useful for showing users what will be migrated before committing.
171
+ *
172
+ * @param page - The legacy page to preview
173
+ * @param customBlockTypeMap - Optional custom block type mapping
174
+ * @returns Preview information about the migration
175
+ */
176
+ declare function getMigrationPreview(page: LegacyPage, customBlockTypeMap?: Record<string, string>): MigrationPreview;
177
+
178
+ /**
179
+ * Puck Data Validation Utilities
180
+ *
181
+ * Provides validation functions for ensuring Puck data structures are well-formed.
182
+ */
183
+
184
+ /**
185
+ * Result of a validation operation
186
+ */
187
+ interface ValidationResult {
188
+ valid: boolean;
189
+ errors: string[];
190
+ warnings: string[];
191
+ }
192
+ /**
193
+ * Options for validation
194
+ */
195
+ interface ValidationOptions {
196
+ /**
197
+ * Whether to validate that all content items have IDs
198
+ * @default true
199
+ */
200
+ requireContentIds?: boolean;
201
+ /**
202
+ * Whether to validate root props
203
+ * @default true
204
+ */
205
+ validateRoot?: boolean;
206
+ /**
207
+ * Required root prop fields
208
+ * @default ['title']
209
+ */
210
+ requiredRootProps?: string[];
211
+ /**
212
+ * Allowed component types (if specified, unknown types will be flagged)
213
+ */
214
+ allowedComponentTypes?: string[];
215
+ /**
216
+ * Whether to treat unknown component types as errors (vs warnings)
217
+ * @default false
218
+ */
219
+ strictComponentTypes?: boolean;
220
+ }
221
+ /**
222
+ * Type guard to check if a value is a valid PuckPageData structure.
223
+ * Performs basic structural validation.
224
+ */
225
+ declare function isPuckData(data: unknown): data is PuckPageData;
226
+ /**
227
+ * Type guard for PuckRootProps
228
+ */
229
+ declare function isPuckRootProps(props: unknown): props is PuckRootProps;
230
+ /**
231
+ * Validates that a PuckPageData structure is well-formed.
232
+ * Useful for testing and debugging migration issues.
233
+ *
234
+ * @param data - The data to validate
235
+ * @param options - Validation options
236
+ * @returns Validation result with errors and warnings
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * const result = validatePuckData(puckData)
241
+ * if (!result.valid) {
242
+ * console.error('Validation errors:', result.errors)
243
+ * }
244
+ * ```
245
+ */
246
+ declare function validatePuckData(data: unknown, options?: ValidationOptions): ValidationResult;
247
+ /**
248
+ * Validates and returns typed PuckPageData, throwing if invalid.
249
+ *
250
+ * @param data - The data to validate
251
+ * @param options - Validation options
252
+ * @returns The validated PuckPageData
253
+ * @throws Error if validation fails
254
+ */
255
+ declare function assertPuckData(data: unknown, options?: ValidationOptions): PuckPageData;
256
+ /**
257
+ * Safely parses JSON and validates as PuckPageData.
258
+ *
259
+ * @param json - JSON string to parse
260
+ * @param options - Validation options
261
+ * @returns Validation result with parsed data if valid
262
+ */
263
+ declare function parsePuckDataJson(json: string, options?: ValidationOptions): ValidationResult & {
264
+ data?: PuckPageData;
265
+ };
266
+
267
+ export { type LegacyBlock, type LegacyPage, type MediaReference, type MigrateLegacyOptions, type MigrationPreview, type PuckContentItem, type ValidationOptions, type ValidationResult, assertPuckData, blockTypeMap, generatePuckId, getMigrationPreview, isPuckData, isPuckRootProps, migrateLegacyToPuck, parsePuckDataJson, transformBlockProps, transformMediaReference, transformRelationshipArray, transformRichText, validatePuckData };