@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.
- package/README.md +71 -8
- 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 +6014 -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,213 @@
|
|
|
1
|
+
import { useMemo, useCallback } from "react"
|
|
2
|
+
import { DataTableTheme } from "../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Hook pour gérer les thèmes personnalisés du DataTable
|
|
6
|
+
*/
|
|
7
|
+
export function useDataTableTheme({
|
|
8
|
+
theme,
|
|
9
|
+
variant = "bordered",
|
|
10
|
+
density = "comfortable",
|
|
11
|
+
}: {
|
|
12
|
+
theme?: DataTableTheme
|
|
13
|
+
variant?: "bordered" | "minimal" | "striped" | "glass"
|
|
14
|
+
density?: "comfortable" | "compact" | "spacious"
|
|
15
|
+
}): {
|
|
16
|
+
theme: DataTableTheme
|
|
17
|
+
variantClasses: string
|
|
18
|
+
densityClasses: Record<string, string>
|
|
19
|
+
customStyles: Record<string, string>
|
|
20
|
+
getThemedClass: (baseClass: string, themeKey?: string) => string
|
|
21
|
+
getThemedStyles: (baseStyles?: React.CSSProperties) => React.CSSProperties
|
|
22
|
+
} {
|
|
23
|
+
// Thème par défaut
|
|
24
|
+
const defaultTheme: DataTableTheme = {
|
|
25
|
+
colors: {
|
|
26
|
+
primary: "hsl(var(--primary))",
|
|
27
|
+
secondary: "hsl(var(--secondary))",
|
|
28
|
+
accent: "hsl(var(--accent))",
|
|
29
|
+
background: "hsl(var(--background))",
|
|
30
|
+
surface: "hsl(var(--card))",
|
|
31
|
+
text: "hsl(var(--foreground))",
|
|
32
|
+
textSecondary: "hsl(var(--muted-foreground))",
|
|
33
|
+
border: "hsl(var(--border))",
|
|
34
|
+
hover: "hsl(var(--muted))",
|
|
35
|
+
selected: "hsl(var(--accent))",
|
|
36
|
+
disabled: "hsl(var(--muted))",
|
|
37
|
+
},
|
|
38
|
+
spacing: {
|
|
39
|
+
xs: "0.25rem",
|
|
40
|
+
sm: "0.5rem",
|
|
41
|
+
md: "1rem",
|
|
42
|
+
lg: "1.5rem",
|
|
43
|
+
xl: "2rem",
|
|
44
|
+
},
|
|
45
|
+
typography: {
|
|
46
|
+
fontFamily: "inherit",
|
|
47
|
+
fontSize: {
|
|
48
|
+
xs: "0.75rem",
|
|
49
|
+
sm: "0.875rem",
|
|
50
|
+
md: "1rem",
|
|
51
|
+
lg: "1.125rem",
|
|
52
|
+
xl: "1.25rem",
|
|
53
|
+
},
|
|
54
|
+
fontWeight: {
|
|
55
|
+
normal: "400",
|
|
56
|
+
medium: "500",
|
|
57
|
+
semibold: "600",
|
|
58
|
+
bold: "700",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
borders: {
|
|
62
|
+
radius: {
|
|
63
|
+
sm: "0.25rem",
|
|
64
|
+
md: "0.5rem",
|
|
65
|
+
lg: "0.75rem",
|
|
66
|
+
},
|
|
67
|
+
width: {
|
|
68
|
+
thin: "1px",
|
|
69
|
+
medium: "2px",
|
|
70
|
+
thick: "4px",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
shadows: {
|
|
74
|
+
sm: "0 1px 2px 0 rgb(0 0 0 / 0.05)",
|
|
75
|
+
md: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",
|
|
76
|
+
lg: "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",
|
|
77
|
+
xl: "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)",
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Fusion du thème personnalisé avec le thème par défaut
|
|
82
|
+
const mergedTheme = useMemo(() => {
|
|
83
|
+
if (!theme) return defaultTheme
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
colors: { ...defaultTheme.colors, ...theme.colors },
|
|
87
|
+
spacing: { ...defaultTheme.spacing, ...theme.spacing },
|
|
88
|
+
typography: { ...defaultTheme.typography, ...theme.typography },
|
|
89
|
+
borders: { ...defaultTheme.borders, ...theme.borders },
|
|
90
|
+
shadows: { ...defaultTheme.shadows, ...theme.shadows },
|
|
91
|
+
}
|
|
92
|
+
}, [theme, defaultTheme])
|
|
93
|
+
|
|
94
|
+
// Classes CSS pour les variants
|
|
95
|
+
const variantClasses = useMemo(() => {
|
|
96
|
+
const baseClasses = "w-full"
|
|
97
|
+
|
|
98
|
+
switch (variant) {
|
|
99
|
+
case "bordered":
|
|
100
|
+
return `${baseClasses} border rounded-lg`
|
|
101
|
+
case "minimal":
|
|
102
|
+
return baseClasses
|
|
103
|
+
case "striped":
|
|
104
|
+
return `${baseClasses} [&_tbody_tr:nth-child(even)]:bg-muted/50`
|
|
105
|
+
case "glass":
|
|
106
|
+
return `${baseClasses} backdrop-blur-sm bg-background/80 border rounded-lg`
|
|
107
|
+
default:
|
|
108
|
+
return baseClasses
|
|
109
|
+
}
|
|
110
|
+
}, [variant])
|
|
111
|
+
|
|
112
|
+
// Classes CSS pour la densité
|
|
113
|
+
const densityClasses = useMemo(() => {
|
|
114
|
+
switch (density) {
|
|
115
|
+
case "spacious":
|
|
116
|
+
return {
|
|
117
|
+
table: "text-base",
|
|
118
|
+
header: "px-6 py-4",
|
|
119
|
+
cell: "px-6 py-4",
|
|
120
|
+
row: "h-16",
|
|
121
|
+
}
|
|
122
|
+
case "compact":
|
|
123
|
+
return {
|
|
124
|
+
table: "text-sm",
|
|
125
|
+
header: "px-3 py-2",
|
|
126
|
+
cell: "px-3 py-2",
|
|
127
|
+
row: "h-8",
|
|
128
|
+
}
|
|
129
|
+
case "comfortable":
|
|
130
|
+
default:
|
|
131
|
+
return {
|
|
132
|
+
table: "text-sm",
|
|
133
|
+
header: "px-4 py-3",
|
|
134
|
+
cell: "px-4 py-3",
|
|
135
|
+
row: "h-12",
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}, [density])
|
|
139
|
+
|
|
140
|
+
// Styles CSS personnalisés
|
|
141
|
+
const customStyles = useMemo(() => {
|
|
142
|
+
const styles: Record<string, string> = {}
|
|
143
|
+
|
|
144
|
+
if (mergedTheme.colors) {
|
|
145
|
+
Object.entries(mergedTheme.colors).forEach(([key, value]) => {
|
|
146
|
+
styles[`--datatable-color-${key}`] = value
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (mergedTheme.spacing) {
|
|
151
|
+
Object.entries(mergedTheme.spacing).forEach(([key, value]) => {
|
|
152
|
+
styles[`--datatable-spacing-${key}`] = value
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (mergedTheme.typography) {
|
|
157
|
+
if (mergedTheme.typography.fontFamily) {
|
|
158
|
+
styles["--datatable-font-family"] = mergedTheme.typography.fontFamily
|
|
159
|
+
}
|
|
160
|
+
if (mergedTheme.typography.fontSize) {
|
|
161
|
+
Object.entries(mergedTheme.typography.fontSize).forEach(([key, value]) => {
|
|
162
|
+
styles[`--datatable-font-size-${key}`] = value
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
if (mergedTheme.typography.fontWeight) {
|
|
166
|
+
Object.entries(mergedTheme.typography.fontWeight).forEach(([key, value]) => {
|
|
167
|
+
styles[`--datatable-font-weight-${key}`] = value
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (mergedTheme.borders) {
|
|
173
|
+
if (mergedTheme.borders.radius) {
|
|
174
|
+
Object.entries(mergedTheme.borders.radius).forEach(([key, value]) => {
|
|
175
|
+
styles[`--datatable-radius-${key}`] = value
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
if (mergedTheme.borders.width) {
|
|
179
|
+
Object.entries(mergedTheme.borders.width).forEach(([key, value]) => {
|
|
180
|
+
styles[`--datatable-border-width-${key}`] = value
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (mergedTheme.shadows) {
|
|
186
|
+
Object.entries(mergedTheme.shadows).forEach(([key, value]) => {
|
|
187
|
+
styles[`--datatable-shadow-${key}`] = value
|
|
188
|
+
})
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return styles
|
|
192
|
+
}, [mergedTheme])
|
|
193
|
+
|
|
194
|
+
// Fonction pour obtenir une classe CSS avec le thème
|
|
195
|
+
const getThemedClass = useCallback((baseClass: string, themeKey?: string) => {
|
|
196
|
+
if (!themeKey) return baseClass
|
|
197
|
+
return `${baseClass} [--datatable-theme-key:${themeKey}]`
|
|
198
|
+
}, [])
|
|
199
|
+
|
|
200
|
+
// Fonction pour obtenir des styles inline avec le thème
|
|
201
|
+
const getThemedStyles = useCallback((baseStyles: React.CSSProperties = {}) => {
|
|
202
|
+
return { ...baseStyles, ...customStyles }
|
|
203
|
+
}, [customStyles])
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
theme: mergedTheme,
|
|
207
|
+
variantClasses,
|
|
208
|
+
densityClasses,
|
|
209
|
+
customStyles,
|
|
210
|
+
getThemedClass,
|
|
211
|
+
getThemedStyles,
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useMemo, useCallback, useState, useEffect } from "react"
|
|
2
|
+
import { useVirtualizer } from "@tanstack/react-virtual"
|
|
3
|
+
import { VirtualizationConfig } from "../types"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Hook pour gérer la virtualisation du DataTable
|
|
7
|
+
*/
|
|
8
|
+
export function useDataTableVirtualization<TData>({
|
|
9
|
+
data,
|
|
10
|
+
virtualization,
|
|
11
|
+
containerRef,
|
|
12
|
+
}: {
|
|
13
|
+
data: TData[]
|
|
14
|
+
virtualization?: VirtualizationConfig
|
|
15
|
+
containerRef: React.RefObject<HTMLElement>
|
|
16
|
+
}) {
|
|
17
|
+
const [containerHeight, setContainerHeight] = useState(
|
|
18
|
+
virtualization?.containerHeight || 600
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
// Observer pour détecter les changements de taille du conteneur
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!containerRef.current || !virtualization) return
|
|
24
|
+
|
|
25
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
setContainerHeight(entry.contentRect.height)
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
resizeObserver.observe(containerRef.current)
|
|
32
|
+
|
|
33
|
+
return () => {
|
|
34
|
+
resizeObserver.disconnect()
|
|
35
|
+
}
|
|
36
|
+
}, [containerRef, virtualization])
|
|
37
|
+
|
|
38
|
+
// Configuration de la virtualisation
|
|
39
|
+
const virtualizerConfig = useMemo(() => {
|
|
40
|
+
if (!virtualization || virtualization.type === "none") {
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const config = {
|
|
45
|
+
count: data.length,
|
|
46
|
+
getScrollElement: () => containerRef.current,
|
|
47
|
+
estimateSize: () => virtualization.itemHeight || 50,
|
|
48
|
+
overscan: virtualization.overscan || 5,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Configuration pour la virtualisation dynamique
|
|
52
|
+
if (virtualization.type === "dynamic") {
|
|
53
|
+
return {
|
|
54
|
+
...config,
|
|
55
|
+
estimateSize: () => virtualization.estimatedItemHeight || 50,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return config
|
|
60
|
+
}, [data.length, virtualization, containerRef])
|
|
61
|
+
|
|
62
|
+
// Création du virtualizer seulement si la virtualisation est activée
|
|
63
|
+
const virtualizer = virtualizerConfig ? useVirtualizer(virtualizerConfig) : null
|
|
64
|
+
|
|
65
|
+
// Fonctions utilitaires
|
|
66
|
+
const scrollToIndex = useCallback((index: number, align: "start" | "center" | "end" = "start") => {
|
|
67
|
+
if (virtualizer) {
|
|
68
|
+
virtualizer.scrollToIndex(index, { align })
|
|
69
|
+
}
|
|
70
|
+
}, [virtualizer])
|
|
71
|
+
|
|
72
|
+
const scrollToOffset = useCallback((offset: number) => {
|
|
73
|
+
if (virtualizer) {
|
|
74
|
+
virtualizer.scrollToOffset(offset)
|
|
75
|
+
}
|
|
76
|
+
}, [virtualizer])
|
|
77
|
+
|
|
78
|
+
const getVirtualItems = useCallback(() => {
|
|
79
|
+
return virtualizer ? virtualizer.getVirtualItems() : []
|
|
80
|
+
}, [virtualizer])
|
|
81
|
+
|
|
82
|
+
const getTotalSize = useCallback(() => {
|
|
83
|
+
return virtualizer ? virtualizer.getTotalSize() : 0
|
|
84
|
+
}, [virtualizer])
|
|
85
|
+
|
|
86
|
+
const isVirtualized = virtualization?.type !== "none" && virtualizerConfig !== null
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
virtualizer,
|
|
90
|
+
isVirtualized,
|
|
91
|
+
containerHeight,
|
|
92
|
+
scrollToIndex,
|
|
93
|
+
scrollToOffset,
|
|
94
|
+
getVirtualItems,
|
|
95
|
+
getTotalSize,
|
|
96
|
+
virtualItems: virtualizer ? virtualizer.getVirtualItems() : [],
|
|
97
|
+
totalSize: virtualizer ? virtualizer.getTotalSize() : 0,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useState, useEffect, useCallback } from "react"
|
|
2
|
+
import { DataTableLayout, DataTableDensity } from "../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Hook pour gérer le layout et la densité du DataTable
|
|
6
|
+
*/
|
|
7
|
+
export function useTableLayout(
|
|
8
|
+
initialLayout: DataTableLayout = "standard",
|
|
9
|
+
initialDensity: DataTableDensity = "comfortable"
|
|
10
|
+
) {
|
|
11
|
+
const [layout, setLayout] = useState<DataTableLayout>(initialLayout)
|
|
12
|
+
const [density, setDensity] = useState<DataTableDensity>(initialDensity)
|
|
13
|
+
const [isMobile, setIsMobile] = useState(false)
|
|
14
|
+
|
|
15
|
+
// Détection mobile
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const checkMobile = () => {
|
|
18
|
+
setIsMobile(window.innerWidth < 768)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
checkMobile()
|
|
22
|
+
window.addEventListener("resize", checkMobile)
|
|
23
|
+
|
|
24
|
+
return () => window.removeEventListener("resize", checkMobile)
|
|
25
|
+
}, [])
|
|
26
|
+
|
|
27
|
+
// Basculer automatiquement en mode card sur mobile si en mode standard
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (isMobile && layout === "standard") {
|
|
30
|
+
setLayout("card")
|
|
31
|
+
}
|
|
32
|
+
}, [isMobile, layout])
|
|
33
|
+
|
|
34
|
+
// Toggle de layout
|
|
35
|
+
const toggleLayout = useCallback(() => {
|
|
36
|
+
setLayout((prev) => {
|
|
37
|
+
switch (prev) {
|
|
38
|
+
case "standard":
|
|
39
|
+
return "card"
|
|
40
|
+
case "card":
|
|
41
|
+
return "compact"
|
|
42
|
+
case "compact":
|
|
43
|
+
return "standard"
|
|
44
|
+
default:
|
|
45
|
+
return "standard"
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}, [])
|
|
49
|
+
|
|
50
|
+
// Toggle de densité
|
|
51
|
+
const toggleDensity = useCallback(() => {
|
|
52
|
+
setDensity((prev) => (prev === "comfortable" ? "compact" : "comfortable"))
|
|
53
|
+
}, [])
|
|
54
|
+
|
|
55
|
+
// Classes CSS selon la densité
|
|
56
|
+
const densityClasses = {
|
|
57
|
+
comfortable: {
|
|
58
|
+
table: "text-sm",
|
|
59
|
+
cell: "px-4 py-3",
|
|
60
|
+
header: "px-4 py-3",
|
|
61
|
+
},
|
|
62
|
+
compact: {
|
|
63
|
+
table: "text-xs",
|
|
64
|
+
cell: "px-2 py-1.5",
|
|
65
|
+
header: "px-2 py-2",
|
|
66
|
+
},
|
|
67
|
+
spacious: {
|
|
68
|
+
table: "text-base",
|
|
69
|
+
cell: "px-6 py-4",
|
|
70
|
+
header: "px-6 py-4",
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
layout,
|
|
76
|
+
setLayout,
|
|
77
|
+
density,
|
|
78
|
+
setDensity,
|
|
79
|
+
toggleLayout,
|
|
80
|
+
toggleDensity,
|
|
81
|
+
isMobile,
|
|
82
|
+
densityClasses: densityClasses[density],
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataTable - Composant ultra-complet basé sur TanStack Table v8
|
|
3
|
+
*
|
|
4
|
+
* @module DataTable
|
|
5
|
+
* @description
|
|
6
|
+
* Composant de table de données hautement configurable avec support de :
|
|
7
|
+
* - Tri, filtrage, pagination
|
|
8
|
+
* - Sélection multiple
|
|
9
|
+
* - Export/Import (CSV, JSON)
|
|
10
|
+
* - Layouts multiples (standard, card, compact, split, infinite)
|
|
11
|
+
* - Thème clair/sombre via TweakCN
|
|
12
|
+
* - i18n complet
|
|
13
|
+
* - Virtualisation pour grandes données
|
|
14
|
+
* - Toolbar customisable
|
|
15
|
+
* - Actions par ligne et groupées
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// Composant principal
|
|
19
|
+
export { DataTable } from "./DataTable"
|
|
20
|
+
export { DataTableAdvanced } from "./DataTableAdvanced"
|
|
21
|
+
|
|
22
|
+
// Sous-composants
|
|
23
|
+
export { DataTableToolbar } from "./DataTableToolbar"
|
|
24
|
+
export { DataTablePagination } from "./DataTablePagination"
|
|
25
|
+
export { DataTableFilters } from "./DataTableFilters"
|
|
26
|
+
export { DataTableEditCell } from "./DataTableEditCell"
|
|
27
|
+
export { DataTableColumnResizer } from "./DataTableColumnResizer"
|
|
28
|
+
export { DataTableGrouping, DataTableGroupTotals, DataTableGroupingControls } from "./DataTableGrouping"
|
|
29
|
+
export { DataTableContextMenu } from "./DataTableContextMenu"
|
|
30
|
+
export { DataTableSelection, useDataTableSelection } from "./DataTableSelection"
|
|
31
|
+
|
|
32
|
+
// Hooks
|
|
33
|
+
export { useDataTable } from "./hooks/useDataTable"
|
|
34
|
+
export { useDataTableAdvanced } from "./hooks/useDataTableAdvanced"
|
|
35
|
+
export { useDataTableVirtualization } from "./hooks/useDataTableVirtualization"
|
|
36
|
+
export { useDataTableExport } from "./hooks/useDataTableExport"
|
|
37
|
+
export { useDataTableImport } from "./hooks/useDataTableImport"
|
|
38
|
+
export { useDataTableTheme } from "./hooks/useDataTableTheme"
|
|
39
|
+
export { useTableLayout } from "./hooks/useTableLayout"
|
|
40
|
+
export { useDataTableEdit } from "./hooks/useDataTableEdit"
|
|
41
|
+
|
|
42
|
+
// Types
|
|
43
|
+
export type {
|
|
44
|
+
DataTableProps,
|
|
45
|
+
DataTableLayout,
|
|
46
|
+
DataTableVariant,
|
|
47
|
+
DataTableDensity,
|
|
48
|
+
DataTableState,
|
|
49
|
+
FilterConfig,
|
|
50
|
+
FilterPosition,
|
|
51
|
+
PaginationConfig,
|
|
52
|
+
ToolbarConfig,
|
|
53
|
+
TableAction,
|
|
54
|
+
ExportConfig,
|
|
55
|
+
ImportConfig,
|
|
56
|
+
SelectionState,
|
|
57
|
+
EditConfig,
|
|
58
|
+
ColumnEditConfig,
|
|
59
|
+
SelectionMode,
|
|
60
|
+
SortMode,
|
|
61
|
+
VirtualizationType,
|
|
62
|
+
GroupingConfig,
|
|
63
|
+
VirtualizationConfig,
|
|
64
|
+
ColumnResizeConfig,
|
|
65
|
+
ColumnOrderConfig,
|
|
66
|
+
RowExpansionConfig,
|
|
67
|
+
DataTableTheme,
|
|
68
|
+
} from "./types"
|
|
69
|
+
|
|
70
|
+
// Types d'édition
|
|
71
|
+
export type { EditCellConfig } from "./DataTableEditCell"
|
|
72
|
+
|
|
73
|
+
// Utilitaires
|
|
74
|
+
export {
|
|
75
|
+
exportToCSV,
|
|
76
|
+
exportToJSON,
|
|
77
|
+
parseCSV,
|
|
78
|
+
saveTableState,
|
|
79
|
+
loadTableState,
|
|
80
|
+
} from "./utils"
|
|
81
|
+
|