monto-email-block-video 0.0.1
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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/index.d.ts +125 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/package.json +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Waypoint (Metaccountant, Inc.)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const VideoPropsSchema: z.ZodObject<{
|
|
4
|
+
style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
5
|
+
padding: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
6
|
+
top: z.ZodNumber;
|
|
7
|
+
bottom: z.ZodNumber;
|
|
8
|
+
right: z.ZodNumber;
|
|
9
|
+
left: z.ZodNumber;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
top: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
right: number;
|
|
14
|
+
left: number;
|
|
15
|
+
}, {
|
|
16
|
+
top: number;
|
|
17
|
+
bottom: number;
|
|
18
|
+
right: number;
|
|
19
|
+
left: number;
|
|
20
|
+
}>>>;
|
|
21
|
+
backgroundColor: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
22
|
+
textAlign: z.ZodNullable<z.ZodOptional<z.ZodEnum<["center", "left", "right"]>>>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
padding?: {
|
|
25
|
+
top: number;
|
|
26
|
+
bottom: number;
|
|
27
|
+
right: number;
|
|
28
|
+
left: number;
|
|
29
|
+
} | null | undefined;
|
|
30
|
+
backgroundColor?: string | null | undefined;
|
|
31
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
padding?: {
|
|
34
|
+
top: number;
|
|
35
|
+
bottom: number;
|
|
36
|
+
right: number;
|
|
37
|
+
left: number;
|
|
38
|
+
} | null | undefined;
|
|
39
|
+
backgroundColor?: string | null | undefined;
|
|
40
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
41
|
+
}>>>;
|
|
42
|
+
props: z.ZodNullable<z.ZodOptional<z.ZodObject<{
|
|
43
|
+
url: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
44
|
+
alt: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
45
|
+
width: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
46
|
+
height: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
47
|
+
contentAlignment: z.ZodNullable<z.ZodOptional<z.ZodEnum<["top", "middle", "bottom"]>>>;
|
|
48
|
+
linkHref: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
49
|
+
autoplay: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
50
|
+
loop: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
51
|
+
muted: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
52
|
+
controls: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
url?: string | null | undefined;
|
|
55
|
+
alt?: string | null | undefined;
|
|
56
|
+
width?: string | null | undefined;
|
|
57
|
+
height?: string | null | undefined;
|
|
58
|
+
contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
|
|
59
|
+
linkHref?: string | null | undefined;
|
|
60
|
+
autoplay?: boolean | null | undefined;
|
|
61
|
+
loop?: boolean | null | undefined;
|
|
62
|
+
muted?: boolean | null | undefined;
|
|
63
|
+
controls?: boolean | null | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
url?: string | null | undefined;
|
|
66
|
+
alt?: string | null | undefined;
|
|
67
|
+
width?: string | null | undefined;
|
|
68
|
+
height?: string | null | undefined;
|
|
69
|
+
contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
|
|
70
|
+
linkHref?: string | null | undefined;
|
|
71
|
+
autoplay?: boolean | null | undefined;
|
|
72
|
+
loop?: boolean | null | undefined;
|
|
73
|
+
muted?: boolean | null | undefined;
|
|
74
|
+
controls?: boolean | null | undefined;
|
|
75
|
+
}>>>;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
style?: {
|
|
78
|
+
padding?: {
|
|
79
|
+
top: number;
|
|
80
|
+
bottom: number;
|
|
81
|
+
right: number;
|
|
82
|
+
left: number;
|
|
83
|
+
} | null | undefined;
|
|
84
|
+
backgroundColor?: string | null | undefined;
|
|
85
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
86
|
+
} | null | undefined;
|
|
87
|
+
props?: {
|
|
88
|
+
url?: string | null | undefined;
|
|
89
|
+
alt?: string | null | undefined;
|
|
90
|
+
width?: string | null | undefined;
|
|
91
|
+
height?: string | null | undefined;
|
|
92
|
+
contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
|
|
93
|
+
linkHref?: string | null | undefined;
|
|
94
|
+
autoplay?: boolean | null | undefined;
|
|
95
|
+
loop?: boolean | null | undefined;
|
|
96
|
+
muted?: boolean | null | undefined;
|
|
97
|
+
controls?: boolean | null | undefined;
|
|
98
|
+
} | null | undefined;
|
|
99
|
+
}, {
|
|
100
|
+
style?: {
|
|
101
|
+
padding?: {
|
|
102
|
+
top: number;
|
|
103
|
+
bottom: number;
|
|
104
|
+
right: number;
|
|
105
|
+
left: number;
|
|
106
|
+
} | null | undefined;
|
|
107
|
+
backgroundColor?: string | null | undefined;
|
|
108
|
+
textAlign?: "right" | "left" | "center" | null | undefined;
|
|
109
|
+
} | null | undefined;
|
|
110
|
+
props?: {
|
|
111
|
+
url?: string | null | undefined;
|
|
112
|
+
alt?: string | null | undefined;
|
|
113
|
+
width?: string | null | undefined;
|
|
114
|
+
height?: string | null | undefined;
|
|
115
|
+
contentAlignment?: "top" | "bottom" | "middle" | null | undefined;
|
|
116
|
+
linkHref?: string | null | undefined;
|
|
117
|
+
autoplay?: boolean | null | undefined;
|
|
118
|
+
loop?: boolean | null | undefined;
|
|
119
|
+
muted?: boolean | null | undefined;
|
|
120
|
+
controls?: boolean | null | undefined;
|
|
121
|
+
} | null | undefined;
|
|
122
|
+
}>;
|
|
123
|
+
export type VideoProps = z.infer<typeof VideoPropsSchema>;
|
|
124
|
+
export declare function Video({ style, props }: VideoProps): React.JSX.Element | null;
|
|
125
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAexB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4B3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,wBAAgB,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,UAAU,4BA0DjD"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
const PADDING_SCHEMA = z
|
|
4
|
+
.object({
|
|
5
|
+
top: z.number(),
|
|
6
|
+
bottom: z.number(),
|
|
7
|
+
right: z.number(),
|
|
8
|
+
left: z.number(),
|
|
9
|
+
})
|
|
10
|
+
.optional()
|
|
11
|
+
.nullable();
|
|
12
|
+
const getPadding = (padding) => padding ? `${padding.top}px ${padding.right}px ${padding.bottom}px ${padding.left}px` : undefined;
|
|
13
|
+
export const VideoPropsSchema = z.object({
|
|
14
|
+
style: z
|
|
15
|
+
.object({
|
|
16
|
+
padding: PADDING_SCHEMA,
|
|
17
|
+
backgroundColor: z
|
|
18
|
+
.string()
|
|
19
|
+
.regex(/^#[0-9a-fA-F]{6}$/)
|
|
20
|
+
.optional()
|
|
21
|
+
.nullable(),
|
|
22
|
+
textAlign: z.enum(['center', 'left', 'right']).optional().nullable(),
|
|
23
|
+
})
|
|
24
|
+
.optional()
|
|
25
|
+
.nullable(),
|
|
26
|
+
props: z
|
|
27
|
+
.object({
|
|
28
|
+
url: z.string().optional().nullable(),
|
|
29
|
+
alt: z.string().optional().nullable(),
|
|
30
|
+
width: z.string().optional().nullable(),
|
|
31
|
+
height: z.string().optional().nullable(),
|
|
32
|
+
contentAlignment: z.enum(['top', 'middle', 'bottom']).optional().nullable(),
|
|
33
|
+
linkHref: z.string().optional().nullable(),
|
|
34
|
+
autoplay: z.boolean().optional().nullable(),
|
|
35
|
+
loop: z.boolean().optional().nullable(),
|
|
36
|
+
muted: z.boolean().optional().nullable(),
|
|
37
|
+
controls: z.boolean().optional().nullable(),
|
|
38
|
+
})
|
|
39
|
+
.optional()
|
|
40
|
+
.nullable(),
|
|
41
|
+
});
|
|
42
|
+
export function Video({ style, props }) {
|
|
43
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
44
|
+
const sectionStyle = {
|
|
45
|
+
padding: getPadding(style === null || style === void 0 ? void 0 : style.padding),
|
|
46
|
+
backgroundColor: (_a = style === null || style === void 0 ? void 0 : style.backgroundColor) !== null && _a !== void 0 ? _a : undefined,
|
|
47
|
+
textAlign: (_b = style === null || style === void 0 ? void 0 : style.textAlign) !== null && _b !== void 0 ? _b : undefined,
|
|
48
|
+
display: 'flex',
|
|
49
|
+
justifyContent: 'center',
|
|
50
|
+
alignItems: (props === null || props === void 0 ? void 0 : props.contentAlignment) === 'top' ? 'flex-start' :
|
|
51
|
+
(props === null || props === void 0 ? void 0 : props.contentAlignment) === 'bottom' ? 'flex-end' : 'center',
|
|
52
|
+
width: '100%',
|
|
53
|
+
};
|
|
54
|
+
// 如果没有 URL,不渲染任何内容
|
|
55
|
+
if (!(props === null || props === void 0 ? void 0 : props.url)) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const videoUrl = props.url;
|
|
59
|
+
const width = props.width || '100%';
|
|
60
|
+
const height = props.height || 'auto';
|
|
61
|
+
const autoplay = (_c = props.autoplay) !== null && _c !== void 0 ? _c : false;
|
|
62
|
+
const loop = (_d = props.loop) !== null && _d !== void 0 ? _d : false;
|
|
63
|
+
const muted = (_e = props.muted) !== null && _e !== void 0 ? _e : false;
|
|
64
|
+
const controls = (_f = props.controls) !== null && _f !== void 0 ? _f : true;
|
|
65
|
+
const videoStyle = {
|
|
66
|
+
maxWidth: '100%',
|
|
67
|
+
height: height === 'auto' ? 'auto' : height,
|
|
68
|
+
};
|
|
69
|
+
const videoElement = (React.createElement("video", { src: videoUrl, width: width, height: height, autoPlay: autoplay, loop: loop, muted: muted, controls: controls, style: videoStyle }, "Your browser does not support the video tag."));
|
|
70
|
+
const linkHref = (_g = props.linkHref) !== null && _g !== void 0 ? _g : null;
|
|
71
|
+
if (!linkHref) {
|
|
72
|
+
return React.createElement("div", { style: sectionStyle }, videoElement);
|
|
73
|
+
}
|
|
74
|
+
return (React.createElement("div", { style: sectionStyle },
|
|
75
|
+
React.createElement("a", { href: linkHref, style: { textDecoration: 'none' }, target: "_blank" }, videoElement)));
|
|
76
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "monto-email-block-video",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "monto-email compatible Video component",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "npx tsc",
|
|
20
|
+
"prepublishOnly": "npm run build",
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
22
|
+
},
|
|
23
|
+
"author": "heiheihoho1213",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": "^16 || ^17 || ^18",
|
|
27
|
+
"zod": "^1 || ^2 || ^3"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/react": "^18.3.1",
|
|
31
|
+
"react": "^18.3.1",
|
|
32
|
+
"zod": "^3.24.2",
|
|
33
|
+
"@testing-library/react": "^14.2.1",
|
|
34
|
+
"typescript": "^5.0.0"
|
|
35
|
+
}
|
|
36
|
+
}
|