@sqrzro/ui 4.0.0-alpha.65 → 4.0.0-alpha.66
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.
|
@@ -2,7 +2,7 @@ import { DeepPartial } from '@sqrzro/utility';
|
|
|
2
2
|
import { MailConfigObject } from '../utility/interfaces';
|
|
3
3
|
export interface MailProps extends DeepPartial<MailConfigObject> {
|
|
4
4
|
children: React.ReactNode;
|
|
5
|
-
title
|
|
5
|
+
title?: string;
|
|
6
6
|
}
|
|
7
7
|
declare function Mail({ children, logo, styles, title, }: Readonly<MailProps>): Promise<React.ReactElement>;
|
|
8
8
|
export default Mail;
|
package/dist/mail/Mail/index.js
CHANGED
|
@@ -64,14 +64,16 @@ async function Mail({ children, logo, styles, title, }) {
|
|
|
64
64
|
}, width: mailConfig.styles.panel.padding }), _jsx("td", { style: {
|
|
65
65
|
backgroundColor: mailConfig.styles.panel.backgroundColor,
|
|
66
66
|
}, children: _jsx("table", { border: 0, cellPadding: 0, cellSpacing: 0, width: "100%", children: _jsxs("tbody", { children: [logoData ? (_jsxs(Fragment, { children: [_jsx("tr", { children: _jsx("td", { children: _jsx("table", { border: 0, cellPadding: 0, cellSpacing: 0, width: 240, children: _jsx("tbody", { children: _jsx("tr", { children: _jsx("td", { children: _jsx("img", { alt: "Logo", src: logoData, width: 240 }) }) }) }) }) }) }), _jsx("tr", { children: _jsx("td", { height: mailConfig.styles.panel
|
|
67
|
-
.padding }) })] })) : null, _jsx("tr", { children: _jsx("td", { style: {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
.padding }) })] })) : null, title ? (_jsxs(Fragment, { children: [_jsx("tr", { children: _jsx("td", { style: {
|
|
68
|
+
color: mailConfig.styles
|
|
69
|
+
.title.color,
|
|
70
|
+
fontSize: mailConfig.styles
|
|
71
|
+
.title.fontSize,
|
|
72
|
+
fontWeight: mailConfig.styles
|
|
73
|
+
.title
|
|
74
|
+
.fontWeight,
|
|
75
|
+
}, children: title }) }), _jsx("tr", { children: _jsx("td", { height: mailConfig.styles.panel
|
|
76
|
+
.padding }) })] })) : null, _jsx("tr", { children: _jsx("td", { children: children }) })] }) }) }), _jsx("td", { className: "padding", style: {
|
|
75
77
|
backgroundColor: mailConfig.styles.panel.backgroundColor,
|
|
76
78
|
}, width: mailConfig.styles.panel.padding })] }), _jsxs("tr", { children: [_jsx("td", { className: "padding", height: mailConfig.styles.panel.padding, style: {
|
|
77
79
|
backgroundColor: mailConfig.styles.panel.backgroundColor,
|
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
'use server';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
function isURL(value) {
|
|
5
|
+
try {
|
|
6
|
+
const url = new URL(value);
|
|
7
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
8
|
+
}
|
|
9
|
+
catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
async function read(fileName) {
|
|
14
|
+
if (isURL(fileName)) {
|
|
15
|
+
const response = await fetch(fileName);
|
|
16
|
+
if (!response.ok) {
|
|
17
|
+
throw new Error(`Failed to fetch ${fileName}: ${response.status}`);
|
|
18
|
+
}
|
|
19
|
+
return Buffer.from(await response.arrayBuffer());
|
|
20
|
+
}
|
|
21
|
+
return fs.readFileSync(fileName);
|
|
22
|
+
}
|
|
4
23
|
async function convertToDataURI(fileName) {
|
|
5
24
|
try {
|
|
6
|
-
const filePath = path.
|
|
25
|
+
const filePath = path.isAbsolute(fileName) || isURL(fileName)
|
|
26
|
+
? fileName
|
|
27
|
+
: path.join(process.cwd(), fileName);
|
|
7
28
|
const mimeType = 'image/' + path.extname(filePath).slice(1);
|
|
8
|
-
const imageData =
|
|
29
|
+
const imageData = await read(filePath);
|
|
9
30
|
const base64Image = Buffer.from(imageData).toString('base64');
|
|
10
31
|
return Promise.resolve(`data:${mimeType};base64,${base64Image}`);
|
|
11
32
|
}
|