@sqrzro/ui 4.0.0-alpha.41 → 4.0.0-alpha.42

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.
@@ -31,14 +31,6 @@ export type { AppForbiddenErrorProps } from './errors/AppForbiddenError';
31
31
  export { default as AppForbiddenError } from './errors/AppForbiddenError';
32
32
  export type { AppNotFoundErrorProps } from './errors/AppNotFoundError';
33
33
  export { default as AppNotFoundError } from './errors/AppNotFoundError';
34
- export type { MailProps } from './mail/Mail';
35
- export { default as Mail } from './mail/Mail';
36
- export type { MailBlockProps } from './mail/MailBlock';
37
- export { default as MailBlock } from './mail/MailBlock';
38
- export type { MailButtonProps } from './mail/MailButton';
39
- export { default as MailButton } from './mail/MailButton';
40
- export type { MailTableProps } from './mail/MailTable';
41
- export { default as MailTable } from './mail/MailTable';
42
34
  export type { ModalProps } from './modals/Modal';
43
35
  export { default as Modal } from './modals/Modal';
44
36
  export type { ModalLauncherProps } from './modals/ModalLauncher';
@@ -15,10 +15,6 @@ export { default as Summary } from './elements/Summary';
15
15
  export { default as AppError } from './errors/AppError';
16
16
  export { default as AppForbiddenError } from './errors/AppForbiddenError';
17
17
  export { default as AppNotFoundError } from './errors/AppNotFoundError';
18
- export { default as Mail } from './mail/Mail';
19
- export { default as MailBlock } from './mail/MailBlock';
20
- export { default as MailButton } from './mail/MailButton';
21
- export { default as MailTable } from './mail/MailTable';
22
18
  export { default as Modal } from './modals/Modal';
23
19
  export { default as ModalLauncher } from './modals/ModalLauncher';
24
20
  export { default as Container } from './utility/Container';
@@ -1,7 +1,8 @@
1
- import type { AppConfig } from '@sqrzro/config';
2
- export type MailProps = AppConfig['mail'] & {
1
+ import { DeepPartial } from '@sqrzro/utility';
2
+ import { MailConfigObject } from '../utility/interfaces';
3
+ export interface MailProps extends DeepPartial<MailConfigObject> {
3
4
  children: React.ReactNode;
4
5
  title: string;
5
- };
6
+ }
6
7
  declare function Mail({ children, logo, styles, title, }: Readonly<MailProps>): Promise<React.ReactElement>;
7
8
  export default Mail;
@@ -1,28 +1,11 @@
1
+ 'use server';
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- /* eslint-disable max-lines-per-function, react/jsx-max-depth, react/no-danger */
3
3
  import { Fragment } from 'react';
4
- import { deepMerge } from '@sqrzro/utility';
5
- import { getConfig } from '../../../addon/config';
6
- const DEFAULT_STYLES = {
7
- styles: {
8
- root: {
9
- backgroundColor: '#f5f5f5',
10
- },
11
- panel: {
12
- backgroundColor: '#ffffff',
13
- padding: 40,
14
- },
15
- title: {
16
- color: '#62748e',
17
- fontSize: 20,
18
- fontWeight: 'bold',
19
- },
20
- },
21
- };
4
+ import getMailConfig from '../utility/get-mail-config';
22
5
  const HALF = 2;
23
6
  async function Mail({ children, logo, styles, title, }) {
24
- const styleConfig = deepMerge(DEFAULT_STYLES?.styles || {}, getConfig().app.mail?.styles || {}, styles || {});
25
- const logoData = await (await import('../../../utility/convert-to-datauri')).default(logo ?? getConfig().app.mail?.logo ?? '');
7
+ const mailConfig = getMailConfig({ styles });
8
+ const logoData = await (await import('../utility/convert-to-datauri')).default(logo ?? mailConfig.logo ?? '');
26
9
  return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { charSet: "utf-8" }), _jsx("style", { dangerouslySetInnerHTML: {
27
10
  __html: `
28
11
  body {
@@ -48,66 +31,76 @@ async function Mail({ children, logo, styles, title, }) {
48
31
  }
49
32
  }
50
33
  `,
51
- } })] }), _jsx("body", { children: _jsx("table", { border: 0, cellPadding: 0, cellSpacing: 0, width: "100%", children: _jsxs("tbody", { children: [_jsx("tr", { children: _jsx("td", { className: "padding", colSpan: 3, height: "20", style: { backgroundColor: styleConfig.root.backgroundColor } }) }), _jsxs("tr", { children: [_jsx("td", { className: "padding", style: { backgroundColor: styleConfig.root.backgroundColor }, width: "20" }), _jsx("td", { align: "center", style: { backgroundColor: styleConfig.root.backgroundColor }, children: _jsx("table", { border: 0, cellPadding: 0, cellSpacing: 0, className: "container", width: "650", children: _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { className: "padding", height: "20", style: {
52
- backgroundColor: styleConfig.panel.backgroundColor,
34
+ } })] }), _jsx("body", { children: _jsx("table", { border: 0, cellPadding: 0, cellSpacing: 0, width: "100%", children: _jsxs("tbody", { children: [_jsx("tr", { children: _jsx("td", { className: "padding", colSpan: 3, height: "20", style: { backgroundColor: mailConfig.styles.root.backgroundColor } }) }), _jsxs("tr", { children: [_jsx("td", { className: "padding", style: { backgroundColor: mailConfig.styles.root.backgroundColor }, width: "20" }), _jsx("td", { align: "center", style: { backgroundColor: mailConfig.styles.root.backgroundColor }, children: _jsx("table", { border: 0, cellPadding: 0, cellSpacing: 0, className: "container", width: "650", children: _jsxs("tbody", { children: [_jsxs("tr", { children: [_jsx("td", { className: "padding", height: "20", style: {
35
+ backgroundColor: mailConfig.styles.panel.backgroundColor,
53
36
  }, width: "20", children: _jsx("div", { className: "padding", style: {
54
- backgroundColor: styleConfig.root.backgroundColor,
55
- height: styleConfig.panel.padding,
56
- width: styleConfig.panel.padding,
37
+ backgroundColor: mailConfig.styles.root.backgroundColor,
38
+ height: mailConfig.styles.panel.padding,
39
+ width: mailConfig.styles.panel.padding,
57
40
  }, children: _jsx("div", { className: "padding", style: {
58
- backgroundColor: styleConfig.panel.backgroundColor,
59
- borderTopLeftRadius: styleConfig.panel.padding / HALF,
60
- height: styleConfig.panel.padding,
61
- width: styleConfig.panel.padding,
41
+ backgroundColor: mailConfig.styles.panel
42
+ .backgroundColor,
43
+ borderTopLeftRadius: mailConfig.styles.panel.padding /
44
+ HALF,
45
+ height: mailConfig.styles.panel.padding,
46
+ width: mailConfig.styles.panel.padding,
62
47
  } }) }) }), _jsx("td", { className: "container", style: {
63
- backgroundColor: styleConfig.panel.backgroundColor,
64
- }, width: "610" }), _jsx("td", { className: "padding", height: styleConfig.panel.padding, style: {
65
- backgroundColor: styleConfig.panel.backgroundColor,
66
- }, width: styleConfig.panel.padding, children: _jsx("div", { className: "padding", style: {
67
- backgroundColor: styleConfig.root.backgroundColor,
68
- height: styleConfig.panel.padding,
69
- width: styleConfig.panel.padding,
48
+ backgroundColor: mailConfig.styles.panel.backgroundColor,
49
+ }, width: "610" }), _jsx("td", { className: "padding", height: mailConfig.styles.panel.padding, style: {
50
+ backgroundColor: mailConfig.styles.panel.backgroundColor,
51
+ }, width: mailConfig.styles.panel.padding, children: _jsx("div", { className: "padding", style: {
52
+ backgroundColor: mailConfig.styles.root.backgroundColor,
53
+ height: mailConfig.styles.panel.padding,
54
+ width: mailConfig.styles.panel.padding,
70
55
  }, children: _jsx("div", { className: "padding", style: {
71
- backgroundColor: styleConfig.panel.backgroundColor,
72
- borderTopRightRadius: styleConfig.panel.padding / HALF,
73
- height: styleConfig.panel.padding,
74
- width: styleConfig.panel.padding,
56
+ backgroundColor: mailConfig.styles.panel
57
+ .backgroundColor,
58
+ borderTopRightRadius: mailConfig.styles.panel.padding /
59
+ HALF,
60
+ height: mailConfig.styles.panel.padding,
61
+ width: mailConfig.styles.panel.padding,
75
62
  } }) }) })] }), _jsxs("tr", { children: [_jsx("td", { className: "padding", style: {
76
- backgroundColor: styleConfig.panel.backgroundColor,
77
- }, width: styleConfig.panel.padding }), _jsx("td", { style: {
78
- backgroundColor: styleConfig.panel.backgroundColor,
79
- }, 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: styleConfig.panel
63
+ backgroundColor: mailConfig.styles.panel.backgroundColor,
64
+ }, width: mailConfig.styles.panel.padding }), _jsx("td", { style: {
65
+ backgroundColor: mailConfig.styles.panel.backgroundColor,
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
80
67
  .padding }) })] })) : null, _jsx("tr", { children: _jsx("td", { style: {
81
- color: styleConfig.title.color,
82
- fontSize: styleConfig.title.fontSize,
83
- fontWeight: styleConfig.title
68
+ color: mailConfig.styles.title
69
+ .color,
70
+ fontSize: mailConfig.styles.title
71
+ .fontSize,
72
+ fontWeight: mailConfig.styles.title
84
73
  .fontWeight,
85
- }, children: title }) }), _jsx("tr", { children: _jsx("td", { height: styleConfig.panel.padding }) }), _jsx("tr", { children: _jsx("td", { children: children }) })] }) }) }), _jsx("td", { className: "padding", style: {
86
- backgroundColor: styleConfig.panel.backgroundColor,
87
- }, width: styleConfig.panel.padding })] }), _jsxs("tr", { children: [_jsx("td", { className: "padding", height: styleConfig.panel.padding, style: {
88
- backgroundColor: styleConfig.panel.backgroundColor,
89
- }, width: styleConfig.panel.padding, children: _jsx("div", { className: "padding", style: {
90
- backgroundColor: styleConfig.root.backgroundColor,
91
- height: styleConfig.panel.padding,
92
- width: styleConfig.panel.padding,
74
+ }, children: title }) }), _jsx("tr", { children: _jsx("td", { height: mailConfig.styles.panel.padding }) }), _jsx("tr", { children: _jsx("td", { children: children }) })] }) }) }), _jsx("td", { className: "padding", style: {
75
+ backgroundColor: mailConfig.styles.panel.backgroundColor,
76
+ }, width: mailConfig.styles.panel.padding })] }), _jsxs("tr", { children: [_jsx("td", { className: "padding", height: mailConfig.styles.panel.padding, style: {
77
+ backgroundColor: mailConfig.styles.panel.backgroundColor,
78
+ }, width: mailConfig.styles.panel.padding, children: _jsx("div", { className: "padding", style: {
79
+ backgroundColor: mailConfig.styles.root.backgroundColor,
80
+ height: mailConfig.styles.panel.padding,
81
+ width: mailConfig.styles.panel.padding,
93
82
  }, children: _jsx("div", { className: "padding", style: {
94
- backgroundColor: styleConfig.panel.backgroundColor,
95
- borderBottomLeftRadius: styleConfig.panel.padding / HALF,
96
- height: styleConfig.panel.padding,
97
- width: styleConfig.panel.padding,
83
+ backgroundColor: mailConfig.styles.panel
84
+ .backgroundColor,
85
+ borderBottomLeftRadius: mailConfig.styles.panel.padding /
86
+ HALF,
87
+ height: mailConfig.styles.panel.padding,
88
+ width: mailConfig.styles.panel.padding,
98
89
  } }) }) }), _jsx("td", { className: "container", style: {
99
- backgroundColor: styleConfig.panel.backgroundColor,
100
- }, width: "610" }), _jsx("td", { className: "padding", height: styleConfig.panel.padding, style: {
101
- backgroundColor: styleConfig.panel.backgroundColor,
102
- }, width: styleConfig.panel.padding, children: _jsx("div", { className: "padding", style: {
103
- backgroundColor: styleConfig.root.backgroundColor,
104
- height: styleConfig.panel.padding,
105
- width: styleConfig.panel.padding,
90
+ backgroundColor: mailConfig.styles.panel.backgroundColor,
91
+ }, width: "610" }), _jsx("td", { className: "padding", height: mailConfig.styles.panel.padding, style: {
92
+ backgroundColor: mailConfig.styles.panel.backgroundColor,
93
+ }, width: mailConfig.styles.panel.padding, children: _jsx("div", { className: "padding", style: {
94
+ backgroundColor: mailConfig.styles.root.backgroundColor,
95
+ height: mailConfig.styles.panel.padding,
96
+ width: mailConfig.styles.panel.padding,
106
97
  }, children: _jsx("div", { className: "padding", style: {
107
- backgroundColor: styleConfig.panel.backgroundColor,
108
- borderBottomRightRadius: styleConfig.panel.padding / HALF,
109
- height: styleConfig.panel.padding,
110
- width: styleConfig.panel.padding,
111
- } }) }) })] })] }) }) }), _jsx("td", { className: "padding", style: { backgroundColor: styleConfig.root.backgroundColor }, width: "20" })] }), _jsx("tr", { children: _jsx("td", { className: "padding", colSpan: 3, height: "20", style: { backgroundColor: styleConfig.root.backgroundColor } }) })] }) }) })] }));
98
+ backgroundColor: mailConfig.styles.panel
99
+ .backgroundColor,
100
+ borderBottomRightRadius: mailConfig.styles.panel.padding /
101
+ HALF,
102
+ height: mailConfig.styles.panel.padding,
103
+ width: mailConfig.styles.panel.padding,
104
+ } }) }) })] })] }) }) }), _jsx("td", { className: "padding", style: { backgroundColor: mailConfig.styles.root.backgroundColor }, width: "20" })] }), _jsx("tr", { children: _jsx("td", { className: "padding", colSpan: 3, height: "20", style: { backgroundColor: mailConfig.styles.root.backgroundColor } }) })] }) }) })] }));
112
105
  }
113
106
  export default Mail;
@@ -0,0 +1,8 @@
1
+ import type { DeepPartial } from '@sqrzro/utility';
2
+ import { MailConfigObject } from '../utility/interfaces';
3
+ export interface MailButtonProps extends DeepPartial<MailConfigObject> {
4
+ children: string;
5
+ href: string;
6
+ }
7
+ declare function MailButton({ children, href, styles, }: MailButtonProps): Promise<React.ReactElement>;
8
+ export default MailButton;
@@ -0,0 +1,28 @@
1
+ 'use server';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import getMailConfig from '../utility/get-mail-config';
4
+ function calculateWidth(text) {
5
+ const characterWidth = 8;
6
+ const padding = 50;
7
+ return text.length * characterWidth + padding;
8
+ }
9
+ async function MailButton({ children, href, styles, }) {
10
+ const mailConfig = getMailConfig({ styles });
11
+ const calculatedWidth = calculateWidth(children);
12
+ return (_jsx("div", { dangerouslySetInnerHTML: {
13
+ __html: `
14
+ <!--[if mso]>
15
+ <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="${href}" style="height:${mailConfig.styles.button.height}px;v-text-anchor:middle;width:${calculatedWidth}px;" arcsize="50%" stroke="f" fillcolor="${mailConfig.styles.button.backgroundColor}">
16
+ <w:anchorlock/>
17
+ <center>
18
+ <![endif]-->
19
+ <a href="${href}"
20
+ style="background-color:${mailConfig.styles.button.backgroundColor};border-radius:${mailConfig.styles.button.borderRadius}px;color:${mailConfig.styles.button.color};display:inline-block;font-weight:bold;line-height:${mailConfig.styles.button.height}px;text-align:center;text-decoration:none;width:${calculatedWidth}px;-webkit-text-size-adjust:none;">${children}</a>
21
+ <!--[if mso]>
22
+ </center>
23
+ </v:roundrect>
24
+ <![endif]-->
25
+ `,
26
+ } }));
27
+ }
28
+ export default MailButton;
@@ -0,0 +1,8 @@
1
+ export type { MailProps } from './Mail';
2
+ export { default as Mail } from './Mail';
3
+ export type { MailBlockProps } from './MailBlock';
4
+ export { default as MailBlock } from './MailBlock';
5
+ export type { MailButtonProps } from './MailButton';
6
+ export { default as MailButton } from './MailButton';
7
+ export type { MailTableProps } from './MailTable';
8
+ export { default as MailTable } from './MailTable';
@@ -0,0 +1,4 @@
1
+ export { default as Mail } from './Mail';
2
+ export { default as MailBlock } from './MailBlock';
3
+ export { default as MailButton } from './MailButton';
4
+ export { default as MailTable } from './MailTable';
@@ -3,7 +3,8 @@ import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  async function convertToDataURI(fileName) {
5
5
  try {
6
- const filePath = path.resolve('./src', `.${fileName}`);
6
+ const filePath = path.resolve(fileName);
7
+ console.log('Converting file to Data URI:', filePath);
7
8
  const mimeType = 'image/' + path.extname(filePath).slice(1);
8
9
  const imageData = fs.readFileSync(filePath);
9
10
  const base64Image = Buffer.from(imageData).toString('base64');
@@ -0,0 +1,4 @@
1
+ import type { DeepPartial } from '@sqrzro/utility';
2
+ import type { MailConfigObject } from './interfaces';
3
+ declare function getMailConfig(overrides?: DeepPartial<MailConfigObject>): MailConfigObject;
4
+ export default getMailConfig;
@@ -0,0 +1,34 @@
1
+ import { deepMerge } from '@sqrzro/utility';
2
+ const DEFAULT_STYLES = {
3
+ styles: {
4
+ button: {
5
+ backgroundColor: '#0f172b',
6
+ borderRadius: 4,
7
+ color: '#ffffff',
8
+ height: 40,
9
+ },
10
+ panel: {
11
+ backgroundColor: '#ffffff',
12
+ padding: 40,
13
+ },
14
+ root: {
15
+ backgroundColor: '#f5f5f5',
16
+ },
17
+ title: {
18
+ color: '#62748e',
19
+ fontSize: 20,
20
+ fontWeight: 'bold',
21
+ },
22
+ },
23
+ };
24
+ function getMailConfig(overrides) {
25
+ const string = process.env.MAIL_CONFIG || '{}';
26
+ try {
27
+ const object = JSON.parse(string);
28
+ return deepMerge(DEFAULT_STYLES, object, overrides || {});
29
+ }
30
+ catch (err) {
31
+ return deepMerge(DEFAULT_STYLES, overrides || {});
32
+ }
33
+ }
34
+ export default getMailConfig;
@@ -0,0 +1,23 @@
1
+ export interface MailConfigObject {
2
+ logo?: string;
3
+ styles: {
4
+ root: {
5
+ backgroundColor: string;
6
+ };
7
+ panel: {
8
+ backgroundColor: string;
9
+ padding: number;
10
+ };
11
+ button: {
12
+ backgroundColor: string;
13
+ borderRadius: number;
14
+ color: string;
15
+ height: number;
16
+ };
17
+ title: {
18
+ color: string;
19
+ fontSize: number;
20
+ fontWeight: string;
21
+ };
22
+ };
23
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqrzro/ui",
3
3
  "type": "module",
4
- "version": "4.0.0-alpha.41",
4
+ "version": "4.0.0-alpha.42",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "ISC",
@@ -26,6 +26,10 @@
26
26
  "types": "./dist/hooks/index.d.ts",
27
27
  "default": "./dist/hooks/index.js"
28
28
  },
29
+ "./mail": {
30
+ "types": "./dist/mail/index.d.ts",
31
+ "default": "./dist/mail/index.js"
32
+ },
29
33
  "./navigation": {
30
34
  "types": "./dist/navigation/index.d.ts",
31
35
  "default": "./dist/navigation/index.js"
@@ -53,9 +57,8 @@
53
57
  "react-dom": "^19.2.4",
54
58
  "tailwind-merge": "^3.5.0",
55
59
  "use-deep-compare-effect": "^1.8.1",
56
- "@sqrzro/addons": "^4.0.0-alpha.5",
57
- "@sqrzro/utility": "^4.0.0-alpha.15",
58
- "@sqrzro/config": "^4.0.0-alpha.3"
60
+ "@sqrzro/addons": "^4.0.0-alpha.6",
61
+ "@sqrzro/utility": "^4.0.0-alpha.16"
59
62
  },
60
63
  "devDependencies": {
61
64
  "@storybook/addon-a11y": "^10.2.14",
@@ -1,5 +0,0 @@
1
- import { AppConfig } from '@sqrzro/config';
2
- import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
3
- import type { UIAddonConfigObject, BaseUIAddonConfigObject } from './interfaces';
4
- export declare function setConfig(db: NodePgDatabase, appConfig: AppConfig, cfg?: Partial<BaseUIAddonConfigObject>): void;
5
- export declare function getConfig(): UIAddonConfigObject;
@@ -1,12 +0,0 @@
1
- import { MissingConfigError } from '@sqrzro/addons';
2
- import applyDefaults from './defaults';
3
- let config = null;
4
- export function setConfig(db, appConfig, cfg) {
5
- config = { ...applyDefaults(cfg), db, app: appConfig };
6
- }
7
- export function getConfig() {
8
- if (!config) {
9
- throw new MissingConfigError('ui');
10
- }
11
- return config;
12
- }
@@ -1,3 +0,0 @@
1
- import type { BaseUIAddonConfigObject } from './interfaces';
2
- declare function applyDefaults(config?: Partial<BaseUIAddonConfigObject>): BaseUIAddonConfigObject;
3
- export default applyDefaults;
@@ -1,6 +0,0 @@
1
- import { deepMerge } from '@sqrzro/utility';
2
- const defaults = {};
3
- function applyDefaults(config) {
4
- return deepMerge(defaults, config || {});
5
- }
6
- export default applyDefaults;
@@ -1,5 +0,0 @@
1
- import type { AddonRegisterFunction } from '@sqrzro/addons';
2
- import { BaseUIAddonConfigObject } from './interfaces';
3
- export * from './interfaces';
4
- declare const withUI: AddonRegisterFunction<BaseUIAddonConfigObject>;
5
- export default withUI;
@@ -1,8 +0,0 @@
1
- import { setConfig } from './config';
2
- export * from './interfaces';
3
- const withUI = (config) => ({
4
- register: (db, appConfig) => {
5
- setConfig(db, appConfig, config);
6
- },
7
- });
8
- export default withUI;
@@ -1,8 +0,0 @@
1
- import { AppConfig } from '@sqrzro/config';
2
- import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
3
- export interface BaseUIAddonConfigObject {
4
- }
5
- export interface UIAddonConfigObject extends BaseUIAddonConfigObject {
6
- app: AppConfig;
7
- db: NodePgDatabase;
8
- }
@@ -1,7 +0,0 @@
1
- import type { AppConfig } from '@sqrzro/config';
2
- export type MailButtonProps = AppConfig['mail'] & {
3
- children: string;
4
- href: string;
5
- };
6
- declare function MailButton({ children, href, styles }: Readonly<MailButtonProps>): React.ReactElement;
7
- export default MailButton;
@@ -1,38 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { deepMerge } from '@sqrzro/utility';
3
- import { getConfig } from '../../../addon/config';
4
- const DEFAULT_STYLES = {
5
- styles: {
6
- button: {
7
- backgroundColor: '#f26c25',
8
- borderRadius: 20,
9
- color: '#ffffff',
10
- height: 40,
11
- },
12
- },
13
- };
14
- function calculateWidth(text) {
15
- const characterWidth = 8;
16
- const padding = 50;
17
- return text.length * characterWidth + padding;
18
- }
19
- function MailButton({ children, href, styles }) {
20
- const styleConfig = deepMerge(DEFAULT_STYLES?.styles || {}, getConfig().app.mail?.styles || {}, styles || {});
21
- const calculatedWidth = calculateWidth(children);
22
- return (_jsx("div", { dangerouslySetInnerHTML: {
23
- __html: `
24
- <!--[if mso]>
25
- <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="${href}" style="height:${styleConfig.button.height}px;v-text-anchor:middle;width:${calculatedWidth}px;" arcsize="50%" stroke="f" fillcolor="${styleConfig.button.backgroundColor}">
26
- <w:anchorlock/>
27
- <center>
28
- <![endif]-->
29
- <a href="${href}"
30
- style="background-color:${styleConfig.button.backgroundColor};border-radius:${styleConfig.button.borderRadius}px;color:${styleConfig.button.color};display:inline-block;font-weight:bold;line-height:${styleConfig.button.height}px;text-align:center;text-decoration:none;width:${calculatedWidth}px;-webkit-text-size-adjust:none;">${children}</a>
31
- <!--[if mso]>
32
- </center>
33
- </v:roundrect>
34
- <![endif]-->
35
- `,
36
- } }));
37
- }
38
- export default MailButton;
File without changes