@wakastellar/ui 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/add.d.ts +7 -0
- package/dist/cli/commands/init.d.ts +6 -0
- package/dist/cli/commands/list.d.ts +5 -0
- package/dist/cli/commands/search.d.ts +1 -0
- package/dist/cli/index.cjs +4844 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/utils/config.d.ts +29 -0
- package/dist/cli/utils/logger.d.ts +20 -0
- package/dist/cli/utils/registry.d.ts +23 -0
- package/package.json +14 -3
- package/src/blocks/activity-timeline/index.tsx +586 -0
- package/src/blocks/calendar-view/index.tsx +756 -0
- package/src/blocks/chat/index.tsx +1018 -0
- package/src/blocks/chat/widget.tsx +504 -0
- package/src/blocks/dashboard/index.tsx +522 -0
- package/src/blocks/empty-states/index.tsx +452 -0
- package/src/blocks/error-pages/index.tsx +426 -0
- package/src/blocks/faq/index.tsx +479 -0
- package/src/blocks/file-manager/index.tsx +890 -0
- package/src/blocks/footer/index.tsx +133 -0
- package/src/blocks/header/index.tsx +357 -0
- package/src/blocks/headtab/index.tsx +139 -0
- package/src/blocks/i18n-editor/index.tsx +1016 -0
- package/src/blocks/index.ts +80 -0
- package/src/blocks/kanban-board/index.tsx +779 -0
- package/src/blocks/landing/index.tsx +677 -0
- package/src/blocks/language-selector/index.tsx +88 -0
- package/src/blocks/layout/index.tsx +159 -0
- package/src/blocks/login/index.tsx +339 -0
- package/src/blocks/login/types.ts +131 -0
- package/src/blocks/pricing/index.tsx +564 -0
- package/src/blocks/profile/index.tsx +746 -0
- package/src/blocks/settings/index.tsx +558 -0
- package/src/blocks/sidebar/index.tsx +713 -0
- package/src/blocks/theme-creator-block/index.tsx +835 -0
- package/src/blocks/user-management/index.tsx +1037 -0
- package/src/blocks/wizard/index.tsx +719 -0
- package/src/components/DataTable/DataTable.tsx +406 -0
- package/src/components/DataTable/DataTableAdvanced.tsx +720 -0
- package/src/components/DataTable/DataTableBody.tsx +216 -0
- package/src/components/DataTable/DataTableCell.tsx +172 -0
- package/src/components/DataTable/DataTableColumnResizer.tsx +62 -0
- package/src/components/DataTable/DataTableConflictResolver.tsx +478 -0
- package/src/components/DataTable/DataTableContextMenu.tsx +219 -0
- package/src/components/DataTable/DataTableEditCell.tsx +279 -0
- package/src/components/DataTable/DataTableFilterBuilder.tsx +519 -0
- package/src/components/DataTable/DataTableFilters.tsx +535 -0
- package/src/components/DataTable/DataTableGrouping.tsx +147 -0
- package/src/components/DataTable/DataTableHeader.tsx +172 -0
- package/src/components/DataTable/DataTablePagination.tsx +125 -0
- package/src/components/DataTable/DataTableSelection.tsx +269 -0
- package/src/components/DataTable/DataTableSyncStatus.tsx +281 -0
- package/src/components/DataTable/DataTableToolbar.tsx +262 -0
- package/src/components/DataTable/README.md +446 -0
- package/src/components/DataTable/__tests__/DataTableAdvanced.test.tsx +426 -0
- package/src/components/DataTable/__tests__/DataTableEdit.test.tsx +329 -0
- package/src/components/DataTable/__tests__/useDataTableAdvanced.test.ts +455 -0
- package/src/components/DataTable/examples/EditExample.tsx +166 -0
- package/src/components/DataTable/formatters/index.ts +335 -0
- package/src/components/DataTable/hooks/__tests__/useDataTableEdit.test.ts +239 -0
- package/src/components/DataTable/hooks/useDataTable.ts +145 -0
- package/src/components/DataTable/hooks/useDataTableAdvanced.ts +342 -0
- package/src/components/DataTable/hooks/useDataTableAdvancedFilters.ts +637 -0
- package/src/components/DataTable/hooks/useDataTableColumnTemplates.ts +186 -0
- package/src/components/DataTable/hooks/useDataTableEdit.ts +167 -0
- package/src/components/DataTable/hooks/useDataTableExport.ts +227 -0
- package/src/components/DataTable/hooks/useDataTableImport.ts +216 -0
- package/src/components/DataTable/hooks/useDataTableOffline.ts +481 -0
- package/src/components/DataTable/hooks/useDataTableTheme.ts +213 -0
- package/src/components/DataTable/hooks/useDataTableVirtualization.ts +99 -0
- package/src/components/DataTable/hooks/useTableLayout.ts +85 -0
- package/src/components/DataTable/index.ts +81 -0
- package/src/components/DataTable/services/IndexedDBService.ts +504 -0
- package/src/components/DataTable/templates/index.tsx +803 -0
- package/src/components/DataTable/types.ts +504 -0
- package/src/components/DataTable/utils.ts +164 -0
- package/src/components/DataTable/workers/exportWorker.ts +213 -0
- package/src/components/accordion/index.tsx +61 -0
- package/src/components/alert/index.tsx +61 -0
- package/src/components/alert-dialog/index.tsx +146 -0
- package/src/components/aspect-ratio/index.tsx +12 -0
- package/src/components/avatar/index.tsx +54 -0
- package/src/components/badge/Badge.stories.tsx +64 -0
- package/src/components/badge/index.tsx +38 -0
- package/src/components/button/Button.stories.tsx +173 -0
- package/src/components/button/index.tsx +56 -0
- package/src/components/calendar/index.tsx +73 -0
- package/src/components/card/index.tsx +78 -0
- package/src/components/checkbox/index.tsx +34 -0
- package/src/components/code/index.tsx +229 -0
- package/src/components/collapsible/index.tsx +16 -0
- package/src/components/command/index.tsx +162 -0
- package/src/components/context-menu/index.tsx +204 -0
- package/src/components/dialog/index.tsx +126 -0
- package/src/components/dropdown-menu/index.tsx +204 -0
- package/src/components/error-boundary/ErrorBoundary.tsx +281 -0
- package/src/components/error-boundary/index.ts +7 -0
- package/src/components/form/index.tsx +183 -0
- package/src/components/hover-card/index.tsx +33 -0
- package/src/components/index.ts +368 -0
- package/src/components/input/Input.stories.tsx +100 -0
- package/src/components/input/index.tsx +27 -0
- package/src/components/input-otp/index.tsx +277 -0
- package/src/components/label/index.tsx +30 -0
- package/src/components/language-selector/index.tsx +341 -0
- package/src/components/menubar/index.tsx +240 -0
- package/src/components/navigation-menu/index.tsx +134 -0
- package/src/components/popover/index.tsx +35 -0
- package/src/components/progress/index.tsx +32 -0
- package/src/components/radio-group/index.tsx +48 -0
- package/src/components/scroll-area/index.tsx +52 -0
- package/src/components/select/index.tsx +164 -0
- package/src/components/separator/index.tsx +35 -0
- package/src/components/sheet/index.tsx +147 -0
- package/src/components/skeleton/index.tsx +22 -0
- package/src/components/slider/index.tsx +32 -0
- package/src/components/switch/index.tsx +33 -0
- package/src/components/table/index.tsx +117 -0
- package/src/components/tabs/index.tsx +59 -0
- package/src/components/textarea/index.tsx +30 -0
- package/src/components/theme-selector/index.tsx +327 -0
- package/src/components/toast/index.tsx +133 -0
- package/src/components/toaster/index.tsx +34 -0
- package/src/components/toggle/index.tsx +49 -0
- package/src/components/tooltip/index.tsx +34 -0
- package/src/components/typography/index.tsx +276 -0
- package/src/components/waka-3d-pie-chart/index.tsx +486 -0
- package/src/components/waka-achievement-unlock/index.tsx +716 -0
- package/src/components/waka-activity-feed/index.tsx +686 -0
- package/src/components/waka-address-autocomplete/index.tsx +1202 -0
- package/src/components/waka-admincrumb/index.tsx +349 -0
- package/src/components/waka-alert-stack/index.tsx +827 -0
- package/src/components/waka-allocation-matrix/index.tsx +1278 -0
- package/src/components/waka-approval-chain/index.tsx +766 -0
- package/src/components/waka-audit-log/index.tsx +1475 -0
- package/src/components/waka-autocomplete/index.tsx +358 -0
- package/src/components/waka-badge-showcase/index.tsx +704 -0
- package/src/components/waka-barcode/index.tsx +260 -0
- package/src/components/waka-biometric-prompt/index.tsx +765 -0
- package/src/components/waka-bottom-sheet/index.tsx +495 -0
- package/src/components/waka-breadcrumb/index.tsx +376 -0
- package/src/components/waka-breadcrumb-path/index.tsx +513 -0
- package/src/components/waka-budget-burn/index.tsx +1234 -0
- package/src/components/waka-capacity-planner/index.tsx +1107 -0
- package/src/components/waka-carousel/index.tsx +893 -0
- package/src/components/waka-cart-summary/index.tsx +1055 -0
- package/src/components/waka-challenge-timer/index.tsx +1044 -0
- package/src/components/waka-charts/WakaAreaChart.tsx +251 -0
- package/src/components/waka-charts/WakaBarChart.tsx +222 -0
- package/src/components/waka-charts/WakaChart.tsx +124 -0
- package/src/components/waka-charts/WakaLineChart.tsx +219 -0
- package/src/components/waka-charts/WakaMiniChart.tsx +133 -0
- package/src/components/waka-charts/WakaPieChart.tsx +214 -0
- package/src/components/waka-charts/WakaSparkline.tsx +229 -0
- package/src/components/waka-charts/dataTableHelpers.ts +109 -0
- package/src/components/waka-charts/hooks/useChartTheme.ts +123 -0
- package/src/components/waka-charts/hooks/useRechartsLoader.ts +234 -0
- package/src/components/waka-charts/index.ts +90 -0
- package/src/components/waka-charts/types.ts +330 -0
- package/src/components/waka-chat-bubble/index.tsx +1060 -0
- package/src/components/waka-checklist/index.tsx +1067 -0
- package/src/components/waka-checkout-stepper/index.tsx +976 -0
- package/src/components/waka-cohort-table/index.tsx +1011 -0
- package/src/components/waka-color-picker/index.tsx +447 -0
- package/src/components/waka-combo-counter/index.tsx +864 -0
- package/src/components/waka-combobox/index.tsx +497 -0
- package/src/components/waka-command-bar/index.tsx +403 -0
- package/src/components/waka-compare-period/index.tsx +1230 -0
- package/src/components/waka-connection-matrix/index.tsx +1053 -0
- package/src/components/waka-contribution-graph/index.tsx +552 -0
- package/src/components/waka-cost-breakdown/index.tsx +1065 -0
- package/src/components/waka-coupon-input/index.tsx +592 -0
- package/src/components/waka-credit-card-input/index.tsx +982 -0
- package/src/components/waka-daily-reward/index.tsx +762 -0
- package/src/components/waka-date-range-picker/index.tsx +378 -0
- package/src/components/waka-datetime-picker/index.tsx +793 -0
- package/src/components/waka-datetime-picker.form-integration/index.tsx +402 -0
- package/src/components/waka-deployment-lane/index.tsx +673 -0
- package/src/components/waka-device-trust/index.tsx +1259 -0
- package/src/components/waka-dock/index.tsx +285 -0
- package/src/components/waka-drawer/index.tsx +319 -0
- package/src/components/waka-empty-state/index.tsx +545 -0
- package/src/components/waka-error-shake/index.tsx +398 -0
- package/src/components/waka-feature-announcement/index.tsx +991 -0
- package/src/components/waka-file-upload/index.tsx +437 -0
- package/src/components/waka-floating-nav/index.tsx +413 -0
- package/src/components/waka-flow-diagram/index.tsx +508 -0
- package/src/components/waka-funnel-chart/index.tsx +823 -0
- package/src/components/waka-glow-card/index.tsx +246 -0
- package/src/components/waka-goal-progress/index.tsx +1025 -0
- package/src/components/waka-haptic-button/index.tsx +388 -0
- package/src/components/waka-health-pulse/index.tsx +451 -0
- package/src/components/waka-heatmap/index.tsx +1026 -0
- package/src/components/waka-hotspot/index.tsx +682 -0
- package/src/components/waka-image/index.tsx +373 -0
- package/src/components/waka-incident-timeline/index.tsx +686 -0
- package/src/components/waka-invoice-preview/index.tsx +829 -0
- package/src/components/waka-kanban/index.tsx +646 -0
- package/src/components/waka-kpi-dashboard/index.tsx +755 -0
- package/src/components/waka-leaderboard/index.tsx +746 -0
- package/src/components/waka-level-progress/index.tsx +665 -0
- package/src/components/waka-liquid-button/index.tsx +520 -0
- package/src/components/waka-loading-orbit/index.tsx +478 -0
- package/src/components/waka-loot-box/index.tsx +1091 -0
- package/src/components/waka-magic-link/index.tsx +321 -0
- package/src/components/waka-magnetic-button/index.tsx +567 -0
- package/src/components/waka-mention-input/index.tsx +953 -0
- package/src/components/waka-metric-sparkline/index.tsx +627 -0
- package/src/components/waka-milestone-road/index.tsx +1064 -0
- package/src/components/waka-modal/index.tsx +374 -0
- package/src/components/waka-morph-button/index.tsx +495 -0
- package/src/components/waka-network-topology/index.tsx +801 -0
- package/src/components/waka-notifications/index.tsx +414 -0
- package/src/components/waka-number-input/index.tsx +373 -0
- package/src/components/waka-orbital-menu/index.tsx +445 -0
- package/src/components/waka-order-tracker/index.tsx +1041 -0
- package/src/components/waka-pagination/index.tsx +393 -0
- package/src/components/waka-password-strength/index.tsx +824 -0
- package/src/components/waka-payment-method-picker/index.tsx +715 -0
- package/src/components/waka-permission-matrix/index.tsx +1302 -0
- package/src/components/waka-phone-input/index.tsx +801 -0
- package/src/components/waka-pipeline-view/index.tsx +604 -0
- package/src/components/waka-player-card/index.tsx +691 -0
- package/src/components/waka-points-popup/index.tsx +366 -0
- package/src/components/waka-power-up/index.tsx +1155 -0
- package/src/components/waka-presence-indicator/index.tsx +1181 -0
- package/src/components/waka-pricing-table/index.tsx +755 -0
- package/src/components/waka-product-card/index.tsx +786 -0
- package/src/components/waka-progress-onboarding/index.tsx +878 -0
- package/src/components/waka-pull-to-refresh/index.tsx +451 -0
- package/src/components/waka-qrcode/index.tsx +232 -0
- package/src/components/waka-quest-card/index.tsx +1275 -0
- package/src/components/waka-quota-bar/index.tsx +693 -0
- package/src/components/waka-radar-score/index.tsx +512 -0
- package/src/components/waka-rank-badge/index.tsx +813 -0
- package/src/components/waka-rating-input/index.tsx +560 -0
- package/src/components/waka-reaction-picker/index.tsx +1062 -0
- package/src/components/waka-region-map/index.tsx +730 -0
- package/src/components/waka-resource-gauge/index.tsx +654 -0
- package/src/components/waka-resource-pool/index.tsx +1035 -0
- package/src/components/waka-rich-text-editor/index.tsx +594 -0
- package/src/components/waka-rollback-slider/index.tsx +891 -0
- package/src/components/waka-sankey-diagram/index.tsx +1032 -0
- package/src/components/waka-schedule-picker/index.tsx +1060 -0
- package/src/components/waka-scratch-card/index.tsx +914 -0
- package/src/components/waka-season-pass/index.tsx +886 -0
- package/src/components/waka-security-score/index.tsx +1126 -0
- package/src/components/waka-segmented-control/index.tsx +238 -0
- package/src/components/waka-server-rack/index.tsx +764 -0
- package/src/components/waka-session-manager/index.tsx +815 -0
- package/src/components/waka-signature-pad/index.tsx +744 -0
- package/src/components/waka-skeleton-wave/index.tsx +454 -0
- package/src/components/waka-skill-tree/index.tsx +1031 -0
- package/src/components/waka-sla-tracker/index.tsx +798 -0
- package/src/components/waka-slider-range/index.tsx +765 -0
- package/src/components/waka-spin-wheel/index.tsx +671 -0
- package/src/components/waka-spinner/index.tsx +284 -0
- package/src/components/waka-spotlight/index.tsx +410 -0
- package/src/components/waka-stat/index.tsx +428 -0
- package/src/components/waka-stats-hexagon/index.tsx +824 -0
- package/src/components/waka-status-matrix/index.tsx +565 -0
- package/src/components/waka-stepper/index.tsx +489 -0
- package/src/components/waka-streak-counter/index.tsx +334 -0
- package/src/components/waka-success-explosion/index.tsx +453 -0
- package/src/components/waka-swipe-card/index.tsx +574 -0
- package/src/components/waka-tabs-morph/index.tsx +509 -0
- package/src/components/waka-tag-input/index.tsx +877 -0
- package/src/components/waka-team-banner/index.tsx +1183 -0
- package/src/components/waka-terminal-output/index.tsx +836 -0
- package/src/components/waka-theme-creator/index.tsx +762 -0
- package/src/components/waka-theme-manager/index.tsx +654 -0
- package/src/components/waka-thread-view/index.tsx +874 -0
- package/src/components/waka-tilt-card/index.tsx +250 -0
- package/src/components/waka-time-picker/index.tsx +479 -0
- package/src/components/waka-timeline/index.tsx +385 -0
- package/src/components/waka-tooltip-tour/index.tsx +855 -0
- package/src/components/waka-tour-guide/index.tsx +920 -0
- package/src/components/waka-tournament-bracket/index.tsx +1276 -0
- package/src/components/waka-tree/index.tsx +557 -0
- package/src/components/waka-treemap-chart/index.tsx +1031 -0
- package/src/components/waka-two-factor-setup/index.tsx +995 -0
- package/src/components/waka-typewriter/index.tsx +566 -0
- package/src/components/waka-typing-indicator/index.tsx +649 -0
- package/src/components/waka-versus-card/index.tsx +1026 -0
- package/src/components/waka-video/index.tsx +557 -0
- package/src/components/waka-video-call/index.tsx +1087 -0
- package/src/components/waka-virtual-list/index.tsx +327 -0
- package/src/components/waka-voice-message/index.tsx +1019 -0
- package/src/components/waka-welcome-modal/index.tsx +790 -0
- package/src/components/waka-xp-bar/index.tsx +799 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WakaLineChart - Graphique en ligne
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as React from "react"
|
|
8
|
+
import { WakaChart } from "./WakaChart"
|
|
9
|
+
import { useChartTheme } from "./hooks/useChartTheme"
|
|
10
|
+
import type { LineChartProps, ChartSeries } from "./types"
|
|
11
|
+
|
|
12
|
+
export interface WakaLineChartProps extends LineChartProps {}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Graphique en ligne avec support multi-séries, courbes, et animations
|
|
16
|
+
*/
|
|
17
|
+
export const WakaLineChart = React.forwardRef<HTMLDivElement, WakaLineChartProps>(
|
|
18
|
+
(
|
|
19
|
+
{
|
|
20
|
+
data,
|
|
21
|
+
dataKeys,
|
|
22
|
+
series,
|
|
23
|
+
variant = "default",
|
|
24
|
+
size = "md",
|
|
25
|
+
height,
|
|
26
|
+
width,
|
|
27
|
+
animation = true,
|
|
28
|
+
animationDuration = 500,
|
|
29
|
+
grid = true,
|
|
30
|
+
tooltip = true,
|
|
31
|
+
legend,
|
|
32
|
+
axis,
|
|
33
|
+
theme: customTheme,
|
|
34
|
+
className,
|
|
35
|
+
style,
|
|
36
|
+
title,
|
|
37
|
+
description,
|
|
38
|
+
loading,
|
|
39
|
+
error,
|
|
40
|
+
onClick,
|
|
41
|
+
responsive = true,
|
|
42
|
+
// Line specific
|
|
43
|
+
curve = "monotone",
|
|
44
|
+
dots = true,
|
|
45
|
+
dotSize = 4,
|
|
46
|
+
activeDot = true,
|
|
47
|
+
strokeWidth = 2,
|
|
48
|
+
},
|
|
49
|
+
ref
|
|
50
|
+
) => {
|
|
51
|
+
const { theme, getColor, tooltipStyles } = useChartTheme(customTheme, variant)
|
|
52
|
+
|
|
53
|
+
// Déterminer les séries à afficher
|
|
54
|
+
const chartSeries = React.useMemo<ChartSeries[]>(() => {
|
|
55
|
+
if (series && series.length > 0) return series
|
|
56
|
+
|
|
57
|
+
if (dataKeys && dataKeys.length > 0) {
|
|
58
|
+
return dataKeys.map((key, index) => ({
|
|
59
|
+
dataKey: key,
|
|
60
|
+
label: key,
|
|
61
|
+
color: getColor(index),
|
|
62
|
+
strokeWidth,
|
|
63
|
+
}))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Default: utiliser "value" si présent
|
|
67
|
+
if (data.length > 0 && "value" in data[0]) {
|
|
68
|
+
return [{ dataKey: "value", label: "Value", color: getColor(0), strokeWidth }]
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Sinon, utiliser toutes les clés numériques
|
|
72
|
+
const sampleItem = data[0]
|
|
73
|
+
if (!sampleItem) return []
|
|
74
|
+
|
|
75
|
+
return Object.keys(sampleItem)
|
|
76
|
+
.filter((key) => key !== "name" && typeof sampleItem[key] === "number")
|
|
77
|
+
.map((key, index) => ({
|
|
78
|
+
dataKey: key,
|
|
79
|
+
label: key,
|
|
80
|
+
color: getColor(index),
|
|
81
|
+
strokeWidth,
|
|
82
|
+
}))
|
|
83
|
+
}, [series, dataKeys, data, getColor, strokeWidth])
|
|
84
|
+
|
|
85
|
+
// Configuration de la légende
|
|
86
|
+
const legendConfig = React.useMemo(() => {
|
|
87
|
+
if (!legend) return null
|
|
88
|
+
if (typeof legend === "boolean") {
|
|
89
|
+
return { enabled: legend, position: "bottom" as const, align: "center" as const }
|
|
90
|
+
}
|
|
91
|
+
return legend
|
|
92
|
+
}, [legend])
|
|
93
|
+
|
|
94
|
+
// Configuration du tooltip
|
|
95
|
+
const tooltipConfig = React.useMemo(() => {
|
|
96
|
+
if (!tooltip) return null
|
|
97
|
+
if (typeof tooltip === "boolean") {
|
|
98
|
+
return { enabled: tooltip }
|
|
99
|
+
}
|
|
100
|
+
return tooltip
|
|
101
|
+
}, [tooltip])
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<WakaChart
|
|
105
|
+
ref={ref}
|
|
106
|
+
variant={variant}
|
|
107
|
+
size={size}
|
|
108
|
+
height={height}
|
|
109
|
+
width={width}
|
|
110
|
+
theme={customTheme}
|
|
111
|
+
className={className}
|
|
112
|
+
style={style}
|
|
113
|
+
title={title}
|
|
114
|
+
description={description}
|
|
115
|
+
loading={loading}
|
|
116
|
+
error={error}
|
|
117
|
+
responsive={responsive}
|
|
118
|
+
>
|
|
119
|
+
{(components) => {
|
|
120
|
+
if (!components) return null
|
|
121
|
+
|
|
122
|
+
const {
|
|
123
|
+
LineChart,
|
|
124
|
+
Line,
|
|
125
|
+
XAxis,
|
|
126
|
+
YAxis,
|
|
127
|
+
CartesianGrid,
|
|
128
|
+
Tooltip,
|
|
129
|
+
Legend,
|
|
130
|
+
} = components
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<LineChart data={data}>
|
|
134
|
+
{grid && (
|
|
135
|
+
<CartesianGrid
|
|
136
|
+
strokeDasharray="3 3"
|
|
137
|
+
stroke={theme.gridColor}
|
|
138
|
+
horizontal={true}
|
|
139
|
+
vertical={false}
|
|
140
|
+
/>
|
|
141
|
+
)}
|
|
142
|
+
|
|
143
|
+
{axis?.showXAxis !== false && (
|
|
144
|
+
<XAxis
|
|
145
|
+
dataKey="name"
|
|
146
|
+
axisLine={{ stroke: theme.axisColor }}
|
|
147
|
+
tickLine={{ stroke: theme.axisColor }}
|
|
148
|
+
tick={{ fill: theme.textColor, fontSize: 12 }}
|
|
149
|
+
tickFormatter={axis?.xAxisFormatter}
|
|
150
|
+
/>
|
|
151
|
+
)}
|
|
152
|
+
|
|
153
|
+
{axis?.showYAxis !== false && (
|
|
154
|
+
<YAxis
|
|
155
|
+
axisLine={{ stroke: theme.axisColor }}
|
|
156
|
+
tickLine={{ stroke: theme.axisColor }}
|
|
157
|
+
tick={{ fill: theme.textColor, fontSize: 12 }}
|
|
158
|
+
tickFormatter={axis?.yAxisFormatter}
|
|
159
|
+
domain={axis?.yAxisDomain}
|
|
160
|
+
unit={axis?.yAxisUnit}
|
|
161
|
+
/>
|
|
162
|
+
)}
|
|
163
|
+
|
|
164
|
+
{tooltipConfig?.enabled !== false && tooltip && (
|
|
165
|
+
<Tooltip
|
|
166
|
+
{...tooltipStyles}
|
|
167
|
+
formatter={
|
|
168
|
+
tooltipConfig && typeof tooltipConfig !== "boolean" && tooltipConfig.formatter
|
|
169
|
+
? (value: unknown, name: string) => {
|
|
170
|
+
const formatted = tooltipConfig.formatter!(
|
|
171
|
+
value as number,
|
|
172
|
+
name,
|
|
173
|
+
data[0]
|
|
174
|
+
)
|
|
175
|
+
return formatted as unknown as [string, string]
|
|
176
|
+
}
|
|
177
|
+
: (value: unknown) => {
|
|
178
|
+
const prefix = tooltipConfig && typeof tooltipConfig !== "boolean" ? tooltipConfig.valuePrefix || "" : ""
|
|
179
|
+
const suffix = tooltipConfig && typeof tooltipConfig !== "boolean" ? tooltipConfig.valueSuffix || "" : ""
|
|
180
|
+
return `${prefix}${value}${suffix}`
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/>
|
|
184
|
+
)}
|
|
185
|
+
|
|
186
|
+
{legendConfig?.enabled && (
|
|
187
|
+
<Legend
|
|
188
|
+
align={legendConfig.align}
|
|
189
|
+
verticalAlign={legendConfig.position === "top" ? "top" : "bottom"}
|
|
190
|
+
wrapperStyle={{ paddingTop: legendConfig.position === "bottom" ? 16 : 0 }}
|
|
191
|
+
/>
|
|
192
|
+
)}
|
|
193
|
+
|
|
194
|
+
{chartSeries.map((s, index) => (
|
|
195
|
+
<Line
|
|
196
|
+
key={s.dataKey}
|
|
197
|
+
dataKey={s.dataKey}
|
|
198
|
+
name={s.label}
|
|
199
|
+
stroke={s.color || getColor(index)}
|
|
200
|
+
strokeWidth={s.strokeWidth || strokeWidth}
|
|
201
|
+
strokeDasharray={s.strokeDasharray}
|
|
202
|
+
type={curve}
|
|
203
|
+
dot={dots ? { r: dotSize, fill: s.color || getColor(index) } : false}
|
|
204
|
+
activeDot={activeDot ? { r: dotSize + 2 } : false}
|
|
205
|
+
animationDuration={animationDuration}
|
|
206
|
+
isAnimationActive={animation}
|
|
207
|
+
/>
|
|
208
|
+
))}
|
|
209
|
+
</LineChart>
|
|
210
|
+
)
|
|
211
|
+
}}
|
|
212
|
+
</WakaChart>
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
WakaLineChart.displayName = "WakaLineChart"
|
|
218
|
+
|
|
219
|
+
export default WakaLineChart
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WakaMiniChart - Mini graphique pour DataTable
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as React from "react"
|
|
8
|
+
import { cn } from "../../utils/cn"
|
|
9
|
+
import { WakaSparkline } from "./WakaSparkline"
|
|
10
|
+
import { TrendingUp, TrendingDown, Minus } from "lucide-react"
|
|
11
|
+
import type { MiniChartProps, ChartDataPoint } from "./types"
|
|
12
|
+
|
|
13
|
+
export interface WakaMiniChartProps extends MiniChartProps {}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Mini graphique optimisé pour les cellules DataTable
|
|
17
|
+
* Affiche une tendance avec sparkline et indicateur de direction
|
|
18
|
+
*/
|
|
19
|
+
export const WakaMiniChart = React.forwardRef<HTMLDivElement, WakaMiniChartProps>(
|
|
20
|
+
(
|
|
21
|
+
{
|
|
22
|
+
data,
|
|
23
|
+
type = "sparkline",
|
|
24
|
+
width = 80,
|
|
25
|
+
height = 24,
|
|
26
|
+
color,
|
|
27
|
+
showTrend = true,
|
|
28
|
+
valueFormatter,
|
|
29
|
+
className,
|
|
30
|
+
},
|
|
31
|
+
ref
|
|
32
|
+
) => {
|
|
33
|
+
// Normaliser les données en tableau de nombres
|
|
34
|
+
const numericData = React.useMemo((): number[] => {
|
|
35
|
+
if (!data || data.length === 0) return []
|
|
36
|
+
|
|
37
|
+
if (typeof data[0] === "number") {
|
|
38
|
+
return data as number[]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return (data as ChartDataPoint[]).map((d) => {
|
|
42
|
+
const val = d.value ?? (Object.values(d).find((v) => typeof v === "number") as number)
|
|
43
|
+
return typeof val === "number" ? val : 0
|
|
44
|
+
})
|
|
45
|
+
}, [data])
|
|
46
|
+
|
|
47
|
+
// Calculer la tendance
|
|
48
|
+
const { trend, trendPercent, currentValue } = React.useMemo(() => {
|
|
49
|
+
if (numericData.length < 2) {
|
|
50
|
+
return {
|
|
51
|
+
trend: "neutral" as const,
|
|
52
|
+
trendPercent: 0,
|
|
53
|
+
currentValue: numericData[0] ?? 0,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const first = numericData[0]
|
|
58
|
+
const last = numericData[numericData.length - 1]
|
|
59
|
+
const diff = last - first
|
|
60
|
+
const percent = first !== 0 ? (diff / first) * 100 : 0
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
trend: diff > 0 ? "up" : diff < 0 ? "down" : "neutral",
|
|
64
|
+
trendPercent: percent,
|
|
65
|
+
currentValue: last,
|
|
66
|
+
}
|
|
67
|
+
}, [numericData])
|
|
68
|
+
|
|
69
|
+
// Couleur par défaut selon la tendance
|
|
70
|
+
const chartColor = React.useMemo(() => {
|
|
71
|
+
if (color) return color
|
|
72
|
+
if (trend === "up") return "hsl(var(--chart-2, 142 76% 36%))"
|
|
73
|
+
if (trend === "down") return "hsl(var(--destructive, 0 84% 60%))"
|
|
74
|
+
return "hsl(var(--muted-foreground, 220 9% 46%))"
|
|
75
|
+
}, [color, trend])
|
|
76
|
+
|
|
77
|
+
// Pas de données
|
|
78
|
+
if (numericData.length === 0) {
|
|
79
|
+
return (
|
|
80
|
+
<div ref={ref} className={cn("flex items-center gap-1 text-muted-foreground", className)}>
|
|
81
|
+
<Minus className="h-3 w-3" />
|
|
82
|
+
</div>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Formater la valeur
|
|
87
|
+
const formattedValue = valueFormatter
|
|
88
|
+
? valueFormatter(currentValue)
|
|
89
|
+
: currentValue.toLocaleString()
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div ref={ref} className={cn("flex items-center gap-2", className)}>
|
|
93
|
+
<WakaSparkline
|
|
94
|
+
data={numericData}
|
|
95
|
+
type={type === "sparkline" ? "line" : type}
|
|
96
|
+
width={width}
|
|
97
|
+
height={height}
|
|
98
|
+
color={chartColor}
|
|
99
|
+
animation={false}
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
{showTrend && (
|
|
103
|
+
<div className="flex items-center gap-1">
|
|
104
|
+
{trend === "up" && (
|
|
105
|
+
<TrendingUp className="h-3 w-3 text-green-600 dark:text-green-400" />
|
|
106
|
+
)}
|
|
107
|
+
{trend === "down" && (
|
|
108
|
+
<TrendingDown className="h-3 w-3 text-red-600 dark:text-red-400" />
|
|
109
|
+
)}
|
|
110
|
+
{trend === "neutral" && (
|
|
111
|
+
<Minus className="h-3 w-3 text-muted-foreground" />
|
|
112
|
+
)}
|
|
113
|
+
<span
|
|
114
|
+
className={cn(
|
|
115
|
+
"text-xs font-medium",
|
|
116
|
+
trend === "up" && "text-green-600 dark:text-green-400",
|
|
117
|
+
trend === "down" && "text-red-600 dark:text-red-400",
|
|
118
|
+
trend === "neutral" && "text-muted-foreground"
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
121
|
+
{trend !== "neutral" && (trendPercent > 0 ? "+" : "")}
|
|
122
|
+
{trendPercent.toFixed(1)}%
|
|
123
|
+
</span>
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
126
|
+
</div>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
WakaMiniChart.displayName = "WakaMiniChart"
|
|
132
|
+
|
|
133
|
+
export default WakaMiniChart
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WakaPieChart - Graphique camembert/donut
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import * as React from "react"
|
|
8
|
+
import { WakaChart } from "./WakaChart"
|
|
9
|
+
import { useChartTheme } from "./hooks/useChartTheme"
|
|
10
|
+
import type { PieChartProps } from "./types"
|
|
11
|
+
|
|
12
|
+
export interface WakaPieChartProps extends PieChartProps {}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Graphique camembert/donut avec labels, animations, et interactivité
|
|
16
|
+
*/
|
|
17
|
+
export const WakaPieChart = React.forwardRef<HTMLDivElement, WakaPieChartProps>(
|
|
18
|
+
(
|
|
19
|
+
{
|
|
20
|
+
data,
|
|
21
|
+
variant = "default",
|
|
22
|
+
size = "md",
|
|
23
|
+
height,
|
|
24
|
+
width,
|
|
25
|
+
animation = true,
|
|
26
|
+
animationDuration = 500,
|
|
27
|
+
tooltip = true,
|
|
28
|
+
legend = true,
|
|
29
|
+
theme: customTheme,
|
|
30
|
+
className,
|
|
31
|
+
style,
|
|
32
|
+
title,
|
|
33
|
+
description,
|
|
34
|
+
loading,
|
|
35
|
+
error,
|
|
36
|
+
onClick,
|
|
37
|
+
responsive = true,
|
|
38
|
+
// Pie specific
|
|
39
|
+
dataKey = "value",
|
|
40
|
+
nameKey = "name",
|
|
41
|
+
innerRadius = 0,
|
|
42
|
+
outerRadius = "80%",
|
|
43
|
+
startAngle = 90,
|
|
44
|
+
endAngle = -270,
|
|
45
|
+
paddingAngle = 2,
|
|
46
|
+
label = false,
|
|
47
|
+
labelPosition = "outside",
|
|
48
|
+
},
|
|
49
|
+
ref
|
|
50
|
+
) => {
|
|
51
|
+
const { theme, getColor, tooltipStyles } = useChartTheme(customTheme, variant)
|
|
52
|
+
|
|
53
|
+
// Configuration de la légende
|
|
54
|
+
const legendConfig = React.useMemo(() => {
|
|
55
|
+
if (!legend) return null
|
|
56
|
+
if (typeof legend === "boolean") {
|
|
57
|
+
return { enabled: legend, position: "bottom" as const, align: "center" as const }
|
|
58
|
+
}
|
|
59
|
+
return legend
|
|
60
|
+
}, [legend])
|
|
61
|
+
|
|
62
|
+
// Configuration du tooltip
|
|
63
|
+
const tooltipConfig = React.useMemo(() => {
|
|
64
|
+
if (!tooltip) return null
|
|
65
|
+
if (typeof tooltip === "boolean") {
|
|
66
|
+
return { enabled: tooltip }
|
|
67
|
+
}
|
|
68
|
+
return tooltip
|
|
69
|
+
}, [tooltip])
|
|
70
|
+
|
|
71
|
+
// Fonction de rendu des labels
|
|
72
|
+
const renderLabel = React.useCallback(
|
|
73
|
+
(props: {
|
|
74
|
+
cx: number
|
|
75
|
+
cy: number
|
|
76
|
+
midAngle: number
|
|
77
|
+
innerRadius: number
|
|
78
|
+
outerRadius: number
|
|
79
|
+
percent: number
|
|
80
|
+
value: number
|
|
81
|
+
name: string
|
|
82
|
+
index: number
|
|
83
|
+
}) => {
|
|
84
|
+
if (!label) return null
|
|
85
|
+
|
|
86
|
+
const RADIAN = Math.PI / 180
|
|
87
|
+
const radius = labelPosition === "inside"
|
|
88
|
+
? props.innerRadius + (props.outerRadius - props.innerRadius) * 0.5
|
|
89
|
+
: props.outerRadius * 1.1
|
|
90
|
+
const x = props.cx + radius * Math.cos(-props.midAngle * RADIAN)
|
|
91
|
+
const y = props.cy + radius * Math.sin(-props.midAngle * RADIAN)
|
|
92
|
+
|
|
93
|
+
let text = ""
|
|
94
|
+
if (label === "percent") {
|
|
95
|
+
text = `${(props.percent * 100).toFixed(0)}%`
|
|
96
|
+
} else if (label === "value") {
|
|
97
|
+
text = String(props.value)
|
|
98
|
+
} else if (label === "name") {
|
|
99
|
+
text = props.name
|
|
100
|
+
} else {
|
|
101
|
+
text = `${(props.percent * 100).toFixed(0)}%`
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<text
|
|
106
|
+
x={x}
|
|
107
|
+
y={y}
|
|
108
|
+
fill={labelPosition === "inside" ? "#fff" : theme.textColor}
|
|
109
|
+
textAnchor={x > props.cx ? "start" : "end"}
|
|
110
|
+
dominantBaseline="central"
|
|
111
|
+
fontSize={12}
|
|
112
|
+
>
|
|
113
|
+
{text}
|
|
114
|
+
</text>
|
|
115
|
+
)
|
|
116
|
+
},
|
|
117
|
+
[label, labelPosition, theme.textColor]
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<WakaChart
|
|
122
|
+
ref={ref}
|
|
123
|
+
variant={variant}
|
|
124
|
+
size={size}
|
|
125
|
+
height={height}
|
|
126
|
+
width={width}
|
|
127
|
+
theme={customTheme}
|
|
128
|
+
className={className}
|
|
129
|
+
style={style}
|
|
130
|
+
title={title}
|
|
131
|
+
description={description}
|
|
132
|
+
loading={loading}
|
|
133
|
+
error={error}
|
|
134
|
+
responsive={responsive}
|
|
135
|
+
>
|
|
136
|
+
{(components) => {
|
|
137
|
+
if (!components) return null
|
|
138
|
+
|
|
139
|
+
const {
|
|
140
|
+
PieChart,
|
|
141
|
+
Pie,
|
|
142
|
+
Cell,
|
|
143
|
+
Tooltip,
|
|
144
|
+
Legend,
|
|
145
|
+
} = components
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<PieChart>
|
|
149
|
+
{tooltipConfig?.enabled !== false && tooltip && (
|
|
150
|
+
<Tooltip
|
|
151
|
+
{...tooltipStyles}
|
|
152
|
+
formatter={
|
|
153
|
+
tooltipConfig && typeof tooltipConfig !== "boolean" && tooltipConfig.formatter
|
|
154
|
+
? (value: unknown, name: string) => {
|
|
155
|
+
const formatted = tooltipConfig.formatter!(
|
|
156
|
+
value as number,
|
|
157
|
+
name,
|
|
158
|
+
data[0]
|
|
159
|
+
)
|
|
160
|
+
return formatted as unknown as [string, string]
|
|
161
|
+
}
|
|
162
|
+
: (value: unknown) => {
|
|
163
|
+
const prefix = tooltipConfig && typeof tooltipConfig !== "boolean" ? tooltipConfig.valuePrefix || "" : ""
|
|
164
|
+
const suffix = tooltipConfig && typeof tooltipConfig !== "boolean" ? tooltipConfig.valueSuffix || "" : ""
|
|
165
|
+
return `${prefix}${value}${suffix}`
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/>
|
|
169
|
+
)}
|
|
170
|
+
|
|
171
|
+
{legendConfig?.enabled && (
|
|
172
|
+
<Legend
|
|
173
|
+
align={legendConfig.align}
|
|
174
|
+
verticalAlign={legendConfig.position === "top" ? "top" : "bottom"}
|
|
175
|
+
layout={legendConfig.position === "left" || legendConfig.position === "right" ? "vertical" : "horizontal"}
|
|
176
|
+
wrapperStyle={{ paddingTop: legendConfig.position === "bottom" ? 16 : 0 }}
|
|
177
|
+
/>
|
|
178
|
+
)}
|
|
179
|
+
|
|
180
|
+
<Pie
|
|
181
|
+
data={data}
|
|
182
|
+
dataKey={dataKey}
|
|
183
|
+
nameKey={nameKey}
|
|
184
|
+
cx="50%"
|
|
185
|
+
cy="50%"
|
|
186
|
+
innerRadius={innerRadius}
|
|
187
|
+
outerRadius={outerRadius}
|
|
188
|
+
startAngle={startAngle}
|
|
189
|
+
endAngle={endAngle}
|
|
190
|
+
paddingAngle={paddingAngle}
|
|
191
|
+
animationDuration={animationDuration}
|
|
192
|
+
isAnimationActive={animation}
|
|
193
|
+
label={label ? renderLabel : false}
|
|
194
|
+
labelLine={label && labelPosition === "outside"}
|
|
195
|
+
>
|
|
196
|
+
{data.map((entry, index) => (
|
|
197
|
+
<Cell
|
|
198
|
+
key={`cell-${index}`}
|
|
199
|
+
fill={getColor(index)}
|
|
200
|
+
stroke="transparent"
|
|
201
|
+
/>
|
|
202
|
+
))}
|
|
203
|
+
</Pie>
|
|
204
|
+
</PieChart>
|
|
205
|
+
)
|
|
206
|
+
}}
|
|
207
|
+
</WakaChart>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
WakaPieChart.displayName = "WakaPieChart"
|
|
213
|
+
|
|
214
|
+
export default WakaPieChart
|