@maily-to/render 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +30 -2
- package/dist/index.d.ts +30 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +5 -7
- package/readme.md +63 -4
package/dist/index.d.mts
CHANGED
|
@@ -82,8 +82,28 @@ interface MailyConfig {
|
|
|
82
82
|
*/
|
|
83
83
|
theme?: Partial<ThemeOptions>;
|
|
84
84
|
}
|
|
85
|
+
declare const DEFAULT_SECTION_BACKGROUND_COLOR = "#ffffff";
|
|
86
|
+
declare const DEFAULT_SECTION_ALIGN = "left";
|
|
87
|
+
declare const DEFAULT_SECTION_BORDER_WIDTH = 1;
|
|
88
|
+
declare const DEFAULT_SECTION_BORDER_COLOR = "#000000";
|
|
89
|
+
declare const DEFAULT_SECTION_MARGIN_TOP = 0;
|
|
90
|
+
declare const DEFAULT_SECTION_MARGIN_RIGHT = 0;
|
|
91
|
+
declare const DEFAULT_SECTION_MARGIN_BOTTOM = 0;
|
|
92
|
+
declare const DEFAULT_SECTION_MARGIN_LEFT = 0;
|
|
93
|
+
declare const DEFAULT_SECTION_PADDING_TOP = 5;
|
|
94
|
+
declare const DEFAULT_SECTION_PADDING_RIGHT = 5;
|
|
95
|
+
declare const DEFAULT_SECTION_PADDING_BOTTOM = 5;
|
|
96
|
+
declare const DEFAULT_SECTION_PADDING_LEFT = 5;
|
|
85
97
|
declare const DEFAULT_COLUMNS_WIDTH = "100%";
|
|
86
|
-
declare const
|
|
98
|
+
declare const DEFAULT_COLUMNS_GAP = 8;
|
|
99
|
+
declare const DEFAULT_COLUMN_BACKGROUND_COLOR = "transparent";
|
|
100
|
+
declare const DEFAULT_COLUMN_BORDER_RADIUS = 0;
|
|
101
|
+
declare const DEFAULT_COLUMN_BORDER_WIDTH = 0;
|
|
102
|
+
declare const DEFAULT_COLUMN_BORDER_COLOR = "transparent";
|
|
103
|
+
declare const DEFAULT_COLUMN_PADDING_TOP = 0;
|
|
104
|
+
declare const DEFAULT_COLUMN_PADDING_RIGHT = 0;
|
|
105
|
+
declare const DEFAULT_COLUMN_PADDING_BOTTOM = 0;
|
|
106
|
+
declare const DEFAULT_COLUMN_PADDING_LEFT = 0;
|
|
87
107
|
interface RenderOptions {
|
|
88
108
|
/**
|
|
89
109
|
* The options object allows you to customize the output of the rendered
|
|
@@ -104,6 +124,8 @@ type VariableFormatter = (options: {
|
|
|
104
124
|
}) => string;
|
|
105
125
|
type VariableValues = Map<string, string>;
|
|
106
126
|
type LinkValues = Map<string, string>;
|
|
127
|
+
type PayloadValue = Record<string, any> | boolean;
|
|
128
|
+
type PayloadValues = Map<string, PayloadValue>;
|
|
107
129
|
declare class Maily {
|
|
108
130
|
private readonly content;
|
|
109
131
|
private config;
|
|
@@ -112,6 +134,7 @@ declare class Maily {
|
|
|
112
134
|
private variableValues;
|
|
113
135
|
private linkValues;
|
|
114
136
|
private openTrackingPixel;
|
|
137
|
+
private payloadValues;
|
|
115
138
|
constructor(content?: JSONContent);
|
|
116
139
|
setPreviewText(preview?: string): void;
|
|
117
140
|
setTheme(theme: Partial<ThemeOptions>): void;
|
|
@@ -142,6 +165,8 @@ declare class Maily {
|
|
|
142
165
|
setVariableValues(values: Record<string, string>): void;
|
|
143
166
|
setLinkValue(link: string, value: string): void;
|
|
144
167
|
setLinkValues(values: Record<string, string>): void;
|
|
168
|
+
setPayloadValue(key: string, value: PayloadValue): void;
|
|
169
|
+
setPayloadValues(values: Record<string, PayloadValue>): void;
|
|
145
170
|
/**
|
|
146
171
|
* `setOpenTrackingPixel` will set the open tracking pixel.
|
|
147
172
|
*
|
|
@@ -192,9 +217,12 @@ declare class Maily {
|
|
|
192
217
|
private linkCard;
|
|
193
218
|
private section;
|
|
194
219
|
private columns;
|
|
220
|
+
private adjustColumnsContent;
|
|
195
221
|
private column;
|
|
222
|
+
private for;
|
|
223
|
+
private shouldShow;
|
|
196
224
|
}
|
|
197
225
|
|
|
198
226
|
declare function render(content: JSONContent, config?: MailyConfig & RenderOptions): Promise<string>;
|
|
199
227
|
|
|
200
|
-
export { type AllowedSpacers,
|
|
228
|
+
export { type AllowedSpacers, DEFAULT_COLUMNS_GAP, DEFAULT_COLUMNS_WIDTH, DEFAULT_COLUMN_BACKGROUND_COLOR, DEFAULT_COLUMN_BORDER_COLOR, DEFAULT_COLUMN_BORDER_RADIUS, DEFAULT_COLUMN_BORDER_WIDTH, DEFAULT_COLUMN_PADDING_BOTTOM, DEFAULT_COLUMN_PADDING_LEFT, DEFAULT_COLUMN_PADDING_RIGHT, DEFAULT_COLUMN_PADDING_TOP, DEFAULT_SECTION_ALIGN, DEFAULT_SECTION_BACKGROUND_COLOR, DEFAULT_SECTION_BORDER_COLOR, DEFAULT_SECTION_BORDER_WIDTH, DEFAULT_SECTION_MARGIN_BOTTOM, DEFAULT_SECTION_MARGIN_LEFT, DEFAULT_SECTION_MARGIN_RIGHT, DEFAULT_SECTION_MARGIN_TOP, DEFAULT_SECTION_PADDING_BOTTOM, DEFAULT_SECTION_PADDING_LEFT, DEFAULT_SECTION_PADDING_RIGHT, DEFAULT_SECTION_PADDING_TOP, type LinkValues, Maily, type MailyConfig, type MarkType, type PayloadValue, type PayloadValues, type RenderOptions, type ThemeOptions, type VariableFormatter, type VariableValues, render };
|
package/dist/index.d.ts
CHANGED
|
@@ -82,8 +82,28 @@ interface MailyConfig {
|
|
|
82
82
|
*/
|
|
83
83
|
theme?: Partial<ThemeOptions>;
|
|
84
84
|
}
|
|
85
|
+
declare const DEFAULT_SECTION_BACKGROUND_COLOR = "#ffffff";
|
|
86
|
+
declare const DEFAULT_SECTION_ALIGN = "left";
|
|
87
|
+
declare const DEFAULT_SECTION_BORDER_WIDTH = 1;
|
|
88
|
+
declare const DEFAULT_SECTION_BORDER_COLOR = "#000000";
|
|
89
|
+
declare const DEFAULT_SECTION_MARGIN_TOP = 0;
|
|
90
|
+
declare const DEFAULT_SECTION_MARGIN_RIGHT = 0;
|
|
91
|
+
declare const DEFAULT_SECTION_MARGIN_BOTTOM = 0;
|
|
92
|
+
declare const DEFAULT_SECTION_MARGIN_LEFT = 0;
|
|
93
|
+
declare const DEFAULT_SECTION_PADDING_TOP = 5;
|
|
94
|
+
declare const DEFAULT_SECTION_PADDING_RIGHT = 5;
|
|
95
|
+
declare const DEFAULT_SECTION_PADDING_BOTTOM = 5;
|
|
96
|
+
declare const DEFAULT_SECTION_PADDING_LEFT = 5;
|
|
85
97
|
declare const DEFAULT_COLUMNS_WIDTH = "100%";
|
|
86
|
-
declare const
|
|
98
|
+
declare const DEFAULT_COLUMNS_GAP = 8;
|
|
99
|
+
declare const DEFAULT_COLUMN_BACKGROUND_COLOR = "transparent";
|
|
100
|
+
declare const DEFAULT_COLUMN_BORDER_RADIUS = 0;
|
|
101
|
+
declare const DEFAULT_COLUMN_BORDER_WIDTH = 0;
|
|
102
|
+
declare const DEFAULT_COLUMN_BORDER_COLOR = "transparent";
|
|
103
|
+
declare const DEFAULT_COLUMN_PADDING_TOP = 0;
|
|
104
|
+
declare const DEFAULT_COLUMN_PADDING_RIGHT = 0;
|
|
105
|
+
declare const DEFAULT_COLUMN_PADDING_BOTTOM = 0;
|
|
106
|
+
declare const DEFAULT_COLUMN_PADDING_LEFT = 0;
|
|
87
107
|
interface RenderOptions {
|
|
88
108
|
/**
|
|
89
109
|
* The options object allows you to customize the output of the rendered
|
|
@@ -104,6 +124,8 @@ type VariableFormatter = (options: {
|
|
|
104
124
|
}) => string;
|
|
105
125
|
type VariableValues = Map<string, string>;
|
|
106
126
|
type LinkValues = Map<string, string>;
|
|
127
|
+
type PayloadValue = Record<string, any> | boolean;
|
|
128
|
+
type PayloadValues = Map<string, PayloadValue>;
|
|
107
129
|
declare class Maily {
|
|
108
130
|
private readonly content;
|
|
109
131
|
private config;
|
|
@@ -112,6 +134,7 @@ declare class Maily {
|
|
|
112
134
|
private variableValues;
|
|
113
135
|
private linkValues;
|
|
114
136
|
private openTrackingPixel;
|
|
137
|
+
private payloadValues;
|
|
115
138
|
constructor(content?: JSONContent);
|
|
116
139
|
setPreviewText(preview?: string): void;
|
|
117
140
|
setTheme(theme: Partial<ThemeOptions>): void;
|
|
@@ -142,6 +165,8 @@ declare class Maily {
|
|
|
142
165
|
setVariableValues(values: Record<string, string>): void;
|
|
143
166
|
setLinkValue(link: string, value: string): void;
|
|
144
167
|
setLinkValues(values: Record<string, string>): void;
|
|
168
|
+
setPayloadValue(key: string, value: PayloadValue): void;
|
|
169
|
+
setPayloadValues(values: Record<string, PayloadValue>): void;
|
|
145
170
|
/**
|
|
146
171
|
* `setOpenTrackingPixel` will set the open tracking pixel.
|
|
147
172
|
*
|
|
@@ -192,9 +217,12 @@ declare class Maily {
|
|
|
192
217
|
private linkCard;
|
|
193
218
|
private section;
|
|
194
219
|
private columns;
|
|
220
|
+
private adjustColumnsContent;
|
|
195
221
|
private column;
|
|
222
|
+
private for;
|
|
223
|
+
private shouldShow;
|
|
196
224
|
}
|
|
197
225
|
|
|
198
226
|
declare function render(content: JSONContent, config?: MailyConfig & RenderOptions): Promise<string>;
|
|
199
227
|
|
|
200
|
-
export { type AllowedSpacers,
|
|
228
|
+
export { type AllowedSpacers, DEFAULT_COLUMNS_GAP, DEFAULT_COLUMNS_WIDTH, DEFAULT_COLUMN_BACKGROUND_COLOR, DEFAULT_COLUMN_BORDER_COLOR, DEFAULT_COLUMN_BORDER_RADIUS, DEFAULT_COLUMN_BORDER_WIDTH, DEFAULT_COLUMN_PADDING_BOTTOM, DEFAULT_COLUMN_PADDING_LEFT, DEFAULT_COLUMN_PADDING_RIGHT, DEFAULT_COLUMN_PADDING_TOP, DEFAULT_SECTION_ALIGN, DEFAULT_SECTION_BACKGROUND_COLOR, DEFAULT_SECTION_BORDER_COLOR, DEFAULT_SECTION_BORDER_WIDTH, DEFAULT_SECTION_MARGIN_BOTTOM, DEFAULT_SECTION_MARGIN_LEFT, DEFAULT_SECTION_MARGIN_RIGHT, DEFAULT_SECTION_MARGIN_TOP, DEFAULT_SECTION_PADDING_BOTTOM, DEFAULT_SECTION_PADDING_LEFT, DEFAULT_SECTION_PADDING_RIGHT, DEFAULT_SECTION_PADDING_TOP, type LinkValues, Maily, type MailyConfig, type MarkType, type PayloadValue, type PayloadValues, type RenderOptions, type ThemeOptions, type VariableFormatter, type VariableValues, render };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
|
|
3
|
-
"use strict";var w=Object.defineProperty,K=Object.defineProperties,Y=Object.getOwnPropertyDescriptor,G=Object.getOwnPropertyDescriptors,Q=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var I=(a,e,n)=>e in a?w(a,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[e]=n,h=(a,e)=>{for(var n in e||(e={}))T.call(e,n)&&I(a,n,e[n]);if(O)for(var n of O(e))W.call(e,n)&&I(a,n,e[n]);return a},y=(a,e)=>K(a,G(e));var D=(a,e)=>{var n={};for(var t in a)T.call(a,t)&&e.indexOf(t)<0&&(n[t]=a[t]);if(a!=null&&O)for(var t of O(a))e.indexOf(t)<0&&W.call(a,t)&&(n[t]=a[t]);return n};var Z=(a,e)=>{for(var n in e)w(a,n,{get:e[n],enumerable:!0})},ee=(a,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Q(e))!T.call(a,o)&&o!==n&&w(a,o,{get:()=>e[o],enumerable:!(t=Y(e,o))||t.enumerable});return a};var te=a=>ee(w({},"__esModule",{value:!0}),a);var b=(a,e,n)=>new Promise((t,o)=>{var i=p=>{try{c(n.next(p))}catch(u){o(u)}},l=p=>{try{c(n.throw(p))}catch(u){o(u)}},c=p=>p.done?t(p.value):Promise.resolve(p.value).then(i,l);c((n=n.apply(a,e)).next())});var ue={};Z(ue,{DEFAULT_COLUMNS_ALIGN:()=>$,DEFAULT_COLUMNS_WIDTH:()=>U,Maily:()=>v,render:()=>pe});module.exports=te(ue);var k=require("react"),s=require("@react-email/components"),q=require("@react-email/render");var ne=a=>Object.prototype.toString.call(a);var ie=a=>ne(a)==="[object Object]";function re(a){return Object.keys(a)}function N(a,...e){if(!e.length)return a;let n=e.shift();return n===void 0?a:(E(a)&&E(n)&&re(n).forEach(t=>{t==="__proto__"||t==="constructor"||t==="prototype"||(E(n[t])?(a[t]||(a[t]={}),E(a[t])?N(a[t],n[t]):a[t]=n[t]):a[t]=n[t])}),N(a,...e))}function E(a){return ie(a)&&!Array.isArray(a)}var Se=Symbol("p-void");function L(){return Math.random().toString(36).substr(2,6)}var r=require("react/jsx-runtime");var oe={sm:"8px",md:"16px",lg:"32px",xl:"64px"},C={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var se={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var j={sm:"40px",md:"48px",lg:"64px"},ae={pretty:!1,plainText:!1},H={colors:{heading:"#111827",paragraph:"#374151",horizontal:"#EAEAEA",footer:"#64748B",blockquoteBorder:"#D1D5DB",codeBackground:"#EFEFEF",codeText:"#111827",linkCardTitle:"#111827",linkCardDescription:"#6B7280",linkCardBadgeText:"#111827",linkCardBadgeBackground:"#FEF08A",linkCardSubTitle:"#6B7280"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}},le='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',ce="#ffffff",U="100%",$="left",v=class{constructor(e={type:"doc",content:[]}){this.config={theme:H};this.variableFormatter=({variable:e,fallback:n})=>n?`{{${e},fallback=${n}}}`:`{{${e}}}`;this.shouldReplaceVariableValues=!1;this.variableValues=new Map;this.linkValues=new Map;this.content=e}setPreviewText(e){this.config.preview=e}setTheme(e){this.config.theme=N(this.config.theme||H,e)}setVariableFormatter(e){this.variableFormatter=e}setVariableValue(e,n){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(e,n)}setVariableValues(e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(e).forEach(([n,t])=>{this.setVariableValue(n,t)})}setLinkValue(e,n){this.linkValues.set(e,n)}setLinkValues(e){Object.entries(e).forEach(([n,t])=>{this.setLinkValue(n,t)})}setOpenTrackingPixel(e){this.openTrackingPixel=e}setShouldReplaceVariableValues(e){this.shouldReplaceVariableValues=e}getAllLinks(){let e=this.content.content||[],n=new Set,t=i=>i&&this.isValidUrl(i)&&!i.startsWith("#")&&!i.startsWith("mailto:")&&!i.startsWith("tel:")&&typeof i=="string",o=i=>{var l;if(i.type==="button"){let c=(l=i.attrs)==null?void 0:l.url;t(c)&&c&&n.add(c)}else i.content&&i.content.forEach(c=>{c.marks&&c.marks.forEach(p=>{var m;let u=(m=p.attrs)==null?void 0:m.href;p.type==="link"&&t(u)&&n.add(u)}),c.content&&o(c)})};return e.forEach(i=>{o(i)}),n}isValidUrl(e){try{let n=new URL(e);return!0}catch(n){return!1}}render(){return b(this,arguments,function*(e=ae){let n=this.markup();return(0,q.renderAsync)(n,e)})}markup(){let e=this.content.content||[],n=e.map((i,l)=>{let c={prev:e[l-1],next:e[l+1],parent:i},p=this.renderNode(i,c);return p?(0,r.jsx)(k.Fragment,{children:p},L()):null}),{preview:t}=this.config;return(0,r.jsxs)(s.Html,{children:[(0,r.jsxs)(s.Head,{children:[(0,r.jsx)(s.Font,{fallbackFontFamily:"sans-serif",fontFamily:"Inter",fontStyle:"normal",fontWeight:400,webFont:{url:"https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19",format:"woff2"}}),(0,r.jsx)("style",{dangerouslySetInnerHTML:{__html:"blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}"}}),(0,r.jsx)("meta",{content:"width=device-width",name:"viewport"}),(0,r.jsx)("meta",{content:"IE=edge",httpEquiv:"X-UA-Compatible"}),(0,r.jsx)("meta",{name:"x-apple-disable-message-reformatting"}),(0,r.jsx)("meta",{content:"telephone=no,address=no,email=no,date=no,url=no",name:"format-detection"}),(0,r.jsx)("meta",{content:"light",name:"color-scheme"}),(0,r.jsx)("meta",{content:"light",name:"supported-color-schemes"})]}),(0,r.jsxs)(s.Body,{style:{margin:0},children:[t?(0,r.jsx)(s.Preview,{id:"__react-email-preview",children:t}):null,(0,r.jsx)(s.Container,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:n}),this.openTrackingPixel?(0,r.jsx)(s.Img,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMarginOverrideConditions(e,n){let{parent:t,prev:o,next:i}=n||{},l=(i==null?void 0:i.type)==="spacer",c=(o==null?void 0:o.type)==="spacer",p=(t==null?void 0:t.type)==="listItem",u=(t==null?void 0:t.type)==="section"&&!i,m=(t==null?void 0:t.type)==="section"&&!o,d=(t==null?void 0:t.type)==="column"&&!i,f=(t==null?void 0:t.type)==="column"&&!o;return{isNextSpacer:l,isPrevSpacer:c,isLastSectionElement:u,isFirstSectionElement:m,isParentListItem:p,isLastColumnElement:d,isFirstColumnElement:f}}getMappedContent(e,n){let t=e.content||[];return t.map((o,i)=>{let l=this.renderNode(o,y(h({},n),{next:t[i+1],prev:t[i-1]}));return l?(0,r.jsx)(k.Fragment,{children:l},L()):null}).filter(o=>o!==null)}renderNode(e,n={}){var o;let t=e.type||"";if(t in this)return(o=this[t])==null?void 0:o.call(this,e,n);throw new Error(`Node type "${t}" is not supported.`)}renderMark(e){let n=e.text||(0,r.jsx)(r.Fragment,{children:"\xA0"});return(e.marks||[]).reduce((o,i)=>{var c;let l=i.type;if(l in this)return(c=this[l])==null?void 0:c.call(this,i,o);throw new Error(`Mark type "${l}" is not supported.`)},(0,r.jsx)(r.Fragment,{children:n}))}paragraph(e,n){var u,m,d,f;let{attrs:t}=e,o=(t==null?void 0:t.textAlign)||"left",{isNextSpacer:i,isLastSectionElement:l,isParentListItem:c,isLastColumnElement:p}=this.getMarginOverrideConditions(e,n);return(0,r.jsx)(s.Text,{style:h({textAlign:o,marginBottom:c||i||l||p?"0px":"20px",marginTop:"0px",fontSize:(m=(u=this.config.theme)==null?void 0:u.fontSize)==null?void 0:m.paragraph,color:(f=(d=this.config.theme)==null?void 0:d.colors)==null?void 0:f.paragraph},C),children:e.content?this.getMappedContent(e):(0,r.jsx)(r.Fragment,{children:"\xA0"})})}text(e,n){let t=e.text||" ";return e.marks?this.renderMark(e):(0,r.jsx)(r.Fragment,{children:t})}bold(e,n){return(0,r.jsx)("strong",{children:n})}italic(e,n){return(0,r.jsx)("em",{children:n})}underline(e,n){return(0,r.jsx)("u",{children:n})}strike(e,n){return(0,r.jsx)("s",{style:{textDecoration:"line-through"},children:n})}textStyle(e,n){var i,l;let{attrs:t}=e,{color:o=(l=(i=this.config.theme)==null?void 0:i.colors)==null?void 0:l.paragraph}=t||{};return(0,r.jsx)("span",{style:{color:o},children:n})}link(e,n){var c,p;let{attrs:t}=e,o=(t==null?void 0:t.href)||"#",i=(t==null?void 0:t.target)||"_blank",l=(t==null?void 0:t.rel)||"noopener noreferrer nofollow";return(typeof this.linkValues=="object"||typeof this.variableValues=="object")&&(o=this.linkValues.get(o)||this.variableValues.get(o)||o),(0,r.jsx)(s.Link,{href:o,rel:l,style:{fontWeight:500,textDecoration:"underline",color:(p=(c=this.config.theme)==null?void 0:c.colors)==null?void 0:p.heading},target:i,children:n})}heading(e,n){var f,g;let{attrs:t}=e,o=`h${Number(t==null?void 0:t.level)||1}`,i=(t==null?void 0:t.textAlign)||"left",{isNextSpacer:l,isLastSectionElement:c,isLastColumnElement:p}=this.getMarginOverrideConditions(e,n),{fontSize:u,lineHeight:m,fontWeight:d}=se[o];return(0,r.jsx)(s.Heading,{as:o,style:{textAlign:i,color:(g=(f=this.config.theme)==null?void 0:f.colors)==null?void 0:g.heading,marginBottom:l||c||p?"0":"12px",marginTop:0,fontSize:u,lineHeight:m,fontWeight:d},children:this.getMappedContent(e,n)})}variable(e,n){let{id:t,fallback:o}=e.attrs||{},i=this.variableFormatter({variable:t,fallback:o});return this.shouldReplaceVariableValues&&(i=this.variableValues.get(t)||o||i),(0,r.jsx)(r.Fragment,{children:i})}horizontalRule(e,n){return(0,r.jsx)(s.Hr,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(e,n){let{isNextSpacer:t,isLastSectionElement:o,isLastColumnElement:i}=this.getMarginOverrideConditions(e,n);return(0,r.jsx)(s.Container,{children:(0,r.jsx)("ol",{style:{marginTop:"0px",marginBottom:t||o||i?"0":"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(e)})})}bulletList(e,n){let{parent:t,next:o}=n||{},{isLastSectionElement:i,isNextSpacer:l,isLastColumnElement:c}=this.getMarginOverrideConditions(e,{parent:t,next:o});return(0,r.jsx)(s.Container,{style:{maxWidth:"100%"},children:(0,r.jsx)("ul",{style:{marginTop:"0px",marginBottom:i||l||c?"0":"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(e)})})}listItem(e,n){return(0,r.jsx)(s.Container,{style:{maxWidth:"100%"},children:(0,r.jsx)("li",{style:h({marginBottom:"8px",paddingLeft:"6px"},C),children:this.getMappedContent(e,y(h({},n),{parent:e}))})})}button(e,n){let{attrs:t}=e,{text:o,url:i,variant:l,buttonColor:c,textColor:p,borderRadius:u,alignment:m="left"}=t||{},d="0px";u==="round"?d="9999px":u==="smooth"&&(d="6px");let{isNextSpacer:f,isLastSectionElement:g,isLastColumnElement:x}=this.getMarginOverrideConditions(e,n),S=this.linkValues.get(i)||this.variableValues.get(i)||i;return(0,r.jsx)(s.Container,{style:{textAlign:m,maxWidth:"100%",marginBottom:f||g||x?"0px":"20px"},children:(0,r.jsx)(s.Button,{href:S,style:{color:String(p),backgroundColor:l==="filled"?String(c):"transparent",borderColor:String(c),padding:l==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:d},children:o})})}spacer(e,n){let{attrs:t}=e,{height:o="auto"}=t||{};return(0,r.jsx)(s.Container,{style:{height:oe[o]||o}})}hardBreak(e,n){return(0,r.jsx)("br",{})}logo(e,n){let{attrs:t}=e,{src:o,alt:i,title:l,size:c,alignment:p="left"}=t||{},{isNextSpacer:u,isLastSectionElement:m,isLastColumnElement:d}=this.getMarginOverrideConditions(e,n);return(0,r.jsx)(s.Row,{style:{marginTop:"0px",marginBottom:u||m||d?"0px":"32px"},children:(0,r.jsx)(s.Column,{align:p,children:(0,r.jsx)(s.Img,{alt:i||l||"Logo",src:o,style:{width:j[c]||c,height:j[c]||c},title:l||i||"Logo"})})})}image(e,n){let{attrs:t}=e,{src:o,alt:i,title:l,width:c="auto",height:p="auto",alignment:u="center",externalLink:m=""}=t||{},{isNextSpacer:d,isLastSectionElement:f,isLastColumnElement:g}=this.getMarginOverrideConditions(e,n),x=(0,r.jsx)(s.Img,{alt:i||l||"Image",src:o,style:{height:"100%",width:"100%",maxWidth:c,maxHeight:p,outline:"none",border:"none",textDecoration:"none"},title:l||i||"Image"});return(0,r.jsx)(s.Row,{style:{marginTop:"0px",marginBottom:d||f||g?"0px":"32px"},children:(0,r.jsx)(s.Column,{align:u,children:m?(0,r.jsx)("a",{href:m,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:x}):x})})}footer(e,n){var p,u,m,d,f,g,x,S;let{attrs:t}=e,{textAlign:o="left"}=t||{},{isNextSpacer:i,isLastSectionElement:l,isLastColumnElement:c}=this.getMarginOverrideConditions(e,n);return(0,r.jsx)(s.Text,{style:h({fontSize:(m=(u=(p=this.config.theme)==null?void 0:p.fontSize)==null?void 0:u.footer)==null?void 0:m.size,lineHeight:(g=(f=(d=this.config.theme)==null?void 0:d.fontSize)==null?void 0:f.footer)==null?void 0:g.lineHeight,color:(S=(x=this.config.theme)==null?void 0:x.colors)==null?void 0:S.footer,marginTop:"0px",marginBottom:i||l||c?"0px":"20px",textAlign:o},C),children:this.getMappedContent(e)})}blockquote(e,n){var c,p;let{isNextSpacer:t,isPrevSpacer:o,isLastSectionElement:i,isLastColumnElement:l}=this.getMarginOverrideConditions(e,n);return(0,r.jsx)("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(p=(c=this.config.theme)==null?void 0:c.colors)==null?void 0:p.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:o?"0px":"20px",marginBottom:t||i||l?"0px":"20px"},children:this.getMappedContent(e)})}code(e,n){var t,o,i,l;return(0,r.jsx)("code",{style:{backgroundColor:(o=(t=this.config.theme)==null?void 0:t.colors)==null?void 0:o.codeBackground,color:(l=(i=this.config.theme)==null?void 0:i.colors)==null?void 0:l.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:le,fontWeight:400,letterSpacing:0},children:n})}linkCard(e,n){var S,J,M,A,V,_,B,R,P,X,F,z;let{attrs:t}=e,{isNextSpacer:o,isLastSectionElement:i,isLastColumnElement:l}=this.getMarginOverrideConditions(e,n),{title:c,description:p,link:u,linkTitle:m,image:d,badgeText:f,subTitle:g}=t||{},x=this.linkValues.get(u)||this.variableValues.get(u)||u||"#";return(0,r.jsxs)("a",{href:x,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:o||i||l?"0px":"20px"},target:"_blank",children:[d?(0,r.jsx)(s.Row,{style:{marginBottom:"6px"},children:(0,r.jsx)(s.Column,{style:{width:"100%",height:"100%"},children:(0,r.jsx)(s.Img,{alt:c||"Link Card",src:d,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:c||"Link Card"})})}):null,(0,r.jsx)(s.Row,{style:{padding:"15px",marginTop:0,marginBottom:0},children:(0,r.jsxs)(s.Column,{style:{verticalAlign:"top"},children:[(0,r.jsxs)(s.Row,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[(0,r.jsx)(s.Column,{children:(0,r.jsx)(s.Text,{style:h({fontSize:"18px",fontWeight:600,color:(J=(S=this.config.theme)==null?void 0:S.colors)==null?void 0:J.linkCardTitle,margin:"0px"},C),children:c})}),f||g?(0,r.jsxs)(s.Column,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[f?(0,r.jsx)("span",{style:{fontWeight:600,color:(A=(M=this.config.theme)==null?void 0:M.colors)==null?void 0:A.linkCardBadgeText,padding:"4px 8px",borderRadius:"8px",backgroundColor:(_=(V=this.config.theme)==null?void 0:V.colors)==null?void 0:_.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:f}):null," ",g&&!f?(0,r.jsx)("span",{style:{fontWeight:"normal",color:(R=(B=this.config.theme)==null?void 0:B.colors)==null?void 0:R.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:g}):null]}):null]}),(0,r.jsxs)(s.Text,{style:h({fontSize:"16px",color:(X=(P=this.config.theme)==null?void 0:P.colors)==null?void 0:X.linkCardDescription,marginTop:"0px",marginBottom:"0px"},C),children:[p," ",m?(0,r.jsx)("a",{href:x,rel:"noopener noreferrer",style:{color:(z=(F=this.config.theme)==null?void 0:F.colors)==null?void 0:z.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:m}):null]})]})})]})}section(e,n){let{attrs:t}=e,{borderRadius:o=0,padding:i=0,backgroundColor:l=ce}=t||{};return(0,r.jsx)(s.Container,{style:{backgroundColor:l,borderRadius:o,padding:i},children:this.getMappedContent(e,y(h({},n),{parent:e}))})}columns(e,n){let{attrs:t}=e,{width:o=U,align:i=$}=t||{};return(0,r.jsx)(s.Row,{width:o,align:i,style:{margin:0,padding:0,width:o},children:this.getMappedContent(e,y(h({},n),{parent:e}))})}column(e,n){let{attrs:t}=e,{width:o="50%",verticalAlign:i="top"}=t||{};return(0,r.jsx)(s.Column,{style:{width:o,verticalAlign:i,margin:0,padding:0},children:this.getMappedContent(e,y(h({},n),{parent:e}))})}};function pe(a,e){return b(this,null,function*(){let l=e||{},{theme:n,preview:t}=l,o=D(l,["theme","preview"]),i=new v(a);return i.setPreviewText(t),i.setTheme(n||{}),i.render(o)})}0&&(module.exports={DEFAULT_COLUMNS_ALIGN,DEFAULT_COLUMNS_WIDTH,Maily,render});
|
|
3
|
+
"use strict";var T=Object.defineProperty,rt=Object.defineProperties,it=Object.getOwnPropertyDescriptor,st=Object.getOwnPropertyDescriptors,at=Object.getOwnPropertyNames,E=Object.getOwnPropertySymbols;var R=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var P=(c,t,n)=>t in c?T(c,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[t]=n,g=(c,t)=>{for(var n in t||(t={}))R.call(t,n)&&P(c,n,t[n]);if(E)for(var n of E(t))I.call(t,n)&&P(c,n,t[n]);return c},x=(c,t)=>rt(c,st(t));var U=(c,t)=>{var n={};for(var e in c)R.call(c,e)&&t.indexOf(e)<0&&(n[e]=c[e]);if(c!=null&&E)for(var e of E(c))t.indexOf(e)<0&&I.call(c,e)&&(n[e]=c[e]);return n};var lt=(c,t)=>{for(var n in t)T(c,n,{get:t[n],enumerable:!0})},ct=(c,t,n,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of at(t))!R.call(c,i)&&i!==n&&T(c,i,{get:()=>t[i],enumerable:!(e=it(t,i))||e.enumerable});return c};var pt=c=>ct(T({},"__esModule",{value:!0}),c);var C=(c,t,n)=>new Promise((e,i)=>{var r=p=>{try{a(n.next(p))}catch(u){i(u)}},s=p=>{try{a(n.throw(p))}catch(u){i(u)}},a=p=>p.done?e(p.value):Promise.resolve(p.value).then(r,s);a((n=n.apply(c,t)).next())});var _t={};lt(_t,{DEFAULT_COLUMNS_GAP:()=>ot,DEFAULT_COLUMNS_WIDTH:()=>yt,DEFAULT_COLUMN_BACKGROUND_COLOR:()=>St,DEFAULT_COLUMN_BORDER_COLOR:()=>Ot,DEFAULT_COLUMN_BORDER_RADIUS:()=>bt,DEFAULT_COLUMN_BORDER_WIDTH:()=>wt,DEFAULT_COLUMN_PADDING_BOTTOM:()=>Nt,DEFAULT_COLUMN_PADDING_LEFT:()=>Et,DEFAULT_COLUMN_PADDING_RIGHT:()=>vt,DEFAULT_COLUMN_PADDING_TOP:()=>Ct,DEFAULT_SECTION_ALIGN:()=>H,DEFAULT_SECTION_BACKGROUND_COLOR:()=>j,DEFAULT_SECTION_BORDER_COLOR:()=>q,DEFAULT_SECTION_BORDER_WIDTH:()=>G,DEFAULT_SECTION_MARGIN_BOTTOM:()=>Y,DEFAULT_SECTION_MARGIN_LEFT:()=>Q,DEFAULT_SECTION_MARGIN_RIGHT:()=>K,DEFAULT_SECTION_MARGIN_TOP:()=>$,DEFAULT_SECTION_PADDING_BOTTOM:()=>et,DEFAULT_SECTION_PADDING_LEFT:()=>nt,DEFAULT_SECTION_PADDING_RIGHT:()=>tt,DEFAULT_SECTION_PADDING_TOP:()=>Z,Maily:()=>N,render:()=>Tt});module.exports=pt(_t);var A=require("react"),l=require("@react-email/components"),z=require("@react-email/render");var ut=c=>Object.prototype.toString.call(c);var ht=c=>ut(c)==="[object Object]";function dt(c){return Object.keys(c)}function L(c,...t){if(!t.length)return c;let n=t.shift();return n===void 0?c:(_(c)&&_(n)&&dt(n).forEach(e=>{e==="__proto__"||e==="constructor"||e==="prototype"||(_(n[e])?(c[e]||(c[e]={}),_(c[e])?L(c[e],n[e]):c[e]=n[e]):c[e]=n[e])}),L(c,...t))}function _(c){return ht(c)&&!Array.isArray(c)}var Jt=Symbol("p-void");function M(){return Math.random().toString(36).substr(2,6)}var o=require("react/jsx-runtime");var mt={sm:"8px",md:"16px",lg:"32px",xl:"64px"},v={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var ft={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var W={sm:"40px",md:"48px",lg:"64px"},gt={pretty:!1,plainText:!1},X={colors:{heading:"#111827",paragraph:"#374151",horizontal:"#EAEAEA",footer:"#64748B",blockquoteBorder:"#D1D5DB",codeBackground:"#EFEFEF",codeText:"#111827",linkCardTitle:"#111827",linkCardDescription:"#6B7280",linkCardBadgeText:"#111827",linkCardBadgeBackground:"#FEF08A",linkCardSubTitle:"#6B7280"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}},xt='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',j="#ffffff",H="left",G=1,q="#000000",$=0,K=0,Y=0,Q=0,Z=5,tt=5,et=5,nt=5,yt="100%",ot=8,St="transparent",bt=0,wt=0,Ot="transparent",Ct=0,vt=0,Nt=0,Et=0,N=class{constructor(t={type:"doc",content:[]}){this.config={theme:X};this.variableFormatter=({variable:t,fallback:n})=>n?`{{${t},fallback=${n}}}`:`{{${t}}}`;this.shouldReplaceVariableValues=!1;this.variableValues=new Map;this.linkValues=new Map;this.payloadValues=new Map;this.content=t}setPreviewText(t){this.config.preview=t}setTheme(t){this.config.theme=L(this.config.theme||X,t)}setVariableFormatter(t){this.variableFormatter=t}setVariableValue(t,n){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(t,n)}setVariableValues(t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(t).forEach(([n,e])=>{this.setVariableValue(n,e)})}setLinkValue(t,n){this.linkValues.set(t,n)}setLinkValues(t){Object.entries(t).forEach(([n,e])=>{this.setLinkValue(n,e)})}setPayloadValue(t,n){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.payloadValues.set(t,n)}setPayloadValues(t){Object.entries(t).forEach(([n,e])=>{this.setPayloadValue(n,e)})}setOpenTrackingPixel(t){this.openTrackingPixel=t}setShouldReplaceVariableValues(t){this.shouldReplaceVariableValues=t}getAllLinks(){let t=this.content.content||[],n=new Set,e=r=>r&&this.isValidUrl(r)&&!r.startsWith("#")&&!r.startsWith("mailto:")&&!r.startsWith("tel:")&&typeof r=="string",i=r=>{var s;if(r.type==="button"){let a=(s=r.attrs)==null?void 0:s.url;e(a)&&a&&n.add(a)}else r.content&&r.content.forEach(a=>{a.marks&&a.marks.forEach(p=>{var h;let u=(h=p.attrs)==null?void 0:h.href;p.type==="link"&&e(u)&&n.add(u)}),a.content&&i(a)})};return t.forEach(r=>{i(r)}),n}isValidUrl(t){try{let n=new URL(t);return!0}catch(n){return!1}}render(){return C(this,arguments,function*(t=gt){let n=this.markup();return(0,z.renderAsync)(n,t)})}markup(){let t=this.content.content||[],n=t.map((r,s)=>{let a={prev:t[s-1],next:t[s+1],parent:r},p=this.renderNode(r,a);return p?(0,o.jsx)(A.Fragment,{children:p},M()):null}),{preview:e}=this.config;return(0,o.jsxs)(l.Html,{children:[(0,o.jsxs)(l.Head,{children:[(0,o.jsx)(l.Font,{fallbackFontFamily:"sans-serif",fontFamily:"Inter",fontStyle:"normal",fontWeight:400,webFont:{url:"https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19",format:"woff2"}}),(0,o.jsx)("style",{dangerouslySetInnerHTML:{__html:"blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}@media only screen and (max-width:425px){.tab-row-full{width:100%!important}.tab-col-full{display:block!important;width:100%!important}.tab-pad{padding:0!important}}"}}),(0,o.jsx)("meta",{content:"width=device-width",name:"viewport"}),(0,o.jsx)("meta",{content:"IE=edge",httpEquiv:"X-UA-Compatible"}),(0,o.jsx)("meta",{name:"x-apple-disable-message-reformatting"}),(0,o.jsx)("meta",{content:"telephone=no,address=no,email=no,date=no,url=no",name:"format-detection"}),(0,o.jsx)("meta",{content:"light",name:"color-scheme"}),(0,o.jsx)("meta",{content:"light",name:"supported-color-schemes"})]}),(0,o.jsxs)(l.Body,{style:{margin:0},children:[e?(0,o.jsx)(l.Preview,{id:"__react-email-preview",children:e}):null,(0,o.jsx)(l.Container,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:n}),this.openTrackingPixel?(0,o.jsx)(l.Img,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMarginOverrideConditions(t,n){let{parent:e,prev:i,next:r}=n||{},s=(r==null?void 0:r.type)==="spacer",a=(i==null?void 0:i.type)==="spacer",p=(e==null?void 0:e.type)==="listItem",u=(e==null?void 0:e.type)==="section"&&!r,h=(e==null?void 0:e.type)==="section"&&!i,d=(e==null?void 0:e.type)==="column"&&!r,m=(e==null?void 0:e.type)==="column"&&!i,f=(e==null?void 0:e.type)==="for"&&!i,y=(e==null?void 0:e.type)==="for"&&!r,S=(e==null?void 0:e.type)==="show"&&!i,b=(e==null?void 0:e.type)==="show"&&!r;return{isNextSpacer:s,isPrevSpacer:a,isLastSectionElement:u,isFirstSectionElement:h,isParentListItem:p,isLastColumnElement:d,isFirstColumnElement:m,isFirstForElement:f,isLastForElement:y,isFirstShowElement:S,isLastShowElement:b,shouldRemoveTopMargin:a||h||m||f||S,shouldRemoveBottomMargin:s||u||d||y||b}}getMappedContent(t,n){let e=t.content||[];return e.map((i,r)=>{let s=this.renderNode(i,x(g({},n),{next:e[r+1],prev:e[r-1]}));return s?(0,o.jsx)(A.Fragment,{children:s},M()):null}).filter(i=>i!==null)}renderNode(t,n={}){var i;let e=t.type||"";if(e in this)return(i=this[e])==null?void 0:i.call(this,t,n);throw new Error(`Node type "${e}" is not supported.`)}renderMark(t){let n=(t==null?void 0:t.text)||(0,o.jsx)(o.Fragment,{children:"\xA0"});return((t==null?void 0:t.marks)||[]).reduce((i,r)=>{var a;let s=r.type;if(s in this)return(a=this[s])==null?void 0:a.call(this,r,i);throw new Error(`Mark type "${s}" is not supported.`)},(0,o.jsx)(o.Fragment,{children:n}))}paragraph(t,n){var a,p,u,h;let{attrs:e}=t,i=(e==null?void 0:e.textAlign)||"left",{isParentListItem:r,shouldRemoveBottomMargin:s}=this.getMarginOverrideConditions(t,n);return(0,o.jsx)(l.Text,{style:g({textAlign:i,marginBottom:r||s?"0px":"20px",marginTop:"0px",fontSize:(p=(a=this.config.theme)==null?void 0:a.fontSize)==null?void 0:p.paragraph,color:(h=(u=this.config.theme)==null?void 0:u.colors)==null?void 0:h.paragraph},v),children:t.content?this.getMappedContent(t,x(g({},n),{parent:t})):(0,o.jsx)(o.Fragment,{children:"\xA0"})})}text(t,n){let e=t.text||" ";return t.marks?this.renderMark(t):(0,o.jsx)(o.Fragment,{children:e})}bold(t,n){return(0,o.jsx)("strong",{children:n})}italic(t,n){return(0,o.jsx)("em",{children:n})}underline(t,n){return(0,o.jsx)("u",{children:n})}strike(t,n){return(0,o.jsx)("s",{style:{textDecoration:"line-through"},children:n})}textStyle(t,n){var r,s;let{attrs:e}=t,{color:i=(s=(r=this.config.theme)==null?void 0:r.colors)==null?void 0:s.paragraph}=e||{};return(0,o.jsx)("span",{style:{color:i},children:n})}link(t,n){var a,p;let{attrs:e}=t,i=(e==null?void 0:e.href)||"#",r=(e==null?void 0:e.target)||"_blank",s=(e==null?void 0:e.rel)||"noopener noreferrer nofollow";return(typeof this.linkValues=="object"||typeof this.variableValues=="object")&&(i=this.linkValues.get(i)||this.variableValues.get(i)||i),(0,o.jsx)(l.Link,{href:i,rel:s,style:{fontWeight:500,textDecoration:"underline",color:(p=(a=this.config.theme)==null?void 0:a.colors)==null?void 0:p.heading},target:r,children:n})}heading(t,n){var h,d;let{attrs:e}=t,i=`h${Number(e==null?void 0:e.level)||1}`,r=(e==null?void 0:e.textAlign)||"left",{shouldRemoveBottomMargin:s}=this.getMarginOverrideConditions(t,n),{fontSize:a,lineHeight:p,fontWeight:u}=ft[i];return(0,o.jsx)(l.Heading,{as:i,style:{textAlign:r,color:(d=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:d.heading,marginBottom:s?"0":"12px",marginTop:0,fontSize:a,lineHeight:p,fontWeight:u},children:this.getMappedContent(t,x(g({},n),{parent:t}))})}variable(t,n){var p,u,h;let{payloadValue:e}=n||{},{id:i,fallback:r}=t.attrs||{};if(!this.shouldShow(t,n)||!i)return(0,o.jsx)(o.Fragment,{});let a=this.variableFormatter({variable:i,fallback:r});return this.shouldReplaceVariableValues&&(a=(h=(u=(p=typeof e=="object"?e[i]:e)!=null?p:this.variableValues.get(i))!=null?u:r)!=null?h:a),t!=null&&t.marks?this.renderMark({text:a,marks:t.marks}):(0,o.jsx)(o.Fragment,{children:a})}horizontalRule(t,n){return(0,o.jsx)(l.Hr,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(t,n){let{shouldRemoveBottomMargin:e}=this.getMarginOverrideConditions(t,n);return(0,o.jsx)(l.Container,{children:(0,o.jsx)("ol",{style:{marginTop:"0px",marginBottom:e?"0":"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(t,x(g({},n),{parent:t}))})})}bulletList(t,n){let{parent:e,next:i}=n||{},{shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(t,{parent:e,next:i});return(0,o.jsx)(l.Container,{style:{maxWidth:"100%"},children:(0,o.jsx)("ul",{style:{marginTop:"0px",marginBottom:r?"0":"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(t,x(g({},n),{parent:t}))})})}listItem(t,n){return(0,o.jsx)("li",{style:g({marginBottom:"8px",paddingLeft:"6px"},v),children:this.getMappedContent(t,x(g({},n),{parent:t}))})}button(t,n){let{attrs:e}=t,{text:i,url:r,variant:s,buttonColor:a,textColor:p,borderRadius:u,alignment:h="left"}=e||{};if(!this.shouldShow(t,n))return(0,o.jsx)(o.Fragment,{});let m="0px";u==="round"?m="9999px":u==="smooth"&&(m="6px");let{shouldRemoveBottomMargin:f}=this.getMarginOverrideConditions(t,n),y=this.linkValues.get(r)||this.variableValues.get(r)||r;return(0,o.jsx)(l.Container,{style:{textAlign:h,maxWidth:"100%",marginBottom:f?"0px":"20px"},children:(0,o.jsx)(l.Button,{href:y,style:{color:String(p),backgroundColor:s==="filled"?String(a):"transparent",borderColor:String(a),padding:s==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:m},children:i})})}spacer(t,n){let{attrs:e}=t,{height:i="auto"}=e||{};return this.shouldShow(t,n)?(0,o.jsx)(l.Container,{style:{height:mt[i]||i}}):(0,o.jsx)(o.Fragment,{})}hardBreak(t,n){return(0,o.jsx)("br",{})}logo(t,n){let{attrs:e}=t,{src:i,alt:r,title:s,size:a,alignment:p="left"}=e||{};if(!this.shouldShow(t,n))return(0,o.jsx)(o.Fragment,{});let{shouldRemoveBottomMargin:h}=this.getMarginOverrideConditions(t,n);return(0,o.jsx)(l.Row,{style:{marginTop:"0px",marginBottom:h?"0px":"32px"},children:(0,o.jsx)(l.Column,{align:p,children:(0,o.jsx)(l.Img,{alt:r||s||"Logo",src:i,style:{width:W[a]||a,height:W[a]||a},title:s||r||"Logo"})})})}image(t,n){let{attrs:e}=t,{src:i,alt:r,title:s,width:a="auto",height:p="auto",alignment:u="center",externalLink:h=""}=e||{};if(!this.shouldShow(t,n))return(0,o.jsx)(o.Fragment,{});let{shouldRemoveBottomMargin:m}=this.getMarginOverrideConditions(t,n),f=a==="auto"?"100%":`${Number(a)}px`,y=p==="auto"?"100%":`${Number(p)}px`,S=(0,o.jsx)(l.Img,{alt:r||s||"Image",src:i,style:{height:"100%",width:"100%",maxWidth:f,maxHeight:y,outline:"none",border:"none",textDecoration:"none"},title:s||r||"Image"});return(0,o.jsx)(l.Row,{style:{marginTop:"0px",marginBottom:m?"0px":"32px"},children:(0,o.jsx)(l.Column,{align:u,children:h?(0,o.jsx)("a",{href:h,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:S}):S})})}footer(t,n){var s,a,p,u,h,d,m,f;let{attrs:e}=t,{textAlign:i="left"}=e||{},{shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(t,n);return(0,o.jsx)(l.Text,{style:g({fontSize:(p=(a=(s=this.config.theme)==null?void 0:s.fontSize)==null?void 0:a.footer)==null?void 0:p.size,lineHeight:(d=(h=(u=this.config.theme)==null?void 0:u.fontSize)==null?void 0:h.footer)==null?void 0:d.lineHeight,color:(f=(m=this.config.theme)==null?void 0:m.colors)==null?void 0:f.footer,marginTop:"0px",marginBottom:r?"0px":"20px",textAlign:i},v),children:this.getMappedContent(t,x(g({},n),{parent:t}))})}blockquote(t,n){var r,s;let{isPrevSpacer:e,shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(t,n);return(0,o.jsx)("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(s=(r=this.config.theme)==null?void 0:r.colors)==null?void 0:s.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:e?"0px":"20px",marginBottom:i?"0px":"20px"},children:this.getMappedContent(t,x(g({},n),{parent:t}))})}code(t,n){var e,i,r,s;return(0,o.jsx)("code",{style:{backgroundColor:(i=(e=this.config.theme)==null?void 0:e.colors)==null?void 0:i.codeBackground,color:(s=(r=this.config.theme)==null?void 0:r.colors)==null?void 0:s.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:xt,fontWeight:400,letterSpacing:0},children:n})}linkCard(t,n){var f,y,S,b,w,O,V,k,J,D,B,F;let{attrs:e}=t,{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(t,n),{title:r,description:s,link:a,linkTitle:p,image:u,badgeText:h,subTitle:d}=e||{},m=this.linkValues.get(a)||this.variableValues.get(a)||a||"#";return(0,o.jsxs)("a",{href:m,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:i?"0px":"20px"},target:"_blank",children:[u?(0,o.jsx)(l.Row,{style:{marginBottom:"6px"},children:(0,o.jsx)(l.Column,{style:{width:"100%",height:"100%"},children:(0,o.jsx)(l.Img,{alt:r||"Link Card",src:u,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:r||"Link Card"})})}):null,(0,o.jsx)(l.Row,{style:{padding:"15px",marginTop:0,marginBottom:0},children:(0,o.jsxs)(l.Column,{style:{verticalAlign:"top"},children:[(0,o.jsxs)(l.Row,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[(0,o.jsx)(l.Column,{children:(0,o.jsx)(l.Text,{style:g({fontSize:"18px",fontWeight:600,color:(y=(f=this.config.theme)==null?void 0:f.colors)==null?void 0:y.linkCardTitle,margin:"0px"},v),children:r})}),h||d?(0,o.jsxs)(l.Column,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[h?(0,o.jsx)("span",{style:{fontWeight:600,color:(b=(S=this.config.theme)==null?void 0:S.colors)==null?void 0:b.linkCardBadgeText,padding:"4px 8px",borderRadius:"8px",backgroundColor:(O=(w=this.config.theme)==null?void 0:w.colors)==null?void 0:O.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:h}):null," ",d&&!h?(0,o.jsx)("span",{style:{fontWeight:"normal",color:(k=(V=this.config.theme)==null?void 0:V.colors)==null?void 0:k.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:d}):null]}):null]}),(0,o.jsxs)(l.Text,{style:g({fontSize:"16px",color:(D=(J=this.config.theme)==null?void 0:J.colors)==null?void 0:D.linkCardDescription,marginTop:"0px",marginBottom:"0px"},v),children:[s," ",p?(0,o.jsx)("a",{href:m,rel:"noopener noreferrer",style:{color:(F=(B=this.config.theme)==null?void 0:B.colors)==null?void 0:F.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:p}):null]})]})})]})}section(t,n){let{attrs:e}=t,{borderRadius:i=0,backgroundColor:r=j,align:s=H,borderWidth:a=G,borderColor:p=q,marginTop:u=$,marginRight:h=K,marginBottom:d=Y,marginLeft:m=Q,paddingTop:f=Z,paddingRight:y=tt,paddingBottom:S=et,paddingLeft:b=nt}=e||{};return this.shouldShow(t,n)?(0,o.jsx)(l.Row,{style:{marginTop:u,marginRight:h,marginBottom:d,marginLeft:m},children:(0,o.jsx)(l.Column,{align:s,style:{borderColor:p,borderWidth:a,borderStyle:"solid",backgroundColor:r,borderRadius:i,paddingTop:f,paddingRight:y,paddingBottom:S,paddingLeft:b},children:this.getMappedContent(t,x(g({},n),{parent:t}))})}):(0,o.jsx)(o.Fragment,{})}columns(t,n){let{attrs:e}=t;if(!this.shouldShow(t,n))return(0,o.jsx)(o.Fragment,{});let[r,s]=this.adjustColumnsContent(t);return(0,o.jsx)(l.Row,{width:`${s}%`,style:{margin:0,padding:0,width:`${s}%`},className:"tab-row-full",children:this.getMappedContent(r,x(g({},n),{parent:r}))})}adjustColumnsContent(t){var h;let{content:n=[]}=t,e=100,i=n.filter(d=>{var m;return d.type==="column"&&!!Number(((m=d.attrs)==null?void 0:m.width)||0)}),r=n.filter(d=>{var m,f;return d.type==="column"&&(((m=d.attrs)==null?void 0:m.width)==="auto"||!((f=d.attrs)!=null&&f.width))}),s=i.reduce((d,m)=>{var f;return d+Number((f=m.attrs)==null?void 0:f.width)},0),p=(e-s)/r.length,u=((h=t.attrs)==null?void 0:h.gap)||ot;return[x(g({},t),{content:n.map((d,m)=>{var b,w,O;let f=d.type==="column"&&(((b=d.attrs)==null?void 0:b.width)==="auto"||!((w=d.attrs)!=null&&w.width)),y=m===0,S=m===n.length-1;return x(g({},d),{attrs:x(g({},d.attrs),{width:f?p:(O=d.attrs)==null?void 0:O.width,isFirstColumn:y,isLastColumn:S,index:m,paddingLeft:y?0:u/2,paddingRight:S?0:u/2})})})}),r.length===0?Math.min(e,s):e]}column(t,n){let{attrs:e}=t,{width:i,verticalAlign:r="top",paddingLeft:s=0,paddingRight:a=0}=e||{};return(0,o.jsx)(l.Column,{width:`${Number(i)}%`,style:{width:`${Number(i)}%`,margin:0,verticalAlign:r},className:"tab-col-full",children:(0,o.jsx)(l.Section,{style:{margin:0,paddingLeft:s,paddingRight:a},className:"tab-pad",children:this.getMappedContent(t,x(g({},n),{parent:t}))})})}for(t,n){var p,u;let{attrs:e}=t,{each:i=""}=e||{};if(!this.shouldShow(t,n))return(0,o.jsx)(o.Fragment,{});let{payloadValue:s}=n||{};s=typeof s=="object"?s:{};let a=(u=(p=this.payloadValues.get(i))!=null?p:s[i])!=null?u:[];if(!Array.isArray(a))throw new Error(`Payload value for each "${i}" is not an array`);return(0,o.jsx)(o.Fragment,{children:a.map(h=>(0,o.jsx)(A.Fragment,{children:this.getMappedContent(t,x(g({},n),{parent:t,payloadValue:h}))},M()))})}shouldShow(t,n){var r,s,a;let e=(s=(r=t==null?void 0:t.attrs)==null?void 0:r.showIfKey)!=null?s:"";if(!e)return!0;let{payloadValue:i}=n||{};return i=typeof i=="object"?i:{},!!((a=this.payloadValues.get(e))!=null?a:i[e])}};function Tt(c,t){return C(this,null,function*(){let s=t||{},{theme:n,preview:e}=s,i=U(s,["theme","preview"]),r=new N(c);return r.setPreviewText(e),r.setTheme(n||{}),r.setPayloadValue("items",[{name:"John Doe"},{name:"Novu"}]),r.setPayloadValue("shouldShow",!0),r.render(i)})}0&&(module.exports={DEFAULT_COLUMNS_GAP,DEFAULT_COLUMNS_WIDTH,DEFAULT_COLUMN_BACKGROUND_COLOR,DEFAULT_COLUMN_BORDER_COLOR,DEFAULT_COLUMN_BORDER_RADIUS,DEFAULT_COLUMN_BORDER_WIDTH,DEFAULT_COLUMN_PADDING_BOTTOM,DEFAULT_COLUMN_PADDING_LEFT,DEFAULT_COLUMN_PADDING_RIGHT,DEFAULT_COLUMN_PADDING_TOP,DEFAULT_SECTION_ALIGN,DEFAULT_SECTION_BACKGROUND_COLOR,DEFAULT_SECTION_BORDER_COLOR,DEFAULT_SECTION_BORDER_WIDTH,DEFAULT_SECTION_MARGIN_BOTTOM,DEFAULT_SECTION_MARGIN_LEFT,DEFAULT_SECTION_MARGIN_RIGHT,DEFAULT_SECTION_MARGIN_TOP,DEFAULT_SECTION_PADDING_BOTTOM,DEFAULT_SECTION_PADDING_LEFT,DEFAULT_SECTION_PADDING_RIGHT,DEFAULT_SECTION_PADDING_TOP,Maily,render});
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
|
|
3
|
-
var G=Object.defineProperty,Q=Object.defineProperties;var Z=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var H=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var j=(l,e,n)=>e in l?G(l,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[e]=n,g=(l,e)=>{for(var n in e||(e={}))H.call(e,n)&&j(l,n,e[n]);if(N)for(var n of N(e))q.call(e,n)&&j(l,n,e[n]);return l},C=(l,e)=>Q(l,Z(e));var U=(l,e)=>{var n={};for(var t in l)H.call(l,t)&&e.indexOf(t)<0&&(n[t]=l[t]);if(l!=null&&N)for(var t of N(l))e.indexOf(t)<0&&q.call(l,t)&&(n[t]=l[t]);return n};var O=(l,e,n)=>new Promise((t,r)=>{var i=c=>{try{a(n.next(c))}catch(p){r(p)}},s=c=>{try{a(n.throw(c))}catch(p){r(p)}},a=c=>c.done?t(c.value):Promise.resolve(c.value).then(i,s);a((n=n.apply(l,e)).next())});import{Fragment as $}from"react";import{Text as k,Html as ie,Head as re,Body as oe,Font as se,Container as y,Link as ae,Heading as le,Hr as ce,Button as pe,Img as J,Preview as ue,Row as v,Column as b}from"@react-email/components";import{renderAsync as me}from"@react-email/render";var ee=l=>Object.prototype.toString.call(l);var te=l=>ee(l)==="[object Object]";function ne(l){return Object.keys(l)}function L(l,...e){if(!e.length)return l;let n=e.shift();return n===void 0?l:(T(l)&&T(n)&&ne(n).forEach(t=>{t==="__proto__"||t==="constructor"||t==="prototype"||(T(n[t])?(l[t]||(l[t]={}),T(l[t])?L(l[t],n[t]):l[t]=n[t]):l[t]=n[t])}),L(l,...e))}function T(l){return te(l)&&!Array.isArray(l)}var Ne=Symbol("p-void");function A(){return Math.random().toString(36).substr(2,6)}import{Fragment as E,jsx as o,jsxs as x}from"react/jsx-runtime";var de={sm:"8px",md:"16px",lg:"32px",xl:"64px"},w={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var fe={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var K={sm:"40px",md:"48px",lg:"64px"},ge={pretty:!1,plainText:!1},Y={colors:{heading:"#111827",paragraph:"#374151",horizontal:"#EAEAEA",footer:"#64748B",blockquoteBorder:"#D1D5DB",codeBackground:"#EFEFEF",codeText:"#111827",linkCardTitle:"#111827",linkCardDescription:"#6B7280",linkCardBadgeText:"#111827",linkCardBadgeBackground:"#FEF08A",linkCardSubTitle:"#6B7280"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}},he='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',xe="#ffffff",Se="100%",ye="left",M=class{constructor(e={type:"doc",content:[]}){this.config={theme:Y};this.variableFormatter=({variable:e,fallback:n})=>n?`{{${e},fallback=${n}}}`:`{{${e}}}`;this.shouldReplaceVariableValues=!1;this.variableValues=new Map;this.linkValues=new Map;this.content=e}setPreviewText(e){this.config.preview=e}setTheme(e){this.config.theme=L(this.config.theme||Y,e)}setVariableFormatter(e){this.variableFormatter=e}setVariableValue(e,n){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(e,n)}setVariableValues(e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(e).forEach(([n,t])=>{this.setVariableValue(n,t)})}setLinkValue(e,n){this.linkValues.set(e,n)}setLinkValues(e){Object.entries(e).forEach(([n,t])=>{this.setLinkValue(n,t)})}setOpenTrackingPixel(e){this.openTrackingPixel=e}setShouldReplaceVariableValues(e){this.shouldReplaceVariableValues=e}getAllLinks(){let e=this.content.content||[],n=new Set,t=i=>i&&this.isValidUrl(i)&&!i.startsWith("#")&&!i.startsWith("mailto:")&&!i.startsWith("tel:")&&typeof i=="string",r=i=>{var s;if(i.type==="button"){let a=(s=i.attrs)==null?void 0:s.url;t(a)&&a&&n.add(a)}else i.content&&i.content.forEach(a=>{a.marks&&a.marks.forEach(c=>{var u;let p=(u=c.attrs)==null?void 0:u.href;c.type==="link"&&t(p)&&n.add(p)}),a.content&&r(a)})};return e.forEach(i=>{r(i)}),n}isValidUrl(e){try{let n=new URL(e);return!0}catch(n){return!1}}render(){return O(this,arguments,function*(e=ge){let n=this.markup();return me(n,e)})}markup(){let e=this.content.content||[],n=e.map((i,s)=>{let a={prev:e[s-1],next:e[s+1],parent:i},c=this.renderNode(i,a);return c?o($,{children:c},A()):null}),{preview:t}=this.config;return x(ie,{children:[x(re,{children:[o(se,{fallbackFontFamily:"sans-serif",fontFamily:"Inter",fontStyle:"normal",fontWeight:400,webFont:{url:"https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19",format:"woff2"}}),o("style",{dangerouslySetInnerHTML:{__html:"blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}"}}),o("meta",{content:"width=device-width",name:"viewport"}),o("meta",{content:"IE=edge",httpEquiv:"X-UA-Compatible"}),o("meta",{name:"x-apple-disable-message-reformatting"}),o("meta",{content:"telephone=no,address=no,email=no,date=no,url=no",name:"format-detection"}),o("meta",{content:"light",name:"color-scheme"}),o("meta",{content:"light",name:"supported-color-schemes"})]}),x(oe,{style:{margin:0},children:[t?o(ue,{id:"__react-email-preview",children:t}):null,o(y,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:n}),this.openTrackingPixel?o(J,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMarginOverrideConditions(e,n){let{parent:t,prev:r,next:i}=n||{},s=(i==null?void 0:i.type)==="spacer",a=(r==null?void 0:r.type)==="spacer",c=(t==null?void 0:t.type)==="listItem",p=(t==null?void 0:t.type)==="section"&&!i,u=(t==null?void 0:t.type)==="section"&&!r,m=(t==null?void 0:t.type)==="column"&&!i,d=(t==null?void 0:t.type)==="column"&&!r;return{isNextSpacer:s,isPrevSpacer:a,isLastSectionElement:p,isFirstSectionElement:u,isParentListItem:c,isLastColumnElement:m,isFirstColumnElement:d}}getMappedContent(e,n){let t=e.content||[];return t.map((r,i)=>{let s=this.renderNode(r,C(g({},n),{next:t[i+1],prev:t[i-1]}));return s?o($,{children:s},A()):null}).filter(r=>r!==null)}renderNode(e,n={}){var r;let t=e.type||"";if(t in this)return(r=this[t])==null?void 0:r.call(this,e,n);throw new Error(`Node type "${t}" is not supported.`)}renderMark(e){let n=e.text||o(E,{children:"\xA0"});return(e.marks||[]).reduce((r,i)=>{var a;let s=i.type;if(s in this)return(a=this[s])==null?void 0:a.call(this,i,r);throw new Error(`Mark type "${s}" is not supported.`)},o(E,{children:n}))}paragraph(e,n){var p,u,m,d;let{attrs:t}=e,r=(t==null?void 0:t.textAlign)||"left",{isNextSpacer:i,isLastSectionElement:s,isParentListItem:a,isLastColumnElement:c}=this.getMarginOverrideConditions(e,n);return o(k,{style:g({textAlign:r,marginBottom:a||i||s||c?"0px":"20px",marginTop:"0px",fontSize:(u=(p=this.config.theme)==null?void 0:p.fontSize)==null?void 0:u.paragraph,color:(d=(m=this.config.theme)==null?void 0:m.colors)==null?void 0:d.paragraph},w),children:e.content?this.getMappedContent(e):o(E,{children:"\xA0"})})}text(e,n){let t=e.text||" ";return e.marks?this.renderMark(e):o(E,{children:t})}bold(e,n){return o("strong",{children:n})}italic(e,n){return o("em",{children:n})}underline(e,n){return o("u",{children:n})}strike(e,n){return o("s",{style:{textDecoration:"line-through"},children:n})}textStyle(e,n){var i,s;let{attrs:t}=e,{color:r=(s=(i=this.config.theme)==null?void 0:i.colors)==null?void 0:s.paragraph}=t||{};return o("span",{style:{color:r},children:n})}link(e,n){var a,c;let{attrs:t}=e,r=(t==null?void 0:t.href)||"#",i=(t==null?void 0:t.target)||"_blank",s=(t==null?void 0:t.rel)||"noopener noreferrer nofollow";return(typeof this.linkValues=="object"||typeof this.variableValues=="object")&&(r=this.linkValues.get(r)||this.variableValues.get(r)||r),o(ae,{href:r,rel:s,style:{fontWeight:500,textDecoration:"underline",color:(c=(a=this.config.theme)==null?void 0:a.colors)==null?void 0:c.heading},target:i,children:n})}heading(e,n){var d,f;let{attrs:t}=e,r=`h${Number(t==null?void 0:t.level)||1}`,i=(t==null?void 0:t.textAlign)||"left",{isNextSpacer:s,isLastSectionElement:a,isLastColumnElement:c}=this.getMarginOverrideConditions(e,n),{fontSize:p,lineHeight:u,fontWeight:m}=fe[r];return o(le,{as:r,style:{textAlign:i,color:(f=(d=this.config.theme)==null?void 0:d.colors)==null?void 0:f.heading,marginBottom:s||a||c?"0":"12px",marginTop:0,fontSize:p,lineHeight:u,fontWeight:m},children:this.getMappedContent(e,n)})}variable(e,n){let{id:t,fallback:r}=e.attrs||{},i=this.variableFormatter({variable:t,fallback:r});return this.shouldReplaceVariableValues&&(i=this.variableValues.get(t)||r||i),o(E,{children:i})}horizontalRule(e,n){return o(ce,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(e,n){let{isNextSpacer:t,isLastSectionElement:r,isLastColumnElement:i}=this.getMarginOverrideConditions(e,n);return o(y,{children:o("ol",{style:{marginTop:"0px",marginBottom:t||r||i?"0":"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(e)})})}bulletList(e,n){let{parent:t,next:r}=n||{},{isLastSectionElement:i,isNextSpacer:s,isLastColumnElement:a}=this.getMarginOverrideConditions(e,{parent:t,next:r});return o(y,{style:{maxWidth:"100%"},children:o("ul",{style:{marginTop:"0px",marginBottom:i||s||a?"0":"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(e)})})}listItem(e,n){return o(y,{style:{maxWidth:"100%"},children:o("li",{style:g({marginBottom:"8px",paddingLeft:"6px"},w),children:this.getMappedContent(e,C(g({},n),{parent:e}))})})}button(e,n){let{attrs:t}=e,{text:r,url:i,variant:s,buttonColor:a,textColor:c,borderRadius:p,alignment:u="left"}=t||{},m="0px";p==="round"?m="9999px":p==="smooth"&&(m="6px");let{isNextSpacer:d,isLastSectionElement:f,isLastColumnElement:h}=this.getMarginOverrideConditions(e,n),S=this.linkValues.get(i)||this.variableValues.get(i)||i;return o(y,{style:{textAlign:u,maxWidth:"100%",marginBottom:d||f||h?"0px":"20px"},children:o(pe,{href:S,style:{color:String(c),backgroundColor:s==="filled"?String(a):"transparent",borderColor:String(a),padding:s==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:m},children:r})})}spacer(e,n){let{attrs:t}=e,{height:r="auto"}=t||{};return o(y,{style:{height:de[r]||r}})}hardBreak(e,n){return o("br",{})}logo(e,n){let{attrs:t}=e,{src:r,alt:i,title:s,size:a,alignment:c="left"}=t||{},{isNextSpacer:p,isLastSectionElement:u,isLastColumnElement:m}=this.getMarginOverrideConditions(e,n);return o(v,{style:{marginTop:"0px",marginBottom:p||u||m?"0px":"32px"},children:o(b,{align:c,children:o(J,{alt:i||s||"Logo",src:r,style:{width:K[a]||a,height:K[a]||a},title:s||i||"Logo"})})})}image(e,n){let{attrs:t}=e,{src:r,alt:i,title:s,width:a="auto",height:c="auto",alignment:p="center",externalLink:u=""}=t||{},{isNextSpacer:m,isLastSectionElement:d,isLastColumnElement:f}=this.getMarginOverrideConditions(e,n),h=o(J,{alt:i||s||"Image",src:r,style:{height:"100%",width:"100%",maxWidth:a,maxHeight:c,outline:"none",border:"none",textDecoration:"none"},title:s||i||"Image"});return o(v,{style:{marginTop:"0px",marginBottom:m||d||f?"0px":"32px"},children:o(b,{align:p,children:u?o("a",{href:u,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:h}):h})})}footer(e,n){var c,p,u,m,d,f,h,S;let{attrs:t}=e,{textAlign:r="left"}=t||{},{isNextSpacer:i,isLastSectionElement:s,isLastColumnElement:a}=this.getMarginOverrideConditions(e,n);return o(k,{style:g({fontSize:(u=(p=(c=this.config.theme)==null?void 0:c.fontSize)==null?void 0:p.footer)==null?void 0:u.size,lineHeight:(f=(d=(m=this.config.theme)==null?void 0:m.fontSize)==null?void 0:d.footer)==null?void 0:f.lineHeight,color:(S=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:S.footer,marginTop:"0px",marginBottom:i||s||a?"0px":"20px",textAlign:r},w),children:this.getMappedContent(e)})}blockquote(e,n){var a,c;let{isNextSpacer:t,isPrevSpacer:r,isLastSectionElement:i,isLastColumnElement:s}=this.getMarginOverrideConditions(e,n);return o("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(c=(a=this.config.theme)==null?void 0:a.colors)==null?void 0:c.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:r?"0px":"20px",marginBottom:t||i||s?"0px":"20px"},children:this.getMappedContent(e)})}code(e,n){var t,r,i,s;return o("code",{style:{backgroundColor:(r=(t=this.config.theme)==null?void 0:t.colors)==null?void 0:r.codeBackground,color:(s=(i=this.config.theme)==null?void 0:i.colors)==null?void 0:s.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:he,fontWeight:400,letterSpacing:0},children:n})}linkCard(e,n){var S,V,_,B,R,P,X,F,z,I,W,D;let{attrs:t}=e,{isNextSpacer:r,isLastSectionElement:i,isLastColumnElement:s}=this.getMarginOverrideConditions(e,n),{title:a,description:c,link:p,linkTitle:u,image:m,badgeText:d,subTitle:f}=t||{},h=this.linkValues.get(p)||this.variableValues.get(p)||p||"#";return x("a",{href:h,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:r||i||s?"0px":"20px"},target:"_blank",children:[m?o(v,{style:{marginBottom:"6px"},children:o(b,{style:{width:"100%",height:"100%"},children:o(J,{alt:a||"Link Card",src:m,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:a||"Link Card"})})}):null,o(v,{style:{padding:"15px",marginTop:0,marginBottom:0},children:x(b,{style:{verticalAlign:"top"},children:[x(v,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[o(b,{children:o(k,{style:g({fontSize:"18px",fontWeight:600,color:(V=(S=this.config.theme)==null?void 0:S.colors)==null?void 0:V.linkCardTitle,margin:"0px"},w),children:a})}),d||f?x(b,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[d?o("span",{style:{fontWeight:600,color:(B=(_=this.config.theme)==null?void 0:_.colors)==null?void 0:B.linkCardBadgeText,padding:"4px 8px",borderRadius:"8px",backgroundColor:(P=(R=this.config.theme)==null?void 0:R.colors)==null?void 0:P.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:d}):null," ",f&&!d?o("span",{style:{fontWeight:"normal",color:(F=(X=this.config.theme)==null?void 0:X.colors)==null?void 0:F.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:f}):null]}):null]}),x(k,{style:g({fontSize:"16px",color:(I=(z=this.config.theme)==null?void 0:z.colors)==null?void 0:I.linkCardDescription,marginTop:"0px",marginBottom:"0px"},w),children:[c," ",u?o("a",{href:h,rel:"noopener noreferrer",style:{color:(D=(W=this.config.theme)==null?void 0:W.colors)==null?void 0:D.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:u}):null]})]})})]})}section(e,n){let{attrs:t}=e,{borderRadius:r=0,padding:i=0,backgroundColor:s=xe}=t||{};return o(y,{style:{backgroundColor:s,borderRadius:r,padding:i},children:this.getMappedContent(e,C(g({},n),{parent:e}))})}columns(e,n){let{attrs:t}=e,{width:r=Se,align:i=ye}=t||{};return o(v,{width:r,align:i,style:{margin:0,padding:0,width:r},children:this.getMappedContent(e,C(g({},n),{parent:e}))})}column(e,n){let{attrs:t}=e,{width:r="50%",verticalAlign:i="top"}=t||{};return o(b,{style:{width:r,verticalAlign:i,margin:0,padding:0},children:this.getMappedContent(e,C(g({},n),{parent:e}))})}};function Fe(l,e){return O(this,null,function*(){let s=e||{},{theme:n,preview:t}=s,r=U(s,["theme","preview"]),i=new M(l);return i.setPreviewText(t),i.setTheme(n||{}),i.render(r)})}export{ye as DEFAULT_COLUMNS_ALIGN,Se as DEFAULT_COLUMNS_WIDTH,M as Maily,Fe as render};
|
|
3
|
+
var $=Object.defineProperty,K=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var X=(c,t,n)=>t in c?$(c,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):c[t]=n,f=(c,t)=>{for(var n in t||(t={}))z.call(t,n)&&X(c,n,t[n]);if(L)for(var n of L(t))j.call(t,n)&&X(c,n,t[n]);return c},g=(c,t)=>K(c,Y(t));var H=(c,t)=>{var n={};for(var e in c)z.call(c,e)&&t.indexOf(e)<0&&(n[e]=c[e]);if(c!=null&&L)for(var e of L(c))t.indexOf(e)<0&&j.call(c,e)&&(n[e]=c[e]);return n};var E=(c,t,n)=>new Promise((e,r)=>{var o=l=>{try{a(n.next(l))}catch(p){r(p)}},s=l=>{try{a(n.throw(l))}catch(p){r(p)}},a=l=>l.done?e(l.value):Promise.resolve(l.value).then(o,s);a((n=n.apply(c,t)).next())});import{Fragment as D}from"react";import{Text as V,Html as et,Head as nt,Body as ot,Font as rt,Container as T,Link as it,Heading as st,Hr as at,Button as lt,Img as k,Preview as ct,Row as C,Column as w,Section as pt}from"@react-email/components";import{renderAsync as ut}from"@react-email/render";var Q=c=>Object.prototype.toString.call(c);var Z=c=>Q(c)==="[object Object]";function tt(c){return Object.keys(c)}function A(c,...t){if(!t.length)return c;let n=t.shift();return n===void 0?c:(M(c)&&M(n)&&tt(n).forEach(e=>{e==="__proto__"||e==="constructor"||e==="prototype"||(M(n[e])?(c[e]||(c[e]={}),M(c[e])?A(c[e],n[e]):c[e]=n[e]):c[e]=n[e])}),A(c,...t))}function M(c){return Z(c)&&!Array.isArray(c)}var Jt=Symbol("p-void");function R(){return Math.random().toString(36).substr(2,6)}import{Fragment as y,jsx as i,jsxs as O}from"react/jsx-runtime";var ht={sm:"8px",md:"16px",lg:"32px",xl:"64px"},_={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var dt={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var G={sm:"40px",md:"48px",lg:"64px"},mt={pretty:!1,plainText:!1},q={colors:{heading:"#111827",paragraph:"#374151",horizontal:"#EAEAEA",footer:"#64748B",blockquoteBorder:"#D1D5DB",codeBackground:"#EFEFEF",codeText:"#111827",linkCardTitle:"#111827",linkCardDescription:"#6B7280",linkCardBadgeText:"#111827",linkCardBadgeBackground:"#FEF08A",linkCardSubTitle:"#6B7280"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}},ft='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',gt="#ffffff",xt="left",yt=1,St="#000000",bt=0,wt=0,Ot=0,Ct=0,vt=5,Nt=5,Et=5,Tt=5,zt="100%",_t=8,jt="transparent",Ht=0,Gt=0,qt="transparent",$t=0,Kt=0,Yt=0,Qt=0,J=class{constructor(t={type:"doc",content:[]}){this.config={theme:q};this.variableFormatter=({variable:t,fallback:n})=>n?`{{${t},fallback=${n}}}`:`{{${t}}}`;this.shouldReplaceVariableValues=!1;this.variableValues=new Map;this.linkValues=new Map;this.payloadValues=new Map;this.content=t}setPreviewText(t){this.config.preview=t}setTheme(t){this.config.theme=A(this.config.theme||q,t)}setVariableFormatter(t){this.variableFormatter=t}setVariableValue(t,n){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(t,n)}setVariableValues(t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(t).forEach(([n,e])=>{this.setVariableValue(n,e)})}setLinkValue(t,n){this.linkValues.set(t,n)}setLinkValues(t){Object.entries(t).forEach(([n,e])=>{this.setLinkValue(n,e)})}setPayloadValue(t,n){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.payloadValues.set(t,n)}setPayloadValues(t){Object.entries(t).forEach(([n,e])=>{this.setPayloadValue(n,e)})}setOpenTrackingPixel(t){this.openTrackingPixel=t}setShouldReplaceVariableValues(t){this.shouldReplaceVariableValues=t}getAllLinks(){let t=this.content.content||[],n=new Set,e=o=>o&&this.isValidUrl(o)&&!o.startsWith("#")&&!o.startsWith("mailto:")&&!o.startsWith("tel:")&&typeof o=="string",r=o=>{var s;if(o.type==="button"){let a=(s=o.attrs)==null?void 0:s.url;e(a)&&a&&n.add(a)}else o.content&&o.content.forEach(a=>{a.marks&&a.marks.forEach(l=>{var u;let p=(u=l.attrs)==null?void 0:u.href;l.type==="link"&&e(p)&&n.add(p)}),a.content&&r(a)})};return t.forEach(o=>{r(o)}),n}isValidUrl(t){try{let n=new URL(t);return!0}catch(n){return!1}}render(){return E(this,arguments,function*(t=mt){let n=this.markup();return ut(n,t)})}markup(){let t=this.content.content||[],n=t.map((o,s)=>{let a={prev:t[s-1],next:t[s+1],parent:o},l=this.renderNode(o,a);return l?i(D,{children:l},R()):null}),{preview:e}=this.config;return O(et,{children:[O(nt,{children:[i(rt,{fallbackFontFamily:"sans-serif",fontFamily:"Inter",fontStyle:"normal",fontWeight:400,webFont:{url:"https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19",format:"woff2"}}),i("style",{dangerouslySetInnerHTML:{__html:"blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}@media only screen and (max-width:425px){.tab-row-full{width:100%!important}.tab-col-full{display:block!important;width:100%!important}.tab-pad{padding:0!important}}"}}),i("meta",{content:"width=device-width",name:"viewport"}),i("meta",{content:"IE=edge",httpEquiv:"X-UA-Compatible"}),i("meta",{name:"x-apple-disable-message-reformatting"}),i("meta",{content:"telephone=no,address=no,email=no,date=no,url=no",name:"format-detection"}),i("meta",{content:"light",name:"color-scheme"}),i("meta",{content:"light",name:"supported-color-schemes"})]}),O(ot,{style:{margin:0},children:[e?i(ct,{id:"__react-email-preview",children:e}):null,i(T,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:n}),this.openTrackingPixel?i(k,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMarginOverrideConditions(t,n){let{parent:e,prev:r,next:o}=n||{},s=(o==null?void 0:o.type)==="spacer",a=(r==null?void 0:r.type)==="spacer",l=(e==null?void 0:e.type)==="listItem",p=(e==null?void 0:e.type)==="section"&&!o,u=(e==null?void 0:e.type)==="section"&&!r,h=(e==null?void 0:e.type)==="column"&&!o,d=(e==null?void 0:e.type)==="column"&&!r,m=(e==null?void 0:e.type)==="for"&&!r,x=(e==null?void 0:e.type)==="for"&&!o,S=(e==null?void 0:e.type)==="show"&&!r,b=(e==null?void 0:e.type)==="show"&&!o;return{isNextSpacer:s,isPrevSpacer:a,isLastSectionElement:p,isFirstSectionElement:u,isParentListItem:l,isLastColumnElement:h,isFirstColumnElement:d,isFirstForElement:m,isLastForElement:x,isFirstShowElement:S,isLastShowElement:b,shouldRemoveTopMargin:a||u||d||m||S,shouldRemoveBottomMargin:s||p||h||x||b}}getMappedContent(t,n){let e=t.content||[];return e.map((r,o)=>{let s=this.renderNode(r,g(f({},n),{next:e[o+1],prev:e[o-1]}));return s?i(D,{children:s},R()):null}).filter(r=>r!==null)}renderNode(t,n={}){var r;let e=t.type||"";if(e in this)return(r=this[e])==null?void 0:r.call(this,t,n);throw new Error(`Node type "${e}" is not supported.`)}renderMark(t){let n=(t==null?void 0:t.text)||i(y,{children:"\xA0"});return((t==null?void 0:t.marks)||[]).reduce((r,o)=>{var a;let s=o.type;if(s in this)return(a=this[s])==null?void 0:a.call(this,o,r);throw new Error(`Mark type "${s}" is not supported.`)},i(y,{children:n}))}paragraph(t,n){var a,l,p,u;let{attrs:e}=t,r=(e==null?void 0:e.textAlign)||"left",{isParentListItem:o,shouldRemoveBottomMargin:s}=this.getMarginOverrideConditions(t,n);return i(V,{style:f({textAlign:r,marginBottom:o||s?"0px":"20px",marginTop:"0px",fontSize:(l=(a=this.config.theme)==null?void 0:a.fontSize)==null?void 0:l.paragraph,color:(u=(p=this.config.theme)==null?void 0:p.colors)==null?void 0:u.paragraph},_),children:t.content?this.getMappedContent(t,g(f({},n),{parent:t})):i(y,{children:"\xA0"})})}text(t,n){let e=t.text||" ";return t.marks?this.renderMark(t):i(y,{children:e})}bold(t,n){return i("strong",{children:n})}italic(t,n){return i("em",{children:n})}underline(t,n){return i("u",{children:n})}strike(t,n){return i("s",{style:{textDecoration:"line-through"},children:n})}textStyle(t,n){var o,s;let{attrs:e}=t,{color:r=(s=(o=this.config.theme)==null?void 0:o.colors)==null?void 0:s.paragraph}=e||{};return i("span",{style:{color:r},children:n})}link(t,n){var a,l;let{attrs:e}=t,r=(e==null?void 0:e.href)||"#",o=(e==null?void 0:e.target)||"_blank",s=(e==null?void 0:e.rel)||"noopener noreferrer nofollow";return(typeof this.linkValues=="object"||typeof this.variableValues=="object")&&(r=this.linkValues.get(r)||this.variableValues.get(r)||r),i(it,{href:r,rel:s,style:{fontWeight:500,textDecoration:"underline",color:(l=(a=this.config.theme)==null?void 0:a.colors)==null?void 0:l.heading},target:o,children:n})}heading(t,n){var u,h;let{attrs:e}=t,r=`h${Number(e==null?void 0:e.level)||1}`,o=(e==null?void 0:e.textAlign)||"left",{shouldRemoveBottomMargin:s}=this.getMarginOverrideConditions(t,n),{fontSize:a,lineHeight:l,fontWeight:p}=dt[r];return i(st,{as:r,style:{textAlign:o,color:(h=(u=this.config.theme)==null?void 0:u.colors)==null?void 0:h.heading,marginBottom:s?"0":"12px",marginTop:0,fontSize:a,lineHeight:l,fontWeight:p},children:this.getMappedContent(t,g(f({},n),{parent:t}))})}variable(t,n){var l,p,u;let{payloadValue:e}=n||{},{id:r,fallback:o}=t.attrs||{};if(!this.shouldShow(t,n)||!r)return i(y,{});let a=this.variableFormatter({variable:r,fallback:o});return this.shouldReplaceVariableValues&&(a=(u=(p=(l=typeof e=="object"?e[r]:e)!=null?l:this.variableValues.get(r))!=null?p:o)!=null?u:a),t!=null&&t.marks?this.renderMark({text:a,marks:t.marks}):i(y,{children:a})}horizontalRule(t,n){return i(at,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(t,n){let{shouldRemoveBottomMargin:e}=this.getMarginOverrideConditions(t,n);return i(T,{children:i("ol",{style:{marginTop:"0px",marginBottom:e?"0":"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(t,g(f({},n),{parent:t}))})})}bulletList(t,n){let{parent:e,next:r}=n||{},{shouldRemoveBottomMargin:o}=this.getMarginOverrideConditions(t,{parent:e,next:r});return i(T,{style:{maxWidth:"100%"},children:i("ul",{style:{marginTop:"0px",marginBottom:o?"0":"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(t,g(f({},n),{parent:t}))})})}listItem(t,n){return i("li",{style:f({marginBottom:"8px",paddingLeft:"6px"},_),children:this.getMappedContent(t,g(f({},n),{parent:t}))})}button(t,n){let{attrs:e}=t,{text:r,url:o,variant:s,buttonColor:a,textColor:l,borderRadius:p,alignment:u="left"}=e||{};if(!this.shouldShow(t,n))return i(y,{});let d="0px";p==="round"?d="9999px":p==="smooth"&&(d="6px");let{shouldRemoveBottomMargin:m}=this.getMarginOverrideConditions(t,n),x=this.linkValues.get(o)||this.variableValues.get(o)||o;return i(T,{style:{textAlign:u,maxWidth:"100%",marginBottom:m?"0px":"20px"},children:i(lt,{href:x,style:{color:String(l),backgroundColor:s==="filled"?String(a):"transparent",borderColor:String(a),padding:s==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:d},children:r})})}spacer(t,n){let{attrs:e}=t,{height:r="auto"}=e||{};return this.shouldShow(t,n)?i(T,{style:{height:ht[r]||r}}):i(y,{})}hardBreak(t,n){return i("br",{})}logo(t,n){let{attrs:e}=t,{src:r,alt:o,title:s,size:a,alignment:l="left"}=e||{};if(!this.shouldShow(t,n))return i(y,{});let{shouldRemoveBottomMargin:u}=this.getMarginOverrideConditions(t,n);return i(C,{style:{marginTop:"0px",marginBottom:u?"0px":"32px"},children:i(w,{align:l,children:i(k,{alt:o||s||"Logo",src:r,style:{width:G[a]||a,height:G[a]||a},title:s||o||"Logo"})})})}image(t,n){let{attrs:e}=t,{src:r,alt:o,title:s,width:a="auto",height:l="auto",alignment:p="center",externalLink:u=""}=e||{};if(!this.shouldShow(t,n))return i(y,{});let{shouldRemoveBottomMargin:d}=this.getMarginOverrideConditions(t,n),m=a==="auto"?"100%":`${Number(a)}px`,x=l==="auto"?"100%":`${Number(l)}px`,S=i(k,{alt:o||s||"Image",src:r,style:{height:"100%",width:"100%",maxWidth:m,maxHeight:x,outline:"none",border:"none",textDecoration:"none"},title:s||o||"Image"});return i(C,{style:{marginTop:"0px",marginBottom:d?"0px":"32px"},children:i(w,{align:p,children:u?i("a",{href:u,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:S}):S})})}footer(t,n){var s,a,l,p,u,h,d,m;let{attrs:e}=t,{textAlign:r="left"}=e||{},{shouldRemoveBottomMargin:o}=this.getMarginOverrideConditions(t,n);return i(V,{style:f({fontSize:(l=(a=(s=this.config.theme)==null?void 0:s.fontSize)==null?void 0:a.footer)==null?void 0:l.size,lineHeight:(h=(u=(p=this.config.theme)==null?void 0:p.fontSize)==null?void 0:u.footer)==null?void 0:h.lineHeight,color:(m=(d=this.config.theme)==null?void 0:d.colors)==null?void 0:m.footer,marginTop:"0px",marginBottom:o?"0px":"20px",textAlign:r},_),children:this.getMappedContent(t,g(f({},n),{parent:t}))})}blockquote(t,n){var o,s;let{isPrevSpacer:e,shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(t,n);return i("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(s=(o=this.config.theme)==null?void 0:o.colors)==null?void 0:s.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:e?"0px":"20px",marginBottom:r?"0px":"20px"},children:this.getMappedContent(t,g(f({},n),{parent:t}))})}code(t,n){var e,r,o,s;return i("code",{style:{backgroundColor:(r=(e=this.config.theme)==null?void 0:e.colors)==null?void 0:r.codeBackground,color:(s=(o=this.config.theme)==null?void 0:o.colors)==null?void 0:s.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:ft,fontWeight:400,letterSpacing:0},children:n})}linkCard(t,n){var m,x,S,b,v,N,B,F,P,I,U,W;let{attrs:e}=t,{shouldRemoveBottomMargin:r}=this.getMarginOverrideConditions(t,n),{title:o,description:s,link:a,linkTitle:l,image:p,badgeText:u,subTitle:h}=e||{},d=this.linkValues.get(a)||this.variableValues.get(a)||a||"#";return O("a",{href:d,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:r?"0px":"20px"},target:"_blank",children:[p?i(C,{style:{marginBottom:"6px"},children:i(w,{style:{width:"100%",height:"100%"},children:i(k,{alt:o||"Link Card",src:p,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:o||"Link Card"})})}):null,i(C,{style:{padding:"15px",marginTop:0,marginBottom:0},children:O(w,{style:{verticalAlign:"top"},children:[O(C,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[i(w,{children:i(V,{style:f({fontSize:"18px",fontWeight:600,color:(x=(m=this.config.theme)==null?void 0:m.colors)==null?void 0:x.linkCardTitle,margin:"0px"},_),children:o})}),u||h?O(w,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[u?i("span",{style:{fontWeight:600,color:(b=(S=this.config.theme)==null?void 0:S.colors)==null?void 0:b.linkCardBadgeText,padding:"4px 8px",borderRadius:"8px",backgroundColor:(N=(v=this.config.theme)==null?void 0:v.colors)==null?void 0:N.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:u}):null," ",h&&!u?i("span",{style:{fontWeight:"normal",color:(F=(B=this.config.theme)==null?void 0:B.colors)==null?void 0:F.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:h}):null]}):null]}),O(V,{style:f({fontSize:"16px",color:(I=(P=this.config.theme)==null?void 0:P.colors)==null?void 0:I.linkCardDescription,marginTop:"0px",marginBottom:"0px"},_),children:[s," ",l?i("a",{href:d,rel:"noopener noreferrer",style:{color:(W=(U=this.config.theme)==null?void 0:U.colors)==null?void 0:W.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:l}):null]})]})})]})}section(t,n){let{attrs:e}=t,{borderRadius:r=0,backgroundColor:o=gt,align:s=xt,borderWidth:a=yt,borderColor:l=St,marginTop:p=bt,marginRight:u=wt,marginBottom:h=Ot,marginLeft:d=Ct,paddingTop:m=vt,paddingRight:x=Nt,paddingBottom:S=Et,paddingLeft:b=Tt}=e||{};return this.shouldShow(t,n)?i(C,{style:{marginTop:p,marginRight:u,marginBottom:h,marginLeft:d},children:i(w,{align:s,style:{borderColor:l,borderWidth:a,borderStyle:"solid",backgroundColor:o,borderRadius:r,paddingTop:m,paddingRight:x,paddingBottom:S,paddingLeft:b},children:this.getMappedContent(t,g(f({},n),{parent:t}))})}):i(y,{})}columns(t,n){let{attrs:e}=t;if(!this.shouldShow(t,n))return i(y,{});let[o,s]=this.adjustColumnsContent(t);return i(C,{width:`${s}%`,style:{margin:0,padding:0,width:`${s}%`},className:"tab-row-full",children:this.getMappedContent(o,g(f({},n),{parent:o}))})}adjustColumnsContent(t){var u;let{content:n=[]}=t,e=100,r=n.filter(h=>{var d;return h.type==="column"&&!!Number(((d=h.attrs)==null?void 0:d.width)||0)}),o=n.filter(h=>{var d,m;return h.type==="column"&&(((d=h.attrs)==null?void 0:d.width)==="auto"||!((m=h.attrs)!=null&&m.width))}),s=r.reduce((h,d)=>{var m;return h+Number((m=d.attrs)==null?void 0:m.width)},0),l=(e-s)/o.length,p=((u=t.attrs)==null?void 0:u.gap)||_t;return[g(f({},t),{content:n.map((h,d)=>{var b,v,N;let m=h.type==="column"&&(((b=h.attrs)==null?void 0:b.width)==="auto"||!((v=h.attrs)!=null&&v.width)),x=d===0,S=d===n.length-1;return g(f({},h),{attrs:g(f({},h.attrs),{width:m?l:(N=h.attrs)==null?void 0:N.width,isFirstColumn:x,isLastColumn:S,index:d,paddingLeft:x?0:p/2,paddingRight:S?0:p/2})})})}),o.length===0?Math.min(e,s):e]}column(t,n){let{attrs:e}=t,{width:r,verticalAlign:o="top",paddingLeft:s=0,paddingRight:a=0}=e||{};return i(w,{width:`${Number(r)}%`,style:{width:`${Number(r)}%`,margin:0,verticalAlign:o},className:"tab-col-full",children:i(pt,{style:{margin:0,paddingLeft:s,paddingRight:a},className:"tab-pad",children:this.getMappedContent(t,g(f({},n),{parent:t}))})})}for(t,n){var l,p;let{attrs:e}=t,{each:r=""}=e||{};if(!this.shouldShow(t,n))return i(y,{});let{payloadValue:s}=n||{};s=typeof s=="object"?s:{};let a=(p=(l=this.payloadValues.get(r))!=null?l:s[r])!=null?p:[];if(!Array.isArray(a))throw new Error(`Payload value for each "${r}" is not an array`);return i(y,{children:a.map(u=>i(D,{children:this.getMappedContent(t,g(f({},n),{parent:t,payloadValue:u}))},R()))})}shouldShow(t,n){var o,s,a;let e=(s=(o=t==null?void 0:t.attrs)==null?void 0:o.showIfKey)!=null?s:"";if(!e)return!0;let{payloadValue:r}=n||{};return r=typeof r=="object"?r:{},!!((a=this.payloadValues.get(e))!=null?a:r[e])}};function oe(c,t){return E(this,null,function*(){let s=t||{},{theme:n,preview:e}=s,r=H(s,["theme","preview"]),o=new J(c);return o.setPreviewText(e),o.setTheme(n||{}),o.setPayloadValue("items",[{name:"John Doe"},{name:"Novu"}]),o.setPayloadValue("shouldShow",!0),o.render(r)})}export{_t as DEFAULT_COLUMNS_GAP,zt as DEFAULT_COLUMNS_WIDTH,jt as DEFAULT_COLUMN_BACKGROUND_COLOR,qt as DEFAULT_COLUMN_BORDER_COLOR,Ht as DEFAULT_COLUMN_BORDER_RADIUS,Gt as DEFAULT_COLUMN_BORDER_WIDTH,Yt as DEFAULT_COLUMN_PADDING_BOTTOM,Qt as DEFAULT_COLUMN_PADDING_LEFT,Kt as DEFAULT_COLUMN_PADDING_RIGHT,$t as DEFAULT_COLUMN_PADDING_TOP,xt as DEFAULT_SECTION_ALIGN,gt as DEFAULT_SECTION_BACKGROUND_COLOR,St as DEFAULT_SECTION_BORDER_COLOR,yt as DEFAULT_SECTION_BORDER_WIDTH,Ot as DEFAULT_SECTION_MARGIN_BOTTOM,Ct as DEFAULT_SECTION_MARGIN_LEFT,wt as DEFAULT_SECTION_MARGIN_RIGHT,bt as DEFAULT_SECTION_MARGIN_TOP,Et as DEFAULT_SECTION_PADDING_BOTTOM,Tt as DEFAULT_SECTION_PADDING_LEFT,Nt as DEFAULT_SECTION_PADDING_RIGHT,vt as DEFAULT_SECTION_PADDING_TOP,J as Maily,oe as render};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maily-to/render",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A transformer that converts Maily content into HTML email templates.",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -48,13 +48,11 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@antfu/utils": "^0.7.10",
|
|
51
|
-
"@babel/preset-react": "^7.
|
|
52
|
-
"@tiptap/core": "^2.
|
|
53
|
-
"@types/
|
|
54
|
-
"@types/react": "^18.3.5",
|
|
55
|
-
"eslint-config-custom": "workspace:*",
|
|
51
|
+
"@babel/preset-react": "^7.25.9",
|
|
52
|
+
"@tiptap/core": "^2.9.1",
|
|
53
|
+
"@types/react": "^18.3.12",
|
|
56
54
|
"tsconfig": "workspace:*",
|
|
57
|
-
"typescript": "^5.
|
|
55
|
+
"typescript": "^5.6.3"
|
|
58
56
|
},
|
|
59
57
|
"dependencies": {
|
|
60
58
|
"@react-email/components": "^0.0.25",
|
package/readme.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
## Install
|
|
20
20
|
|
|
21
|
-
Install
|
|
21
|
+
Install `@maily-to/render` from your command line.
|
|
22
22
|
|
|
23
23
|
```sh
|
|
24
24
|
pnpm add @maily-to/render
|
|
@@ -30,10 +30,10 @@ pnpm add @maily-to/render
|
|
|
30
30
|
|
|
31
31
|
Convert React components into a HTML string.
|
|
32
32
|
|
|
33
|
-
```
|
|
34
|
-
import {
|
|
33
|
+
```ts
|
|
34
|
+
import { render } from '@maily-to/render';
|
|
35
35
|
|
|
36
|
-
const html =
|
|
36
|
+
const html = await render({
|
|
37
37
|
type: 'doc',
|
|
38
38
|
content: [
|
|
39
39
|
{
|
|
@@ -49,6 +49,65 @@ const html = renderSync({
|
|
|
49
49
|
});
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
### Variables
|
|
53
|
+
|
|
54
|
+
You can replace variables in the content.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { Maily } from '@maily-to/render';
|
|
58
|
+
|
|
59
|
+
const maily = new Maily({
|
|
60
|
+
type: 'doc',
|
|
61
|
+
content: [
|
|
62
|
+
{
|
|
63
|
+
type: 'paragraph',
|
|
64
|
+
attrs: { textAlign: 'left' },
|
|
65
|
+
content: [
|
|
66
|
+
{
|
|
67
|
+
type: 'variable',
|
|
68
|
+
attrs: {
|
|
69
|
+
id: 'currentDate',
|
|
70
|
+
fallback: 'now',
|
|
71
|
+
showIfKey: null,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
maily.setVariableValue('currentDate', new Date().toISOString());
|
|
80
|
+
const html = await maily.render();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Payloads
|
|
84
|
+
|
|
85
|
+
Payload values are used for the `For Loop` and `Show If` blocks.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
// (Omitted repeated imports)
|
|
89
|
+
|
|
90
|
+
const maily = new Maily({
|
|
91
|
+
type: 'doc',
|
|
92
|
+
content: [
|
|
93
|
+
{
|
|
94
|
+
type: 'for',
|
|
95
|
+
attrs: { each: 'items', showIfKey: null },
|
|
96
|
+
content: [
|
|
97
|
+
{
|
|
98
|
+
type: 'paragraph',
|
|
99
|
+
attrs: { textAlign: 'left' },
|
|
100
|
+
content: [{ type: 'text', text: 'Hello' }],
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
maily.setPayloadValue('items', ['Alice', 'Bob', 'Charlie']);
|
|
108
|
+
const html = await maily.render();
|
|
109
|
+
```
|
|
110
|
+
|
|
52
111
|
## Contributions
|
|
53
112
|
|
|
54
113
|
Feel free to submit pull requests, create issues, or spread the word.
|