@shipfox/react-ui 0.16.0 → 0.18.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/count-up/count-up.d.ts +14 -0
- package/dist/components/count-up/count-up.js +98 -0
- package/dist/components/count-up/count-up.stories.js +568 -0
- package/dist/components/count-up/index.d.ts +2 -0
- package/dist/components/count-up/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/components/kpi-card.d.ts +8 -9
- package/dist/components/dashboard/components/kpi-card.js +26 -44
- package/dist/components/dashboard/index.d.ts +2 -7
- package/dist/components/dashboard/index.js +0 -11
- package/dist/components/dashboard/pages/analytics-page.d.ts +0 -18
- package/dist/components/dashboard/pages/analytics-page.js +83 -37
- package/dist/components/dashboard/pages/jobs-page.d.ts +0 -18
- package/dist/components/dashboard/pages/jobs-page.js +27 -24
- package/dist/components/dashboard/table/table-wrapper.d.ts +21 -24
- package/dist/components/dashboard/table/table-wrapper.js +38 -51
- 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 +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/item/item.stories.js +3 -3
- package/dist/components/table/data-table.d.ts +12 -1
- package/dist/components/table/data-table.js +84 -71
- package/dist/components/table/table-column-header.d.ts +14 -1
- package/dist/components/table/table-column-header.js +12 -5
- package/dist/components/table/table-pagination.d.ts +14 -1
- package/dist/components/table/table-pagination.js +6 -2
- package/dist/components/table/table.js +3 -3
- package/dist/components/table/table.stories.components.js +6 -28
- package/dist/styles.css +1 -1
- package/package.json +3 -3
|
@@ -1,125 +1,149 @@
|
|
|
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 { CartesianGrid, Line, LineChart as RechartsLineChart, 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 LineChart({ data, lines, height = 200, xAxis, yAxis, grid, tooltip, className, title }) {
|
|
8
10
|
const [hoveredDataKey, setHoveredDataKey] = useState(undefined);
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
const visibleLines = lines.filter((line)=>!line.hide);
|
|
12
|
+
const hasData = data && data.length > 0 && visibleLines.length > 0;
|
|
13
|
+
const hasNonZeroData = hasData && data.some((item)=>visibleLines.some((line)=>{
|
|
14
|
+
const value = item[line.dataKey];
|
|
15
|
+
return value !== undefined && value !== null && Number(value) !== 0;
|
|
16
|
+
}));
|
|
17
|
+
const isEmpty = !hasData || !hasNonZeroData;
|
|
18
|
+
return /*#__PURE__*/ _jsxs(Card, {
|
|
19
|
+
className: className,
|
|
11
20
|
children: [
|
|
12
|
-
title && /*#__PURE__*/ _jsx(
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
title && /*#__PURE__*/ _jsx(CardHeader, {
|
|
22
|
+
children: /*#__PURE__*/ _jsx(CardTitle, {
|
|
23
|
+
variant: "h4",
|
|
24
|
+
children: title
|
|
25
|
+
})
|
|
15
26
|
}),
|
|
16
|
-
/*#__PURE__*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
width: "100%",
|
|
22
|
-
height: "100%",
|
|
23
|
-
children: /*#__PURE__*/ _jsxs(RechartsLineChart, {
|
|
24
|
-
data: data,
|
|
25
|
-
margin: {
|
|
26
|
-
top: 8,
|
|
27
|
-
right: 8,
|
|
28
|
-
left: -20,
|
|
29
|
-
bottom: 0
|
|
27
|
+
/*#__PURE__*/ _jsxs(CardContent, {
|
|
28
|
+
children: [
|
|
29
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
30
|
+
style: {
|
|
31
|
+
height
|
|
30
32
|
},
|
|
33
|
+
className: "relative",
|
|
31
34
|
children: [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
!yAxis?.hide && /*#__PURE__*/ _jsx(YAxis, {
|
|
43
|
-
axisLine: false,
|
|
44
|
-
tickLine: false,
|
|
45
|
-
tick: {
|
|
46
|
-
fill: 'var(--foreground-neutral-muted)',
|
|
47
|
-
fontSize: 12
|
|
48
|
-
},
|
|
49
|
-
domain: yAxis?.domain,
|
|
50
|
-
ticks: yAxis?.ticks
|
|
51
|
-
}),
|
|
52
|
-
/*#__PURE__*/ _jsx(CartesianGrid, {
|
|
53
|
-
strokeDasharray: "3 3",
|
|
54
|
-
stroke: "var(--border-neutral-base)",
|
|
55
|
-
vertical: grid?.vertical ?? false,
|
|
56
|
-
horizontal: grid?.horizontal ?? true
|
|
57
|
-
}),
|
|
58
|
-
/*#__PURE__*/ _jsx(Tooltip, {
|
|
59
|
-
content: (props)=>{
|
|
60
|
-
if (!props.active) return null;
|
|
61
|
-
return /*#__PURE__*/ _jsx(ChartTooltipContent, {
|
|
62
|
-
active: props.active,
|
|
63
|
-
label: props.label,
|
|
64
|
-
payload: props.payload,
|
|
65
|
-
hoveredDataKey: hoveredDataKey,
|
|
66
|
-
labelFormatter: tooltip?.labelFormatter
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}),
|
|
70
|
-
lines.map((line, index)=>{
|
|
71
|
-
const defaultColor = line.color ? chartColors[line.color] : chartColorsList[index % chartColorsList.length];
|
|
72
|
-
const strokeWidth = line.strokeWidth ?? 2;
|
|
73
|
-
const strokeOpacity = hoveredDataKey ? hoveredDataKey === line.dataKey ? 1 : 0.25 : 1;
|
|
74
|
-
const { dataKey, name, ...restLine } = line;
|
|
75
|
-
return /*#__PURE__*/ _jsx(Line, {
|
|
76
|
-
type: "monotone",
|
|
77
|
-
dataKey: dataKey,
|
|
78
|
-
name: name ?? dataKey,
|
|
79
|
-
stroke: defaultColor,
|
|
80
|
-
strokeWidth: strokeWidth,
|
|
81
|
-
strokeOpacity: strokeOpacity,
|
|
82
|
-
dot: false,
|
|
83
|
-
activeDot: {
|
|
84
|
-
r: strokeWidth * 2,
|
|
85
|
-
fill: defaultColor,
|
|
86
|
-
fillOpacity: strokeOpacity,
|
|
87
|
-
stroke: 'var(--background-neutral-base)',
|
|
88
|
-
strokeWidth,
|
|
89
|
-
strokeOpacity,
|
|
90
|
-
onMouseEnter: ()=>setHoveredDataKey(dataKey),
|
|
91
|
-
onMouseLeave: ()=>setHoveredDataKey(undefined)
|
|
35
|
+
/*#__PURE__*/ _jsx(ResponsiveContainer, {
|
|
36
|
+
width: "100%",
|
|
37
|
+
height: "100%",
|
|
38
|
+
children: /*#__PURE__*/ _jsxs(RechartsLineChart, {
|
|
39
|
+
data: isEmpty ? [] : data,
|
|
40
|
+
margin: {
|
|
41
|
+
top: 8,
|
|
42
|
+
right: 8,
|
|
43
|
+
left: -20,
|
|
44
|
+
bottom: 0
|
|
92
45
|
},
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
46
|
+
children: [
|
|
47
|
+
!xAxis?.hide && /*#__PURE__*/ _jsx(XAxis, {
|
|
48
|
+
dataKey: xAxis?.dataKey ?? 'label',
|
|
49
|
+
axisLine: false,
|
|
50
|
+
tickLine: false,
|
|
51
|
+
tick: {
|
|
52
|
+
fill: 'var(--foreground-neutral-muted)',
|
|
53
|
+
fontSize: 12
|
|
54
|
+
},
|
|
55
|
+
tickFormatter: xAxis?.tickFormatter
|
|
56
|
+
}),
|
|
57
|
+
!yAxis?.hide && /*#__PURE__*/ _jsx(YAxis, {
|
|
58
|
+
axisLine: false,
|
|
59
|
+
tickLine: false,
|
|
60
|
+
tick: {
|
|
61
|
+
fill: 'var(--foreground-neutral-muted)',
|
|
62
|
+
fontSize: 12
|
|
63
|
+
},
|
|
64
|
+
domain: yAxis?.domain,
|
|
65
|
+
ticks: yAxis?.ticks,
|
|
66
|
+
tickFormatter: yAxis?.tickFormatter
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ _jsx(CartesianGrid, {
|
|
69
|
+
strokeDasharray: "3 3",
|
|
70
|
+
stroke: "var(--border-neutral-base)",
|
|
71
|
+
vertical: grid?.vertical ?? false,
|
|
72
|
+
horizontal: grid?.horizontal ?? true
|
|
73
|
+
}),
|
|
74
|
+
/*#__PURE__*/ _jsx(Tooltip, {
|
|
75
|
+
content: (props)=>{
|
|
76
|
+
if (!props.active) return null;
|
|
77
|
+
return /*#__PURE__*/ _jsx(ChartTooltipContent, {
|
|
78
|
+
active: props.active,
|
|
79
|
+
label: props.label,
|
|
80
|
+
payload: normalizeTooltipPayload(props.payload, tooltip?.formatter),
|
|
81
|
+
hoveredDataKey: hoveredDataKey,
|
|
82
|
+
labelFormatter: tooltip?.labelFormatter
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
visibleLines.map((line, index)=>{
|
|
87
|
+
const color = getChartColor(line.color, index);
|
|
88
|
+
const strokeWidth = line.strokeWidth ?? 2;
|
|
89
|
+
const strokeOpacity = getHoverOpacity(hoveredDataKey, line.dataKey);
|
|
90
|
+
return /*#__PURE__*/ _jsx(Line, {
|
|
91
|
+
type: "monotone",
|
|
92
|
+
dataKey: line.dataKey,
|
|
93
|
+
name: line.name ?? line.dataKey,
|
|
94
|
+
stroke: color,
|
|
95
|
+
strokeWidth: strokeWidth,
|
|
96
|
+
strokeOpacity: strokeOpacity,
|
|
97
|
+
dot: false,
|
|
98
|
+
activeDot: {
|
|
99
|
+
r: strokeWidth * 2,
|
|
100
|
+
fill: color,
|
|
101
|
+
fillOpacity: strokeOpacity,
|
|
102
|
+
stroke: 'var(--background-neutral-base)',
|
|
103
|
+
strokeWidth,
|
|
104
|
+
strokeOpacity,
|
|
105
|
+
onMouseEnter: ()=>setHoveredDataKey(line.dataKey),
|
|
106
|
+
onMouseLeave: ()=>setHoveredDataKey(undefined)
|
|
107
|
+
},
|
|
108
|
+
onMouseEnter: ()=>setHoveredDataKey(line.dataKey),
|
|
109
|
+
onMouseLeave: ()=>setHoveredDataKey(undefined),
|
|
110
|
+
isAnimationActive: false
|
|
111
|
+
}, line.dataKey);
|
|
112
|
+
})
|
|
113
|
+
]
|
|
114
|
+
})
|
|
115
115
|
}),
|
|
116
|
-
/*#__PURE__*/ _jsx(
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
isEmpty && /*#__PURE__*/ _jsx(EmptyState, {
|
|
117
|
+
icon: "lineChartLine",
|
|
118
|
+
title: "Nothing here yet.",
|
|
119
|
+
variant: "compact",
|
|
120
|
+
className: "absolute inset-0 z-10"
|
|
119
121
|
})
|
|
120
122
|
]
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
+
}),
|
|
124
|
+
!isEmpty && visibleLines.length > 0 && /*#__PURE__*/ _jsx("div", {
|
|
125
|
+
className: "flex items-center justify-center flex-wrap gap-16",
|
|
126
|
+
children: visibleLines.map((line, index)=>{
|
|
127
|
+
const color = getChartColor(line.color, index);
|
|
128
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
129
|
+
className: "flex items-center gap-6",
|
|
130
|
+
children: [
|
|
131
|
+
/*#__PURE__*/ _jsx("span", {
|
|
132
|
+
className: "size-8 rounded-full",
|
|
133
|
+
style: {
|
|
134
|
+
backgroundColor: color
|
|
135
|
+
}
|
|
136
|
+
}),
|
|
137
|
+
/*#__PURE__*/ _jsx(Text, {
|
|
138
|
+
size: "xs",
|
|
139
|
+
className: "text-foreground-neutral-subtle",
|
|
140
|
+
children: line.name ?? line.dataKey
|
|
141
|
+
})
|
|
142
|
+
]
|
|
143
|
+
}, line.dataKey);
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
]
|
|
123
147
|
})
|
|
124
148
|
]
|
|
125
149
|
});
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { LineChart } from './line-chart.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Components/Charts/LineChart',
|
|
5
|
+
component: LineChart,
|
|
6
|
+
tags: [
|
|
7
|
+
'autodocs'
|
|
8
|
+
],
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
const sampleData = [
|
|
15
|
+
{
|
|
16
|
+
label: 'Jan',
|
|
17
|
+
value1: 100,
|
|
18
|
+
value2: 80,
|
|
19
|
+
value3: 120
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: 'Feb',
|
|
23
|
+
value1: 150,
|
|
24
|
+
value2: 130,
|
|
25
|
+
value3: 140
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: 'Mar',
|
|
29
|
+
value1: 200,
|
|
30
|
+
value2: 180,
|
|
31
|
+
value3: 160
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: 'Apr',
|
|
35
|
+
value1: 180,
|
|
36
|
+
value2: 200,
|
|
37
|
+
value3: 180
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: 'May',
|
|
41
|
+
value1: 250,
|
|
42
|
+
value2: 220,
|
|
43
|
+
value3: 200
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: 'Jun',
|
|
47
|
+
value1: 300,
|
|
48
|
+
value2: 280,
|
|
49
|
+
value3: 240
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
export const Default = {
|
|
53
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
54
|
+
className: "w-400",
|
|
55
|
+
children: /*#__PURE__*/ _jsx(LineChart, {
|
|
56
|
+
...args
|
|
57
|
+
})
|
|
58
|
+
}),
|
|
59
|
+
args: {
|
|
60
|
+
data: sampleData,
|
|
61
|
+
lines: [
|
|
62
|
+
{
|
|
63
|
+
dataKey: 'value1',
|
|
64
|
+
name: 'Series 1'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
dataKey: 'value2',
|
|
68
|
+
name: 'Series 2'
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
dataKey: 'value3',
|
|
72
|
+
name: 'Series 3'
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
height: 200
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export const WithTitle = {
|
|
79
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
80
|
+
className: "w-400",
|
|
81
|
+
children: /*#__PURE__*/ _jsx(LineChart, {
|
|
82
|
+
...args
|
|
83
|
+
})
|
|
84
|
+
}),
|
|
85
|
+
args: {
|
|
86
|
+
data: sampleData,
|
|
87
|
+
lines: [
|
|
88
|
+
{
|
|
89
|
+
dataKey: 'value1',
|
|
90
|
+
name: 'Revenue'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
dataKey: 'value2',
|
|
94
|
+
name: 'Expenses'
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
height: 200,
|
|
98
|
+
title: 'Monthly Trends'
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
export const SingleLine = {
|
|
102
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
103
|
+
className: "w-400",
|
|
104
|
+
children: /*#__PURE__*/ _jsx(LineChart, {
|
|
105
|
+
...args
|
|
106
|
+
})
|
|
107
|
+
}),
|
|
108
|
+
args: {
|
|
109
|
+
data: sampleData,
|
|
110
|
+
lines: [
|
|
111
|
+
{
|
|
112
|
+
dataKey: 'value1',
|
|
113
|
+
name: 'Total Sales'
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
height: 200,
|
|
117
|
+
title: 'Sales Over Time'
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
export const CustomColors = {
|
|
121
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
122
|
+
className: "w-400",
|
|
123
|
+
children: /*#__PURE__*/ _jsx(LineChart, {
|
|
124
|
+
...args
|
|
125
|
+
})
|
|
126
|
+
}),
|
|
127
|
+
args: {
|
|
128
|
+
data: sampleData,
|
|
129
|
+
lines: [
|
|
130
|
+
{
|
|
131
|
+
dataKey: 'value1',
|
|
132
|
+
name: 'Blue Series',
|
|
133
|
+
color: 'blue'
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
dataKey: 'value2',
|
|
137
|
+
name: 'Green Series',
|
|
138
|
+
color: 'green'
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
dataKey: 'value3',
|
|
142
|
+
name: 'Orange Series',
|
|
143
|
+
color: 'orange'
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
height: 200,
|
|
147
|
+
title: 'Custom Colored Lines'
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
export const HiddenAxis = {
|
|
151
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
152
|
+
className: "w-400",
|
|
153
|
+
children: /*#__PURE__*/ _jsx(LineChart, {
|
|
154
|
+
...args
|
|
155
|
+
})
|
|
156
|
+
}),
|
|
157
|
+
args: {
|
|
158
|
+
data: sampleData,
|
|
159
|
+
lines: [
|
|
160
|
+
{
|
|
161
|
+
dataKey: 'value1',
|
|
162
|
+
name: 'Series 1'
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
dataKey: 'value2',
|
|
166
|
+
name: 'Series 2'
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
height: 200,
|
|
170
|
+
xAxis: {
|
|
171
|
+
hide: true
|
|
172
|
+
},
|
|
173
|
+
yAxis: {
|
|
174
|
+
hide: true
|
|
175
|
+
},
|
|
176
|
+
title: 'No Axes'
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
export const HiddenLines = {
|
|
180
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
181
|
+
className: "w-400",
|
|
182
|
+
children: /*#__PURE__*/ _jsx(LineChart, {
|
|
183
|
+
...args
|
|
184
|
+
})
|
|
185
|
+
}),
|
|
186
|
+
args: {
|
|
187
|
+
data: sampleData,
|
|
188
|
+
lines: [
|
|
189
|
+
{
|
|
190
|
+
dataKey: 'value1',
|
|
191
|
+
name: 'Visible Series'
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
dataKey: 'value2',
|
|
195
|
+
name: 'Hidden Series',
|
|
196
|
+
hide: true
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
dataKey: 'value3',
|
|
200
|
+
name: 'Another Visible Series'
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
height: 200,
|
|
204
|
+
title: 'With Hidden Lines'
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
export const CustomFormatter = {
|
|
208
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
209
|
+
className: "w-400",
|
|
210
|
+
children: /*#__PURE__*/ _jsx(LineChart, {
|
|
211
|
+
...args
|
|
212
|
+
})
|
|
213
|
+
}),
|
|
214
|
+
args: {
|
|
215
|
+
data: sampleData,
|
|
216
|
+
lines: [
|
|
217
|
+
{
|
|
218
|
+
dataKey: 'value1',
|
|
219
|
+
name: 'Sales'
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
dataKey: 'value2',
|
|
223
|
+
name: 'Profit'
|
|
224
|
+
}
|
|
225
|
+
],
|
|
226
|
+
height: 200,
|
|
227
|
+
tooltip: {
|
|
228
|
+
formatter: (value)=>`$${value.toLocaleString()}`,
|
|
229
|
+
labelFormatter: (label)=>`Month: ${label}`
|
|
230
|
+
},
|
|
231
|
+
yAxis: {
|
|
232
|
+
tickFormatter: (value)=>`$${value}`
|
|
233
|
+
},
|
|
234
|
+
title: 'Formatted Values'
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
export const EmptyState = {
|
|
238
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
239
|
+
className: "w-400",
|
|
240
|
+
children: /*#__PURE__*/ _jsx(LineChart, {
|
|
241
|
+
...args
|
|
242
|
+
})
|
|
243
|
+
}),
|
|
244
|
+
args: {
|
|
245
|
+
data: [],
|
|
246
|
+
lines: [
|
|
247
|
+
{
|
|
248
|
+
dataKey: 'value1',
|
|
249
|
+
name: 'Series 1'
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
height: 200,
|
|
253
|
+
title: 'Performance over time'
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
//# sourceMappingURL=line-chart.stories.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChartTooltipContentProps } from './chart-tooltip';
|
|
2
|
+
import { type ChartColor } from './colors';
|
|
3
|
+
type RechartsPayloadItem = {
|
|
4
|
+
name?: unknown;
|
|
5
|
+
value?: unknown;
|
|
6
|
+
dataKey?: unknown;
|
|
7
|
+
color?: unknown;
|
|
8
|
+
};
|
|
9
|
+
export declare function normalizeTooltipPayload(payload: readonly RechartsPayloadItem[] | undefined, formatter?: (value: number) => string): ChartTooltipContentProps['payload'];
|
|
10
|
+
export declare function getChartColor(color: ChartColor | undefined, index: number): string;
|
|
11
|
+
export declare function getHoverOpacity(hoveredDataKey: string | undefined, currentDataKey: string): number;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { chartColors, chartColorsList } from './colors.js';
|
|
2
|
+
export function normalizeTooltipPayload(payload, formatter) {
|
|
3
|
+
if (!payload) return undefined;
|
|
4
|
+
return payload.map((p)=>({
|
|
5
|
+
name: typeof p.name === 'string' ? p.name : String(p.name ?? ''),
|
|
6
|
+
value: formatter ? formatter(Number(p.value)) : typeof p.value === 'string' || typeof p.value === 'number' ? p.value : String(p.value ?? ''),
|
|
7
|
+
dataKey: typeof p.dataKey === 'string' || typeof p.dataKey === 'number' ? p.dataKey : String(p.dataKey ?? ''),
|
|
8
|
+
color: typeof p.color === 'string' ? p.color : undefined
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
11
|
+
export function getChartColor(color, index) {
|
|
12
|
+
return color ? chartColors[color] : chartColorsList[index % chartColorsList.length];
|
|
13
|
+
}
|
|
14
|
+
export function getHoverOpacity(hoveredDataKey, currentDataKey) {
|
|
15
|
+
return hoveredDataKey ? hoveredDataKey === currentDataKey ? 1 : 0.25 : 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
export type KpiVariant = 'neutral' | 'success' | 'warning' | 'error' | 'info' | 'purple';
|
|
3
|
+
export interface KpiCardProps extends Omit<ComponentProps<'div'>, 'title'> {
|
|
3
4
|
label: string;
|
|
4
|
-
value: string | number;
|
|
5
|
+
value: string | number | ReactNode;
|
|
5
6
|
variant?: KpiVariant;
|
|
6
|
-
|
|
7
|
+
isLoading?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare function KpiCard({ label, value, variant, className }: KpiCardProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export interface KpiCardsGroupProps {
|
|
9
|
+
export declare function KpiCard({ label, value, variant, isLoading, className, ...props }: KpiCardProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export interface KpiCardsGroupProps extends ComponentProps<'div'> {
|
|
10
11
|
cards: KpiCardProps[];
|
|
11
|
-
className?: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function KpiCardsGroup({ cards, className }: KpiCardsGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export declare const defaultKpiCards: KpiCardProps[];
|
|
13
|
+
export declare function KpiCardsGroup({ cards, className, ...props }: KpiCardsGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
15
14
|
//# sourceMappingURL=kpi-card.d.ts.map
|