@dextinity/mail-react 2.0.0-canary-20260729062014
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 +24 -0
- package/README.md +112 -0
- package/lib/blocks/factories/BlocksBlock.d.ts +14 -0
- package/lib/blocks/factories/BlocksBlock.js +15 -0
- package/lib/blocks/factories/ListBlock.d.ts +13 -0
- package/lib/blocks/factories/ListBlock.js +5 -0
- package/lib/blocks/factories/OneOfBlock.d.ts +14 -0
- package/lib/blocks/factories/OneOfBlock.js +15 -0
- package/lib/blocks/factories/OptionalBlock.d.ts +10 -0
- package/lib/blocks/factories/OptionalBlock.js +7 -0
- package/lib/blocks/factories/types.d.ts +4 -0
- package/lib/blocks/factories/types.js +1 -0
- package/lib/blocks/helpers/PropsWithData.d.ts +3 -0
- package/lib/blocks/helpers/PropsWithData.js +1 -0
- package/lib/blocks/pixelImage/HtmlPixelImageBlock.d.ts +11 -0
- package/lib/blocks/pixelImage/HtmlPixelImageBlock.js +18 -0
- package/lib/blocks/pixelImage/MjmlPixelImageBlock.d.ts +9 -0
- package/lib/blocks/pixelImage/MjmlPixelImageBlock.js +15 -0
- package/lib/blocks/pixelImage/common.d.ts +18 -0
- package/lib/blocks/pixelImage/common.js +1 -0
- package/lib/blocks/pixelImage/usePixelImageBlockConfig.d.ts +5 -0
- package/lib/blocks/pixelImage/usePixelImageBlockConfig.js +11 -0
- package/lib/blocks/pixelImage/usePixelImageBlockData.d.ts +16 -0
- package/lib/blocks/pixelImage/usePixelImageBlockData.js +80 -0
- package/lib/blocks/richText/common.d.ts +66 -0
- package/lib/blocks/richText/common.js +1 -0
- package/lib/blocks/richText/createRichTextBlock.d.ts +30 -0
- package/lib/blocks/richText/createRichTextBlock.js +81 -0
- package/lib/blocks/richText/createRichTextRenderers.d.ts +17 -0
- package/lib/blocks/richText/createRichTextRenderers.js +83 -0
- package/lib/blocks.generated.d.ts +140 -0
- package/lib/blocks.generated.js +1 -0
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +1 -0
- package/lib/client/renderMailHtml.d.ts +9 -0
- package/lib/client/renderMailHtml.js +7 -0
- package/lib/components/button/HtmlButton.d.ts +9 -0
- package/lib/components/button/HtmlButton.js +58 -0
- package/lib/components/button/MjmlButton.d.ts +10 -0
- package/lib/components/button/MjmlButton.js +91 -0
- package/lib/components/button/buttonProps.d.ts +35 -0
- package/lib/components/button/buttonProps.js +1 -0
- package/lib/components/button/defaultButtonStyles.d.ts +2 -0
- package/lib/components/button/defaultButtonStyles.js +9 -0
- package/lib/components/button/generateResponsiveButtonCss.d.ts +8 -0
- package/lib/components/button/generateResponsiveButtonCss.js +21 -0
- package/lib/components/divider/HtmlDivider.d.ts +9 -0
- package/lib/components/divider/HtmlDivider.js +43 -0
- package/lib/components/divider/MjmlDivider.d.ts +7 -0
- package/lib/components/divider/MjmlDivider.js +13 -0
- package/lib/components/divider/defaultDividerStyles.d.ts +2 -0
- package/lib/components/divider/defaultDividerStyles.js +4 -0
- package/lib/components/divider/dividerProps.d.ts +51 -0
- package/lib/components/divider/dividerProps.js +1 -0
- package/lib/components/divider/generateResponsiveDividerCss.d.ts +8 -0
- package/lib/components/divider/generateResponsiveDividerCss.js +15 -0
- package/lib/components/image/HtmlImage.d.ts +11 -0
- package/lib/components/image/HtmlImage.js +23 -0
- package/lib/components/image/MjmlImage.d.ts +10 -0
- package/lib/components/image/MjmlImage.js +22 -0
- package/lib/components/inlineLink/HtmlInlineLink.d.ts +17 -0
- package/lib/components/inlineLink/HtmlInlineLink.js +35 -0
- package/lib/components/mailRoot/MjmlMailRoot.d.ts +32 -0
- package/lib/components/mailRoot/MjmlMailRoot.js +25 -0
- package/lib/components/section/MjmlSection.d.ts +21 -0
- package/lib/components/section/MjmlSection.js +48 -0
- package/lib/components/text/HtmlText.d.ts +51 -0
- package/lib/components/text/HtmlText.js +47 -0
- package/lib/components/text/MjmlText.d.ts +40 -0
- package/lib/components/text/MjmlText.js +65 -0
- package/lib/components/text/OutlookTextStyleContext.d.ts +9 -0
- package/lib/components/text/OutlookTextStyleContext.js +10 -0
- package/lib/components/text/textStyles.d.ts +10 -0
- package/lib/components/text/textStyles.js +24 -0
- package/lib/components/wrapper/InsideMjmlWrapperContext.d.ts +3 -0
- package/lib/components/wrapper/InsideMjmlWrapperContext.js +6 -0
- package/lib/components/wrapper/MjmlWrapper.d.ts +14 -0
- package/lib/components/wrapper/MjmlWrapper.js +12 -0
- package/lib/config/ConfigProvider.d.ts +43 -0
- package/lib/config/ConfigProvider.js +16 -0
- package/lib/index.d.ts +47 -0
- package/lib/index.js +29 -0
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +1 -0
- package/lib/server/renderMailHtml.d.ts +9 -0
- package/lib/server/renderMailHtml.js +7 -0
- package/lib/storybook/CopyMailHtmlButton.d.ts +4 -0
- package/lib/storybook/CopyMailHtmlButton.js +33 -0
- package/lib/storybook/MailRendererDecorator.d.ts +7 -0
- package/lib/storybook/MailRendererDecorator.js +17 -0
- package/lib/storybook/MjmlWarningsPanel.d.ts +7 -0
- package/lib/storybook/MjmlWarningsPanel.js +33 -0
- package/lib/storybook/UsePublicImageUrlsToggle.d.ts +4 -0
- package/lib/storybook/UsePublicImageUrlsToggle.js +14 -0
- package/lib/storybook/index.d.ts +2 -0
- package/lib/storybook/index.js +9 -0
- package/lib/storybook/manager.d.ts +1 -0
- package/lib/storybook/manager.js +25 -0
- package/lib/storybook/preview.d.ts +39 -0
- package/lib/storybook/preview.js +27 -0
- package/lib/storybook/replaceImagesWithPublicUrl.d.ts +1 -0
- package/lib/storybook/replaceImagesWithPublicUrl.js +15 -0
- package/lib/styles/Styles.d.ts +6 -0
- package/lib/styles/Styles.js +16 -0
- package/lib/styles/generateResponsiveVariantCss.d.ts +26 -0
- package/lib/styles/generateResponsiveVariantCss.js +66 -0
- package/lib/styles/registerStyles.d.ts +19 -0
- package/lib/styles/registerStyles.js +14 -0
- package/lib/theme/ThemeProvider.d.ts +8 -0
- package/lib/theme/ThemeProvider.js +17 -0
- package/lib/theme/createBreakpoint.d.ts +7 -0
- package/lib/theme/createBreakpoint.js +11 -0
- package/lib/theme/createTheme.d.ts +24 -0
- package/lib/theme/createTheme.js +32 -0
- package/lib/theme/defaultTheme.d.ts +2 -0
- package/lib/theme/defaultTheme.js +27 -0
- package/lib/theme/responsiveValue.d.ts +31 -0
- package/lib/theme/responsiveValue.js +34 -0
- package/lib/theme/themeTypes.d.ts +204 -0
- package/lib/theme/themeTypes.js +1 -0
- package/lib/utils/css.d.ts +4 -0
- package/lib/utils/css.js +4 -0
- package/package.json +91 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IMjmlStyleProps } from "@faire/mjml-react";
|
|
2
|
+
import type { Theme } from "../theme/themeTypes.js";
|
|
3
|
+
import type { css } from "../utils/css.js";
|
|
4
|
+
type StylesPayload = ReturnType<typeof css> | ((theme: Theme) => ReturnType<typeof css>);
|
|
5
|
+
type MjmlStyleOptions = Partial<Omit<IMjmlStyleProps, "children">>;
|
|
6
|
+
interface StyleRegistryEntry {
|
|
7
|
+
styles: StylesPayload;
|
|
8
|
+
mjmlStyleProps?: MjmlStyleOptions;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Registers CSS styles that will be rendered in the email head as `<mj-style>` elements.
|
|
12
|
+
*
|
|
13
|
+
* Styles can be static CSS strings (via the `css` tagged template) or functions that
|
|
14
|
+
* receive the theme and return a CSS string.
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerStyles(styles: StylesPayload, mjmlStyleProps?: MjmlStyleOptions): void;
|
|
17
|
+
/** Returns all registered style entries. */
|
|
18
|
+
export declare function getRegisteredStyles(): ReadonlyMap<StylesPayload, StyleRegistryEntry>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const registry = new Map();
|
|
2
|
+
/**
|
|
3
|
+
* Registers CSS styles that will be rendered in the email head as `<mj-style>` elements.
|
|
4
|
+
*
|
|
5
|
+
* Styles can be static CSS strings (via the `css` tagged template) or functions that
|
|
6
|
+
* receive the theme and return a CSS string.
|
|
7
|
+
*/
|
|
8
|
+
export function registerStyles(styles, mjmlStyleProps) {
|
|
9
|
+
registry.set(styles, { styles, mjmlStyleProps });
|
|
10
|
+
}
|
|
11
|
+
/** Returns all registered style entries. */
|
|
12
|
+
export function getRegisteredStyles() {
|
|
13
|
+
return registry;
|
|
14
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PropsWithChildren, type ReactNode } from "react";
|
|
2
|
+
import type { Theme } from "./themeTypes.js";
|
|
3
|
+
export declare function ThemeProvider({ theme, children }: PropsWithChildren<{
|
|
4
|
+
theme: Theme;
|
|
5
|
+
}>): ReactNode;
|
|
6
|
+
export declare function useTheme(): Theme;
|
|
7
|
+
/** Returns the current theme or `null` if no `ThemeProvider` is present. Internal use only. */
|
|
8
|
+
export declare function useOptionalTheme(): Theme | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const ThemeContext = createContext(null);
|
|
4
|
+
export function ThemeProvider({ theme, children }) {
|
|
5
|
+
return _jsx(ThemeContext.Provider, { value: theme, children: children });
|
|
6
|
+
}
|
|
7
|
+
export function useTheme() {
|
|
8
|
+
const theme = useContext(ThemeContext);
|
|
9
|
+
if (theme === null) {
|
|
10
|
+
throw new Error("useTheme must be used within a ThemeProvider (or MjmlMailRoot).");
|
|
11
|
+
}
|
|
12
|
+
return theme;
|
|
13
|
+
}
|
|
14
|
+
/** Returns the current theme or `null` if no `ThemeProvider` is present. Internal use only. */
|
|
15
|
+
export function useOptionalTheme() {
|
|
16
|
+
return useContext(ThemeContext);
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ThemeBreakpoint } from "./themeTypes.js";
|
|
2
|
+
/**
|
|
3
|
+
* Constructs a `ThemeBreakpoint` for use in `createTheme` overrides or
|
|
4
|
+
* `ThemeBreakpoints` module augmentation. Guarantees the `belowMediaQuery`
|
|
5
|
+
* string is always formatted correctly.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createBreakpoint(value: number): ThemeBreakpoint;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constructs a `ThemeBreakpoint` for use in `createTheme` overrides or
|
|
3
|
+
* `ThemeBreakpoints` module augmentation. Guarantees the `belowMediaQuery`
|
|
4
|
+
* string is always formatted correctly.
|
|
5
|
+
*/
|
|
6
|
+
export function createBreakpoint(value) {
|
|
7
|
+
return {
|
|
8
|
+
value,
|
|
9
|
+
belowMediaQuery: `@media (max-width: ${value - 1}px)`,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Theme, ThemeBackgroundColors, ThemeBreakpoints, ThemeButton, ThemeColors, ThemeDivider, ThemeSizes, ThemeText } from "./themeTypes.js";
|
|
2
|
+
type CreateThemeOverrides = {
|
|
3
|
+
sizes?: Partial<ThemeSizes>;
|
|
4
|
+
breakpoints?: Partial<ThemeBreakpoints>;
|
|
5
|
+
text?: Partial<ThemeText>;
|
|
6
|
+
divider?: Partial<ThemeDivider>;
|
|
7
|
+
button?: Partial<ThemeButton>;
|
|
8
|
+
colors?: {
|
|
9
|
+
background?: Partial<ThemeBackgroundColors>;
|
|
10
|
+
} & Partial<Omit<ThemeColors, "background">>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates a complete theme by merging optional overrides onto the default
|
|
14
|
+
* theme values.
|
|
15
|
+
*
|
|
16
|
+
* Breakpoint overrides must be `ThemeBreakpoint` objects constructed via
|
|
17
|
+
* `createBreakpoint`. Arbitrary breakpoint keys from `ThemeBreakpoints`
|
|
18
|
+
* module augmentation are supported and flow through to the result.
|
|
19
|
+
*
|
|
20
|
+
* `breakpoints.default` is always auto-derived from `sizes.bodyWidth` unless
|
|
21
|
+
* explicitly overridden.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createTheme(overrides?: CreateThemeOverrides): Theme;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createBreakpoint } from "./createBreakpoint.js";
|
|
2
|
+
import { defaultTheme } from "./defaultTheme.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a complete theme by merging optional overrides onto the default
|
|
5
|
+
* theme values.
|
|
6
|
+
*
|
|
7
|
+
* Breakpoint overrides must be `ThemeBreakpoint` objects constructed via
|
|
8
|
+
* `createBreakpoint`. Arbitrary breakpoint keys from `ThemeBreakpoints`
|
|
9
|
+
* module augmentation are supported and flow through to the result.
|
|
10
|
+
*
|
|
11
|
+
* `breakpoints.default` is always auto-derived from `sizes.bodyWidth` unless
|
|
12
|
+
* explicitly overridden.
|
|
13
|
+
*/
|
|
14
|
+
export function createTheme(overrides) {
|
|
15
|
+
const resolvedSizes = { ...defaultTheme.sizes, ...overrides?.sizes };
|
|
16
|
+
return {
|
|
17
|
+
sizes: resolvedSizes,
|
|
18
|
+
breakpoints: {
|
|
19
|
+
...defaultTheme.breakpoints,
|
|
20
|
+
default: createBreakpoint(resolvedSizes.bodyWidth),
|
|
21
|
+
...overrides?.breakpoints,
|
|
22
|
+
},
|
|
23
|
+
text: { ...defaultTheme.text, ...overrides?.text },
|
|
24
|
+
divider: { ...defaultTheme.divider, ...overrides?.divider },
|
|
25
|
+
button: { ...defaultTheme.button, ...overrides?.button },
|
|
26
|
+
colors: {
|
|
27
|
+
...defaultTheme.colors,
|
|
28
|
+
...overrides?.colors,
|
|
29
|
+
background: { ...defaultTheme.colors.background, ...overrides?.colors?.background },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defaultButtonStyles } from "../components/button/defaultButtonStyles.js";
|
|
2
|
+
import { defaultDividerStyles } from "../components/divider/defaultDividerStyles.js";
|
|
3
|
+
import { createBreakpoint } from "./createBreakpoint.js";
|
|
4
|
+
export const defaultTheme = {
|
|
5
|
+
sizes: {
|
|
6
|
+
bodyWidth: 600,
|
|
7
|
+
contentIndentation: { default: 32, mobile: 16 },
|
|
8
|
+
},
|
|
9
|
+
breakpoints: {
|
|
10
|
+
default: createBreakpoint(600),
|
|
11
|
+
mobile: createBreakpoint(420),
|
|
12
|
+
},
|
|
13
|
+
text: {
|
|
14
|
+
fontFamily: "Arial, sans-serif",
|
|
15
|
+
fontSize: "16px",
|
|
16
|
+
lineHeight: "20px",
|
|
17
|
+
bottomSpacing: "16px",
|
|
18
|
+
},
|
|
19
|
+
divider: defaultDividerStyles,
|
|
20
|
+
button: defaultButtonStyles,
|
|
21
|
+
colors: {
|
|
22
|
+
background: {
|
|
23
|
+
body: "#F2F2F2",
|
|
24
|
+
content: "#FFFFFF",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ThemeBreakpoints } from "./themeTypes.js";
|
|
2
|
+
/**
|
|
3
|
+
* A value that can vary per breakpoint. A plain `T` is shorthand for
|
|
4
|
+
* `{ default: T }` (inline only, no responsive overrides).
|
|
5
|
+
*
|
|
6
|
+
* The object form requires a `default` key and optional keys matching
|
|
7
|
+
* `ThemeBreakpoints` (including keys added via module augmentation).
|
|
8
|
+
*/
|
|
9
|
+
export type ResponsiveValue<T = number> = T | (Partial<Record<keyof ThemeBreakpoints, T>> & {
|
|
10
|
+
default: T;
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Returns the default (inline) value from a `ResponsiveValue`.
|
|
14
|
+
* For a plain value, returns it directly. For an object, returns the `default` property.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getDefaultFromResponsiveValue<T = number>(value: ResponsiveValue<T>): T;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the default value from a `ResponsiveValue`, or `undefined` if the
|
|
19
|
+
* input is `undefined`. Useful for extracting inline prop values from optional
|
|
20
|
+
* theme properties.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getDefaultOrUndefined<T>(value: ResponsiveValue<T> | undefined): T | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the non-default breakpoint overrides from a `ResponsiveValue`.
|
|
25
|
+
* For a plain value, returns an empty array. For an object, returns one
|
|
26
|
+
* entry per breakpoint key (excluding `default`).
|
|
27
|
+
*/
|
|
28
|
+
export declare function getResponsiveOverrides<T = number>(value: ResponsiveValue<T>): Array<{
|
|
29
|
+
breakpointKey: keyof ThemeBreakpoints;
|
|
30
|
+
value: T;
|
|
31
|
+
}>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function isResponsiveObject(value) {
|
|
2
|
+
return typeof value === "object" && value !== null && "default" in value;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Returns the default (inline) value from a `ResponsiveValue`.
|
|
6
|
+
* For a plain value, returns it directly. For an object, returns the `default` property.
|
|
7
|
+
*/
|
|
8
|
+
export function getDefaultFromResponsiveValue(value) {
|
|
9
|
+
return isResponsiveObject(value) ? value.default : value;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Returns the default value from a `ResponsiveValue`, or `undefined` if the
|
|
13
|
+
* input is `undefined`. Useful for extracting inline prop values from optional
|
|
14
|
+
* theme properties.
|
|
15
|
+
*/
|
|
16
|
+
export function getDefaultOrUndefined(value) {
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return getDefaultFromResponsiveValue(value);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the non-default breakpoint overrides from a `ResponsiveValue`.
|
|
24
|
+
* For a plain value, returns an empty array. For an object, returns one
|
|
25
|
+
* entry per breakpoint key (excluding `default`).
|
|
26
|
+
*/
|
|
27
|
+
export function getResponsiveOverrides(value) {
|
|
28
|
+
if (!isResponsiveObject(value)) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
return Object.entries(value)
|
|
32
|
+
.filter(([key]) => key !== "default")
|
|
33
|
+
.map(([key, val]) => ({ breakpointKey: key, value: val }));
|
|
34
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { ResponsiveValue } from "./responsiveValue.js";
|
|
2
|
+
/**
|
|
3
|
+
* Single source of truth for text style property names and their value types.
|
|
4
|
+
* Both `TextStyles` and `TextVariantStyles` are derived from this interface.
|
|
5
|
+
*/
|
|
6
|
+
interface TextStyleMap {
|
|
7
|
+
fontFamily: string;
|
|
8
|
+
fontSize: string;
|
|
9
|
+
fontWeight: string | number;
|
|
10
|
+
fontStyle: string;
|
|
11
|
+
lineHeight: string | number;
|
|
12
|
+
letterSpacing: string;
|
|
13
|
+
textDecoration: string;
|
|
14
|
+
textTransform: string;
|
|
15
|
+
color: string;
|
|
16
|
+
bottomSpacing: string;
|
|
17
|
+
}
|
|
18
|
+
/** Base text styles where each property holds a plain value. */
|
|
19
|
+
export type TextStyles = {
|
|
20
|
+
[K in keyof TextStyleMap]?: TextStyleMap[K];
|
|
21
|
+
};
|
|
22
|
+
/** Variant text styles where each property supports responsive values. */
|
|
23
|
+
export type TextVariantStyles = {
|
|
24
|
+
[K in keyof TextStyleMap]?: ResponsiveValue<TextStyleMap[K]>;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Defines the variants available on the `MjmlText` component.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* declare module "@dextinity/mail-react" {
|
|
31
|
+
* interface TextVariants {
|
|
32
|
+
* heading: true;
|
|
33
|
+
* body: true;
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export interface TextVariants {
|
|
39
|
+
}
|
|
40
|
+
type VariantsRecord = keyof TextVariants extends never ? Record<string, TextVariantStyles> : {
|
|
41
|
+
[K in keyof TextVariants]?: TextVariantStyles;
|
|
42
|
+
};
|
|
43
|
+
export type VariantName = keyof TextVariants extends never ? string : keyof TextVariants;
|
|
44
|
+
/** Theme configuration for text styles, variants, and default variant. */
|
|
45
|
+
export interface ThemeText extends TextStyles {
|
|
46
|
+
defaultVariant?: VariantName;
|
|
47
|
+
variants?: VariantsRecord;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Single source of truth for divider style property names and their value types.
|
|
51
|
+
* Both `DividerStyles` and `DividerVariantStyles` are derived from this interface.
|
|
52
|
+
*/
|
|
53
|
+
interface DividerStyleMap {
|
|
54
|
+
height: number;
|
|
55
|
+
backgroundColor: string;
|
|
56
|
+
backgroundImage: string;
|
|
57
|
+
}
|
|
58
|
+
/** Base divider styles where each property holds a plain value. */
|
|
59
|
+
export type DividerStyles = {
|
|
60
|
+
[K in keyof DividerStyleMap]?: DividerStyleMap[K];
|
|
61
|
+
};
|
|
62
|
+
/** Variant divider styles where each property supports responsive values. */
|
|
63
|
+
export type DividerVariantStyles = {
|
|
64
|
+
[K in keyof DividerStyleMap]?: ResponsiveValue<DividerStyleMap[K]>;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Defines the variants available on the `MjmlDivider` and `HtmlDivider` components.
|
|
68
|
+
*
|
|
69
|
+
* ```ts
|
|
70
|
+
* declare module "@dextinity/mail-react" {
|
|
71
|
+
* interface DividerVariants {
|
|
72
|
+
* thin: true;
|
|
73
|
+
* thick: true;
|
|
74
|
+
* }
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export interface DividerVariants {
|
|
79
|
+
}
|
|
80
|
+
type DividerVariantsRecord = keyof DividerVariants extends never ? Record<string, DividerVariantStyles> : {
|
|
81
|
+
[K in keyof DividerVariants]?: DividerVariantStyles;
|
|
82
|
+
};
|
|
83
|
+
export type DividerVariantName = keyof DividerVariants extends never ? string : keyof DividerVariants;
|
|
84
|
+
/** Theme configuration for divider styles, variants, and default variant. */
|
|
85
|
+
export interface ThemeDivider extends DividerStyles {
|
|
86
|
+
defaultVariant?: DividerVariantName;
|
|
87
|
+
variants?: DividerVariantsRecord;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Single source of truth for button style property names and their value types.
|
|
91
|
+
* Both `ButtonStyles` and `ButtonVariantStyles` are derived from this interface.
|
|
92
|
+
*
|
|
93
|
+
* `padding` is the button's inner padding (the space around the label). It is
|
|
94
|
+
* deliberately distinct from `MjmlButton`'s `padding` prop, which is the outer
|
|
95
|
+
* spacing around the button.
|
|
96
|
+
*/
|
|
97
|
+
interface ButtonStyleMap {
|
|
98
|
+
color: string;
|
|
99
|
+
backgroundColor: string;
|
|
100
|
+
/**
|
|
101
|
+
* A background image — typically a gradient. Rendered as progressive
|
|
102
|
+
* enhancement on top of `backgroundColor`; clients that don't render it
|
|
103
|
+
* (notably Outlook) fall back to the solid color.
|
|
104
|
+
*/
|
|
105
|
+
backgroundImage: string;
|
|
106
|
+
border: string;
|
|
107
|
+
borderRadius: string;
|
|
108
|
+
fontFamily: string;
|
|
109
|
+
fontSize: string;
|
|
110
|
+
fontWeight: string | number;
|
|
111
|
+
lineHeight: string | number;
|
|
112
|
+
padding: string;
|
|
113
|
+
}
|
|
114
|
+
/** Base button styles where each property holds a plain value. */
|
|
115
|
+
export type ButtonStyles = {
|
|
116
|
+
[K in keyof ButtonStyleMap]?: ButtonStyleMap[K];
|
|
117
|
+
};
|
|
118
|
+
/** Variant button styles where each property supports responsive values. */
|
|
119
|
+
export type ButtonVariantStyles = {
|
|
120
|
+
[K in keyof ButtonStyleMap]?: ResponsiveValue<ButtonStyleMap[K]>;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Defines the variants available on the `MjmlButton` and `HtmlButton` components.
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* declare module "@dextinity/mail-react" {
|
|
127
|
+
* interface ButtonVariants {
|
|
128
|
+
* primary: true;
|
|
129
|
+
* secondary: true;
|
|
130
|
+
* }
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export interface ButtonVariants {
|
|
135
|
+
}
|
|
136
|
+
type ButtonVariantsRecord = keyof ButtonVariants extends never ? Record<string, ButtonVariantStyles> : {
|
|
137
|
+
[K in keyof ButtonVariants]?: ButtonVariantStyles;
|
|
138
|
+
};
|
|
139
|
+
export type ButtonVariantName = keyof ButtonVariants extends never ? string : keyof ButtonVariants;
|
|
140
|
+
/** Theme configuration for button styles, variants, and default variant. */
|
|
141
|
+
export interface ThemeButton extends ButtonStyles {
|
|
142
|
+
defaultVariant?: ButtonVariantName;
|
|
143
|
+
variants?: ButtonVariantsRecord;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A resolved breakpoint with its numeric value and a ready-to-use media query
|
|
147
|
+
* string that targets viewports narrower than this breakpoint.
|
|
148
|
+
*/
|
|
149
|
+
export interface ThemeBreakpoint {
|
|
150
|
+
/** The breakpoint width in pixels. */
|
|
151
|
+
value: number;
|
|
152
|
+
/** A CSS media query matching viewports below this breakpoint, e.g. `"@media (max-width: 599px)"`. */
|
|
153
|
+
belowMediaQuery: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Responsive breakpoints used by the email layout.
|
|
157
|
+
*
|
|
158
|
+
* The `default` breakpoint typically matches the body width, while `mobile`
|
|
159
|
+
* defines the narrow viewport threshold.
|
|
160
|
+
*/
|
|
161
|
+
export interface ThemeBreakpoints {
|
|
162
|
+
/** The default breakpoint, usually equal to `sizes.bodyWidth`. */
|
|
163
|
+
default: ThemeBreakpoint;
|
|
164
|
+
/**
|
|
165
|
+
* The mobile breakpoint — the viewport width below which the layout is
|
|
166
|
+
* considered "mobile".
|
|
167
|
+
*
|
|
168
|
+
* When used with `MjmlMailRoot`, this value also controls the MJML
|
|
169
|
+
* responsive breakpoint (`<mj-breakpoint>`), which determines the viewport
|
|
170
|
+
* width at which columns stack vertically.
|
|
171
|
+
*/
|
|
172
|
+
mobile: ThemeBreakpoint;
|
|
173
|
+
}
|
|
174
|
+
/** Numeric size tokens for the email layout. */
|
|
175
|
+
export interface ThemeSizes {
|
|
176
|
+
/** The width of the email body in pixels. */
|
|
177
|
+
bodyWidth: number;
|
|
178
|
+
/** Content indentation (left/right padding) in pixels, supporting per-breakpoint values. */
|
|
179
|
+
contentIndentation: ResponsiveValue;
|
|
180
|
+
}
|
|
181
|
+
/** Background color tokens for usage through the email layout. */
|
|
182
|
+
export interface ThemeBackgroundColors {
|
|
183
|
+
body: string;
|
|
184
|
+
content: string;
|
|
185
|
+
}
|
|
186
|
+
/** Color tokens for usage through the email layout. */
|
|
187
|
+
export interface ThemeColors {
|
|
188
|
+
background: ThemeBackgroundColors;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The root theme object that holds all design tokens for `@dextinity/mail-react`.
|
|
192
|
+
*
|
|
193
|
+
* Every sub-interface is declared as an `interface` so consumers can
|
|
194
|
+
* extend the theme at any level via TypeScript module augmentation.
|
|
195
|
+
*/
|
|
196
|
+
export interface Theme {
|
|
197
|
+
sizes: ThemeSizes;
|
|
198
|
+
breakpoints: ThemeBreakpoints;
|
|
199
|
+
text: ThemeText;
|
|
200
|
+
divider: ThemeDivider;
|
|
201
|
+
button: ThemeButton;
|
|
202
|
+
colors: ThemeColors;
|
|
203
|
+
}
|
|
204
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/utils/css.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dextinity/mail-react",
|
|
3
|
+
"version": "2.0.0-canary-20260729062014",
|
|
4
|
+
"description": "Utilities for building HTML emails with React",
|
|
5
|
+
"license": "BSD-2-Clause",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"directory": "packages/mail-react",
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/vivid-planet/comet"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./lib/index.js",
|
|
14
|
+
"./client": "./lib/client/index.js",
|
|
15
|
+
"./server": "./lib/server/index.js",
|
|
16
|
+
"./storybook": "./lib/storybook/index.js"
|
|
17
|
+
},
|
|
18
|
+
"sideEffects": false,
|
|
19
|
+
"files": [
|
|
20
|
+
"lib/*"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@faire/mjml-react": "^3.5.4",
|
|
24
|
+
"clsx": "^2.1.1",
|
|
25
|
+
"mjml": "^4.18.0",
|
|
26
|
+
"mjml-browser": "^4.18.0",
|
|
27
|
+
"redraft": "^0.10.2"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@storybook/addon-docs": "^10.3.5",
|
|
31
|
+
"@storybook/addon-vitest": "10.3.5",
|
|
32
|
+
"@storybook/react-vite": "^10.3.5",
|
|
33
|
+
"@types/mjml": "^4.7.4",
|
|
34
|
+
"@types/mjml-browser": "^4.15.0",
|
|
35
|
+
"@types/react": "^19.2.15",
|
|
36
|
+
"@types/react-dom": "^19.2.3",
|
|
37
|
+
"@vitest/browser": "4.1.8",
|
|
38
|
+
"@vitest/browser-playwright": "4.1.8",
|
|
39
|
+
"chokidar-cli": "^3.0.0",
|
|
40
|
+
"eslint": "^9.39.4",
|
|
41
|
+
"npm-run-all2": "^8.0.4",
|
|
42
|
+
"playwright": "^1.49.1",
|
|
43
|
+
"prettier": "^3.6.2",
|
|
44
|
+
"react": "^19.2.6",
|
|
45
|
+
"react-dom": "^19.2.6",
|
|
46
|
+
"rimraf": "^6.1.2",
|
|
47
|
+
"storybook": "^10.3.5",
|
|
48
|
+
"typescript": "^5.9.3",
|
|
49
|
+
"vite": "^7.3.1",
|
|
50
|
+
"vitest": "^4.1.8",
|
|
51
|
+
"@dextinity/cli": "2.0.0-canary-20260729062014",
|
|
52
|
+
"@dextinity/eslint-config": "2.0.0-canary-20260729062014"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
56
|
+
"storybook": ">=10.0.0"
|
|
57
|
+
},
|
|
58
|
+
"peerDependenciesMeta": {
|
|
59
|
+
"storybook": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"node": ">=22.0.0"
|
|
65
|
+
},
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public",
|
|
68
|
+
"registry": "https://registry.npmjs.org"
|
|
69
|
+
},
|
|
70
|
+
"scripts": {
|
|
71
|
+
"build": "pnpm run clean && pnpm run generate-block-types && tsc -p tsconfig.build.json",
|
|
72
|
+
"build-storybook": "storybook build",
|
|
73
|
+
"clean": "rimraf lib 'src/**/*.generated.ts'",
|
|
74
|
+
"dev": "pnpm run clean && pnpm generate-block-types && tsc --watch",
|
|
75
|
+
"generate-block-types": "comet generate-block-types",
|
|
76
|
+
"generate-block-types:watch": "chokidar -s \"**/block-meta.json\" -c \"$npm_execpath generate-block-types\"",
|
|
77
|
+
"lint": "pnpm generate-block-types && run-p lint:prettier lint:eslint lint:tsc",
|
|
78
|
+
"lint:ci": "pnpm run lint",
|
|
79
|
+
"lint:eslint": "eslint --max-warnings 0 src/ '**/*.json' --no-warn-ignored",
|
|
80
|
+
"lint:fix": "run-p lint:fix:eslint lint:fix:prettier",
|
|
81
|
+
"lint:fix:eslint": "pnpm run lint:eslint --fix",
|
|
82
|
+
"lint:fix:prettier": "pnpm run lint:prettier --write",
|
|
83
|
+
"lint:prettier": "pnpm exec prettier --check '*.{ts,js,json,md,yml,yaml}'",
|
|
84
|
+
"lint:tsc": "tsc",
|
|
85
|
+
"storybook": "storybook dev -p 6066 --no-open",
|
|
86
|
+
"test": "pnpm run test:unit && pnpm run test:storybook",
|
|
87
|
+
"test:storybook": "vitest --run --project storybook --outputFile.junit=./junit-storybook.xml",
|
|
88
|
+
"test:unit": "vitest --run --project unit --outputFile.junit=./junit-unit.xml",
|
|
89
|
+
"test:watch": "vitest --watch"
|
|
90
|
+
}
|
|
91
|
+
}
|