@turtleclub/ui 0.7.0-beta.33 → 0.7.0-beta.35

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.
Files changed (135) hide show
  1. package/dist/index.cjs +10331 -110
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +7227 -48026
  4. package/dist/index.js.map +1 -1
  5. package/package.json +17 -11
  6. package/.prettierrc.json +0 -4
  7. package/.turbo/turbo-build.log +0 -182
  8. package/CHANGELOG.md +0 -801
  9. package/components.json +0 -21
  10. package/src/components/charts/QUICK_REFERENCE.md +0 -323
  11. package/src/components/charts/README.md +0 -658
  12. package/src/components/charts/RECHARTS_FEATURES.md +0 -458
  13. package/src/components/charts/area-chart.tsx +0 -248
  14. package/src/components/charts/bar-chart.tsx +0 -362
  15. package/src/components/charts/index.ts +0 -4
  16. package/src/components/charts/pie-chart.tsx +0 -277
  17. package/src/components/charts/radial-chart.tsx +0 -312
  18. package/src/components/features/api-status/index.tsx +0 -23
  19. package/src/components/features/data-table/data-table.tsx +0 -538
  20. package/src/components/features/data-table/expand-toggle.tsx +0 -17
  21. package/src/components/features/data-table/fuzzy-filter.tsx +0 -34
  22. package/src/components/features/data-table/index.ts +0 -3
  23. package/src/components/features/data-table/item-info.tsx +0 -19
  24. package/src/components/features/data-table/skeleton.tsx +0 -23
  25. package/src/components/features/data-table/sort-dropdown.tsx +0 -118
  26. package/src/components/features/data-table/sortable-header.tsx +0 -37
  27. package/src/components/features/index.ts +0 -6
  28. package/src/components/features/page-heading.tsx +0 -27
  29. package/src/components/features/search-bar.tsx +0 -55
  30. package/src/components/features/segmented-navigation.tsx +0 -18
  31. package/src/components/features/sidebar-layout.tsx +0 -279
  32. package/src/components/features/turtle-tooltip.tsx +0 -67
  33. package/src/components/icons/arrow.tsx +0 -23
  34. package/src/components/icons/beta.tsx +0 -95
  35. package/src/components/icons/dot.tsx +0 -102
  36. package/src/components/icons/index.ts +0 -7
  37. package/src/components/icons/issue.tsx +0 -106
  38. package/src/components/icons/turtle.tsx +0 -156
  39. package/src/components/icons/update.tsx +0 -113
  40. package/src/components/icons/warning.tsx +0 -95
  41. package/src/components/molecules/index.ts +0 -9
  42. package/src/components/molecules/opportunity/index.ts +0 -10
  43. package/src/components/molecules/opportunity/opportunity-apr.tsx +0 -129
  44. package/src/components/molecules/opportunity/opportunity-disclaimer.tsx +0 -46
  45. package/src/components/molecules/opportunity/opportunity-rate-estimator.tsx +0 -62
  46. package/src/components/molecules/opportunity/opportunity-section.tsx +0 -113
  47. package/src/components/molecules/opportunity/opportunity-selector.tsx +0 -30
  48. package/src/components/molecules/opportunity/opportunity-type.tsx +0 -16
  49. package/src/components/molecules/route-details.tsx +0 -112
  50. package/src/components/molecules/slippage-selector.tsx +0 -200
  51. package/src/components/molecules/swap-details.tsx +0 -55
  52. package/src/components/molecules/swap-input.tsx +0 -186
  53. package/src/components/molecules/tabs.tsx +0 -79
  54. package/src/components/molecules/token-selector.tsx +0 -180
  55. package/src/components/molecules/tx-status.tsx +0 -312
  56. package/src/components/molecules/widget/asset-list/asset-filters.tsx +0 -113
  57. package/src/components/molecules/widget/asset-list/asset-list.tsx +0 -178
  58. package/src/components/molecules/widget/asset-list/asset-row.tsx +0 -45
  59. package/src/components/molecules/widget/asset-list/hooks/index.ts +0 -2
  60. package/src/components/molecules/widget/asset-list/hooks/use-asset-filtering.ts +0 -44
  61. package/src/components/molecules/widget/asset-list/hooks/use-asset-grouping.ts +0 -87
  62. package/src/components/molecules/widget/asset-list/index.ts +0 -3
  63. package/src/components/molecules/widget/base-selector.tsx +0 -121
  64. package/src/components/molecules/widget/campaign-item.tsx +0 -82
  65. package/src/components/molecules/widget/deal-item.tsx +0 -92
  66. package/src/components/molecules/widget/index.ts +0 -36
  67. package/src/components/molecules/widget/opportunity-item.tsx +0 -105
  68. package/src/components/molecules/widget/widget-item-stats.tsx +0 -50
  69. package/src/components/molecules/widget/widget-item.tsx +0 -139
  70. package/src/components/molecules/widget/widget-list-items.tsx +0 -86
  71. package/src/components/ui/alert-dialog.tsx +0 -163
  72. package/src/components/ui/animated-background/animated-background.tsx +0 -182
  73. package/src/components/ui/animated-background/index.ts +0 -1
  74. package/src/components/ui/avatar.tsx +0 -73
  75. package/src/components/ui/badge.tsx +0 -59
  76. package/src/components/ui/banner.tsx +0 -84
  77. package/src/components/ui/button.tsx +0 -100
  78. package/src/components/ui/card.tsx +0 -119
  79. package/src/components/ui/chart.tsx +0 -346
  80. package/src/components/ui/checkbox.tsx +0 -32
  81. package/src/components/ui/chip.tsx +0 -52
  82. package/src/components/ui/collapsible.tsx +0 -34
  83. package/src/components/ui/combobox.tsx +0 -730
  84. package/src/components/ui/command.tsx +0 -184
  85. package/src/components/ui/dialog.tsx +0 -129
  86. package/src/components/ui/dropdown.tsx +0 -316
  87. package/src/components/ui/field.tsx +0 -244
  88. package/src/components/ui/heading.tsx +0 -74
  89. package/src/components/ui/hover-card.tsx +0 -139
  90. package/src/components/ui/icon-animation.tsx +0 -82
  91. package/src/components/ui/icon-list.tsx +0 -168
  92. package/src/components/ui/index.ts +0 -48
  93. package/src/components/ui/info-card.tsx +0 -110
  94. package/src/components/ui/input-group.tsx +0 -170
  95. package/src/components/ui/input.tsx +0 -72
  96. package/src/components/ui/label-with-icon.tsx +0 -122
  97. package/src/components/ui/label.tsx +0 -24
  98. package/src/components/ui/multi-select.tsx +0 -1090
  99. package/src/components/ui/navigation-bar.tsx +0 -153
  100. package/src/components/ui/navigation-menu.tsx +0 -188
  101. package/src/components/ui/opportunity-details-v1.tsx +0 -104
  102. package/src/components/ui/pagination.tsx +0 -127
  103. package/src/components/ui/popover.tsx +0 -48
  104. package/src/components/ui/scroll-area.tsx +0 -64
  105. package/src/components/ui/segment-control.tsx +0 -146
  106. package/src/components/ui/select.tsx +0 -199
  107. package/src/components/ui/separator.tsx +0 -26
  108. package/src/components/ui/sheet.tsx +0 -139
  109. package/src/components/ui/sidebar.tsx +0 -728
  110. package/src/components/ui/skeleton.tsx +0 -14
  111. package/src/components/ui/slider.tsx +0 -58
  112. package/src/components/ui/sonner.tsx +0 -24
  113. package/src/components/ui/switch.tsx +0 -29
  114. package/src/components/ui/table-shadcn.tsx +0 -110
  115. package/src/components/ui/table.tsx +0 -117
  116. package/src/components/ui/textarea.tsx +0 -22
  117. package/src/components/ui/toggle-group.tsx +0 -71
  118. package/src/components/ui/toggle.tsx +0 -47
  119. package/src/components/ui/tooltip.tsx +0 -66
  120. package/src/hooks/index.ts +0 -1
  121. package/src/hooks/useIsMobile.ts +0 -77
  122. package/src/index.ts +0 -16
  123. package/src/lib/utils.ts +0 -6
  124. package/src/styles/globals.css +0 -181
  125. package/src/styles/themes/index.css +0 -9
  126. package/src/styles/themes/semantic.css +0 -117
  127. package/src/styles/tokens/colors.css +0 -124
  128. package/src/styles/tokens/index.css +0 -15
  129. package/src/styles/tokens/radius.css +0 -18
  130. package/src/styles/tokens/spacing.css +0 -58
  131. package/src/styles/tokens/typography.css +0 -87
  132. package/src/tokens/index.ts +0 -108
  133. package/tsconfig.json +0 -20
  134. package/vite.config.js +0 -49
  135. /package/{src/images/enso.png → dist/enso-22FJ4GNK.png} +0 -0
@@ -1,362 +0,0 @@
1
- "use client";
2
-
3
- import {
4
- Bar,
5
- BarChart as RechartsBarChart,
6
- CartesianGrid,
7
- XAxis,
8
- YAxis,
9
- Cell,
10
- } from "recharts";
11
- import {
12
- ChartConfig,
13
- ChartContainer,
14
- ChartLegend,
15
- ChartLegendContent,
16
- ChartTooltip,
17
- ChartTooltipContent,
18
- } from "../ui/chart";
19
- import { cn } from "@/lib/utils";
20
-
21
- export interface BarChartData {
22
- [key: string]: string | number;
23
- }
24
-
25
- export interface BarChartProps {
26
- /**
27
- * Array of data objects to be displayed in the chart
28
- */
29
- data: BarChartData[];
30
- /**
31
- * Configuration for chart styling and labels
32
- */
33
- config: ChartConfig;
34
- /**
35
- * Key from data objects to use for X-axis categories
36
- */
37
- categoryKey: string;
38
- /**
39
- * Array of keys from data objects to display as bars
40
- */
41
- dataKeys: string[];
42
- /**
43
- * Chart layout orientation
44
- * @default "horizontal"
45
- */
46
- layout?: "horizontal" | "vertical";
47
- /**
48
- * Show grid lines. Can be boolean for both axes or object for granular control
49
- * @default true
50
- */
51
- showGrid?: boolean | { horizontal?: boolean; vertical?: boolean };
52
- /**
53
- * Show legend
54
- * @default false
55
- */
56
- showLegend?: boolean;
57
- /**
58
- * Show tooltip on hover
59
- * @default true
60
- */
61
- showTooltip?: boolean;
62
- /**
63
- * Stack bars on top of each other
64
- * @default false
65
- */
66
- stacked?: boolean;
67
- /**
68
- * Border radius for bars
69
- * @default 2
70
- */
71
- barRadius?: number;
72
- /**
73
- * Enable gradient fill for bars with directional support based on value
74
- * Vertical bars: positive (bottom-to-top), negative (top-to-bottom)
75
- * Horizontal bars: positive (left-to-right), negative (right-to-left)
76
- * @default false
77
- */
78
- gradient?: boolean;
79
- /**
80
- * Function to conditionally determine bar color based on data entry
81
- * Receives the data entry and index, returns a color string or undefined to use default
82
- * Can return gradient URLs when used with gradient definitions
83
- * @example (entry) => entry.value > 100 ? 'hsl(var(--destructive))' : undefined
84
- */
85
- getBarColor?: (
86
- entry: BarChartData,
87
- index: number,
88
- dataKey: string,
89
- ) => string | undefined;
90
- /**
91
- * Custom className for the container
92
- */
93
- className?: string;
94
- /**
95
- * Chart height aspect ratio
96
- * @default "aspect-video"
97
- */
98
- aspectRatio?: string;
99
- /**
100
- * Make chart grow to fill parent container (ignores aspectRatio if true)
101
- * @default false
102
- */
103
- grow?: boolean;
104
- /**
105
- * Custom formatter function for Y-axis tick labels
106
- * @example (value) => `$${value.toLocaleString()}`
107
- * @example (value) => formatCompactNumber(value)
108
- */
109
- yAxisFormatter?: (value: number) => string;
110
- /**
111
- * Custom formatter function for X-axis tick labels
112
- * @example (value) => new Date(value).toLocaleDateString()
113
- * @example (value) => formatCompactNumber(value)
114
- */
115
- xAxisFormatter?: (value: any) => string;
116
- /** X-axis tick interval strategy / step (passed to Recharts XAxis `interval`)
117
- * Useful when you need predictable tick density instead of Recharts auto-skip.
118
- */
119
- xAxisInterval?:
120
- | number
121
- | "preserveStart"
122
- | "preserveEnd"
123
- | "preserveStartEnd"
124
- | "equidistantPreserveStart";
125
- /**
126
- * Minimum gap between X-axis ticks in px (passed to Recharts XAxis `minTickGap`)
127
- */
128
- xAxisMinTickGap?: number;
129
- /**
130
- * Custom formatter function for tooltip values
131
- * @example (value, name, item, index, payload) => `$${value.toLocaleString()}`
132
- */
133
- tooltipFormatter?: (
134
- value: any,
135
- name: any,
136
- item: any,
137
- index: number,
138
- payload: any,
139
- ) => React.ReactNode;
140
- }
141
-
142
- export function BarChart({
143
- data,
144
- config,
145
- categoryKey,
146
- dataKeys,
147
- layout = "horizontal",
148
- showGrid = true,
149
- showLegend = false,
150
- showTooltip = true,
151
- stacked = false,
152
- barRadius = 5,
153
- gradient = false,
154
- getBarColor,
155
- className,
156
- aspectRatio = "aspect-video",
157
- grow = false,
158
- yAxisFormatter,
159
- xAxisFormatter,
160
- xAxisInterval,
161
- xAxisMinTickGap,
162
- tooltipFormatter,
163
- }: BarChartProps) {
164
- const isVertical = layout === "vertical";
165
- const stackId = stacked ? "stack" : undefined;
166
-
167
- // Parse grid configuration
168
- const gridConfig =
169
- typeof showGrid === "boolean"
170
- ? { horizontal: showGrid, vertical: showGrid }
171
- : {
172
- horizontal: showGrid?.horizontal ?? false,
173
- vertical: showGrid?.vertical ?? false,
174
- };
175
-
176
- // Internal gradient color function that handles directional gradients
177
- const internalGetBarColor = gradient
178
- ? (entry: BarChartData, index: number, dataKey: string) => {
179
- const value = entry[dataKey] as number;
180
- const isNegative = value < 0;
181
- const gradientId = `gradient-bar-${dataKey}-${isNegative ? "neg" : "pos"}`;
182
-
183
- // If user provided custom color function, use it
184
- if (getBarColor) {
185
- const customColor = getBarColor(entry, index, dataKey);
186
- if (customColor) return customColor;
187
- }
188
-
189
- return `url(#${gradientId})`;
190
- }
191
- : getBarColor;
192
-
193
- return (
194
- <ChartContainer
195
- config={config}
196
- className={cn(grow ? "h-full w-full" : aspectRatio, className)}
197
- >
198
- <RechartsBarChart
199
- accessibilityLayer
200
- data={data}
201
- layout={layout}
202
- margin={{
203
- top: 10,
204
- right: 10,
205
- bottom: 10,
206
- left: 10,
207
- }}
208
- >
209
- {(gridConfig.horizontal || gridConfig.vertical) && (
210
- <CartesianGrid
211
- strokeDasharray="3 3"
212
- horizontal={gridConfig.horizontal}
213
- vertical={gridConfig.vertical}
214
- />
215
- )}
216
-
217
- {isVertical ? (
218
- <>
219
- <YAxis
220
- dataKey={categoryKey}
221
- type="category"
222
- tickLine={false}
223
- tickMargin={10}
224
- axisLine={false}
225
- tickFormatter={(value) => {
226
- if (yAxisFormatter) {
227
- return yAxisFormatter(value);
228
- }
229
- return (
230
- config[value as keyof typeof config]?.label?.toString() ||
231
- value
232
- );
233
- }}
234
- width={yAxisFormatter ? 50 : undefined}
235
- />
236
- <XAxis
237
- type="number"
238
- tickLine={false}
239
- axisLine={false}
240
- interval={xAxisInterval}
241
- minTickGap={xAxisMinTickGap}
242
- tickFormatter={(value) =>
243
- xAxisFormatter ? xAxisFormatter(value) : value
244
- }
245
- />
246
- </>
247
- ) : (
248
- <>
249
- <XAxis
250
- dataKey={categoryKey}
251
- tickLine={false}
252
- tickMargin={10}
253
- axisLine={false}
254
- interval={xAxisInterval}
255
- minTickGap={xAxisMinTickGap}
256
- tickFormatter={(value) => {
257
- if (xAxisFormatter) {
258
- return xAxisFormatter(value);
259
- }
260
- return (
261
- config[value as keyof typeof config]?.label?.toString() ||
262
- value
263
- );
264
- }}
265
- />
266
- <YAxis
267
- tickLine={false}
268
- axisLine={false}
269
- tickFormatter={(value) =>
270
- yAxisFormatter ? yAxisFormatter(value) : value
271
- }
272
- width={yAxisFormatter ? 50 : undefined}
273
- />
274
- </>
275
- )}
276
-
277
- {showTooltip && (
278
- <ChartTooltip
279
- cursor={false}
280
- content={
281
- <ChartTooltipContent
282
- indicator={stacked ? "line" : "dot"}
283
- formatter={tooltipFormatter}
284
- />
285
- }
286
- />
287
- )}
288
-
289
- {showLegend && <ChartLegend content={<ChartLegendContent />} />}
290
-
291
- <defs>
292
- {gradient &&
293
- dataKeys.flatMap((key) => [
294
- // Positive gradient
295
- <linearGradient
296
- key={`${key}-pos`}
297
- id={`gradient-bar-${key}-pos`}
298
- x1={isVertical ? "0" : "0"}
299
- y1={isVertical ? "0" : "1"}
300
- x2={isVertical ? "1" : "0"}
301
- y2={isVertical ? "0" : "0"}
302
- >
303
- <stop
304
- offset="0%"
305
- stopColor={`var(--color-${key})`}
306
- stopOpacity={0.1}
307
- />
308
- <stop
309
- offset="100%"
310
- stopColor={`var(--color-${key})`}
311
- stopOpacity={1}
312
- />
313
- </linearGradient>,
314
- // Negative gradient (reversed direction)
315
- <linearGradient
316
- key={`${key}-neg`}
317
- id={`gradient-bar-${key}-neg`}
318
- x1={isVertical ? "1" : "0"}
319
- y1={isVertical ? "0" : "0"}
320
- x2={isVertical ? "0" : "0"}
321
- y2={isVertical ? "0" : "1"}
322
- >
323
- <stop
324
- offset="0%"
325
- stopColor={`var(--color-${key})`}
326
- stopOpacity={0.1}
327
- />
328
- <stop
329
- offset="100%"
330
- stopColor={`var(--color-${key})`}
331
- stopOpacity={1}
332
- />
333
- </linearGradient>,
334
- ])}
335
- </defs>
336
-
337
- {dataKeys.map((key) => (
338
- <Bar
339
- key={key}
340
- dataKey={key}
341
- fill={`var(--color-${key})`}
342
- radius={barRadius}
343
- stackId={stackId}
344
- >
345
- {(gradient || getBarColor) &&
346
- data.map((entry, index) => {
347
- const fillColor = internalGetBarColor
348
- ? internalGetBarColor(entry, index, key)
349
- : `var(--color-${key})`;
350
- return (
351
- <Cell
352
- key={`cell-${key}-${index}`}
353
- fill={fillColor || `var(--color-${key})`}
354
- />
355
- );
356
- })}
357
- </Bar>
358
- ))}
359
- </RechartsBarChart>
360
- </ChartContainer>
361
- );
362
- }
@@ -1,4 +0,0 @@
1
- export * from "./bar-chart";
2
- export * from "./area-chart";
3
- export * from "./pie-chart";
4
- export * from "./radial-chart";
@@ -1,277 +0,0 @@
1
- "use client";
2
-
3
- import { Pie, PieChart as RechartsPieChart, Cell, Sector, PolarAngleAxis } from "recharts";
4
- import {
5
- ChartConfig,
6
- ChartContainer,
7
- ChartLegend,
8
- ChartLegendContent,
9
- ChartTooltip,
10
- ChartTooltipContent,
11
- } from "../ui/chart";
12
-
13
- export interface PieChartData {
14
- [key: string]: string | number;
15
- }
16
-
17
- export interface PieChartProps {
18
- /**
19
- * Array of data objects to be displayed in the chart
20
- */
21
- data: PieChartData[];
22
- /**
23
- * Configuration for chart styling and labels
24
- */
25
- config: ChartConfig;
26
- /**
27
- * Key from data objects to use for segment names
28
- */
29
- nameKey: string;
30
- /**
31
- * Key from data objects to use for segment values
32
- */
33
- dataKey: string;
34
- /**
35
- * Show legend
36
- * @default true
37
- */
38
- showLegend?: boolean;
39
- /**
40
- * Show tooltip on hover
41
- * @default true
42
- */
43
- showTooltip?: boolean;
44
- /**
45
- * Show labels on segments
46
- * @default false
47
- */
48
- showLabels?: boolean;
49
- /**
50
- * Inner radius for donut chart (0-100)
51
- * Set to 0 for full pie chart
52
- * @default 0
53
- */
54
- innerRadius?: number;
55
- /**
56
- * Outer radius (0-100)
57
- * @default 80
58
- */
59
- outerRadius?: number;
60
- /**
61
- * Padding angle between segments in degrees
62
- * @default 0
63
- */
64
- paddingAngle?: number;
65
- /**
66
- * Custom className for the container
67
- */
68
- className?: string;
69
- /**
70
- * Chart height aspect ratio
71
- * @default "aspect-square"
72
- */
73
- aspectRatio?: string;
74
- /**
75
- * Custom label formatter function
76
- */
77
- labelFormatter?: (value: number, entry: PieChartData) => string;
78
- /**
79
- * Custom formatter function for tooltip values
80
- * @example (value, name, item, index, payload) => `$${value.toLocaleString()}`
81
- */
82
- tooltipFormatter?: (
83
- value: any,
84
- name: any,
85
- item: any,
86
- index: number,
87
- payload: any
88
- ) => React.ReactNode;
89
- /**
90
- * Scale outer radius based on value percentage (larger values = larger radius)
91
- * Creates a "bursting" effect where segments extend outward based on their size
92
- * @default false
93
- */
94
- scaledRadius?: boolean;
95
- /**
96
- * Enable gradient fill for segments (radial gradient from center outward)
97
- * @default false
98
- */
99
- gradient?: boolean;
100
- /**
101
- * Show radial grid lines in the background
102
- * @default false
103
- */
104
- showRadialGrid?: boolean;
105
- /**
106
- * Number of radial lines to display (evenly spaced around the circle)
107
- * @default 8
108
- */
109
- radialGridLines?: number;
110
- }
111
-
112
- export function PieChart({
113
- data,
114
- config,
115
- nameKey,
116
- dataKey,
117
- showLegend = true,
118
- showTooltip = true,
119
- showLabels = false,
120
- innerRadius = 0,
121
- outerRadius = 80,
122
- paddingAngle = 0,
123
- className,
124
- aspectRatio = "aspect-square",
125
- labelFormatter,
126
- scaledRadius = false,
127
- gradient = false,
128
- showRadialGrid = false,
129
- radialGridLines = 8,
130
- tooltipFormatter,
131
- }: PieChartProps) {
132
- // Calculate total and max value for scaling
133
- const maxValue = Math.max(...data.map((entry) => Number(entry[dataKey]) || 0));
134
-
135
- const renderLabel = showLabels
136
- ? (entry: any) => {
137
- if (labelFormatter) {
138
- return labelFormatter(entry[dataKey], entry);
139
- }
140
- return `${entry[dataKey]}`;
141
- }
142
- : undefined;
143
-
144
- // Custom active shape renderer for scaled radius
145
- const renderActiveShape = (props: any) => {
146
- const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, fill } = props;
147
-
148
- return (
149
- <g>
150
- <Sector
151
- cx={cx}
152
- cy={cy}
153
- innerRadius={innerRadius}
154
- outerRadius={outerRadius}
155
- startAngle={startAngle}
156
- endAngle={endAngle}
157
- fill={fill}
158
- />
159
- </g>
160
- );
161
- };
162
-
163
- // Custom shape renderer for scaled radius and gradient
164
- const renderCustomShape = (props: any) => {
165
- const { cx, cy, innerRadius, outerRadius, startAngle, endAngle, fill, value, index } = props;
166
-
167
- // Calculate scaled radius if enabled
168
- let scaledOuterRadius = outerRadius;
169
- if (scaledRadius && maxValue > 0) {
170
- const valueNum = Number(value) || 0;
171
- const percentage = valueNum / maxValue;
172
- // Scale between 40% and 100% of the max outer radius
173
- const minScale = 0.4;
174
- scaledOuterRadius = outerRadius * (minScale + percentage * (1 - minScale));
175
- }
176
-
177
- if (gradient) {
178
- return (
179
- <>
180
- <defs>
181
- <radialGradient
182
- id={`fillGradient${index}`}
183
- cx={cx}
184
- cy={cy}
185
- r={scaledOuterRadius}
186
- gradientUnits="userSpaceOnUse"
187
- >
188
- <stop offset="0%" stopColor={fill} stopOpacity={0} />
189
- <stop offset="100%" stopColor={fill} stopOpacity={1} />
190
- </radialGradient>
191
- <clipPath id={`clipPath${index}`}>
192
- <Sector
193
- cx={cx}
194
- cy={cy}
195
- innerRadius={innerRadius}
196
- outerRadius={scaledOuterRadius}
197
- startAngle={startAngle}
198
- endAngle={endAngle}
199
- />
200
- </clipPath>
201
- </defs>
202
- <Sector
203
- cx={cx}
204
- cy={cy}
205
- innerRadius={innerRadius}
206
- outerRadius={scaledOuterRadius}
207
- startAngle={startAngle}
208
- endAngle={endAngle}
209
- clipPath={`url(#clipPath${index})`}
210
- fill={`url(#fillGradient${index})`}
211
- />
212
- </>
213
- );
214
- }
215
-
216
- return (
217
- <Sector
218
- cx={cx}
219
- cy={cy}
220
- innerRadius={innerRadius}
221
- outerRadius={scaledOuterRadius}
222
- startAngle={startAngle}
223
- endAngle={endAngle}
224
- fill={fill}
225
- />
226
- );
227
- };
228
-
229
- return (
230
- <ChartContainer config={config} className={className || aspectRatio}>
231
- <RechartsPieChart>
232
- {showRadialGrid && (
233
- <PolarAngleAxis
234
- dataKey="gridLines"
235
- tick={false}
236
- axisLine={{
237
- stroke: "hsl(var(--border))",
238
- strokeOpacity: 0.5,
239
- strokeWidth: 0.5,
240
- }}
241
- domain={[0, radialGridLines]}
242
- tickCount={radialGridLines}
243
- />
244
- )}
245
-
246
- {showTooltip && (
247
- <ChartTooltip
248
- cursor={false}
249
- content={
250
- <ChartTooltipContent hideLabel nameKey={nameKey} formatter={tooltipFormatter} />
251
- }
252
- />
253
- )}
254
-
255
- {showLegend && <ChartLegend content={<ChartLegendContent nameKey={nameKey} />} />}
256
-
257
- <Pie
258
- data={data}
259
- dataKey={dataKey}
260
- nameKey={nameKey}
261
- innerRadius={`${innerRadius}%`}
262
- outerRadius={`${outerRadius}%`}
263
- paddingAngle={paddingAngle}
264
- label={renderLabel}
265
- activeShape={scaledRadius || gradient ? renderActiveShape : undefined}
266
- shape={scaledRadius || gradient ? renderCustomShape : undefined}
267
- >
268
- {data.map((entry, index) => {
269
- const name = entry[nameKey] as string;
270
- const color = `var(--color-${name})`;
271
- return <Cell key={`cell-${index}`} fill={color} />;
272
- })}
273
- </Pie>
274
- </RechartsPieChart>
275
- </ChartContainer>
276
- );
277
- }