@vtex-email/react 0.2.0 → 0.4.0
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/adapter/email.d.ts +21 -3
- package/dist/adapter/email.d.ts.map +1 -1
- package/dist/compile/compile-email.d.ts.map +1 -1
- package/dist/compile/session.d.ts +2 -0
- package/dist/compile/session.d.ts.map +1 -1
- package/dist/dsl/attributes.d.ts +18 -11
- package/dist/dsl/attributes.d.ts.map +1 -1
- package/dist/dsl/blocks.d.ts +32 -7
- package/dist/dsl/blocks.d.ts.map +1 -1
- package/dist/dsl/values.d.ts +10 -1
- package/dist/dsl/values.d.ts.map +1 -1
- package/dist/dsl/vtex.d.ts +9 -4
- package/dist/dsl/vtex.d.ts.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +189 -77
- package/package.json +3 -3
package/dist/adapter/email.d.ts
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
export
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export interface EmailProps {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
className?: string;
|
|
5
|
-
|
|
5
|
+
/** Extra nodes for `<head>` (`<title>`, `<style>`, font `<link>`s). Rendered after the React Email defaults. */
|
|
6
|
+
head?: ReactNode;
|
|
7
|
+
/** Extra attributes for `<html>` (for example `xmlns:o` for Outlook). `lang` defaults to the compiled locale. */
|
|
8
|
+
htmlAttributes?: Readonly<Record<string, string>>;
|
|
9
|
+
/** Inline style for `<body>`. */
|
|
10
|
+
bodyStyle?: CSSProperties;
|
|
11
|
+
/**
|
|
12
|
+
* React Email wraps the body content in a full-width presentation table and moves the body style to its cell.
|
|
13
|
+
* `false` writes a plain `<body>` with `bodyStyle` on it, for migrations that must keep an existing structure.
|
|
14
|
+
*/
|
|
15
|
+
bodyTable?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Document type declaration. Defaults to React Email's XHTML 1.0 Transitional (standards-like rendering).
|
|
18
|
+
* `null` writes none, which puts browsers and WebKit-based clients in quirks mode; use it only to keep the
|
|
19
|
+
* rendering of a legacy template that shipped without a doctype.
|
|
20
|
+
*/
|
|
21
|
+
doctype?: string | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function Email({ children, className, head, htmlAttributes, bodyStyle, bodyTable, doctype }: EmailProps): import("react/jsx-runtime").JSX.Element;
|
|
6
24
|
//# sourceMappingURL=email.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/adapter/email.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/adapter/email.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMrD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,SAAS,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gHAAgH;IAChH,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,iHAAiH;IACjH,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACjD,iCAAiC;IACjC,SAAS,CAAC,EAAE,aAAa,CAAA;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB;AAED,wBAAgB,KAAK,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,SAAgB,EAAE,OAAO,EAAE,EAAE,UAAU,2CAmBpH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-email.d.ts","sourceRoot":"","sources":["../../src/compile/compile-email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAKL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIrD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAE3F,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,aAAa,CAAC,MAAM,SAAS,CAAC,CAAA;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,cAAc,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"compile-email.d.ts","sourceRoot":"","sources":["../../src/compile/compile-email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAKL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAIrD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAE3F,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,aAAa,CAAC,MAAM,SAAS,CAAC,CAAA;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,cAAc,CAAA;IACxB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA2CxF"}
|
|
@@ -15,6 +15,8 @@ export interface Session {
|
|
|
15
15
|
nextIndex: number;
|
|
16
16
|
templateId: string;
|
|
17
17
|
file?: string;
|
|
18
|
+
/** Doctype requested by the Email adapter. undefined keeps the React Email default; null writes none. */
|
|
19
|
+
doctype?: string | null;
|
|
18
20
|
}
|
|
19
21
|
export declare function createSession(input: Omit<Session, 'markers' | 'sites' | 'diagnostics' | 'nextIndex'>): Session;
|
|
20
22
|
export declare function getSession(): Session;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/compile/session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAE7D,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAA;AAGzB,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,WAAW,EAAE,UAAU,EAAE,CAAA;gBAEtB,WAAW,EAAE,UAAU,EAAE;CAKtC;AAED,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IACzC,OAAO,EAAE,eAAe,CAAA;IACxB,QAAQ,EAAE,cAAc,CAAA;IACxB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC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O,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAE/D;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,KAAK,CAGrE;AAED,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACxD,MAAM,EAAE,MAAM,GACb,MAAM,CAmBR;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAE5E"}
|
package/dist/dsl/attributes.d.ts
CHANGED
|
@@ -2,24 +2,31 @@ import type { DynamicAttribute } from '@vtex-email/core';
|
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import { type Session } from '../compile/session';
|
|
4
4
|
import { type Expression } from './expr';
|
|
5
|
-
export
|
|
5
|
+
export type AttributeValue = string | Expression | ReadonlyArray<string | Expression>;
|
|
6
|
+
/**
|
|
7
|
+
* Value for a dynamic `href`, `src`, `alt`, or `title` on any element (`<a href={Vtex.attr('href', [...])}>`).
|
|
8
|
+
* Accepts a static string, an expression, or a composite of literals and paths. Static `href`/`src` must be
|
|
9
|
+
* https, mailto, or tel.
|
|
10
|
+
*/
|
|
11
|
+
export declare function attributeToken(name: DynamicAttribute, value: AttributeValue): string;
|
|
6
12
|
export declare function rejectClassExpression(className: string | Expression | undefined, session: Session): string | undefined;
|
|
7
13
|
export declare function DynamicLink({ href, title, children, className, }: {
|
|
8
|
-
href:
|
|
9
|
-
title?:
|
|
14
|
+
href: AttributeValue;
|
|
15
|
+
title?: AttributeValue;
|
|
10
16
|
children?: ReactNode;
|
|
11
17
|
className?: string | Expression;
|
|
12
18
|
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
-
export declare function DynamicImg({ src, alt, title, width, height, }: {
|
|
14
|
-
src:
|
|
15
|
-
alt:
|
|
16
|
-
title?:
|
|
17
|
-
width
|
|
18
|
-
height
|
|
19
|
+
export declare function DynamicImg({ src, alt, title, width, height, style, }: {
|
|
20
|
+
src: AttributeValue;
|
|
21
|
+
alt: AttributeValue;
|
|
22
|
+
title?: AttributeValue;
|
|
23
|
+
width?: number | `${number}`;
|
|
24
|
+
height?: number | `${number}`;
|
|
25
|
+
style?: React.CSSProperties;
|
|
19
26
|
}): import("react/jsx-runtime").JSX.Element;
|
|
20
27
|
export declare function DynamicButton({ href, title, children, className, }: {
|
|
21
|
-
href:
|
|
22
|
-
title?:
|
|
28
|
+
href: AttributeValue;
|
|
29
|
+
title?: AttributeValue;
|
|
23
30
|
children?: ReactNode;
|
|
24
31
|
className?: string | Expression;
|
|
25
32
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/dsl/attributes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/dsl/attributes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAgB,MAAM,kBAAkB,CAAA;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAKtC,OAAO,EAAkC,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AAGtD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,aAAa,CAAC,MAAM,GAAG,UAAU,CAAC,CAAA;AAmCrF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,cAAc,GAAG,MAAM,CAuDpF;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,EAC1C,OAAO,EAAE,OAAO,GACf,MAAM,GAAG,SAAS,CAMpB;AAED,wBAAgB,WAAW,CAAC,EAC1B,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,GACV,EAAE;IACD,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;CAChC,2CAWA;AAED,wBAAgB,UAAU,CAAC,EACzB,GAAG,EACH,GAAG,EACH,KAAK,EACL,KAAK,EACL,MAAM,EACN,KAAK,GACN,EAAE;IACD,GAAG,EAAE,cAAc,CAAA;IACnB,GAAG,EAAE,cAAc,CAAA;IACnB,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG,MAAM,EAAE,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,GAAG,MAAM,EAAE,CAAA;IAC7B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;CAC5B,2CAWA;AAED,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,GACV,EAAE;IACD,IAAI,EAAE,cAAc,CAAA;IACpB,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,QAAQ,CAAC,EAAE,SAAS,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;CAChC,2CAWA"}
|
package/dist/dsl/blocks.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { BlockName, SiteArgument, SiteHash } from '@vtex-email/core';
|
|
2
2
|
import { type ReactElement, type ReactNode } from 'react';
|
|
3
3
|
import { type Expression } from './expr';
|
|
4
|
+
/** Compiler-owned host for block regions. Authors never see or forward this. */
|
|
5
|
+
export declare const BLOCK_HOST = "vtx-anchor";
|
|
4
6
|
export declare function stamp(children: ReactNode, token: string): ReactElement;
|
|
5
7
|
export declare function openRegion(path: string, block: BlockName, hasElse: boolean, extras?: {
|
|
6
8
|
args?: readonly SiteArgument[];
|
|
@@ -28,22 +30,26 @@ export declare function Unless({ path, children, fallback }: {
|
|
|
28
30
|
children: ReactNode;
|
|
29
31
|
fallback?: ReactNode;
|
|
30
32
|
}): ReactNode;
|
|
31
|
-
|
|
33
|
+
type ComparisonOperator = '==' | '===' | '!=' | '<' | '<=' | '>' | '>=';
|
|
34
|
+
export declare function IfCond({ path, operator, value, right, children, fallback, }: {
|
|
32
35
|
path: string;
|
|
33
|
-
operator:
|
|
34
|
-
value
|
|
36
|
+
operator: ComparisonOperator;
|
|
37
|
+
value?: string | number | boolean | null;
|
|
38
|
+
right?: Expression | string | number | boolean | null;
|
|
35
39
|
children: ReactNode;
|
|
36
40
|
fallback?: ReactNode;
|
|
37
41
|
}): ReactNode;
|
|
38
|
-
export declare function HasSubStr({ path, value, children, fallback, }: {
|
|
42
|
+
export declare function HasSubStr({ path, value, search, children, fallback, }: {
|
|
39
43
|
path: string;
|
|
40
|
-
value
|
|
44
|
+
value?: string;
|
|
45
|
+
search?: Expression | string;
|
|
41
46
|
children: ReactNode;
|
|
42
47
|
fallback?: ReactNode;
|
|
43
48
|
}): ReactNode;
|
|
44
|
-
export declare function Eq({ path, value, children, fallback, }: {
|
|
49
|
+
export declare function Eq({ path, value, right, children, fallback, }: {
|
|
45
50
|
path: string;
|
|
46
|
-
value
|
|
51
|
+
value?: string | number | boolean | null;
|
|
52
|
+
right?: Expression | string | number | boolean | null;
|
|
47
53
|
children: ReactNode;
|
|
48
54
|
fallback?: ReactNode;
|
|
49
55
|
}): ReactNode;
|
|
@@ -53,5 +59,24 @@ export declare function Group({ path, by, children, fallback, }: {
|
|
|
53
59
|
children: ReactNode;
|
|
54
60
|
fallback?: ReactNode;
|
|
55
61
|
}): ReactNode;
|
|
62
|
+
export declare function With({ path, children, fallback }: {
|
|
63
|
+
path: string;
|
|
64
|
+
children: ReactNode;
|
|
65
|
+
fallback?: ReactNode;
|
|
66
|
+
}): ReactNode;
|
|
67
|
+
type MathOperator = '+' | '-' | '*' | '/' | '%';
|
|
68
|
+
export declare function Math({ path, left, operator, right, form, children, }: {
|
|
69
|
+
path?: string;
|
|
70
|
+
left?: Expression | string | number;
|
|
71
|
+
operator: MathOperator;
|
|
72
|
+
right: Expression | string | number;
|
|
73
|
+
form?: 'inline' | 'block';
|
|
74
|
+
children?: ReactNode;
|
|
75
|
+
}): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
76
|
+
export declare function RichShippingData({ path, children, fallback, }: {
|
|
77
|
+
path: string;
|
|
78
|
+
children: ReactNode;
|
|
79
|
+
fallback?: ReactNode;
|
|
80
|
+
}): ReactNode;
|
|
56
81
|
export type { Expression };
|
|
57
82
|
//# sourceMappingURL=blocks.d.ts.map
|
package/dist/dsl/blocks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/dsl/blocks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAErF,OAAO,
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/dsl/blocks.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAc,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAErF,OAAO,EAAiB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAGxE,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AAI9C,gFAAgF;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ACF,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,aAQA;AAED,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,aAE7G;AAED,KAAK,YAAY,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAE/C,wBAAgB,IAAI,CAAC,EACnB,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,KAAK,EACL,IAAe,EACf,QAAQ,GACT,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;IACnC,QAAQ,EAAE,YAAY,CAAA;IACtB,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,CAAA;IACnC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAA;IACzB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,2TAeA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,aAEA;AAED,YAAY,EAAE,UAAU,EAAE,CAAA"}
|
package/dist/dsl/values.d.ts
CHANGED
|
@@ -4,8 +4,17 @@ export declare function Value({ path }: {
|
|
|
4
4
|
}): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
5
5
|
export declare function textValue(path: string): ReactElement;
|
|
6
6
|
export declare function textLiteral(value: string | number | boolean | null): ReactElement;
|
|
7
|
-
export declare function Helper({ name, args }: {
|
|
7
|
+
export declare function Helper({ name, args, hash, }: {
|
|
8
8
|
name: string;
|
|
9
9
|
args: readonly unknown[];
|
|
10
|
+
hash?: Readonly<Record<string, unknown>>;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
/**
|
|
13
|
+
* VTEX eval: runs `code` on the destination after replacing each `${name}` with the matching `vars` value, and
|
|
14
|
+
* prints the result. Emits `{{#eval "code" name=path}}{{/eval}}`. The result is not escaped, so it may carry markup.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Eval({ code, vars }: {
|
|
17
|
+
code: string;
|
|
18
|
+
vars?: Readonly<Record<string, unknown>>;
|
|
10
19
|
}): import("react/jsx-runtime").JSX.Element;
|
|
11
20
|
//# sourceMappingURL=values.d.ts.map
|
package/dist/dsl/values.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/dsl/values.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/dsl/values.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAQzC,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,8EAE/C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAapD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,YAAY,CAajF;AAED,wBAAgB,MAAM,CAAC,EACrB,IAAI,EACJ,IAAI,EACJ,IAAI,GACL,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,SAAS,OAAO,EAAE,CAAA;IACxB,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACzC,2CAwBA;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,IAAS,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CAAE,2CAEnG"}
|
package/dist/dsl/vtex.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DynamicButton, DynamicImg, DynamicLink } from './attributes';
|
|
2
|
-
import { Each, Eq, Group, HasSubStr, If, IfCond, Unless } from './blocks';
|
|
1
|
+
import { attributeToken, DynamicButton, DynamicImg, DynamicLink } from './attributes';
|
|
2
|
+
import { Each, Eq, Group, HasSubStr, If, IfCond, Math, RichShippingData, Unless, With } from './blocks';
|
|
3
3
|
import { expr } from './expr';
|
|
4
4
|
import { Trans } from './trans';
|
|
5
|
-
import { Helper, Value } from './values';
|
|
5
|
+
import { Eval, Helper, Value } from './values';
|
|
6
6
|
export declare const Vtex: {
|
|
7
7
|
Each: typeof Each;
|
|
8
8
|
If: typeof If;
|
|
@@ -11,11 +11,16 @@ export declare const Vtex: {
|
|
|
11
11
|
HasSubStr: typeof HasSubStr;
|
|
12
12
|
Group: typeof Group;
|
|
13
13
|
Eq: typeof Eq;
|
|
14
|
+
With: typeof With;
|
|
15
|
+
Math: typeof Math;
|
|
16
|
+
RichShippingData: typeof RichShippingData;
|
|
14
17
|
Value: typeof Value;
|
|
15
18
|
Helper: typeof Helper;
|
|
19
|
+
Eval: typeof Eval;
|
|
16
20
|
Link: typeof DynamicLink;
|
|
17
21
|
Img: typeof DynamicImg;
|
|
18
22
|
Button: typeof DynamicButton;
|
|
23
|
+
attr: typeof attributeToken;
|
|
19
24
|
};
|
|
20
|
-
export { Each, Eq, expr, Group, HasSubStr, Helper, If, IfCond, Trans, Unless, Value };
|
|
25
|
+
export { Each, Eq, Eval, expr, Group, HasSubStr, Helper, If, IfCond, Math, RichShippingData, Trans, Unless, Value, With, };
|
|
21
26
|
//# sourceMappingURL=vtex.d.ts.map
|
package/dist/dsl/vtex.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vtex.d.ts","sourceRoot":"","sources":["../../src/dsl/vtex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"vtex.d.ts","sourceRoot":"","sources":["../../src/dsl/vtex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AACrF,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AACvG,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAE9C,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;CAkBhB,CAAA;AAED,OAAO,EACL,IAAI,EACJ,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,SAAS,EACT,MAAM,EACN,EAAE,EACF,MAAM,EACN,IAAI,EACJ,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,KAAK,EACL,IAAI,GACL,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { Email } from './adapter/email';
|
|
1
|
+
export { Email, type EmailProps } from './adapter/email';
|
|
2
2
|
export { diagnoseStyles } from './adapter/style-diagnostics';
|
|
3
3
|
export { compileEmail, type BuildManifest, type CompiledArtifact, type CompileEmailInput, type CompileEmailResult, } from './compile/compile-email';
|
|
4
|
+
export { attributeToken, type AttributeValue } from './dsl/attributes';
|
|
4
5
|
export { isExpression, type Expression } from './dsl/expr';
|
|
5
|
-
export { Each, Eq, expr, Group, HasSubStr, Helper, If, IfCond, Trans, Unless, Value, Vtex } from './dsl/vtex';
|
|
6
|
+
export { Each, Eq, Eval, expr, Group, HasSubStr, Helper, If, IfCond, Math, RichShippingData, Trans, Unless, Value, Vtex, With, } from './dsl/vtex';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAC5D,OAAO,EACL,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,EACL,IAAI,EACJ,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,SAAS,EACT,MAAM,EACN,EAAE,EACF,MAAM,EACN,IAAI,EACJ,gBAAgB,EAChB,KAAK,EACL,MAAM,EACN,KAAK,EACL,IAAI,EACJ,IAAI,GACL,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -64,11 +64,12 @@ function addSite(session, id, site) {
|
|
|
64
64
|
|
|
65
65
|
// src/adapter/email.tsx
|
|
66
66
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
67
|
-
function Email({ children, className }) {
|
|
67
|
+
function Email({ children, className, head, htmlAttributes, bodyStyle, bodyTable = true, doctype }) {
|
|
68
68
|
const session = getSession();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/* @__PURE__ */ jsx(
|
|
69
|
+
if (doctype !== void 0) session.doctype = doctype;
|
|
70
|
+
return /* @__PURE__ */ jsx(Html, { lang: session.locale, ...htmlAttributes, children: /* @__PURE__ */ jsxs(Tailwind, { config: session.tailwind, children: [
|
|
71
|
+
/* @__PURE__ */ jsx(Head, { children: head }),
|
|
72
|
+
bodyTable ? /* @__PURE__ */ jsx(Body, { className, ...bodyStyle ? { style: bodyStyle } : {}, children }) : /* @__PURE__ */ jsx("body", { className, style: bodyStyle, children })
|
|
72
73
|
] }) });
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -159,6 +160,7 @@ async function compileEmail(input) {
|
|
|
159
160
|
throw error;
|
|
160
161
|
}
|
|
161
162
|
if (session.diagnostics.length > 0) return fail(session.diagnostics);
|
|
163
|
+
if (session.doctype !== void 0) html = replaceDoctype(html, session.doctype);
|
|
162
164
|
return assembleDocument({
|
|
163
165
|
html,
|
|
164
166
|
markers: session.markers,
|
|
@@ -169,6 +171,11 @@ async function compileEmail(input) {
|
|
|
169
171
|
locale: input.locale
|
|
170
172
|
});
|
|
171
173
|
}
|
|
174
|
+
var LEADING_DOCTYPE = /^\s*<!DOCTYPE[^>]*>/i;
|
|
175
|
+
function replaceDoctype(html, doctype) {
|
|
176
|
+
const body = html.replace(LEADING_DOCTYPE, "");
|
|
177
|
+
return doctype === null ? body : `${doctype}${body}`;
|
|
178
|
+
}
|
|
172
179
|
function fail(diagnostics) {
|
|
173
180
|
return { ok: false, diagnostics };
|
|
174
181
|
}
|
|
@@ -188,6 +195,10 @@ function readAborted(error) {
|
|
|
188
195
|
return null;
|
|
189
196
|
}
|
|
190
197
|
|
|
198
|
+
// src/dsl/attributes.tsx
|
|
199
|
+
import { Button as EmailButton, Img as EmailImg, Link as EmailLink } from "@react-email/components";
|
|
200
|
+
import { emitLiteral as emitLiteral2 } from "@vtex-email/core";
|
|
201
|
+
|
|
191
202
|
// src/dsl/expr.ts
|
|
192
203
|
var brand = /* @__PURE__ */ Symbol("vtex-email.expression");
|
|
193
204
|
function isExpression(value) {
|
|
@@ -202,10 +213,6 @@ var expr = {
|
|
|
202
213
|
}
|
|
203
214
|
};
|
|
204
215
|
|
|
205
|
-
// src/dsl/attributes.tsx
|
|
206
|
-
import { Button as EmailButton, Img as EmailImg, Link as EmailLink } from "@react-email/components";
|
|
207
|
-
import { emitLiteral as emitLiteral2 } from "@vtex-email/core";
|
|
208
|
-
|
|
209
216
|
// src/dsl/resolve.ts
|
|
210
217
|
import { emitLiteral, errorDiagnostic as errorDiagnostic4, parentHops, parsePath } from "@vtex-email/core";
|
|
211
218
|
function dslFailure(session, code, message, extra = {}) {
|
|
@@ -248,12 +255,52 @@ function assertStaticUrl(value, session) {
|
|
|
248
255
|
dslFailure(session, "HBS001", `URL scheme is not allowed: ${url.protocol}`);
|
|
249
256
|
}
|
|
250
257
|
}
|
|
258
|
+
function readCompositePart(part, session) {
|
|
259
|
+
if (typeof part === "string") {
|
|
260
|
+
if (part.includes('"') || part.includes("\n") || part.includes("\r")) {
|
|
261
|
+
dslFailure(session, "HBS001", "Composite attribute literals cannot contain quotes or newlines.");
|
|
262
|
+
}
|
|
263
|
+
return { kind: "literal", emitted: part };
|
|
264
|
+
}
|
|
265
|
+
if (!isExpression(part)) {
|
|
266
|
+
dslFailure(session, "DSL002", "A dynamic attribute requires expr.path or expr.literal.");
|
|
267
|
+
}
|
|
268
|
+
if (part.kind === "literal") {
|
|
269
|
+
const text = part.value === null || typeof part.value === "boolean" ? String(part.value) : String(part.value);
|
|
270
|
+
if (text.includes('"') || text.includes("\n") || text.includes("\r")) {
|
|
271
|
+
dslFailure(session, "HBS001", "Composite attribute literals cannot contain quotes or newlines.");
|
|
272
|
+
}
|
|
273
|
+
return { kind: "literal", emitted: text };
|
|
274
|
+
}
|
|
275
|
+
const resolved = resolvePath(part.value, session);
|
|
276
|
+
return { kind: "path", emitted: resolved.emitted, path: resolved };
|
|
277
|
+
}
|
|
251
278
|
function attributeToken(name, value) {
|
|
252
279
|
const session = getSession();
|
|
253
280
|
if (typeof value === "string") {
|
|
254
281
|
if (name === "href" || name === "src") assertStaticUrl(value, session);
|
|
255
282
|
return value;
|
|
256
283
|
}
|
|
284
|
+
if (Array.isArray(value)) {
|
|
285
|
+
if (value.length === 0) dslFailure(session, "DSL002", "A composite attribute requires at least one part.");
|
|
286
|
+
const parts = value.map((part) => readCompositePart(part, session));
|
|
287
|
+
const hasPath = parts.some((part) => part.kind === "path");
|
|
288
|
+
if (!hasPath && (name === "href" || name === "src")) {
|
|
289
|
+
assertStaticUrl(parts.map((part) => part.emitted).join(""), session);
|
|
290
|
+
}
|
|
291
|
+
const detail = parts.map((part) => part.emitted).join("");
|
|
292
|
+
const token2 = addMarker(
|
|
293
|
+
session,
|
|
294
|
+
{ kind: "attr", path: name, detail },
|
|
295
|
+
{
|
|
296
|
+
kind: "attr",
|
|
297
|
+
attribute: name,
|
|
298
|
+
replacement: ""
|
|
299
|
+
}
|
|
300
|
+
);
|
|
301
|
+
addSite(session, token2, { kind: "attr", attribute: name, args: parts });
|
|
302
|
+
return token2;
|
|
303
|
+
}
|
|
257
304
|
if (!isExpression(value)) {
|
|
258
305
|
dslFailure(session, "DSL002", "A dynamic attribute requires expr.path or expr.literal.");
|
|
259
306
|
}
|
|
@@ -313,7 +360,8 @@ function DynamicImg({
|
|
|
313
360
|
alt,
|
|
314
361
|
title,
|
|
315
362
|
width,
|
|
316
|
-
height
|
|
363
|
+
height,
|
|
364
|
+
style
|
|
317
365
|
}) {
|
|
318
366
|
return /* @__PURE__ */ jsx2(
|
|
319
367
|
EmailImg,
|
|
@@ -321,6 +369,7 @@ function DynamicImg({
|
|
|
321
369
|
alt: attributeToken("alt", alt),
|
|
322
370
|
height,
|
|
323
371
|
src: attributeToken("src", src),
|
|
372
|
+
style,
|
|
324
373
|
title: title === void 0 ? void 0 : attributeToken("title", title),
|
|
325
374
|
width
|
|
326
375
|
}
|
|
@@ -345,20 +394,80 @@ function DynamicButton({
|
|
|
345
394
|
}
|
|
346
395
|
|
|
347
396
|
// src/dsl/blocks.tsx
|
|
348
|
-
import {
|
|
349
|
-
|
|
350
|
-
|
|
397
|
+
import { createElement as createElement2 } from "react";
|
|
398
|
+
|
|
399
|
+
// src/dsl/values.tsx
|
|
400
|
+
import { emitLiteral as emitLiteral3 } from "@vtex-email/core";
|
|
401
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
402
|
+
function Value({ path }) {
|
|
403
|
+
return textValue(path);
|
|
404
|
+
}
|
|
405
|
+
function textValue(path) {
|
|
351
406
|
const session = getSession();
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
407
|
+
const resolved = resolvePath(path, session);
|
|
408
|
+
const token = addMarker(
|
|
409
|
+
session,
|
|
410
|
+
{ kind: "text", path: resolved.emitted, detail: "value" },
|
|
411
|
+
{
|
|
412
|
+
kind: "text",
|
|
413
|
+
replacement: ""
|
|
414
|
+
}
|
|
415
|
+
);
|
|
416
|
+
addSite(session, token, { kind: "value", path: resolved });
|
|
417
|
+
return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
|
|
418
|
+
}
|
|
419
|
+
function textLiteral(value) {
|
|
420
|
+
const session = getSession();
|
|
421
|
+
const emitted = emitLiteral3(value);
|
|
422
|
+
const token = addMarker(
|
|
423
|
+
session,
|
|
424
|
+
{ kind: "text", path: "literal", detail: emitted },
|
|
425
|
+
{
|
|
426
|
+
kind: "text",
|
|
427
|
+
replacement: ""
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
addSite(session, token, { kind: "literal", args: [{ kind: "literal", emitted }] });
|
|
431
|
+
return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
|
|
432
|
+
}
|
|
433
|
+
function Helper({
|
|
434
|
+
name,
|
|
435
|
+
args,
|
|
436
|
+
hash
|
|
437
|
+
}) {
|
|
438
|
+
const session = getSession();
|
|
439
|
+
const rendered = args.map((arg) => readArgument(arg, session));
|
|
440
|
+
const named = {};
|
|
441
|
+
for (const [key, value] of Object.entries(hash ?? {})) named[key] = readArgument(value, session);
|
|
442
|
+
const detail = [
|
|
443
|
+
...rendered.map((arg) => arg.emitted),
|
|
444
|
+
...Object.entries(named).map(([key, arg]) => `${key}=${arg.emitted}`)
|
|
445
|
+
].join(" ");
|
|
446
|
+
const token = addMarker(
|
|
447
|
+
session,
|
|
448
|
+
{ kind: "text", path: name, detail },
|
|
449
|
+
{
|
|
450
|
+
kind: "text",
|
|
451
|
+
replacement: ""
|
|
452
|
+
}
|
|
453
|
+
);
|
|
454
|
+
addSite(session, token, {
|
|
455
|
+
kind: "helper",
|
|
456
|
+
helper: name,
|
|
457
|
+
args: rendered,
|
|
458
|
+
...Object.keys(named).length > 0 ? { hash: named } : {}
|
|
459
|
+
});
|
|
460
|
+
return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
|
|
461
|
+
}
|
|
462
|
+
function Eval({ code, vars = {} }) {
|
|
463
|
+
return Helper({ name: "eval", args: [expr.literal(code)], hash: vars });
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// src/dsl/blocks.tsx
|
|
467
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
468
|
+
var BLOCK_HOST = "vtx-anchor";
|
|
469
|
+
function stamp(children, token) {
|
|
470
|
+
return createElement2(BLOCK_HOST, { "data-anchor": token }, children);
|
|
362
471
|
}
|
|
363
472
|
function openRegion(path, block, hasElse, extras = {}) {
|
|
364
473
|
const session = getSession();
|
|
@@ -393,7 +502,7 @@ function blockRegion(path, block, children, fallback, extras = {}) {
|
|
|
393
502
|
const region = openRegion(path, block, fallback !== void 0, extras);
|
|
394
503
|
const thenNode = stamp(children, region.openId);
|
|
395
504
|
if (!region.elseId || fallback === void 0) return thenNode;
|
|
396
|
-
return /* @__PURE__ */ jsxs2(
|
|
505
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
397
506
|
thenNode,
|
|
398
507
|
stamp(fallback, region.elseId)
|
|
399
508
|
] });
|
|
@@ -407,38 +516,49 @@ function If({ path, children, fallback }) {
|
|
|
407
516
|
function Unless({ path, children, fallback }) {
|
|
408
517
|
return blockRegion(path, "unless", children, fallback);
|
|
409
518
|
}
|
|
519
|
+
function asExpression(value, session) {
|
|
520
|
+
if (value === void 0) dslFailure(session, "HBS002", "A comparison operand is required.");
|
|
521
|
+
if (typeof value === "object" && value !== null && "kind" in value) return value;
|
|
522
|
+
return expr.literal(value);
|
|
523
|
+
}
|
|
410
524
|
function IfCond({
|
|
411
525
|
path,
|
|
412
526
|
operator,
|
|
413
527
|
value,
|
|
528
|
+
right,
|
|
414
529
|
children,
|
|
415
530
|
fallback
|
|
416
531
|
}) {
|
|
417
532
|
const session = getSession();
|
|
533
|
+
const operand = right !== void 0 ? asExpression(right, session) : asExpression(value, session);
|
|
418
534
|
return blockRegion(path, "ifCond", children, fallback, {
|
|
419
|
-
args: [readArgument(expr.literal(operator), session), readArgument(
|
|
535
|
+
args: [readArgument(expr.literal(operator), session), readArgument(operand, session)]
|
|
420
536
|
});
|
|
421
537
|
}
|
|
422
538
|
function HasSubStr({
|
|
423
539
|
path,
|
|
424
540
|
value,
|
|
541
|
+
search,
|
|
425
542
|
children,
|
|
426
543
|
fallback
|
|
427
544
|
}) {
|
|
428
545
|
const session = getSession();
|
|
546
|
+
const operand = search !== void 0 ? asExpression(search, session) : asExpression(value, session);
|
|
429
547
|
return blockRegion(path, "hasSubStr", children, fallback, {
|
|
430
|
-
args: [readArgument(
|
|
548
|
+
args: [readArgument(operand, session)]
|
|
431
549
|
});
|
|
432
550
|
}
|
|
433
551
|
function Eq({
|
|
434
552
|
path,
|
|
435
553
|
value,
|
|
554
|
+
right,
|
|
436
555
|
children,
|
|
437
556
|
fallback
|
|
438
557
|
}) {
|
|
439
558
|
const session = getSession();
|
|
559
|
+
const operand = right !== void 0 ? asExpression(right, session) : asExpression(value, session);
|
|
440
560
|
return blockRegion(path, "eq", children, fallback, {
|
|
441
|
-
args: [readArgument(
|
|
561
|
+
args: [readArgument(operand, session)]
|
|
442
562
|
});
|
|
443
563
|
}
|
|
444
564
|
function Group({
|
|
@@ -455,61 +575,43 @@ function Group({
|
|
|
455
575
|
hash: { by: readArgument(expr.literal(by), session) }
|
|
456
576
|
});
|
|
457
577
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
import { parseMessage } from "@vtex-email/core";
|
|
461
|
-
|
|
462
|
-
// src/dsl/values.tsx
|
|
463
|
-
import { emitLiteral as emitLiteral3 } from "@vtex-email/core";
|
|
464
|
-
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
465
|
-
function Value({ path }) {
|
|
466
|
-
return textValue(path);
|
|
467
|
-
}
|
|
468
|
-
function textValue(path) {
|
|
469
|
-
const session = getSession();
|
|
470
|
-
const resolved = resolvePath(path, session);
|
|
471
|
-
const token = addMarker(
|
|
472
|
-
session,
|
|
473
|
-
{ kind: "text", path: resolved.emitted, detail: "value" },
|
|
474
|
-
{
|
|
475
|
-
kind: "text",
|
|
476
|
-
replacement: ""
|
|
477
|
-
}
|
|
478
|
-
);
|
|
479
|
-
addSite(session, token, { kind: "value", path: resolved });
|
|
480
|
-
return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
|
|
578
|
+
function With({ path, children, fallback }) {
|
|
579
|
+
return blockRegion(path, "with", children, fallback);
|
|
481
580
|
}
|
|
482
|
-
function
|
|
581
|
+
function Math({
|
|
582
|
+
path,
|
|
583
|
+
left,
|
|
584
|
+
operator,
|
|
585
|
+
right,
|
|
586
|
+
form = "inline",
|
|
587
|
+
children
|
|
588
|
+
}) {
|
|
483
589
|
const session = getSession();
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
590
|
+
const rightArg = asExpression(right, session);
|
|
591
|
+
if (form === "block") {
|
|
592
|
+
let leftPath = path ?? null;
|
|
593
|
+
if (!leftPath && typeof left === "string") leftPath = left;
|
|
594
|
+
if (!leftPath && left && typeof left === "object" && left.kind === "path") leftPath = left.value;
|
|
595
|
+
if (!leftPath) dslFailure(session, "HBS002", "Block math requires a left path.");
|
|
596
|
+
return blockRegion(leftPath, "math", children ?? /* @__PURE__ */ jsx4("span", { children: "\u200B" }), void 0, {
|
|
597
|
+
args: [readArgument(expr.literal(operator), session), readArgument(rightArg, session)]
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
const leftArg = left !== void 0 ? asExpression(left, session) : path ? expr.path(path) : null;
|
|
601
|
+
if (!leftArg) dslFailure(session, "HBS002", "Inline math requires a left operand.");
|
|
602
|
+
return /* @__PURE__ */ jsx4(Helper, { args: [leftArg, expr.literal(operator), rightArg], name: "math" });
|
|
495
603
|
}
|
|
496
|
-
function
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
{
|
|
503
|
-
kind: "text",
|
|
504
|
-
replacement: ""
|
|
505
|
-
}
|
|
506
|
-
);
|
|
507
|
-
addSite(session, token, { kind: "helper", helper: name, args: rendered });
|
|
508
|
-
return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
|
|
604
|
+
function RichShippingData({
|
|
605
|
+
path,
|
|
606
|
+
children,
|
|
607
|
+
fallback
|
|
608
|
+
}) {
|
|
609
|
+
return blockRegion(path, "richShippingData", children, fallback);
|
|
509
610
|
}
|
|
510
611
|
|
|
511
612
|
// src/dsl/trans.tsx
|
|
512
|
-
import {
|
|
613
|
+
import { parseMessage } from "@vtex-email/core";
|
|
614
|
+
import { Fragment as Fragment2, jsx as jsx5 } from "react/jsx-runtime";
|
|
513
615
|
function Trans({ id, values }) {
|
|
514
616
|
const session = getSession();
|
|
515
617
|
const text = session.catalog[id];
|
|
@@ -525,7 +627,7 @@ function Trans({ id, values }) {
|
|
|
525
627
|
if (provided.join("\0") !== expected.join("\0")) {
|
|
526
628
|
dslFailure(session, "I18N001", `Placeholders for ${id} do not match the catalog.`, { locale: session.locale });
|
|
527
629
|
}
|
|
528
|
-
return /* @__PURE__ */
|
|
630
|
+
return /* @__PURE__ */ jsx5(Fragment2, { children: parsed.parts.map((part) => {
|
|
529
631
|
if (part.type === "text") return part.value;
|
|
530
632
|
const value = values?.[part.name];
|
|
531
633
|
if (!value) {
|
|
@@ -545,25 +647,35 @@ var Vtex = {
|
|
|
545
647
|
HasSubStr,
|
|
546
648
|
Group,
|
|
547
649
|
Eq,
|
|
650
|
+
With,
|
|
651
|
+
Math,
|
|
652
|
+
RichShippingData,
|
|
548
653
|
Value,
|
|
549
654
|
Helper,
|
|
655
|
+
Eval,
|
|
550
656
|
Link: DynamicLink,
|
|
551
657
|
Img: DynamicImg,
|
|
552
|
-
Button: DynamicButton
|
|
658
|
+
Button: DynamicButton,
|
|
659
|
+
attr: attributeToken
|
|
553
660
|
};
|
|
554
661
|
export {
|
|
555
662
|
Each,
|
|
556
663
|
Email,
|
|
557
664
|
Eq,
|
|
665
|
+
Eval,
|
|
558
666
|
Group,
|
|
559
667
|
HasSubStr,
|
|
560
668
|
Helper,
|
|
561
669
|
If,
|
|
562
670
|
IfCond,
|
|
671
|
+
Math,
|
|
672
|
+
RichShippingData,
|
|
563
673
|
Trans,
|
|
564
674
|
Unless,
|
|
565
675
|
Value,
|
|
566
676
|
Vtex,
|
|
677
|
+
With,
|
|
678
|
+
attributeToken,
|
|
567
679
|
compileEmail,
|
|
568
680
|
diagnoseStyles,
|
|
569
681
|
expr,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtex-email/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/marcelotk15/vtex-react-email.git"
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@react-email/components": "1.0.12",
|
|
22
|
-
"@vtex-email/core": "0.
|
|
22
|
+
"@vtex-email/core": "0.4.0",
|
|
23
23
|
"react": "19.3.0",
|
|
24
24
|
"react-dom": "19.3.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@vtex-email/vtex": "0.
|
|
27
|
+
"@vtex-email/vtex": "0.4.0",
|
|
28
28
|
"zod": "4.6.5"
|
|
29
29
|
}
|
|
30
30
|
}
|