@turtleclub/ui 0.7.0-beta.3 → 0.7.0-beta.30
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/.turbo/turbo-build.log +143 -132
- package/CHANGELOG.md +152 -0
- package/dist/index.cjs +76 -36
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36068 -17674
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/components/charts/area-chart.d.ts +108 -0
- package/dist/types/components/charts/area-chart.d.ts.map +1 -0
- package/dist/types/components/charts/bar-chart.d.ts +110 -0
- package/dist/types/components/charts/bar-chart.d.ts.map +1 -0
- package/dist/types/components/charts/index.d.ts +5 -0
- package/dist/types/components/charts/index.d.ts.map +1 -0
- package/dist/types/components/charts/pie-chart.d.ts +94 -0
- package/dist/types/components/charts/pie-chart.d.ts.map +1 -0
- package/dist/types/components/charts/radial-chart.d.ts +151 -0
- package/dist/types/components/charts/radial-chart.d.ts.map +1 -0
- package/dist/types/components/features/data-table/data-table.d.ts +7 -4
- package/dist/types/components/features/data-table/data-table.d.ts.map +1 -1
- package/dist/types/components/features/data-table/sort-dropdown.d.ts.map +1 -1
- package/dist/types/components/features/search-bar.d.ts +1 -0
- package/dist/types/components/features/search-bar.d.ts.map +1 -1
- package/dist/types/components/molecules/swap-input.d.ts +3 -0
- package/dist/types/components/molecules/swap-input.d.ts.map +1 -1
- package/dist/types/components/molecules/token-selector.d.ts +2 -1
- package/dist/types/components/molecules/token-selector.d.ts.map +1 -1
- package/dist/types/components/ui/avatar.d.ts +2 -2
- package/dist/types/components/ui/avatar.d.ts.map +1 -1
- package/dist/types/components/ui/chart.d.ts +18 -4
- package/dist/types/components/ui/chart.d.ts.map +1 -1
- package/dist/types/components/ui/combobox.d.ts +21 -0
- package/dist/types/components/ui/combobox.d.ts.map +1 -1
- package/dist/types/components/ui/dialog.d.ts.map +1 -1
- package/dist/types/components/ui/dropdown.d.ts +2 -1
- package/dist/types/components/ui/dropdown.d.ts.map +1 -1
- package/dist/types/components/ui/index.d.ts +1 -0
- package/dist/types/components/ui/index.d.ts.map +1 -1
- package/dist/types/components/ui/multi-select.d.ts.map +1 -1
- package/dist/types/components/ui/segment-control.d.ts +1 -0
- package/dist/types/components/ui/segment-control.d.ts.map +1 -1
- package/dist/types/components/ui/slider.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/charts/QUICK_REFERENCE.md +323 -0
- package/src/components/charts/README.md +658 -0
- package/src/components/charts/RECHARTS_FEATURES.md +458 -0
- package/src/components/charts/area-chart.tsx +248 -0
- package/src/components/charts/bar-chart.tsx +362 -0
- package/src/components/charts/index.ts +4 -0
- package/src/components/charts/pie-chart.tsx +277 -0
- package/src/components/charts/radial-chart.tsx +312 -0
- package/src/components/features/data-table/data-table.tsx +136 -125
- package/src/components/features/data-table/sort-dropdown.tsx +8 -11
- package/src/components/features/search-bar.tsx +6 -1
- package/src/components/molecules/swap-input.tsx +44 -30
- package/src/components/molecules/token-selector.tsx +10 -1
- package/src/components/ui/avatar.tsx +8 -15
- package/src/components/ui/chart.tsx +100 -109
- package/src/components/ui/combobox.tsx +150 -137
- package/src/components/ui/dialog.tsx +9 -23
- package/src/components/ui/dropdown.tsx +3 -1
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/multi-select.tsx +325 -307
- package/src/components/ui/segment-control.tsx +7 -2
- package/src/components/ui/slider.tsx +6 -11
- package/src/index.ts +1 -0
- package/src/styles/globals.css +4 -0
- package/src/styles/themes/semantic.css +26 -56
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Cell,
|
|
5
|
+
PolarAngleAxis,
|
|
6
|
+
PolarGrid,
|
|
7
|
+
Radar,
|
|
8
|
+
RadarChart as RechartsRadarChart,
|
|
9
|
+
RadialBar,
|
|
10
|
+
RadialBarChart as RechartsRadialBarChart,
|
|
11
|
+
} from "recharts";
|
|
12
|
+
import {
|
|
13
|
+
ChartConfig,
|
|
14
|
+
ChartContainer,
|
|
15
|
+
ChartLegend,
|
|
16
|
+
ChartLegendContent,
|
|
17
|
+
ChartTooltip,
|
|
18
|
+
ChartTooltipContent,
|
|
19
|
+
} from "../ui/chart";
|
|
20
|
+
import { cn } from "@/lib/utils";
|
|
21
|
+
|
|
22
|
+
export interface RadialChartData {
|
|
23
|
+
[key: string]: string | number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface RadialBarChartProps {
|
|
27
|
+
/**
|
|
28
|
+
* Array of data objects to be displayed in the chart
|
|
29
|
+
*/
|
|
30
|
+
data: RadialChartData[];
|
|
31
|
+
/**
|
|
32
|
+
* Configuration for chart styling and labels
|
|
33
|
+
*/
|
|
34
|
+
config: ChartConfig;
|
|
35
|
+
/**
|
|
36
|
+
* Key from data objects to use for segment names
|
|
37
|
+
*/
|
|
38
|
+
nameKey: string;
|
|
39
|
+
/**
|
|
40
|
+
* Key from data objects to use for values
|
|
41
|
+
*/
|
|
42
|
+
dataKey: string;
|
|
43
|
+
/**
|
|
44
|
+
* Show legend
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
showLegend?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Show tooltip on hover
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
showTooltip?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Inner radius (0-100)
|
|
55
|
+
* @default 30
|
|
56
|
+
*/
|
|
57
|
+
innerRadius?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Outer radius (0-100)
|
|
60
|
+
* @default 100
|
|
61
|
+
*/
|
|
62
|
+
outerRadius?: number;
|
|
63
|
+
/**
|
|
64
|
+
* Start angle in degrees
|
|
65
|
+
* @default 90
|
|
66
|
+
*/
|
|
67
|
+
startAngle?: number;
|
|
68
|
+
/**
|
|
69
|
+
* End angle in degrees
|
|
70
|
+
* @default -270
|
|
71
|
+
*/
|
|
72
|
+
endAngle?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Custom className for the container
|
|
75
|
+
*/
|
|
76
|
+
className?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Chart height aspect ratio
|
|
79
|
+
* @default "aspect-square"
|
|
80
|
+
*/
|
|
81
|
+
aspectRatio?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Show labels on bars
|
|
84
|
+
* @default false
|
|
85
|
+
*/
|
|
86
|
+
showLabels?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Corner radius for bars
|
|
89
|
+
* @default 2
|
|
90
|
+
*/
|
|
91
|
+
cornerRadius?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Enable gradient fill for bars (uses Recharts native gradient support via Cell component)
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
gradient?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Make chart grow to fill parent container (ignores aspectRatio if true)
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
grow?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Custom formatter function for tooltip values
|
|
104
|
+
* @example (value, name, item, index, payload) => `$${value.toLocaleString()}`
|
|
105
|
+
*/
|
|
106
|
+
tooltipFormatter?: (
|
|
107
|
+
value: any,
|
|
108
|
+
name: any,
|
|
109
|
+
item: any,
|
|
110
|
+
index: number,
|
|
111
|
+
payload: any
|
|
112
|
+
) => React.ReactNode;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function RadialBarChart({
|
|
116
|
+
data,
|
|
117
|
+
config,
|
|
118
|
+
nameKey,
|
|
119
|
+
dataKey,
|
|
120
|
+
showLegend = false,
|
|
121
|
+
showTooltip = true,
|
|
122
|
+
innerRadius = 30,
|
|
123
|
+
outerRadius = 100,
|
|
124
|
+
startAngle = 90,
|
|
125
|
+
endAngle = -270,
|
|
126
|
+
className,
|
|
127
|
+
aspectRatio = "aspect-square",
|
|
128
|
+
showLabels = false,
|
|
129
|
+
cornerRadius = 2,
|
|
130
|
+
gradient = true,
|
|
131
|
+
grow = false,
|
|
132
|
+
tooltipFormatter,
|
|
133
|
+
}: RadialBarChartProps) {
|
|
134
|
+
return (
|
|
135
|
+
<ChartContainer config={config} className={cn(grow ? "h-full w-full" : aspectRatio, className)}>
|
|
136
|
+
<RechartsRadialBarChart
|
|
137
|
+
data={data}
|
|
138
|
+
startAngle={startAngle}
|
|
139
|
+
endAngle={endAngle}
|
|
140
|
+
innerRadius={`${innerRadius}%`}
|
|
141
|
+
outerRadius={`${outerRadius}%`}
|
|
142
|
+
>
|
|
143
|
+
<PolarGrid gridType="circle" />
|
|
144
|
+
|
|
145
|
+
{showTooltip && (
|
|
146
|
+
<ChartTooltip
|
|
147
|
+
cursor={false}
|
|
148
|
+
content={
|
|
149
|
+
<ChartTooltipContent hideLabel nameKey={nameKey} formatter={tooltipFormatter} />
|
|
150
|
+
}
|
|
151
|
+
/>
|
|
152
|
+
)}
|
|
153
|
+
|
|
154
|
+
{showLegend && <ChartLegend content={<ChartLegendContent nameKey={nameKey} />} />}
|
|
155
|
+
|
|
156
|
+
<defs>
|
|
157
|
+
{gradient &&
|
|
158
|
+
data.map((entry, index) => {
|
|
159
|
+
const name = entry[nameKey] as string;
|
|
160
|
+
return (
|
|
161
|
+
<linearGradient
|
|
162
|
+
key={name}
|
|
163
|
+
id={`gradient-radial-${name}`}
|
|
164
|
+
x1="1"
|
|
165
|
+
y1="0"
|
|
166
|
+
x2="0"
|
|
167
|
+
y2="0"
|
|
168
|
+
>
|
|
169
|
+
<stop offset="0%" stopColor={`var(--color-${name})`} stopOpacity={0.1} />
|
|
170
|
+
<stop offset="100%" stopColor={`var(--color-${name})`} stopOpacity={1} />
|
|
171
|
+
</linearGradient>
|
|
172
|
+
);
|
|
173
|
+
})}
|
|
174
|
+
</defs>
|
|
175
|
+
|
|
176
|
+
<RadialBar
|
|
177
|
+
dataKey={dataKey}
|
|
178
|
+
cornerRadius={cornerRadius}
|
|
179
|
+
label={showLabels ? { position: "insideStart", fill: "#fff" } : false}
|
|
180
|
+
background={{ fill: "transparent" }}
|
|
181
|
+
>
|
|
182
|
+
{/* Using Recharts native Cell component for per-bar styling and gradients */}
|
|
183
|
+
{data.map((entry, index) => {
|
|
184
|
+
const name = entry[nameKey] as string;
|
|
185
|
+
const fill = gradient ? `url(#gradient-radial-${name})` : `var(--color-${name})`;
|
|
186
|
+
return <Cell key={`cell-${index}`} fill={fill} />;
|
|
187
|
+
})}
|
|
188
|
+
</RadialBar>
|
|
189
|
+
</RechartsRadialBarChart>
|
|
190
|
+
</ChartContainer>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface RadarChartProps {
|
|
195
|
+
/**
|
|
196
|
+
* Array of data objects to be displayed in the chart
|
|
197
|
+
*/
|
|
198
|
+
data: RadialChartData[];
|
|
199
|
+
/**
|
|
200
|
+
* Configuration for chart styling and labels
|
|
201
|
+
*/
|
|
202
|
+
config: ChartConfig;
|
|
203
|
+
/**
|
|
204
|
+
* Key from data objects to use for categories
|
|
205
|
+
*/
|
|
206
|
+
categoryKey: string;
|
|
207
|
+
/**
|
|
208
|
+
* Array of keys from data objects to display as radar areas
|
|
209
|
+
*/
|
|
210
|
+
dataKeys: string[];
|
|
211
|
+
/**
|
|
212
|
+
* Show legend
|
|
213
|
+
* @default false
|
|
214
|
+
*/
|
|
215
|
+
showLegend?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Show tooltip on hover
|
|
218
|
+
* @default true
|
|
219
|
+
*/
|
|
220
|
+
showTooltip?: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Show dots on data points
|
|
223
|
+
* @default true
|
|
224
|
+
*/
|
|
225
|
+
showDots?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Fill opacity for radar areas
|
|
228
|
+
* @default 0.6
|
|
229
|
+
*/
|
|
230
|
+
fillOpacity?: number;
|
|
231
|
+
/**
|
|
232
|
+
* Stroke width for radar lines
|
|
233
|
+
* @default 2
|
|
234
|
+
*/
|
|
235
|
+
strokeWidth?: number;
|
|
236
|
+
/**
|
|
237
|
+
* Custom className for the container
|
|
238
|
+
*/
|
|
239
|
+
className?: string;
|
|
240
|
+
/**
|
|
241
|
+
* Chart height aspect ratio
|
|
242
|
+
* @default "aspect-square"
|
|
243
|
+
*/
|
|
244
|
+
aspectRatio?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Make chart grow to fill parent container (ignores aspectRatio if true)
|
|
247
|
+
* @default false
|
|
248
|
+
*/
|
|
249
|
+
grow?: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* Custom formatter function for tooltip values
|
|
252
|
+
* @example (value, name, item, index, payload) => `$${value.toLocaleString()}`
|
|
253
|
+
*/
|
|
254
|
+
tooltipFormatter?: (
|
|
255
|
+
value: any,
|
|
256
|
+
name: any,
|
|
257
|
+
item: any,
|
|
258
|
+
index: number,
|
|
259
|
+
payload: any
|
|
260
|
+
) => React.ReactNode;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function RadarChart({
|
|
264
|
+
data,
|
|
265
|
+
config,
|
|
266
|
+
categoryKey,
|
|
267
|
+
dataKeys,
|
|
268
|
+
showLegend = false,
|
|
269
|
+
showTooltip = true,
|
|
270
|
+
showDots = true,
|
|
271
|
+
fillOpacity = 0.6,
|
|
272
|
+
strokeWidth = 2,
|
|
273
|
+
className,
|
|
274
|
+
aspectRatio = "aspect-square",
|
|
275
|
+
grow = false,
|
|
276
|
+
tooltipFormatter,
|
|
277
|
+
}: RadarChartProps) {
|
|
278
|
+
return (
|
|
279
|
+
<ChartContainer config={config} className={cn(grow ? "h-full w-full" : aspectRatio, className)}>
|
|
280
|
+
<RechartsRadarChart data={data}>
|
|
281
|
+
<PolarGrid />
|
|
282
|
+
<PolarAngleAxis
|
|
283
|
+
dataKey={categoryKey}
|
|
284
|
+
tickFormatter={(value) =>
|
|
285
|
+
config[value as keyof typeof config]?.label?.toString() || value
|
|
286
|
+
}
|
|
287
|
+
/>
|
|
288
|
+
|
|
289
|
+
{showTooltip && (
|
|
290
|
+
<ChartTooltip
|
|
291
|
+
cursor={false}
|
|
292
|
+
content={<ChartTooltipContent indicator="line" formatter={tooltipFormatter} />}
|
|
293
|
+
/>
|
|
294
|
+
)}
|
|
295
|
+
|
|
296
|
+
{showLegend && <ChartLegend content={<ChartLegendContent />} />}
|
|
297
|
+
|
|
298
|
+
{dataKeys.map((key) => (
|
|
299
|
+
<Radar
|
|
300
|
+
key={key}
|
|
301
|
+
dataKey={key}
|
|
302
|
+
fill={`var(--color-${key})`}
|
|
303
|
+
stroke={`var(--color-${key})`}
|
|
304
|
+
fillOpacity={fillOpacity}
|
|
305
|
+
strokeWidth={strokeWidth}
|
|
306
|
+
dot={showDots}
|
|
307
|
+
/>
|
|
308
|
+
))}
|
|
309
|
+
</RechartsRadarChart>
|
|
310
|
+
</ChartContainer>
|
|
311
|
+
);
|
|
312
|
+
}
|