@handled-ai/design-system 0.8.0 → 0.9.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/README.md +14 -4
- package/dist/charts/bar-chart-component.d.ts +24 -0
- package/dist/charts/bar-chart-component.js +123 -0
- package/dist/charts/bar-chart-component.js.map +1 -0
- package/dist/charts/chart-tooltip.d.ts +26 -0
- package/dist/charts/chart-tooltip.js +69 -0
- package/dist/charts/chart-tooltip.js.map +1 -0
- package/dist/charts/chart.d.ts +64 -0
- package/dist/charts/chart.js +285 -0
- package/dist/charts/chart.js.map +1 -0
- package/dist/charts/donut-chart.d.ts +21 -0
- package/dist/charts/donut-chart.js +96 -0
- package/dist/charts/donut-chart.js.map +1 -0
- package/dist/charts/index.d.ts +11 -0
- package/dist/charts/index.js +10 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/charts/pipeline-overview.d.ts +76 -0
- package/dist/charts/pipeline-overview.js +372 -0
- package/dist/charts/pipeline-overview.js.map +1 -0
- package/dist/charts/sankey-chart.d.ts +52 -0
- package/dist/charts/sankey-chart.js +219 -0
- package/dist/charts/sankey-chart.js.map +1 -0
- package/dist/charts/top-line-metrics.d.ts +26 -0
- package/dist/charts/top-line-metrics.js +224 -0
- package/dist/charts/top-line-metrics.js.map +1 -0
- package/dist/charts/trend-area-chart.d.ts +21 -0
- package/dist/charts/trend-area-chart.js +150 -0
- package/dist/charts/trend-area-chart.js.map +1 -0
- package/dist/charts/volume-analysis-chart.d.ts +19 -0
- package/dist/charts/volume-analysis-chart.js +121 -0
- package/dist/charts/volume-analysis-chart.js.map +1 -0
- package/dist/components/activity-detail.d.ts +38 -0
- package/dist/components/activity-detail.js +163 -0
- package/dist/components/activity-detail.js.map +1 -0
- package/dist/components/activity-log.d.ts +21 -0
- package/dist/components/activity-log.js +61 -0
- package/dist/components/activity-log.js.map +1 -0
- package/dist/components/agent-popover.d.ts +71 -0
- package/dist/components/agent-popover.js +282 -0
- package/dist/components/agent-popover.js.map +1 -0
- package/dist/components/agent-widget.d.ts +24 -0
- package/dist/components/agent-widget.js +117 -0
- package/dist/components/agent-widget.js.map +1 -0
- package/dist/components/avatar.d.ts +13 -0
- package/dist/components/avatar.js +140 -0
- package/dist/components/avatar.js.map +1 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +75 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/button.d.ts +13 -0
- package/dist/components/button.js +83 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/card.d.ts +11 -0
- package/dist/components/card.js +119 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/contact-list.d.ts +34 -0
- package/dist/components/contact-list.js +84 -0
- package/dist/components/contact-list.js.map +1 -0
- package/dist/components/dashboard-cards.d.ts +10 -0
- package/dist/components/dashboard-cards.js +164 -0
- package/dist/components/dashboard-cards.js.map +1 -0
- package/dist/components/data-table-display.d.ts +19 -0
- package/dist/components/data-table-display.js +109 -0
- package/dist/components/data-table-display.js.map +1 -0
- package/dist/components/data-table-filter.d.ts +18 -0
- package/dist/components/data-table-filter.js +107 -0
- package/dist/components/data-table-filter.js.map +1 -0
- package/dist/components/data-table-quick-views.d.ts +13 -0
- package/dist/components/data-table-quick-views.js +90 -0
- package/dist/components/data-table-quick-views.js.map +1 -0
- package/dist/components/data-table-toolbar.d.ts +18 -0
- package/dist/components/data-table-toolbar.js +45 -0
- package/dist/components/data-table-toolbar.js.map +1 -0
- package/dist/components/data-table.d.ts +39 -0
- package/dist/components/data-table.js +821 -0
- package/dist/components/data-table.js.map +1 -0
- package/dist/components/detail-view.d.ts +44 -0
- package/dist/components/detail-view.js +165 -0
- package/dist/components/detail-view.js.map +1 -0
- package/dist/components/dialog.d.ts +19 -0
- package/dist/components/dialog.js +188 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +27 -0
- package/dist/components/dropdown-menu.js +279 -0
- package/dist/components/dropdown-menu.js.map +1 -0
- package/dist/components/entity-panel.d.ts +69 -0
- package/dist/components/entity-panel.js +584 -0
- package/dist/components/entity-panel.js.map +1 -0
- package/dist/components/inbox-row.d.ts +27 -0
- package/dist/components/inbox-row.js +139 -0
- package/dist/components/inbox-row.js.map +1 -0
- package/dist/components/inbox-toolbar.d.ts +21 -0
- package/dist/components/inbox-toolbar.js +203 -0
- package/dist/components/inbox-toolbar.js.map +1 -0
- package/dist/components/input.d.ts +5 -0
- package/dist/components/input.js +50 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/insights-filter-bar.d.ts +21 -0
- package/dist/components/insights-filter-bar.js +99 -0
- package/dist/components/insights-filter-bar.js.map +1 -0
- package/dist/components/item-list-display.d.ts +22 -0
- package/dist/components/item-list-display.js +240 -0
- package/dist/components/item-list-display.js.map +1 -0
- package/dist/components/item-list-filter.d.ts +16 -0
- package/dist/components/item-list-filter.js +87 -0
- package/dist/components/item-list-filter.js.map +1 -0
- package/dist/components/item-list-toolbar.d.ts +25 -0
- package/dist/components/item-list-toolbar.js +79 -0
- package/dist/components/item-list-toolbar.js.map +1 -0
- package/dist/components/item-list.d.ts +20 -0
- package/dist/components/item-list.js +702 -0
- package/dist/components/item-list.js.map +1 -0
- package/dist/components/label.d.ts +6 -0
- package/dist/components/label.js +55 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/message.d.ts +23 -0
- package/dist/components/message.js +117 -0
- package/dist/components/message.js.map +1 -0
- package/dist/components/metric-card.d.ts +25 -0
- package/dist/components/metric-card.js +107 -0
- package/dist/components/metric-card.js.map +1 -0
- package/dist/components/performance-metrics-table.d.ts +38 -0
- package/dist/components/performance-metrics-table.js +342 -0
- package/dist/components/performance-metrics-table.js.map +1 -0
- package/dist/components/preview-list.d.ts +14 -0
- package/dist/components/preview-list.js +83 -0
- package/dist/components/preview-list.js.map +1 -0
- package/dist/components/progress.d.ts +6 -0
- package/dist/components/progress.js +69 -0
- package/dist/components/progress.js.map +1 -0
- package/dist/components/quick-action-chat-area.d.ts +24 -0
- package/dist/components/quick-action-chat-area.js +178 -0
- package/dist/components/quick-action-chat-area.js.map +1 -0
- package/dist/components/quick-action-modal.d.ts +30 -0
- package/dist/components/quick-action-modal.js +288 -0
- package/dist/components/quick-action-modal.js.map +1 -0
- package/dist/components/quick-action-sidebar-nav.d.ts +51 -0
- package/dist/components/quick-action-sidebar-nav.js +528 -0
- package/dist/components/quick-action-sidebar-nav.js.map +1 -0
- package/dist/components/recommended-actions-section.d.ts +23 -0
- package/dist/components/recommended-actions-section.js +215 -0
- package/dist/components/recommended-actions-section.js.map +1 -0
- package/dist/components/report-card.d.ts +26 -0
- package/dist/components/report-card.js +69 -0
- package/dist/components/report-card.js.map +1 -0
- package/dist/components/score-analysis-modal.d.ts +26 -0
- package/dist/components/score-analysis-modal.js +141 -0
- package/dist/components/score-analysis-modal.js.map +1 -0
- package/dist/components/score-breakdown.d.ts +17 -0
- package/dist/components/score-breakdown.js +162 -0
- package/dist/components/score-breakdown.js.map +1 -0
- package/dist/components/score-feedback.d.ts +40 -0
- package/dist/components/score-feedback.js +209 -0
- package/dist/components/score-feedback.js.map +1 -0
- package/dist/components/score-ring.d.ts +14 -0
- package/dist/components/score-ring.js +79 -0
- package/dist/components/score-ring.js.map +1 -0
- package/dist/components/scroll-area.d.ts +7 -0
- package/dist/components/scroll-area.js +101 -0
- package/dist/components/scroll-area.js.map +1 -0
- package/dist/components/select.d.ts +17 -0
- package/dist/components/select.js +228 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +6 -0
- package/dist/components/separator.js +61 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +16 -0
- package/dist/components/sheet.js +168 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/sidebar.d.ts +73 -0
- package/dist/components/sidebar.js +723 -0
- package/dist/components/sidebar.js.map +1 -0
- package/dist/components/signal-feedback-inline.d.ts +51 -0
- package/dist/components/signal-feedback-inline.js +548 -0
- package/dist/components/signal-feedback-inline.js.map +1 -0
- package/dist/components/simple-data-table.d.ts +15 -0
- package/dist/components/simple-data-table.js +91 -0
- package/dist/components/simple-data-table.js.map +1 -0
- package/dist/components/skeleton.d.ts +5 -0
- package/dist/components/skeleton.js +44 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/status-badge.d.ts +10 -0
- package/dist/components/status-badge.js +82 -0
- package/dist/components/status-badge.js.map +1 -0
- package/dist/components/styled-bar-list.d.ts +20 -0
- package/dist/components/styled-bar-list.js +59 -0
- package/dist/components/styled-bar-list.js.map +1 -0
- package/dist/components/suggested-actions.d.ts +110 -0
- package/dist/components/suggested-actions.js +1538 -0
- package/dist/components/suggested-actions.js.map +1 -0
- package/dist/components/table.d.ts +12 -0
- package/dist/components/table.js +147 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +14 -0
- package/dist/components/tabs.js +129 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/textarea.d.ts +5 -0
- package/dist/components/textarea.js +47 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/timeline-activity.d.ts +34 -0
- package/dist/components/timeline-activity.js +181 -0
- package/dist/components/timeline-activity.js.map +1 -0
- package/dist/components/tooltip.d.ts +9 -0
- package/dist/components/tooltip.js +93 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/view-mode-toggle.d.ts +16 -0
- package/dist/components/view-mode-toggle.js +24 -0
- package/dist/components/view-mode-toggle.js.map +1 -0
- package/dist/hooks/use-mobile.d.ts +3 -0
- package/dist/hooks/use-mobile.js +21 -0
- package/dist/hooks/use-mobile.js.map +1 -0
- package/dist/index.d.ts +68 -1878
- package/dist/index.js +69 -10918
- package/dist/index.js.map +1 -1
- package/dist/lib/icons.d.ts +18 -0
- package/dist/lib/icons.js +21 -0
- package/dist/lib/icons.js.map +1 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.js +9 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/prototype/index.d.ts +20 -0
- package/dist/prototype/index.js +8 -0
- package/dist/prototype/index.js.map +1 -0
- package/dist/prototype/prototype-accounts-view.d.ts +22 -0
- package/dist/prototype/prototype-accounts-view.js +70 -0
- package/dist/prototype/prototype-accounts-view.js.map +1 -0
- package/dist/prototype/prototype-admin-view.d.ts +21 -0
- package/dist/prototype/prototype-admin-view.js +53 -0
- package/dist/prototype/prototype-admin-view.js.map +1 -0
- package/dist/prototype/prototype-config.d.ts +226 -0
- package/dist/prototype/prototype-config.js +1 -0
- package/dist/prototype/prototype-config.js.map +1 -0
- package/dist/prototype/prototype-inbox-view.d.ts +48 -0
- package/dist/prototype/prototype-inbox-view.js +701 -0
- package/dist/prototype/prototype-inbox-view.js.map +1 -0
- package/dist/prototype/prototype-insights-view.d.ts +23 -0
- package/dist/prototype/prototype-insights-view.js +335 -0
- package/dist/prototype/prototype-insights-view.js.map +1 -0
- package/dist/prototype/prototype-shell.d.ts +40 -0
- package/dist/prototype/prototype-shell.js +190 -0
- package/dist/prototype/prototype-shell.js.map +1 -0
- package/dist/prototype/prototype-work-queue-view.d.ts +8 -0
- package/dist/prototype/prototype-work-queue-view.js +17 -0
- package/dist/prototype/prototype-work-queue-view.js.map +1 -0
- package/dist/three/agent-orb.d.ts +39 -0
- package/dist/three/agent-orb.js +500 -0
- package/dist/three/agent-orb.js.map +1 -0
- package/dist/three/index.d.ts +2 -0
- package/dist/three/index.js +2 -0
- package/dist/three/index.js.map +1 -0
- package/package.json +98 -17
- package/src/charts/bar-chart-component.tsx +150 -0
- package/src/charts/chart-tooltip.tsx +86 -0
- package/src/charts/chart.tsx +371 -0
- package/src/charts/donut-chart.tsx +112 -0
- package/src/charts/index.ts +13 -0
- package/src/charts/pipeline-overview.tsx +476 -0
- package/src/charts/sankey-chart.tsx +290 -0
- package/src/charts/top-line-metrics.tsx +261 -0
- package/src/charts/trend-area-chart.tsx +150 -0
- package/src/charts/volume-analysis-chart.tsx +124 -0
- package/src/components/activity-detail.tsx +233 -0
- package/src/components/activity-log.tsx +89 -0
- package/src/components/agent-popover.tsx +373 -0
- package/src/components/agent-widget.tsx +163 -0
- package/src/components/avatar.tsx +109 -0
- package/src/components/badge.tsx +48 -0
- package/src/components/button.tsx +59 -0
- package/src/components/card.tsx +92 -0
- package/src/components/contact-list.tsx +121 -0
- package/src/components/dashboard-cards.tsx +170 -0
- package/src/components/data-table-display.tsx +139 -0
- package/src/components/data-table-filter.tsx +138 -0
- package/src/components/data-table-quick-views.tsx +103 -0
- package/src/components/data-table-toolbar.tsx +56 -0
- package/src/components/data-table.tsx +915 -0
- package/src/components/detail-view.tsx +237 -0
- package/src/components/dialog.tsx +158 -0
- package/src/components/dropdown-menu.tsx +257 -0
- package/src/components/entity-panel.tsx +767 -0
- package/src/components/inbox-row.tsx +132 -0
- package/src/components/inbox-toolbar.tsx +213 -0
- package/src/components/input.tsx +21 -0
- package/src/components/insights-filter-bar.tsx +132 -0
- package/src/components/item-list-display.tsx +278 -0
- package/src/components/item-list-filter.tsx +118 -0
- package/src/components/item-list-toolbar.tsx +97 -0
- package/src/components/item-list.tsx +843 -0
- package/src/components/label.tsx +24 -0
- package/src/components/message.tsx +83 -0
- package/src/components/metric-card.tsx +178 -0
- package/src/components/performance-metrics-table.tsx +442 -0
- package/src/components/preview-list.tsx +62 -0
- package/src/components/progress.tsx +31 -0
- package/src/components/quick-action-chat-area.tsx +156 -0
- package/src/components/quick-action-modal.tsx +331 -0
- package/src/components/quick-action-sidebar-nav.tsx +592 -0
- package/src/components/recommended-actions-section.tsx +258 -0
- package/src/components/report-card.tsx +106 -0
- package/src/components/score-analysis-modal.tsx +172 -0
- package/src/components/score-breakdown.tsx +179 -0
- package/src/components/score-feedback.tsx +288 -0
- package/src/components/score-ring.tsx +87 -0
- package/src/components/scroll-area.tsx +58 -0
- package/src/components/select.tsx +190 -0
- package/src/components/separator.tsx +28 -0
- package/src/components/sheet.tsx +143 -0
- package/src/components/sidebar.tsx +726 -0
- package/src/components/signal-feedback-inline.tsx +591 -0
- package/src/components/simple-data-table.tsx +124 -0
- package/src/components/skeleton.tsx +15 -0
- package/src/components/status-badge.tsx +63 -0
- package/src/components/styled-bar-list.tsx +70 -0
- package/src/components/suggested-actions.tsx +1985 -0
- package/src/components/table.tsx +116 -0
- package/src/components/tabs.tsx +91 -0
- package/src/components/textarea.tsx +18 -0
- package/src/components/timeline-activity.tsx +234 -0
- package/src/components/tooltip.tsx +57 -0
- package/src/components/view-mode-toggle.tsx +39 -0
- package/src/hooks/use-mobile.ts +21 -0
- package/src/index.ts +77 -0
- package/src/lib/icons.ts +18 -0
- package/src/lib/utils.ts +6 -0
- package/src/prototype/index.ts +11 -0
- package/src/prototype/prototype-accounts-view.tsx +112 -0
- package/src/prototype/prototype-admin-view.tsx +67 -0
- package/src/prototype/prototype-config.ts +243 -0
- package/src/prototype/prototype-inbox-view.tsx +810 -0
- package/src/prototype/prototype-insights-view.tsx +379 -0
- package/src/prototype/prototype-shell.tsx +219 -0
- package/src/prototype/prototype-work-queue-view.tsx +30 -0
- package/src/styles/globals.css +299 -0
- package/src/three/agent-orb.tsx +557 -0
- package/src/three/index.ts +5 -0
- package/src/types/r3f.d.ts +8 -0
package/README.md
CHANGED
|
@@ -16,8 +16,8 @@ A shared design system built on [shadcn/ui](https://ui.shadcn.com). Components a
|
|
|
16
16
|
|
|
17
17
|
- **Primary distribution:** npm package `@handled-ai/design-system`, built with `npm run build:lib` (tsup)
|
|
18
18
|
- **Secondary distribution:** shadcn registry at `/r/{name}.json`, deployed on Vercel for showcase/discovery
|
|
19
|
-
- **Component source:** `
|
|
20
|
-
- **Package entry point:**
|
|
19
|
+
- **Component source:** `src/components/`, `src/charts/`, `src/three/`, `src/prototype/` — customized shadcn primitives and custom UX blocks
|
|
20
|
+
- **Package entry point:** `src/index.ts` (light components), subpath exports for `./charts`, `./three`, `./prototype`
|
|
21
21
|
- **Theming:** Semantic CSS variable tokens — consuming projects define their own palette (see [Styling Reference](docs/STYLING.md))
|
|
22
22
|
- **Build tool:** `shadcn build` generates distributable registry JSON from source
|
|
23
23
|
|
|
@@ -57,7 +57,17 @@ pnpm add @handled-ai/design-system
|
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
```tsx
|
|
60
|
+
// Light components (no heavy deps)
|
|
60
61
|
import { Button, Card, Input } from "@handled-ai/design-system"
|
|
62
|
+
|
|
63
|
+
// Charts (requires recharts / @nivo)
|
|
64
|
+
import { DonutChart } from "@handled-ai/design-system/charts"
|
|
65
|
+
|
|
66
|
+
// Three.js components (requires three / @react-three)
|
|
67
|
+
import { AgentOrb } from "@handled-ai/design-system/three"
|
|
68
|
+
|
|
69
|
+
// Prototype template system
|
|
70
|
+
import { PrototypeShell, type PrototypeConfig } from "@handled-ai/design-system/prototype"
|
|
61
71
|
```
|
|
62
72
|
|
|
63
73
|
### Install via shadcn registry (alternative)
|
|
@@ -105,8 +115,8 @@ If port 3000 is taken, Next.js will auto-pick the next available port.
|
|
|
105
115
|
|
|
106
116
|
See the [Publishing Guide](docs/PUBLISHING.md) for the full workflow. Quick summary:
|
|
107
117
|
|
|
108
|
-
1. Make component changes in `
|
|
109
|
-
2. Export new components from `index.ts
|
|
118
|
+
1. Make component changes in `src/components/` (or `src/charts/`, `src/three/`, `src/prototype/`).
|
|
119
|
+
2. Export new components from the appropriate barrel (`src/index.ts` for light components, subpath barrels for heavy-dep groups).
|
|
110
120
|
3. Update `docs/components/{name}.md` and `docs/COMPONENTS.md`.
|
|
111
121
|
4. Bump the version in `package.json` (semver: patch / minor / major).
|
|
112
122
|
5. Run `npm publish` (build runs automatically via `prepublishOnly`).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface BarSeries {
|
|
4
|
+
dataKey: string;
|
|
5
|
+
color: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
icon?: React.ComponentType<{
|
|
8
|
+
className?: string;
|
|
9
|
+
}>;
|
|
10
|
+
barSize?: number;
|
|
11
|
+
}
|
|
12
|
+
interface BarChartComponentProps {
|
|
13
|
+
data: Record<string, unknown>[];
|
|
14
|
+
bars: BarSeries[];
|
|
15
|
+
height?: number;
|
|
16
|
+
xAxisKey?: string;
|
|
17
|
+
showGrid?: boolean;
|
|
18
|
+
showLegend?: boolean;
|
|
19
|
+
barGap?: number;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
declare function BarChartComponent({ data, bars, height, xAxisKey, showGrid, showLegend, barGap, className, }: BarChartComponentProps): React.JSX.Element;
|
|
23
|
+
|
|
24
|
+
export { BarChartComponent, type BarChartComponentProps, type BarSeries };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import {
|
|
6
|
+
BarChart,
|
|
7
|
+
Bar,
|
|
8
|
+
XAxis,
|
|
9
|
+
YAxis,
|
|
10
|
+
CartesianGrid,
|
|
11
|
+
Tooltip,
|
|
12
|
+
ResponsiveContainer
|
|
13
|
+
} from "recharts";
|
|
14
|
+
import { cn } from "../lib/utils.js";
|
|
15
|
+
function CustomBarTooltip({ active, payload, label }) {
|
|
16
|
+
if (!active || !(payload == null ? void 0 : payload.length)) return null;
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-border bg-card px-3 py-2 shadow-md", children: [
|
|
18
|
+
label ? /* @__PURE__ */ jsx("p", { className: "mb-1.5 text-xs font-medium text-muted-foreground", children: label }) : null,
|
|
19
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1", children: payload.map((entry, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs", children: [
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
className: "h-2 w-2 shrink-0 rounded-full",
|
|
24
|
+
style: { backgroundColor: entry.fill || entry.color }
|
|
25
|
+
}
|
|
26
|
+
),
|
|
27
|
+
/* @__PURE__ */ jsxs("span", { className: "font-medium text-muted-foreground", children: [
|
|
28
|
+
entry.name,
|
|
29
|
+
":"
|
|
30
|
+
] }),
|
|
31
|
+
/* @__PURE__ */ jsx("span", { className: "font-semibold text-foreground", children: entry.value })
|
|
32
|
+
] }, i)) })
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
function CustomLegend({ bars }) {
|
|
36
|
+
return /* @__PURE__ */ jsx("div", { className: "mt-3 flex flex-wrap items-center justify-center gap-4", children: bars.map((bar) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 text-xs", children: [
|
|
37
|
+
bar.icon ? /* @__PURE__ */ jsx(bar.icon, { className: "h-3.5 w-3.5 text-muted-foreground" }) : /* @__PURE__ */ jsx(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
className: "h-2.5 w-2.5 shrink-0 rounded-sm",
|
|
41
|
+
style: { backgroundColor: bar.color }
|
|
42
|
+
}
|
|
43
|
+
),
|
|
44
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-muted-foreground", children: bar.name || bar.dataKey })
|
|
45
|
+
] }, bar.dataKey)) });
|
|
46
|
+
}
|
|
47
|
+
function BarChartComponent({
|
|
48
|
+
data,
|
|
49
|
+
bars,
|
|
50
|
+
height = 280,
|
|
51
|
+
xAxisKey = "date",
|
|
52
|
+
showGrid = true,
|
|
53
|
+
showLegend = true,
|
|
54
|
+
barGap = 2,
|
|
55
|
+
className
|
|
56
|
+
}) {
|
|
57
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("w-full", className), children: [
|
|
58
|
+
/* @__PURE__ */ jsx("div", { style: { height }, children: /* @__PURE__ */ jsx(
|
|
59
|
+
ResponsiveContainer,
|
|
60
|
+
{
|
|
61
|
+
width: "100%",
|
|
62
|
+
height: "100%",
|
|
63
|
+
debounce: 1,
|
|
64
|
+
minWidth: 1,
|
|
65
|
+
minHeight: 1,
|
|
66
|
+
children: /* @__PURE__ */ jsxs(
|
|
67
|
+
BarChart,
|
|
68
|
+
{
|
|
69
|
+
data,
|
|
70
|
+
margin: { top: 10, right: 10, left: -20, bottom: 0 },
|
|
71
|
+
barGap,
|
|
72
|
+
children: [
|
|
73
|
+
showGrid ? /* @__PURE__ */ jsx(
|
|
74
|
+
CartesianGrid,
|
|
75
|
+
{
|
|
76
|
+
strokeDasharray: "3 3",
|
|
77
|
+
vertical: false,
|
|
78
|
+
stroke: "#f1f5f9"
|
|
79
|
+
}
|
|
80
|
+
) : null,
|
|
81
|
+
/* @__PURE__ */ jsx(
|
|
82
|
+
XAxis,
|
|
83
|
+
{
|
|
84
|
+
dataKey: xAxisKey,
|
|
85
|
+
axisLine: false,
|
|
86
|
+
tickLine: false,
|
|
87
|
+
tick: { fill: "#64748B", fontSize: 12 }
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ jsx(
|
|
91
|
+
YAxis,
|
|
92
|
+
{
|
|
93
|
+
axisLine: false,
|
|
94
|
+
tickLine: false,
|
|
95
|
+
tick: { fill: "#64748B", fontSize: 12 }
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
/* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CustomBarTooltip, {}), cursor: false }),
|
|
99
|
+
bars.map((bar) => {
|
|
100
|
+
var _a;
|
|
101
|
+
return /* @__PURE__ */ jsx(
|
|
102
|
+
Bar,
|
|
103
|
+
{
|
|
104
|
+
dataKey: bar.dataKey,
|
|
105
|
+
fill: bar.color,
|
|
106
|
+
name: bar.name || bar.dataKey,
|
|
107
|
+
barSize: (_a = bar.barSize) != null ? _a : 12
|
|
108
|
+
},
|
|
109
|
+
bar.dataKey
|
|
110
|
+
);
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
) }),
|
|
117
|
+
showLegend ? /* @__PURE__ */ jsx(CustomLegend, { bars }) : null
|
|
118
|
+
] });
|
|
119
|
+
}
|
|
120
|
+
export {
|
|
121
|
+
BarChartComponent
|
|
122
|
+
};
|
|
123
|
+
//# sourceMappingURL=bar-chart-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/charts/bar-chart-component.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\nimport {\n BarChart,\n Bar,\n XAxis,\n YAxis,\n CartesianGrid,\n Tooltip,\n ResponsiveContainer,\n} from \"recharts\"\n\nimport { cn } from \"../lib/utils\"\n\nexport interface BarSeries {\n dataKey: string\n color: string\n name?: string\n icon?: React.ComponentType<{ className?: string }>\n barSize?: number\n}\n\nexport interface BarChartComponentProps {\n data: Record<string, unknown>[]\n bars: BarSeries[]\n height?: number\n xAxisKey?: string\n showGrid?: boolean\n showLegend?: boolean\n barGap?: number\n className?: string\n}\n\ninterface TooltipPayloadEntry {\n fill?: string\n color?: string\n name?: string\n dataKey?: string\n value?: number | string\n}\n\nfunction CustomBarTooltip({ active, payload, label }: { active?: boolean; payload?: TooltipPayloadEntry[]; label?: string }) {\n if (!active || !payload?.length) return null\n\n return (\n <div className=\"rounded-lg border border-border bg-card px-3 py-2 shadow-md\">\n {label ? (\n <p className=\"mb-1.5 text-xs font-medium text-muted-foreground\">{label}</p>\n ) : null}\n <div className=\"space-y-1\">\n {payload.map((entry: TooltipPayloadEntry, i: number) => (\n <div key={i} className=\"flex items-center gap-2 text-xs\">\n <div\n className=\"h-2 w-2 shrink-0 rounded-full\"\n style={{ backgroundColor: entry.fill || entry.color }}\n />\n <span className=\"font-medium text-muted-foreground\">\n {entry.name}:\n </span>\n <span className=\"font-semibold text-foreground\">{entry.value}</span>\n </div>\n ))}\n </div>\n </div>\n )\n}\n\nfunction CustomLegend({ bars }: { bars: BarSeries[] }) {\n return (\n <div className=\"mt-3 flex flex-wrap items-center justify-center gap-4\">\n {bars.map((bar) => (\n <div key={bar.dataKey} className=\"flex items-center gap-1.5 text-xs\">\n {bar.icon ? (\n <bar.icon className=\"h-3.5 w-3.5 text-muted-foreground\" />\n ) : (\n <div\n className=\"h-2.5 w-2.5 shrink-0 rounded-sm\"\n style={{ backgroundColor: bar.color }}\n />\n )}\n <span className=\"font-medium text-muted-foreground\">\n {bar.name || bar.dataKey}\n </span>\n </div>\n ))}\n </div>\n )\n}\n\nexport function BarChartComponent({\n data,\n bars,\n height = 280,\n xAxisKey = \"date\",\n showGrid = true,\n showLegend = true,\n barGap = 2,\n className,\n}: BarChartComponentProps) {\n return (\n <div className={cn(\"w-full\", className)}>\n <div style={{ height }}>\n <ResponsiveContainer\n width=\"100%\"\n height=\"100%\"\n debounce={1}\n minWidth={1}\n minHeight={1}\n >\n <BarChart\n data={data}\n margin={{ top: 10, right: 10, left: -20, bottom: 0 }}\n barGap={barGap}\n >\n {showGrid ? (\n <CartesianGrid\n strokeDasharray=\"3 3\"\n vertical={false}\n stroke=\"#f1f5f9\"\n />\n ) : null}\n <XAxis\n dataKey={xAxisKey}\n axisLine={false}\n tickLine={false}\n tick={{ fill: \"#64748B\", fontSize: 12 }}\n />\n <YAxis\n axisLine={false}\n tickLine={false}\n tick={{ fill: \"#64748B\", fontSize: 12 }}\n />\n <Tooltip content={<CustomBarTooltip />} cursor={false} />\n {bars.map((bar) => (\n <Bar\n key={bar.dataKey}\n dataKey={bar.dataKey}\n fill={bar.color}\n name={bar.name || bar.dataKey}\n barSize={bar.barSize ?? 12}\n />\n ))}\n </BarChart>\n </ResponsiveContainer>\n </div>\n {showLegend ? <CustomLegend bars={bars} /> : null}\n </div>\n )\n}\n"],"mappings":";AAgDQ,cASI,YATJ;AA7CR;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,UAAU;AA6BnB,SAAS,iBAAiB,EAAE,QAAQ,SAAS,MAAM,GAA0E;AAC3H,MAAI,CAAC,UAAU,EAAC,mCAAS,QAAQ,QAAO;AAExC,SACE,qBAAC,SAAI,WAAU,+DACZ;AAAA,YACC,oBAAC,OAAE,WAAU,oDAAoD,iBAAM,IACrE;AAAA,IACJ,oBAAC,SAAI,WAAU,aACZ,kBAAQ,IAAI,CAAC,OAA4B,MACxC,qBAAC,SAAY,WAAU,mCACrB;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,OAAO,EAAE,iBAAiB,MAAM,QAAQ,MAAM,MAAM;AAAA;AAAA,MACtD;AAAA,MACA,qBAAC,UAAK,WAAU,qCACb;AAAA,cAAM;AAAA,QAAK;AAAA,SACd;AAAA,MACA,oBAAC,UAAK,WAAU,iCAAiC,gBAAM,OAAM;AAAA,SARrD,CASV,CACD,GACH;AAAA,KACF;AAEJ;AAEA,SAAS,aAAa,EAAE,KAAK,GAA0B;AACrD,SACE,oBAAC,SAAI,WAAU,yDACZ,eAAK,IAAI,CAAC,QACT,qBAAC,SAAsB,WAAU,qCAC9B;AAAA,QAAI,OACH,oBAAC,IAAI,MAAJ,EAAS,WAAU,qCAAoC,IAExD;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,OAAO,EAAE,iBAAiB,IAAI,MAAM;AAAA;AAAA,IACtC;AAAA,IAEF,oBAAC,UAAK,WAAU,qCACb,cAAI,QAAQ,IAAI,SACnB;AAAA,OAXQ,IAAI,OAYd,CACD,GACH;AAEJ;AAEO,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,WAAW;AAAA,EACX,WAAW;AAAA,EACX,aAAa;AAAA,EACb,SAAS;AAAA,EACT;AACF,GAA2B;AACzB,SACE,qBAAC,SAAI,WAAW,GAAG,UAAU,SAAS,GACpC;AAAA,wBAAC,SAAI,OAAO,EAAE,OAAO,GACnB;AAAA,MAAC;AAAA;AAAA,QACC,OAAM;AAAA,QACN,QAAO;AAAA,QACP,UAAU;AAAA,QACV,UAAU;AAAA,QACV,WAAW;AAAA,QAEX;AAAA,UAAC;AAAA;AAAA,YACC;AAAA,YACA,QAAQ,EAAE,KAAK,IAAI,OAAO,IAAI,MAAM,KAAK,QAAQ,EAAE;AAAA,YACnD;AAAA,YAEC;AAAA,yBACC;AAAA,gBAAC;AAAA;AAAA,kBACC,iBAAgB;AAAA,kBAChB,UAAU;AAAA,kBACV,QAAO;AAAA;AAAA,cACT,IACE;AAAA,cACJ;AAAA,gBAAC;AAAA;AAAA,kBACC,SAAS;AAAA,kBACT,UAAU;AAAA,kBACV,UAAU;AAAA,kBACV,MAAM,EAAE,MAAM,WAAW,UAAU,GAAG;AAAA;AAAA,cACxC;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACC,UAAU;AAAA,kBACV,UAAU;AAAA,kBACV,MAAM,EAAE,MAAM,WAAW,UAAU,GAAG;AAAA;AAAA,cACxC;AAAA,cACA,oBAAC,WAAQ,SAAS,oBAAC,oBAAiB,GAAI,QAAQ,OAAO;AAAA,cACtD,KAAK,IAAI,CAAC,QAAK;AAtI5B;AAuIc;AAAA,kBAAC;AAAA;AAAA,oBAEC,SAAS,IAAI;AAAA,oBACb,MAAM,IAAI;AAAA,oBACV,MAAM,IAAI,QAAQ,IAAI;AAAA,oBACtB,UAAS,SAAI,YAAJ,YAAe;AAAA;AAAA,kBAJnB,IAAI;AAAA,gBAKX;AAAA,eACD;AAAA;AAAA;AAAA,QACH;AAAA;AAAA,IACF,GACF;AAAA,IACC,aAAa,oBAAC,gBAAa,MAAY,IAAK;AAAA,KAC/C;AAEJ;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ChartTooltipEntry {
|
|
4
|
+
name?: string;
|
|
5
|
+
value?: number | string;
|
|
6
|
+
dataKey?: string;
|
|
7
|
+
color?: string;
|
|
8
|
+
stroke?: string;
|
|
9
|
+
fill?: string;
|
|
10
|
+
}
|
|
11
|
+
interface SimpleChartTooltipProps {
|
|
12
|
+
active?: boolean;
|
|
13
|
+
payload?: ChartTooltipEntry[];
|
|
14
|
+
label?: string;
|
|
15
|
+
formatter?: (value: number | string, name: string) => [string, string];
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
declare function SimpleChartTooltip({ active, payload, label, formatter, className, }: SimpleChartTooltipProps): React.JSX.Element | null;
|
|
19
|
+
declare const CHART_TOOLTIP_STYLE: React.CSSProperties;
|
|
20
|
+
declare const CHART_CURSOR_STYLE: {
|
|
21
|
+
stroke: string;
|
|
22
|
+
strokeWidth: number;
|
|
23
|
+
strokeDasharray: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { CHART_CURSOR_STYLE, CHART_TOOLTIP_STYLE, type ChartTooltipEntry, SimpleChartTooltip, type SimpleChartTooltipProps };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { cn } from "../lib/utils.js";
|
|
6
|
+
function SimpleChartTooltip({
|
|
7
|
+
active,
|
|
8
|
+
payload,
|
|
9
|
+
label,
|
|
10
|
+
formatter,
|
|
11
|
+
className
|
|
12
|
+
}) {
|
|
13
|
+
if (!active || !payload || !payload.length) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return /* @__PURE__ */ jsxs(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
className: cn(
|
|
20
|
+
"rounded-lg border border-border bg-card px-3 py-2 shadow-md",
|
|
21
|
+
className
|
|
22
|
+
),
|
|
23
|
+
style: { fontSize: "12px" },
|
|
24
|
+
children: [
|
|
25
|
+
label ? /* @__PURE__ */ jsx("p", { className: "mb-1 text-xs font-medium text-muted-foreground", children: label }) : null,
|
|
26
|
+
payload.map((entry, index) => {
|
|
27
|
+
var _a;
|
|
28
|
+
const value = (_a = entry.value) != null ? _a : "";
|
|
29
|
+
const name = entry.name || entry.dataKey || "";
|
|
30
|
+
const color = entry.color || entry.stroke || entry.fill;
|
|
31
|
+
const [displayValue, displayName] = formatter ? formatter(value, name) : [String(value), name];
|
|
32
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
33
|
+
color ? /* @__PURE__ */ jsx(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
className: "h-2 w-2 shrink-0 rounded-full",
|
|
37
|
+
style: { backgroundColor: color }
|
|
38
|
+
}
|
|
39
|
+
) : null,
|
|
40
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs font-medium text-foreground", children: [
|
|
41
|
+
displayName,
|
|
42
|
+
": ",
|
|
43
|
+
displayValue
|
|
44
|
+
] })
|
|
45
|
+
] }, index);
|
|
46
|
+
})
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
const CHART_TOOLTIP_STYLE = {
|
|
52
|
+
backgroundColor: "#fff",
|
|
53
|
+
borderRadius: "8px",
|
|
54
|
+
fontSize: "12px",
|
|
55
|
+
padding: "8px",
|
|
56
|
+
border: "1px solid #e2e8f0",
|
|
57
|
+
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1)"
|
|
58
|
+
};
|
|
59
|
+
const CHART_CURSOR_STYLE = {
|
|
60
|
+
stroke: "#94a3b8",
|
|
61
|
+
strokeWidth: 1,
|
|
62
|
+
strokeDasharray: "4 4"
|
|
63
|
+
};
|
|
64
|
+
export {
|
|
65
|
+
CHART_CURSOR_STYLE,
|
|
66
|
+
CHART_TOOLTIP_STYLE,
|
|
67
|
+
SimpleChartTooltip
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=chart-tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/charts/chart-tooltip.tsx"],"sourcesContent":["\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"../lib/utils\"\n\nexport interface ChartTooltipEntry {\n name?: string\n value?: number | string\n dataKey?: string\n color?: string\n stroke?: string\n fill?: string\n}\n\nexport interface SimpleChartTooltipProps {\n active?: boolean\n payload?: ChartTooltipEntry[]\n label?: string\n formatter?: (value: number | string, name: string) => [string, string]\n className?: string\n}\n\nexport function SimpleChartTooltip({\n active,\n payload,\n label,\n formatter,\n className,\n}: SimpleChartTooltipProps) {\n if (!active || !payload || !payload.length) {\n return null\n }\n\n return (\n <div\n className={cn(\n \"rounded-lg border border-border bg-card px-3 py-2 shadow-md\",\n className,\n )}\n style={{ fontSize: \"12px\" }}\n >\n {label ? (\n <p className=\"mb-1 text-xs font-medium text-muted-foreground\">{label}</p>\n ) : null}\n {payload.map((entry, index) => {\n const value = entry.value ?? \"\"\n const name = entry.name || entry.dataKey || \"\"\n const color = entry.color || entry.stroke || entry.fill\n\n const [displayValue, displayName] = formatter\n ? formatter(value as number | string, name)\n : [String(value), name]\n\n return (\n <div key={index} className=\"flex items-center gap-2\">\n {color ? (\n <div\n className=\"h-2 w-2 shrink-0 rounded-full\"\n style={{ backgroundColor: color }}\n />\n ) : null}\n <span className=\"text-xs font-medium text-foreground\">\n {displayName}: {displayValue}\n </span>\n </div>\n )\n })}\n </div>\n )\n}\n\nexport const CHART_TOOLTIP_STYLE: React.CSSProperties = {\n backgroundColor: \"#fff\",\n borderRadius: \"8px\",\n fontSize: \"12px\",\n padding: \"8px\",\n border: \"1px solid #e2e8f0\",\n boxShadow: \"0 4px 6px -1px rgba(0, 0, 0, 0.1)\",\n}\n\nexport const CHART_CURSOR_STYLE = {\n stroke: \"#94a3b8\",\n strokeWidth: 1,\n strokeDasharray: \"4 4\",\n}\n"],"mappings":";AA2CQ,cAmBI,YAnBJ;AAvCR,SAAS,UAAU;AAmBZ,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA4B;AAC1B,MAAI,CAAC,UAAU,CAAC,WAAW,CAAC,QAAQ,QAAQ;AAC1C,WAAO;AAAA,EACT;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO,EAAE,UAAU,OAAO;AAAA,MAEzB;AAAA,gBACC,oBAAC,OAAE,WAAU,kDAAkD,iBAAM,IACnE;AAAA,QACH,QAAQ,IAAI,CAAC,OAAO,UAAU;AA7CrC;AA8CQ,gBAAM,SAAQ,WAAM,UAAN,YAAe;AAC7B,gBAAM,OAAO,MAAM,QAAQ,MAAM,WAAW;AAC5C,gBAAM,QAAQ,MAAM,SAAS,MAAM,UAAU,MAAM;AAEnD,gBAAM,CAAC,cAAc,WAAW,IAAI,YAChC,UAAU,OAA0B,IAAI,IACxC,CAAC,OAAO,KAAK,GAAG,IAAI;AAExB,iBACE,qBAAC,SAAgB,WAAU,2BACxB;AAAA,oBACC;AAAA,cAAC;AAAA;AAAA,gBACC,WAAU;AAAA,gBACV,OAAO,EAAE,iBAAiB,MAAM;AAAA;AAAA,YAClC,IACE;AAAA,YACJ,qBAAC,UAAK,WAAU,uCACb;AAAA;AAAA,cAAY;AAAA,cAAG;AAAA,eAClB;AAAA,eATQ,KAUV;AAAA,QAEJ,CAAC;AAAA;AAAA;AAAA,EACH;AAEJ;AAEO,MAAM,sBAA2C;AAAA,EACtD,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,UAAU;AAAA,EACV,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,WAAW;AACb;AAEO,MAAM,qBAAqB;AAAA,EAChC,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,iBAAiB;AACnB;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as RechartsPrimitive from 'recharts';
|
|
3
|
+
|
|
4
|
+
declare const THEMES: {
|
|
5
|
+
readonly light: "";
|
|
6
|
+
readonly dark: ".dark";
|
|
7
|
+
};
|
|
8
|
+
type ChartConfig = {
|
|
9
|
+
[k in string]: {
|
|
10
|
+
label?: React.ReactNode;
|
|
11
|
+
icon?: React.ComponentType;
|
|
12
|
+
} & ({
|
|
13
|
+
color?: string;
|
|
14
|
+
theme?: never;
|
|
15
|
+
} | {
|
|
16
|
+
color?: never;
|
|
17
|
+
theme: Record<keyof typeof THEMES, string>;
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
declare function ChartContainer({ id, className, children, config, ...props }: React.ComponentProps<"div"> & {
|
|
21
|
+
config: ChartConfig;
|
|
22
|
+
children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>["children"];
|
|
23
|
+
}): React.JSX.Element;
|
|
24
|
+
declare const ChartStyle: ({ id, config }: {
|
|
25
|
+
id: string;
|
|
26
|
+
config: ChartConfig;
|
|
27
|
+
}) => React.JSX.Element | null;
|
|
28
|
+
declare const ChartTooltip: typeof RechartsPrimitive.Tooltip;
|
|
29
|
+
type TooltipPayloadItem = {
|
|
30
|
+
name?: string;
|
|
31
|
+
value?: number | string;
|
|
32
|
+
dataKey?: string;
|
|
33
|
+
payload?: Record<string, unknown>;
|
|
34
|
+
color?: string;
|
|
35
|
+
fill?: string;
|
|
36
|
+
};
|
|
37
|
+
declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, color, nameKey, labelKey, }: React.ComponentProps<"div"> & {
|
|
38
|
+
active?: boolean;
|
|
39
|
+
payload?: TooltipPayloadItem[];
|
|
40
|
+
label?: string;
|
|
41
|
+
labelFormatter?: (value: unknown, payload: TooltipPayloadItem[]) => React.ReactNode;
|
|
42
|
+
formatter?: (value: unknown, name: string, item: TooltipPayloadItem, index: number, payload: Record<string, unknown>) => React.ReactNode;
|
|
43
|
+
hideLabel?: boolean;
|
|
44
|
+
hideIndicator?: boolean;
|
|
45
|
+
indicator?: "line" | "dot" | "dashed";
|
|
46
|
+
nameKey?: string;
|
|
47
|
+
labelKey?: string;
|
|
48
|
+
labelClassName?: string;
|
|
49
|
+
color?: string;
|
|
50
|
+
}): React.JSX.Element | null;
|
|
51
|
+
declare const ChartLegend: typeof RechartsPrimitive.Legend;
|
|
52
|
+
type LegendPayloadItem = {
|
|
53
|
+
value?: string;
|
|
54
|
+
dataKey?: string;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
};
|
|
57
|
+
declare function ChartLegendContent({ className, hideIcon, payload, verticalAlign, nameKey, }: React.ComponentProps<"div"> & {
|
|
58
|
+
payload?: LegendPayloadItem[];
|
|
59
|
+
verticalAlign?: "top" | "bottom";
|
|
60
|
+
hideIcon?: boolean;
|
|
61
|
+
nameKey?: string;
|
|
62
|
+
}): React.JSX.Element | null;
|
|
63
|
+
|
|
64
|
+
export { type ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent };
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __objRest = (source, exclude) => {
|
|
24
|
+
var target = {};
|
|
25
|
+
for (var prop in source)
|
|
26
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
27
|
+
target[prop] = source[prop];
|
|
28
|
+
if (source != null && __getOwnPropSymbols)
|
|
29
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
30
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
}
|
|
33
|
+
return target;
|
|
34
|
+
};
|
|
35
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
36
|
+
import * as React from "react";
|
|
37
|
+
import * as RechartsPrimitive from "recharts";
|
|
38
|
+
import { cn } from "../lib/utils.js";
|
|
39
|
+
const THEMES = { light: "", dark: ".dark" };
|
|
40
|
+
const ChartContext = React.createContext(null);
|
|
41
|
+
function useChart() {
|
|
42
|
+
const context = React.useContext(ChartContext);
|
|
43
|
+
if (!context) {
|
|
44
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
45
|
+
}
|
|
46
|
+
return context;
|
|
47
|
+
}
|
|
48
|
+
function ChartContainer(_a) {
|
|
49
|
+
var _b = _a, {
|
|
50
|
+
id,
|
|
51
|
+
className,
|
|
52
|
+
children,
|
|
53
|
+
config
|
|
54
|
+
} = _b, props = __objRest(_b, [
|
|
55
|
+
"id",
|
|
56
|
+
"className",
|
|
57
|
+
"children",
|
|
58
|
+
"config"
|
|
59
|
+
]);
|
|
60
|
+
const uniqueId = React.useId();
|
|
61
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
62
|
+
return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
|
|
63
|
+
"div",
|
|
64
|
+
__spreadProps(__spreadValues({
|
|
65
|
+
"data-slot": "chart",
|
|
66
|
+
"data-chart": chartId,
|
|
67
|
+
className: cn(
|
|
68
|
+
"[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border flex aspect-video justify-center text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
|
|
69
|
+
className
|
|
70
|
+
)
|
|
71
|
+
}, props), {
|
|
72
|
+
children: [
|
|
73
|
+
/* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
|
|
74
|
+
/* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { children })
|
|
75
|
+
]
|
|
76
|
+
})
|
|
77
|
+
) });
|
|
78
|
+
}
|
|
79
|
+
const ChartStyle = ({ id, config }) => {
|
|
80
|
+
const colorConfig = Object.entries(config).filter(
|
|
81
|
+
([, config2]) => config2.theme || config2.color
|
|
82
|
+
);
|
|
83
|
+
if (!colorConfig.length) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return /* @__PURE__ */ jsx(
|
|
87
|
+
"style",
|
|
88
|
+
{
|
|
89
|
+
dangerouslySetInnerHTML: {
|
|
90
|
+
__html: Object.entries(THEMES).map(
|
|
91
|
+
([theme, prefix]) => `
|
|
92
|
+
${prefix} [data-chart=${id}] {
|
|
93
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
94
|
+
var _a;
|
|
95
|
+
const color = ((_a = itemConfig.theme) == null ? void 0 : _a[theme]) || itemConfig.color;
|
|
96
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
97
|
+
}).join("\n")}
|
|
98
|
+
}
|
|
99
|
+
`
|
|
100
|
+
).join("\n")
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
const ChartTooltip = RechartsPrimitive.Tooltip;
|
|
106
|
+
function ChartTooltipContent({
|
|
107
|
+
active,
|
|
108
|
+
payload,
|
|
109
|
+
className,
|
|
110
|
+
indicator = "dot",
|
|
111
|
+
hideLabel = false,
|
|
112
|
+
hideIndicator = false,
|
|
113
|
+
label,
|
|
114
|
+
labelFormatter,
|
|
115
|
+
labelClassName,
|
|
116
|
+
formatter,
|
|
117
|
+
color,
|
|
118
|
+
nameKey,
|
|
119
|
+
labelKey
|
|
120
|
+
}) {
|
|
121
|
+
const { config } = useChart();
|
|
122
|
+
const tooltipLabel = React.useMemo(() => {
|
|
123
|
+
var _a;
|
|
124
|
+
if (hideLabel || !(payload == null ? void 0 : payload.length)) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const [item] = payload;
|
|
128
|
+
const key = `${labelKey || (item == null ? void 0 : item.dataKey) || (item == null ? void 0 : item.name) || "value"}`;
|
|
129
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
130
|
+
const value = !labelKey && typeof label === "string" ? ((_a = config[label]) == null ? void 0 : _a.label) || label : itemConfig == null ? void 0 : itemConfig.label;
|
|
131
|
+
if (labelFormatter) {
|
|
132
|
+
return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
|
|
133
|
+
}
|
|
134
|
+
if (!value) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: value });
|
|
138
|
+
}, [
|
|
139
|
+
label,
|
|
140
|
+
labelFormatter,
|
|
141
|
+
payload,
|
|
142
|
+
hideLabel,
|
|
143
|
+
labelClassName,
|
|
144
|
+
config,
|
|
145
|
+
labelKey
|
|
146
|
+
]);
|
|
147
|
+
if (!active || !(payload == null ? void 0 : payload.length)) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
151
|
+
return /* @__PURE__ */ jsxs(
|
|
152
|
+
"div",
|
|
153
|
+
{
|
|
154
|
+
className: cn(
|
|
155
|
+
"border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl",
|
|
156
|
+
className
|
|
157
|
+
),
|
|
158
|
+
children: [
|
|
159
|
+
!nestLabel ? tooltipLabel : null,
|
|
160
|
+
/* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
|
|
161
|
+
var _a, _b;
|
|
162
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
163
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
164
|
+
const indicatorColor = color || ((_a = item.payload) == null ? void 0 : _a.fill) || item.color;
|
|
165
|
+
return /* @__PURE__ */ jsx(
|
|
166
|
+
"div",
|
|
167
|
+
{
|
|
168
|
+
className: cn(
|
|
169
|
+
"[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
|
|
170
|
+
indicator === "dot" && "items-center"
|
|
171
|
+
),
|
|
172
|
+
children: formatter && (item == null ? void 0 : item.value) !== void 0 && item.name ? formatter(item.value, item.name, item, index, (_b = item.payload) != null ? _b : {}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
173
|
+
(itemConfig == null ? void 0 : itemConfig.icon) ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
className: cn(
|
|
177
|
+
"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
|
|
178
|
+
{
|
|
179
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
180
|
+
"w-1": indicator === "line",
|
|
181
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
182
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
style: {
|
|
186
|
+
"--color-bg": indicatorColor,
|
|
187
|
+
"--color-border": indicatorColor
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
/* @__PURE__ */ jsxs(
|
|
192
|
+
"div",
|
|
193
|
+
{
|
|
194
|
+
className: cn(
|
|
195
|
+
"flex flex-1 justify-between leading-none",
|
|
196
|
+
nestLabel ? "items-end" : "items-center"
|
|
197
|
+
),
|
|
198
|
+
children: [
|
|
199
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
|
|
200
|
+
nestLabel ? tooltipLabel : null,
|
|
201
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: (itemConfig == null ? void 0 : itemConfig.label) || item.name })
|
|
202
|
+
] }),
|
|
203
|
+
item.value && /* @__PURE__ */ jsx("span", { className: "text-foreground font-mono font-medium tabular-nums", children: item.value.toLocaleString() })
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
] })
|
|
208
|
+
},
|
|
209
|
+
item.dataKey
|
|
210
|
+
);
|
|
211
|
+
}) })
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
const ChartLegend = RechartsPrimitive.Legend;
|
|
217
|
+
function ChartLegendContent({
|
|
218
|
+
className,
|
|
219
|
+
hideIcon = false,
|
|
220
|
+
payload,
|
|
221
|
+
verticalAlign = "bottom",
|
|
222
|
+
nameKey
|
|
223
|
+
}) {
|
|
224
|
+
const { config } = useChart();
|
|
225
|
+
if (!(payload == null ? void 0 : payload.length)) {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
return /* @__PURE__ */ jsx(
|
|
229
|
+
"div",
|
|
230
|
+
{
|
|
231
|
+
className: cn(
|
|
232
|
+
"flex items-center justify-center gap-4",
|
|
233
|
+
verticalAlign === "top" ? "pb-3" : "pt-3",
|
|
234
|
+
className
|
|
235
|
+
),
|
|
236
|
+
children: payload.map((item) => {
|
|
237
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
238
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
239
|
+
return /* @__PURE__ */ jsxs(
|
|
240
|
+
"div",
|
|
241
|
+
{
|
|
242
|
+
className: cn(
|
|
243
|
+
"[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
|
|
244
|
+
),
|
|
245
|
+
children: [
|
|
246
|
+
(itemConfig == null ? void 0 : itemConfig.icon) && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
|
|
247
|
+
"div",
|
|
248
|
+
{
|
|
249
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
250
|
+
style: {
|
|
251
|
+
backgroundColor: item.color
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
),
|
|
255
|
+
itemConfig == null ? void 0 : itemConfig.label
|
|
256
|
+
]
|
|
257
|
+
},
|
|
258
|
+
item.value
|
|
259
|
+
);
|
|
260
|
+
})
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
265
|
+
if (typeof payload !== "object" || payload === null) {
|
|
266
|
+
return void 0;
|
|
267
|
+
}
|
|
268
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
|
|
269
|
+
let configLabelKey = key;
|
|
270
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
271
|
+
configLabelKey = payload[key];
|
|
272
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
273
|
+
configLabelKey = payloadPayload[key];
|
|
274
|
+
}
|
|
275
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
276
|
+
}
|
|
277
|
+
export {
|
|
278
|
+
ChartContainer,
|
|
279
|
+
ChartLegend,
|
|
280
|
+
ChartLegendContent,
|
|
281
|
+
ChartStyle,
|
|
282
|
+
ChartTooltip,
|
|
283
|
+
ChartTooltipContent
|
|
284
|
+
};
|
|
285
|
+
//# sourceMappingURL=chart.js.map
|