flikkui 0.1.0-beta.3 → 0.1.0-beta.5
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/README.md +155 -0
- package/dist/components/charts/AreaChart/AreaChart.js +434 -0
- package/dist/components/charts/AreaChart/AreaChart.types.js +7 -0
- package/dist/components/charts/BarChart/BarChart.js +402 -0
- package/dist/components/charts/BarChart/BarChart.types.js +7 -0
- package/dist/components/charts/ChartContainer.js +38 -0
- package/dist/components/charts/Heatmap/Heatmap.js +153 -0
- package/dist/components/charts/Heatmap/HeatmapCell.js +100 -0
- package/dist/components/charts/Heatmap/HeatmapLegend.js +20 -0
- package/dist/components/charts/Heatmap/utils/heatmapUtils.js +174 -0
- package/dist/components/charts/LineChart/LineChart.js +396 -0
- package/dist/components/charts/LineChart/LineChart.types.js +7 -0
- package/dist/components/charts/hooks/useChartAccessibility.js +127 -0
- package/dist/components/charts/hooks/useChartTheme.js +86 -0
- package/dist/components/charts/hooks/useChartValidation.js +59 -0
- package/dist/components/charts/hooks/useTooltipPosition.js +292 -0
- package/dist/components/charts/shared/ChartAxis/XAxis.js +30 -0
- package/dist/components/charts/shared/ChartAxis/YAxis.js +97 -0
- package/dist/components/charts/shared/ChartCrosshair/ChartCrosshair.js +35 -0
- package/dist/components/charts/shared/ChartCrosshair/ChartCrosshair.theme.js +11 -0
- package/dist/components/charts/shared/ChartErrorBoundary/ChartErrorBoundary.js +66 -0
- package/dist/components/charts/shared/ChartGrid/HorizontalGrid.js +22 -0
- package/dist/components/charts/shared/ChartLegend/ChartLegend.js +30 -0
- package/dist/components/charts/shared/ChartLegend/ChartLegendContent.js +22 -0
- package/dist/components/charts/shared/ChartMarker/ChartMarker.js +25 -0
- package/dist/components/charts/shared/ChartMarker/ChartMarker.theme.js +9 -0
- package/dist/components/charts/shared/ChartText/ChartText.js +33 -0
- package/dist/components/charts/shared/ChartText/ChartText.theme.js +9 -0
- package/dist/components/charts/shared/ChartTooltip/ChartTooltip.js +62 -0
- package/dist/components/charts/theme/chart.theme.js +73 -0
- package/dist/components/charts/types/chart.types.js +29 -0
- package/dist/components/charts/utils/chart-validation.js +292 -0
- package/dist/components/charts/utils/color-utils.js +175 -0
- package/dist/components/core/Accordion/Accordion.animations.js +45 -0
- package/dist/components/core/Accordion/Accordion.js +52 -0
- package/dist/components/core/Accordion/Accordion.theme.js +8 -0
- package/dist/components/core/Accordion/AccordionContent.js +25 -0
- package/dist/components/core/Accordion/AccordionItem.js +56 -0
- package/dist/components/core/Accordion/AccordionTrigger.js +32 -0
- package/dist/components/core/Accordion/index.js +5 -0
- package/dist/components/core/Avatar/Avatar.js +94 -0
- package/dist/components/core/Avatar/Avatar.theme.js +25 -0
- package/dist/components/core/AvatarGroup/AvatarGroup.animations.js +79 -0
- package/dist/components/core/AvatarGroup/AvatarGroup.js +67 -0
- package/dist/components/core/AvatarGroup/AvatarGroup.theme.js +23 -0
- package/dist/components/core/Badge/Badge.animations.js +109 -0
- package/dist/components/core/Badge/Badge.js +101 -0
- package/dist/components/core/Badge/Badge.theme.js +41 -0
- package/dist/components/core/Breadcrumbs/Breadcrumbs.theme.js +8 -8
- package/dist/components/core/Button/Button.theme.js +5 -5
- package/dist/components/core/Card/Card.js +46 -0
- package/dist/components/core/Card/Card.theme.js +5 -0
- package/dist/components/core/Divider/Divider.js +21 -0
- package/dist/components/core/Divider/Divider.theme.js +19 -0
- package/dist/components/core/Pagination/Pagination.js +113 -0
- package/dist/components/core/Pagination/Pagination.theme.js +27 -0
- package/dist/components/core/Segmented/Segmented.js +69 -0
- package/dist/components/core/Segmented/Segmented.theme.js +40 -0
- package/dist/components/core/Segmented/SegmentedContext.js +8 -0
- package/dist/components/core/Segmented/SegmentedItem.js +30 -0
- package/dist/components/core/Stepper/Stepper.js +57 -0
- package/dist/components/core/Stepper/Stepper.theme.js +9 -0
- package/dist/components/core/Stepper/components/ConnectorLine.js +42 -0
- package/dist/components/core/Stepper/components/IconCircle.js +44 -0
- package/dist/components/core/Stepper/components/ProgressIndicator.js +12 -0
- package/dist/components/core/Stepper/components/StepContent.js +36 -0
- package/dist/components/core/Stepper/components/StepperItem.js +22 -0
- package/dist/components/core/Tabs/Tabs.theme.js +2 -2
- package/dist/components/core/Tooltip/Tooltip.animations.js +46 -0
- package/dist/components/core/Tooltip/Tooltip.js +85 -0
- package/dist/components/core/Tooltip/Tooltip.theme.js +11 -0
- package/dist/components/core/Tooltip/useTooltipPositioning.js +59 -0
- package/dist/components/core/Tree/Tree.animations.js +38 -0
- package/dist/components/core/Tree/Tree.js +177 -0
- package/dist/components/core/Tree/Tree.theme.js +11 -0
- package/dist/components/data-display/Table/Table.js +177 -0
- package/dist/components/data-display/Table/Table.theme.js +28 -0
- package/dist/components/data-display/Table/Table.utils.js +28 -0
- package/dist/components/data-display/Table/components/DeclarativeComponents.js +123 -0
- package/dist/components/data-display/Table/components/TableActions/TableActions.js +56 -0
- package/dist/components/data-display/Table/components/TableActions/TableActionsMenu.js +29 -0
- package/dist/components/data-display/Table/components/TableColumnManager/TableColumnManager.js +85 -0
- package/dist/components/data-display/Table/components/TableColumnManager/TableColumnManager.theme.js +21 -0
- package/dist/components/data-display/Table/components/TablePagination/TablePagination.js +51 -0
- package/dist/components/data-display/Table/components/TableSelectionHeader/TableSelectionHeader.js +29 -0
- package/dist/components/data-display/Table/components/core/TableBody.js +32 -0
- package/dist/components/data-display/Table/components/core/TableCell.js +47 -0
- package/dist/components/data-display/Table/components/core/TableHeader.js +77 -0
- package/dist/components/data-display/Table/components/core/TableRow.js +46 -0
- package/dist/components/data-display/Table/index.js +20 -0
- package/dist/components/feedback/Alert/Alert.js +36 -0
- package/dist/components/feedback/Alert/Alert.theme.js +17 -0
- package/dist/components/feedback/ChatMessage/ChatMessage.js +26 -0
- package/dist/components/feedback/ChatMessage/ChatMessage.theme.js +16 -0
- package/dist/components/feedback/Empty/Empty.js +26 -0
- package/dist/components/feedback/Empty/Empty.theme.js +13 -0
- package/dist/components/feedback/Notification/Notification.js +41 -0
- package/dist/components/feedback/Notification/Notification.theme.js +49 -0
- package/dist/components/feedback/Spinner/Spinner.theme.js +3 -3
- package/dist/components/feedback/Toast/Toast.animations.js +58 -0
- package/dist/components/feedback/Toast/Toast.js +67 -0
- package/dist/components/feedback/Toast/Toast.theme.js +18 -0
- package/dist/components/feedback/Toast/ToastProvider.js +73 -0
- package/dist/components/feedback/Toast/useToast.js +91 -0
- package/dist/components/forms/Checkbox/Checkbox.theme.js +1 -1
- package/dist/components/forms/FormLabel/FormLabel.theme.js +2 -2
- package/dist/components/forms/Input/Input.theme.js +4 -4
- package/dist/components/forms/Radio/Radio.theme.js +2 -2
- package/dist/components/forms/Select/Select.js +1 -1
- package/dist/components/forms/Select/Select.theme.js +5 -5
- package/dist/components/forms/Switch/Switch.theme.js +1 -1
- package/dist/components/forms/TimePicker/TimePicker.theme.js +19 -19
- package/dist/components/forms/forms.theme.js +8 -8
- package/dist/components/navigation/NavItem/NavItem.js +93 -0
- package/dist/components/navigation/NavItem/NavItem.theme.js +27 -0
- package/dist/components/navigation/Sidebar/Sidebar.js +28 -0
- package/dist/components/navigation/Sidebar/Sidebar.theme.js +16 -0
- package/dist/components/navigation/Sidebar/SidebarContent.js +12 -0
- package/dist/components/navigation/Sidebar/SidebarContext.js +38 -0
- package/dist/components/navigation/Sidebar/SidebarFooter.js +11 -0
- package/dist/components/navigation/Sidebar/SidebarHeader.js +22 -0
- package/dist/components/navigation/Sidebar/SidebarNav.js +11 -0
- package/dist/components/navigation/Sidebar/SidebarNavGroup.js +19 -0
- package/dist/components/navigation/Sidebar/SidebarToggle.js +26 -0
- package/dist/icons/core/TickIcon.js +3 -1
- package/dist/index.d.ts +29 -4
- package/dist/index.js +64 -4
- package/dist/node_modules/@heroicons/react/20/solid/esm/ChevronDownIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/ChevronDoubleLeftIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/ChevronDoubleRightIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/ChevronLeftIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/Cog6ToothIcon.js +32 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/DocumentIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/EllipsisVerticalIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/outline/esm/PlusIcon.js +28 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/ArrowPathIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/BellIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/CheckCircleIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/ExclamationTriangleIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/InformationCircleIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/XCircleIcon.js +26 -0
- package/dist/node_modules/@heroicons/react/24/solid/esm/XMarkIcon.js +26 -0
- package/dist/node_modules/tslib/tslib.es6.js +15 -1
- package/dist/utils/dateUtils.js +32 -0
- package/dist/utils/debounce.js +21 -0
- package/package.json +3 -4
- package/dist/styles.css +0 -2
package/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Flikkui
|
|
2
|
+
|
|
3
|
+
A modern React component library built with TypeScript, Tailwind CSS v4, and optional Framer Motion animations. Follows the shadcn philosophy where users can override any styling using className props while getting sensible defaults out of the box.
|
|
4
|
+
|
|
5
|
+
## 🚀 Quick Start
|
|
6
|
+
|
|
7
|
+
### 1. Install the package
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install flikkui@beta motion
|
|
11
|
+
# or
|
|
12
|
+
yarn add flikkui@beta motion
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### 2. Download the theme file
|
|
16
|
+
|
|
17
|
+
Download the theme file from [flikkui.dev/theme](https://flikkui.dev/theme) and save it as `flikkui-theme.css` in your project root.
|
|
18
|
+
|
|
19
|
+
Alternatively, you can copy this file: [flikkui-theme.css](./flikkui-theme.css)
|
|
20
|
+
|
|
21
|
+
### 3. Import the theme in your app
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
// In your main App.tsx, index.tsx, or _app.tsx
|
|
25
|
+
import './flikkui-theme.css' // Import the downloaded theme file
|
|
26
|
+
import App from './App'
|
|
27
|
+
|
|
28
|
+
// Your app code...
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### 4. Start using components
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { Button } from 'flikkui'
|
|
35
|
+
|
|
36
|
+
export function MyComponent() {
|
|
37
|
+
return (
|
|
38
|
+
<Button variant="primary">
|
|
39
|
+
Hello World
|
|
40
|
+
</Button>
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 🎨 Customization
|
|
46
|
+
|
|
47
|
+
Edit the `flikkui-theme.css` file to customize your design system:
|
|
48
|
+
|
|
49
|
+
```css
|
|
50
|
+
/* flikkui-theme.css */
|
|
51
|
+
@theme {
|
|
52
|
+
/* Change primary color */
|
|
53
|
+
--color-primary-base: oklch(0.666 0.223 48.717); /* Orange */
|
|
54
|
+
--color-primary-600: oklch(0.666 0.223 48.717);
|
|
55
|
+
--color-primary-700: oklch(0.555 0.192 47.355);
|
|
56
|
+
|
|
57
|
+
/* Larger buttons */
|
|
58
|
+
--button-min-h-md: 3rem;
|
|
59
|
+
--button-px-md: 1.25rem;
|
|
60
|
+
|
|
61
|
+
/* More rounded design */
|
|
62
|
+
--form-rounded: 1rem;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
You can also override styles using className props (shadcn approach):
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
<Button className="bg-purple-600 hover:bg-purple-700 rounded-full">
|
|
70
|
+
Custom Button
|
|
71
|
+
</Button>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 📚 Components
|
|
75
|
+
|
|
76
|
+
### Core Components
|
|
77
|
+
- **Button** - Multiple variants, states, optional animations
|
|
78
|
+
- **Avatar** - Image handling, fallbacks, status indicators
|
|
79
|
+
- **AvatarGroup** - Overlapping avatars with compound component pattern
|
|
80
|
+
- **Badge** - Variants, sizes, content flexibility
|
|
81
|
+
- **Accordion** - Compound component with animations
|
|
82
|
+
- **Modal** - Compound component with header, body, footer
|
|
83
|
+
- **Drawer** - Slide-out panels from edges
|
|
84
|
+
- **Popover** - Compound with portal rendering
|
|
85
|
+
- **Tooltip** - Positioning, animations, accessibility
|
|
86
|
+
- **Tabs** - Horizontal tabbed interface
|
|
87
|
+
|
|
88
|
+
### Form Components
|
|
89
|
+
- **Input** - Multiple types, masking, validation
|
|
90
|
+
- **Select** - Searchable, compound pattern
|
|
91
|
+
- **Checkbox** - Custom styling, controlled/uncontrolled
|
|
92
|
+
- **Radio** - Group management
|
|
93
|
+
- **Switch** - Toggle functionality
|
|
94
|
+
- **Textarea** - Resizable, validation
|
|
95
|
+
|
|
96
|
+
### Data Display
|
|
97
|
+
- **Table** - Dual API, sorting, filtering, selection
|
|
98
|
+
- **Spinner** - Loading states, sizes
|
|
99
|
+
|
|
100
|
+
### Charts
|
|
101
|
+
- **AreaChart** - Stacked, curved, null value handling
|
|
102
|
+
- **BarChart** - Horizontal/vertical, grouped, stacked
|
|
103
|
+
- **LineChart** - Multiple series, curved lines
|
|
104
|
+
- **DonutChart** - Progress, animations, gradients
|
|
105
|
+
- **Heatmap** - Interactive, customizable intensity
|
|
106
|
+
|
|
107
|
+
## 🔄 Migration from v0.1.0-beta.3
|
|
108
|
+
|
|
109
|
+
If you were using the previous version, update your imports:
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
// Old (v0.1.0-beta.3)
|
|
113
|
+
import 'flikkui/styles.css'
|
|
114
|
+
|
|
115
|
+
// New (v0.1.0-beta.4+)
|
|
116
|
+
import './flikkui-theme.css' // Download this file first
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This change gives you:
|
|
120
|
+
- ✅ 100% predictable styling
|
|
121
|
+
- ✅ Full control over your design system
|
|
122
|
+
- ✅ No more CSS cascade conflicts
|
|
123
|
+
- ✅ Easy theme customization
|
|
124
|
+
|
|
125
|
+
## 💡 Philosophy
|
|
126
|
+
|
|
127
|
+
Flikkui follows the **shadcn approach**:
|
|
128
|
+
- Components provide sensible defaults
|
|
129
|
+
- **className overrides always take precedence**
|
|
130
|
+
- Full TypeScript support with excellent DX
|
|
131
|
+
- Copy-paste friendly - customize anything
|
|
132
|
+
- CSS variables for consistent theming
|
|
133
|
+
|
|
134
|
+
## 🛠️ Tech Stack
|
|
135
|
+
|
|
136
|
+
- **React 18** with TypeScript (strict mode)
|
|
137
|
+
- **Tailwind CSS v4** with CSS variables
|
|
138
|
+
- **Framer Motion** (optional, for enhanced components)
|
|
139
|
+
- **Accessibility-first** - WCAG 2.1 AA compliance built-in
|
|
140
|
+
|
|
141
|
+
## 📖 Documentation
|
|
142
|
+
|
|
143
|
+
Visit [flikkui.dev](https://flikkui.dev) for:
|
|
144
|
+
- Component API documentation
|
|
145
|
+
- Interactive examples
|
|
146
|
+
- Theme customization guide
|
|
147
|
+
- Migration guides
|
|
148
|
+
|
|
149
|
+
## 📄 License
|
|
150
|
+
|
|
151
|
+
MIT
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
Made with ❤️ by [Espranza Innovations](https://espranza.net)
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import { __rest, __assign, __spreadArray } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import React__default, { useRef, useState, useEffect } from 'react';
|
|
3
|
+
import { cn } from '../../../utils/cn.js';
|
|
4
|
+
import { useChartTheme } from '../hooks/useChartTheme.js';
|
|
5
|
+
import { useTooltipPosition } from '../hooks/useTooltipPosition.js';
|
|
6
|
+
import { useChartAccessibility } from '../hooks/useChartAccessibility.js';
|
|
7
|
+
import { XAxis } from '../shared/ChartAxis/XAxis.js';
|
|
8
|
+
import { YAxis } from '../shared/ChartAxis/YAxis.js';
|
|
9
|
+
import { HorizontalGrid } from '../shared/ChartGrid/HorizontalGrid.js';
|
|
10
|
+
import { ChartTooltip } from '../shared/ChartTooltip/ChartTooltip.js';
|
|
11
|
+
import { ChartMarker } from '../shared/ChartMarker/ChartMarker.js';
|
|
12
|
+
import { ChartCrosshair } from '../shared/ChartCrosshair/ChartCrosshair.js';
|
|
13
|
+
import { getColorValue } from '../utils/color-utils.js';
|
|
14
|
+
import { AREA_CHART_DEFAULTS } from './AreaChart.types.js';
|
|
15
|
+
|
|
16
|
+
// Color configuration for data series
|
|
17
|
+
var getSeriesColorClass = function (index) {
|
|
18
|
+
var colors = [
|
|
19
|
+
"stroke-primary-base fill-primary-base",
|
|
20
|
+
"stroke-warning-base fill-warning-base",
|
|
21
|
+
"stroke-success-base fill-success-base",
|
|
22
|
+
"stroke-error-base fill-error-base",
|
|
23
|
+
];
|
|
24
|
+
return colors[index % colors.length];
|
|
25
|
+
};
|
|
26
|
+
// Get fill color for gradients - now using comprehensive color mapping
|
|
27
|
+
var getSeriesFillColor = function (index) {
|
|
28
|
+
var colorClasses = [
|
|
29
|
+
"fill-primary-base",
|
|
30
|
+
"fill-warning-base",
|
|
31
|
+
"fill-success-base",
|
|
32
|
+
"fill-error-base",
|
|
33
|
+
];
|
|
34
|
+
var colorClass = colorClasses[index % colorClasses.length];
|
|
35
|
+
return getColorValue(colorClass);
|
|
36
|
+
};
|
|
37
|
+
// Simplified curve generation
|
|
38
|
+
var generateMonotonePath = function (points) {
|
|
39
|
+
if (points.length === 0)
|
|
40
|
+
return "";
|
|
41
|
+
if (points.length === 1)
|
|
42
|
+
return "M ".concat(points[0].x, " ").concat(points[0].y);
|
|
43
|
+
var path = "M ".concat(points[0].x, " ").concat(points[0].y);
|
|
44
|
+
for (var i = 1; i < points.length; i++) {
|
|
45
|
+
var prev = points[i - 1];
|
|
46
|
+
var curr = points[i];
|
|
47
|
+
// Calculate control points for smooth curve
|
|
48
|
+
var dx = curr.x - prev.x;
|
|
49
|
+
var controlDistance = dx * 0.3;
|
|
50
|
+
var cp1x = prev.x + controlDistance;
|
|
51
|
+
var cp1y = prev.y;
|
|
52
|
+
var cp2x = curr.x - controlDistance;
|
|
53
|
+
var cp2y = curr.y;
|
|
54
|
+
path += " C ".concat(cp1x, " ").concat(cp1y, ", ").concat(cp2x, " ").concat(cp2y, ", ").concat(curr.x, " ").concat(curr.y);
|
|
55
|
+
}
|
|
56
|
+
return path;
|
|
57
|
+
};
|
|
58
|
+
var generateLinearPath = function (points) {
|
|
59
|
+
if (points.length === 0)
|
|
60
|
+
return "";
|
|
61
|
+
var path = "M ".concat(points[0].x, " ").concat(points[0].y);
|
|
62
|
+
for (var i = 1; i < points.length; i++) {
|
|
63
|
+
path += " L ".concat(points[i].x, " ").concat(points[i].y);
|
|
64
|
+
}
|
|
65
|
+
return path;
|
|
66
|
+
};
|
|
67
|
+
// Simple curve implementation
|
|
68
|
+
var generateCurvePath = function (points, curveType) {
|
|
69
|
+
if (curveType === void 0) { curveType = "monotone"; }
|
|
70
|
+
if (points.length === 0)
|
|
71
|
+
return "";
|
|
72
|
+
if (points.length === 1)
|
|
73
|
+
return "M ".concat(points[0].x, " ").concat(points[0].y);
|
|
74
|
+
switch (curveType) {
|
|
75
|
+
case "monotone":
|
|
76
|
+
return generateMonotonePath(points);
|
|
77
|
+
case "linear":
|
|
78
|
+
default:
|
|
79
|
+
return generateLinearPath(points);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var AreaChart = function (_a) {
|
|
83
|
+
var data = _a.data, config = _a.config,
|
|
84
|
+
// Standardized display props with defaults
|
|
85
|
+
_b = _a.showGrid,
|
|
86
|
+
// Standardized display props with defaults
|
|
87
|
+
showGrid = _b === void 0 ? AREA_CHART_DEFAULTS.showGrid : _b, _c = _a.showXAxis, showXAxis = _c === void 0 ? AREA_CHART_DEFAULTS.showXAxis : _c, _d = _a.showYAxis, showYAxis = _d === void 0 ? AREA_CHART_DEFAULTS.showYAxis : _d, _e = _a.showNullValues, showNullValues = _e === void 0 ? AREA_CHART_DEFAULTS.showNullValues : _e, // NEW!
|
|
88
|
+
propMinValue = _a.minValue, propMaxValue = _a.maxValue, _f = _a.variant, variant = _f === void 0 ? AREA_CHART_DEFAULTS.variant : _f, theme = _a.theme,
|
|
89
|
+
// Standardized visual props with defaults (renamed from area-specific names)
|
|
90
|
+
_g = _a.radius,
|
|
91
|
+
// Standardized visual props with defaults (renamed from area-specific names)
|
|
92
|
+
radius = _g === void 0 ? AREA_CHART_DEFAULTS.radius : _g, // Was dotRadius
|
|
93
|
+
_h = _a.strokeWidth, // Was dotRadius
|
|
94
|
+
strokeWidth = _h === void 0 ? AREA_CHART_DEFAULTS.strokeWidth : _h, _j = _a.curved, curved = _j === void 0 ? AREA_CHART_DEFAULTS.curved : _j, _k = _a.curveType, curveType = _k === void 0 ? AREA_CHART_DEFAULTS.curveType : _k, _l = _a.showDots, showDots = _l === void 0 ? AREA_CHART_DEFAULTS.showDots : _l, _m = _a.fillOpacity, fillOpacity = _m === void 0 ? AREA_CHART_DEFAULTS.fillOpacity : _m, _o = _a.showStroke, showStroke = _o === void 0 ? AREA_CHART_DEFAULTS.showStroke : _o, _p = _a.stacked, stacked = _p === void 0 ? AREA_CHART_DEFAULTS.stacked : _p,
|
|
95
|
+
// Base props
|
|
96
|
+
className = _a.className, title = _a.title, description = _a.description, _q = _a.enableKeyboardNavigation, enableKeyboardNavigation = _q === void 0 ? AREA_CHART_DEFAULTS.enableKeyboardNavigation : _q, children = _a.children, props = __rest(_a, ["data", "config", "showGrid", "showXAxis", "showYAxis", "showNullValues", "minValue", "maxValue", "variant", "theme", "radius", "strokeWidth", "curved", "curveType", "showDots", "fillOpacity", "showStroke", "stacked", "className", "title", "description", "enableKeyboardNavigation", "children"]);
|
|
97
|
+
// Use the new theme system
|
|
98
|
+
var _r = useChartTheme({ config: config, variant: variant, theme: theme }); _r.getSeriesColor; _r.getColorClass; _r.getOpacityClass; _r.getTransitionClass;
|
|
99
|
+
// Legacy support
|
|
100
|
+
_r.getThemeValue;
|
|
101
|
+
var containerRef = useRef(null);
|
|
102
|
+
var _s = useState({ width: 600, height: 400 }), dimensions = _s[0], setDimensions = _s[1];
|
|
103
|
+
var _t = useState(null), hoveredPoint = _t[0], setHoveredPoint = _t[1];
|
|
104
|
+
// Detect if device is mobile/touch
|
|
105
|
+
var isMobile = typeof window !== 'undefined' &&
|
|
106
|
+
('ontouchstart' in window || navigator.maxTouchPoints > 0);
|
|
107
|
+
// Use the new tooltip positioning hook
|
|
108
|
+
var _u = useTooltipPosition({
|
|
109
|
+
containerRef: containerRef,
|
|
110
|
+
isMobile: isMobile,
|
|
111
|
+
}), tooltipData = _u.tooltipData, tooltipRef = _u.tooltipRef, handleMouseEnter = _u.handleMouseEnter, handleMouseMove = _u.handleMouseMove, handleMouseLeave = _u.handleMouseLeave;
|
|
112
|
+
// Use accessibility hook
|
|
113
|
+
var _v = useChartAccessibility({
|
|
114
|
+
chartType: 'area',
|
|
115
|
+
data: data,
|
|
116
|
+
config: config,
|
|
117
|
+
title: title,
|
|
118
|
+
description: description,
|
|
119
|
+
enableKeyboardNavigation: enableKeyboardNavigation,
|
|
120
|
+
}), chartAccessibilityProps = _v.chartAccessibilityProps, descriptionProps = _v.descriptionProps; _v.focusedElementIndex; _v.isKeyboardMode; var handleMouseInteraction = _v.handleMouseInteraction;
|
|
121
|
+
// Measure container dimensions
|
|
122
|
+
useEffect(function () {
|
|
123
|
+
var updateDimensions = function () {
|
|
124
|
+
if (containerRef.current) {
|
|
125
|
+
var _a = containerRef.current.getBoundingClientRect(), width = _a.width, height = _a.height;
|
|
126
|
+
setDimensions({
|
|
127
|
+
width: width || 600,
|
|
128
|
+
height: height || 400,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
updateDimensions();
|
|
133
|
+
var resizeObserver = new ResizeObserver(updateDimensions);
|
|
134
|
+
if (containerRef.current) {
|
|
135
|
+
resizeObserver.observe(containerRef.current);
|
|
136
|
+
}
|
|
137
|
+
return function () {
|
|
138
|
+
resizeObserver.disconnect();
|
|
139
|
+
};
|
|
140
|
+
}, []);
|
|
141
|
+
// Early return if no data
|
|
142
|
+
if (!data || data.length === 0) {
|
|
143
|
+
return (React__default.createElement("div", __assign({ className: cn("chart-container flex items-center justify-center text-neutral-500", className), role: "img", "aria-label": "Empty area chart" }, props),
|
|
144
|
+
React__default.createElement("span", null, "No data available")));
|
|
145
|
+
}
|
|
146
|
+
// Calculate dimensions
|
|
147
|
+
var margin = {
|
|
148
|
+
top: 0,
|
|
149
|
+
right: 0,
|
|
150
|
+
bottom: showXAxis ? 40 : 0,
|
|
151
|
+
left: showYAxis ? 60 : 0,
|
|
152
|
+
};
|
|
153
|
+
var innerWidth = dimensions.width - margin.left - margin.right;
|
|
154
|
+
var innerHeight = dimensions.height - margin.top - margin.bottom;
|
|
155
|
+
// Get all data keys from config
|
|
156
|
+
var dataKeys = Object.keys(config);
|
|
157
|
+
// Calculate scales
|
|
158
|
+
var rawMaxValue = Math.max.apply(Math, data.map(function (item) {
|
|
159
|
+
return stacked
|
|
160
|
+
? dataKeys.reduce(function (sum, key) {
|
|
161
|
+
var value = item[key];
|
|
162
|
+
return sum + (typeof value === "number" ? value : 0);
|
|
163
|
+
}, 0)
|
|
164
|
+
: Math.max.apply(Math, dataKeys.map(function (key) {
|
|
165
|
+
var value = item[key];
|
|
166
|
+
return typeof value === "number" ? value : 0;
|
|
167
|
+
}));
|
|
168
|
+
}));
|
|
169
|
+
var minValue = propMinValue !== null && propMinValue !== void 0 ? propMinValue : 0;
|
|
170
|
+
var maxValue = propMaxValue !== null && propMaxValue !== void 0 ? propMaxValue : (function () {
|
|
171
|
+
if (rawMaxValue <= 10)
|
|
172
|
+
return Math.ceil(rawMaxValue);
|
|
173
|
+
if (rawMaxValue <= 100)
|
|
174
|
+
return Math.ceil(rawMaxValue / 5) * 5;
|
|
175
|
+
if (rawMaxValue <= 1000)
|
|
176
|
+
return Math.ceil(rawMaxValue / 50) * 50;
|
|
177
|
+
if (rawMaxValue <= 10000)
|
|
178
|
+
return Math.ceil(rawMaxValue / 500) * 500;
|
|
179
|
+
return Math.ceil(rawMaxValue / 1000) * 1000;
|
|
180
|
+
})();
|
|
181
|
+
// Calculate point position
|
|
182
|
+
var getPointPosition = function (dataIndex, value) {
|
|
183
|
+
// Spread points evenly across the full width
|
|
184
|
+
// First point at left edge (margin.left), last point at right edge (margin.left + innerWidth)
|
|
185
|
+
var x = data.length === 1
|
|
186
|
+
? margin.left + innerWidth / 2 // Center single point
|
|
187
|
+
: margin.left + (dataIndex / (data.length - 1)) * innerWidth;
|
|
188
|
+
var y = margin.top +
|
|
189
|
+
innerHeight -
|
|
190
|
+
((value - minValue) / (maxValue - minValue)) * innerHeight;
|
|
191
|
+
return { x: x, y: y };
|
|
192
|
+
};
|
|
193
|
+
// Generate area path with null value handling
|
|
194
|
+
var generateAreaPath = function (key, stackedValues) {
|
|
195
|
+
if (!showNullValues) {
|
|
196
|
+
// Original behavior: skip null values entirely
|
|
197
|
+
var points_1 = [];
|
|
198
|
+
var baselinePoints_1 = [];
|
|
199
|
+
data.forEach(function (item, index) {
|
|
200
|
+
var rawValue = item[key];
|
|
201
|
+
var isNull = rawValue === null || rawValue === undefined;
|
|
202
|
+
var value = isNull ? 0 : typeof rawValue === "number" ? rawValue : 0;
|
|
203
|
+
if (!isNull) {
|
|
204
|
+
var baselineValue = stacked && stackedValues ? stackedValues[index] : minValue;
|
|
205
|
+
var topValue = stacked && stackedValues ? stackedValues[index] + value : value;
|
|
206
|
+
var topPoint = getPointPosition(index, topValue);
|
|
207
|
+
var baselinePoint = getPointPosition(index, baselineValue);
|
|
208
|
+
points_1.push(topPoint);
|
|
209
|
+
baselinePoints_1.push(baselinePoint);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
if (points_1.length === 0)
|
|
213
|
+
return null;
|
|
214
|
+
// Generate the top curve
|
|
215
|
+
var topPath = generateCurvePath(points_1, curved ? curveType : "linear");
|
|
216
|
+
// Generate the baseline (reverse order for proper area closure)
|
|
217
|
+
var reversedBaselinePoints = __spreadArray([], baselinePoints_1, true).reverse();
|
|
218
|
+
var baselinePath = generateCurvePath(reversedBaselinePoints, curved ? curveType : "linear");
|
|
219
|
+
// Create closed area path
|
|
220
|
+
var areaPath = "".concat(topPath, " L ").concat(baselinePoints_1[baselinePoints_1.length - 1].x, " ").concat(baselinePoints_1[baselinePoints_1.length - 1].y, " ").concat(baselinePath.replace('M', 'L'), " Z");
|
|
221
|
+
return {
|
|
222
|
+
areaPath: areaPath,
|
|
223
|
+
linePath: topPath
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// New behavior: break areas at null values
|
|
228
|
+
var segments_1 = [];
|
|
229
|
+
var currentSegment_1 = { points: [], baselinePoints: [] };
|
|
230
|
+
data.forEach(function (item, index) {
|
|
231
|
+
var rawValue = item[key];
|
|
232
|
+
var isNull = rawValue === null || rawValue === undefined;
|
|
233
|
+
if (isNull) {
|
|
234
|
+
// End current segment and start a new one
|
|
235
|
+
if (currentSegment_1.points.length > 0) {
|
|
236
|
+
segments_1.push(currentSegment_1);
|
|
237
|
+
currentSegment_1 = { points: [], baselinePoints: [] };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
var value = typeof rawValue === "number" ? rawValue : 0;
|
|
242
|
+
var baselineValue = stacked && stackedValues ? stackedValues[index] : minValue;
|
|
243
|
+
var topValue = stacked && stackedValues ? stackedValues[index] + value : value;
|
|
244
|
+
var topPoint = getPointPosition(index, topValue);
|
|
245
|
+
var baselinePoint = getPointPosition(index, baselineValue);
|
|
246
|
+
currentSegment_1.points.push(topPoint);
|
|
247
|
+
currentSegment_1.baselinePoints.push(baselinePoint);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
// Add the last segment if it has points
|
|
251
|
+
if (currentSegment_1.points.length > 0) {
|
|
252
|
+
segments_1.push(currentSegment_1);
|
|
253
|
+
}
|
|
254
|
+
if (segments_1.length === 0)
|
|
255
|
+
return null;
|
|
256
|
+
// Generate paths for each segment
|
|
257
|
+
var areaPaths_1 = [];
|
|
258
|
+
var linePaths_1 = [];
|
|
259
|
+
segments_1.forEach(function (segment) {
|
|
260
|
+
if (segment.points.length > 0) {
|
|
261
|
+
// Generate the top curve
|
|
262
|
+
var topPath = generateCurvePath(segment.points, curved ? curveType : "linear");
|
|
263
|
+
// Generate the baseline (reverse order for proper area closure)
|
|
264
|
+
var reversedBaselinePoints = __spreadArray([], segment.baselinePoints, true).reverse();
|
|
265
|
+
var baselinePath = generateCurvePath(reversedBaselinePoints, curved ? curveType : "linear");
|
|
266
|
+
// Create closed area path
|
|
267
|
+
var areaPath = "".concat(topPath, " L ").concat(segment.baselinePoints[segment.baselinePoints.length - 1].x, " ").concat(segment.baselinePoints[segment.baselinePoints.length - 1].y, " ").concat(baselinePath.replace('M', 'L'), " Z");
|
|
268
|
+
areaPaths_1.push(areaPath);
|
|
269
|
+
linePaths_1.push(topPath);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
return {
|
|
273
|
+
areaPath: areaPaths_1.join(" "),
|
|
274
|
+
linePath: linePaths_1.join(" ")
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
// Calculate stacked values for each data point
|
|
279
|
+
var getStackedValues = function () {
|
|
280
|
+
if (!stacked)
|
|
281
|
+
return {};
|
|
282
|
+
var stackedData = {};
|
|
283
|
+
var cumulativeValues = new Array(data.length).fill(0);
|
|
284
|
+
dataKeys.forEach(function (key) {
|
|
285
|
+
stackedData[key] = __spreadArray([], cumulativeValues, true);
|
|
286
|
+
data.forEach(function (item, index) {
|
|
287
|
+
var rawValue = item[key];
|
|
288
|
+
var value = typeof rawValue === "number" ? rawValue : 0;
|
|
289
|
+
cumulativeValues[index] += value;
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
return stackedData;
|
|
293
|
+
};
|
|
294
|
+
var stackedValues = getStackedValues();
|
|
295
|
+
return (React__default.createElement("div", __assign({ ref: containerRef, className: cn("chart-container w-full h-full", className) }, chartAccessibilityProps, { onMouseEnter: handleMouseInteraction, onMouseMove: handleMouseInteraction }, props),
|
|
296
|
+
descriptionProps && React__default.createElement("div", __assign({}, descriptionProps)),
|
|
297
|
+
React__default.createElement("svg", { width: "100%", height: "100%", viewBox: "0 0 ".concat(dimensions.width, " ").concat(dimensions.height), className: "overflow-visible", role: "presentation" },
|
|
298
|
+
React__default.createElement("defs", null,
|
|
299
|
+
React__default.createElement("filter", { id: "area-shadow", x: "-20%", y: "-20%", width: "140%", height: "140%" },
|
|
300
|
+
React__default.createElement("feDropShadow", { dx: "4", dy: "4", stdDeviation: "6", floodOpacity: "0.1", floodColor: "#000000" })),
|
|
301
|
+
dataKeys.map(function (key, keyIndex) {
|
|
302
|
+
var fillColor = getSeriesFillColor(keyIndex);
|
|
303
|
+
return (React__default.createElement("linearGradient", { key: "gradient-".concat(key), id: "area-gradient-".concat(key), x1: "0%", y1: "0%", x2: "0%", y2: "100%" },
|
|
304
|
+
React__default.createElement("stop", { offset: "0%", stopColor: fillColor, stopOpacity: fillOpacity * 0.8 }),
|
|
305
|
+
React__default.createElement("stop", { offset: "100%", stopColor: fillColor, stopOpacity: fillOpacity * 0.05 })));
|
|
306
|
+
}),
|
|
307
|
+
React__default.createElement("linearGradient", { id: "vertical-fade", x1: "0%", y1: "0%", x2: "0%", y2: "100%" },
|
|
308
|
+
React__default.createElement("stop", { offset: "0%", stopColor: "#6b7280", stopOpacity: "0" }),
|
|
309
|
+
React__default.createElement("stop", { offset: "40%", stopColor: "#6b7280", stopOpacity: "0.3" }),
|
|
310
|
+
React__default.createElement("stop", { offset: "50%", stopColor: "#6b7280", stopOpacity: "0.5" }),
|
|
311
|
+
React__default.createElement("stop", { offset: "60%", stopColor: "#6b7280", stopOpacity: "0.3" }),
|
|
312
|
+
React__default.createElement("stop", { offset: "100%", stopColor: "#6b7280", stopOpacity: "0" })),
|
|
313
|
+
React__default.createElement("linearGradient", { id: "horizontal-fade", x1: "0%", y1: "0%", x2: "100%", y2: "0%" },
|
|
314
|
+
React__default.createElement("stop", { offset: "0%", stopColor: "#6b7280", stopOpacity: "0" }),
|
|
315
|
+
React__default.createElement("stop", { offset: "40%", stopColor: "#6b7280", stopOpacity: "0.3" }),
|
|
316
|
+
React__default.createElement("stop", { offset: "50%", stopColor: "#6b7280", stopOpacity: "0.5" }),
|
|
317
|
+
React__default.createElement("stop", { offset: "60%", stopColor: "#6b7280", stopOpacity: "0.3" }),
|
|
318
|
+
React__default.createElement("stop", { offset: "100%", stopColor: "#6b7280", stopOpacity: "0" }))),
|
|
319
|
+
React__default.createElement(HorizontalGrid, { show: showGrid, x: margin.left, y: margin.top, width: innerWidth, height: innerHeight, lineCount: 5 }),
|
|
320
|
+
React__default.createElement(ChartCrosshair, { show: hoveredPoint !== null, x: hoveredPoint !== null ? (data.length === 1
|
|
321
|
+
? margin.left + innerWidth / 2
|
|
322
|
+
: margin.left + (hoveredPoint.index / (data.length - 1)) * innerWidth) : 0, y: hoveredPoint !== null && dataKeys.length === 1 ? (function () {
|
|
323
|
+
var item = data[hoveredPoint.index];
|
|
324
|
+
var singleKey = dataKeys[0];
|
|
325
|
+
var singleValue = item[singleKey];
|
|
326
|
+
var numValue = typeof singleValue === 'number' ? singleValue : 0;
|
|
327
|
+
return margin.top + innerHeight - ((numValue - minValue) / (maxValue - minValue)) * innerHeight;
|
|
328
|
+
})() : undefined, margin: margin, innerWidth: innerWidth, innerHeight: innerHeight, showHorizontal: dataKeys.length === 1 }),
|
|
329
|
+
React__default.createElement(YAxis, { show: showYAxis, min: minValue, max: maxValue, x: margin.left, y: margin.top, height: innerHeight, showGrid: false, gridWidth: innerWidth, tickFormatter: function (value) {
|
|
330
|
+
if (value >= 1000)
|
|
331
|
+
return "".concat((value / 1000).toFixed(0), "k");
|
|
332
|
+
return value.toString();
|
|
333
|
+
} }),
|
|
334
|
+
React__default.createElement("g", { className: "chart-areas" }, dataKeys.map(function (key, keyIndex) {
|
|
335
|
+
var paths = generateAreaPath(key, stackedValues[key]);
|
|
336
|
+
var colorClass = getSeriesColorClass(keyIndex);
|
|
337
|
+
if (!paths)
|
|
338
|
+
return null;
|
|
339
|
+
return (React__default.createElement("g", { key: key },
|
|
340
|
+
React__default.createElement("path", { d: paths.areaPath, fill: "url(#area-gradient-".concat(key, ")"), className: "transition-all duration-200", filter: "url(#area-shadow)" }),
|
|
341
|
+
showStroke && (React__default.createElement("path", { d: paths.linePath, fill: "none", strokeWidth: strokeWidth, strokeLinecap: "round", className: cn("transition-all duration-200", colorClass.split(' ').find(function (cls) { return cls.startsWith('stroke-'); }) || '') })),
|
|
342
|
+
showDots &&
|
|
343
|
+
data.map(function (item, dataIndex) {
|
|
344
|
+
var rawValue = item[key];
|
|
345
|
+
var isNull = rawValue === null || rawValue === undefined;
|
|
346
|
+
var value = isNull
|
|
347
|
+
? 0
|
|
348
|
+
: typeof rawValue === "number"
|
|
349
|
+
? rawValue
|
|
350
|
+
: 0;
|
|
351
|
+
// Don't render dots for null values regardless of showNullValues
|
|
352
|
+
if (isNull)
|
|
353
|
+
return null;
|
|
354
|
+
stacked && stackedValues[key] ? stackedValues[key][dataIndex] : minValue;
|
|
355
|
+
var topValue = stacked && stackedValues[key] ? stackedValues[key][dataIndex] + value : value;
|
|
356
|
+
var _a = getPointPosition(dataIndex, topValue), x = _a.x, y = _a.y;
|
|
357
|
+
(hoveredPoint === null || hoveredPoint === void 0 ? void 0 : hoveredPoint.index) === dataIndex && hoveredPoint.key === key;
|
|
358
|
+
return (React__default.createElement("g", { key: "".concat(key, "-").concat(dataIndex) },
|
|
359
|
+
React__default.createElement(ChartMarker, { cx: x, cy: y, radius: radius, colorClass: colorClass })));
|
|
360
|
+
})));
|
|
361
|
+
})),
|
|
362
|
+
!showDots && hoveredPoint !== null && (React__default.createElement("g", { className: "chart-hover-markers" }, dataKeys.map(function (key, keyIndex) {
|
|
363
|
+
var item = data[hoveredPoint.index];
|
|
364
|
+
var rawValue = item[key];
|
|
365
|
+
var isNull = rawValue === null || rawValue === undefined;
|
|
366
|
+
var value = isNull
|
|
367
|
+
? 0
|
|
368
|
+
: typeof rawValue === "number"
|
|
369
|
+
? rawValue
|
|
370
|
+
: 0;
|
|
371
|
+
// Don't render hover markers for null values
|
|
372
|
+
if (isNull)
|
|
373
|
+
return null;
|
|
374
|
+
stacked && stackedValues[key] ? stackedValues[key][hoveredPoint.index] : minValue;
|
|
375
|
+
var topValue = stacked && stackedValues[key] ? stackedValues[key][hoveredPoint.index] + value : value;
|
|
376
|
+
var _a = getPointPosition(hoveredPoint.index, topValue), x = _a.x, y = _a.y;
|
|
377
|
+
var colorClass = getSeriesColorClass(keyIndex);
|
|
378
|
+
return (React__default.createElement(ChartMarker, { key: "hover-".concat(key, "-").concat(hoveredPoint.index), cx: x, cy: y, radius: radius, colorClass: colorClass }));
|
|
379
|
+
}))),
|
|
380
|
+
React__default.createElement("g", { className: "chart-hover-areas" }, data.map(function (item, dataIndex) {
|
|
381
|
+
// Calculate hover area based on new point positioning
|
|
382
|
+
var pointX = data.length === 1
|
|
383
|
+
? margin.left + innerWidth / 2
|
|
384
|
+
: margin.left + (dataIndex / (data.length - 1)) * innerWidth;
|
|
385
|
+
// Create hover area around each point
|
|
386
|
+
var hoverWidth = data.length === 1 ? innerWidth : innerWidth / (data.length - 1);
|
|
387
|
+
var hoverX = data.length === 1
|
|
388
|
+
? margin.left
|
|
389
|
+
: Math.max(margin.left, pointX - hoverWidth / 2);
|
|
390
|
+
// Ensure hover area doesn't exceed chart bounds
|
|
391
|
+
var adjustedWidth = data.length === 1
|
|
392
|
+
? innerWidth
|
|
393
|
+
: Math.min(hoverWidth, margin.left + innerWidth - hoverX);
|
|
394
|
+
return (React__default.createElement("rect", { key: "hover-".concat(dataIndex), x: hoverX, y: margin.top, width: adjustedWidth, height: innerHeight, fill: "transparent", className: "cursor-pointer", onMouseEnter: function (e) {
|
|
395
|
+
setHoveredPoint({ index: dataIndex, key: dataKeys[0] });
|
|
396
|
+
// Create multi-series tooltip data
|
|
397
|
+
var seriesData = dataKeys.map(function (seriesKey, keyIndex) {
|
|
398
|
+
var _a, _b;
|
|
399
|
+
var seriesValue = item[seriesKey];
|
|
400
|
+
var numValue = typeof seriesValue === 'number' ? seriesValue : 0;
|
|
401
|
+
return {
|
|
402
|
+
key: seriesKey,
|
|
403
|
+
label: ((_a = config[seriesKey]) === null || _a === void 0 ? void 0 : _a.label) || seriesKey,
|
|
404
|
+
value: numValue,
|
|
405
|
+
color: ((_b = config[seriesKey]) === null || _b === void 0 ? void 0 : _b.color) || getSeriesFillColor(keyIndex)
|
|
406
|
+
};
|
|
407
|
+
});
|
|
408
|
+
var content = {
|
|
409
|
+
category: item.name || "Category ".concat(dataIndex + 1),
|
|
410
|
+
series: seriesData
|
|
411
|
+
};
|
|
412
|
+
var svgCoordinates = {
|
|
413
|
+
x: pointX,
|
|
414
|
+
y: margin.top + innerHeight / 2,
|
|
415
|
+
dimensions: dimensions
|
|
416
|
+
};
|
|
417
|
+
handleMouseEnter(e, content, svgCoordinates);
|
|
418
|
+
}, onMouseMove: function (e) {
|
|
419
|
+
if ((hoveredPoint === null || hoveredPoint === void 0 ? void 0 : hoveredPoint.index) === dataIndex) {
|
|
420
|
+
var svgCoordinates = {
|
|
421
|
+
x: pointX,
|
|
422
|
+
y: margin.top + innerHeight / 2,
|
|
423
|
+
dimensions: dimensions
|
|
424
|
+
};
|
|
425
|
+
handleMouseMove(e, svgCoordinates);
|
|
426
|
+
}
|
|
427
|
+
}, onMouseLeave: handleMouseLeave }));
|
|
428
|
+
})),
|
|
429
|
+
React__default.createElement(XAxis, { show: showXAxis, data: data, x: margin.left, y: margin.top + innerHeight, width: innerWidth, categoryWidth: innerWidth / data.length, categoryGap: 0 })),
|
|
430
|
+
React__default.createElement(ChartTooltip, { active: !!tooltipData, position: tooltipData ? { x: tooltipData.x, y: tooltipData.y } : { x: 0, y: 0 }, tooltipRef: tooltipRef, content: tooltipData === null || tooltipData === void 0 ? void 0 : tooltipData.content, chartType: "area" }),
|
|
431
|
+
children));
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
export { AreaChart };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { __assign } from '../../../node_modules/tslib/tslib.es6.js';
|
|
2
|
+
import { CHART_DEFAULTS } from '../types/chart.types.js';
|
|
3
|
+
|
|
4
|
+
// Default values using centralized defaults
|
|
5
|
+
var AREA_CHART_DEFAULTS = __assign(__assign({}, CHART_DEFAULTS), { radius: CHART_DEFAULTS.radius, strokeWidth: CHART_DEFAULTS.strokeWidth, curved: CHART_DEFAULTS.curved, curveType: CHART_DEFAULTS.curveType, showDots: CHART_DEFAULTS.showDots, fillOpacity: CHART_DEFAULTS.fillOpacity, showStroke: CHART_DEFAULTS.showStroke, stacked: CHART_DEFAULTS.stacked });
|
|
6
|
+
|
|
7
|
+
export { AREA_CHART_DEFAULTS };
|