@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,287 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { BarChart } from './bar-chart.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Components/Charts/BarChart',
|
|
5
|
+
component: BarChart,
|
|
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(BarChart, {
|
|
56
|
+
...args
|
|
57
|
+
})
|
|
58
|
+
}),
|
|
59
|
+
args: {
|
|
60
|
+
data: sampleData,
|
|
61
|
+
bars: [
|
|
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(BarChart, {
|
|
82
|
+
...args
|
|
83
|
+
})
|
|
84
|
+
}),
|
|
85
|
+
args: {
|
|
86
|
+
data: sampleData,
|
|
87
|
+
bars: [
|
|
88
|
+
{
|
|
89
|
+
dataKey: 'value1',
|
|
90
|
+
name: 'Revenue'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
dataKey: 'value2',
|
|
94
|
+
name: 'Expenses'
|
|
95
|
+
}
|
|
96
|
+
],
|
|
97
|
+
height: 200,
|
|
98
|
+
title: 'Monthly Comparison'
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
export const SingleBar = {
|
|
102
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
103
|
+
className: "w-400",
|
|
104
|
+
children: /*#__PURE__*/ _jsx(BarChart, {
|
|
105
|
+
...args
|
|
106
|
+
})
|
|
107
|
+
}),
|
|
108
|
+
args: {
|
|
109
|
+
data: sampleData,
|
|
110
|
+
bars: [
|
|
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(BarChart, {
|
|
124
|
+
...args
|
|
125
|
+
})
|
|
126
|
+
}),
|
|
127
|
+
args: {
|
|
128
|
+
data: sampleData,
|
|
129
|
+
bars: [
|
|
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 Bars'
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
export const StackedBars = {
|
|
151
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
152
|
+
className: "w-400",
|
|
153
|
+
children: /*#__PURE__*/ _jsx(BarChart, {
|
|
154
|
+
...args
|
|
155
|
+
})
|
|
156
|
+
}),
|
|
157
|
+
args: {
|
|
158
|
+
data: sampleData,
|
|
159
|
+
bars: [
|
|
160
|
+
{
|
|
161
|
+
dataKey: 'value1',
|
|
162
|
+
name: 'Series 1',
|
|
163
|
+
stackId: 'stack'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
dataKey: 'value2',
|
|
167
|
+
name: 'Series 2',
|
|
168
|
+
stackId: 'stack'
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
dataKey: 'value3',
|
|
172
|
+
name: 'Series 3',
|
|
173
|
+
stackId: 'stack'
|
|
174
|
+
}
|
|
175
|
+
],
|
|
176
|
+
height: 200,
|
|
177
|
+
title: 'Stacked Bars'
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
export const RoundedBars = {
|
|
181
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
182
|
+
className: "w-400",
|
|
183
|
+
children: /*#__PURE__*/ _jsx(BarChart, {
|
|
184
|
+
...args
|
|
185
|
+
})
|
|
186
|
+
}),
|
|
187
|
+
args: {
|
|
188
|
+
data: sampleData,
|
|
189
|
+
bars: [
|
|
190
|
+
{
|
|
191
|
+
dataKey: 'value1',
|
|
192
|
+
name: 'Series 1'
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
dataKey: 'value2',
|
|
196
|
+
name: 'Series 2'
|
|
197
|
+
}
|
|
198
|
+
],
|
|
199
|
+
height: 200,
|
|
200
|
+
barRadius: [
|
|
201
|
+
4,
|
|
202
|
+
4,
|
|
203
|
+
0,
|
|
204
|
+
0
|
|
205
|
+
],
|
|
206
|
+
title: 'Rounded Top Corners'
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
export const HiddenBars = {
|
|
210
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
211
|
+
className: "w-400",
|
|
212
|
+
children: /*#__PURE__*/ _jsx(BarChart, {
|
|
213
|
+
...args
|
|
214
|
+
})
|
|
215
|
+
}),
|
|
216
|
+
args: {
|
|
217
|
+
data: sampleData,
|
|
218
|
+
bars: [
|
|
219
|
+
{
|
|
220
|
+
dataKey: 'value1',
|
|
221
|
+
name: 'Visible Series'
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
dataKey: 'value2',
|
|
225
|
+
name: 'Hidden Series',
|
|
226
|
+
hide: true
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
dataKey: 'value3',
|
|
230
|
+
name: 'Another Visible Series'
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
height: 200,
|
|
234
|
+
title: 'With Hidden Bars'
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
export const CustomFormatter = {
|
|
238
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
239
|
+
className: "w-400",
|
|
240
|
+
children: /*#__PURE__*/ _jsx(BarChart, {
|
|
241
|
+
...args
|
|
242
|
+
})
|
|
243
|
+
}),
|
|
244
|
+
args: {
|
|
245
|
+
data: sampleData,
|
|
246
|
+
bars: [
|
|
247
|
+
{
|
|
248
|
+
dataKey: 'value1',
|
|
249
|
+
name: 'Sales'
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
dataKey: 'value2',
|
|
253
|
+
name: 'Profit'
|
|
254
|
+
}
|
|
255
|
+
],
|
|
256
|
+
height: 200,
|
|
257
|
+
tooltip: {
|
|
258
|
+
formatter: (value)=>`$${value.toLocaleString()}`,
|
|
259
|
+
labelFormatter: (label)=>`Month: ${label}`
|
|
260
|
+
},
|
|
261
|
+
yAxis: {
|
|
262
|
+
tickFormatter: (value)=>`$${value}`
|
|
263
|
+
},
|
|
264
|
+
title: 'Formatted Values'
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
export const EmptyState = {
|
|
268
|
+
render: (args)=>/*#__PURE__*/ _jsx("div", {
|
|
269
|
+
className: "w-400",
|
|
270
|
+
children: /*#__PURE__*/ _jsx(BarChart, {
|
|
271
|
+
...args
|
|
272
|
+
})
|
|
273
|
+
}),
|
|
274
|
+
args: {
|
|
275
|
+
data: [],
|
|
276
|
+
bars: [
|
|
277
|
+
{
|
|
278
|
+
dataKey: 'value1',
|
|
279
|
+
name: 'Series 1'
|
|
280
|
+
}
|
|
281
|
+
],
|
|
282
|
+
height: 200,
|
|
283
|
+
title: 'Duration distribution'
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
//# sourceMappingURL=bar-chart.stories.js.map
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from '../../../../components/typography/index.js';
|
|
2
3
|
import { cn } from '../../../../utils/cn.js';
|
|
3
4
|
export function ChartTooltipContent({ active, label, payload, hoveredDataKey, labelFormatter }) {
|
|
4
5
|
const isVisible = active && payload && payload.length;
|
|
5
6
|
if (!isVisible) return null;
|
|
6
7
|
return /*#__PURE__*/ _jsxs("div", {
|
|
7
|
-
className:
|
|
8
|
+
className: "flex flex-col gap-4 rounded-8 p-12 bg-background-neutral-overlay border border-border-neutral-base shadow-lg",
|
|
8
9
|
children: [
|
|
9
|
-
/*#__PURE__*/ _jsx(
|
|
10
|
-
|
|
10
|
+
/*#__PURE__*/ _jsx(Text, {
|
|
11
|
+
size: "xs",
|
|
12
|
+
className: "text-foreground-neutral-muted",
|
|
11
13
|
children: labelFormatter ? labelFormatter(String(label)) : label
|
|
12
14
|
}),
|
|
13
15
|
/*#__PURE__*/ _jsx("div", {
|
|
@@ -16,23 +18,22 @@ export function ChartTooltipContent({ active, label, payload, hoveredDataKey, la
|
|
|
16
18
|
/*#__PURE__*/ _jsx("div", {
|
|
17
19
|
className: "flex flex-col gap-4",
|
|
18
20
|
children: payload.map((item, index)=>/*#__PURE__*/ _jsxs("div", {
|
|
19
|
-
className:
|
|
20
|
-
style: {
|
|
21
|
-
opacity: hoveredDataKey ? item.dataKey === hoveredDataKey ? 1 : 0.5 : 1
|
|
22
|
-
},
|
|
21
|
+
className: cn('flex items-center gap-8', hoveredDataKey && item.dataKey !== hoveredDataKey && 'opacity-50'),
|
|
23
22
|
children: [
|
|
24
23
|
/*#__PURE__*/ _jsx("span", {
|
|
25
|
-
className: "size-8 rounded-full
|
|
24
|
+
className: "size-8 shrink-0 rounded-full",
|
|
26
25
|
style: {
|
|
27
26
|
backgroundColor: item.color
|
|
28
27
|
}
|
|
29
28
|
}),
|
|
30
|
-
item.name && /*#__PURE__*/ _jsx(
|
|
31
|
-
|
|
29
|
+
item.name && /*#__PURE__*/ _jsx(Text, {
|
|
30
|
+
size: "xs",
|
|
31
|
+
className: "text-foreground-neutral-subtle",
|
|
32
32
|
children: item.name
|
|
33
33
|
}),
|
|
34
|
-
/*#__PURE__*/ _jsx(
|
|
35
|
-
|
|
34
|
+
/*#__PURE__*/ _jsx(Text, {
|
|
35
|
+
size: "xs",
|
|
36
|
+
className: "text-foreground-neutral-base font-medium ml-auto tabular-nums",
|
|
36
37
|
children: item.value
|
|
37
38
|
})
|
|
38
39
|
]
|
|
@@ -4,8 +4,9 @@ export declare const chartColors: {
|
|
|
4
4
|
readonly orange: "var(--color-orange-500)";
|
|
5
5
|
readonly purple: "var(--color-purple-500)";
|
|
6
6
|
readonly red: "var(--color-red-500)";
|
|
7
|
-
readonly
|
|
7
|
+
readonly amber: "var(--color-amber-500)";
|
|
8
|
+
readonly neutral: "var(--color-neutral-500)";
|
|
8
9
|
};
|
|
9
10
|
export type ChartColor = keyof typeof chartColors;
|
|
10
|
-
export declare const chartColorsList: ("var(--color-blue-500)" | "var(--color-green-500)" | "var(--color-orange-500)" | "var(--color-purple-500)" | "var(--color-red-500)")[];
|
|
11
|
+
export declare const chartColorsList: ("var(--color-blue-500)" | "var(--color-green-500)" | "var(--color-orange-500)" | "var(--color-purple-500)" | "var(--color-red-500)" | "var(--color-amber-500)" | "var(--color-neutral-500)")[];
|
|
11
12
|
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -4,14 +4,17 @@ export const chartColors = {
|
|
|
4
4
|
orange: 'var(--color-orange-500)',
|
|
5
5
|
purple: 'var(--color-purple-500)',
|
|
6
6
|
red: 'var(--color-red-500)',
|
|
7
|
-
|
|
7
|
+
amber: 'var(--color-amber-500)',
|
|
8
|
+
neutral: 'var(--color-neutral-500)'
|
|
8
9
|
};
|
|
9
10
|
export const chartColorsList = [
|
|
10
11
|
chartColors.blue,
|
|
11
12
|
chartColors.green,
|
|
12
13
|
chartColors.orange,
|
|
13
14
|
chartColors.purple,
|
|
14
|
-
chartColors.red
|
|
15
|
+
chartColors.red,
|
|
16
|
+
chartColors.amber,
|
|
17
|
+
chartColors.neutral
|
|
15
18
|
];
|
|
16
19
|
|
|
17
20
|
//# sourceMappingURL=colors.js.map
|
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import type { ComponentProps } from 'react';
|
|
2
|
-
import { type LineProps, LineChart as RechartsLineChart } from 'recharts';
|
|
3
|
-
import {
|
|
2
|
+
import { type CartesianGridProps, type LineProps, LineChart as RechartsLineChart, type XAxisProps, type YAxisProps } from 'recharts';
|
|
3
|
+
import type { ChartColor } from './colors';
|
|
4
4
|
export type RechartsLineChartProps = ComponentProps<typeof RechartsLineChart>;
|
|
5
5
|
export interface LineChartLine extends Omit<LineProps, 'dataKey' | 'strokeWidth'> {
|
|
6
6
|
dataKey: string;
|
|
7
7
|
name?: string;
|
|
8
8
|
strokeWidth?: number;
|
|
9
9
|
color?: ChartColor;
|
|
10
|
+
hide?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export interface LineChartProps {
|
|
12
13
|
data: RechartsLineChartProps['data'];
|
|
13
14
|
lines: LineChartLine[];
|
|
14
15
|
syncId?: RechartsLineChartProps['syncId'];
|
|
15
16
|
height?: number;
|
|
16
|
-
xAxis?:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
hide?: boolean;
|
|
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'>;
|
|
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;
|