@maily-to/render 0.0.15 → 0.0.17
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 +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -104,6 +104,7 @@ declare const DEFAULT_COLUMN_PADDING_TOP = 0;
|
|
|
104
104
|
declare const DEFAULT_COLUMN_PADDING_RIGHT = 0;
|
|
105
105
|
declare const DEFAULT_COLUMN_PADDING_BOTTOM = 0;
|
|
106
106
|
declare const DEFAULT_COLUMN_PADDING_LEFT = 0;
|
|
107
|
+
declare const LINK_PROTOCOL_REGEX: RegExp;
|
|
107
108
|
interface RenderOptions {
|
|
108
109
|
/**
|
|
109
110
|
* The options object allows you to customize the output of the rendered
|
|
@@ -135,6 +136,7 @@ declare class Maily {
|
|
|
135
136
|
private linkValues;
|
|
136
137
|
private openTrackingPixel;
|
|
137
138
|
private payloadValues;
|
|
139
|
+
private marksOrder;
|
|
138
140
|
constructor(content?: JSONContent);
|
|
139
141
|
setPreviewText(preview?: string): void;
|
|
140
142
|
setTheme(theme: Partial<ThemeOptions>): void;
|
|
@@ -200,6 +202,8 @@ declare class Maily {
|
|
|
200
202
|
private strike;
|
|
201
203
|
private textStyle;
|
|
202
204
|
private link;
|
|
205
|
+
private removeLinkProtocol;
|
|
206
|
+
private variableUrlValue;
|
|
203
207
|
private heading;
|
|
204
208
|
private variable;
|
|
205
209
|
private horizontalRule;
|
|
@@ -225,4 +229,4 @@ declare class Maily {
|
|
|
225
229
|
|
|
226
230
|
declare function render(content: JSONContent, config?: MailyConfig & RenderOptions): Promise<string>;
|
|
227
231
|
|
|
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 };
|
|
232
|
+
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, LINK_PROTOCOL_REGEX, 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
|
@@ -104,6 +104,7 @@ declare const DEFAULT_COLUMN_PADDING_TOP = 0;
|
|
|
104
104
|
declare const DEFAULT_COLUMN_PADDING_RIGHT = 0;
|
|
105
105
|
declare const DEFAULT_COLUMN_PADDING_BOTTOM = 0;
|
|
106
106
|
declare const DEFAULT_COLUMN_PADDING_LEFT = 0;
|
|
107
|
+
declare const LINK_PROTOCOL_REGEX: RegExp;
|
|
107
108
|
interface RenderOptions {
|
|
108
109
|
/**
|
|
109
110
|
* The options object allows you to customize the output of the rendered
|
|
@@ -135,6 +136,7 @@ declare class Maily {
|
|
|
135
136
|
private linkValues;
|
|
136
137
|
private openTrackingPixel;
|
|
137
138
|
private payloadValues;
|
|
139
|
+
private marksOrder;
|
|
138
140
|
constructor(content?: JSONContent);
|
|
139
141
|
setPreviewText(preview?: string): void;
|
|
140
142
|
setTheme(theme: Partial<ThemeOptions>): void;
|
|
@@ -200,6 +202,8 @@ declare class Maily {
|
|
|
200
202
|
private strike;
|
|
201
203
|
private textStyle;
|
|
202
204
|
private link;
|
|
205
|
+
private removeLinkProtocol;
|
|
206
|
+
private variableUrlValue;
|
|
203
207
|
private heading;
|
|
204
208
|
private variable;
|
|
205
209
|
private horizontalRule;
|
|
@@ -225,4 +229,4 @@ declare class Maily {
|
|
|
225
229
|
|
|
226
230
|
declare function render(content: JSONContent, config?: MailyConfig & RenderOptions): Promise<string>;
|
|
227
231
|
|
|
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 };
|
|
232
|
+
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, LINK_PROTOCOL_REGEX, 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,2 +1,2 @@
|
|
|
1
|
-
"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",alignment:p="center",externalLink:u=""}=e||{};if(!this.shouldShow(t,n))return(0,o.jsx)(o.Fragment,{});let{shouldRemoveBottomMargin:d}=this.getMarginOverrideConditions(t,n),m=a==="auto"?"auto":Number(a),f=m==="auto"?"auto":`${m}px`,y=(0,o.jsx)(l.Img,{alt:r||s||"Image",src:i,style:{width:f,maxWidth:"100%",outline:"none",border:"none",textDecoration:"none",display:"block"},title:s||r||"Image"});return(0,o.jsx)(l.Row,{style:{marginTop:"0px",marginBottom:d?"0px":"32px"},children:(0,o.jsx)(l.Column,{align:p,children:u?(0,o.jsx)("a",{href:u,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:y}):y})})}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,k,V,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:(V=(k=this.config.theme)==null?void 0:k.colors)==null?void 0:V.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});
|
|
1
|
+
"use strict";var V=Object.defineProperty,it=Object.defineProperties,st=Object.getOwnPropertyDescriptor,at=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertyNames,R=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var F=(u,t,e)=>t in u?V(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,x=(u,t)=>{for(var e in t||(t={}))B.call(t,e)&&F(u,e,t[e]);if(R)for(var e of R(t))I.call(t,e)&&F(u,e,t[e]);return u},y=(u,t)=>it(u,at(t));var U=(u,t)=>{var e={};for(var n in u)B.call(u,n)&&t.indexOf(n)<0&&(e[n]=u[n]);if(u!=null&&R)for(var n of R(u))t.indexOf(n)<0&&I.call(u,n)&&(e[n]=u[n]);return e};var ct=(u,t)=>{for(var e in t)V(u,e,{get:t[e],enumerable:!0})},ut=(u,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of lt(t))!B.call(u,o)&&o!==e&&V(u,o,{get:()=>t[o],enumerable:!(n=st(t,o))||n.enumerable});return u};var pt=u=>ut(V({},"__esModule",{value:!0}),u);var L=(u,t,e)=>new Promise((n,o)=>{var i=c=>{try{a(e.next(c))}catch(d){o(d)}},s=c=>{try{a(e.throw(c))}catch(d){o(d)}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(i,s);a((e=e.apply(u,t)).next())});var Lt={};ct(Lt,{DEFAULT_COLUMNS_GAP:()=>ot,DEFAULT_COLUMNS_WIDTH:()=>St,DEFAULT_COLUMN_BACKGROUND_COLOR:()=>bt,DEFAULT_COLUMN_BORDER_COLOR:()=>Ct,DEFAULT_COLUMN_BORDER_RADIUS:()=>Ot,DEFAULT_COLUMN_BORDER_WIDTH:()=>wt,DEFAULT_COLUMN_PADDING_BOTTOM:()=>Et,DEFAULT_COLUMN_PADDING_LEFT:()=>Tt,DEFAULT_COLUMN_PADDING_RIGHT:()=>Nt,DEFAULT_COLUMN_PADDING_TOP:()=>vt,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,LINK_PROTOCOL_REGEX:()=>rt,Maily:()=>A,render:()=>_t});module.exports=pt(Lt);var P=require("react"),l=require("@react-email/components"),z=require("@react-email/render");var dt=u=>Object.prototype.toString.call(u);var ht=u=>dt(u)==="[object Object]";function mt(u){return Object.keys(u)}function J(u,...t){if(!t.length)return u;let e=t.shift();return e===void 0?u:(k(u)&&k(e)&&mt(e).forEach(n=>{n==="__proto__"||n==="constructor"||n==="prototype"||(k(e[n])?(u[n]||(u[n]={}),k(u[n])?J(u[n],e[n]):u[n]=e[n]):u[n]=e[n])}),J(u,...t))}function k(u){return ht(u)&&!Array.isArray(u)}var Dt=Symbol("p-void");function D(){return Math.random().toString(36).substr(2,6)}var r=require("react/jsx-runtime");var ft={sm:"8px",md:"16px",lg:"32px",xl:"64px"},M={WebkitFontSmoothing:"antialiased",MozOsxFontSmoothing:"grayscale"};var gt={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"},xt={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"}}},yt='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,St="100%",ot=8,bt="transparent",Ot=0,wt=0,Ct="transparent",vt=0,Nt=0,Et=0,Tt=0,rt=/https?:\/\//,A=class{constructor(t={type:"doc",content:[]}){this.config={theme:X};this.variableFormatter=({variable:t,fallback:e})=>e?`{{${t},fallback=${e}}}`:`{{${t}}}`;this.shouldReplaceVariableValues=!1;this.variableValues=new Map;this.linkValues=new Map;this.payloadValues=new Map;this.marksOrder=["underline","bold","italic","textStyle","link"];this.content=t}setPreviewText(t){this.config.preview=t}setTheme(t){this.config.theme=J(this.config.theme||X,t)}setVariableFormatter(t){this.variableFormatter=t}setVariableValue(t,e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.variableValues.set(t,e)}setVariableValues(t){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),Object.entries(t).forEach(([e,n])=>{this.setVariableValue(e,n)})}setLinkValue(t,e){this.linkValues.set(t,e)}setLinkValues(t){Object.entries(t).forEach(([e,n])=>{this.setLinkValue(e,n)})}setPayloadValue(t,e){this.shouldReplaceVariableValues||(this.shouldReplaceVariableValues=!0),this.payloadValues.set(t,e)}setPayloadValues(t){Object.entries(t).forEach(([e,n])=>{this.setPayloadValue(e,n)})}setOpenTrackingPixel(t){this.openTrackingPixel=t}setShouldReplaceVariableValues(t){this.shouldReplaceVariableValues=t}getAllLinks(){let t=this.content.content||[],e=new Set,n=i=>i&&this.isValidUrl(i)&&!i.startsWith("#")&&!i.startsWith("mailto:")&&!i.startsWith("tel:")&&typeof i=="string",o=i=>{var s;if(i.type==="button"){let a=(s=i.attrs)==null?void 0:s.url;n(a)&&a&&e.add(a)}else i.content&&i.content.forEach(a=>{a.marks&&a.marks.forEach(c=>{var p;let d=(p=c.attrs)==null?void 0:p.href;c.type==="link"&&n(d)&&e.add(d)}),a.content&&o(a)})};return t.forEach(i=>{o(i)}),e}isValidUrl(t){try{let e=new URL(t);return!0}catch(e){return!1}}render(){return L(this,arguments,function*(t=xt){let e=this.markup();return(0,z.renderAsync)(e,t)})}markup(){let t=this.content.content||[],e=t.map((i,s)=>{let a={prev:t[s-1],next:t[s+1],parent:i},c=this.renderNode(i,a);return c?(0,r.jsx)(P.Fragment,{children:c},D()):null}),{preview:n}=this.config;return(0,r.jsxs)(l.Html,{children:[(0,r.jsxs)(l.Head,{children:[(0,r.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,r.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,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)(l.Body,{style:{margin:0},children:[n?(0,r.jsx)(l.Preview,{id:"__react-email-preview",children:n}):null,(0,r.jsx)(l.Container,{style:{maxWidth:"600px",minWidth:"300px",width:"100%",marginLeft:"auto",marginRight:"auto",padding:"0.5rem"},children:e}),this.openTrackingPixel?(0,r.jsx)(l.Img,{alt:"",src:this.openTrackingPixel,style:{display:"none",width:"1px",height:"1px"}}):null]})]})}getMarginOverrideConditions(t,e){let{parent:n,prev:o,next:i}=e||{},s=(i==null?void 0:i.type)==="spacer",a=(o==null?void 0:o.type)==="spacer",c=(n==null?void 0:n.type)==="listItem",d=(n==null?void 0:n.type)==="section"&&!i,p=(n==null?void 0:n.type)==="section"&&!o,m=(n==null?void 0:n.type)==="column"&&!i,h=(n==null?void 0:n.type)==="column"&&!o,f=(n==null?void 0:n.type)==="for"&&!o,g=(n==null?void 0:n.type)==="for"&&!i,S=(n==null?void 0:n.type)==="show"&&!o,b=(n==null?void 0:n.type)==="show"&&!i;return{isNextSpacer:s,isPrevSpacer:a,isLastSectionElement:d,isFirstSectionElement:p,isParentListItem:c,isLastColumnElement:m,isFirstColumnElement:h,isFirstForElement:f,isLastForElement:g,isFirstShowElement:S,isLastShowElement:b,shouldRemoveTopMargin:a||p||h||f||S,shouldRemoveBottomMargin:s||d||m||g||b}}getMappedContent(t,e){let n=t.content||[];return n.map((o,i)=>{let s=this.renderNode(o,y(x({},e),{next:n[i+1],prev:n[i-1]}));return s?(0,r.jsx)(P.Fragment,{children:s},D()):null}).filter(o=>o!==null)}renderNode(t,e={}){var o;let n=t.type||"";if(n in this)return(o=this[n])==null?void 0:o.call(this,t,e);throw new Error(`Node type "${n}" is not supported.`)}renderMark(t,e){let n=(t==null?void 0:t.text)||(0,r.jsx)(r.Fragment,{children:"\xA0"}),o=(t==null?void 0:t.marks)||[];return o.sort((i,s)=>this.marksOrder.indexOf(i.type)-this.marksOrder.indexOf(s.type)),o.reduce((i,s)=>{var c;let a=s.type;if(a in this)return(c=this[a])==null?void 0:c.call(this,s,i);throw new Error(`Mark type "${a}" is not supported.`)},(0,r.jsx)(r.Fragment,{children:n}))}paragraph(t,e){var a,c,d,p;let{attrs:n}=t,o=(n==null?void 0:n.textAlign)||"left",{isParentListItem:i,shouldRemoveBottomMargin:s}=this.getMarginOverrideConditions(t,e);return(0,r.jsx)(l.Text,{style:x({textAlign:o,marginBottom:i||s?"0px":"20px",marginTop:"0px",fontSize:(c=(a=this.config.theme)==null?void 0:a.fontSize)==null?void 0:c.paragraph,color:(p=(d=this.config.theme)==null?void 0:d.colors)==null?void 0:p.paragraph},M),children:t.content?this.getMappedContent(t,y(x({},e),{parent:t})):(0,r.jsx)(r.Fragment,{children:"\xA0"})})}text(t,e){let n=t.text||" ";return t.marks?this.renderMark(t,e):(0,r.jsx)(r.Fragment,{children:n})}bold(t,e){return(0,r.jsx)("strong",{children:e})}italic(t,e){return(0,r.jsx)("em",{children:e})}underline(t,e){return(0,r.jsx)("u",{children:e})}strike(t,e){return(0,r.jsx)("s",{style:{textDecoration:"line-through"},children:e})}textStyle(t,e){var i,s;let{attrs:n}=t,{color:o=(s=(i=this.config.theme)==null?void 0:i.colors)==null?void 0:s.paragraph}=n||{};return(0,r.jsx)("span",{style:{color:o},children:e})}link(t,e,n){var d,p,m;let{attrs:o}=t,i=(o==null?void 0:o.href)||"#",s=(o==null?void 0:o.target)||"_blank",a=(o==null?void 0:o.rel)||"noopener noreferrer nofollow";if((d=o==null?void 0:o.isUrlVariable)!=null?d:!1){let h=this.removeLinkProtocol(i);i=this.variableUrlValue(h,n)}else i=this.linkValues.get(i)||i;return(0,r.jsx)(l.Link,{href:i,rel:a,style:{fontWeight:500,textDecoration:"none",color:(m=(p=this.config.theme)==null?void 0:p.colors)==null?void 0:m.heading},target:s,children:e})}removeLinkProtocol(t){return t.replace(rt,"")}variableUrlValue(t,e){var i,s;let{payloadValue:n}=e||{},o=this.removeLinkProtocol(t);return(s=(i=typeof n=="object"?n[o]:n)!=null?i:this.variableValues.get(o))!=null?s:t}heading(t,e){var p,m;let{attrs:n}=t,o=`h${Number(n==null?void 0:n.level)||1}`,i=(n==null?void 0:n.textAlign)||"left",{shouldRemoveBottomMargin:s}=this.getMarginOverrideConditions(t,e),{fontSize:a,lineHeight:c,fontWeight:d}=gt[o];return(0,r.jsx)(l.Heading,{as:o,style:{textAlign:i,color:(m=(p=this.config.theme)==null?void 0:p.colors)==null?void 0:m.heading,marginBottom:s?"0":"12px",marginTop:0,fontSize:a,lineHeight:c,fontWeight:d},children:this.getMappedContent(t,y(x({},e),{parent:t}))})}variable(t,e){var c,d,p;let{payloadValue:n}=e||{},{id:o,fallback:i}=t.attrs||{};if(!this.shouldShow(t,e)||!o)return(0,r.jsx)(r.Fragment,{});let a=this.variableFormatter({variable:o,fallback:i});return this.shouldReplaceVariableValues&&(a=(p=(d=(c=typeof n=="object"?n[o]:n)!=null?c:this.variableValues.get(o))!=null?d:i)!=null?p:a),t!=null&&t.marks?this.renderMark({text:a,marks:t.marks},e):(0,r.jsx)(r.Fragment,{children:a})}horizontalRule(t,e){return(0,r.jsx)(l.Hr,{style:{marginTop:"32px",marginBottom:"32px"}})}orderedList(t,e){let{shouldRemoveBottomMargin:n}=this.getMarginOverrideConditions(t,e);return(0,r.jsx)(l.Container,{children:(0,r.jsx)("ol",{style:{marginTop:"0px",marginBottom:n?"0":"20px",paddingLeft:"26px",listStyleType:"decimal"},children:this.getMappedContent(t,y(x({},e),{parent:t}))})})}bulletList(t,e){let{parent:n,next:o}=e||{},{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(t,{parent:n,next:o});return(0,r.jsx)(l.Container,{style:{maxWidth:"100%"},children:(0,r.jsx)("ul",{style:{marginTop:"0px",marginBottom:i?"0":"20px",paddingLeft:"26px",listStyleType:"disc"},children:this.getMappedContent(t,y(x({},e),{parent:t}))})})}listItem(t,e){return(0,r.jsx)("li",{style:x({marginBottom:"8px",paddingLeft:"6px"},M),children:this.getMappedContent(t,y(x({},e),{parent:t}))})}button(t,e){let{attrs:n}=t,{text:o,isTextVariable:i,url:s,isUrlVariable:a,variant:c,buttonColor:d,textColor:p,borderRadius:m,alignment:h="left"}=n||{};if(!this.shouldShow(t,e))return(0,r.jsx)(r.Fragment,{});let g="0px";m==="round"?g="9999px":m==="smooth"&&(g="6px");let{shouldRemoveBottomMargin:S}=this.getMarginOverrideConditions(t,e),b=a?this.variableUrlValue(s,e):this.linkValues.get(s)||s,O=i?this.variableUrlValue(o,e):o;return(0,r.jsx)(l.Container,{style:{textAlign:h,maxWidth:"100%",marginBottom:S?"0px":"20px"},children:(0,r.jsx)(l.Button,{href:b,style:{color:String(p),backgroundColor:c==="filled"?String(d):"transparent",borderColor:String(d),padding:c==="filled"?"12px 34px":"10px 34px",borderWidth:"2px",borderStyle:"solid",textDecoration:"none",fontSize:"14px",fontWeight:500,borderRadius:g},children:O})})}spacer(t,e){let{attrs:n}=t,{height:o="auto"}=n||{};return this.shouldShow(t,e)?(0,r.jsx)(l.Container,{style:{height:ft[o]||o}}):(0,r.jsx)(r.Fragment,{})}hardBreak(t,e){return(0,r.jsx)("br",{})}logo(t,e){let{attrs:n}=t,{src:o,isSrcVariable:i,alt:s,title:a,size:c,alignment:d="left"}=n||{};if(!this.shouldShow(t,e))return(0,r.jsx)(r.Fragment,{});o=i?this.variableUrlValue(o,e):o;let{shouldRemoveBottomMargin:m}=this.getMarginOverrideConditions(t,e);return(0,r.jsx)(l.Row,{style:{marginTop:"0px",marginBottom:m?"0px":"32px"},children:(0,r.jsx)(l.Column,{align:d,children:(0,r.jsx)(l.Img,{alt:s||a||"Logo",src:o,style:{width:W[c]||c,height:W[c]||c},title:a||s||"Logo"})})})}image(t,e){let{attrs:n}=t,{src:o,isSrcVariable:i,alt:s,title:a,width:c="auto",alignment:d="center",externalLink:p="",isExternalLinkVariable:m}=n||{};if(!this.shouldShow(t,e))return(0,r.jsx)(r.Fragment,{});let{shouldRemoveBottomMargin:f}=this.getMarginOverrideConditions(t,e);o=i?this.variableUrlValue(o,e):o,p=m?this.variableUrlValue(p,e):p;let g=c==="auto"?"auto":Number(c),S=g==="auto"?"auto":`${g}px`,b=(0,r.jsx)(l.Img,{alt:s||a||"Image",src:o,style:{width:S,maxWidth:"100%",outline:"none",border:"none",textDecoration:"none",display:"block"},title:a||s||"Image"});return(0,r.jsx)(l.Row,{style:{marginTop:"0px",marginBottom:f?"0px":"32px"},children:(0,r.jsx)(l.Column,{align:d,children:p?(0,r.jsx)("a",{href:p,rel:"noopener noreferrer",style:{display:"block",maxWidth:"100%",textDecoration:"none"},target:"_blank",children:b}):b})})}footer(t,e){var s,a,c,d,p,m,h,f;let{attrs:n}=t,{textAlign:o="left"}=n||{},{shouldRemoveBottomMargin:i}=this.getMarginOverrideConditions(t,e);return(0,r.jsx)(l.Text,{style:x({fontSize:(c=(a=(s=this.config.theme)==null?void 0:s.fontSize)==null?void 0:a.footer)==null?void 0:c.size,lineHeight:(m=(p=(d=this.config.theme)==null?void 0:d.fontSize)==null?void 0:p.footer)==null?void 0:m.lineHeight,color:(f=(h=this.config.theme)==null?void 0:h.colors)==null?void 0:f.footer,marginTop:"0px",marginBottom:i?"0px":"20px",textAlign:o},M),children:this.getMappedContent(t,y(x({},e),{parent:t}))})}blockquote(t,e){var i,s;let{isPrevSpacer:n,shouldRemoveBottomMargin:o}=this.getMarginOverrideConditions(t,e);return(0,r.jsx)("blockquote",{style:{borderLeftWidth:"4px",borderLeftStyle:"solid",borderLeftColor:(s=(i=this.config.theme)==null?void 0:i.colors)==null?void 0:s.blockquoteBorder,paddingLeft:"16px",marginLeft:"0px",marginRight:"0px",marginTop:n?"0px":"20px",marginBottom:o?"0px":"20px"},children:this.getMappedContent(t,y(x({},e),{parent:t}))})}code(t,e){var n,o,i,s;return(0,r.jsx)("code",{style:{backgroundColor:(o=(n=this.config.theme)==null?void 0:n.colors)==null?void 0:o.codeBackground,color:(s=(i=this.config.theme)==null?void 0:i.colors)==null?void 0:s.codeText,padding:"2px 4px",borderRadius:"6px",fontFamily:yt,fontWeight:400,letterSpacing:0},children:e})}linkCard(t,e){var f,g,S,b,O,w,C,N,E,T,v,_;let{attrs:n}=t,{shouldRemoveBottomMargin:o}=this.getMarginOverrideConditions(t,e),{title:i,description:s,link:a,linkTitle:c,image:d,badgeText:p,subTitle:m}=n||{},h=this.linkValues.get(a)||this.variableValues.get(a)||a||"#";return(0,r.jsxs)("a",{href:h,rel:"noopener noreferrer",style:{border:"1px solid #eaeaea",borderRadius:"10px",textDecoration:"none",color:"inherit",display:"block",marginBottom:o?"0px":"20px"},target:"_blank",children:[d?(0,r.jsx)(l.Row,{style:{marginBottom:"6px"},children:(0,r.jsx)(l.Column,{style:{width:"100%",height:"100%"},children:(0,r.jsx)(l.Img,{alt:i||"Link Card",src:d,style:{borderRadius:"10px 10px 0 0",width:"100%",height:"100%",objectFit:"cover"},title:i||"Link Card"})})}):null,(0,r.jsx)(l.Row,{style:{padding:"15px",marginTop:0,marginBottom:0},children:(0,r.jsxs)(l.Column,{style:{verticalAlign:"top"},children:[(0,r.jsxs)(l.Row,{align:void 0,style:{marginBottom:"8px",marginTop:"0px"},width:"auto",children:[(0,r.jsx)(l.Column,{children:(0,r.jsx)(l.Text,{style:x({fontSize:"18px",fontWeight:600,color:(g=(f=this.config.theme)==null?void 0:f.colors)==null?void 0:g.linkCardTitle,margin:"0px"},M),children:i})}),p||m?(0,r.jsxs)(l.Column,{style:{paddingLeft:"6px",verticalAlign:"middle"},children:[p?(0,r.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:(w=(O=this.config.theme)==null?void 0:O.colors)==null?void 0:w.linkCardBadgeBackground,fontSize:"12px",lineHeight:"12px"},children:p}):null," ",m&&!p?(0,r.jsx)("span",{style:{fontWeight:"normal",color:(N=(C=this.config.theme)==null?void 0:C.colors)==null?void 0:N.linkCardSubTitle,fontSize:"12px",lineHeight:"12px"},children:m}):null]}):null]}),(0,r.jsxs)(l.Text,{style:x({fontSize:"16px",color:(T=(E=this.config.theme)==null?void 0:E.colors)==null?void 0:T.linkCardDescription,marginTop:"0px",marginBottom:"0px"},M),children:[s," ",c?(0,r.jsx)("a",{href:h,rel:"noopener noreferrer",style:{color:(_=(v=this.config.theme)==null?void 0:v.colors)==null?void 0:_.linkCardTitle,fontSize:"14px",fontWeight:600,textDecoration:"underline"},children:c}):null]})]})})]})}section(t,e){let{attrs:n}=t,{borderRadius:o=0,backgroundColor:i=j,align:s=H,borderWidth:a=G,borderColor:c=q,marginTop:d=$,marginRight:p=K,marginBottom:m=Y,marginLeft:h=Q,paddingTop:f=Z,paddingRight:g=tt,paddingBottom:S=et,paddingLeft:b=nt}=n||{};return this.shouldShow(t,e)?(0,r.jsx)(l.Row,{style:{marginTop:d,marginRight:p,marginBottom:m,marginLeft:h},children:(0,r.jsx)(l.Column,{align:s,style:{borderColor:c,borderWidth:a,borderStyle:"solid",backgroundColor:i,borderRadius:o,paddingTop:f,paddingRight:g,paddingBottom:S,paddingLeft:b},children:this.getMappedContent(t,y(x({},e),{parent:t}))})}):(0,r.jsx)(r.Fragment,{})}columns(t,e){let{attrs:n}=t;if(!this.shouldShow(t,e))return(0,r.jsx)(r.Fragment,{});let[i,s]=this.adjustColumnsContent(t);return(0,r.jsx)(l.Row,{width:`${s}%`,style:{margin:0,padding:0,width:`${s}%`},className:"tab-row-full",children:this.getMappedContent(i,y(x({},e),{parent:i}))})}adjustColumnsContent(t){var m;let{content:e=[]}=t,n=100,o=e.filter(h=>{var f;return h.type==="column"&&!!Number(((f=h.attrs)==null?void 0:f.width)||0)}),i=e.filter(h=>{var f,g;return h.type==="column"&&(((f=h.attrs)==null?void 0:f.width)==="auto"||!((g=h.attrs)!=null&&g.width))}),s=o.reduce((h,f)=>{var g;return h+Number((g=f.attrs)==null?void 0:g.width)},0),a=n-s,c=Math.round(a/i.length),d=e.filter(h=>h.type==="column").length,p=((m=t.attrs)==null?void 0:m.gap)||ot;return[y(x({},t),{content:e.map((h,f)=>{var N,E,T;let g=h.type==="column"&&(((N=h.attrs)==null?void 0:N.width)==="auto"||!((E=h.attrs)!=null&&E.width)),S=f===0,b=f>0&&f<d-1,O=f===e.length-1,w=0,C=0;if(d<3)w=S?0:p/2,C=O?0:p/2;else{let v=p/2*1.5,_=v/2;w=S?0:b?_:v,C=O?0:b?_:v}return w=Math.round(w*100)/100,C=Math.round(C*100)/100,y(x({},h),{attrs:y(x({},h.attrs),{width:g?c:(T=h.attrs)==null?void 0:T.width,isFirstColumn:S,isLastColumn:O,index:f,paddingLeft:w,paddingRight:C})})})}),i.length===0?Math.min(n,s):n]}column(t,e){let{attrs:n}=t,{width:o,verticalAlign:i="top",paddingLeft:s=0,paddingRight:a=0}=n||{};return(0,r.jsx)(l.Column,{width:`${Number(o)}%`,style:{width:`${Number(o)}%`,margin:0,verticalAlign:i},className:"tab-col-full",children:(0,r.jsx)(l.Section,{style:{margin:0,paddingLeft:s,paddingRight:a},className:"tab-pad",children:this.getMappedContent(t,y(x({},e),{parent:t}))})})}for(t,e){var c,d;let{attrs:n}=t,{each:o=""}=n||{};if(!this.shouldShow(t,e))return(0,r.jsx)(r.Fragment,{});let{payloadValue:s}=e||{};s=typeof s=="object"?s:{};let a=(d=(c=this.payloadValues.get(o))!=null?c:s[o])!=null?d:[];if(!Array.isArray(a))throw new Error(`Payload value for each "${o}" is not an array`);return(0,r.jsx)(r.Fragment,{children:a.map(p=>(0,r.jsx)(P.Fragment,{children:this.getMappedContent(t,y(x({},e),{parent:t,payloadValue:p}))},D()))})}shouldShow(t,e){var i,s,a;let n=(s=(i=t==null?void 0:t.attrs)==null?void 0:i.showIfKey)!=null?s:"";if(!n)return!0;let{payloadValue:o}=e||{};return o=typeof o=="object"?o:{},!!((a=this.payloadValues.get(n))!=null?a:o[n])}};function _t(u,t){return L(this,null,function*(){let s=t||{},{theme:e,preview:n}=s,o=U(s,["theme","preview"]),i=new A(u);return i.setPreviewText(n),i.setTheme(e||{}),i.setPayloadValue("items",[{name:"John Doe"},{name:"Novu"}]),i.setPayloadValue("shouldShow",!0),i.render(o)})}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,LINK_PROTOCOL_REGEX,Maily,render});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|