@maily-to/render 0.0.10 → 0.0.11
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 +34 -32
- package/dist/index.d.ts +34 -32
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -10,27 +10,27 @@ interface MarkType {
|
|
|
10
10
|
declare const allowedSpacers: readonly ["sm", "md", "lg", "xl"];
|
|
11
11
|
type AllowedSpacers = (typeof allowedSpacers)[number];
|
|
12
12
|
interface ThemeOptions {
|
|
13
|
-
colors?: {
|
|
14
|
-
heading
|
|
15
|
-
paragraph
|
|
16
|
-
horizontal
|
|
17
|
-
footer
|
|
18
|
-
blockquoteBorder
|
|
19
|
-
codeBackground
|
|
20
|
-
codeText
|
|
21
|
-
linkCardTitle
|
|
22
|
-
linkCardDescription
|
|
23
|
-
linkCardBadgeText
|
|
24
|
-
linkCardBadgeBackground
|
|
13
|
+
colors?: Partial<{
|
|
14
|
+
heading: string;
|
|
15
|
+
paragraph: string;
|
|
16
|
+
horizontal: string;
|
|
17
|
+
footer: string;
|
|
18
|
+
blockquoteBorder: string;
|
|
19
|
+
codeBackground: string;
|
|
20
|
+
codeText: string;
|
|
21
|
+
linkCardTitle: string;
|
|
22
|
+
linkCardDescription: string;
|
|
23
|
+
linkCardBadgeText: string;
|
|
24
|
+
linkCardBadgeBackground: string;
|
|
25
25
|
linkCardSubTitle: string;
|
|
26
|
-
}
|
|
27
|
-
fontSize?: {
|
|
28
|
-
paragraph
|
|
29
|
-
footer
|
|
30
|
-
size
|
|
31
|
-
lineHeight
|
|
26
|
+
}>;
|
|
27
|
+
fontSize?: Partial<{
|
|
28
|
+
paragraph: string;
|
|
29
|
+
footer: {
|
|
30
|
+
size: string;
|
|
31
|
+
lineHeight: string;
|
|
32
32
|
};
|
|
33
|
-
}
|
|
33
|
+
}>;
|
|
34
34
|
}
|
|
35
35
|
interface MailyConfig {
|
|
36
36
|
/**
|
|
@@ -48,10 +48,10 @@ interface MailyConfig {
|
|
|
48
48
|
* ```js
|
|
49
49
|
* {
|
|
50
50
|
* colors: {
|
|
51
|
-
* heading: '
|
|
52
|
-
* paragraph: '
|
|
53
|
-
* horizontal: '
|
|
54
|
-
* footer: '
|
|
51
|
+
* heading: '#111827',
|
|
52
|
+
* paragraph: '#374151',
|
|
53
|
+
* horizontal: '#EAEAEA',
|
|
54
|
+
* footer: '#64748B',
|
|
55
55
|
* },
|
|
56
56
|
* fontSize: {
|
|
57
57
|
* paragraph: '15px',
|
|
@@ -68,7 +68,7 @@ interface MailyConfig {
|
|
|
68
68
|
* const maily = new Maily(content, {
|
|
69
69
|
* theme: {
|
|
70
70
|
* colors: {
|
|
71
|
-
* heading: '
|
|
71
|
+
* heading: '#111827',
|
|
72
72
|
* },
|
|
73
73
|
* fontSize: {
|
|
74
74
|
* footer: {
|
|
@@ -80,7 +80,7 @@ interface MailyConfig {
|
|
|
80
80
|
* });
|
|
81
81
|
* ```
|
|
82
82
|
*/
|
|
83
|
-
theme?: ThemeOptions
|
|
83
|
+
theme?: Partial<ThemeOptions>;
|
|
84
84
|
}
|
|
85
85
|
interface RenderOptions {
|
|
86
86
|
/**
|
|
@@ -112,7 +112,7 @@ declare class Maily {
|
|
|
112
112
|
private openTrackingPixel;
|
|
113
113
|
constructor(content?: JSONContent);
|
|
114
114
|
setPreviewText(preview?: string): void;
|
|
115
|
-
setTheme(theme
|
|
115
|
+
setTheme(theme: Partial<ThemeOptions>): void;
|
|
116
116
|
setVariableFormatter(formatter: VariableFormatter): void;
|
|
117
117
|
/**
|
|
118
118
|
* `setVariableValue` will set the variable value.
|
|
@@ -155,13 +155,13 @@ declare class Maily {
|
|
|
155
155
|
setShouldReplaceVariableValues(shouldReplace: boolean): void;
|
|
156
156
|
getAllLinks(): Set<string>;
|
|
157
157
|
private isValidUrl;
|
|
158
|
-
|
|
159
|
-
renderAsync(options?: RenderOptions): Promise<string>;
|
|
158
|
+
render(options?: RenderOptions): Promise<string>;
|
|
160
159
|
/**
|
|
161
160
|
* `markup` will render the JSON content into React Email markup.
|
|
162
161
|
* and return the raw React Tree.
|
|
163
162
|
*/
|
|
164
163
|
markup(): react_jsx_runtime.JSX.Element;
|
|
164
|
+
private getMarginOverrideConditions;
|
|
165
165
|
private getMappedContent;
|
|
166
166
|
private renderNode;
|
|
167
167
|
private renderMark;
|
|
@@ -171,6 +171,7 @@ declare class Maily {
|
|
|
171
171
|
private italic;
|
|
172
172
|
private underline;
|
|
173
173
|
private strike;
|
|
174
|
+
private textStyle;
|
|
174
175
|
private link;
|
|
175
176
|
private heading;
|
|
176
177
|
private variable;
|
|
@@ -187,10 +188,11 @@ declare class Maily {
|
|
|
187
188
|
private blockquote;
|
|
188
189
|
private code;
|
|
189
190
|
private linkCard;
|
|
191
|
+
private section;
|
|
192
|
+
private columns;
|
|
193
|
+
private column;
|
|
190
194
|
}
|
|
191
195
|
|
|
192
|
-
declare function
|
|
196
|
+
declare function render(content: JSONContent, config?: MailyConfig & RenderOptions): Promise<string>;
|
|
193
197
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
export { type AllowedSpacers, type LinkValues, Maily, type MailyConfig, type MarkType, type RenderOptions, type ThemeOptions, type VariableFormatter, type VariableValues, renderAsync, renderSync };
|
|
198
|
+
export { type AllowedSpacers, type LinkValues, Maily, type MailyConfig, type MarkType, type RenderOptions, type ThemeOptions, type VariableFormatter, type VariableValues, render };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,27 +10,27 @@ interface MarkType {
|
|
|
10
10
|
declare const allowedSpacers: readonly ["sm", "md", "lg", "xl"];
|
|
11
11
|
type AllowedSpacers = (typeof allowedSpacers)[number];
|
|
12
12
|
interface ThemeOptions {
|
|
13
|
-
colors?: {
|
|
14
|
-
heading
|
|
15
|
-
paragraph
|
|
16
|
-
horizontal
|
|
17
|
-
footer
|
|
18
|
-
blockquoteBorder
|
|
19
|
-
codeBackground
|
|
20
|
-
codeText
|
|
21
|
-
linkCardTitle
|
|
22
|
-
linkCardDescription
|
|
23
|
-
linkCardBadgeText
|
|
24
|
-
linkCardBadgeBackground
|
|
13
|
+
colors?: Partial<{
|
|
14
|
+
heading: string;
|
|
15
|
+
paragraph: string;
|
|
16
|
+
horizontal: string;
|
|
17
|
+
footer: string;
|
|
18
|
+
blockquoteBorder: string;
|
|
19
|
+
codeBackground: string;
|
|
20
|
+
codeText: string;
|
|
21
|
+
linkCardTitle: string;
|
|
22
|
+
linkCardDescription: string;
|
|
23
|
+
linkCardBadgeText: string;
|
|
24
|
+
linkCardBadgeBackground: string;
|
|
25
25
|
linkCardSubTitle: string;
|
|
26
|
-
}
|
|
27
|
-
fontSize?: {
|
|
28
|
-
paragraph
|
|
29
|
-
footer
|
|
30
|
-
size
|
|
31
|
-
lineHeight
|
|
26
|
+
}>;
|
|
27
|
+
fontSize?: Partial<{
|
|
28
|
+
paragraph: string;
|
|
29
|
+
footer: {
|
|
30
|
+
size: string;
|
|
31
|
+
lineHeight: string;
|
|
32
32
|
};
|
|
33
|
-
}
|
|
33
|
+
}>;
|
|
34
34
|
}
|
|
35
35
|
interface MailyConfig {
|
|
36
36
|
/**
|
|
@@ -48,10 +48,10 @@ interface MailyConfig {
|
|
|
48
48
|
* ```js
|
|
49
49
|
* {
|
|
50
50
|
* colors: {
|
|
51
|
-
* heading: '
|
|
52
|
-
* paragraph: '
|
|
53
|
-
* horizontal: '
|
|
54
|
-
* footer: '
|
|
51
|
+
* heading: '#111827',
|
|
52
|
+
* paragraph: '#374151',
|
|
53
|
+
* horizontal: '#EAEAEA',
|
|
54
|
+
* footer: '#64748B',
|
|
55
55
|
* },
|
|
56
56
|
* fontSize: {
|
|
57
57
|
* paragraph: '15px',
|
|
@@ -68,7 +68,7 @@ interface MailyConfig {
|
|
|
68
68
|
* const maily = new Maily(content, {
|
|
69
69
|
* theme: {
|
|
70
70
|
* colors: {
|
|
71
|
-
* heading: '
|
|
71
|
+
* heading: '#111827',
|
|
72
72
|
* },
|
|
73
73
|
* fontSize: {
|
|
74
74
|
* footer: {
|
|
@@ -80,7 +80,7 @@ interface MailyConfig {
|
|
|
80
80
|
* });
|
|
81
81
|
* ```
|
|
82
82
|
*/
|
|
83
|
-
theme?: ThemeOptions
|
|
83
|
+
theme?: Partial<ThemeOptions>;
|
|
84
84
|
}
|
|
85
85
|
interface RenderOptions {
|
|
86
86
|
/**
|
|
@@ -112,7 +112,7 @@ declare class Maily {
|
|
|
112
112
|
private openTrackingPixel;
|
|
113
113
|
constructor(content?: JSONContent);
|
|
114
114
|
setPreviewText(preview?: string): void;
|
|
115
|
-
setTheme(theme
|
|
115
|
+
setTheme(theme: Partial<ThemeOptions>): void;
|
|
116
116
|
setVariableFormatter(formatter: VariableFormatter): void;
|
|
117
117
|
/**
|
|
118
118
|
* `setVariableValue` will set the variable value.
|
|
@@ -155,13 +155,13 @@ declare class Maily {
|
|
|
155
155
|
setShouldReplaceVariableValues(shouldReplace: boolean): void;
|
|
156
156
|
getAllLinks(): Set<string>;
|
|
157
157
|
private isValidUrl;
|
|
158
|
-
|
|
159
|
-
renderAsync(options?: RenderOptions): Promise<string>;
|
|
158
|
+
render(options?: RenderOptions): Promise<string>;
|
|
160
159
|
/**
|
|
161
160
|
* `markup` will render the JSON content into React Email markup.
|
|
162
161
|
* and return the raw React Tree.
|
|
163
162
|
*/
|
|
164
163
|
markup(): react_jsx_runtime.JSX.Element;
|
|
164
|
+
private getMarginOverrideConditions;
|
|
165
165
|
private getMappedContent;
|
|
166
166
|
private renderNode;
|
|
167
167
|
private renderMark;
|
|
@@ -171,6 +171,7 @@ declare class Maily {
|
|
|
171
171
|
private italic;
|
|
172
172
|
private underline;
|
|
173
173
|
private strike;
|
|
174
|
+
private textStyle;
|
|
174
175
|
private link;
|
|
175
176
|
private heading;
|
|
176
177
|
private variable;
|
|
@@ -187,10 +188,11 @@ declare class Maily {
|
|
|
187
188
|
private blockquote;
|
|
188
189
|
private code;
|
|
189
190
|
private linkCard;
|
|
191
|
+
private section;
|
|
192
|
+
private columns;
|
|
193
|
+
private column;
|
|
190
194
|
}
|
|
191
195
|
|
|
192
|
-
declare function
|
|
196
|
+
declare function render(content: JSONContent, config?: MailyConfig & RenderOptions): Promise<string>;
|
|
193
197
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
export { type AllowedSpacers, type LinkValues, Maily, type MailyConfig, type MarkType, type RenderOptions, type ThemeOptions, type VariableFormatter, type VariableValues, renderAsync, renderSync };
|
|
198
|
+
export { type AllowedSpacers, type LinkValues, Maily, type MailyConfig, type MarkType, 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 K=Object.create;var S=Object.defineProperty,Y=Object.defineProperties,G=Object.getOwnPropertyDescriptor,Q=Object.getOwnPropertyDescriptors,Z=Object.getOwnPropertyNames,k=Object.getOwnPropertySymbols,ee=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var P=(p,e,t)=>e in p?S(p,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):p[e]=t,x=(p,e)=>{for(var t in e||(e={}))J.call(e,t)&&P(p,t,e[t]);if(k)for(var t of k(e))D.call(e,t)&&P(p,t,e[t]);return p},I=(p,e)=>Y(p,Q(e));var C=(p,e)=>{var t={};for(var n in p)J.call(p,n)&&e.indexOf(n)<0&&(t[n]=p[n]);if(p!=null&&k)for(var n of k(p))e.indexOf(n)<0&&D.call(p,n)&&(t[n]=p[n]);return t};var te=(p,e)=>{for(var t in e)S(p,t,{get:e[t],enumerable:!0})},q=(p,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Z(e))!J.call(p,i)&&i!==t&&S(p,i,{get:()=>e[i],enumerable:!(n=G(e,i))||n.enumerable});return p};var ne=(p,e,t)=>(t=p!=null?K(ee(p)):{},q(e||!p||!p.__esModule?S(t,"default",{value:p,enumerable:!0}):t,p)),oe=p=>q(S({},"__esModule",{value:!0}),p);var O=(p,e,t)=>new Promise((n,i)=>{var r=c=>{try{l(t.next(c))}catch(g){i(g)}},s=c=>{try{l(t.throw(c))}catch(g){i(g)}},l=c=>c.done?n(c.value):Promise.resolve(c.value).then(r,s);l((t=t.apply(p,e)).next())});var ce={};te(ce,{Maily:()=>y,renderAsync:()=>pe,renderSync:()=>le});module.exports=oe(ce);var w=require("react"),a=require("@react-email/components"),v=require("@react-email/render"),j=ne(require("lodash/merge"));function T(){return Math.random().toString(36).substr(2,6)}var o=require("react/jsx-runtime");var re={sm:"8px",md:"16px",lg:"32px",xl:"64px"},b={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var ie={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var $={sm:"40px",md:"48px",lg:"64px"},U={pretty:!1,plainText:!1},ae={colors:{heading:"rgb(17, 24, 39)",paragraph:"rgb(55, 65, 81)",horizontal:"rgb(234, 234, 234)",footer:"rgb(100, 116, 139)",blockquoteBorder:"rgb(209, 213, 219)",codeBackground:"rgb(239, 239, 239)",codeText:"rgb(17, 24, 39)",linkCardTitle:"rgb(17, 24, 39)",linkCardDescription:"rgb(107, 114, 128)",linkCardBadgeText:"rgb(17, 24, 39)",linkCardBadgeBackground:"rgb(254, 240, 138)",linkCardSubTitle:"rgb(107, 114, 128)"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}},se='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',y=class{constructor(e={type:"doc",content:[]}){this.config={theme:ae};this.variableFormatter=({variable:e,fallback:t})=>t?`{{${e},fallback=${t}}}`:`{{${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=(0,j.default)(this.config.theme,e)}setVariableFormatter(e){this.variableFormatter=e}setVariableValue(e,t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(e,t)}setVariableValues(e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(e).forEach(([t,n])=>{this.setVariableValue(t,n)})}setLinkValue(e,t){this.linkValues.set(e,t)}setLinkValues(e){Object.entries(e).forEach(([t,n])=>{this.setLinkValue(t,n)})}setOpenTrackingPixel(e){this.openTrackingPixel=e}setShouldReplaceVariableValues(e){this.shouldReplaceVariableValues=e}getAllLinks(){let e=this.content.content||[],t=new Set,n=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 l=(s=r.attrs)==null?void 0:s.url;n(l)&&l&&t.add(l)}else r.content&&r.content.forEach(l=>{l.marks&&l.marks.forEach(c=>{var m;let g=(m=c.attrs)==null?void 0:m.href;c.type==="link"&&n(g)&&t.add(g)}),l.content&&i(l)})};return e.forEach(r=>{i(r)}),t}isValidUrl(e){try{let t=new URL(e);return!0}catch(t){return!1}}renderSync(e=U){let t=this.markup();return(0,v.render)(t,e)}renderAsync(){return O(this,arguments,function*(e=U){let t=this.markup();return(0,v.renderAsync)(t,e)})}markup(){let e=this.content.content||[],t=e.map((r,s)=>{let l={prev:e[s-1],next:e[s+1],parent:r},c=this.renderNode(r,l);return c?(0,o.jsx)(w.Fragment,{children:c},T()):null}),{preview:n}=this.config;return(0,o.jsxs)(a.Html,{children:[(0,o.jsxs)(a.Head,{children:[(0,o.jsx)(a.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}"}}),(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)(a.Body,{children:[n?(0,o.jsx)(a.Preview,{id:"__react-email-preview",children:n}):null,(0,o.jsx)(a.Container,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:t}),this.openTrackingPixel?(0,o.jsx)(a.Img,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMappedContent(e,t){var n;return(n=e.content)==null?void 0:n.map(i=>{let r=this.renderNode(i,t);return r?(0,o.jsx)(w.Fragment,{children:r},T()):null}).filter(i=>i!==null)}renderNode(e,t={}){var i;let n=e.type||"";if(n in this)return(i=this[n])==null?void 0:i.call(this,e,t);throw new Error(`Node type "${n}" is not supported.`)}renderMark(e){let t=e.text||(0,o.jsx)(o.Fragment,{children:"\xA0"});return(e.marks||[]).reduce((i,r)=>{var l;let s=r.type;if(s in this)return(l=this[s])==null?void 0:l.call(this,r,i);throw new Error(`Mark type "${s}" is not supported.`)},(0,o.jsx)(o.Fragment,{children:t}))}paragraph(e,t){var g,m,d,h;let{attrs:n}=e,i=(n==null?void 0:n.textAlign)||"left",{parent:r,next:s}=t||{},l=(r==null?void 0:r.type)==="listItem",c=(s==null?void 0:s.type)==="spacer";return(0,o.jsx)(a.Text,{style:x({textAlign:i,marginBottom:l||c?"0px":"20px",marginTop:"0px",fontSize:(m=(g=this.config.theme)==null?void 0:g.fontSize)==null?void 0:m.paragraph,color:(h=(d=this.config.theme)==null?void 0:d.colors)==null?void 0:h.paragraph},b),children:e.content?this.getMappedContent(e):(0,o.jsx)(o.Fragment,{children:"\xA0"})})}text(e,t){let n=e.text||" ";return e.marks?this.renderMark(e):(0,o.jsx)(o.Fragment,{children:n})}bold(e,t){return(0,o.jsx)("strong",{children:t})}italic(e,t){return(0,o.jsx)("em",{children:t})}underline(e,t){return(0,o.jsx)("u",{children:t})}strike(e,t){return(0,o.jsx)("s",{style:{textDecoration:"line-through"},children:t})}link(e,t){var l,c;let{attrs:n}=e,i=(n==null?void 0:n.href)||"#",r=(n==null?void 0:n.target)||"_blank",s=(n==null?void 0:n.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)(a.Link,{href:i,rel:s,style:{fontWeight:500,textDecoration:"underline",color:(c=(l=this.config.theme)==null?void 0:l.colors)==null?void 0:c.heading},target:r,children:t})}heading(e,t){var u,f;let{attrs:n}=e,{next:i,prev:r}=t||{},s=`h${Number(n==null?void 0:n.level)||1}`,l=(n==null?void 0:n.textAlign)||"left",c=(i==null?void 0:i.type)==="spacer",g=(r==null?void 0:r.type)==="spacer",{fontSize:m,lineHeight:d,fontWeight:h}=ie[s];return(0,o.jsx)(a.Heading,{as:s,style:{textAlign:l,color:(f=(u=this.config.theme)==null?void 0:u.colors)==null?void 0:f.heading,marginBottom:c?"0px":"12px",marginTop:"0px",fontSize:m,lineHeight:d,fontWeight:h},children:this.getMappedContent(e)})}variable(e,t){let{id:n,fallback:i}=e.attrs||{},r=this.variableFormatter({variable:n,fallback:i});return this.shouldReplaceVariableValues&&(r=this.variableValues.get(n)||i||r),(0,o.jsx)(o.Fragment,{children:r})}horizontalRule(e,t){return(0,o.jsx)(a.Hr,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(e,t){return(0,o.jsx)(a.Container,{children:(0,o.jsx)("ol",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(e)})})}bulletList(e,t){return(0,o.jsx)(a.Container,{style:{maxWidth:"100%"},children:(0,o.jsx)("ul",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(e)})})}listItem(e,t){return(0,o.jsx)(a.Container,{style:{maxWidth:"100%"},children:(0,o.jsx)("li",{style:x({marginBottom:"8px",paddingLeft:"6px"},b),children:this.getMappedContent(e,I(x({},t),{parent:e}))})})}button(e,t){let{attrs:n}=e,{text:i,url:r,variant:s,buttonColor:l,textColor:c,borderRadius:g,alignment:m="left"}=n||{},d="0px";g==="round"?d="9999px":g==="smooth"&&(d="6px");let{next:h}=t||{},u=(h==null?void 0:h.type)==="spacer",f=this.linkValues.get(r)||this.variableValues.get(r)||r;return(0,o.jsx)(a.Container,{style:{textAlign:m,maxWidth:"100%",marginBottom:u?"0px":"20px"},children:(0,o.jsx)(a.Button,{href:f,style:{color:String(c),backgroundColor:s==="filled"?String(l):"transparent",borderColor:String(l),padding:s==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:d},children:i})})}spacer(e,t){let{attrs:n}=e,{height:i="auto"}=n||{};return(0,o.jsx)(a.Container,{style:{height:re[i]||i}})}hardBreak(e,t){return(0,o.jsx)("br",{})}logo(e,t){let{attrs:n}=e,{src:i,alt:r,title:s,size:l,alignment:c="left"}=n||{},{next:g}=t||{},m=(g==null?void 0:g.type)==="spacer";return(0,o.jsx)(a.Row,{style:{marginTop:"0px",marginBottom:m?"0px":"32px"},children:(0,o.jsx)(a.Column,{align:c,children:(0,o.jsx)(a.Img,{alt:r||s||"Logo",src:i,style:{width:$[l]||l,height:$[l]||l},title:s||r||"Logo"})})})}image(e,t){let{attrs:n}=e,{src:i,alt:r,title:s,width:l="auto",height:c="auto",alignment:g="center",externalLink:m=""}=n||{},{next:d}=t||{},h=(d==null?void 0:d.type)==="spacer",u=(0,o.jsx)(a.Img,{alt:r||s||"Image",src:i,style:{height:c,width:l,maxWidth:"100%",outline:"none",border:"none",textDecoration:"none"},title:s||r||"Image"});return(0,o.jsx)(a.Row,{style:{marginTop:"0px",marginBottom:h?"0px":"32px"},children:(0,o.jsx)(a.Column,{align:g,children:m?(0,o.jsx)("a",{href:m,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:u}):u})})}footer(e,t){var l,c,g,m,d,h,u,f;let{attrs:n}=e,{textAlign:i="left"}=n||{},{next:r}=t||{},s=(r==null?void 0:r.type)==="spacer";return(0,o.jsx)(a.Text,{style:x({fontSize:(g=(c=(l=this.config.theme)==null?void 0:l.fontSize)==null?void 0:c.footer)==null?void 0:g.size,lineHeight:(h=(d=(m=this.config.theme)==null?void 0:m.fontSize)==null?void 0:d.footer)==null?void 0:h.lineHeight,color:(f=(u=this.config.theme)==null?void 0:u.colors)==null?void 0:f.footer,marginTop:"0px",marginBottom:s?"0px":"20px",textAlign:i},b),children:this.getMappedContent(e)})}blockquote(e,t){var l,c;let{next:n,prev:i}=t||{},r=(n==null?void 0:n.type)==="spacer",s=(i==null?void 0:i.type)==="spacer";return(0,o.jsx)("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(c=(l=this.config.theme)==null?void 0:l.colors)==null?void 0:c.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:s?"0px":"20px",marginBottom:r?"0px":"20px"},children:this.getMappedContent(e)})}code(e,t){var n,i,r,s;return(0,o.jsx)("code",{style:{backgroundColor:(i=(n=this.config.theme)==null?void 0:n.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:se,fontWeight:400,letterSpacing:0},children:t})}linkCard(e,t){var V,R,L,M,B,X,z,_,A,F,W,H;let{attrs:n}=e,{next:i}=t||{},r=(i==null?void 0:i.type)==="spacer",s=600,l=16/9,c=s/l,{title:g,description:m,link:d,linkTitle:h,image:u,badgeText:f,subTitle:N}=n||{},E=this.linkValues.get(d)||this.variableValues.get(d)||d||"#";return(0,o.jsxs)("a",{href:E,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:r?"0px":"20px"},target:"_blank",children:[u?(0,o.jsx)(a.Row,{style:{marginBottom:"6px"},children:(0,o.jsx)(a.Column,{style:{width:`${s}px`,height:`${c}px`},children:(0,o.jsx)(a.Img,{alt:g||"Link Card",src:u,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:g||"Link Card"})})}):null,(0,o.jsx)(a.Row,{style:{padding:"15px",marginTop:0,marginBottom:0},children:(0,o.jsxs)(a.Column,{style:{verticalAlign:"top"},children:[(0,o.jsxs)(a.Row,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[(0,o.jsx)(a.Column,{children:(0,o.jsx)(a.Text,{style:x({fontSize:"18px",fontWeight:600,color:(R=(V=this.config.theme)==null?void 0:V.colors)==null?void 0:R.linkCardTitle,margin:"0px"},b),children:g})}),f||N?(0,o.jsxs)(a.Column,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[f?(0,o.jsx)("span",{style:{fontWeight:600,color:(M=(L=this.config.theme)==null?void 0:L.colors)==null?void 0:M.linkCardBadgeText,padding:"4px 8px",borderRadius:"8px",backgroundColor:(X=(B=this.config.theme)==null?void 0:B.colors)==null?void 0:X.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:f}):null," ",N&&!f?(0,o.jsx)("span",{style:{fontWeight:"normal",color:(_=(z=this.config.theme)==null?void 0:z.colors)==null?void 0:_.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:N}):null]}):null]}),(0,o.jsxs)(a.Text,{style:x({fontSize:"16px",color:(F=(A=this.config.theme)==null?void 0:A.colors)==null?void 0:F.linkCardDescription,marginTop:"0px",marginBottom:"0px"},b),children:[m," ",h?(0,o.jsx)("a",{href:E,rel:"noopener noreferrer",style:{color:(H=(W=this.config.theme)==null?void 0:W.colors)==null?void 0:H.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:h}):null]})]})})]})}};function le(p,e){let s=e||{},{theme:t,preview:n}=s,i=C(s,["theme","preview"]),r=new y(p);return r.setPreviewText(n),r.setTheme(t),r.renderSync(i)}function pe(p,e){return O(this,null,function*(){let s=e||{},{theme:t,preview:n}=s,i=C(s,["theme","preview"]),r=new y(p);return r.setPreviewText(n),r.setTheme(t),r.renderAsync(i)})}0&&(module.exports={Maily,renderAsync,renderSync});
|
|
3
|
+
"use strict";var w=Object.defineProperty,U=Object.defineProperties,$=Object.getOwnPropertyDescriptor,K=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertyNames,O=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var W=(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)&&W(a,n,e[n]);if(O)for(var n of O(e))I.call(e,n)&&W(a,n,e[n]);return a},y=(a,e)=>U(a,K(e));var j=(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&&I.call(a,t)&&(n[t]=a[t]);return n};var G=(a,e)=>{for(var n in e)w(a,n,{get:e[n],enumerable:!0})},Q=(a,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Y(e))!T.call(a,o)&&o!==n&&w(a,o,{get:()=>e[o],enumerable:!(t=$(e,o))||t.enumerable});return a};var Z=a=>Q(w({},"__esModule",{value:!0}),a);var b=(a,e,n)=>new Promise((t,o)=>{var r=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(r,l);c((n=n.apply(a,e)).next())});var ce={};G(ce,{Maily:()=>v,render:()=>le});module.exports=Z(ce);var k=require("react"),s=require("@react-email/components"),q=require("@react-email/render");var ee=a=>Object.prototype.toString.call(a);var te=a=>ee(a)==="[object Object]";function ne(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)&&ne(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 te(a)&&!Array.isArray(a)}var he=Symbol("p-void");function L(){return Math.random().toString(36).substr(2,6)}var i=require("react/jsx-runtime");var ie={sm:"8px",md:"16px",lg:"32px",xl:"64px"},C={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var re={h1:{fontSize:"36px",lineHeight:"40px",fontWeight:800},h2:{fontSize:"30px",lineHeight:"36px",fontWeight:700},h3:{fontSize:"24px",lineHeight:"38px",fontWeight:600}};var D={sm:"40px",md:"48px",lg:"64px"},oe={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"}}},se='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',ae="#ffffff",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=r=>r&&this.isValidUrl(r)&&!r.startsWith("#")&&!r.startsWith("mailto:")&&!r.startsWith("tel:")&&typeof r=="string",o=r=>{var l;if(r.type==="button"){let c=(l=r.attrs)==null?void 0:l.url;t(c)&&c&&n.add(c)}else r.content&&r.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(r=>{o(r)}),n}isValidUrl(e){try{let n=new URL(e);return!0}catch(n){return!1}}render(){return b(this,arguments,function*(e=oe){let n=this.markup();return(0,q.renderAsync)(n,e)})}markup(){let e=this.content.content||[],n=e.map((r,l)=>{let c={prev:e[l-1],next:e[l+1],parent:r},p=this.renderNode(r,c);return p?(0,i.jsx)(k.Fragment,{children:p},L()):null}),{preview:t}=this.config;return(0,i.jsxs)(s.Html,{children:[(0,i.jsxs)(s.Head,{children:[(0,i.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,i.jsx)("style",{dangerouslySetInnerHTML:{__html:"blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}"}}),(0,i.jsx)("meta",{content:"width=device-width",name:"viewport"}),(0,i.jsx)("meta",{content:"IE=edge",httpEquiv:"X-UA-Compatible"}),(0,i.jsx)("meta",{name:"x-apple-disable-message-reformatting"}),(0,i.jsx)("meta",{content:"telephone=no,address=no,email=no,date=no,url=no",name:"format-detection"}),(0,i.jsx)("meta",{content:"light",name:"color-scheme"}),(0,i.jsx)("meta",{content:"light",name:"supported-color-schemes"})]}),(0,i.jsxs)(s.Body,{style:{margin:0},children:[t?(0,i.jsx)(s.Preview,{id:"__react-email-preview",children:t}):null,(0,i.jsx)(s.Container,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:n}),this.openTrackingPixel?(0,i.jsx)(s.Img,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMarginOverrideConditions(e,n){let{parent:t,prev:o,next:r}=n||{},l=(r==null?void 0:r.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"&&!r,m=(t==null?void 0:t.type)==="section"&&!o,f=(t==null?void 0:t.type)==="column"&&!r,d=(t==null?void 0:t.type)==="column"&&!o;return{isNextSpacer:l,isPrevSpacer:c,isLastSectionElement:u,isFirstSectionElement:m,isParentListItem:p,isLastColumnElement:f,isFirstColumnElement:d}}getMappedContent(e,n){let t=e.content||[];return t.map((o,r)=>{let l=this.renderNode(o,y(h({},n),{next:t[r+1],prev:t[r-1]}));return l?(0,i.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,i.jsx)(i.Fragment,{children:"\xA0"});return(e.marks||[]).reduce((o,r)=>{var c;let l=r.type;if(l in this)return(c=this[l])==null?void 0:c.call(this,r,o);throw new Error(`Mark type "${l}" is not supported.`)},(0,i.jsx)(i.Fragment,{children:n}))}paragraph(e,n){var u,m,f,d;let{attrs:t}=e,o=(t==null?void 0:t.textAlign)||"left",{isNextSpacer:r,isLastSectionElement:l,isParentListItem:c,isLastColumnElement:p}=this.getMarginOverrideConditions(e,n);return(0,i.jsx)(s.Text,{style:h({textAlign:o,marginBottom:c||r||l||p?"0px":"20px",marginTop:"0px",fontSize:(m=(u=this.config.theme)==null?void 0:u.fontSize)==null?void 0:m.paragraph,color:(d=(f=this.config.theme)==null?void 0:f.colors)==null?void 0:d.paragraph},C),children:e.content?this.getMappedContent(e):(0,i.jsx)(i.Fragment,{children:"\xA0"})})}text(e,n){let t=e.text||" ";return e.marks?this.renderMark(e):(0,i.jsx)(i.Fragment,{children:t})}bold(e,n){return(0,i.jsx)("strong",{children:n})}italic(e,n){return(0,i.jsx)("em",{children:n})}underline(e,n){return(0,i.jsx)("u",{children:n})}strike(e,n){return(0,i.jsx)("s",{style:{textDecoration:"line-through"},children:n})}textStyle(e,n){var r,l;let{attrs:t}=e,{color:o=(l=(r=this.config.theme)==null?void 0:r.colors)==null?void 0:l.paragraph}=t||{};return(0,i.jsx)("span",{style:{color:o},children:n})}link(e,n){var c,p;let{attrs:t}=e,o=(t==null?void 0:t.href)||"#",r=(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,i.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:r,children:n})}heading(e,n){var d,g;let{attrs:t}=e,o=`h${Number(t==null?void 0:t.level)||1}`,r=(t==null?void 0:t.textAlign)||"left",{isNextSpacer:l,isLastSectionElement:c,isLastColumnElement:p}=this.getMarginOverrideConditions(e,n),{fontSize:u,lineHeight:m,fontWeight:f}=re[o];return(0,i.jsx)(s.Heading,{as:o,style:{textAlign:r,color:(g=(d=this.config.theme)==null?void 0:d.colors)==null?void 0:g.heading,marginBottom:l||c||p?"0":"12px",marginTop:0,fontSize:u,lineHeight:m,fontWeight:f},children:this.getMappedContent(e,n)})}variable(e,n){let{id:t,fallback:o}=e.attrs||{},r=this.variableFormatter({variable:t,fallback:o});return this.shouldReplaceVariableValues&&(r=this.variableValues.get(t)||o||r),(0,i.jsx)(i.Fragment,{children:r})}horizontalRule(e,n){return(0,i.jsx)(s.Hr,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(e,n){let{isNextSpacer:t,isLastSectionElement:o,isLastColumnElement:r}=this.getMarginOverrideConditions(e,n);return(0,i.jsx)(s.Container,{children:(0,i.jsx)("ol",{style:{marginTop:"0px",marginBottom:t||o||r?"0":"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(e)})})}bulletList(e,n){let{parent:t,next:o}=n||{},{isLastSectionElement:r,isNextSpacer:l,isLastColumnElement:c}=this.getMarginOverrideConditions(e,{parent:t,next:o});return(0,i.jsx)(s.Container,{style:{maxWidth:"100%"},children:(0,i.jsx)("ul",{style:{marginTop:"0px",marginBottom:r||l||c?"0":"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(e)})})}listItem(e,n){return(0,i.jsx)(s.Container,{style:{maxWidth:"100%"},children:(0,i.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:r,variant:l,buttonColor:c,textColor:p,borderRadius:u,alignment:m="left"}=t||{},f="0px";u==="round"?f="9999px":u==="smooth"&&(f="6px");let{isNextSpacer:d,isLastSectionElement:g,isLastColumnElement:x}=this.getMarginOverrideConditions(e,n),S=this.linkValues.get(r)||this.variableValues.get(r)||r;return(0,i.jsx)(s.Container,{style:{textAlign:m,maxWidth:"100%",marginBottom:d||g||x?"0px":"20px"},children:(0,i.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:f},children:o})})}spacer(e,n){let{attrs:t}=e,{height:o="auto"}=t||{};return(0,i.jsx)(s.Container,{style:{height:ie[o]||o}})}hardBreak(e,n){return(0,i.jsx)("br",{})}logo(e,n){let{attrs:t}=e,{src:o,alt:r,title:l,size:c,alignment:p="left"}=t||{},{isNextSpacer:u,isLastSectionElement:m,isLastColumnElement:f}=this.getMarginOverrideConditions(e,n);return(0,i.jsx)(s.Row,{style:{marginTop:"0px",marginBottom:u||m||f?"0px":"32px"},children:(0,i.jsx)(s.Column,{align:p,children:(0,i.jsx)(s.Img,{alt:r||l||"Logo",src:o,style:{width:D[c]||c,height:D[c]||c},title:l||r||"Logo"})})})}image(e,n){let{attrs:t}=e,{src:o,alt:r,title:l,width:c="auto",height:p="auto",alignment:u="center",externalLink:m=""}=t||{},{isNextSpacer:f,isLastSectionElement:d,isLastColumnElement:g}=this.getMarginOverrideConditions(e,n),x=(0,i.jsx)(s.Img,{alt:r||l||"Image",src:o,style:{height:"100%",width:"100%",maxWidth:c,maxHeight:p,outline:"none",border:"none",textDecoration:"none"},title:l||r||"Image"});return(0,i.jsx)(s.Row,{style:{marginTop:"0px",marginBottom:f||d||g?"0px":"32px"},children:(0,i.jsx)(s.Column,{align:u,children:m?(0,i.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,f,d,g,x,S;let{attrs:t}=e,{textAlign:o="left"}=t||{},{isNextSpacer:r,isLastSectionElement:l,isLastColumnElement:c}=this.getMarginOverrideConditions(e,n);return(0,i.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=(d=(f=this.config.theme)==null?void 0:f.fontSize)==null?void 0:d.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:r||l||c?"0px":"20px",textAlign:o},C),children:this.getMappedContent(e)})}blockquote(e,n){var c,p;let{isNextSpacer:t,isPrevSpacer:o,isLastSectionElement:r,isLastColumnElement:l}=this.getMarginOverrideConditions(e,n);return(0,i.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||r||l?"0px":"20px"},children:this.getMappedContent(e)})}code(e,n){var t,o,r,l;return(0,i.jsx)("code",{style:{backgroundColor:(o=(t=this.config.theme)==null?void 0:t.colors)==null?void 0:o.codeBackground,color:(l=(r=this.config.theme)==null?void 0:r.colors)==null?void 0:l.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:se,fontWeight:400,letterSpacing:0},children:n})}linkCard(e,n){var S,J,M,A,V,_,B,R,P,X,z,F;let{attrs:t}=e,{isNextSpacer:o,isLastSectionElement:r,isLastColumnElement:l}=this.getMarginOverrideConditions(e,n),{title:c,description:p,link:u,linkTitle:m,image:f,badgeText:d,subTitle:g}=t||{},x=this.linkValues.get(u)||this.variableValues.get(u)||u||"#";return(0,i.jsxs)("a",{href:x,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:o||r||l?"0px":"20px"},target:"_blank",children:[f?(0,i.jsx)(s.Row,{style:{marginBottom:"6px"},children:(0,i.jsx)(s.Column,{style:{width:"100%",height:"100%"},children:(0,i.jsx)(s.Img,{alt:c||"Link Card",src:f,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:c||"Link Card"})})}):null,(0,i.jsx)(s.Row,{style:{padding:"15px",marginTop:0,marginBottom:0},children:(0,i.jsxs)(s.Column,{style:{verticalAlign:"top"},children:[(0,i.jsxs)(s.Row,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[(0,i.jsx)(s.Column,{children:(0,i.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})}),d||g?(0,i.jsxs)(s.Column,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[d?(0,i.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:d}):null," ",g&&!d?(0,i.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,i.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,i.jsx)("a",{href:x,rel:"noopener noreferrer",style:{color:(F=(z=this.config.theme)==null?void 0:z.colors)==null?void 0:F.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:m}):null]})]})})]})}section(e,n){let{attrs:t}=e,{borderRadius:o=0,padding:r=0,backgroundColor:l=ae}=t||{};return(0,i.jsx)(s.Container,{style:{backgroundColor:l,borderRadius:o,padding:r},children:this.getMappedContent(e,y(h({},n),{parent:e}))})}columns(e,n){return(0,i.jsx)(s.Row,{children:this.getMappedContent(e,y(h({},n),{parent:e}))})}column(e,n){let{attrs:t}=e,{width:o="50%",verticalAlign:r="top"}=t||{};return(0,i.jsx)(s.Column,{style:{width:o,verticalAlign:r},children:this.getMappedContent(e,y(h({},n),{parent:e}))})}};function le(a,e){return b(this,null,function*(){let l=e||{},{theme:n,preview:t}=l,o=j(l,["theme","preview"]),r=new v(a);return r.setPreviewText(t),r.setTheme(n||{}),r.render(o)})}0&&(module.exports={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 v=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var I=(c,e,t)=>e in c?G(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,x=(c,e)=>{for(var t in e||(e={}))q.call(e,t)&&I(c,t,e[t]);if(v)for(var t of v(e))$.call(e,t)&&I(c,t,e[t]);return c},U=(c,e)=>Q(c,Z(e));var N=(c,e)=>{var t={};for(var n in c)q.call(c,n)&&e.indexOf(n)<0&&(t[n]=c[n]);if(c!=null&&v)for(var n of v(c))e.indexOf(n)<0&&$.call(c,n)&&(t[n]=c[n]);return t};var J=(c,e,t)=>new Promise((n,r)=>{var o=l=>{try{s(t.next(l))}catch(p){r(p)}},a=l=>{try{s(t.throw(l))}catch(p){r(p)}},s=l=>l.done?n(l.value):Promise.resolve(l.value).then(o,a);s((t=t.apply(c,e)).next())});import{Fragment as j}from"react";import{Text as T,Html as ee,Head as te,Body as ne,Font as oe,Container as y,Link as re,Heading as ie,Hr as ae,Button as se,Img as w,Preview as le,Row as k,Column as S}from"@react-email/components";import{render as pe,renderAsync as ce}from"@react-email/render";import ge from"lodash/merge";function V(){return Math.random().toString(36).substr(2,6)}import{Fragment as O,jsx as i,jsxs as f}from"react/jsx-runtime";var me={sm:"8px",md:"16px",lg:"32px",xl:"64px"},C={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var de={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"},Y={pretty:!1,plainText:!1},he={colors:{heading:"rgb(17, 24, 39)",paragraph:"rgb(55, 65, 81)",horizontal:"rgb(234, 234, 234)",footer:"rgb(100, 116, 139)",blockquoteBorder:"rgb(209, 213, 219)",codeBackground:"rgb(239, 239, 239)",codeText:"rgb(17, 24, 39)",linkCardTitle:"rgb(17, 24, 39)",linkCardDescription:"rgb(107, 114, 128)",linkCardBadgeText:"rgb(17, 24, 39)",linkCardBadgeBackground:"rgb(254, 240, 138)",linkCardSubTitle:"rgb(107, 114, 128)"},fontSize:{paragraph:"15px",footer:{size:"14px",lineHeight:"24px"}}},ue='SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',b=class{constructor(e={type:"doc",content:[]}){this.config={theme:he};this.variableFormatter=({variable:e,fallback:t})=>t?`{{${e},fallback=${t}}}`:`{{${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=ge(this.config.theme,e)}setVariableFormatter(e){this.variableFormatter=e}setVariableValue(e,t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(e,t)}setVariableValues(e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(e).forEach(([t,n])=>{this.setVariableValue(t,n)})}setLinkValue(e,t){this.linkValues.set(e,t)}setLinkValues(e){Object.entries(e).forEach(([t,n])=>{this.setLinkValue(t,n)})}setOpenTrackingPixel(e){this.openTrackingPixel=e}setShouldReplaceVariableValues(e){this.shouldReplaceVariableValues=e}getAllLinks(){let e=this.content.content||[],t=new Set,n=o=>o&&this.isValidUrl(o)&&!o.startsWith("#")&&!o.startsWith("mailto:")&&!o.startsWith("tel:")&&typeof o=="string",r=o=>{var a;if(o.type==="button"){let s=(a=o.attrs)==null?void 0:a.url;n(s)&&s&&t.add(s)}else o.content&&o.content.forEach(s=>{s.marks&&s.marks.forEach(l=>{var g;let p=(g=l.attrs)==null?void 0:g.href;l.type==="link"&&n(p)&&t.add(p)}),s.content&&r(s)})};return e.forEach(o=>{r(o)}),t}isValidUrl(e){try{let t=new URL(e);return!0}catch(t){return!1}}renderSync(e=Y){let t=this.markup();return pe(t,e)}renderAsync(){return J(this,arguments,function*(e=Y){let t=this.markup();return ce(t,e)})}markup(){let e=this.content.content||[],t=e.map((o,a)=>{let s={prev:e[a-1],next:e[a+1],parent:o},l=this.renderNode(o,s);return l?i(j,{children:l},V()):null}),{preview:n}=this.config;return f(ee,{children:[f(te,{children:[i(oe,{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}"}}),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"})]}),f(ne,{children:[n?i(le,{id:"__react-email-preview",children:n}):null,i(y,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:t}),this.openTrackingPixel?i(w,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMappedContent(e,t){var n;return(n=e.content)==null?void 0:n.map(r=>{let o=this.renderNode(r,t);return o?i(j,{children:o},V()):null}).filter(r=>r!==null)}renderNode(e,t={}){var r;let n=e.type||"";if(n in this)return(r=this[n])==null?void 0:r.call(this,e,t);throw new Error(`Node type "${n}" is not supported.`)}renderMark(e){let t=e.text||i(O,{children:"\xA0"});return(e.marks||[]).reduce((r,o)=>{var s;let a=o.type;if(a in this)return(s=this[a])==null?void 0:s.call(this,o,r);throw new Error(`Mark type "${a}" is not supported.`)},i(O,{children:t}))}paragraph(e,t){var p,g,m,d;let{attrs:n}=e,r=(n==null?void 0:n.textAlign)||"left",{parent:o,next:a}=t||{},s=(o==null?void 0:o.type)==="listItem",l=(a==null?void 0:a.type)==="spacer";return i(T,{style:x({textAlign:r,marginBottom:s||l?"0px":"20px",marginTop:"0px",fontSize:(g=(p=this.config.theme)==null?void 0:p.fontSize)==null?void 0:g.paragraph,color:(d=(m=this.config.theme)==null?void 0:m.colors)==null?void 0:d.paragraph},C),children:e.content?this.getMappedContent(e):i(O,{children:"\xA0"})})}text(e,t){let n=e.text||" ";return e.marks?this.renderMark(e):i(O,{children:n})}bold(e,t){return i("strong",{children:t})}italic(e,t){return i("em",{children:t})}underline(e,t){return i("u",{children:t})}strike(e,t){return i("s",{style:{textDecoration:"line-through"},children:t})}link(e,t){var s,l;let{attrs:n}=e,r=(n==null?void 0:n.href)||"#",o=(n==null?void 0:n.target)||"_blank",a=(n==null?void 0:n.rel)||"noopener noreferrer nofollow";return(typeof this.linkValues=="object"||typeof this.variableValues=="object")&&(r=this.linkValues.get(r)||this.variableValues.get(r)||r),i(re,{href:r,rel:a,style:{fontWeight:500,textDecoration:"underline",color:(l=(s=this.config.theme)==null?void 0:s.colors)==null?void 0:l.heading},target:o,children:t})}heading(e,t){var h,u;let{attrs:n}=e,{next:r,prev:o}=t||{},a=`h${Number(n==null?void 0:n.level)||1}`,s=(n==null?void 0:n.textAlign)||"left",l=(r==null?void 0:r.type)==="spacer",p=(o==null?void 0:o.type)==="spacer",{fontSize:g,lineHeight:m,fontWeight:d}=de[a];return i(ie,{as:a,style:{textAlign:s,color:(u=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:u.heading,marginBottom:l?"0px":"12px",marginTop:"0px",fontSize:g,lineHeight:m,fontWeight:d},children:this.getMappedContent(e)})}variable(e,t){let{id:n,fallback:r}=e.attrs||{},o=this.variableFormatter({variable:n,fallback:r});return this.shouldReplaceVariableValues&&(o=this.variableValues.get(n)||r||o),i(O,{children:o})}horizontalRule(e,t){return i(ae,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(e,t){return i(y,{children:i("ol",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(e)})})}bulletList(e,t){return i(y,{style:{maxWidth:"100%"},children:i("ul",{style:{marginTop:"0px",marginBottom:"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(e)})})}listItem(e,t){return i(y,{style:{maxWidth:"100%"},children:i("li",{style:x({marginBottom:"8px",paddingLeft:"6px"},C),children:this.getMappedContent(e,U(x({},t),{parent:e}))})})}button(e,t){let{attrs:n}=e,{text:r,url:o,variant:a,buttonColor:s,textColor:l,borderRadius:p,alignment:g="left"}=n||{},m="0px";p==="round"?m="9999px":p==="smooth"&&(m="6px");let{next:d}=t||{},h=(d==null?void 0:d.type)==="spacer",u=this.linkValues.get(o)||this.variableValues.get(o)||o;return i(y,{style:{textAlign:g,maxWidth:"100%",marginBottom:h?"0px":"20px"},children:i(se,{href:u,style:{color:String(l),backgroundColor:a==="filled"?String(s):"transparent",borderColor:String(s),padding:a==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:m},children:r})})}spacer(e,t){let{attrs:n}=e,{height:r="auto"}=n||{};return i(y,{style:{height:me[r]||r}})}hardBreak(e,t){return i("br",{})}logo(e,t){let{attrs:n}=e,{src:r,alt:o,title:a,size:s,alignment:l="left"}=n||{},{next:p}=t||{},g=(p==null?void 0:p.type)==="spacer";return i(k,{style:{marginTop:"0px",marginBottom:g?"0px":"32px"},children:i(S,{align:l,children:i(w,{alt:o||a||"Logo",src:r,style:{width:K[s]||s,height:K[s]||s},title:a||o||"Logo"})})})}image(e,t){let{attrs:n}=e,{src:r,alt:o,title:a,width:s="auto",height:l="auto",alignment:p="center",externalLink:g=""}=n||{},{next:m}=t||{},d=(m==null?void 0:m.type)==="spacer",h=i(w,{alt:o||a||"Image",src:r,style:{height:l,width:s,maxWidth:"100%",outline:"none",border:"none",textDecoration:"none"},title:a||o||"Image"});return i(k,{style:{marginTop:"0px",marginBottom:d?"0px":"32px"},children:i(S,{align:p,children:g?i("a",{href:g,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:h}):h})})}footer(e,t){var s,l,p,g,m,d,h,u;let{attrs:n}=e,{textAlign:r="left"}=n||{},{next:o}=t||{},a=(o==null?void 0:o.type)==="spacer";return i(T,{style:x({fontSize:(p=(l=(s=this.config.theme)==null?void 0:s.fontSize)==null?void 0:l.footer)==null?void 0:p.size,lineHeight:(d=(m=(g=this.config.theme)==null?void 0:g.fontSize)==null?void 0:m.footer)==null?void 0:d.lineHeight,color:(u=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:u.footer,marginTop:"0px",marginBottom:a?"0px":"20px",textAlign:r},C),children:this.getMappedContent(e)})}blockquote(e,t){var s,l;let{next:n,prev:r}=t||{},o=(n==null?void 0:n.type)==="spacer",a=(r==null?void 0:r.type)==="spacer";return i("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(l=(s=this.config.theme)==null?void 0:s.colors)==null?void 0:l.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:a?"0px":"20px",marginBottom:o?"0px":"20px"},children:this.getMappedContent(e)})}code(e,t){var n,r,o,a;return i("code",{style:{backgroundColor:(r=(n=this.config.theme)==null?void 0:n.colors)==null?void 0:r.codeBackground,color:(a=(o=this.config.theme)==null?void 0:o.colors)==null?void 0:a.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:ue,fontWeight:400,letterSpacing:0},children:t})}linkCard(e,t){var L,M,B,X,z,_,A,F,W,H,P,D;let{attrs:n}=e,{next:r}=t||{},o=(r==null?void 0:r.type)==="spacer",a=600,s=16/9,l=a/s,{title:p,description:g,link:m,linkTitle:d,image:h,badgeText:u,subTitle:E}=n||{},R=this.linkValues.get(m)||this.variableValues.get(m)||m||"#";return f("a",{href:R,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:o?"0px":"20px"},target:"_blank",children:[h?i(k,{style:{marginBottom:"6px"},children:i(S,{style:{width:`${a}px`,height:`${l}px`},children:i(w,{alt:p||"Link Card",src:h,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:p||"Link Card"})})}):null,i(k,{style:{padding:"15px",marginTop:0,marginBottom:0},children:f(S,{style:{verticalAlign:"top"},children:[f(k,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[i(S,{children:i(T,{style:x({fontSize:"18px",fontWeight:600,color:(M=(L=this.config.theme)==null?void 0:L.colors)==null?void 0:M.linkCardTitle,margin:"0px"},C),children:p})}),u||E?f(S,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[u?i("span",{style:{fontWeight:600,color:(X=(B=this.config.theme)==null?void 0:B.colors)==null?void 0:X.linkCardBadgeText,padding:"4px 8px",borderRadius:"8px",backgroundColor:(_=(z=this.config.theme)==null?void 0:z.colors)==null?void 0:_.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:u}):null," ",E&&!u?i("span",{style:{fontWeight:"normal",color:(F=(A=this.config.theme)==null?void 0:A.colors)==null?void 0:F.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:E}):null]}):null]}),f(T,{style:x({fontSize:"16px",color:(H=(W=this.config.theme)==null?void 0:W.colors)==null?void 0:H.linkCardDescription,marginTop:"0px",marginBottom:"0px"},C),children:[g," ",d?i("a",{href:R,rel:"noopener noreferrer",style:{color:(D=(P=this.config.theme)==null?void 0:P.colors)==null?void 0:D.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:d}):null]})]})})]})}};function Te(c,e){let a=e||{},{theme:t,preview:n}=a,r=N(a,["theme","preview"]),o=new b(c);return o.setPreviewText(n),o.setTheme(t),o.renderSync(r)}function Re(c,e){return J(this,null,function*(){let a=e||{},{theme:t,preview:n}=a,r=N(a,["theme","preview"]),o=new b(c);return o.setPreviewText(n),o.setTheme(t),o.renderAsync(r)})}export{b as Maily,Re as renderAsync,Te as renderSync};
|
|
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 D=(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)&&D(l,n,e[n]);if(N)for(var n of N(e))q.call(e,n)&&D(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 we=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 fe={sm:"8px",md:"16px",lg:"32px",xl:"64px"},w={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var de={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",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,f=(t==null?void 0:t.type)==="column"&&!r;return{isNextSpacer:s,isPrevSpacer:a,isLastSectionElement:p,isFirstSectionElement:u,isParentListItem:c,isLastColumnElement:m,isFirstColumnElement:f}}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,f;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:(f=(m=this.config.theme)==null?void 0:m.colors)==null?void 0:f.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 f,d;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}=de[r];return o(le,{as:r,style:{textAlign:i,color:(d=(f=this.config.theme)==null?void 0:f.colors)==null?void 0:d.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:f,isLastSectionElement:d,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:f||d||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:fe[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:f,isLastColumnElement:d}=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||f||d?"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,f,d,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:(d=(f=(m=this.config.theme)==null?void 0:m.fontSize)==null?void 0:f.footer)==null?void 0:d.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,z,F,W,I,j;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:f,subTitle:d}=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})}),f||d?x(b,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[f?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:f}):null," ",d&&!f?o("span",{style:{fontWeight:"normal",color:(z=(X=this.config.theme)==null?void 0:X.colors)==null?void 0:z.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:d}):null]}):null]}),x(k,{style:g({fontSize:"16px",color:(W=(F=this.config.theme)==null?void 0:F.colors)==null?void 0:W.linkCardDescription,marginTop:"0px",marginBottom:"0px"},w),children:[c," ",u?o("a",{href:h,rel:"noopener noreferrer",style:{color:(j=(I=this.config.theme)==null?void 0:I.colors)==null?void 0:j.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){return o(v,{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},children:this.getMappedContent(e,C(g({},n),{parent:e}))})}};function Pe(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{M as Maily,Pe 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.11",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A transformer that converts Maily content into HTML email templates.",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -47,21 +47,21 @@
|
|
|
47
47
|
"node": ">=18.0.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
53
|
-
"@types/
|
|
50
|
+
"@antfu/utils": "^0.7.10",
|
|
51
|
+
"@babel/preset-react": "^7.24.7",
|
|
52
|
+
"@tiptap/core": "^2.6.6",
|
|
53
|
+
"@types/lodash": "^4.17.7",
|
|
54
|
+
"@types/react": "^18.3.5",
|
|
54
55
|
"eslint-config-custom": "workspace:*",
|
|
55
56
|
"tsconfig": "workspace:*",
|
|
56
|
-
"typescript": "^5.
|
|
57
|
+
"typescript": "^5.5.4"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"@react-email/components": "^0.0.
|
|
60
|
-
"@react-email/render": "^
|
|
61
|
-
"lodash": "^4.17.21"
|
|
60
|
+
"@react-email/components": "^0.0.25",
|
|
61
|
+
"@react-email/render": "^1.0.1"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"react": "18.
|
|
64
|
+
"react": "^18.3.1"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|