@vtex-email/react 0.1.0 → 0.2.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/blocks.d.ts +36 -3
- package/dist/dsl/blocks.d.ts.map +1 -1
- package/dist/dsl/vtex.d.ts +6 -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 +66 -4
- package/package.json +3 -3
package/dist/dsl/blocks.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import type { BlockName } from '@vtex-email/core';
|
|
1
|
+
import type { BlockName, SiteArgument, SiteHash } from '@vtex-email/core';
|
|
2
2
|
import { type ReactElement, type ReactNode } from 'react';
|
|
3
|
+
import { type Expression } from './expr';
|
|
3
4
|
export declare function stamp(children: ReactNode, token: string): ReactElement;
|
|
4
|
-
export declare function openRegion(path: string, block: BlockName, hasElse: boolean
|
|
5
|
+
export declare function openRegion(path: string, block: BlockName, hasElse: boolean, extras?: {
|
|
6
|
+
args?: readonly SiteArgument[];
|
|
7
|
+
hash?: SiteHash;
|
|
8
|
+
}): {
|
|
5
9
|
openId: string;
|
|
6
10
|
elseId: string | null;
|
|
7
11
|
};
|
|
8
|
-
export declare function blockRegion(path: string, block: BlockName, children: ReactNode, fallback: ReactNode | undefined
|
|
12
|
+
export declare function blockRegion(path: string, block: BlockName, children: ReactNode, fallback: ReactNode | undefined, extras?: {
|
|
13
|
+
args?: readonly SiteArgument[];
|
|
14
|
+
hash?: SiteHash;
|
|
15
|
+
}): ReactNode;
|
|
9
16
|
export declare function Each({ path, children, fallback }: {
|
|
10
17
|
path: string;
|
|
11
18
|
children: ReactNode;
|
|
@@ -21,4 +28,30 @@ export declare function Unless({ path, children, fallback }: {
|
|
|
21
28
|
children: ReactNode;
|
|
22
29
|
fallback?: ReactNode;
|
|
23
30
|
}): ReactNode;
|
|
31
|
+
export declare function IfCond({ path, operator, value, children, fallback, }: {
|
|
32
|
+
path: string;
|
|
33
|
+
operator: '==' | '===' | '!=';
|
|
34
|
+
value: string | number | boolean | null;
|
|
35
|
+
children: ReactNode;
|
|
36
|
+
fallback?: ReactNode;
|
|
37
|
+
}): ReactNode;
|
|
38
|
+
export declare function HasSubStr({ path, value, children, fallback, }: {
|
|
39
|
+
path: string;
|
|
40
|
+
value: string;
|
|
41
|
+
children: ReactNode;
|
|
42
|
+
fallback?: ReactNode;
|
|
43
|
+
}): ReactNode;
|
|
44
|
+
export declare function Eq({ path, value, children, fallback, }: {
|
|
45
|
+
path: string;
|
|
46
|
+
value: string | number | boolean | null;
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
fallback?: ReactNode;
|
|
49
|
+
}): ReactNode;
|
|
50
|
+
export declare function Group({ path, by, children, fallback, }: {
|
|
51
|
+
path: string;
|
|
52
|
+
by: string;
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
fallback?: ReactNode;
|
|
55
|
+
}): ReactNode;
|
|
56
|
+
export type { Expression };
|
|
24
57
|
//# 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,MAAM,kBAAkB,CAAA;
|
|
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,EAAoD,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAG3G,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAA;AAG9C,wBAAgB,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,E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,GACT,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,CAAA;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;IACvC,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,aAKA;AAED,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,aAKA;AAED,wBAAgB,EAAE,CAAC,EACjB,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;IACvC,QAAQ,EAAE,SAAS,CAAA;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,aAKA;AAED,wBAAgB,KAAK,CAAC,EACpB,IAAI,EACJ,EAAE,EACF,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,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, If, Unless } from './blocks';
|
|
2
|
+
import { Each, Eq, Group, HasSubStr, If, IfCond, Unless } from './blocks';
|
|
3
3
|
import { expr } from './expr';
|
|
4
4
|
import { Trans } from './trans';
|
|
5
5
|
import { Helper, Value } from './values';
|
|
@@ -7,11 +7,15 @@ export declare const Vtex: {
|
|
|
7
7
|
Each: typeof Each;
|
|
8
8
|
If: typeof If;
|
|
9
9
|
Unless: typeof Unless;
|
|
10
|
+
IfCond: typeof IfCond;
|
|
11
|
+
HasSubStr: typeof HasSubStr;
|
|
12
|
+
Group: typeof Group;
|
|
13
|
+
Eq: typeof Eq;
|
|
10
14
|
Value: typeof Value;
|
|
11
15
|
Helper: typeof Helper;
|
|
12
16
|
Link: typeof DynamicLink;
|
|
13
17
|
Img: typeof DynamicImg;
|
|
14
18
|
Button: typeof DynamicButton;
|
|
15
19
|
};
|
|
16
|
-
export { Each, expr, Helper, If, Trans, Unless, Value };
|
|
20
|
+
export { Each, Eq, expr, Group, HasSubStr, Helper, If, IfCond, Trans, Unless, Value };
|
|
17
21
|
//# 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,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,MAAM,EAAE,MAAM,UAAU,CAAA;AACzE,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;;;;;;;;;;;;;CAahB,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,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, expr, Helper, If, Trans, Unless, Value, Vtex } from './dsl/vtex';
|
|
5
|
+
export { Each, Eq, expr, Group, HasSubStr, Helper, If, IfCond, Trans, Unless, Value, Vtex } 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,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA"}
|
|
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,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -360,7 +360,7 @@ function stamp(children, token) {
|
|
|
360
360
|
}
|
|
361
361
|
return cloneElement(only, { "data-anchor": token });
|
|
362
362
|
}
|
|
363
|
-
function openRegion(path, block, hasElse) {
|
|
363
|
+
function openRegion(path, block, hasElse, extras = {}) {
|
|
364
364
|
const session = getSession();
|
|
365
365
|
const resolved = resolvePath(path, session);
|
|
366
366
|
const marker = {
|
|
@@ -370,7 +370,13 @@ function openRegion(path, block, hasElse) {
|
|
|
370
370
|
elseId: null
|
|
371
371
|
};
|
|
372
372
|
const openId = addMarker(session, { kind: "open", path: resolved.emitted, detail: block }, marker);
|
|
373
|
-
addSite(session, openId, {
|
|
373
|
+
addSite(session, openId, {
|
|
374
|
+
kind: "block",
|
|
375
|
+
block,
|
|
376
|
+
path: resolved,
|
|
377
|
+
...extras.args ? { args: extras.args } : {},
|
|
378
|
+
...extras.hash ? { hash: extras.hash } : {}
|
|
379
|
+
});
|
|
374
380
|
if (!hasElse) return { openId, elseId: null };
|
|
375
381
|
const elseId = addMarker(
|
|
376
382
|
session,
|
|
@@ -383,8 +389,8 @@ function openRegion(path, block, hasElse) {
|
|
|
383
389
|
marker.elseId = elseId;
|
|
384
390
|
return { openId, elseId };
|
|
385
391
|
}
|
|
386
|
-
function blockRegion(path, block, children, fallback) {
|
|
387
|
-
const region = openRegion(path, block, fallback !== void 0);
|
|
392
|
+
function blockRegion(path, block, children, fallback, extras = {}) {
|
|
393
|
+
const region = openRegion(path, block, fallback !== void 0, extras);
|
|
388
394
|
const thenNode = stamp(children, region.openId);
|
|
389
395
|
if (!region.elseId || fallback === void 0) return thenNode;
|
|
390
396
|
return /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
@@ -401,6 +407,54 @@ function If({ path, children, fallback }) {
|
|
|
401
407
|
function Unless({ path, children, fallback }) {
|
|
402
408
|
return blockRegion(path, "unless", children, fallback);
|
|
403
409
|
}
|
|
410
|
+
function IfCond({
|
|
411
|
+
path,
|
|
412
|
+
operator,
|
|
413
|
+
value,
|
|
414
|
+
children,
|
|
415
|
+
fallback
|
|
416
|
+
}) {
|
|
417
|
+
const session = getSession();
|
|
418
|
+
return blockRegion(path, "ifCond", children, fallback, {
|
|
419
|
+
args: [readArgument(expr.literal(operator), session), readArgument(expr.literal(value), session)]
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
function HasSubStr({
|
|
423
|
+
path,
|
|
424
|
+
value,
|
|
425
|
+
children,
|
|
426
|
+
fallback
|
|
427
|
+
}) {
|
|
428
|
+
const session = getSession();
|
|
429
|
+
return blockRegion(path, "hasSubStr", children, fallback, {
|
|
430
|
+
args: [readArgument(expr.literal(value), session)]
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
function Eq({
|
|
434
|
+
path,
|
|
435
|
+
value,
|
|
436
|
+
children,
|
|
437
|
+
fallback
|
|
438
|
+
}) {
|
|
439
|
+
const session = getSession();
|
|
440
|
+
return blockRegion(path, "eq", children, fallback, {
|
|
441
|
+
args: [readArgument(expr.literal(value), session)]
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
function Group({
|
|
445
|
+
path,
|
|
446
|
+
by,
|
|
447
|
+
children,
|
|
448
|
+
fallback
|
|
449
|
+
}) {
|
|
450
|
+
const session = getSession();
|
|
451
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(by)) {
|
|
452
|
+
dslFailure(session, "HBS002", "Group by must be an identifier.");
|
|
453
|
+
}
|
|
454
|
+
return blockRegion(path, "group", children, fallback, {
|
|
455
|
+
hash: { by: readArgument(expr.literal(by), session) }
|
|
456
|
+
});
|
|
457
|
+
}
|
|
404
458
|
|
|
405
459
|
// src/dsl/trans.tsx
|
|
406
460
|
import { parseMessage } from "@vtex-email/core";
|
|
@@ -487,6 +541,10 @@ var Vtex = {
|
|
|
487
541
|
Each,
|
|
488
542
|
If,
|
|
489
543
|
Unless,
|
|
544
|
+
IfCond,
|
|
545
|
+
HasSubStr,
|
|
546
|
+
Group,
|
|
547
|
+
Eq,
|
|
490
548
|
Value,
|
|
491
549
|
Helper,
|
|
492
550
|
Link: DynamicLink,
|
|
@@ -496,8 +554,12 @@ var Vtex = {
|
|
|
496
554
|
export {
|
|
497
555
|
Each,
|
|
498
556
|
Email,
|
|
557
|
+
Eq,
|
|
558
|
+
Group,
|
|
559
|
+
HasSubStr,
|
|
499
560
|
Helper,
|
|
500
561
|
If,
|
|
562
|
+
IfCond,
|
|
501
563
|
Trans,
|
|
502
564
|
Unless,
|
|
503
565
|
Value,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtex-email/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.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.2.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.2.0",
|
|
28
28
|
"zod": "4.6.5"
|
|
29
29
|
}
|
|
30
30
|
}
|