payload-plugin-newsletter 0.19.0 → 0.20.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.
@@ -900,7 +900,7 @@ function useNewsletterAuth(_options = {}) {
900
900
  }
901
901
 
902
902
  // src/components/Broadcasts/EmailPreview.tsx
903
- var import_react5 = require("react");
903
+ var import_react6 = require("react");
904
904
 
905
905
  // src/utils/emailSafeHtml.ts
906
906
  var import_isomorphic_dompurify = __toESM(require("isomorphic-dompurify"), 1);
@@ -971,6 +971,12 @@ async function convertToEmailSafeHtml(editorState, options) {
971
971
  const rawHtml = await lexicalToEmailHtml(editorState, options?.mediaUrl, options?.customBlockConverter);
972
972
  const sanitizedHtml = import_isomorphic_dompurify.default.sanitize(rawHtml, EMAIL_SAFE_CONFIG);
973
973
  if (options?.wrapInTemplate) {
974
+ if (options.customWrapper) {
975
+ return await Promise.resolve(options.customWrapper(sanitizedHtml, {
976
+ preheader: options.preheader,
977
+ subject: options.subject
978
+ }));
979
+ }
974
980
  return wrapInEmailTemplate(sanitizedHtml, options.preheader);
975
981
  }
976
982
  return sanitizedHtml;
@@ -1466,8 +1472,16 @@ function validateEmailHtml(html) {
1466
1472
  };
1467
1473
  }
1468
1474
 
1469
- // src/components/Broadcasts/EmailPreview.tsx
1475
+ // src/contexts/PluginConfigContext.tsx
1476
+ var import_react5 = require("react");
1470
1477
  var import_jsx_runtime4 = require("react/jsx-runtime");
1478
+ var PluginConfigContext = (0, import_react5.createContext)(null);
1479
+ var usePluginConfigOptional = () => {
1480
+ return (0, import_react5.useContext)(PluginConfigContext);
1481
+ };
1482
+
1483
+ // src/components/Broadcasts/EmailPreview.tsx
1484
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1471
1485
  var SAMPLE_DATA = {
1472
1486
  "subscriber.name": "John Doe",
1473
1487
  "subscriber.firstName": "John",
@@ -1483,13 +1497,16 @@ var EmailPreview = ({
1483
1497
  subject,
1484
1498
  preheader,
1485
1499
  mode = "desktop",
1486
- onValidation
1500
+ onValidation,
1501
+ pluginConfig: propPluginConfig
1487
1502
  }) => {
1488
- const [html, setHtml] = (0, import_react5.useState)("");
1489
- const [loading, setLoading] = (0, import_react5.useState)(false);
1490
- const [validationResult, setValidationResult] = (0, import_react5.useState)(null);
1491
- const iframeRef = (0, import_react5.useRef)(null);
1492
- (0, import_react5.useEffect)(() => {
1503
+ const contextPluginConfig = usePluginConfigOptional();
1504
+ const pluginConfig = propPluginConfig || contextPluginConfig;
1505
+ const [html, setHtml] = (0, import_react6.useState)("");
1506
+ const [loading, setLoading] = (0, import_react6.useState)(false);
1507
+ const [validationResult, setValidationResult] = (0, import_react6.useState)(null);
1508
+ const iframeRef = (0, import_react6.useRef)(null);
1509
+ (0, import_react6.useEffect)(() => {
1493
1510
  const convertContent = async () => {
1494
1511
  if (!content) {
1495
1512
  setHtml("");
@@ -1497,9 +1514,13 @@ var EmailPreview = ({
1497
1514
  }
1498
1515
  setLoading(true);
1499
1516
  try {
1517
+ const emailPreviewConfig = pluginConfig?.customizations?.broadcasts?.emailPreview;
1500
1518
  const emailHtml = await convertToEmailSafeHtml(content, {
1501
- wrapInTemplate: true,
1502
- preheader
1519
+ wrapInTemplate: emailPreviewConfig?.wrapInTemplate ?? true,
1520
+ preheader,
1521
+ subject,
1522
+ customWrapper: emailPreviewConfig?.customWrapper,
1523
+ customBlockConverter: pluginConfig?.customizations?.broadcasts?.customBlockConverter
1503
1524
  });
1504
1525
  const personalizedHtml = replacePersonalizationTags(emailHtml, SAMPLE_DATA);
1505
1526
  const previewHtml = addEmailHeader(personalizedHtml, {
@@ -1519,8 +1540,8 @@ var EmailPreview = ({
1519
1540
  }
1520
1541
  };
1521
1542
  convertContent();
1522
- }, [content, subject, preheader, onValidation]);
1523
- (0, import_react5.useEffect)(() => {
1543
+ }, [content, subject, preheader, onValidation, pluginConfig]);
1544
+ (0, import_react6.useEffect)(() => {
1524
1545
  if (iframeRef.current && html) {
1525
1546
  const doc = iframeRef.current.contentDocument;
1526
1547
  if (doc) {
@@ -1531,26 +1552,26 @@ var EmailPreview = ({
1531
1552
  }
1532
1553
  }, [html]);
1533
1554
  const viewport = VIEWPORT_SIZES[mode];
1534
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
1535
- validationResult && (validationResult.errors.length > 0 || validationResult.warnings.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { padding: "16px", borderBottom: "1px solid #e5e7eb" }, children: [
1536
- validationResult.errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginBottom: "12px" }, children: [
1537
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("h4", { style: { color: "#dc2626", margin: "0 0 8px 0", fontSize: "14px" }, children: [
1555
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { height: "100%", display: "flex", flexDirection: "column" }, children: [
1556
+ validationResult && (validationResult.errors.length > 0 || validationResult.warnings.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { padding: "16px", borderBottom: "1px solid #e5e7eb" }, children: [
1557
+ validationResult.errors.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { marginBottom: "12px" }, children: [
1558
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("h4", { style: { color: "#dc2626", margin: "0 0 8px 0", fontSize: "14px" }, children: [
1538
1559
  "Errors (",
1539
1560
  validationResult.errors.length,
1540
1561
  ")"
1541
1562
  ] }),
1542
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { style: { margin: 0, paddingLeft: "20px", fontSize: "13px", color: "#dc2626" }, children: validationResult.errors.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: error }, index)) })
1563
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { style: { margin: 0, paddingLeft: "20px", fontSize: "13px", color: "#dc2626" }, children: validationResult.errors.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: error }, index)) })
1543
1564
  ] }),
1544
- validationResult.warnings.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
1545
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("h4", { style: { color: "#d97706", margin: "0 0 8px 0", fontSize: "14px" }, children: [
1565
+ validationResult.warnings.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
1566
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("h4", { style: { color: "#d97706", margin: "0 0 8px 0", fontSize: "14px" }, children: [
1546
1567
  "Warnings (",
1547
1568
  validationResult.warnings.length,
1548
1569
  ")"
1549
1570
  ] }),
1550
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { style: { margin: 0, paddingLeft: "20px", fontSize: "13px", color: "#d97706" }, children: validationResult.warnings.map((warning, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: warning }, index)) })
1571
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ul", { style: { margin: 0, paddingLeft: "20px", fontSize: "13px", color: "#d97706" }, children: validationResult.warnings.map((warning, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("li", { children: warning }, index)) })
1551
1572
  ] })
1552
1573
  ] }),
1553
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1574
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1554
1575
  flex: 1,
1555
1576
  display: "flex",
1556
1577
  alignItems: "center",
@@ -1558,14 +1579,14 @@ var EmailPreview = ({
1558
1579
  backgroundColor: "#f3f4f6",
1559
1580
  padding: "20px",
1560
1581
  overflow: "auto"
1561
- }, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { textAlign: "center", color: "#6b7280" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: "Loading preview..." }) }) : html ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1582
+ }, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { textAlign: "center", color: "#6b7280" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: "Loading preview..." }) }) : html ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1562
1583
  backgroundColor: "white",
1563
1584
  boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
1564
1585
  borderRadius: "8px",
1565
1586
  overflow: "hidden",
1566
1587
  transform: `scale(${viewport.scale})`,
1567
1588
  transformOrigin: "top center"
1568
- }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1589
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1569
1590
  "iframe",
1570
1591
  {
1571
1592
  ref: iframeRef,
@@ -1578,8 +1599,8 @@ var EmailPreview = ({
1578
1599
  },
1579
1600
  sandbox: "allow-same-origin"
1580
1601
  }
1581
- ) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { textAlign: "center", color: "#6b7280" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: "Start typing to see the email preview" }) }) }),
1582
- validationResult && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
1602
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { textAlign: "center", color: "#6b7280" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { children: "Start typing to see the email preview" }) }) }),
1603
+ validationResult && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
1583
1604
  padding: "12px 16px",
1584
1605
  borderTop: "1px solid #e5e7eb",
1585
1606
  fontSize: "13px",
@@ -1587,20 +1608,20 @@ var EmailPreview = ({
1587
1608
  display: "flex",
1588
1609
  gap: "24px"
1589
1610
  }, children: [
1590
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
1611
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
1591
1612
  "Size: ",
1592
1613
  Math.round(validationResult.stats.sizeInBytes / 1024),
1593
1614
  "KB"
1594
1615
  ] }),
1595
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
1616
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
1596
1617
  "Links: ",
1597
1618
  validationResult.stats.linkCount
1598
1619
  ] }),
1599
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
1620
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
1600
1621
  "Images: ",
1601
1622
  validationResult.stats.imageCount
1602
1623
  ] }),
1603
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { children: [
1624
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { children: [
1604
1625
  "Viewport: ",
1605
1626
  mode === "desktop" ? "600px" : "320px"
1606
1627
  ] })
@@ -1624,13 +1645,14 @@ function escapeHtml2(text) {
1624
1645
  }
1625
1646
 
1626
1647
  // src/components/Broadcasts/EmailPreviewField.tsx
1627
- var import_react6 = require("react");
1648
+ var import_react7 = require("react");
1628
1649
  var import_ui = require("@payloadcms/ui");
1629
- var import_jsx_runtime5 = require("react/jsx-runtime");
1650
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1630
1651
  var EmailPreviewField = () => {
1631
- const [previewMode, setPreviewMode] = (0, import_react6.useState)("desktop");
1632
- const [isValid, setIsValid] = (0, import_react6.useState)(true);
1633
- const [validationSummary, setValidationSummary] = (0, import_react6.useState)("");
1652
+ const [previewMode, setPreviewMode] = (0, import_react7.useState)("desktop");
1653
+ const [isValid, setIsValid] = (0, import_react7.useState)(true);
1654
+ const [validationSummary, setValidationSummary] = (0, import_react7.useState)("");
1655
+ const pluginConfig = usePluginConfigOptional();
1634
1656
  const fields = (0, import_ui.useFormFields)(([fields2]) => ({
1635
1657
  content: fields2["contentSection.content"],
1636
1658
  subject: fields2["subject"],
@@ -1672,13 +1694,13 @@ var EmailPreviewField = () => {
1672
1694
  alert(error instanceof Error ? error.message : "Failed to send test email");
1673
1695
  }
1674
1696
  };
1675
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
1697
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
1676
1698
  marginTop: "24px",
1677
1699
  border: "1px solid #e5e7eb",
1678
1700
  borderRadius: "8px",
1679
1701
  overflow: "hidden"
1680
1702
  }, children: [
1681
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
1703
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
1682
1704
  display: "flex",
1683
1705
  alignItems: "center",
1684
1706
  justifyContent: "space-between",
@@ -1686,10 +1708,10 @@ var EmailPreviewField = () => {
1686
1708
  borderBottom: "1px solid #e5e7eb",
1687
1709
  backgroundColor: "#f9fafb"
1688
1710
  }, children: [
1689
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "16px" }, children: [
1690
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Email Preview" }),
1691
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
1692
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1711
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "16px" }, children: [
1712
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Email Preview" }),
1713
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
1714
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1693
1715
  "button",
1694
1716
  {
1695
1717
  type: "button",
@@ -1706,7 +1728,7 @@ var EmailPreviewField = () => {
1706
1728
  children: "Desktop"
1707
1729
  }
1708
1730
  ),
1709
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1731
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1710
1732
  "button",
1711
1733
  {
1712
1734
  type: "button",
@@ -1724,7 +1746,7 @@ var EmailPreviewField = () => {
1724
1746
  }
1725
1747
  )
1726
1748
  ] }),
1727
- validationSummary && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1749
+ validationSummary && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1728
1750
  padding: "6px 12px",
1729
1751
  backgroundColor: isValid ? "#fef3c7" : "#fee2e2",
1730
1752
  color: isValid ? "#92400e" : "#991b1b",
@@ -1732,7 +1754,7 @@ var EmailPreviewField = () => {
1732
1754
  fontSize: "13px"
1733
1755
  }, children: validationSummary })
1734
1756
  ] }),
1735
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1757
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1736
1758
  "button",
1737
1759
  {
1738
1760
  type: "button",
@@ -1750,34 +1772,35 @@ var EmailPreviewField = () => {
1750
1772
  }
1751
1773
  )
1752
1774
  ] }),
1753
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { height: "600px" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1775
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { height: "600px" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1754
1776
  EmailPreview,
1755
1777
  {
1756
1778
  content: fields.content?.value || null,
1757
1779
  subject: fields.subject?.value || "Email Subject",
1758
1780
  preheader: fields.preheader?.value,
1759
1781
  mode: previewMode,
1760
- onValidation: handleValidation
1782
+ onValidation: handleValidation,
1783
+ pluginConfig: pluginConfig || void 0
1761
1784
  }
1762
1785
  ) })
1763
1786
  ] });
1764
1787
  };
1765
1788
 
1766
1789
  // src/components/Broadcasts/BroadcastEditor.tsx
1767
- var import_react7 = require("react");
1790
+ var import_react8 = require("react");
1768
1791
  var import_ui2 = require("@payloadcms/ui");
1769
- var import_jsx_runtime6 = require("react/jsx-runtime");
1792
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1770
1793
  var BroadcastEditor = (props) => {
1771
1794
  const { value } = (0, import_ui2.useField)({ path: props.path });
1772
- const [showPreview, setShowPreview] = (0, import_react7.useState)(true);
1773
- const [previewMode, setPreviewMode] = (0, import_react7.useState)("desktop");
1774
- const [isValid, setIsValid] = (0, import_react7.useState)(true);
1775
- const [validationSummary, setValidationSummary] = (0, import_react7.useState)("");
1795
+ const [showPreview, setShowPreview] = (0, import_react8.useState)(true);
1796
+ const [previewMode, setPreviewMode] = (0, import_react8.useState)("desktop");
1797
+ const [isValid, setIsValid] = (0, import_react8.useState)(true);
1798
+ const [validationSummary, setValidationSummary] = (0, import_react8.useState)("");
1776
1799
  const fields = (0, import_ui2.useFormFields)(([fields2]) => ({
1777
1800
  subject: fields2["subject"],
1778
1801
  preheader: fields2["contentSection.preheader"]
1779
1802
  }));
1780
- const handleValidation = (0, import_react7.useCallback)((result) => {
1803
+ const handleValidation = (0, import_react8.useCallback)((result) => {
1781
1804
  setIsValid(result.valid);
1782
1805
  const errorCount = result.errors.length;
1783
1806
  const warningCount = result.warnings.length;
@@ -1812,8 +1835,8 @@ var BroadcastEditor = (props) => {
1812
1835
  alert(error instanceof Error ? error.message : "Failed to send test email");
1813
1836
  }
1814
1837
  };
1815
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { height: "600px", display: "flex", flexDirection: "column" }, children: [
1816
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
1838
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { height: "600px", display: "flex", flexDirection: "column" }, children: [
1839
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: {
1817
1840
  display: "flex",
1818
1841
  alignItems: "center",
1819
1842
  justifyContent: "space-between",
@@ -1821,8 +1844,8 @@ var BroadcastEditor = (props) => {
1821
1844
  borderBottom: "1px solid #e5e7eb",
1822
1845
  backgroundColor: "#f9fafb"
1823
1846
  }, children: [
1824
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "16px" }, children: [
1825
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1847
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "16px" }, children: [
1848
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1826
1849
  "button",
1827
1850
  {
1828
1851
  type: "button",
@@ -1839,8 +1862,8 @@ var BroadcastEditor = (props) => {
1839
1862
  children: showPreview ? "Hide Preview" : "Show Preview"
1840
1863
  }
1841
1864
  ),
1842
- showPreview && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
1843
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1865
+ showPreview && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
1866
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1844
1867
  "button",
1845
1868
  {
1846
1869
  type: "button",
@@ -1857,7 +1880,7 @@ var BroadcastEditor = (props) => {
1857
1880
  children: "Desktop"
1858
1881
  }
1859
1882
  ),
1860
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1883
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1861
1884
  "button",
1862
1885
  {
1863
1886
  type: "button",
@@ -1875,7 +1898,7 @@ var BroadcastEditor = (props) => {
1875
1898
  }
1876
1899
  )
1877
1900
  ] }),
1878
- showPreview && validationSummary && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1901
+ showPreview && validationSummary && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
1879
1902
  padding: "6px 12px",
1880
1903
  backgroundColor: isValid ? "#fef3c7" : "#fee2e2",
1881
1904
  color: isValid ? "#92400e" : "#991b1b",
@@ -1883,7 +1906,7 @@ var BroadcastEditor = (props) => {
1883
1906
  fontSize: "13px"
1884
1907
  }, children: validationSummary })
1885
1908
  ] }),
1886
- showPreview && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1909
+ showPreview && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1887
1910
  "button",
1888
1911
  {
1889
1912
  type: "button",
@@ -1901,13 +1924,13 @@ var BroadcastEditor = (props) => {
1901
1924
  }
1902
1925
  )
1903
1926
  ] }),
1904
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { flex: 1, display: "flex", overflow: "hidden" }, children: [
1905
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1927
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { flex: 1, display: "flex", overflow: "hidden" }, children: [
1928
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
1906
1929
  flex: showPreview ? "0 0 50%" : "1",
1907
1930
  overflow: "auto",
1908
1931
  borderRight: showPreview ? "1px solid #e5e7eb" : "none"
1909
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { padding: "16px" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "rich-text-lexical" }) }) }),
1910
- showPreview && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: "0 0 50%", overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1932
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { padding: "16px" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "rich-text-lexical" }) }) }),
1933
+ showPreview && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { flex: "0 0 50%", overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1911
1934
  EmailPreview,
1912
1935
  {
1913
1936
  content: value,
@@ -1922,11 +1945,11 @@ var BroadcastEditor = (props) => {
1922
1945
  };
1923
1946
 
1924
1947
  // src/components/Broadcasts/BroadcastInlinePreview.tsx
1925
- var import_react8 = require("react");
1948
+ var import_react9 = require("react");
1926
1949
  var import_ui3 = require("@payloadcms/ui");
1927
1950
 
1928
1951
  // src/components/Broadcasts/PreviewControls.tsx
1929
- var import_jsx_runtime7 = require("react/jsx-runtime");
1952
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1930
1953
  var PreviewControls = ({
1931
1954
  onUpdate,
1932
1955
  device,
@@ -1968,8 +1991,8 @@ var PreviewControls = ({
1968
1991
  cursor: "pointer",
1969
1992
  fontSize: "14px"
1970
1993
  });
1971
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: controlsStyle, children: [
1972
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1994
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: controlsStyle, children: [
1995
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1973
1996
  "button",
1974
1997
  {
1975
1998
  style: updateButtonStyle,
@@ -1978,33 +2001,33 @@ var PreviewControls = ({
1978
2001
  children: isLoading ? "Updating..." : "Update Preview"
1979
2002
  }
1980
2003
  ),
1981
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: deviceSelectorStyle, children: [
1982
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2004
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: deviceSelectorStyle, children: [
2005
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1983
2006
  "button",
1984
2007
  {
1985
2008
  style: deviceButtonStyle(device === "desktop"),
1986
2009
  onClick: () => onDeviceChange("desktop"),
1987
2010
  "aria-label": "Desktop view",
1988
2011
  children: [
1989
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
1990
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2", ry: "2" }),
1991
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
1992
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
2012
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
2013
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("rect", { x: "2", y: "3", width: "20", height: "14", rx: "2", ry: "2" }),
2014
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("line", { x1: "8", y1: "21", x2: "16", y2: "21" }),
2015
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("line", { x1: "12", y1: "17", x2: "12", y2: "21" })
1993
2016
  ] }),
1994
2017
  "Desktop"
1995
2018
  ]
1996
2019
  }
1997
2020
  ),
1998
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
2021
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
1999
2022
  "button",
2000
2023
  {
2001
2024
  style: deviceButtonStyle(device === "mobile"),
2002
2025
  onClick: () => onDeviceChange("mobile"),
2003
2026
  "aria-label": "Mobile view",
2004
2027
  children: [
2005
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
2006
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("rect", { x: "5", y: "2", width: "14", height: "20", rx: "2", ry: "2" }),
2007
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("line", { x1: "12", y1: "18", x2: "12", y2: "18" })
2028
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
2029
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("rect", { x: "5", y: "2", width: "14", height: "20", rx: "2", ry: "2" }),
2030
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("line", { x1: "12", y1: "18", x2: "12", y2: "18" })
2008
2031
  ] }),
2009
2032
  "Mobile"
2010
2033
  ]
@@ -2015,19 +2038,19 @@ var PreviewControls = ({
2015
2038
  };
2016
2039
 
2017
2040
  // src/components/Broadcasts/BroadcastInlinePreview.tsx
2018
- var import_jsx_runtime8 = require("react/jsx-runtime");
2041
+ var import_jsx_runtime9 = require("react/jsx-runtime");
2019
2042
  var BroadcastInlinePreview = () => {
2020
- const [device, setDevice] = (0, import_react8.useState)("desktop");
2021
- const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
2022
- const [showPreview, setShowPreview] = (0, import_react8.useState)(false);
2023
- const [previewHtml, setPreviewHtml] = (0, import_react8.useState)(null);
2024
- const [error, setError] = (0, import_react8.useState)(null);
2043
+ const [device, setDevice] = (0, import_react9.useState)("desktop");
2044
+ const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
2045
+ const [showPreview, setShowPreview] = (0, import_react9.useState)(false);
2046
+ const [previewHtml, setPreviewHtml] = (0, import_react9.useState)(null);
2047
+ const [error, setError] = (0, import_react9.useState)(null);
2025
2048
  const fields = (0, import_ui3.useFormFields)(([fields2]) => ({
2026
2049
  subject: fields2["subject"]?.value,
2027
2050
  preheader: fields2["contentSection.preheader"]?.value,
2028
2051
  content: fields2["contentSection.content"]?.value
2029
2052
  }));
2030
- const updatePreview = (0, import_react8.useCallback)(async () => {
2053
+ const updatePreview = (0, import_react9.useCallback)(async () => {
2031
2054
  if (!fields.content) {
2032
2055
  setError(new Error("Please add some content before previewing"));
2033
2056
  return;
@@ -2102,10 +2125,10 @@ var BroadcastInlinePreview = () => {
2102
2125
  fontSize: "14px",
2103
2126
  fontWeight: 500
2104
2127
  };
2105
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: containerStyle, children: [
2106
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: headerStyle, children: [
2107
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h3", { style: titleStyle, children: "Email Preview" }),
2108
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2128
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: containerStyle, children: [
2129
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: headerStyle, children: [
2130
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { style: titleStyle, children: "Email Preview" }),
2131
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2109
2132
  "button",
2110
2133
  {
2111
2134
  onClick: () => showPreview ? setShowPreview(false) : updatePreview(),
@@ -2115,9 +2138,9 @@ var BroadcastInlinePreview = () => {
2115
2138
  }
2116
2139
  )
2117
2140
  ] }),
2118
- showPreview && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: previewContainerStyle, children: error ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: errorStyle, children: [
2119
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { style: { color: "#ef4444", margin: "0 0 1rem" }, children: error.message }),
2120
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2141
+ showPreview && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: previewContainerStyle, children: error ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: errorStyle, children: [
2142
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { style: { color: "#ef4444", margin: "0 0 1rem" }, children: error.message }),
2143
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2121
2144
  "button",
2122
2145
  {
2123
2146
  onClick: updatePreview,
@@ -2132,8 +2155,8 @@ var BroadcastInlinePreview = () => {
2132
2155
  children: "Retry"
2133
2156
  }
2134
2157
  )
2135
- ] }) : previewHtml ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
2136
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2158
+ ] }) : previewHtml ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2159
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2137
2160
  PreviewControls,
2138
2161
  {
2139
2162
  onUpdate: updatePreview,
@@ -2142,7 +2165,7 @@ var BroadcastInlinePreview = () => {
2142
2165
  isLoading
2143
2166
  }
2144
2167
  ),
2145
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2168
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2146
2169
  "div",
2147
2170
  {
2148
2171
  style: {
@@ -2152,7 +2175,7 @@ var BroadcastInlinePreview = () => {
2152
2175
  justifyContent: "center",
2153
2176
  overflow: "auto"
2154
2177
  },
2155
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2178
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2156
2179
  "div",
2157
2180
  {
2158
2181
  style: {
@@ -2163,7 +2186,7 @@ var BroadcastInlinePreview = () => {
2163
2186
  borderRadius: "8px",
2164
2187
  overflow: "hidden"
2165
2188
  },
2166
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2189
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
2167
2190
  "iframe",
2168
2191
  {
2169
2192
  srcDoc: previewHtml,
@@ -2185,9 +2208,9 @@ var BroadcastInlinePreview = () => {
2185
2208
  };
2186
2209
 
2187
2210
  // src/components/Broadcasts/BroadcastPreviewField.tsx
2188
- var import_jsx_runtime9 = require("react/jsx-runtime");
2211
+ var import_jsx_runtime10 = require("react/jsx-runtime");
2189
2212
  var BroadcastPreviewField = () => {
2190
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
2213
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: {
2191
2214
  padding: "1rem",
2192
2215
  background: "#f9fafb",
2193
2216
  borderRadius: "4px",
@@ -2197,22 +2220,22 @@ var BroadcastPreviewField = () => {
2197
2220
  };
2198
2221
 
2199
2222
  // src/components/Broadcasts/EmailRenderer.tsx
2200
- var import_react9 = require("react");
2223
+ var import_react10 = require("react");
2201
2224
  var import_render = require("@react-email/render");
2202
- var import_jsx_runtime10 = require("react/jsx-runtime");
2225
+ var import_jsx_runtime11 = require("react/jsx-runtime");
2203
2226
  var EmailRenderer = ({
2204
2227
  template,
2205
2228
  data,
2206
2229
  device = "desktop",
2207
2230
  onRender
2208
2231
  }) => {
2209
- const [renderedHtml, setRenderedHtml] = (0, import_react9.useState)("");
2210
- const [error, setError] = (0, import_react9.useState)(null);
2211
- const iframeRef = (0, import_react9.useRef)(null);
2212
- const renderEmail = (0, import_react9.useCallback)(async () => {
2232
+ const [renderedHtml, setRenderedHtml] = (0, import_react10.useState)("");
2233
+ const [error, setError] = (0, import_react10.useState)(null);
2234
+ const iframeRef = (0, import_react10.useRef)(null);
2235
+ const renderEmail = (0, import_react10.useCallback)(async () => {
2213
2236
  try {
2214
2237
  const TemplateComponent = template;
2215
- const element = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TemplateComponent, { ...data });
2238
+ const element = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TemplateComponent, { ...data });
2216
2239
  const html = await (0, import_render.render)(element, {
2217
2240
  pretty: true
2218
2241
  });
@@ -2224,10 +2247,10 @@ var EmailRenderer = ({
2224
2247
  console.error("Failed to render email template:", err);
2225
2248
  }
2226
2249
  }, [template, data, onRender]);
2227
- (0, import_react9.useEffect)(() => {
2250
+ (0, import_react10.useEffect)(() => {
2228
2251
  renderEmail();
2229
2252
  }, [renderEmail]);
2230
- (0, import_react9.useEffect)(() => {
2253
+ (0, import_react10.useEffect)(() => {
2231
2254
  if (iframeRef.current && renderedHtml) {
2232
2255
  const iframe = iframeRef.current;
2233
2256
  const doc = iframe.contentDocument || iframe.contentWindow?.document;
@@ -2266,9 +2289,9 @@ var EmailRenderer = ({
2266
2289
  maxWidth: "500px"
2267
2290
  };
2268
2291
  if (error) {
2269
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: errorStyle, children: [
2270
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { style: { color: "#ef4444", margin: "0 0 1rem" }, children: "Template Render Error" }),
2271
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("pre", { style: {
2292
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: errorStyle, children: [
2293
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { style: { color: "#ef4444", margin: "0 0 1rem" }, children: "Template Render Error" }),
2294
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("pre", { style: {
2272
2295
  background: "#f9fafb",
2273
2296
  padding: "1rem",
2274
2297
  borderRadius: "4px",
@@ -2279,7 +2302,7 @@ var EmailRenderer = ({
2279
2302
  }, children: error.message })
2280
2303
  ] });
2281
2304
  }
2282
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { style: containerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2305
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: containerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2283
2306
  "iframe",
2284
2307
  {
2285
2308
  ref: iframeRef,
@@ -2291,7 +2314,7 @@ var EmailRenderer = ({
2291
2314
  };
2292
2315
 
2293
2316
  // src/components/Broadcasts/StatusBadge.tsx
2294
- var import_jsx_runtime11 = require("react/jsx-runtime");
2317
+ var import_jsx_runtime12 = require("react/jsx-runtime");
2295
2318
  var statusConfig = {
2296
2319
  ["draft" /* DRAFT */]: {
2297
2320
  label: "Draft",
@@ -2339,7 +2362,7 @@ var statusConfig = {
2339
2362
  var StatusBadge = ({ cellData }) => {
2340
2363
  const status = cellData;
2341
2364
  const config = statusConfig[status] || statusConfig["draft" /* DRAFT */];
2342
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2365
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2343
2366
  "span",
2344
2367
  {
2345
2368
  style: {
@@ -2364,21 +2387,21 @@ var EmptyField = () => {
2364
2387
 
2365
2388
  // src/email-templates/DefaultBroadcastTemplate.tsx
2366
2389
  var import_components2 = require("@react-email/components");
2367
- var import_jsx_runtime12 = require("react/jsx-runtime");
2390
+ var import_jsx_runtime13 = require("react/jsx-runtime");
2368
2391
  var DefaultBroadcastTemplate = ({
2369
2392
  subject,
2370
2393
  preheader,
2371
2394
  content
2372
2395
  }) => {
2373
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_components2.Html, { children: [
2374
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_components2.Head, {}),
2375
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_components2.Preview, { children: preheader || subject }),
2376
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_components2.Body, { style: main, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_components2.Container, { style: container, children: [
2377
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_components2.Section, { style: contentSection, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { dangerouslySetInnerHTML: { __html: content } }) }),
2378
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_components2.Hr, { style: divider }),
2379
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_components2.Section, { style: footer, children: [
2380
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_components2.Text, { style: footerText, children: "You're receiving this email because you subscribed to our newsletter." }),
2381
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_components2.Text, { style: footerText, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_components2.Link, { href: "{{unsubscribe_url}}", style: footerLink, children: "Unsubscribe" }) })
2396
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_components2.Html, { children: [
2397
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Head, {}),
2398
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Preview, { children: preheader || subject }),
2399
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Body, { style: main, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_components2.Container, { style: container, children: [
2400
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Section, { style: contentSection, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { dangerouslySetInnerHTML: { __html: content } }) }),
2401
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Hr, { style: divider }),
2402
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_components2.Section, { style: footer, children: [
2403
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Text, { style: footerText, children: "You're receiving this email because you subscribed to our newsletter." }),
2404
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Text, { style: footerText, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_components2.Link, { href: "{{unsubscribe_url}}", style: footerLink, children: "Unsubscribe" }) })
2382
2405
  ] })
2383
2406
  ] }) })
2384
2407
  ] });