@shipfox/react-ui 0.16.0 → 0.17.0
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/dist/components/card/card.d.ts +24 -0
- package/dist/components/card/card.js +56 -0
- package/dist/components/card/card.stories.js +216 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/index.js +3 -0
- package/dist/components/dashboard/components/charts/bar-chart.d.ts +8 -17
- package/dist/components/dashboard/components/charts/bar-chart.js +127 -81
- package/dist/components/dashboard/components/charts/bar-chart.stories.js +287 -0
- package/dist/components/dashboard/components/charts/chart-tooltip.js +13 -12
- package/dist/components/dashboard/components/charts/colors.d.ts +3 -2
- package/dist/components/dashboard/components/charts/colors.js +5 -2
- package/dist/components/dashboard/components/charts/index.d.ts +1 -0
- package/dist/components/dashboard/components/charts/index.js +1 -0
- package/dist/components/dashboard/components/charts/line-chart.d.ts +7 -16
- package/dist/components/dashboard/components/charts/line-chart.js +132 -108
- package/dist/components/dashboard/components/charts/line-chart.stories.js +257 -0
- package/dist/components/dashboard/components/charts/utils.d.ts +13 -0
- package/dist/components/dashboard/components/charts/utils.js +18 -0
- package/dist/components/dashboard/index.d.ts +1 -1
- package/dist/components/empty-state/empty-state.d.ts +10 -0
- package/dist/components/empty-state/empty-state.js +40 -0
- package/dist/components/empty-state/empty-state.stories.js +74 -0
- package/dist/components/empty-state/index.d.ts +2 -0
- package/dist/components/empty-state/index.js +3 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/components/table/data-table.d.ts +5 -1
- package/dist/components/table/data-table.js +83 -71
- package/dist/components/table/table.js +1 -1
- package/dist/components/table/table.stories.components.js +6 -28
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Header, Text } from '../../components/typography';
|
|
2
|
+
import type { ComponentProps } from 'react';
|
|
3
|
+
export interface CardProps extends ComponentProps<'div'> {
|
|
4
|
+
}
|
|
5
|
+
export declare function Card({ className, children, ...props }: CardProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export interface CardHeaderProps extends ComponentProps<'div'> {
|
|
7
|
+
}
|
|
8
|
+
export declare function CardHeader({ className, children, ...props }: CardHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export interface CardTitleProps extends ComponentProps<typeof Header> {
|
|
10
|
+
}
|
|
11
|
+
export declare function CardTitle({ className, children, variant, ...props }: CardTitleProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export interface CardDescriptionProps extends ComponentProps<typeof Text> {
|
|
13
|
+
}
|
|
14
|
+
export declare function CardDescription({ className, children, size, ...props }: CardDescriptionProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export interface CardActionProps extends ComponentProps<'div'> {
|
|
16
|
+
}
|
|
17
|
+
export declare function CardAction({ className, children, ...props }: CardActionProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export interface CardContentProps extends ComponentProps<'div'> {
|
|
19
|
+
}
|
|
20
|
+
export declare function CardContent({ className, children, ...props }: CardContentProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export interface CardFooterProps extends ComponentProps<'div'> {
|
|
22
|
+
}
|
|
23
|
+
export declare function CardFooter({ className, children, ...props }: CardFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=card.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Header, Text } from '../../components/typography/index.js';
|
|
3
|
+
import { cn } from '../../utils/cn.js';
|
|
4
|
+
export function Card({ className, children, ...props }) {
|
|
5
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
6
|
+
className: cn('p-12 rounded-8 bg-background-neutral-base border border-border-neutral-base flex flex-col gap-16', className),
|
|
7
|
+
...props,
|
|
8
|
+
children: children
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export function CardHeader({ className, children, ...props }) {
|
|
12
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
13
|
+
className: cn('flex flex-col gap-4', className),
|
|
14
|
+
...props,
|
|
15
|
+
children: children
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function CardTitle({ className, children, variant = 'h3', ...props }) {
|
|
19
|
+
return /*#__PURE__*/ _jsx(Header, {
|
|
20
|
+
variant: variant,
|
|
21
|
+
className: cn('text-foreground-neutral-base', className),
|
|
22
|
+
...props,
|
|
23
|
+
children: children
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export function CardDescription({ className, children, size = 'sm', ...props }) {
|
|
27
|
+
return /*#__PURE__*/ _jsx(Text, {
|
|
28
|
+
size: size,
|
|
29
|
+
className: cn('text-foreground-neutral-muted', className),
|
|
30
|
+
...props,
|
|
31
|
+
children: children
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function CardAction({ className, children, ...props }) {
|
|
35
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
36
|
+
className: cn('ml-auto', className),
|
|
37
|
+
...props,
|
|
38
|
+
children: children
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export function CardContent({ className, children, ...props }) {
|
|
42
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
43
|
+
className: cn('flex-1', className),
|
|
44
|
+
...props,
|
|
45
|
+
children: children
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export function CardFooter({ className, children, ...props }) {
|
|
49
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
50
|
+
className: cn('flex items-center gap-8', className),
|
|
51
|
+
...props,
|
|
52
|
+
children: children
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=card.js.map
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button } from '../../components/button/index.js';
|
|
3
|
+
import { Input } from '../../components/input/index.js';
|
|
4
|
+
import { Label } from '../../components/label/index.js';
|
|
5
|
+
import { Text } from '../../components/typography/index.js';
|
|
6
|
+
import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './card.js';
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Components/Card',
|
|
9
|
+
component: Card,
|
|
10
|
+
tags: [
|
|
11
|
+
'autodocs'
|
|
12
|
+
],
|
|
13
|
+
parameters: {
|
|
14
|
+
layout: 'centered'
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export default meta;
|
|
18
|
+
export const Default = {
|
|
19
|
+
render: ()=>/*#__PURE__*/ _jsx("div", {
|
|
20
|
+
className: "w-400",
|
|
21
|
+
children: /*#__PURE__*/ _jsxs(Card, {
|
|
22
|
+
children: [
|
|
23
|
+
/*#__PURE__*/ _jsxs(CardHeader, {
|
|
24
|
+
children: [
|
|
25
|
+
/*#__PURE__*/ _jsx(CardTitle, {
|
|
26
|
+
children: "Card Title"
|
|
27
|
+
}),
|
|
28
|
+
/*#__PURE__*/ _jsx(CardDescription, {
|
|
29
|
+
children: "This is a description of the card content."
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
}),
|
|
33
|
+
/*#__PURE__*/ _jsx(CardContent, {
|
|
34
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
35
|
+
children: "Card content goes here. This is where the main information is displayed."
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
]
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
export const WithFooter = {
|
|
43
|
+
render: ()=>/*#__PURE__*/ _jsx("div", {
|
|
44
|
+
className: "w-400",
|
|
45
|
+
children: /*#__PURE__*/ _jsxs(Card, {
|
|
46
|
+
children: [
|
|
47
|
+
/*#__PURE__*/ _jsxs(CardHeader, {
|
|
48
|
+
children: [
|
|
49
|
+
/*#__PURE__*/ _jsx(CardTitle, {
|
|
50
|
+
children: "Card with Footer"
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ _jsx(CardDescription, {
|
|
53
|
+
children: "This card includes a footer with actions."
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
}),
|
|
57
|
+
/*#__PURE__*/ _jsx(CardContent, {
|
|
58
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
59
|
+
children: "Main content area with important information."
|
|
60
|
+
})
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ _jsxs(CardFooter, {
|
|
63
|
+
children: [
|
|
64
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
65
|
+
variant: "secondary",
|
|
66
|
+
size: "sm",
|
|
67
|
+
children: "Cancel"
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
70
|
+
size: "sm",
|
|
71
|
+
children: "Save"
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
export const WithAction = {
|
|
80
|
+
render: ()=>/*#__PURE__*/ _jsx("div", {
|
|
81
|
+
className: "w-400",
|
|
82
|
+
children: /*#__PURE__*/ _jsxs(Card, {
|
|
83
|
+
children: [
|
|
84
|
+
/*#__PURE__*/ _jsx(CardHeader, {
|
|
85
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
86
|
+
className: "flex items-start justify-between gap-16",
|
|
87
|
+
children: [
|
|
88
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
89
|
+
className: "flex flex-col gap-4 flex-1",
|
|
90
|
+
children: [
|
|
91
|
+
/*#__PURE__*/ _jsx(CardTitle, {
|
|
92
|
+
children: "Card with Action"
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ _jsx(CardDescription, {
|
|
95
|
+
children: "This card has an action button in the header."
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
}),
|
|
99
|
+
/*#__PURE__*/ _jsx(CardAction, {
|
|
100
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
101
|
+
variant: "transparent",
|
|
102
|
+
size: "sm",
|
|
103
|
+
children: "Edit"
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
})
|
|
108
|
+
}),
|
|
109
|
+
/*#__PURE__*/ _jsx(CardContent, {
|
|
110
|
+
children: /*#__PURE__*/ _jsx(Text, {
|
|
111
|
+
children: "Content that can be edited using the action button."
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
};
|
|
118
|
+
export const LoginForm = {
|
|
119
|
+
render: ()=>/*#__PURE__*/ _jsx("div", {
|
|
120
|
+
className: "w-400",
|
|
121
|
+
children: /*#__PURE__*/ _jsxs(Card, {
|
|
122
|
+
children: [
|
|
123
|
+
/*#__PURE__*/ _jsx(CardHeader, {
|
|
124
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
125
|
+
className: "flex items-start justify-between gap-16",
|
|
126
|
+
children: [
|
|
127
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
128
|
+
className: "flex flex-col gap-4 flex-1",
|
|
129
|
+
children: [
|
|
130
|
+
/*#__PURE__*/ _jsx(CardTitle, {
|
|
131
|
+
children: "Login to your account"
|
|
132
|
+
}),
|
|
133
|
+
/*#__PURE__*/ _jsx(CardDescription, {
|
|
134
|
+
children: "Enter your email below to login to your account"
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ _jsx(CardAction, {
|
|
139
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
140
|
+
variant: "transparent",
|
|
141
|
+
size: "sm",
|
|
142
|
+
children: "Sign Up"
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
})
|
|
147
|
+
}),
|
|
148
|
+
/*#__PURE__*/ _jsx(CardContent, {
|
|
149
|
+
children: /*#__PURE__*/ _jsxs("form", {
|
|
150
|
+
className: "flex flex-col gap-16",
|
|
151
|
+
children: [
|
|
152
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
153
|
+
className: "grid gap-6",
|
|
154
|
+
children: [
|
|
155
|
+
/*#__PURE__*/ _jsx(Label, {
|
|
156
|
+
htmlFor: "email",
|
|
157
|
+
children: "Email"
|
|
158
|
+
}),
|
|
159
|
+
/*#__PURE__*/ _jsx(Input, {
|
|
160
|
+
id: "email",
|
|
161
|
+
type: "email",
|
|
162
|
+
placeholder: "m@example.com",
|
|
163
|
+
required: true
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
168
|
+
className: "grid gap-6",
|
|
169
|
+
children: [
|
|
170
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
171
|
+
className: "flex items-center",
|
|
172
|
+
children: [
|
|
173
|
+
/*#__PURE__*/ _jsx(Label, {
|
|
174
|
+
htmlFor: "password",
|
|
175
|
+
children: "Password"
|
|
176
|
+
}),
|
|
177
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
178
|
+
variant: "transparent",
|
|
179
|
+
size: "xs",
|
|
180
|
+
className: "ml-auto",
|
|
181
|
+
children: "Forgot password?"
|
|
182
|
+
})
|
|
183
|
+
]
|
|
184
|
+
}),
|
|
185
|
+
/*#__PURE__*/ _jsx(Input, {
|
|
186
|
+
id: "password",
|
|
187
|
+
type: "password",
|
|
188
|
+
required: true
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
})
|
|
194
|
+
}),
|
|
195
|
+
/*#__PURE__*/ _jsxs(CardFooter, {
|
|
196
|
+
className: "flex-col gap-8",
|
|
197
|
+
children: [
|
|
198
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
199
|
+
type: "submit",
|
|
200
|
+
className: "w-full",
|
|
201
|
+
children: "Login"
|
|
202
|
+
}),
|
|
203
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
204
|
+
type: "submit",
|
|
205
|
+
variant: "secondary",
|
|
206
|
+
className: "w-full",
|
|
207
|
+
children: "Login with Google"
|
|
208
|
+
})
|
|
209
|
+
]
|
|
210
|
+
})
|
|
211
|
+
]
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
//# sourceMappingURL=card.stories.js.map
|
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import type { ComponentProps } from 'react';
|
|
2
|
-
import { type BarProps, BarChart as RechartsBarChart } from 'recharts';
|
|
3
|
-
import {
|
|
2
|
+
import { type BarProps, type CartesianGridProps, BarChart as RechartsBarChart, type XAxisProps, type YAxisProps } from 'recharts';
|
|
3
|
+
import type { ChartColor } from './colors';
|
|
4
4
|
export type RechartsBarChartProps = ComponentProps<typeof RechartsBarChart>;
|
|
5
5
|
export interface BarChartBar extends Omit<BarProps, 'dataKey'> {
|
|
6
6
|
dataKey: string;
|
|
7
7
|
name?: string;
|
|
8
8
|
color?: ChartColor;
|
|
9
|
+
hide?: boolean;
|
|
10
|
+
stackId?: string;
|
|
9
11
|
}
|
|
10
12
|
export interface BarChartProps {
|
|
11
13
|
data: RechartsBarChartProps['data'];
|
|
12
14
|
bars: BarChartBar[];
|
|
13
15
|
syncId?: RechartsBarChartProps['syncId'];
|
|
14
16
|
height?: number;
|
|
15
|
-
xAxis?:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
hide?: boolean;
|
|
19
|
-
interval?: number | 'preserveStart' | 'preserveEnd' | 'preserveStartEnd';
|
|
20
|
-
};
|
|
21
|
-
yAxis?: {
|
|
22
|
-
domain?: [number, number];
|
|
23
|
-
ticks?: number[];
|
|
24
|
-
hide?: boolean;
|
|
25
|
-
};
|
|
26
|
-
grid?: {
|
|
27
|
-
vertical?: boolean;
|
|
28
|
-
horizontal?: boolean;
|
|
29
|
-
};
|
|
17
|
+
xAxis?: Pick<XAxisProps, 'dataKey' | 'tickFormatter' | 'hide' | 'interval'>;
|
|
18
|
+
yAxis?: Pick<YAxisProps, 'domain' | 'ticks' | 'hide' | 'tickFormatter'>;
|
|
19
|
+
grid?: Pick<CartesianGridProps, 'vertical' | 'horizontal'>;
|
|
30
20
|
tooltip?: {
|
|
31
21
|
labelFormatter?: (label: string) => string;
|
|
22
|
+
formatter?: (value: number) => string;
|
|
32
23
|
};
|
|
33
24
|
className?: string;
|
|
34
25
|
title?: string;
|
|
@@ -1,101 +1,147 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card, CardContent, CardHeader, CardTitle } from '../../../../components/card/index.js';
|
|
3
|
+
import { EmptyState } from '../../../../components/empty-state/index.js';
|
|
4
|
+
import { Text } from '../../../../components/typography/index.js';
|
|
2
5
|
import { useState } from 'react';
|
|
3
6
|
import { Bar, CartesianGrid, BarChart as RechartsBarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts';
|
|
4
|
-
import { cn } from '../../../../utils/cn.js';
|
|
5
7
|
import { ChartTooltipContent } from './chart-tooltip.js';
|
|
6
|
-
import {
|
|
8
|
+
import { getChartColor, getHoverOpacity, normalizeTooltipPayload } from './utils.js';
|
|
7
9
|
export function BarChart({ data, bars, height = 200, xAxis, yAxis, grid, tooltip, className, title, barRadius = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
0,
|
|
11
|
+
0,
|
|
10
12
|
0,
|
|
11
13
|
0
|
|
12
14
|
], maxBarSize = 8 }) {
|
|
13
15
|
const [hoveredDataKey, setHoveredDataKey] = useState(undefined);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const visibleBars = bars.filter((bar)=>!bar.hide);
|
|
17
|
+
const hasData = data && data.length > 0 && visibleBars.length > 0;
|
|
18
|
+
const hasNonZeroData = hasData && data.some((item)=>visibleBars.some((bar)=>{
|
|
19
|
+
const value = item[bar.dataKey];
|
|
20
|
+
return value !== undefined && value !== null && Number(value) !== 0;
|
|
21
|
+
}));
|
|
22
|
+
const isEmpty = !hasData || !hasNonZeroData;
|
|
23
|
+
return /*#__PURE__*/ _jsxs(Card, {
|
|
24
|
+
className: className,
|
|
16
25
|
children: [
|
|
17
|
-
title && /*#__PURE__*/ _jsx(
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
title && /*#__PURE__*/ _jsx(CardHeader, {
|
|
27
|
+
children: /*#__PURE__*/ _jsx(CardTitle, {
|
|
28
|
+
variant: "h4",
|
|
29
|
+
children: title
|
|
30
|
+
})
|
|
20
31
|
}),
|
|
21
|
-
/*#__PURE__*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
width: "100%",
|
|
27
|
-
height: "100%",
|
|
28
|
-
children: /*#__PURE__*/ _jsxs(RechartsBarChart, {
|
|
29
|
-
data: data,
|
|
30
|
-
margin: {
|
|
31
|
-
top: 8,
|
|
32
|
-
right: 8,
|
|
33
|
-
left: -20,
|
|
34
|
-
bottom: 0
|
|
32
|
+
/*#__PURE__*/ _jsxs(CardContent, {
|
|
33
|
+
children: [
|
|
34
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
35
|
+
style: {
|
|
36
|
+
height
|
|
35
37
|
},
|
|
38
|
+
className: "relative",
|
|
36
39
|
children: [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
/*#__PURE__*/ _jsx(ResponsiveContainer, {
|
|
41
|
+
width: "100%",
|
|
42
|
+
height: "100%",
|
|
43
|
+
children: /*#__PURE__*/ _jsxs(RechartsBarChart, {
|
|
44
|
+
data: isEmpty ? [] : data,
|
|
45
|
+
margin: {
|
|
46
|
+
top: 8,
|
|
47
|
+
right: 8,
|
|
48
|
+
left: -20,
|
|
49
|
+
bottom: 0
|
|
50
|
+
},
|
|
51
|
+
children: [
|
|
52
|
+
!xAxis?.hide && /*#__PURE__*/ _jsx(XAxis, {
|
|
53
|
+
dataKey: xAxis?.dataKey ?? 'label',
|
|
54
|
+
axisLine: false,
|
|
55
|
+
tickLine: false,
|
|
56
|
+
tick: {
|
|
57
|
+
fill: 'var(--foreground-neutral-muted)',
|
|
58
|
+
fontSize: 12
|
|
59
|
+
},
|
|
60
|
+
tickFormatter: xAxis?.tickFormatter,
|
|
61
|
+
interval: xAxis?.interval ?? 'preserveStartEnd'
|
|
62
|
+
}),
|
|
63
|
+
!yAxis?.hide && /*#__PURE__*/ _jsx(YAxis, {
|
|
64
|
+
axisLine: false,
|
|
65
|
+
tickLine: false,
|
|
66
|
+
tick: {
|
|
67
|
+
fill: 'var(--foreground-neutral-muted)',
|
|
68
|
+
fontSize: 12
|
|
69
|
+
},
|
|
70
|
+
domain: yAxis?.domain,
|
|
71
|
+
ticks: yAxis?.ticks,
|
|
72
|
+
tickFormatter: yAxis?.tickFormatter
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ _jsx(CartesianGrid, {
|
|
75
|
+
strokeDasharray: "3 3",
|
|
76
|
+
stroke: "var(--border-neutral-base)",
|
|
77
|
+
vertical: grid?.vertical ?? false,
|
|
78
|
+
horizontal: grid?.horizontal ?? true
|
|
79
|
+
}),
|
|
80
|
+
/*#__PURE__*/ _jsx(Tooltip, {
|
|
81
|
+
cursor: {
|
|
82
|
+
fill: 'var(--background-neutral-hover)'
|
|
83
|
+
},
|
|
84
|
+
content: (props)=>{
|
|
85
|
+
if (!props.active) return null;
|
|
86
|
+
return /*#__PURE__*/ _jsx(ChartTooltipContent, {
|
|
87
|
+
active: props.active,
|
|
88
|
+
label: props.label,
|
|
89
|
+
payload: normalizeTooltipPayload(props.payload, tooltip?.formatter),
|
|
90
|
+
hoveredDataKey: hoveredDataKey,
|
|
91
|
+
labelFormatter: tooltip?.labelFormatter
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}),
|
|
95
|
+
visibleBars.map((bar, index)=>{
|
|
96
|
+
const color = getChartColor(bar.color, index);
|
|
97
|
+
const fillOpacity = getHoverOpacity(hoveredDataKey, bar.dataKey);
|
|
98
|
+
return /*#__PURE__*/ _jsx(Bar, {
|
|
99
|
+
dataKey: bar.dataKey,
|
|
100
|
+
name: bar.name ?? bar.dataKey,
|
|
101
|
+
fill: color,
|
|
102
|
+
fillOpacity: fillOpacity,
|
|
103
|
+
radius: barRadius,
|
|
104
|
+
maxBarSize: maxBarSize,
|
|
105
|
+
onMouseEnter: ()=>setHoveredDataKey(bar.dataKey),
|
|
106
|
+
onMouseLeave: ()=>setHoveredDataKey(undefined),
|
|
107
|
+
isAnimationActive: false,
|
|
108
|
+
stackId: bar.stackId
|
|
109
|
+
}, bar.dataKey);
|
|
110
|
+
})
|
|
111
|
+
]
|
|
112
|
+
})
|
|
57
113
|
}),
|
|
58
|
-
/*#__PURE__*/ _jsx(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}),
|
|
64
|
-
/*#__PURE__*/ _jsx(Tooltip, {
|
|
65
|
-
cursor: {
|
|
66
|
-
fill: 'var(--background-neutral-hover)'
|
|
67
|
-
},
|
|
68
|
-
content: (props)=>{
|
|
69
|
-
if (!props.active) return null;
|
|
70
|
-
return /*#__PURE__*/ _jsx(ChartTooltipContent, {
|
|
71
|
-
active: props.active,
|
|
72
|
-
label: props.label,
|
|
73
|
-
payload: props.payload,
|
|
74
|
-
hoveredDataKey: hoveredDataKey,
|
|
75
|
-
labelFormatter: tooltip?.labelFormatter
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}),
|
|
79
|
-
bars.map((bar, index)=>{
|
|
80
|
-
const defaultColor = bar.color ? chartColors[bar.color] : chartColorsList[index % chartColorsList.length];
|
|
81
|
-
const fillOpacity = hoveredDataKey ? hoveredDataKey === bar.dataKey ? 1 : 0.25 : 1;
|
|
82
|
-
const { dataKey, name, ...restBar } = bar;
|
|
83
|
-
return /*#__PURE__*/ _jsx(Bar, {
|
|
84
|
-
dataKey: dataKey,
|
|
85
|
-
name: name ?? dataKey,
|
|
86
|
-
fill: defaultColor,
|
|
87
|
-
fillOpacity: fillOpacity,
|
|
88
|
-
radius: barRadius,
|
|
89
|
-
maxBarSize: maxBarSize,
|
|
90
|
-
onMouseEnter: ()=>setHoveredDataKey(dataKey),
|
|
91
|
-
onMouseLeave: ()=>setHoveredDataKey(undefined),
|
|
92
|
-
isAnimationActive: false,
|
|
93
|
-
...restBar
|
|
94
|
-
}, dataKey);
|
|
114
|
+
isEmpty && /*#__PURE__*/ _jsx(EmptyState, {
|
|
115
|
+
icon: "barChartBoxLine",
|
|
116
|
+
title: "Nothing here yet.",
|
|
117
|
+
variant: "compact",
|
|
118
|
+
className: "absolute inset-0 z-10"
|
|
95
119
|
})
|
|
96
120
|
]
|
|
121
|
+
}),
|
|
122
|
+
!isEmpty && visibleBars.length > 0 && /*#__PURE__*/ _jsx("div", {
|
|
123
|
+
className: "flex items-center justify-center flex-wrap gap-16",
|
|
124
|
+
children: visibleBars.map((bar, index)=>{
|
|
125
|
+
const color = getChartColor(bar.color, index);
|
|
126
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
127
|
+
className: "flex items-center gap-6",
|
|
128
|
+
children: [
|
|
129
|
+
/*#__PURE__*/ _jsx("span", {
|
|
130
|
+
className: "size-8 rounded-full",
|
|
131
|
+
style: {
|
|
132
|
+
backgroundColor: color
|
|
133
|
+
}
|
|
134
|
+
}),
|
|
135
|
+
/*#__PURE__*/ _jsx(Text, {
|
|
136
|
+
size: "xs",
|
|
137
|
+
className: "text-foreground-neutral-subtle",
|
|
138
|
+
children: bar.name ?? bar.dataKey
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
}, bar.dataKey);
|
|
142
|
+
})
|
|
97
143
|
})
|
|
98
|
-
|
|
144
|
+
]
|
|
99
145
|
})
|
|
100
146
|
]
|
|
101
147
|
});
|