@vtex-email/react 0.2.0 → 0.3.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/dsl/attributes.d.ts +13 -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/vtex.d.ts +5 -2
- package/dist/dsl/vtex.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +151 -68
- package/package.json +3 -3
package/dist/dsl/attributes.d.ts
CHANGED
|
@@ -2,24 +2,26 @@ 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
|
+
export declare function attributeToken(name: DynamicAttribute, value: AttributeValue): string;
|
|
6
7
|
export declare function rejectClassExpression(className: string | Expression | undefined, session: Session): string | undefined;
|
|
7
8
|
export declare function DynamicLink({ href, title, children, className, }: {
|
|
8
|
-
href:
|
|
9
|
-
title?:
|
|
9
|
+
href: AttributeValue;
|
|
10
|
+
title?: AttributeValue;
|
|
10
11
|
children?: ReactNode;
|
|
11
12
|
className?: string | Expression;
|
|
12
13
|
}): 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
|
|
14
|
+
export declare function DynamicImg({ src, alt, title, width, height, style, }: {
|
|
15
|
+
src: AttributeValue;
|
|
16
|
+
alt: AttributeValue;
|
|
17
|
+
title?: AttributeValue;
|
|
18
|
+
width?: number | `${number}`;
|
|
19
|
+
height?: number | `${number}`;
|
|
20
|
+
style?: React.CSSProperties;
|
|
19
21
|
}): import("react/jsx-runtime").JSX.Element;
|
|
20
22
|
export declare function DynamicButton({ href, title, children, className, }: {
|
|
21
|
-
href:
|
|
22
|
-
title?:
|
|
23
|
+
href: AttributeValue;
|
|
24
|
+
title?: AttributeValue;
|
|
23
25
|
children?: ReactNode;
|
|
24
26
|
className?: string | Expression;
|
|
25
27
|
}): 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,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;AAChF,eAAO,MAAM,UAAU,eAAe,CAAA;AAEtC,wBAAgB,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAEtE;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE;IAAE,IAAI,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAAC,IAAI,CAAC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S,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/vtex.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DynamicButton, DynamicImg, DynamicLink } from './attributes';
|
|
2
|
-
import { Each, Eq, Group, HasSubStr, If, IfCond, Unless } from './blocks';
|
|
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
5
|
import { Helper, Value } from './values';
|
|
@@ -11,11 +11,14 @@ 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;
|
|
16
19
|
Link: typeof DynamicLink;
|
|
17
20
|
Img: typeof DynamicImg;
|
|
18
21
|
Button: typeof DynamicButton;
|
|
19
22
|
};
|
|
20
|
-
export { Each, Eq, expr, Group, HasSubStr, Helper, If, IfCond, Trans, Unless, Value };
|
|
23
|
+
export { Each, Eq, expr, Group, HasSubStr, Helper, If, IfCond, Math, RichShippingData, Trans, Unless, Value, With };
|
|
21
24
|
//# 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;AACrE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;
|
|
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;AACrE,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,MAAM,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAExC,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;CAgBhB,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ export { Email } 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
4
|
export { isExpression, type Expression } from './dsl/expr';
|
|
5
|
-
export { Each, Eq, expr, Group, HasSubStr, Helper, If, IfCond, Trans, Unless, Value, Vtex } from './dsl/vtex';
|
|
5
|
+
export { Each, Eq, expr, Group, HasSubStr, Helper, If, IfCond, Math, RichShippingData, Trans, Unless, Value, Vtex, With, } from './dsl/vtex';
|
|
6
6
|
//# 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;AACvC,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,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,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,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,EACL,IAAI,EACJ,EAAE,EACF,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
|
@@ -248,12 +248,52 @@ function assertStaticUrl(value, session) {
|
|
|
248
248
|
dslFailure(session, "HBS001", `URL scheme is not allowed: ${url.protocol}`);
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
+
function readCompositePart(part, session) {
|
|
252
|
+
if (typeof part === "string") {
|
|
253
|
+
if (part.includes('"') || part.includes("\n") || part.includes("\r")) {
|
|
254
|
+
dslFailure(session, "HBS001", "Composite attribute literals cannot contain quotes or newlines.");
|
|
255
|
+
}
|
|
256
|
+
return { kind: "literal", emitted: part };
|
|
257
|
+
}
|
|
258
|
+
if (!isExpression(part)) {
|
|
259
|
+
dslFailure(session, "DSL002", "A dynamic attribute requires expr.path or expr.literal.");
|
|
260
|
+
}
|
|
261
|
+
if (part.kind === "literal") {
|
|
262
|
+
const text = part.value === null || typeof part.value === "boolean" ? String(part.value) : String(part.value);
|
|
263
|
+
if (text.includes('"') || text.includes("\n") || text.includes("\r")) {
|
|
264
|
+
dslFailure(session, "HBS001", "Composite attribute literals cannot contain quotes or newlines.");
|
|
265
|
+
}
|
|
266
|
+
return { kind: "literal", emitted: text };
|
|
267
|
+
}
|
|
268
|
+
const resolved = resolvePath(part.value, session);
|
|
269
|
+
return { kind: "path", emitted: resolved.emitted, path: resolved };
|
|
270
|
+
}
|
|
251
271
|
function attributeToken(name, value) {
|
|
252
272
|
const session = getSession();
|
|
253
273
|
if (typeof value === "string") {
|
|
254
274
|
if (name === "href" || name === "src") assertStaticUrl(value, session);
|
|
255
275
|
return value;
|
|
256
276
|
}
|
|
277
|
+
if (Array.isArray(value)) {
|
|
278
|
+
if (value.length === 0) dslFailure(session, "DSL002", "A composite attribute requires at least one part.");
|
|
279
|
+
const parts = value.map((part) => readCompositePart(part, session));
|
|
280
|
+
const hasPath = parts.some((part) => part.kind === "path");
|
|
281
|
+
if (!hasPath && (name === "href" || name === "src")) {
|
|
282
|
+
assertStaticUrl(parts.map((part) => part.emitted).join(""), session);
|
|
283
|
+
}
|
|
284
|
+
const detail = parts.map((part) => part.emitted).join("");
|
|
285
|
+
const token2 = addMarker(
|
|
286
|
+
session,
|
|
287
|
+
{ kind: "attr", path: name, detail },
|
|
288
|
+
{
|
|
289
|
+
kind: "attr",
|
|
290
|
+
attribute: name,
|
|
291
|
+
replacement: ""
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
addSite(session, token2, { kind: "attr", attribute: name, args: parts });
|
|
295
|
+
return token2;
|
|
296
|
+
}
|
|
257
297
|
if (!isExpression(value)) {
|
|
258
298
|
dslFailure(session, "DSL002", "A dynamic attribute requires expr.path or expr.literal.");
|
|
259
299
|
}
|
|
@@ -313,7 +353,8 @@ function DynamicImg({
|
|
|
313
353
|
alt,
|
|
314
354
|
title,
|
|
315
355
|
width,
|
|
316
|
-
height
|
|
356
|
+
height,
|
|
357
|
+
style
|
|
317
358
|
}) {
|
|
318
359
|
return /* @__PURE__ */ jsx2(
|
|
319
360
|
EmailImg,
|
|
@@ -321,6 +362,7 @@ function DynamicImg({
|
|
|
321
362
|
alt: attributeToken("alt", alt),
|
|
322
363
|
height,
|
|
323
364
|
src: attributeToken("src", src),
|
|
365
|
+
style,
|
|
324
366
|
title: title === void 0 ? void 0 : attributeToken("title", title),
|
|
325
367
|
width
|
|
326
368
|
}
|
|
@@ -345,20 +387,62 @@ function DynamicButton({
|
|
|
345
387
|
}
|
|
346
388
|
|
|
347
389
|
// src/dsl/blocks.tsx
|
|
348
|
-
import {
|
|
349
|
-
|
|
350
|
-
|
|
390
|
+
import { createElement as createElement2 } from "react";
|
|
391
|
+
|
|
392
|
+
// src/dsl/values.tsx
|
|
393
|
+
import { emitLiteral as emitLiteral3 } from "@vtex-email/core";
|
|
394
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
395
|
+
function Value({ path }) {
|
|
396
|
+
return textValue(path);
|
|
397
|
+
}
|
|
398
|
+
function textValue(path) {
|
|
351
399
|
const session = getSession();
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
400
|
+
const resolved = resolvePath(path, session);
|
|
401
|
+
const token = addMarker(
|
|
402
|
+
session,
|
|
403
|
+
{ kind: "text", path: resolved.emitted, detail: "value" },
|
|
404
|
+
{
|
|
405
|
+
kind: "text",
|
|
406
|
+
replacement: ""
|
|
407
|
+
}
|
|
408
|
+
);
|
|
409
|
+
addSite(session, token, { kind: "value", path: resolved });
|
|
410
|
+
return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
|
|
411
|
+
}
|
|
412
|
+
function textLiteral(value) {
|
|
413
|
+
const session = getSession();
|
|
414
|
+
const emitted = emitLiteral3(value);
|
|
415
|
+
const token = addMarker(
|
|
416
|
+
session,
|
|
417
|
+
{ kind: "text", path: "literal", detail: emitted },
|
|
418
|
+
{
|
|
419
|
+
kind: "text",
|
|
420
|
+
replacement: ""
|
|
421
|
+
}
|
|
422
|
+
);
|
|
423
|
+
addSite(session, token, { kind: "literal", args: [{ kind: "literal", emitted }] });
|
|
424
|
+
return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
|
|
425
|
+
}
|
|
426
|
+
function Helper({ name, args }) {
|
|
427
|
+
const session = getSession();
|
|
428
|
+
const rendered = args.map((arg) => readArgument(arg, session));
|
|
429
|
+
const token = addMarker(
|
|
430
|
+
session,
|
|
431
|
+
{ kind: "text", path: name, detail: rendered.map((arg) => arg.emitted).join(" ") },
|
|
432
|
+
{
|
|
433
|
+
kind: "text",
|
|
434
|
+
replacement: ""
|
|
435
|
+
}
|
|
436
|
+
);
|
|
437
|
+
addSite(session, token, { kind: "helper", helper: name, args: rendered });
|
|
438
|
+
return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// src/dsl/blocks.tsx
|
|
442
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
443
|
+
var BLOCK_HOST = "vtx-anchor";
|
|
444
|
+
function stamp(children, token) {
|
|
445
|
+
return createElement2(BLOCK_HOST, { "data-anchor": token }, children);
|
|
362
446
|
}
|
|
363
447
|
function openRegion(path, block, hasElse, extras = {}) {
|
|
364
448
|
const session = getSession();
|
|
@@ -393,7 +477,7 @@ function blockRegion(path, block, children, fallback, extras = {}) {
|
|
|
393
477
|
const region = openRegion(path, block, fallback !== void 0, extras);
|
|
394
478
|
const thenNode = stamp(children, region.openId);
|
|
395
479
|
if (!region.elseId || fallback === void 0) return thenNode;
|
|
396
|
-
return /* @__PURE__ */ jsxs2(
|
|
480
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
397
481
|
thenNode,
|
|
398
482
|
stamp(fallback, region.elseId)
|
|
399
483
|
] });
|
|
@@ -407,38 +491,49 @@ function If({ path, children, fallback }) {
|
|
|
407
491
|
function Unless({ path, children, fallback }) {
|
|
408
492
|
return blockRegion(path, "unless", children, fallback);
|
|
409
493
|
}
|
|
494
|
+
function asExpression(value, session) {
|
|
495
|
+
if (value === void 0) dslFailure(session, "HBS002", "A comparison operand is required.");
|
|
496
|
+
if (typeof value === "object" && value !== null && "kind" in value) return value;
|
|
497
|
+
return expr.literal(value);
|
|
498
|
+
}
|
|
410
499
|
function IfCond({
|
|
411
500
|
path,
|
|
412
501
|
operator,
|
|
413
502
|
value,
|
|
503
|
+
right,
|
|
414
504
|
children,
|
|
415
505
|
fallback
|
|
416
506
|
}) {
|
|
417
507
|
const session = getSession();
|
|
508
|
+
const operand = right !== void 0 ? asExpression(right, session) : asExpression(value, session);
|
|
418
509
|
return blockRegion(path, "ifCond", children, fallback, {
|
|
419
|
-
args: [readArgument(expr.literal(operator), session), readArgument(
|
|
510
|
+
args: [readArgument(expr.literal(operator), session), readArgument(operand, session)]
|
|
420
511
|
});
|
|
421
512
|
}
|
|
422
513
|
function HasSubStr({
|
|
423
514
|
path,
|
|
424
515
|
value,
|
|
516
|
+
search,
|
|
425
517
|
children,
|
|
426
518
|
fallback
|
|
427
519
|
}) {
|
|
428
520
|
const session = getSession();
|
|
521
|
+
const operand = search !== void 0 ? asExpression(search, session) : asExpression(value, session);
|
|
429
522
|
return blockRegion(path, "hasSubStr", children, fallback, {
|
|
430
|
-
args: [readArgument(
|
|
523
|
+
args: [readArgument(operand, session)]
|
|
431
524
|
});
|
|
432
525
|
}
|
|
433
526
|
function Eq({
|
|
434
527
|
path,
|
|
435
528
|
value,
|
|
529
|
+
right,
|
|
436
530
|
children,
|
|
437
531
|
fallback
|
|
438
532
|
}) {
|
|
439
533
|
const session = getSession();
|
|
534
|
+
const operand = right !== void 0 ? asExpression(right, session) : asExpression(value, session);
|
|
440
535
|
return blockRegion(path, "eq", children, fallback, {
|
|
441
|
-
args: [readArgument(
|
|
536
|
+
args: [readArgument(operand, session)]
|
|
442
537
|
});
|
|
443
538
|
}
|
|
444
539
|
function Group({
|
|
@@ -455,61 +550,43 @@ function Group({
|
|
|
455
550
|
hash: { by: readArgument(expr.literal(by), session) }
|
|
456
551
|
});
|
|
457
552
|
}
|
|
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);
|
|
553
|
+
function With({ path, children, fallback }) {
|
|
554
|
+
return blockRegion(path, "with", children, fallback);
|
|
467
555
|
}
|
|
468
|
-
function
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
replacement: ""
|
|
477
|
-
}
|
|
478
|
-
);
|
|
479
|
-
addSite(session, token, { kind: "value", path: resolved });
|
|
480
|
-
return /* @__PURE__ */ jsx3("span", { "data-anchor": token, children: "\u200B" });
|
|
481
|
-
}
|
|
482
|
-
function textLiteral(value) {
|
|
556
|
+
function Math({
|
|
557
|
+
path,
|
|
558
|
+
left,
|
|
559
|
+
operator,
|
|
560
|
+
right,
|
|
561
|
+
form = "inline",
|
|
562
|
+
children
|
|
563
|
+
}) {
|
|
483
564
|
const session = getSession();
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
565
|
+
const rightArg = asExpression(right, session);
|
|
566
|
+
if (form === "block") {
|
|
567
|
+
let leftPath = path ?? null;
|
|
568
|
+
if (!leftPath && typeof left === "string") leftPath = left;
|
|
569
|
+
if (!leftPath && left && typeof left === "object" && left.kind === "path") leftPath = left.value;
|
|
570
|
+
if (!leftPath) dslFailure(session, "HBS002", "Block math requires a left path.");
|
|
571
|
+
return blockRegion(leftPath, "math", children ?? /* @__PURE__ */ jsx4("span", { children: "\u200B" }), void 0, {
|
|
572
|
+
args: [readArgument(expr.literal(operator), session), readArgument(rightArg, session)]
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
const leftArg = left !== void 0 ? asExpression(left, session) : path ? expr.path(path) : null;
|
|
576
|
+
if (!leftArg) dslFailure(session, "HBS002", "Inline math requires a left operand.");
|
|
577
|
+
return /* @__PURE__ */ jsx4(Helper, { args: [leftArg, expr.literal(operator), rightArg], name: "math" });
|
|
495
578
|
}
|
|
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" });
|
|
579
|
+
function RichShippingData({
|
|
580
|
+
path,
|
|
581
|
+
children,
|
|
582
|
+
fallback
|
|
583
|
+
}) {
|
|
584
|
+
return blockRegion(path, "richShippingData", children, fallback);
|
|
509
585
|
}
|
|
510
586
|
|
|
511
587
|
// src/dsl/trans.tsx
|
|
512
|
-
import {
|
|
588
|
+
import { parseMessage } from "@vtex-email/core";
|
|
589
|
+
import { Fragment as Fragment2, jsx as jsx5 } from "react/jsx-runtime";
|
|
513
590
|
function Trans({ id, values }) {
|
|
514
591
|
const session = getSession();
|
|
515
592
|
const text = session.catalog[id];
|
|
@@ -525,7 +602,7 @@ function Trans({ id, values }) {
|
|
|
525
602
|
if (provided.join("\0") !== expected.join("\0")) {
|
|
526
603
|
dslFailure(session, "I18N001", `Placeholders for ${id} do not match the catalog.`, { locale: session.locale });
|
|
527
604
|
}
|
|
528
|
-
return /* @__PURE__ */
|
|
605
|
+
return /* @__PURE__ */ jsx5(Fragment2, { children: parsed.parts.map((part) => {
|
|
529
606
|
if (part.type === "text") return part.value;
|
|
530
607
|
const value = values?.[part.name];
|
|
531
608
|
if (!value) {
|
|
@@ -545,6 +622,9 @@ var Vtex = {
|
|
|
545
622
|
HasSubStr,
|
|
546
623
|
Group,
|
|
547
624
|
Eq,
|
|
625
|
+
With,
|
|
626
|
+
Math,
|
|
627
|
+
RichShippingData,
|
|
548
628
|
Value,
|
|
549
629
|
Helper,
|
|
550
630
|
Link: DynamicLink,
|
|
@@ -560,10 +640,13 @@ export {
|
|
|
560
640
|
Helper,
|
|
561
641
|
If,
|
|
562
642
|
IfCond,
|
|
643
|
+
Math,
|
|
644
|
+
RichShippingData,
|
|
563
645
|
Trans,
|
|
564
646
|
Unless,
|
|
565
647
|
Value,
|
|
566
648
|
Vtex,
|
|
649
|
+
With,
|
|
567
650
|
compileEmail,
|
|
568
651
|
diagnoseStyles,
|
|
569
652
|
expr,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtex-email/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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.3.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.3.0",
|
|
28
28
|
"zod": "4.6.5"
|
|
29
29
|
}
|
|
30
30
|
}
|