@sqrzro/ui 4.0.0-alpha.65 → 4.0.0-alpha.67
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,6 +2,7 @@ import type { EditableFormFieldComponentProps } from '../../interfaces';
|
|
|
2
2
|
import type { ColorInputComponentProps } from '../ColorInput';
|
|
3
3
|
import type { DropdownComponentProps } from '../Dropdown';
|
|
4
4
|
import type { ImageInputComponentProps } from '../ImageInput';
|
|
5
|
+
import type { SwitchComponentProps } from '../Switch';
|
|
5
6
|
import type { TextAreaComponentProps } from '../TextArea';
|
|
6
7
|
import type { TextInputComponentProps } from '../TextInput';
|
|
7
8
|
export type EditableColorFormFieldProps = EditableFormFieldComponentProps<string | undefined> & ColorInputComponentProps;
|
|
@@ -10,6 +11,8 @@ export type EditableDropdownFormFieldProps<T> = EditableFormFieldComponentProps<
|
|
|
10
11
|
export declare function EditableDropdownFormField<T>(props: Readonly<EditableDropdownFormFieldProps<T>>): React.ReactElement;
|
|
11
12
|
export type EditableImageFormFieldProps = EditableFormFieldComponentProps<string | null> & ImageInputComponentProps;
|
|
12
13
|
export declare function EditableImageFormField(props: Readonly<EditableImageFormFieldProps>): React.ReactElement;
|
|
14
|
+
export type EditableSwitchFormFieldProps = EditableFormFieldComponentProps<boolean> & SwitchComponentProps;
|
|
15
|
+
export declare function EditableSwitchFormField(props: Readonly<EditableSwitchFormFieldProps>): React.ReactElement;
|
|
13
16
|
export type EditableTextAreaFormFieldProps = EditableFormFieldComponentProps<string> & TextAreaComponentProps;
|
|
14
17
|
export declare function EditableTextAreaFormField(props: Readonly<EditableTextAreaFormFieldProps>): React.ReactElement;
|
|
15
18
|
export type EditableTextFormFieldProps = EditableFormFieldComponentProps<string> & TextInputComponentProps;
|
|
@@ -5,8 +5,9 @@ import tw from '../../../styles/classnames/utility/tw';
|
|
|
5
5
|
import extractEditableInputProps from '../../utility/extract-editable-input-props';
|
|
6
6
|
import ColorInput from '../ColorInput';
|
|
7
7
|
import Dropdown from '../Dropdown';
|
|
8
|
-
import ImageInput from '../ImageInput';
|
|
9
8
|
import EditableFormField from '../EditableFormField';
|
|
9
|
+
import ImageInput from '../ImageInput';
|
|
10
|
+
import Switch from '../Switch';
|
|
10
11
|
import TextArea from '../TextArea';
|
|
11
12
|
import TextInput from '../TextInput';
|
|
12
13
|
export function EditableColorFormField(props) {
|
|
@@ -42,6 +43,14 @@ export function EditableImageFormField(props) {
|
|
|
42
43
|
}, [fieldProps.value]);
|
|
43
44
|
return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
|
|
44
45
|
}
|
|
46
|
+
export function EditableSwitchFormField(props) {
|
|
47
|
+
const { fieldProps, inputProps } = extractEditableInputProps(props);
|
|
48
|
+
const renderInput = useCallback((renderProps) => (_jsx(Switch, { ...renderProps, ...inputProps, label: null })), [inputProps]);
|
|
49
|
+
const renderValue = useCallback((value) => {
|
|
50
|
+
return _jsx("div", { children: value ? 'Yes' : 'No' });
|
|
51
|
+
}, [inputProps]);
|
|
52
|
+
return _jsx(EditableFormField, { ...fieldProps, render: renderInput, renderValue: renderValue });
|
|
53
|
+
}
|
|
45
54
|
export function EditableTextAreaFormField(props) {
|
|
46
55
|
const { fieldProps, inputProps } = extractEditableInputProps(props);
|
|
47
56
|
const renderInput = useCallback((renderProps) => (_jsx(TextArea, { ...renderProps, ...inputProps })), [inputProps]);
|
|
@@ -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
|
}
|