@delmaredigital/payload-puck 0.6.16 → 0.6.18

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 (95) hide show
  1. package/dist/components/email/EmailButton/EmailButton.editor.d.ts +3 -0
  2. package/dist/components/email/EmailButton/EmailButton.editor.js +81 -0
  3. package/dist/components/email/EmailButton/EmailButton.server.d.ts +3 -0
  4. package/dist/components/email/EmailButton/EmailButton.server.js +69 -0
  5. package/dist/components/email/EmailButton/EmailButton.types.d.ts +11 -0
  6. package/dist/components/email/EmailButton/EmailButton.types.js +1 -0
  7. package/dist/components/email/EmailColumns/EmailColumns.editor.d.ts +2 -0
  8. package/dist/components/email/EmailColumns/EmailColumns.editor.js +45 -0
  9. package/dist/components/email/EmailColumns/EmailColumns.server.d.ts +2 -0
  10. package/dist/components/email/EmailColumns/EmailColumns.server.js +58 -0
  11. package/dist/components/email/EmailColumns/EmailColumns.types.d.ts +8 -0
  12. package/dist/components/email/EmailColumns/EmailColumns.types.js +1 -0
  13. package/dist/components/email/EmailDivider/EmailDivider.editor.d.ts +3 -0
  14. package/dist/components/email/EmailDivider/EmailDivider.editor.js +38 -0
  15. package/dist/components/email/EmailDivider/EmailDivider.server.d.ts +3 -0
  16. package/dist/components/email/EmailDivider/EmailDivider.server.js +38 -0
  17. package/dist/components/email/EmailDivider/EmailDivider.types.d.ts +6 -0
  18. package/dist/components/email/EmailDivider/EmailDivider.types.js +1 -0
  19. package/dist/components/email/EmailFooter/EmailFooter.editor.d.ts +3 -0
  20. package/dist/components/email/EmailFooter/EmailFooter.editor.js +22 -0
  21. package/dist/components/email/EmailFooter/EmailFooter.server.d.ts +3 -0
  22. package/dist/components/email/EmailFooter/EmailFooter.server.js +59 -0
  23. package/dist/components/email/EmailFooter/EmailFooter.types.d.ts +6 -0
  24. package/dist/components/email/EmailFooter/EmailFooter.types.js +1 -0
  25. package/dist/components/email/EmailHeader/EmailHeader.editor.d.ts +3 -0
  26. package/dist/components/email/EmailHeader/EmailHeader.editor.js +28 -0
  27. package/dist/components/email/EmailHeader/EmailHeader.server.d.ts +3 -0
  28. package/dist/components/email/EmailHeader/EmailHeader.server.js +60 -0
  29. package/dist/components/email/EmailHeader/EmailHeader.types.d.ts +8 -0
  30. package/dist/components/email/EmailHeader/EmailHeader.types.js +1 -0
  31. package/dist/components/email/EmailHeading/EmailHeading.editor.d.ts +3 -0
  32. package/dist/components/email/EmailHeading/EmailHeading.editor.js +50 -0
  33. package/dist/components/email/EmailHeading/EmailHeading.server.d.ts +3 -0
  34. package/dist/components/email/EmailHeading/EmailHeading.server.js +35 -0
  35. package/dist/components/email/EmailHeading/EmailHeading.types.d.ts +7 -0
  36. package/dist/components/email/EmailHeading/EmailHeading.types.js +1 -0
  37. package/dist/components/email/EmailImage/EmailImage.editor.d.ts +3 -0
  38. package/dist/components/email/EmailImage/EmailImage.editor.js +46 -0
  39. package/dist/components/email/EmailImage/EmailImage.server.d.ts +3 -0
  40. package/dist/components/email/EmailImage/EmailImage.server.js +81 -0
  41. package/dist/components/email/EmailImage/EmailImage.types.d.ts +9 -0
  42. package/dist/components/email/EmailImage/EmailImage.types.js +1 -0
  43. package/dist/components/email/EmailSection/EmailSection.editor.d.ts +2 -0
  44. package/dist/components/email/EmailSection/EmailSection.editor.js +21 -0
  45. package/dist/components/email/EmailSection/EmailSection.server.d.ts +2 -0
  46. package/dist/components/email/EmailSection/EmailSection.server.js +49 -0
  47. package/dist/components/email/EmailSection/EmailSection.types.d.ts +7 -0
  48. package/dist/components/email/EmailSection/EmailSection.types.js +1 -0
  49. package/dist/components/email/EmailSocial/EmailSocial.editor.d.ts +3 -0
  50. package/dist/components/email/EmailSocial/EmailSocial.editor.js +70 -0
  51. package/dist/components/email/EmailSocial/EmailSocial.server.d.ts +3 -0
  52. package/dist/components/email/EmailSocial/EmailSocial.server.js +89 -0
  53. package/dist/components/email/EmailSocial/EmailSocial.types.d.ts +10 -0
  54. package/dist/components/email/EmailSocial/EmailSocial.types.js +1 -0
  55. package/dist/components/email/EmailSpacer/EmailSpacer.editor.d.ts +3 -0
  56. package/dist/components/email/EmailSpacer/EmailSpacer.editor.js +12 -0
  57. package/dist/components/email/EmailSpacer/EmailSpacer.server.d.ts +3 -0
  58. package/dist/components/email/EmailSpacer/EmailSpacer.server.js +25 -0
  59. package/dist/components/email/EmailSpacer/EmailSpacer.types.d.ts +3 -0
  60. package/dist/components/email/EmailSpacer/EmailSpacer.types.js +1 -0
  61. package/dist/components/email/EmailText/EmailText.editor.d.ts +3 -0
  62. package/dist/components/email/EmailText/EmailText.editor.js +102 -0
  63. package/dist/components/email/EmailText/EmailText.server.d.ts +3 -0
  64. package/dist/components/email/EmailText/EmailText.server.js +35 -0
  65. package/dist/components/email/EmailText/EmailText.types.d.ts +8 -0
  66. package/dist/components/email/EmailText/EmailText.types.js +1 -0
  67. package/dist/components/email/EmailWrapper/EmailWrapper.editor.d.ts +2 -0
  68. package/dist/components/email/EmailWrapper/EmailWrapper.editor.js +21 -0
  69. package/dist/components/email/EmailWrapper/EmailWrapper.server.d.ts +2 -0
  70. package/dist/components/email/EmailWrapper/EmailWrapper.server.js +61 -0
  71. package/dist/components/email/EmailWrapper/EmailWrapper.types.d.ts +7 -0
  72. package/dist/components/email/EmailWrapper/EmailWrapper.types.js +1 -0
  73. package/dist/components/email/exports.d.ts +49 -0
  74. package/dist/components/email/exports.js +50 -0
  75. package/dist/components/email/utils.d.ts +74 -0
  76. package/dist/components/email/utils.js +137 -0
  77. package/dist/config/config.email.d.ts +71 -0
  78. package/dist/config/config.email.editor.d.ts +82 -0
  79. package/dist/config/config.email.editor.js +112 -0
  80. package/dist/config/config.email.js +101 -0
  81. package/dist/email/EmailRenderer.d.ts +16 -0
  82. package/dist/email/EmailRenderer.js +20 -0
  83. package/dist/email/email-document.d.ts +29 -0
  84. package/dist/email/email-document.js +67 -0
  85. package/dist/email/index.d.ts +23 -0
  86. package/dist/email/index.js +22 -0
  87. package/dist/email/renderToEmailHtml.d.ts +23 -0
  88. package/dist/email/renderToEmailHtml.js +43 -0
  89. package/dist/fields/index.d.ts +1 -0
  90. package/dist/fields/index.js +1 -0
  91. package/dist/fields/shared.d.ts +16 -0
  92. package/dist/fields/shared.js +59 -0
  93. package/dist/version.d.ts +1 -1
  94. package/dist/version.js +1 -1
  95. package/package.json +29 -17
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Email Puck configuration - Editor
3
+ *
4
+ * Full interactive editor experience with field factories.
5
+ * Use with PuckEditor for email building.
6
+ */
7
+ import type { ComponentConfig } from '@puckeditor/core';
8
+ import type { ReactNode } from 'react';
9
+ export declare const emailEditorConfig: {
10
+ root: {
11
+ fields: {
12
+ subject: {
13
+ type: "text";
14
+ label: string;
15
+ };
16
+ previewText: {
17
+ type: "textarea";
18
+ label: string;
19
+ };
20
+ backgroundColor: import("@puckeditor/core").CustomField<import("../fields/shared.js").ColorValue | null>;
21
+ fontFamily: {
22
+ type: "select";
23
+ label: string;
24
+ options: {
25
+ label: "Arial" | "Helvetica" | "Georgia" | "Times New Roman" | "Courier New" | "Verdana" | "Tahoma" | "Trebuchet MS";
26
+ value: "Arial, Helvetica, sans-serif" | "Helvetica, Arial, sans-serif" | "Georgia, Times, serif" | "'Times New Roman', Times, serif" | "'Courier New', Courier, monospace" | "Verdana, Geneva, sans-serif" | "Tahoma, Geneva, sans-serif" | "'Trebuchet MS', Helvetica, sans-serif";
27
+ }[];
28
+ };
29
+ maxWidth: {
30
+ type: "number";
31
+ label: string;
32
+ min: number;
33
+ max: number;
34
+ };
35
+ };
36
+ defaultProps: {
37
+ subject: string;
38
+ previewText: string;
39
+ backgroundColor: {
40
+ hex: string;
41
+ };
42
+ fontFamily: string;
43
+ maxWidth: number;
44
+ };
45
+ render: ({ children }: {
46
+ children: ReactNode;
47
+ }) => import("react").JSX.Element;
48
+ };
49
+ categories: {
50
+ layout: {
51
+ title: string;
52
+ components: string[];
53
+ defaultExpanded: true;
54
+ };
55
+ content: {
56
+ title: string;
57
+ components: string[];
58
+ };
59
+ utility: {
60
+ title: string;
61
+ components: string[];
62
+ };
63
+ prebuilt: {
64
+ title: string;
65
+ components: string[];
66
+ };
67
+ };
68
+ components: {
69
+ EmailWrapper: ComponentConfig<any>;
70
+ EmailSection: ComponentConfig<any>;
71
+ EmailColumns: ComponentConfig<any>;
72
+ EmailText: ComponentConfig<any>;
73
+ EmailHeading: ComponentConfig<any>;
74
+ EmailImage: ComponentConfig<any>;
75
+ EmailButton: ComponentConfig<any>;
76
+ EmailSpacer: ComponentConfig<any>;
77
+ EmailDivider: ComponentConfig<any>;
78
+ EmailHeader: ComponentConfig<any>;
79
+ EmailFooter: ComponentConfig<any>;
80
+ EmailSocial: ComponentConfig<any>;
81
+ };
82
+ };
@@ -0,0 +1,112 @@
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { createColorPickerField } from '../fields/ColorPickerField.js';
4
+ import { WEB_SAFE_FONTS } from '../components/email/utils.js';
5
+ // Layout
6
+ import { EmailWrapperEditorConfig } from '../components/email/EmailWrapper/EmailWrapper.editor.js';
7
+ import { EmailSectionEditorConfig } from '../components/email/EmailSection/EmailSection.editor.js';
8
+ import { EmailColumnsEditorConfig } from '../components/email/EmailColumns/EmailColumns.editor.js';
9
+ // Content
10
+ import { EmailTextEditorConfig } from '../components/email/EmailText/EmailText.editor.js';
11
+ import { EmailHeadingEditorConfig } from '../components/email/EmailHeading/EmailHeading.editor.js';
12
+ import { EmailImageEditorConfig } from '../components/email/EmailImage/EmailImage.editor.js';
13
+ import { EmailButtonEditorConfig } from '../components/email/EmailButton/EmailButton.editor.js';
14
+ // Utility
15
+ import { EmailSpacerEditorConfig } from '../components/email/EmailSpacer/EmailSpacer.editor.js';
16
+ import { EmailDividerEditorConfig } from '../components/email/EmailDivider/EmailDivider.editor.js';
17
+ // Prebuilt
18
+ import { EmailHeaderEditorConfig } from '../components/email/EmailHeader/EmailHeader.editor.js';
19
+ import { EmailFooterEditorConfig } from '../components/email/EmailFooter/EmailFooter.editor.js';
20
+ import { EmailSocialEditorConfig } from '../components/email/EmailSocial/EmailSocial.editor.js';
21
+ export const emailEditorConfig = {
22
+ root: {
23
+ fields: {
24
+ subject: {
25
+ type: 'text',
26
+ label: 'Subject Line'
27
+ },
28
+ previewText: {
29
+ type: 'textarea',
30
+ label: 'Preview Text'
31
+ },
32
+ backgroundColor: createColorPickerField({
33
+ label: 'Background Color'
34
+ }),
35
+ fontFamily: {
36
+ type: 'select',
37
+ label: 'Font Family',
38
+ options: WEB_SAFE_FONTS.map(({ label, value })=>({
39
+ label,
40
+ value
41
+ }))
42
+ },
43
+ maxWidth: {
44
+ type: 'number',
45
+ label: 'Max Width (px)',
46
+ min: 400,
47
+ max: 900
48
+ }
49
+ },
50
+ defaultProps: {
51
+ subject: '',
52
+ previewText: '',
53
+ backgroundColor: {
54
+ hex: '#f4f4f4'
55
+ },
56
+ fontFamily: 'Arial, Helvetica, sans-serif',
57
+ maxWidth: 600
58
+ },
59
+ render: ({ children })=>/*#__PURE__*/ _jsx(_Fragment, {
60
+ children: children
61
+ })
62
+ },
63
+ categories: {
64
+ layout: {
65
+ title: 'Layout',
66
+ components: [
67
+ 'EmailWrapper',
68
+ 'EmailSection',
69
+ 'EmailColumns'
70
+ ],
71
+ defaultExpanded: true
72
+ },
73
+ content: {
74
+ title: 'Content',
75
+ components: [
76
+ 'EmailText',
77
+ 'EmailHeading',
78
+ 'EmailImage',
79
+ 'EmailButton'
80
+ ]
81
+ },
82
+ utility: {
83
+ title: 'Utility',
84
+ components: [
85
+ 'EmailSpacer',
86
+ 'EmailDivider'
87
+ ]
88
+ },
89
+ prebuilt: {
90
+ title: 'Prebuilt',
91
+ components: [
92
+ 'EmailHeader',
93
+ 'EmailFooter',
94
+ 'EmailSocial'
95
+ ]
96
+ }
97
+ },
98
+ components: {
99
+ EmailWrapper: EmailWrapperEditorConfig,
100
+ EmailSection: EmailSectionEditorConfig,
101
+ EmailColumns: EmailColumnsEditorConfig,
102
+ EmailText: EmailTextEditorConfig,
103
+ EmailHeading: EmailHeadingEditorConfig,
104
+ EmailImage: EmailImageEditorConfig,
105
+ EmailButton: EmailButtonEditorConfig,
106
+ EmailSpacer: EmailSpacerEditorConfig,
107
+ EmailDivider: EmailDividerEditorConfig,
108
+ EmailHeader: EmailHeaderEditorConfig,
109
+ EmailFooter: EmailFooterEditorConfig,
110
+ EmailSocial: EmailSocialEditorConfig
111
+ }
112
+ };
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Email Puck configuration - Server-safe
3
+ *
4
+ * All components render to table-based, inline-styled HTML
5
+ * compatible with email clients. No Tailwind, no CSS classes.
6
+ *
7
+ * Use with EmailRenderer or renderToEmailHtml().
8
+ */ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
9
+ // Layout
10
+ import { EmailWrapperConfig } from '../components/email/EmailWrapper/EmailWrapper.server.js';
11
+ import { EmailSectionConfig } from '../components/email/EmailSection/EmailSection.server.js';
12
+ import { EmailColumnsConfig } from '../components/email/EmailColumns/EmailColumns.server.js';
13
+ // Content
14
+ import { EmailTextConfig } from '../components/email/EmailText/EmailText.server.js';
15
+ import { EmailHeadingConfig } from '../components/email/EmailHeading/EmailHeading.server.js';
16
+ import { EmailImageConfig } from '../components/email/EmailImage/EmailImage.server.js';
17
+ import { EmailButtonConfig } from '../components/email/EmailButton/EmailButton.server.js';
18
+ // Utility
19
+ import { EmailSpacerConfig } from '../components/email/EmailSpacer/EmailSpacer.server.js';
20
+ import { EmailDividerConfig } from '../components/email/EmailDivider/EmailDivider.server.js';
21
+ // Prebuilt
22
+ import { EmailHeaderConfig } from '../components/email/EmailHeader/EmailHeader.server.js';
23
+ import { EmailFooterConfig } from '../components/email/EmailFooter/EmailFooter.server.js';
24
+ import { EmailSocialConfig } from '../components/email/EmailSocial/EmailSocial.server.js';
25
+ export const emailBaseConfig = {
26
+ root: {
27
+ fields: {
28
+ subject: {
29
+ type: 'text',
30
+ label: 'Subject Line'
31
+ },
32
+ previewText: {
33
+ type: 'textarea',
34
+ label: 'Preview Text'
35
+ },
36
+ maxWidth: {
37
+ type: 'number',
38
+ label: 'Max Width (px)'
39
+ }
40
+ },
41
+ defaultProps: {
42
+ subject: '',
43
+ previewText: '',
44
+ backgroundColor: '#f4f4f4',
45
+ fontFamily: 'Arial, Helvetica, sans-serif',
46
+ maxWidth: 600
47
+ },
48
+ render: ({ children })=>/*#__PURE__*/ _jsx(_Fragment, {
49
+ children: children
50
+ })
51
+ },
52
+ categories: {
53
+ layout: {
54
+ title: 'Layout',
55
+ components: [
56
+ 'EmailWrapper',
57
+ 'EmailSection',
58
+ 'EmailColumns'
59
+ ],
60
+ defaultExpanded: true
61
+ },
62
+ content: {
63
+ title: 'Content',
64
+ components: [
65
+ 'EmailText',
66
+ 'EmailHeading',
67
+ 'EmailImage',
68
+ 'EmailButton'
69
+ ]
70
+ },
71
+ utility: {
72
+ title: 'Utility',
73
+ components: [
74
+ 'EmailSpacer',
75
+ 'EmailDivider'
76
+ ]
77
+ },
78
+ prebuilt: {
79
+ title: 'Prebuilt',
80
+ components: [
81
+ 'EmailHeader',
82
+ 'EmailFooter',
83
+ 'EmailSocial'
84
+ ]
85
+ }
86
+ },
87
+ components: {
88
+ EmailWrapper: EmailWrapperConfig,
89
+ EmailSection: EmailSectionConfig,
90
+ EmailColumns: EmailColumnsConfig,
91
+ EmailText: EmailTextConfig,
92
+ EmailHeading: EmailHeadingConfig,
93
+ EmailImage: EmailImageConfig,
94
+ EmailButton: EmailButtonConfig,
95
+ EmailSpacer: EmailSpacerConfig,
96
+ EmailDivider: EmailDividerConfig,
97
+ EmailHeader: EmailHeaderConfig,
98
+ EmailFooter: EmailFooterConfig,
99
+ EmailSocial: EmailSocialConfig
100
+ }
101
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * EmailRenderer - Server-safe React component for rendering Puck email data
3
+ *
4
+ * Wraps Puck's Render with email config.
5
+ * For producing HTML strings, use renderToEmailHtml() instead.
6
+ */
7
+ import type { Config as PuckConfig, Data as PuckData } from '@puckeditor/core';
8
+ export interface EmailRendererProps {
9
+ data: PuckData;
10
+ config?: PuckConfig;
11
+ }
12
+ /**
13
+ * Renders Puck email data as React elements.
14
+ * Server-safe — no hooks or client-side interactivity.
15
+ */
16
+ export declare function EmailRenderer({ data, config, }: EmailRendererProps): import("react").JSX.Element | null;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * EmailRenderer - Server-safe React component for rendering Puck email data
4
+ *
5
+ * Wraps Puck's Render with email config.
6
+ * For producing HTML strings, use renderToEmailHtml() instead.
7
+ */ import { Render } from '@puckeditor/core';
8
+ import { emailBaseConfig } from '../config/config.email.js';
9
+ /**
10
+ * Renders Puck email data as React elements.
11
+ * Server-safe — no hooks or client-side interactivity.
12
+ */ export function EmailRenderer({ data, config = emailBaseConfig }) {
13
+ if (!data || !data.content) {
14
+ return null;
15
+ }
16
+ return /*#__PURE__*/ _jsx(Render, {
17
+ config: config,
18
+ data: data
19
+ });
20
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Email HTML Document Shell
3
+ *
4
+ * Provides the DOCTYPE, html, head, and body wrapper for email HTML.
5
+ * Includes standard email reset CSS and MSO conditional comments.
6
+ */
7
+ /**
8
+ * Email reset CSS applied in a style block in the head.
9
+ * These resets normalize rendering across email clients.
10
+ */
11
+ export declare const EMAIL_RESET_CSS: string;
12
+ export interface EmailDocumentOptions {
13
+ /** Preview text shown in inbox list */
14
+ previewText?: string;
15
+ /** Background color for the email body */
16
+ backgroundColor?: string;
17
+ /** Base font family */
18
+ fontFamily?: string;
19
+ /** Max width of email content in px */
20
+ maxWidth?: number;
21
+ }
22
+ /**
23
+ * Wraps email content in a complete HTML document.
24
+ * Returns the opening HTML (before content) and closing HTML (after content).
25
+ */
26
+ export declare function getEmailDocumentParts(options?: EmailDocumentOptions): {
27
+ before: string;
28
+ after: string;
29
+ };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Email HTML Document Shell
3
+ *
4
+ * Provides the DOCTYPE, html, head, and body wrapper for email HTML.
5
+ * Includes standard email reset CSS and MSO conditional comments.
6
+ */ /**
7
+ * Email reset CSS applied in a style block in the head.
8
+ * These resets normalize rendering across email clients.
9
+ */ export const EMAIL_RESET_CSS = `
10
+ body, table, td, a { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
11
+ table, td { mso-table-lspace: 0pt; mso-table-rspace: 0pt; }
12
+ img { -ms-interpolation-mode: bicubic; border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; }
13
+ body { margin: 0 !important; padding: 0 !important; width: 100% !important; min-width: 100% !important; }
14
+ a[x-apple-data-detectors] { color: inherit !important; text-decoration: none !important; font-size: inherit !important; font-family: inherit !important; font-weight: inherit !important; line-height: inherit !important; }
15
+ #MessageViewBody a { color: inherit; text-decoration: none; font-size: inherit; font-family: inherit; font-weight: inherit; line-height: inherit; }
16
+ `.trim();
17
+ /**
18
+ * Wraps email content in a complete HTML document.
19
+ * Returns the opening HTML (before content) and closing HTML (after content).
20
+ */ export function getEmailDocumentParts(options = {}) {
21
+ const { previewText = '', backgroundColor = '#f4f4f4', fontFamily = 'Arial, Helvetica, sans-serif', maxWidth = 600 } = options;
22
+ const preheaderHtml = previewText ? `<div style="display:none;font-size:1px;color:#ffffff;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden;">\n${previewText}${'&#847; &zwnj; &nbsp; '.repeat(20)}\n</div>` : '';
23
+ const before = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
24
+ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
25
+ <head>
26
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
27
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
28
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
29
+ <!--[if mso]>
30
+ <noscript>
31
+ <xml>
32
+ <o:OfficeDocumentSettings>
33
+ <o:AllowPNG/>
34
+ <o:PixelsPerInch>96</o:PixelsPerInch>
35
+ </o:OfficeDocumentSettings>
36
+ </xml>
37
+ </noscript>
38
+ <![endif]-->
39
+ <style type="text/css">
40
+ ${EMAIL_RESET_CSS}
41
+ </style>
42
+ </head>
43
+ <body style="margin:0;padding:0;background-color:${backgroundColor};font-family:${fontFamily};">
44
+ ${preheaderHtml}
45
+ <!--[if mso]>
46
+ <table role="presentation" cellpadding="0" cellspacing="0" border="0" width="${maxWidth}" align="center" style="width:${maxWidth}px;">
47
+ <tr>
48
+ <td>
49
+ <![endif]-->
50
+ <table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="max-width:${maxWidth}px;margin:0 auto;">
51
+ <tr>
52
+ <td>`;
53
+ const after = `</td>
54
+ </tr>
55
+ </table>
56
+ <!--[if mso]>
57
+ </td>
58
+ </tr>
59
+ </table>
60
+ <![endif]-->
61
+ </body>
62
+ </html>`;
63
+ return {
64
+ before,
65
+ after
66
+ };
67
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Email builder exports
3
+ *
4
+ * @example
5
+ * ```tsx
6
+ * import {
7
+ * emailBaseConfig,
8
+ * emailEditorConfig,
9
+ * renderToEmailHtml,
10
+ * EmailRenderer,
11
+ * } from '@delmaredigital/payload-puck/email'
12
+ * ```
13
+ */
14
+ export { emailBaseConfig } from '../config/config.email.js';
15
+ export { emailEditorConfig } from '../config/config.email.editor.js';
16
+ export { EmailRenderer } from './EmailRenderer.js';
17
+ export type { EmailRendererProps } from './EmailRenderer.js';
18
+ export { renderToEmailHtml } from './renderToEmailHtml.js';
19
+ export type { RenderToEmailHtmlOptions } from './renderToEmailHtml.js';
20
+ export { getEmailDocumentParts, EMAIL_RESET_CSS } from './email-document.js';
21
+ export type { EmailDocumentOptions } from './email-document.js';
22
+ export { TABLE_ATTRS, FULL_WIDTH_TABLE_STYLE, centeredTableStyle, emailAlign, alignmentToMargin, WEB_SAFE_FONTS, tiptapHtmlToEmailHtml, vmlBackgroundOpen, vmlBackgroundClose, } from '../components/email/utils.js';
23
+ export type { WebSafeFont } from '../components/email/utils.js';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Email builder exports
3
+ *
4
+ * @example
5
+ * ```tsx
6
+ * import {
7
+ * emailBaseConfig,
8
+ * emailEditorConfig,
9
+ * renderToEmailHtml,
10
+ * EmailRenderer,
11
+ * } from '@delmaredigital/payload-puck/email'
12
+ * ```
13
+ */ // Configs
14
+ export { emailBaseConfig } from '../config/config.email.js';
15
+ export { emailEditorConfig } from '../config/config.email.editor.js';
16
+ // Rendering
17
+ export { EmailRenderer } from './EmailRenderer.js';
18
+ export { renderToEmailHtml } from './renderToEmailHtml.js';
19
+ // Document shell (for advanced customization)
20
+ export { getEmailDocumentParts, EMAIL_RESET_CSS } from './email-document.js';
21
+ // Email utilities (for custom component authors)
22
+ export { TABLE_ATTRS, FULL_WIDTH_TABLE_STYLE, centeredTableStyle, emailAlign, alignmentToMargin, WEB_SAFE_FONTS, tiptapHtmlToEmailHtml, vmlBackgroundOpen, vmlBackgroundClose } from '../components/email/utils.js';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * renderToEmailHtml - Produces a complete email HTML string from Puck data
3
+ *
4
+ * Uses React's renderToStaticMarkup to generate static HTML,
5
+ * then wraps it in the email document shell with reset CSS.
6
+ */
7
+ import type { Config as PuckConfig, Data as PuckData } from '@puckeditor/core';
8
+ export interface RenderToEmailHtmlOptions {
9
+ /** Puck config to use (defaults to emailBaseConfig) */
10
+ config?: PuckConfig;
11
+ }
12
+ /**
13
+ * Renders Puck data to a complete email HTML string.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { renderToEmailHtml } from '@delmaredigital/payload-puck/email'
18
+ *
19
+ * const html = renderToEmailHtml(emailData)
20
+ * await sendEmail({ to: 'user@example.com', html })
21
+ * ```
22
+ */
23
+ export declare function renderToEmailHtml(data: PuckData, options?: RenderToEmailHtmlOptions): string;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * renderToEmailHtml - Produces a complete email HTML string from Puck data
3
+ *
4
+ * Uses React's renderToStaticMarkup to generate static HTML,
5
+ * then wraps it in the email document shell with reset CSS.
6
+ */ import React from 'react';
7
+ import { renderToStaticMarkup } from 'react-dom/server';
8
+ import { EmailRenderer } from './EmailRenderer.js';
9
+ import { getEmailDocumentParts } from './email-document.js';
10
+ import { colorValueToEmailCSS } from '../fields/shared.js';
11
+ /**
12
+ * Renders Puck data to a complete email HTML string.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { renderToEmailHtml } from '@delmaredigital/payload-puck/email'
17
+ *
18
+ * const html = renderToEmailHtml(emailData)
19
+ * await sendEmail({ to: 'user@example.com', html })
20
+ * ```
21
+ */ export function renderToEmailHtml(data, options = {}) {
22
+ const rootProps = data.root?.props;
23
+ // Resolve backgroundColor — could be a ColorValue object or plain string
24
+ let bgColor = '#f4f4f4';
25
+ if (rootProps?.backgroundColor) {
26
+ if (typeof rootProps.backgroundColor === 'string') {
27
+ bgColor = rootProps.backgroundColor;
28
+ } else {
29
+ bgColor = colorValueToEmailCSS(rootProps.backgroundColor) ?? '#f4f4f4';
30
+ }
31
+ }
32
+ const { before, after } = getEmailDocumentParts({
33
+ previewText: rootProps?.previewText,
34
+ backgroundColor: bgColor,
35
+ fontFamily: rootProps?.fontFamily,
36
+ maxWidth: rootProps?.maxWidth
37
+ });
38
+ const contentHtml = renderToStaticMarkup(React.createElement(EmailRenderer, {
39
+ data,
40
+ config: options.config
41
+ }));
42
+ return before + contentHtml + after;
43
+ }
@@ -31,6 +31,7 @@ export { GradientEditor } from './GradientEditor.js';
31
31
  export { BackgroundField, createBackgroundField } from './BackgroundField.js';
32
32
  export type { BackgroundValue, BackgroundImageValue, BackgroundOverlay, GradientValue, GradientStop, GradientMask, } from './shared.js';
33
33
  export { backgroundValueToCSS, gradientValueToCSS, getBackgroundImageOpacity } from './shared.js';
34
+ export { colorValueToEmailCSS, paddingValueToEmailCSS, backgroundValueToEmailCSS, } from './shared.js';
34
35
  export { ResponsiveField, createResponsiveField } from './ResponsiveField.js';
35
36
  export type { Breakpoint, ResponsiveValue, VisibilityValue, ResponsiveCSSResult } from './shared.js';
36
37
  export { BREAKPOINTS, isResponsiveValue, responsiveValueToCSS, cssPropertiesToString, visibilityValueToCSS, DEFAULT_VISIBILITY, } from './shared.js';
@@ -30,6 +30,7 @@ export { SizeField, createSizeField, sizeValueToCSS, getSizeClasses } from './Si
30
30
  export { GradientEditor } from './GradientEditor.js';
31
31
  export { BackgroundField, createBackgroundField } from './BackgroundField.js';
32
32
  export { backgroundValueToCSS, gradientValueToCSS, getBackgroundImageOpacity } from './shared.js';
33
+ export { colorValueToEmailCSS, paddingValueToEmailCSS, backgroundValueToEmailCSS } from './shared.js';
33
34
  export { ResponsiveField, createResponsiveField } from './ResponsiveField.js';
34
35
  export { BREAKPOINTS, isResponsiveValue, responsiveValueToCSS, cssPropertiesToString, visibilityValueToCSS, DEFAULT_VISIBILITY } from './shared.js';
35
36
  export { ResponsiveVisibilityField, createResponsiveVisibilityField } from './ResponsiveVisibilityField.js';
@@ -284,6 +284,22 @@ export declare function backgroundValueToCSS(bg: BackgroundValue | null | undefi
284
284
  * Returns undefined if no image or opacity is 100%
285
285
  */
286
286
  export declare function getBackgroundImageOpacity(bg: BackgroundValue | null | undefined): number | undefined;
287
+ /**
288
+ * Converts a ColorValue to an email-safe hex string.
289
+ * Email clients have poor rgba support, so we always return hex.
290
+ * Opacity is baked into the hex value by blending with white.
291
+ */
292
+ export declare function colorValueToEmailCSS(color: ColorValue | null | undefined): string | undefined;
293
+ /**
294
+ * Converts a PaddingValue to an email-safe CSS padding string.
295
+ * Always uses px units (email clients don't reliably support rem/em).
296
+ */
297
+ export declare function paddingValueToEmailCSS(padding: PaddingValue | null | undefined): string | undefined;
298
+ /**
299
+ * Converts a BackgroundValue to email-safe inline style properties.
300
+ * Only supports solid colors — gradients and images need VML for Outlook.
301
+ */
302
+ export declare function backgroundValueToEmailCSS(bg: BackgroundValue | null | undefined): React.CSSProperties;
287
303
  /**
288
304
  * Check if any custom style values are set
289
305
  */
@@ -1084,6 +1084,65 @@ export const flexWrapField = {
1084
1084
  const opacity = bg.image.opacity ?? 100;
1085
1085
  return opacity < 100 ? opacity / 100 : undefined;
1086
1086
  }
1087
+ // =============================================================================
1088
+ // Email CSS Converters
1089
+ // =============================================================================
1090
+ // Email-safe versions of CSS converters. Email clients don't support:
1091
+ // - rgba/hsla colors (use hex only)
1092
+ // - CSS shorthand inconsistently
1093
+ // - rem/em units (use px only)
1094
+ /**
1095
+ * Converts a ColorValue to an email-safe hex string.
1096
+ * Email clients have poor rgba support, so we always return hex.
1097
+ * Opacity is baked into the hex value by blending with white.
1098
+ */ export function colorValueToEmailCSS(color) {
1099
+ if (!color?.hex) return undefined;
1100
+ const opacity = color.opacity ?? 100;
1101
+ if (opacity === 100) return color.hex;
1102
+ // Bake opacity into hex — email clients don't support rgba
1103
+ const rgb = hexToRgb(color.hex);
1104
+ if (!rgb) return color.hex;
1105
+ // Blend with white background (most emails have white/light bg)
1106
+ const blend = (c)=>Math.round(c * (opacity / 100) + 255 * (1 - opacity / 100));
1107
+ const r = blend(rgb.r).toString(16).padStart(2, '0');
1108
+ const g = blend(rgb.g).toString(16).padStart(2, '0');
1109
+ const b = blend(rgb.b).toString(16).padStart(2, '0');
1110
+ return `#${r}${g}${b}`;
1111
+ }
1112
+ /**
1113
+ * Converts a PaddingValue to an email-safe CSS padding string.
1114
+ * Always uses px units (email clients don't reliably support rem/em).
1115
+ */ export function paddingValueToEmailCSS(padding) {
1116
+ if (!padding) return undefined;
1117
+ const { top, right, bottom, left } = padding;
1118
+ if (top === right && right === bottom && bottom === left) {
1119
+ return `${top}px`;
1120
+ }
1121
+ if (top === bottom && left === right) {
1122
+ return `${top}px ${right}px`;
1123
+ }
1124
+ return `${top}px ${right}px ${bottom}px ${left}px`;
1125
+ }
1126
+ /**
1127
+ * Converts a BackgroundValue to email-safe inline style properties.
1128
+ * Only supports solid colors — gradients and images need VML for Outlook.
1129
+ */ export function backgroundValueToEmailCSS(bg) {
1130
+ if (!bg || bg.type === 'none') return {};
1131
+ if (bg.type === 'solid' && bg.solid) {
1132
+ const color = colorValueToEmailCSS(bg.solid);
1133
+ return color ? {
1134
+ backgroundColor: color
1135
+ } : {};
1136
+ }
1137
+ // Gradient backgrounds: use first stop color as fallback
1138
+ if (bg.type === 'gradient' && bg.gradient?.stops?.length) {
1139
+ const fallback = colorValueToEmailCSS(bg.gradient.stops[0].color);
1140
+ return fallback ? {
1141
+ backgroundColor: fallback
1142
+ } : {};
1143
+ }
1144
+ return {};
1145
+ }
1087
1146
  /**
1088
1147
  * Check if any custom style values are set
1089
1148
  */ export function hasCustomStyles(options) {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.6.16";
1
+ export declare const VERSION = "0.6.18";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by scripts/generate-version.js - do not edit manually
2
- export const VERSION = '0.6.16';
2
+ export const VERSION = '0.6.18';