@wakastellar/ui 2.0.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/README.md +71 -8
  2. package/dist/cli/commands/add.d.ts +7 -0
  3. package/dist/cli/commands/init.d.ts +6 -0
  4. package/dist/cli/commands/list.d.ts +5 -0
  5. package/dist/cli/commands/search.d.ts +1 -0
  6. package/dist/cli/index.cjs +6014 -0
  7. package/dist/cli/index.d.ts +1 -0
  8. package/dist/cli/utils/config.d.ts +29 -0
  9. package/dist/cli/utils/logger.d.ts +20 -0
  10. package/dist/cli/utils/registry.d.ts +23 -0
  11. package/package.json +14 -3
  12. package/src/blocks/activity-timeline/index.tsx +586 -0
  13. package/src/blocks/calendar-view/index.tsx +756 -0
  14. package/src/blocks/chat/index.tsx +1018 -0
  15. package/src/blocks/chat/widget.tsx +504 -0
  16. package/src/blocks/dashboard/index.tsx +522 -0
  17. package/src/blocks/empty-states/index.tsx +452 -0
  18. package/src/blocks/error-pages/index.tsx +426 -0
  19. package/src/blocks/faq/index.tsx +479 -0
  20. package/src/blocks/file-manager/index.tsx +890 -0
  21. package/src/blocks/footer/index.tsx +133 -0
  22. package/src/blocks/header/index.tsx +357 -0
  23. package/src/blocks/headtab/index.tsx +139 -0
  24. package/src/blocks/i18n-editor/index.tsx +1016 -0
  25. package/src/blocks/index.ts +80 -0
  26. package/src/blocks/kanban-board/index.tsx +779 -0
  27. package/src/blocks/landing/index.tsx +677 -0
  28. package/src/blocks/language-selector/index.tsx +88 -0
  29. package/src/blocks/layout/index.tsx +159 -0
  30. package/src/blocks/login/index.tsx +339 -0
  31. package/src/blocks/login/types.ts +131 -0
  32. package/src/blocks/pricing/index.tsx +564 -0
  33. package/src/blocks/profile/index.tsx +746 -0
  34. package/src/blocks/settings/index.tsx +558 -0
  35. package/src/blocks/sidebar/index.tsx +713 -0
  36. package/src/blocks/theme-creator-block/index.tsx +835 -0
  37. package/src/blocks/user-management/index.tsx +1037 -0
  38. package/src/blocks/wizard/index.tsx +719 -0
  39. package/src/components/DataTable/DataTable.tsx +406 -0
  40. package/src/components/DataTable/DataTableAdvanced.tsx +720 -0
  41. package/src/components/DataTable/DataTableBody.tsx +216 -0
  42. package/src/components/DataTable/DataTableCell.tsx +172 -0
  43. package/src/components/DataTable/DataTableColumnResizer.tsx +62 -0
  44. package/src/components/DataTable/DataTableConflictResolver.tsx +478 -0
  45. package/src/components/DataTable/DataTableContextMenu.tsx +219 -0
  46. package/src/components/DataTable/DataTableEditCell.tsx +279 -0
  47. package/src/components/DataTable/DataTableFilterBuilder.tsx +519 -0
  48. package/src/components/DataTable/DataTableFilters.tsx +535 -0
  49. package/src/components/DataTable/DataTableGrouping.tsx +147 -0
  50. package/src/components/DataTable/DataTableHeader.tsx +172 -0
  51. package/src/components/DataTable/DataTablePagination.tsx +125 -0
  52. package/src/components/DataTable/DataTableSelection.tsx +269 -0
  53. package/src/components/DataTable/DataTableSyncStatus.tsx +281 -0
  54. package/src/components/DataTable/DataTableToolbar.tsx +262 -0
  55. package/src/components/DataTable/README.md +446 -0
  56. package/src/components/DataTable/__tests__/DataTableAdvanced.test.tsx +426 -0
  57. package/src/components/DataTable/__tests__/DataTableEdit.test.tsx +329 -0
  58. package/src/components/DataTable/__tests__/useDataTableAdvanced.test.ts +455 -0
  59. package/src/components/DataTable/examples/EditExample.tsx +166 -0
  60. package/src/components/DataTable/formatters/index.ts +335 -0
  61. package/src/components/DataTable/hooks/__tests__/useDataTableEdit.test.ts +239 -0
  62. package/src/components/DataTable/hooks/useDataTable.ts +145 -0
  63. package/src/components/DataTable/hooks/useDataTableAdvanced.ts +342 -0
  64. package/src/components/DataTable/hooks/useDataTableAdvancedFilters.ts +637 -0
  65. package/src/components/DataTable/hooks/useDataTableColumnTemplates.ts +186 -0
  66. package/src/components/DataTable/hooks/useDataTableEdit.ts +167 -0
  67. package/src/components/DataTable/hooks/useDataTableExport.ts +227 -0
  68. package/src/components/DataTable/hooks/useDataTableImport.ts +216 -0
  69. package/src/components/DataTable/hooks/useDataTableOffline.ts +481 -0
  70. package/src/components/DataTable/hooks/useDataTableTheme.ts +213 -0
  71. package/src/components/DataTable/hooks/useDataTableVirtualization.ts +99 -0
  72. package/src/components/DataTable/hooks/useTableLayout.ts +85 -0
  73. package/src/components/DataTable/index.ts +81 -0
  74. package/src/components/DataTable/services/IndexedDBService.ts +504 -0
  75. package/src/components/DataTable/templates/index.tsx +803 -0
  76. package/src/components/DataTable/types.ts +504 -0
  77. package/src/components/DataTable/utils.ts +164 -0
  78. package/src/components/DataTable/workers/exportWorker.ts +213 -0
  79. package/src/components/accordion/index.tsx +61 -0
  80. package/src/components/alert/index.tsx +61 -0
  81. package/src/components/alert-dialog/index.tsx +146 -0
  82. package/src/components/aspect-ratio/index.tsx +12 -0
  83. package/src/components/avatar/index.tsx +54 -0
  84. package/src/components/badge/Badge.stories.tsx +64 -0
  85. package/src/components/badge/index.tsx +38 -0
  86. package/src/components/button/Button.stories.tsx +173 -0
  87. package/src/components/button/index.tsx +56 -0
  88. package/src/components/calendar/index.tsx +73 -0
  89. package/src/components/card/index.tsx +78 -0
  90. package/src/components/checkbox/index.tsx +34 -0
  91. package/src/components/code/index.tsx +229 -0
  92. package/src/components/collapsible/index.tsx +16 -0
  93. package/src/components/command/index.tsx +162 -0
  94. package/src/components/context-menu/index.tsx +204 -0
  95. package/src/components/dialog/index.tsx +126 -0
  96. package/src/components/dropdown-menu/index.tsx +204 -0
  97. package/src/components/error-boundary/ErrorBoundary.tsx +281 -0
  98. package/src/components/error-boundary/index.ts +7 -0
  99. package/src/components/form/index.tsx +183 -0
  100. package/src/components/hover-card/index.tsx +33 -0
  101. package/src/components/index.ts +368 -0
  102. package/src/components/input/Input.stories.tsx +100 -0
  103. package/src/components/input/index.tsx +27 -0
  104. package/src/components/input-otp/index.tsx +277 -0
  105. package/src/components/label/index.tsx +30 -0
  106. package/src/components/language-selector/index.tsx +341 -0
  107. package/src/components/menubar/index.tsx +240 -0
  108. package/src/components/navigation-menu/index.tsx +134 -0
  109. package/src/components/popover/index.tsx +35 -0
  110. package/src/components/progress/index.tsx +32 -0
  111. package/src/components/radio-group/index.tsx +48 -0
  112. package/src/components/scroll-area/index.tsx +52 -0
  113. package/src/components/select/index.tsx +164 -0
  114. package/src/components/separator/index.tsx +35 -0
  115. package/src/components/sheet/index.tsx +147 -0
  116. package/src/components/skeleton/index.tsx +22 -0
  117. package/src/components/slider/index.tsx +32 -0
  118. package/src/components/switch/index.tsx +33 -0
  119. package/src/components/table/index.tsx +117 -0
  120. package/src/components/tabs/index.tsx +59 -0
  121. package/src/components/textarea/index.tsx +30 -0
  122. package/src/components/theme-selector/index.tsx +327 -0
  123. package/src/components/toast/index.tsx +133 -0
  124. package/src/components/toaster/index.tsx +34 -0
  125. package/src/components/toggle/index.tsx +49 -0
  126. package/src/components/tooltip/index.tsx +34 -0
  127. package/src/components/typography/index.tsx +276 -0
  128. package/src/components/waka-3d-pie-chart/index.tsx +486 -0
  129. package/src/components/waka-achievement-unlock/index.tsx +716 -0
  130. package/src/components/waka-activity-feed/index.tsx +686 -0
  131. package/src/components/waka-address-autocomplete/index.tsx +1202 -0
  132. package/src/components/waka-admincrumb/index.tsx +349 -0
  133. package/src/components/waka-alert-stack/index.tsx +827 -0
  134. package/src/components/waka-allocation-matrix/index.tsx +1278 -0
  135. package/src/components/waka-approval-chain/index.tsx +766 -0
  136. package/src/components/waka-audit-log/index.tsx +1475 -0
  137. package/src/components/waka-autocomplete/index.tsx +358 -0
  138. package/src/components/waka-badge-showcase/index.tsx +704 -0
  139. package/src/components/waka-barcode/index.tsx +260 -0
  140. package/src/components/waka-biometric-prompt/index.tsx +765 -0
  141. package/src/components/waka-bottom-sheet/index.tsx +495 -0
  142. package/src/components/waka-breadcrumb/index.tsx +376 -0
  143. package/src/components/waka-breadcrumb-path/index.tsx +513 -0
  144. package/src/components/waka-budget-burn/index.tsx +1234 -0
  145. package/src/components/waka-capacity-planner/index.tsx +1107 -0
  146. package/src/components/waka-carousel/index.tsx +893 -0
  147. package/src/components/waka-cart-summary/index.tsx +1055 -0
  148. package/src/components/waka-challenge-timer/index.tsx +1044 -0
  149. package/src/components/waka-charts/WakaAreaChart.tsx +251 -0
  150. package/src/components/waka-charts/WakaBarChart.tsx +222 -0
  151. package/src/components/waka-charts/WakaChart.tsx +124 -0
  152. package/src/components/waka-charts/WakaLineChart.tsx +219 -0
  153. package/src/components/waka-charts/WakaMiniChart.tsx +133 -0
  154. package/src/components/waka-charts/WakaPieChart.tsx +214 -0
  155. package/src/components/waka-charts/WakaSparkline.tsx +229 -0
  156. package/src/components/waka-charts/dataTableHelpers.ts +109 -0
  157. package/src/components/waka-charts/hooks/useChartTheme.ts +123 -0
  158. package/src/components/waka-charts/hooks/useRechartsLoader.ts +234 -0
  159. package/src/components/waka-charts/index.ts +90 -0
  160. package/src/components/waka-charts/types.ts +330 -0
  161. package/src/components/waka-chat-bubble/index.tsx +1060 -0
  162. package/src/components/waka-checklist/index.tsx +1067 -0
  163. package/src/components/waka-checkout-stepper/index.tsx +976 -0
  164. package/src/components/waka-cohort-table/index.tsx +1011 -0
  165. package/src/components/waka-color-picker/index.tsx +447 -0
  166. package/src/components/waka-combo-counter/index.tsx +864 -0
  167. package/src/components/waka-combobox/index.tsx +497 -0
  168. package/src/components/waka-command-bar/index.tsx +403 -0
  169. package/src/components/waka-compare-period/index.tsx +1230 -0
  170. package/src/components/waka-connection-matrix/index.tsx +1053 -0
  171. package/src/components/waka-contribution-graph/index.tsx +552 -0
  172. package/src/components/waka-cost-breakdown/index.tsx +1065 -0
  173. package/src/components/waka-coupon-input/index.tsx +592 -0
  174. package/src/components/waka-credit-card-input/index.tsx +982 -0
  175. package/src/components/waka-daily-reward/index.tsx +762 -0
  176. package/src/components/waka-date-range-picker/index.tsx +378 -0
  177. package/src/components/waka-datetime-picker/index.tsx +793 -0
  178. package/src/components/waka-datetime-picker.form-integration/index.tsx +402 -0
  179. package/src/components/waka-deployment-lane/index.tsx +673 -0
  180. package/src/components/waka-device-trust/index.tsx +1259 -0
  181. package/src/components/waka-dock/index.tsx +285 -0
  182. package/src/components/waka-drawer/index.tsx +319 -0
  183. package/src/components/waka-empty-state/index.tsx +545 -0
  184. package/src/components/waka-error-shake/index.tsx +398 -0
  185. package/src/components/waka-feature-announcement/index.tsx +991 -0
  186. package/src/components/waka-file-upload/index.tsx +437 -0
  187. package/src/components/waka-floating-nav/index.tsx +413 -0
  188. package/src/components/waka-flow-diagram/index.tsx +508 -0
  189. package/src/components/waka-funnel-chart/index.tsx +823 -0
  190. package/src/components/waka-glow-card/index.tsx +246 -0
  191. package/src/components/waka-goal-progress/index.tsx +1025 -0
  192. package/src/components/waka-haptic-button/index.tsx +388 -0
  193. package/src/components/waka-health-pulse/index.tsx +451 -0
  194. package/src/components/waka-heatmap/index.tsx +1026 -0
  195. package/src/components/waka-hotspot/index.tsx +682 -0
  196. package/src/components/waka-image/index.tsx +373 -0
  197. package/src/components/waka-incident-timeline/index.tsx +686 -0
  198. package/src/components/waka-invoice-preview/index.tsx +829 -0
  199. package/src/components/waka-kanban/index.tsx +646 -0
  200. package/src/components/waka-kpi-dashboard/index.tsx +755 -0
  201. package/src/components/waka-leaderboard/index.tsx +746 -0
  202. package/src/components/waka-level-progress/index.tsx +665 -0
  203. package/src/components/waka-liquid-button/index.tsx +520 -0
  204. package/src/components/waka-loading-orbit/index.tsx +478 -0
  205. package/src/components/waka-loot-box/index.tsx +1091 -0
  206. package/src/components/waka-magic-link/index.tsx +321 -0
  207. package/src/components/waka-magnetic-button/index.tsx +567 -0
  208. package/src/components/waka-mention-input/index.tsx +953 -0
  209. package/src/components/waka-metric-sparkline/index.tsx +627 -0
  210. package/src/components/waka-milestone-road/index.tsx +1064 -0
  211. package/src/components/waka-modal/index.tsx +374 -0
  212. package/src/components/waka-morph-button/index.tsx +495 -0
  213. package/src/components/waka-network-topology/index.tsx +801 -0
  214. package/src/components/waka-notifications/index.tsx +414 -0
  215. package/src/components/waka-number-input/index.tsx +373 -0
  216. package/src/components/waka-orbital-menu/index.tsx +445 -0
  217. package/src/components/waka-order-tracker/index.tsx +1041 -0
  218. package/src/components/waka-pagination/index.tsx +393 -0
  219. package/src/components/waka-password-strength/index.tsx +824 -0
  220. package/src/components/waka-payment-method-picker/index.tsx +715 -0
  221. package/src/components/waka-permission-matrix/index.tsx +1302 -0
  222. package/src/components/waka-phone-input/index.tsx +801 -0
  223. package/src/components/waka-pipeline-view/index.tsx +604 -0
  224. package/src/components/waka-player-card/index.tsx +691 -0
  225. package/src/components/waka-points-popup/index.tsx +366 -0
  226. package/src/components/waka-power-up/index.tsx +1155 -0
  227. package/src/components/waka-presence-indicator/index.tsx +1181 -0
  228. package/src/components/waka-pricing-table/index.tsx +755 -0
  229. package/src/components/waka-product-card/index.tsx +786 -0
  230. package/src/components/waka-progress-onboarding/index.tsx +878 -0
  231. package/src/components/waka-pull-to-refresh/index.tsx +451 -0
  232. package/src/components/waka-qrcode/index.tsx +232 -0
  233. package/src/components/waka-quest-card/index.tsx +1275 -0
  234. package/src/components/waka-quota-bar/index.tsx +693 -0
  235. package/src/components/waka-radar-score/index.tsx +512 -0
  236. package/src/components/waka-rank-badge/index.tsx +813 -0
  237. package/src/components/waka-rating-input/index.tsx +560 -0
  238. package/src/components/waka-reaction-picker/index.tsx +1062 -0
  239. package/src/components/waka-region-map/index.tsx +730 -0
  240. package/src/components/waka-resource-gauge/index.tsx +654 -0
  241. package/src/components/waka-resource-pool/index.tsx +1035 -0
  242. package/src/components/waka-rich-text-editor/index.tsx +594 -0
  243. package/src/components/waka-rollback-slider/index.tsx +891 -0
  244. package/src/components/waka-sankey-diagram/index.tsx +1032 -0
  245. package/src/components/waka-schedule-picker/index.tsx +1060 -0
  246. package/src/components/waka-scratch-card/index.tsx +914 -0
  247. package/src/components/waka-season-pass/index.tsx +886 -0
  248. package/src/components/waka-security-score/index.tsx +1126 -0
  249. package/src/components/waka-segmented-control/index.tsx +238 -0
  250. package/src/components/waka-server-rack/index.tsx +764 -0
  251. package/src/components/waka-session-manager/index.tsx +815 -0
  252. package/src/components/waka-signature-pad/index.tsx +744 -0
  253. package/src/components/waka-skeleton-wave/index.tsx +454 -0
  254. package/src/components/waka-skill-tree/index.tsx +1031 -0
  255. package/src/components/waka-sla-tracker/index.tsx +798 -0
  256. package/src/components/waka-slider-range/index.tsx +765 -0
  257. package/src/components/waka-spin-wheel/index.tsx +671 -0
  258. package/src/components/waka-spinner/index.tsx +284 -0
  259. package/src/components/waka-spotlight/index.tsx +410 -0
  260. package/src/components/waka-stat/index.tsx +428 -0
  261. package/src/components/waka-stats-hexagon/index.tsx +824 -0
  262. package/src/components/waka-status-matrix/index.tsx +565 -0
  263. package/src/components/waka-stepper/index.tsx +489 -0
  264. package/src/components/waka-streak-counter/index.tsx +334 -0
  265. package/src/components/waka-success-explosion/index.tsx +453 -0
  266. package/src/components/waka-swipe-card/index.tsx +574 -0
  267. package/src/components/waka-tabs-morph/index.tsx +509 -0
  268. package/src/components/waka-tag-input/index.tsx +877 -0
  269. package/src/components/waka-team-banner/index.tsx +1183 -0
  270. package/src/components/waka-terminal-output/index.tsx +836 -0
  271. package/src/components/waka-theme-creator/index.tsx +762 -0
  272. package/src/components/waka-theme-manager/index.tsx +654 -0
  273. package/src/components/waka-thread-view/index.tsx +874 -0
  274. package/src/components/waka-tilt-card/index.tsx +250 -0
  275. package/src/components/waka-time-picker/index.tsx +479 -0
  276. package/src/components/waka-timeline/index.tsx +385 -0
  277. package/src/components/waka-tooltip-tour/index.tsx +855 -0
  278. package/src/components/waka-tour-guide/index.tsx +920 -0
  279. package/src/components/waka-tournament-bracket/index.tsx +1276 -0
  280. package/src/components/waka-tree/index.tsx +557 -0
  281. package/src/components/waka-treemap-chart/index.tsx +1031 -0
  282. package/src/components/waka-two-factor-setup/index.tsx +995 -0
  283. package/src/components/waka-typewriter/index.tsx +566 -0
  284. package/src/components/waka-typing-indicator/index.tsx +649 -0
  285. package/src/components/waka-versus-card/index.tsx +1026 -0
  286. package/src/components/waka-video/index.tsx +557 -0
  287. package/src/components/waka-video-call/index.tsx +1087 -0
  288. package/src/components/waka-virtual-list/index.tsx +327 -0
  289. package/src/components/waka-voice-message/index.tsx +1019 -0
  290. package/src/components/waka-welcome-modal/index.tsx +790 -0
  291. package/src/components/waka-xp-bar/index.tsx +799 -0
@@ -0,0 +1,251 @@
1
+ "use client"
2
+
3
+ /**
4
+ * WakaAreaChart - Graphique en aire
5
+ */
6
+
7
+ import * as React from "react"
8
+ import { WakaChart } from "./WakaChart"
9
+ import { useChartTheme } from "./hooks/useChartTheme"
10
+ import type { AreaChartProps, ChartSeries } from "./types"
11
+
12
+ export interface WakaAreaChartProps extends AreaChartProps {}
13
+
14
+ /**
15
+ * Graphique en aire avec support multi-séries, empilé, gradients, et animations
16
+ */
17
+ export const WakaAreaChart = React.forwardRef<HTMLDivElement, WakaAreaChartProps>(
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/Area specific
43
+ curve = "monotone",
44
+ dots = false,
45
+ dotSize = 4,
46
+ activeDot = true,
47
+ strokeWidth = 2,
48
+ // Area specific
49
+ stacked = false,
50
+ fillOpacity = 0.3,
51
+ gradientDirection = "vertical",
52
+ },
53
+ ref
54
+ ) => {
55
+ const { theme, getColor, tooltipStyles } = useChartTheme(customTheme, variant)
56
+
57
+ // Déterminer les séries à afficher
58
+ const chartSeries = React.useMemo<ChartSeries[]>(() => {
59
+ if (series && series.length > 0) return series
60
+
61
+ if (dataKeys && dataKeys.length > 0) {
62
+ return dataKeys.map((key, index) => ({
63
+ dataKey: key,
64
+ label: key,
65
+ color: getColor(index),
66
+ strokeWidth,
67
+ fillOpacity,
68
+ }))
69
+ }
70
+
71
+ // Default: utiliser "value" si présent
72
+ if (data.length > 0 && "value" in data[0]) {
73
+ return [{ dataKey: "value", label: "Value", color: getColor(0), strokeWidth, fillOpacity }]
74
+ }
75
+
76
+ // Sinon, utiliser toutes les clés numériques
77
+ const sampleItem = data[0]
78
+ if (!sampleItem) return []
79
+
80
+ return Object.keys(sampleItem)
81
+ .filter((key) => key !== "name" && typeof sampleItem[key] === "number")
82
+ .map((key, index) => ({
83
+ dataKey: key,
84
+ label: key,
85
+ color: getColor(index),
86
+ strokeWidth,
87
+ fillOpacity,
88
+ }))
89
+ }, [series, dataKeys, data, getColor, strokeWidth, fillOpacity])
90
+
91
+ // Configuration de la légende
92
+ const legendConfig = React.useMemo(() => {
93
+ if (!legend) return null
94
+ if (typeof legend === "boolean") {
95
+ return { enabled: legend, position: "bottom" as const, align: "center" as const }
96
+ }
97
+ return legend
98
+ }, [legend])
99
+
100
+ // Configuration du tooltip
101
+ const tooltipConfig = React.useMemo(() => {
102
+ if (!tooltip) return null
103
+ if (typeof tooltip === "boolean") {
104
+ return { enabled: tooltip }
105
+ }
106
+ return tooltip
107
+ }, [tooltip])
108
+
109
+ return (
110
+ <WakaChart
111
+ ref={ref}
112
+ variant={variant}
113
+ size={size}
114
+ height={height}
115
+ width={width}
116
+ theme={customTheme}
117
+ className={className}
118
+ style={style}
119
+ title={title}
120
+ description={description}
121
+ loading={loading}
122
+ error={error}
123
+ responsive={responsive}
124
+ >
125
+ {(components) => {
126
+ if (!components) return null
127
+
128
+ const {
129
+ AreaChart,
130
+ Area,
131
+ XAxis,
132
+ YAxis,
133
+ CartesianGrid,
134
+ Tooltip,
135
+ Legend,
136
+ } = components
137
+
138
+ return (
139
+ <AreaChart data={data}>
140
+ {/* Gradients */}
141
+ <defs>
142
+ {chartSeries.map((s, index) => {
143
+ const color = s.color || getColor(index)
144
+ const gradientId = `gradient-${s.dataKey}-${index}`
145
+ return (
146
+ <linearGradient
147
+ key={gradientId}
148
+ id={gradientId}
149
+ x1={gradientDirection === "horizontal" ? "0" : "0"}
150
+ y1={gradientDirection === "horizontal" ? "0" : "0"}
151
+ x2={gradientDirection === "horizontal" ? "1" : "0"}
152
+ y2={gradientDirection === "horizontal" ? "0" : "1"}
153
+ >
154
+ <stop offset="5%" stopColor={color} stopOpacity={0.8} />
155
+ <stop offset="95%" stopColor={color} stopOpacity={0.1} />
156
+ </linearGradient>
157
+ )
158
+ })}
159
+ </defs>
160
+
161
+ {grid && (
162
+ <CartesianGrid
163
+ strokeDasharray="3 3"
164
+ stroke={theme.gridColor}
165
+ horizontal={true}
166
+ vertical={false}
167
+ />
168
+ )}
169
+
170
+ {axis?.showXAxis !== false && (
171
+ <XAxis
172
+ dataKey="name"
173
+ axisLine={{ stroke: theme.axisColor }}
174
+ tickLine={{ stroke: theme.axisColor }}
175
+ tick={{ fill: theme.textColor, fontSize: 12 }}
176
+ tickFormatter={axis?.xAxisFormatter}
177
+ />
178
+ )}
179
+
180
+ {axis?.showYAxis !== false && (
181
+ <YAxis
182
+ axisLine={{ stroke: theme.axisColor }}
183
+ tickLine={{ stroke: theme.axisColor }}
184
+ tick={{ fill: theme.textColor, fontSize: 12 }}
185
+ tickFormatter={axis?.yAxisFormatter}
186
+ domain={axis?.yAxisDomain}
187
+ unit={axis?.yAxisUnit}
188
+ />
189
+ )}
190
+
191
+ {tooltipConfig?.enabled !== false && tooltip && (
192
+ <Tooltip
193
+ {...tooltipStyles}
194
+ formatter={
195
+ tooltipConfig && typeof tooltipConfig !== "boolean" && tooltipConfig.formatter
196
+ ? (value: unknown, name: string) => {
197
+ const formatted = tooltipConfig.formatter!(
198
+ value as number,
199
+ name,
200
+ data[0]
201
+ )
202
+ return formatted as unknown as [string, string]
203
+ }
204
+ : (value: unknown) => {
205
+ const prefix = tooltipConfig && typeof tooltipConfig !== "boolean" ? tooltipConfig.valuePrefix || "" : ""
206
+ const suffix = tooltipConfig && typeof tooltipConfig !== "boolean" ? tooltipConfig.valueSuffix || "" : ""
207
+ return `${prefix}${value}${suffix}`
208
+ }
209
+ }
210
+ />
211
+ )}
212
+
213
+ {legendConfig?.enabled && (
214
+ <Legend
215
+ align={legendConfig.align}
216
+ verticalAlign={legendConfig.position === "top" ? "top" : "bottom"}
217
+ wrapperStyle={{ paddingTop: legendConfig.position === "bottom" ? 16 : 0 }}
218
+ />
219
+ )}
220
+
221
+ {chartSeries.map((s, index) => {
222
+ const color = s.color || getColor(index)
223
+ const gradientId = `gradient-${s.dataKey}-${index}`
224
+ return (
225
+ <Area
226
+ key={s.dataKey}
227
+ dataKey={s.dataKey}
228
+ name={s.label}
229
+ stroke={color}
230
+ strokeWidth={s.strokeWidth || strokeWidth}
231
+ fill={`url(#${gradientId})`}
232
+ fillOpacity={s.fillOpacity ?? fillOpacity}
233
+ type={curve}
234
+ dot={dots ? { r: dotSize, fill: color } : false}
235
+ stackId={stacked ? "stack" : undefined}
236
+ animationDuration={animationDuration}
237
+ isAnimationActive={animation}
238
+ />
239
+ )
240
+ })}
241
+ </AreaChart>
242
+ )
243
+ }}
244
+ </WakaChart>
245
+ )
246
+ }
247
+ )
248
+
249
+ WakaAreaChart.displayName = "WakaAreaChart"
250
+
251
+ export default WakaAreaChart
@@ -0,0 +1,222 @@
1
+ "use client"
2
+
3
+ /**
4
+ * WakaBarChart - Graphique à barres
5
+ */
6
+
7
+ import * as React from "react"
8
+ import { cn } from "../../utils/cn"
9
+ import { WakaChart } from "./WakaChart"
10
+ import { useChartTheme } from "./hooks/useChartTheme"
11
+ import type { BarChartProps, ChartDataPoint, ChartSeries } from "./types"
12
+
13
+ export interface WakaBarChartProps extends BarChartProps {}
14
+
15
+ /**
16
+ * Graphique à barres avec support multi-séries, empilé, et animations
17
+ */
18
+ export const WakaBarChart = React.forwardRef<HTMLDivElement, WakaBarChartProps>(
19
+ (
20
+ {
21
+ data,
22
+ dataKeys,
23
+ series,
24
+ variant = "default",
25
+ size = "md",
26
+ height,
27
+ width,
28
+ animation = true,
29
+ animationDuration = 500,
30
+ grid = true,
31
+ tooltip = true,
32
+ legend,
33
+ axis,
34
+ theme: customTheme,
35
+ className,
36
+ style,
37
+ title,
38
+ description,
39
+ loading,
40
+ error,
41
+ onClick,
42
+ responsive = true,
43
+ // Bar specific
44
+ layout = "vertical",
45
+ stacked = false,
46
+ radius = 4,
47
+ barSize,
48
+ barGap = 4,
49
+ barCategoryGap = "20%",
50
+ },
51
+ ref
52
+ ) => {
53
+ const { theme, getColor, tooltipStyles } = useChartTheme(customTheme, variant)
54
+
55
+ // Déterminer les séries à afficher
56
+ const chartSeries = React.useMemo<ChartSeries[]>(() => {
57
+ if (series && series.length > 0) return series
58
+
59
+ if (dataKeys && dataKeys.length > 0) {
60
+ return dataKeys.map((key, index) => ({
61
+ dataKey: key,
62
+ label: key,
63
+ color: getColor(index),
64
+ }))
65
+ }
66
+
67
+ // Default: utiliser "value" si présent
68
+ if (data.length > 0 && "value" in data[0]) {
69
+ return [{ dataKey: "value", label: "Value", color: getColor(0) }]
70
+ }
71
+
72
+ // Sinon, utiliser toutes les clés numériques
73
+ const sampleItem = data[0]
74
+ if (!sampleItem) return []
75
+
76
+ return Object.keys(sampleItem)
77
+ .filter((key) => key !== "name" && typeof sampleItem[key] === "number")
78
+ .map((key, index) => ({
79
+ dataKey: key,
80
+ label: key,
81
+ color: getColor(index),
82
+ }))
83
+ }, [series, dataKeys, data, getColor])
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
+ BarChart,
124
+ Bar,
125
+ XAxis,
126
+ YAxis,
127
+ CartesianGrid,
128
+ Tooltip,
129
+ Legend,
130
+ } = components
131
+
132
+ return (
133
+ <BarChart
134
+ data={data}
135
+ layout={layout === "horizontal" ? "vertical" : "horizontal"}
136
+ barGap={barGap}
137
+ barCategoryGap={barCategoryGap}
138
+ >
139
+ {grid && (
140
+ <CartesianGrid
141
+ strokeDasharray="3 3"
142
+ stroke={theme.gridColor}
143
+ horizontal={true}
144
+ vertical={false}
145
+ />
146
+ )}
147
+
148
+ {axis?.showXAxis !== false && (
149
+ <XAxis
150
+ dataKey="name"
151
+ axisLine={{ stroke: theme.axisColor }}
152
+ tickLine={{ stroke: theme.axisColor }}
153
+ tick={{ fill: theme.textColor, fontSize: 12 }}
154
+ tickFormatter={axis?.xAxisFormatter}
155
+ />
156
+ )}
157
+
158
+ {axis?.showYAxis !== false && (
159
+ <YAxis
160
+ axisLine={{ stroke: theme.axisColor }}
161
+ tickLine={{ stroke: theme.axisColor }}
162
+ tick={{ fill: theme.textColor, fontSize: 12 }}
163
+ tickFormatter={axis?.yAxisFormatter}
164
+ domain={axis?.yAxisDomain}
165
+ unit={axis?.yAxisUnit}
166
+ />
167
+ )}
168
+
169
+ {tooltipConfig?.enabled !== false && tooltip && (
170
+ <Tooltip
171
+ {...tooltipStyles}
172
+ formatter={
173
+ tooltipConfig && typeof tooltipConfig !== "boolean" && tooltipConfig.formatter
174
+ ? (value: unknown, name: string) => {
175
+ const formatted = tooltipConfig.formatter!(
176
+ value as number,
177
+ name,
178
+ data[0]
179
+ )
180
+ return formatted as unknown as [string, string]
181
+ }
182
+ : (value: unknown) => {
183
+ const prefix = tooltipConfig && typeof tooltipConfig !== "boolean" ? tooltipConfig.valuePrefix || "" : ""
184
+ const suffix = tooltipConfig && typeof tooltipConfig !== "boolean" ? tooltipConfig.valueSuffix || "" : ""
185
+ return `${prefix}${value}${suffix}`
186
+ }
187
+ }
188
+ />
189
+ )}
190
+
191
+ {legendConfig?.enabled && (
192
+ <Legend
193
+ align={legendConfig.align}
194
+ verticalAlign={legendConfig.position === "top" ? "top" : "bottom"}
195
+ wrapperStyle={{ paddingTop: legendConfig.position === "bottom" ? 16 : 0 }}
196
+ />
197
+ )}
198
+
199
+ {chartSeries.map((s, index) => (
200
+ <Bar
201
+ key={s.dataKey}
202
+ dataKey={s.dataKey}
203
+ name={s.label}
204
+ fill={s.color || getColor(index)}
205
+ radius={radius}
206
+ stackId={stacked ? "stack" : undefined}
207
+ barSize={barSize}
208
+ animationDuration={animationDuration}
209
+ isAnimationActive={animation}
210
+ />
211
+ ))}
212
+ </BarChart>
213
+ )
214
+ }}
215
+ </WakaChart>
216
+ )
217
+ }
218
+ )
219
+
220
+ WakaBarChart.displayName = "WakaBarChart"
221
+
222
+ export default WakaBarChart
@@ -0,0 +1,124 @@
1
+ "use client"
2
+
3
+ /**
4
+ * WakaChart - Container de base pour les graphiques
5
+ * Gère le chargement dynamique de Recharts et les états loading/error
6
+ */
7
+
8
+ import * as React from "react"
9
+ import { cn } from "../../utils/cn"
10
+ import { useRechartsLoader } from "./hooks/useRechartsLoader"
11
+ import { useChartTheme } from "./hooks/useChartTheme"
12
+ import { Skeleton } from "../skeleton"
13
+ import type { BaseChartProps, ChartSize, CHART_SIZE_MAP } from "./types"
14
+
15
+ const SIZE_MAP: typeof CHART_SIZE_MAP = {
16
+ sm: { width: "100%", height: 150 },
17
+ md: { width: "100%", height: 250 },
18
+ lg: { width: "100%", height: 350 },
19
+ xl: { width: "100%", height: 450 },
20
+ auto: { width: "100%", height: 300 },
21
+ }
22
+
23
+ export interface WakaChartProps extends Omit<BaseChartProps, "data"> {
24
+ /** Contenu du graphique (rendu par les composants enfants) */
25
+ children: (components: ReturnType<typeof useRechartsLoader>["components"]) => React.ReactNode
26
+ }
27
+
28
+ /**
29
+ * Container de base pour les graphiques
30
+ * Gère le chargement de Recharts, les états, et le responsive
31
+ */
32
+ export const WakaChart = React.forwardRef<HTMLDivElement, WakaChartProps>(
33
+ (
34
+ {
35
+ children,
36
+ variant = "default",
37
+ size = "md",
38
+ height: customHeight,
39
+ width: customWidth,
40
+ theme: customTheme,
41
+ className,
42
+ style,
43
+ title,
44
+ description,
45
+ loading: externalLoading,
46
+ error: externalError,
47
+ responsive = true,
48
+ },
49
+ ref
50
+ ) => {
51
+ const { components, loading: rechartsLoading, error: rechartsError, isAvailable } = useRechartsLoader()
52
+ const { containerClasses } = useChartTheme(customTheme, variant)
53
+
54
+ const isLoading = externalLoading || rechartsLoading
55
+ const errorMessage = externalError || (rechartsError ? "Recharts non disponible. Installez recharts pour utiliser les graphiques." : null)
56
+
57
+ // Dimensions
58
+ const sizeConfig = SIZE_MAP[size]
59
+ const chartWidth = customWidth ?? sizeConfig.width
60
+ const chartHeight = customHeight ?? sizeConfig.height
61
+
62
+ // État de chargement
63
+ if (isLoading) {
64
+ return (
65
+ <div ref={ref} className={cn(containerClasses, className)} style={style}>
66
+ {title && <ChartTitle title={title} description={description} />}
67
+ <Skeleton className="w-full" style={{ height: chartHeight }} />
68
+ </div>
69
+ )
70
+ }
71
+
72
+ // Erreur
73
+ if (errorMessage || !isAvailable) {
74
+ return (
75
+ <div ref={ref} className={cn(containerClasses, className)} style={style}>
76
+ {title && <ChartTitle title={title} description={description} />}
77
+ <div
78
+ className="flex items-center justify-center text-muted-foreground text-sm border border-dashed border-border rounded-lg"
79
+ style={{ height: chartHeight }}
80
+ >
81
+ <div className="text-center p-4">
82
+ <p>{errorMessage || "Graphique non disponible"}</p>
83
+ <p className="text-xs mt-1">Installez recharts: pnpm add recharts</p>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ )
88
+ }
89
+
90
+ // ResponsiveContainer wrapper
91
+ const { ResponsiveContainer } = components!
92
+
93
+ return (
94
+ <div ref={ref} className={cn(containerClasses, className)} style={style}>
95
+ {title && <ChartTitle title={title} description={description} />}
96
+ {responsive ? (
97
+ <ResponsiveContainer width={chartWidth} height={chartHeight}>
98
+ {children(components) as React.ReactElement}
99
+ </ResponsiveContainer>
100
+ ) : (
101
+ <div style={{ width: chartWidth, height: chartHeight }}>
102
+ {children(components)}
103
+ </div>
104
+ )}
105
+ </div>
106
+ )
107
+ }
108
+ )
109
+
110
+ WakaChart.displayName = "WakaChart"
111
+
112
+ /**
113
+ * Titre du graphique
114
+ */
115
+ function ChartTitle({ title, description }: { title: string; description?: string }) {
116
+ return (
117
+ <div className="mb-4">
118
+ <h3 className="text-lg font-semibold">{title}</h3>
119
+ {description && <p className="text-sm text-muted-foreground">{description}</p>}
120
+ </div>
121
+ )
122
+ }
123
+
124
+ export default WakaChart