@minutemailer/kit 1.2.5 → 1.4.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/components/details-content.d.ts +6 -0
- package/components/details-content.js +17 -0
- package/components/details.d.ts +4 -0
- package/components/details.js +15 -0
- package/components/donut-chart.js +1 -1
- package/components/engagement-chart.js +1 -1
- package/components/minutemailer-kit.d.ts +10 -1
- package/components/minutemailer-kit.js +21 -6
- package/hooks/use-i18n.js +3 -4
- package/package.json +2 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '../components/ui/button.js';
|
|
3
|
+
import { Close } from '../icons/index.js';
|
|
4
|
+
import { useEffect } from 'react';
|
|
5
|
+
import { createPortal } from 'react-dom';
|
|
6
|
+
import { useDetails } from './minutemailer-kit.js';
|
|
7
|
+
export function DetailsContent({ children, onClose = () => { }, close = false, }) {
|
|
8
|
+
const { mountNode, setVisible } = useDetails();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setVisible(true);
|
|
11
|
+
return () => setVisible(false);
|
|
12
|
+
}, [setVisible]);
|
|
13
|
+
if (!mountNode) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return createPortal(_jsxs("div", { className: "p-4", children: [close && (_jsx("div", { className: "absolute top-4 right-4", children: _jsx(Button, { variant: "ghost", size: "icon", onClick: onClose, children: _jsx(Close, {}) }) })), _jsx("div", { children: children })] }), mountNode);
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { motion } from 'motion/react';
|
|
4
|
+
import { useDetails } from './minutemailer-kit.js';
|
|
5
|
+
export function Details({ children }) {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const { visible, setMountNode } = useDetails();
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (ref.current) {
|
|
10
|
+
setMountNode(ref.current);
|
|
11
|
+
}
|
|
12
|
+
return () => setMountNode(null);
|
|
13
|
+
}, [setMountNode]);
|
|
14
|
+
return (_jsx(motion.div, { initial: { translateX: visible ? 0 : '100%', translateY: 0 }, animate: { translateX: visible ? 0 : '100%', translateY: 0 }, className: "fixed top-(--header-height) right-0 bottom-0 z-25 bg-background w-full max-w-[658px] shadow-md", ref: ref, children: children }, "details"));
|
|
15
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Cell, Label, Pie, PieChart } from 'recharts';
|
|
3
|
-
import { ChartContainer
|
|
3
|
+
import { ChartContainer } from '../components/ui/chart.js';
|
|
4
4
|
export function DonutChart({ percentage, size = 120 }) {
|
|
5
5
|
const COLORS = {
|
|
6
6
|
filled: 'oklch(0.683 0.178 158.484)', // Primary green
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Area, AreaChart, CartesianGrid, XAxis, YAxis,
|
|
2
|
+
import { Area, AreaChart, CartesianGrid, Tooltip, XAxis, YAxis, } from 'recharts';
|
|
3
3
|
import { ChartContainer, ChartTooltipContent, } from '../components/ui/chart.js';
|
|
4
4
|
const defaultData = [
|
|
5
5
|
{ hour: '0h', opens: 245, clicks: 12 },
|
|
@@ -4,16 +4,25 @@ type S3Config = {
|
|
|
4
4
|
cloudFrontUrl: string;
|
|
5
5
|
resizeCloudUrl: string;
|
|
6
6
|
};
|
|
7
|
+
type DetailsState = {
|
|
8
|
+
mountNode: HTMLDivElement | null;
|
|
9
|
+
visible: boolean;
|
|
10
|
+
setMountNode: (node: HTMLDivElement | null) => void;
|
|
11
|
+
setVisible: (visible: boolean) => void;
|
|
12
|
+
};
|
|
7
13
|
type ContextValue = {
|
|
8
14
|
t: (key: string) => string;
|
|
9
15
|
s3?: S3Config;
|
|
16
|
+
details: DetailsState;
|
|
10
17
|
};
|
|
11
|
-
export declare const Context: import("react").Context<ContextValue>;
|
|
18
|
+
export declare const Context: import("react").Context<ContextValue | null>;
|
|
12
19
|
type MinutemailerKitProps = {
|
|
13
20
|
children: ReactNode;
|
|
14
21
|
t: (key: string) => string;
|
|
15
22
|
s3?: S3Config;
|
|
16
23
|
};
|
|
17
24
|
export declare function MinutemailerKit({ children, t, s3 }: MinutemailerKitProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare function useMinutemailerKit(): ContextValue;
|
|
18
26
|
export declare function useS3Config(): S3Config;
|
|
27
|
+
export declare function useDetails(): DetailsState;
|
|
19
28
|
export {};
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from 'react';
|
|
3
|
-
export const Context = createContext(
|
|
4
|
-
t: (key) => key,
|
|
5
|
-
});
|
|
2
|
+
import { createContext, useContext, useState } from 'react';
|
|
3
|
+
export const Context = createContext(null);
|
|
6
4
|
export function MinutemailerKit({ children, t, s3 }) {
|
|
7
|
-
|
|
5
|
+
const [mountNode, setMountNode] = useState(null);
|
|
6
|
+
const [visible, setVisible] = useState(false);
|
|
7
|
+
return (_jsx(Context.Provider, { value: {
|
|
8
|
+
t,
|
|
9
|
+
s3,
|
|
10
|
+
details: { mountNode, visible, setMountNode, setVisible },
|
|
11
|
+
}, children: children }));
|
|
8
12
|
}
|
|
9
|
-
export function
|
|
13
|
+
export function useMinutemailerKit() {
|
|
10
14
|
const context = useContext(Context);
|
|
15
|
+
if (!context) {
|
|
16
|
+
throw new Error('useMinutemailerKit must be used within MinutemailerKit');
|
|
17
|
+
}
|
|
18
|
+
return context;
|
|
19
|
+
}
|
|
20
|
+
export function useS3Config() {
|
|
21
|
+
const context = useMinutemailerKit();
|
|
11
22
|
if (!context.s3) {
|
|
12
23
|
throw new Error('S3 configuration not provided in MinutemailerKit');
|
|
13
24
|
}
|
|
14
25
|
return context.s3;
|
|
15
26
|
}
|
|
27
|
+
export function useDetails() {
|
|
28
|
+
const context = useMinutemailerKit();
|
|
29
|
+
return context.details;
|
|
30
|
+
}
|
package/hooks/use-i18n.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Context } from '../components/minutemailer-kit.js';
|
|
1
|
+
import { useMinutemailerKit } from '../components/minutemailer-kit.js';
|
|
3
2
|
export function useI18n() {
|
|
4
|
-
const
|
|
5
|
-
return t;
|
|
3
|
+
const context = useMinutemailerKit();
|
|
4
|
+
return context.t;
|
|
6
5
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minutemailer/kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Minutemailer UI Kit",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Minutemailer",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"clsx": "^2.1.1",
|
|
61
61
|
"date-fns": "^4.1.0",
|
|
62
62
|
"lucide-react": "^0.544.0",
|
|
63
|
+
"motion": "^12.23.26",
|
|
63
64
|
"next-themes": "^0.4.6",
|
|
64
65
|
"react-day-picker": "^9.11.1",
|
|
65
66
|
"react-hook-form": "^7.63.0",
|