@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.
Files changed (290) hide show
  1. package/dist/cli/commands/add.d.ts +7 -0
  2. package/dist/cli/commands/init.d.ts +6 -0
  3. package/dist/cli/commands/list.d.ts +5 -0
  4. package/dist/cli/commands/search.d.ts +1 -0
  5. package/dist/cli/index.cjs +4844 -0
  6. package/dist/cli/index.d.ts +1 -0
  7. package/dist/cli/utils/config.d.ts +29 -0
  8. package/dist/cli/utils/logger.d.ts +20 -0
  9. package/dist/cli/utils/registry.d.ts +23 -0
  10. package/package.json +14 -3
  11. package/src/blocks/activity-timeline/index.tsx +586 -0
  12. package/src/blocks/calendar-view/index.tsx +756 -0
  13. package/src/blocks/chat/index.tsx +1018 -0
  14. package/src/blocks/chat/widget.tsx +504 -0
  15. package/src/blocks/dashboard/index.tsx +522 -0
  16. package/src/blocks/empty-states/index.tsx +452 -0
  17. package/src/blocks/error-pages/index.tsx +426 -0
  18. package/src/blocks/faq/index.tsx +479 -0
  19. package/src/blocks/file-manager/index.tsx +890 -0
  20. package/src/blocks/footer/index.tsx +133 -0
  21. package/src/blocks/header/index.tsx +357 -0
  22. package/src/blocks/headtab/index.tsx +139 -0
  23. package/src/blocks/i18n-editor/index.tsx +1016 -0
  24. package/src/blocks/index.ts +80 -0
  25. package/src/blocks/kanban-board/index.tsx +779 -0
  26. package/src/blocks/landing/index.tsx +677 -0
  27. package/src/blocks/language-selector/index.tsx +88 -0
  28. package/src/blocks/layout/index.tsx +159 -0
  29. package/src/blocks/login/index.tsx +339 -0
  30. package/src/blocks/login/types.ts +131 -0
  31. package/src/blocks/pricing/index.tsx +564 -0
  32. package/src/blocks/profile/index.tsx +746 -0
  33. package/src/blocks/settings/index.tsx +558 -0
  34. package/src/blocks/sidebar/index.tsx +713 -0
  35. package/src/blocks/theme-creator-block/index.tsx +835 -0
  36. package/src/blocks/user-management/index.tsx +1037 -0
  37. package/src/blocks/wizard/index.tsx +719 -0
  38. package/src/components/DataTable/DataTable.tsx +406 -0
  39. package/src/components/DataTable/DataTableAdvanced.tsx +720 -0
  40. package/src/components/DataTable/DataTableBody.tsx +216 -0
  41. package/src/components/DataTable/DataTableCell.tsx +172 -0
  42. package/src/components/DataTable/DataTableColumnResizer.tsx +62 -0
  43. package/src/components/DataTable/DataTableConflictResolver.tsx +478 -0
  44. package/src/components/DataTable/DataTableContextMenu.tsx +219 -0
  45. package/src/components/DataTable/DataTableEditCell.tsx +279 -0
  46. package/src/components/DataTable/DataTableFilterBuilder.tsx +519 -0
  47. package/src/components/DataTable/DataTableFilters.tsx +535 -0
  48. package/src/components/DataTable/DataTableGrouping.tsx +147 -0
  49. package/src/components/DataTable/DataTableHeader.tsx +172 -0
  50. package/src/components/DataTable/DataTablePagination.tsx +125 -0
  51. package/src/components/DataTable/DataTableSelection.tsx +269 -0
  52. package/src/components/DataTable/DataTableSyncStatus.tsx +281 -0
  53. package/src/components/DataTable/DataTableToolbar.tsx +262 -0
  54. package/src/components/DataTable/README.md +446 -0
  55. package/src/components/DataTable/__tests__/DataTableAdvanced.test.tsx +426 -0
  56. package/src/components/DataTable/__tests__/DataTableEdit.test.tsx +329 -0
  57. package/src/components/DataTable/__tests__/useDataTableAdvanced.test.ts +455 -0
  58. package/src/components/DataTable/examples/EditExample.tsx +166 -0
  59. package/src/components/DataTable/formatters/index.ts +335 -0
  60. package/src/components/DataTable/hooks/__tests__/useDataTableEdit.test.ts +239 -0
  61. package/src/components/DataTable/hooks/useDataTable.ts +145 -0
  62. package/src/components/DataTable/hooks/useDataTableAdvanced.ts +342 -0
  63. package/src/components/DataTable/hooks/useDataTableAdvancedFilters.ts +637 -0
  64. package/src/components/DataTable/hooks/useDataTableColumnTemplates.ts +186 -0
  65. package/src/components/DataTable/hooks/useDataTableEdit.ts +167 -0
  66. package/src/components/DataTable/hooks/useDataTableExport.ts +227 -0
  67. package/src/components/DataTable/hooks/useDataTableImport.ts +216 -0
  68. package/src/components/DataTable/hooks/useDataTableOffline.ts +481 -0
  69. package/src/components/DataTable/hooks/useDataTableTheme.ts +213 -0
  70. package/src/components/DataTable/hooks/useDataTableVirtualization.ts +99 -0
  71. package/src/components/DataTable/hooks/useTableLayout.ts +85 -0
  72. package/src/components/DataTable/index.ts +81 -0
  73. package/src/components/DataTable/services/IndexedDBService.ts +504 -0
  74. package/src/components/DataTable/templates/index.tsx +803 -0
  75. package/src/components/DataTable/types.ts +504 -0
  76. package/src/components/DataTable/utils.ts +164 -0
  77. package/src/components/DataTable/workers/exportWorker.ts +213 -0
  78. package/src/components/accordion/index.tsx +61 -0
  79. package/src/components/alert/index.tsx +61 -0
  80. package/src/components/alert-dialog/index.tsx +146 -0
  81. package/src/components/aspect-ratio/index.tsx +12 -0
  82. package/src/components/avatar/index.tsx +54 -0
  83. package/src/components/badge/Badge.stories.tsx +64 -0
  84. package/src/components/badge/index.tsx +38 -0
  85. package/src/components/button/Button.stories.tsx +173 -0
  86. package/src/components/button/index.tsx +56 -0
  87. package/src/components/calendar/index.tsx +73 -0
  88. package/src/components/card/index.tsx +78 -0
  89. package/src/components/checkbox/index.tsx +34 -0
  90. package/src/components/code/index.tsx +229 -0
  91. package/src/components/collapsible/index.tsx +16 -0
  92. package/src/components/command/index.tsx +162 -0
  93. package/src/components/context-menu/index.tsx +204 -0
  94. package/src/components/dialog/index.tsx +126 -0
  95. package/src/components/dropdown-menu/index.tsx +204 -0
  96. package/src/components/error-boundary/ErrorBoundary.tsx +281 -0
  97. package/src/components/error-boundary/index.ts +7 -0
  98. package/src/components/form/index.tsx +183 -0
  99. package/src/components/hover-card/index.tsx +33 -0
  100. package/src/components/index.ts +368 -0
  101. package/src/components/input/Input.stories.tsx +100 -0
  102. package/src/components/input/index.tsx +27 -0
  103. package/src/components/input-otp/index.tsx +277 -0
  104. package/src/components/label/index.tsx +30 -0
  105. package/src/components/language-selector/index.tsx +341 -0
  106. package/src/components/menubar/index.tsx +240 -0
  107. package/src/components/navigation-menu/index.tsx +134 -0
  108. package/src/components/popover/index.tsx +35 -0
  109. package/src/components/progress/index.tsx +32 -0
  110. package/src/components/radio-group/index.tsx +48 -0
  111. package/src/components/scroll-area/index.tsx +52 -0
  112. package/src/components/select/index.tsx +164 -0
  113. package/src/components/separator/index.tsx +35 -0
  114. package/src/components/sheet/index.tsx +147 -0
  115. package/src/components/skeleton/index.tsx +22 -0
  116. package/src/components/slider/index.tsx +32 -0
  117. package/src/components/switch/index.tsx +33 -0
  118. package/src/components/table/index.tsx +117 -0
  119. package/src/components/tabs/index.tsx +59 -0
  120. package/src/components/textarea/index.tsx +30 -0
  121. package/src/components/theme-selector/index.tsx +327 -0
  122. package/src/components/toast/index.tsx +133 -0
  123. package/src/components/toaster/index.tsx +34 -0
  124. package/src/components/toggle/index.tsx +49 -0
  125. package/src/components/tooltip/index.tsx +34 -0
  126. package/src/components/typography/index.tsx +276 -0
  127. package/src/components/waka-3d-pie-chart/index.tsx +486 -0
  128. package/src/components/waka-achievement-unlock/index.tsx +716 -0
  129. package/src/components/waka-activity-feed/index.tsx +686 -0
  130. package/src/components/waka-address-autocomplete/index.tsx +1202 -0
  131. package/src/components/waka-admincrumb/index.tsx +349 -0
  132. package/src/components/waka-alert-stack/index.tsx +827 -0
  133. package/src/components/waka-allocation-matrix/index.tsx +1278 -0
  134. package/src/components/waka-approval-chain/index.tsx +766 -0
  135. package/src/components/waka-audit-log/index.tsx +1475 -0
  136. package/src/components/waka-autocomplete/index.tsx +358 -0
  137. package/src/components/waka-badge-showcase/index.tsx +704 -0
  138. package/src/components/waka-barcode/index.tsx +260 -0
  139. package/src/components/waka-biometric-prompt/index.tsx +765 -0
  140. package/src/components/waka-bottom-sheet/index.tsx +495 -0
  141. package/src/components/waka-breadcrumb/index.tsx +376 -0
  142. package/src/components/waka-breadcrumb-path/index.tsx +513 -0
  143. package/src/components/waka-budget-burn/index.tsx +1234 -0
  144. package/src/components/waka-capacity-planner/index.tsx +1107 -0
  145. package/src/components/waka-carousel/index.tsx +893 -0
  146. package/src/components/waka-cart-summary/index.tsx +1055 -0
  147. package/src/components/waka-challenge-timer/index.tsx +1044 -0
  148. package/src/components/waka-charts/WakaAreaChart.tsx +251 -0
  149. package/src/components/waka-charts/WakaBarChart.tsx +222 -0
  150. package/src/components/waka-charts/WakaChart.tsx +124 -0
  151. package/src/components/waka-charts/WakaLineChart.tsx +219 -0
  152. package/src/components/waka-charts/WakaMiniChart.tsx +133 -0
  153. package/src/components/waka-charts/WakaPieChart.tsx +214 -0
  154. package/src/components/waka-charts/WakaSparkline.tsx +229 -0
  155. package/src/components/waka-charts/dataTableHelpers.ts +109 -0
  156. package/src/components/waka-charts/hooks/useChartTheme.ts +123 -0
  157. package/src/components/waka-charts/hooks/useRechartsLoader.ts +234 -0
  158. package/src/components/waka-charts/index.ts +90 -0
  159. package/src/components/waka-charts/types.ts +330 -0
  160. package/src/components/waka-chat-bubble/index.tsx +1060 -0
  161. package/src/components/waka-checklist/index.tsx +1067 -0
  162. package/src/components/waka-checkout-stepper/index.tsx +976 -0
  163. package/src/components/waka-cohort-table/index.tsx +1011 -0
  164. package/src/components/waka-color-picker/index.tsx +447 -0
  165. package/src/components/waka-combo-counter/index.tsx +864 -0
  166. package/src/components/waka-combobox/index.tsx +497 -0
  167. package/src/components/waka-command-bar/index.tsx +403 -0
  168. package/src/components/waka-compare-period/index.tsx +1230 -0
  169. package/src/components/waka-connection-matrix/index.tsx +1053 -0
  170. package/src/components/waka-contribution-graph/index.tsx +552 -0
  171. package/src/components/waka-cost-breakdown/index.tsx +1065 -0
  172. package/src/components/waka-coupon-input/index.tsx +592 -0
  173. package/src/components/waka-credit-card-input/index.tsx +982 -0
  174. package/src/components/waka-daily-reward/index.tsx +762 -0
  175. package/src/components/waka-date-range-picker/index.tsx +378 -0
  176. package/src/components/waka-datetime-picker/index.tsx +793 -0
  177. package/src/components/waka-datetime-picker.form-integration/index.tsx +402 -0
  178. package/src/components/waka-deployment-lane/index.tsx +673 -0
  179. package/src/components/waka-device-trust/index.tsx +1259 -0
  180. package/src/components/waka-dock/index.tsx +285 -0
  181. package/src/components/waka-drawer/index.tsx +319 -0
  182. package/src/components/waka-empty-state/index.tsx +545 -0
  183. package/src/components/waka-error-shake/index.tsx +398 -0
  184. package/src/components/waka-feature-announcement/index.tsx +991 -0
  185. package/src/components/waka-file-upload/index.tsx +437 -0
  186. package/src/components/waka-floating-nav/index.tsx +413 -0
  187. package/src/components/waka-flow-diagram/index.tsx +508 -0
  188. package/src/components/waka-funnel-chart/index.tsx +823 -0
  189. package/src/components/waka-glow-card/index.tsx +246 -0
  190. package/src/components/waka-goal-progress/index.tsx +1025 -0
  191. package/src/components/waka-haptic-button/index.tsx +388 -0
  192. package/src/components/waka-health-pulse/index.tsx +451 -0
  193. package/src/components/waka-heatmap/index.tsx +1026 -0
  194. package/src/components/waka-hotspot/index.tsx +682 -0
  195. package/src/components/waka-image/index.tsx +373 -0
  196. package/src/components/waka-incident-timeline/index.tsx +686 -0
  197. package/src/components/waka-invoice-preview/index.tsx +829 -0
  198. package/src/components/waka-kanban/index.tsx +646 -0
  199. package/src/components/waka-kpi-dashboard/index.tsx +755 -0
  200. package/src/components/waka-leaderboard/index.tsx +746 -0
  201. package/src/components/waka-level-progress/index.tsx +665 -0
  202. package/src/components/waka-liquid-button/index.tsx +520 -0
  203. package/src/components/waka-loading-orbit/index.tsx +478 -0
  204. package/src/components/waka-loot-box/index.tsx +1091 -0
  205. package/src/components/waka-magic-link/index.tsx +321 -0
  206. package/src/components/waka-magnetic-button/index.tsx +567 -0
  207. package/src/components/waka-mention-input/index.tsx +953 -0
  208. package/src/components/waka-metric-sparkline/index.tsx +627 -0
  209. package/src/components/waka-milestone-road/index.tsx +1064 -0
  210. package/src/components/waka-modal/index.tsx +374 -0
  211. package/src/components/waka-morph-button/index.tsx +495 -0
  212. package/src/components/waka-network-topology/index.tsx +801 -0
  213. package/src/components/waka-notifications/index.tsx +414 -0
  214. package/src/components/waka-number-input/index.tsx +373 -0
  215. package/src/components/waka-orbital-menu/index.tsx +445 -0
  216. package/src/components/waka-order-tracker/index.tsx +1041 -0
  217. package/src/components/waka-pagination/index.tsx +393 -0
  218. package/src/components/waka-password-strength/index.tsx +824 -0
  219. package/src/components/waka-payment-method-picker/index.tsx +715 -0
  220. package/src/components/waka-permission-matrix/index.tsx +1302 -0
  221. package/src/components/waka-phone-input/index.tsx +801 -0
  222. package/src/components/waka-pipeline-view/index.tsx +604 -0
  223. package/src/components/waka-player-card/index.tsx +691 -0
  224. package/src/components/waka-points-popup/index.tsx +366 -0
  225. package/src/components/waka-power-up/index.tsx +1155 -0
  226. package/src/components/waka-presence-indicator/index.tsx +1181 -0
  227. package/src/components/waka-pricing-table/index.tsx +755 -0
  228. package/src/components/waka-product-card/index.tsx +786 -0
  229. package/src/components/waka-progress-onboarding/index.tsx +878 -0
  230. package/src/components/waka-pull-to-refresh/index.tsx +451 -0
  231. package/src/components/waka-qrcode/index.tsx +232 -0
  232. package/src/components/waka-quest-card/index.tsx +1275 -0
  233. package/src/components/waka-quota-bar/index.tsx +693 -0
  234. package/src/components/waka-radar-score/index.tsx +512 -0
  235. package/src/components/waka-rank-badge/index.tsx +813 -0
  236. package/src/components/waka-rating-input/index.tsx +560 -0
  237. package/src/components/waka-reaction-picker/index.tsx +1062 -0
  238. package/src/components/waka-region-map/index.tsx +730 -0
  239. package/src/components/waka-resource-gauge/index.tsx +654 -0
  240. package/src/components/waka-resource-pool/index.tsx +1035 -0
  241. package/src/components/waka-rich-text-editor/index.tsx +594 -0
  242. package/src/components/waka-rollback-slider/index.tsx +891 -0
  243. package/src/components/waka-sankey-diagram/index.tsx +1032 -0
  244. package/src/components/waka-schedule-picker/index.tsx +1060 -0
  245. package/src/components/waka-scratch-card/index.tsx +914 -0
  246. package/src/components/waka-season-pass/index.tsx +886 -0
  247. package/src/components/waka-security-score/index.tsx +1126 -0
  248. package/src/components/waka-segmented-control/index.tsx +238 -0
  249. package/src/components/waka-server-rack/index.tsx +764 -0
  250. package/src/components/waka-session-manager/index.tsx +815 -0
  251. package/src/components/waka-signature-pad/index.tsx +744 -0
  252. package/src/components/waka-skeleton-wave/index.tsx +454 -0
  253. package/src/components/waka-skill-tree/index.tsx +1031 -0
  254. package/src/components/waka-sla-tracker/index.tsx +798 -0
  255. package/src/components/waka-slider-range/index.tsx +765 -0
  256. package/src/components/waka-spin-wheel/index.tsx +671 -0
  257. package/src/components/waka-spinner/index.tsx +284 -0
  258. package/src/components/waka-spotlight/index.tsx +410 -0
  259. package/src/components/waka-stat/index.tsx +428 -0
  260. package/src/components/waka-stats-hexagon/index.tsx +824 -0
  261. package/src/components/waka-status-matrix/index.tsx +565 -0
  262. package/src/components/waka-stepper/index.tsx +489 -0
  263. package/src/components/waka-streak-counter/index.tsx +334 -0
  264. package/src/components/waka-success-explosion/index.tsx +453 -0
  265. package/src/components/waka-swipe-card/index.tsx +574 -0
  266. package/src/components/waka-tabs-morph/index.tsx +509 -0
  267. package/src/components/waka-tag-input/index.tsx +877 -0
  268. package/src/components/waka-team-banner/index.tsx +1183 -0
  269. package/src/components/waka-terminal-output/index.tsx +836 -0
  270. package/src/components/waka-theme-creator/index.tsx +762 -0
  271. package/src/components/waka-theme-manager/index.tsx +654 -0
  272. package/src/components/waka-thread-view/index.tsx +874 -0
  273. package/src/components/waka-tilt-card/index.tsx +250 -0
  274. package/src/components/waka-time-picker/index.tsx +479 -0
  275. package/src/components/waka-timeline/index.tsx +385 -0
  276. package/src/components/waka-tooltip-tour/index.tsx +855 -0
  277. package/src/components/waka-tour-guide/index.tsx +920 -0
  278. package/src/components/waka-tournament-bracket/index.tsx +1276 -0
  279. package/src/components/waka-tree/index.tsx +557 -0
  280. package/src/components/waka-treemap-chart/index.tsx +1031 -0
  281. package/src/components/waka-two-factor-setup/index.tsx +995 -0
  282. package/src/components/waka-typewriter/index.tsx +566 -0
  283. package/src/components/waka-typing-indicator/index.tsx +649 -0
  284. package/src/components/waka-versus-card/index.tsx +1026 -0
  285. package/src/components/waka-video/index.tsx +557 -0
  286. package/src/components/waka-video-call/index.tsx +1087 -0
  287. package/src/components/waka-virtual-list/index.tsx +327 -0
  288. package/src/components/waka-voice-message/index.tsx +1019 -0
  289. package/src/components/waka-welcome-modal/index.tsx +790 -0
  290. package/src/components/waka-xp-bar/index.tsx +799 -0
@@ -0,0 +1,720 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { flexRender } from "@tanstack/react-table"
5
+ import { Loader2, AlertCircle, ChevronDown, ChevronRight, GripVertical } from "lucide-react"
6
+ import { DataTableProps } from "./types"
7
+ import { useDataTableAdvanced } from "./hooks/useDataTableAdvanced"
8
+ import { useDataTableVirtualization } from "./hooks/useDataTableVirtualization"
9
+ import { useDataTableExport } from "./hooks/useDataTableExport"
10
+ import { useDataTableImport } from "./hooks/useDataTableImport"
11
+ import { useDataTableTheme } from "./hooks/useDataTableTheme"
12
+ import { useTableLayout } from "./hooks/useTableLayout"
13
+ import { useDataTableEdit } from "./hooks/useDataTableEdit"
14
+ import { DataTableToolbar } from "./DataTableToolbar"
15
+ import { DataTablePagination } from "./DataTablePagination"
16
+ import { DataTableFilters } from "./DataTableFilters"
17
+ import { DataTableEditCell } from "./DataTableEditCell"
18
+ import { Checkbox } from "../checkbox"
19
+ import { Button } from "../button"
20
+ import { cn } from "./utils"
21
+ import { useTranslation } from "react-i18next"
22
+
23
+ /**
24
+ * Composant DataTable ultra-complet avec toutes les fonctionnalités avancées
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * <DataTableAdvanced
29
+ * data={users}
30
+ * columns={userColumns}
31
+ * layout="standard"
32
+ * variant="bordered"
33
+ * density="comfortable"
34
+ * selection="multiple"
35
+ * grouping={{ columns: ["department"], showTotals: true }}
36
+ * rowExpansion={{ enabled: true, renderExpanded: (row) => <UserDetails user={row} /> }}
37
+ * virtualization={{ type: "dynamic", estimatedItemHeight: 60 }}
38
+ * columnResize={{ enabled: true, mode: "onChange" }}
39
+ * enableExport={{ formats: ["csv", "xlsx", "json"] }}
40
+ * enableImport={{ accept: ".csv,.xlsx,.json" }}
41
+ * theme={{
42
+ * colors: { primary: "#3b82f6", secondary: "#64748b" },
43
+ * spacing: { md: "1.5rem" }
44
+ * }}
45
+ * />
46
+ * ```
47
+ */
48
+ export function DataTableAdvanced<TData>({
49
+ data,
50
+ columns: initialColumns,
51
+ layout: layoutProp = "standard",
52
+ variant = "bordered",
53
+ density: densityProp = "comfortable",
54
+ filters,
55
+ filterPosition = "top",
56
+ toolbar,
57
+ pagination: paginationConfig,
58
+ selection = false,
59
+ actions,
60
+ i18nNamespace,
61
+ loading = false,
62
+ error,
63
+ emptyState,
64
+ headerSticky = false,
65
+ columnVisibilityToggle = true,
66
+ columnResize = false,
67
+ columnOrder: columnOrderConfig,
68
+ grouping,
69
+ rowExpansion,
70
+ virtualization,
71
+ sortMode = "multiple",
72
+ enableExport = false,
73
+ enableImport = false,
74
+ enableReorder = false,
75
+ enableContextMenu = false,
76
+ onRowClick,
77
+ onRowDoubleClick,
78
+ onSortingChange,
79
+ onFiltersChange,
80
+ onSelectionChange,
81
+ onColumnOrderChange,
82
+ onExpandedChange,
83
+ onGroupingChange,
84
+ className,
85
+ tableId,
86
+ edit,
87
+ theme,
88
+ performance,
89
+ }: DataTableProps<TData>) {
90
+ const { t } = useTranslation(i18nNamespace)
91
+ const containerRef = React.useRef<HTMLDivElement>(null)
92
+
93
+ // Hook de layout
94
+ const {
95
+ layout,
96
+ setLayout,
97
+ density,
98
+ setDensity,
99
+ densityClasses,
100
+ } = useTableLayout(layoutProp, densityProp)
101
+
102
+ // Hook de thème
103
+ const {
104
+ theme: mergedTheme,
105
+ variantClasses,
106
+ densityClasses: themeDensityClasses,
107
+ customStyles,
108
+ getThemedClass,
109
+ getThemedStyles,
110
+ } = useDataTableTheme({ theme, variant, density })
111
+
112
+
113
+ // Colonnes avec fonctionnalités avancées
114
+ const columns = React.useMemo(() => {
115
+ const cols = [...initialColumns]
116
+
117
+ // Ajouter colonne de sélection si activée
118
+ if (selection) {
119
+ const selectionColumn = {
120
+ id: "select",
121
+ header: ({ table }: any) => (
122
+ <Checkbox
123
+ checked={table.getIsAllPageRowsSelected()}
124
+ onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
125
+ aria-label={t("datatable.selectAll", { defaultValue: "Select all" })}
126
+ />
127
+ ),
128
+ cell: ({ row }: any) => (
129
+ <Checkbox
130
+ checked={row.getIsSelected()}
131
+ onCheckedChange={(value) => row.toggleSelected(!!value)}
132
+ aria-label={t("datatable.selectRow", { defaultValue: "Select row" })}
133
+ />
134
+ ),
135
+ enableSorting: false,
136
+ enableHiding: false,
137
+ size: 50,
138
+ }
139
+ cols.unshift(selectionColumn)
140
+ }
141
+
142
+ // Ajouter colonne d'expansion si activée
143
+ if (rowExpansion?.enabled) {
144
+ const expansionColumn = {
145
+ id: "expand",
146
+ header: () => null,
147
+ cell: ({ row }: any) => {
148
+ if (!row.getCanExpand()) return null
149
+
150
+ return (
151
+ <Button
152
+ variant="ghost"
153
+ size="sm"
154
+ onClick={() => row.toggleExpanded()}
155
+ className="h-8 w-8 p-0"
156
+ >
157
+ {row.getIsExpanded() ? (
158
+ <ChevronDown className="h-4 w-4" />
159
+ ) : (
160
+ <ChevronRight className="h-4 w-4" />
161
+ )}
162
+ </Button>
163
+ )
164
+ },
165
+ enableSorting: false,
166
+ enableHiding: false,
167
+ size: 50,
168
+ }
169
+ cols.unshift(expansionColumn)
170
+ }
171
+
172
+ // Ajouter colonne de réordonnancement si activée
173
+ if (enableReorder) {
174
+ const reorderColumn = {
175
+ id: "reorder",
176
+ header: () => null,
177
+ cell: () => (
178
+ <Button variant="ghost" size="sm" className="h-8 w-8 p-0 cursor-move">
179
+ <GripVertical className="h-4 w-4" />
180
+ </Button>
181
+ ),
182
+ enableSorting: false,
183
+ enableHiding: false,
184
+ size: 50,
185
+ }
186
+ cols.unshift(reorderColumn)
187
+ }
188
+
189
+ return cols
190
+ }, [initialColumns, selection, rowExpansion, enableReorder, t])
191
+
192
+ // Debug: Vérifier les props de groupement et expansion
193
+ console.log("DataTableAdvanced - props:", {
194
+ grouping,
195
+ rowExpansion,
196
+ dataLength: data.length
197
+ })
198
+
199
+ // Hook principal avancé
200
+ const {
201
+ table,
202
+ sorting,
203
+ setSorting,
204
+ columnFilters,
205
+ setColumnFilters,
206
+ columnVisibility,
207
+ setColumnVisibility,
208
+ columnOrder,
209
+ setColumnOrder,
210
+ expanded,
211
+ setExpanded,
212
+ grouping: groupingState,
213
+ setGrouping,
214
+ rowSelection,
215
+ setRowSelection,
216
+ globalFilter,
217
+ setGlobalFilter,
218
+ pagination,
219
+ setPagination,
220
+ selectedRows,
221
+ resetFilters,
222
+ resetSelection,
223
+ resetAll,
224
+ exportData,
225
+ getGroupedData,
226
+ getExpandedData,
227
+ toggleGrouping,
228
+ clearGrouping,
229
+ toggleRowExpansion,
230
+ expandAll,
231
+ collapseAll,
232
+ } = useDataTableAdvanced({
233
+ data,
234
+ columns,
235
+ pagination: paginationConfig,
236
+ tableId,
237
+ onSortingChange,
238
+ onFiltersChange,
239
+ onSelectionChange,
240
+ onColumnOrderChange,
241
+ onExpandedChange,
242
+ onGroupingChange,
243
+ grouping,
244
+ virtualization,
245
+ sortMode,
246
+ performance,
247
+ })
248
+
249
+ // Hook de virtualisation
250
+ const {
251
+ isVirtualized,
252
+ virtualItems,
253
+ totalSize,
254
+ scrollToIndex,
255
+ scrollToOffset,
256
+ } = useDataTableVirtualization({
257
+ data,
258
+ virtualization,
259
+ containerRef,
260
+ })
261
+
262
+
263
+ // Hook d'export
264
+ const { exportData: exportDataFn, exportAll, exportSelected } = useDataTableExport({
265
+ data,
266
+ columns,
267
+ exportConfig: typeof enableExport === "object" ? enableExport : undefined,
268
+ })
269
+
270
+ // Hook d'import
271
+ const { importWithUI, supportedFormats } = useDataTableImport({
272
+ importConfig: typeof enableImport === "object" ? enableImport : undefined,
273
+ })
274
+
275
+ // Hook d'édition si configuré
276
+ const [editState, editActions] = useDataTableEdit(table, {
277
+ onSave: edit?.onSave,
278
+ onCancel: edit?.onCancel,
279
+ autoSave: edit?.autoSave,
280
+ autoSaveDelay: edit?.autoSaveDelay,
281
+ })
282
+
283
+ // Ajouter colonne d'actions d'édition
284
+ if (edit?.editableColumns && edit.editableColumns.length > 0) {
285
+ const editColumn = {
286
+ id: "edit-actions",
287
+ header: () => t("datatable.actions", { defaultValue: "Actions" }),
288
+ cell: ({ row }: any) => {
289
+ const isEditing = editState.editingRowId === row.id
290
+
291
+ if (isEditing) {
292
+ return (
293
+ <div className="flex gap-1">
294
+ <Button
295
+ size="sm"
296
+ variant="ghost"
297
+ onClick={() => editActions.saveEdit()}
298
+ disabled={!editState.hasChanges}
299
+ >
300
+ {t("datatable.save", { defaultValue: "Save" })}
301
+ </Button>
302
+ <Button
303
+ size="sm"
304
+ variant="ghost"
305
+ onClick={() => editActions.cancelEdit()}
306
+ >
307
+ {t("datatable.cancel", { defaultValue: "Cancel" })}
308
+ </Button>
309
+ </div>
310
+ )
311
+ }
312
+
313
+ return (
314
+ <Button
315
+ size="sm"
316
+ variant="ghost"
317
+ onClick={() => editActions.startEdit(row.id, row.original)}
318
+ >
319
+ {t("datatable.edit", { defaultValue: "Edit" })}
320
+ </Button>
321
+ )
322
+ },
323
+ enableSorting: false,
324
+ enableHiding: false,
325
+ }
326
+ columns.push(editColumn)
327
+ }
328
+
329
+ // Handler d'export
330
+ const handleExport = React.useCallback(async (format: string) => {
331
+ try {
332
+ await exportDataFn(format)
333
+ } catch (error) {
334
+ console.error("Erreur lors de l'export:", error)
335
+ }
336
+ }, [exportDataFn])
337
+
338
+ // Handler d'import
339
+ const handleImport = React.useCallback(async () => {
340
+ try {
341
+ const importedData = await importWithUI()
342
+ console.log("Données importées:", importedData)
343
+ } catch (error) {
344
+ console.error("Erreur lors de l'import:", error)
345
+ }
346
+ }, [importWithUI])
347
+
348
+ // Si loading
349
+ if (loading) {
350
+ return (
351
+ <div className="flex items-center justify-center h-64 border rounded-lg">
352
+ <div className="flex flex-col items-center gap-2">
353
+ <Loader2 className="h-8 w-8 animate-spin text-muted-foreground" />
354
+ <p className="text-sm text-muted-foreground">
355
+ {t("datatable.loading", { defaultValue: "Loading..." })}
356
+ </p>
357
+ </div>
358
+ </div>
359
+ )
360
+ }
361
+
362
+ // Si erreur
363
+ if (error) {
364
+ return (
365
+ <div className="flex items-center justify-center h-64 border rounded-lg bg-destructive/10">
366
+ <div className="flex flex-col items-center gap-2 text-destructive">
367
+ <AlertCircle className="h-8 w-8" />
368
+ <p className="text-sm font-medium">{error}</p>
369
+ </div>
370
+ </div>
371
+ )
372
+ }
373
+
374
+ // Si pas de données
375
+ if (!data || data.length === 0) {
376
+ return (
377
+ <div className="flex flex-col">
378
+ {/* Toolbar même sans données */}
379
+ {toolbar && (
380
+ <DataTableToolbar
381
+ table={table}
382
+ config={toolbar}
383
+ globalFilter={globalFilter}
384
+ onGlobalFilterChange={setGlobalFilter}
385
+ density={density}
386
+ onDensityChange={setDensity}
387
+ onExport={enableExport ? handleExport : undefined}
388
+ onImport={enableImport ? handleImport : undefined}
389
+ />
390
+ )}
391
+
392
+ <div className="flex items-center justify-center h-64 border rounded-lg">
393
+ {emptyState || (
394
+ <div className="flex flex-col items-center gap-2 text-muted-foreground">
395
+ <p className="text-lg font-medium">
396
+ {t("datatable.noData", { defaultValue: "No data" })}
397
+ </p>
398
+ <p className="text-sm">
399
+ {t("datatable.noDataDescription", { defaultValue: "There are no results to display" })}
400
+ </p>
401
+ </div>
402
+ )}
403
+ </div>
404
+ </div>
405
+ )
406
+ }
407
+
408
+ // Rendu du tableau avec virtualisation
409
+ const renderTable = () => {
410
+ if (isVirtualized) {
411
+ return (
412
+ <div
413
+ ref={containerRef}
414
+ className="h-full overflow-auto"
415
+ style={{ height: virtualization?.containerHeight || 600 }}
416
+ >
417
+ <table
418
+ className={cn("w-full caption-bottom text-sm", themeDensityClasses.table)}
419
+ style={getThemedStyles()}
420
+ >
421
+ <thead className={cn(headerSticky && "sticky top-0 bg-background z-10")}>
422
+ {table.getHeaderGroups().map((headerGroup) => (
423
+ <tr key={headerGroup.id} className="border-b">
424
+ {headerGroup.headers.map((header) => (
425
+ <th
426
+ key={header.id}
427
+ className={cn(
428
+ "text-left font-medium text-muted-foreground",
429
+ themeDensityClasses.header,
430
+ header.column.getCanSort() && "cursor-pointer select-none hover:text-foreground"
431
+ )}
432
+ onClick={header.column.getToggleSortingHandler()}
433
+ style={{
434
+ width: header.getSize(),
435
+ minWidth: header.column.columnDef.minSize,
436
+ maxWidth: header.column.columnDef.maxSize,
437
+ }}
438
+ >
439
+ {header.isPlaceholder
440
+ ? null
441
+ : flexRender(
442
+ header.column.columnDef.header,
443
+ header.getContext()
444
+ )}
445
+ {header.column.getIsSorted() && (
446
+ <span className="ml-2">
447
+ {header.column.getIsSorted() === "asc" ? "↑" : "↓"}
448
+ </span>
449
+ )}
450
+ </th>
451
+ ))}
452
+ </tr>
453
+ ))}
454
+ </thead>
455
+ <tbody>
456
+ {virtualItems.map((virtualItem) => {
457
+ const rows = grouping?.columns?.length ? table.getGroupedRowModel().rows :
458
+ rowExpansion?.enabled ? table.getExpandedRowModel().rows :
459
+ table.getRowModel().rows
460
+ const row = rows[virtualItem.index]
461
+ if (!row) return null
462
+
463
+ return (
464
+ <tr
465
+ key={row.id}
466
+ className={cn(
467
+ "border-b transition-colors",
468
+ onRowClick && "cursor-pointer hover:bg-muted/50",
469
+ row.getIsSelected() && "bg-muted"
470
+ )}
471
+ onClick={() => onRowClick?.(row.original)}
472
+ onDoubleClick={() => onRowDoubleClick?.(row.original)}
473
+ style={{
474
+ position: "absolute",
475
+ top: virtualItem.start,
476
+ left: 0,
477
+ width: "100%",
478
+ height: virtualItem.size,
479
+ }}
480
+ >
481
+ {row.getVisibleCells().map((cell) => {
482
+ const cellValue = cell.getValue()
483
+ const columnId = cell.column.id
484
+ const rowId = row.id
485
+ const isEditing = editState.editingRowId === rowId
486
+
487
+ // Vérifier si cette colonne est éditable
488
+ const editableColumn = edit?.editableColumns?.find(
489
+ col => col.field === columnId
490
+ )
491
+
492
+ if (editableColumn && isEditing) {
493
+ return (
494
+ <td
495
+ key={cell.id}
496
+ className={cn("align-middle", themeDensityClasses.cell)}
497
+ >
498
+ <DataTableEditCell
499
+ value={cellValue}
500
+ field={columnId as keyof TData}
501
+ config={editableColumn.config}
502
+ isEditing={isEditing}
503
+ onChange={(value) => editActions.updateField(columnId as keyof TData, value)}
504
+ onStartEdit={() => editActions.startEdit(rowId, row.original)}
505
+ onSave={() => editActions.saveEdit()}
506
+ onCancel={() => editActions.cancelEdit()}
507
+ />
508
+ </td>
509
+ )
510
+ }
511
+
512
+ return (
513
+ <td
514
+ key={cell.id}
515
+ className={cn("align-middle", themeDensityClasses.cell)}
516
+ >
517
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
518
+ </td>
519
+ )
520
+ })}
521
+ </tr>
522
+ )
523
+ })}
524
+ </tbody>
525
+ </table>
526
+ </div>
527
+ )
528
+ }
529
+
530
+ // Rendu standard
531
+ return (
532
+ <div className={cn("w-full overflow-auto", variantClasses)}>
533
+ <table
534
+ className={cn("w-full caption-bottom text-sm", themeDensityClasses.table)}
535
+ style={getThemedStyles()}
536
+ >
537
+ <thead className={cn(headerSticky && "sticky top-0 bg-background z-10")}>
538
+ {table.getHeaderGroups().map((headerGroup) => (
539
+ <tr key={headerGroup.id} className="border-b">
540
+ {headerGroup.headers.map((header) => (
541
+ <th
542
+ key={header.id}
543
+ className={cn(
544
+ "text-left font-medium text-muted-foreground",
545
+ themeDensityClasses.header,
546
+ header.column.getCanSort() && "cursor-pointer select-none hover:text-foreground"
547
+ )}
548
+ onClick={header.column.getToggleSortingHandler()}
549
+ style={{
550
+ width: header.getSize(),
551
+ minWidth: header.column.columnDef.minSize,
552
+ maxWidth: header.column.columnDef.maxSize,
553
+ }}
554
+ >
555
+ {header.isPlaceholder
556
+ ? null
557
+ : flexRender(
558
+ header.column.columnDef.header,
559
+ header.getContext()
560
+ )}
561
+ {header.column.getIsSorted() && (
562
+ <span className="ml-2">
563
+ {header.column.getIsSorted() === "asc" ? "↑" : "↓"}
564
+ </span>
565
+ )}
566
+ </th>
567
+ ))}
568
+ </tr>
569
+ ))}
570
+ </thead>
571
+ <tbody>
572
+ {(() => {
573
+ const rows = grouping?.columns?.length ? table.getGroupedRowModel().rows :
574
+ rowExpansion?.enabled ? table.getExpandedRowModel().rows :
575
+ table.getRowModel().rows
576
+
577
+ console.log("DataTableAdvanced - rendering rows:", {
578
+ totalRows: rows.length,
579
+ grouping: grouping?.columns,
580
+ rowExpansion: rowExpansion?.enabled,
581
+ firstRow: rows[0]
582
+ })
583
+
584
+ return rows.map((row, index) => {
585
+ const isGroupRow = row.getIsGrouped()
586
+ const isExpanded = row.getIsExpanded()
587
+
588
+ return (
589
+ <React.Fragment key={`${row.id}-${index}`}>
590
+ <tr
591
+ className={cn(
592
+ "border-b transition-colors",
593
+ onRowClick && "cursor-pointer hover:bg-muted/50",
594
+ row.getIsSelected() && "bg-muted",
595
+ isGroupRow && "bg-muted/30 font-medium"
596
+ )}
597
+ onClick={() => onRowClick?.(row.original)}
598
+ onDoubleClick={() => onRowDoubleClick?.(row.original)}
599
+ >
600
+ {row.getVisibleCells().map((cell) => {
601
+ const cellValue = cell.getValue()
602
+ const columnId = cell.column.id
603
+ const rowId = row.id
604
+ const isEditing = editState.editingRowId === rowId
605
+
606
+ // Vérifier si cette colonne est éditable
607
+ const editableColumn = edit?.editableColumns?.find(
608
+ col => col.field === columnId
609
+ )
610
+
611
+ if (editableColumn && isEditing) {
612
+ return (
613
+ <td
614
+ key={cell.id}
615
+ className={cn("align-middle", themeDensityClasses.cell)}
616
+ >
617
+ <DataTableEditCell
618
+ value={cellValue}
619
+ field={columnId as keyof TData}
620
+ config={editableColumn.config}
621
+ isEditing={isEditing}
622
+ onChange={(value) => editActions.updateField(columnId as keyof TData, value)}
623
+ onStartEdit={() => editActions.startEdit(rowId, row.original)}
624
+ onSave={() => editActions.saveEdit()}
625
+ onCancel={() => editActions.cancelEdit()}
626
+ />
627
+ </td>
628
+ )
629
+ }
630
+
631
+ return (
632
+ <td
633
+ key={cell.id}
634
+ className={cn("align-middle", themeDensityClasses.cell)}
635
+ >
636
+ {isGroupRow ? (
637
+ <div className="flex items-center gap-2">
638
+ <button
639
+ onClick={(e) => {
640
+ e.stopPropagation()
641
+ row.toggleExpanded()
642
+ }}
643
+ className="p-1 hover:bg-muted rounded"
644
+ >
645
+ {isExpanded ? "▼" : "▶"}
646
+ </button>
647
+ <span className="font-medium">
648
+ {cell.getValue() as string} ({row.subRows.length} éléments)
649
+ </span>
650
+ </div>
651
+ ) : (
652
+ flexRender(cell.column.columnDef.cell, cell.getContext())
653
+ )}
654
+ </td>
655
+ )
656
+ })}
657
+ </tr>
658
+ {/* Ligne d'expansion */}
659
+ {rowExpansion?.enabled && isExpanded && (
660
+ <tr key={`${row.id}-expanded-${index}`}>
661
+ <td colSpan={columns.length} className="p-0">
662
+ <div className="border-b">
663
+ {rowExpansion.renderExpanded?.(row.original)}
664
+ </div>
665
+ </td>
666
+ </tr>
667
+ )}
668
+ </React.Fragment>
669
+ )
670
+ })
671
+ })()}
672
+ </tbody>
673
+ </table>
674
+ </div>
675
+ )
676
+ }
677
+
678
+ return (
679
+ <div className={cn("w-full", className)} style={getThemedStyles()}>
680
+ {/* Toolbar avec filtres intégrés */}
681
+ <div className="flex items-center justify-between gap-4">
682
+ {toolbar && (
683
+ <div className="flex-1">
684
+ <DataTableToolbar
685
+ table={table}
686
+ config={toolbar}
687
+ globalFilter={globalFilter}
688
+ onGlobalFilterChange={setGlobalFilter}
689
+ density={density}
690
+ onDensityChange={setDensity}
691
+ onExport={enableExport ? handleExport : undefined}
692
+ onImport={enableImport ? handleImport : undefined}
693
+ />
694
+ </div>
695
+ )}
696
+
697
+ {/* Bouton filtres */}
698
+ {filters && (
699
+ <DataTableFilters
700
+ table={table}
701
+ filters={filters}
702
+ position={filterPosition}
703
+ onFiltersChange={onFiltersChange}
704
+ />
705
+ )}
706
+ </div>
707
+
708
+ {/* Table */}
709
+ {renderTable()}
710
+
711
+ {/* Pagination */}
712
+ {paginationConfig && (
713
+ <DataTablePagination
714
+ table={table}
715
+ pageSizeOptions={paginationConfig.pageSizeOptions}
716
+ />
717
+ )}
718
+ </div>
719
+ )
720
+ }