@wakastellar/ui 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/add.d.ts +7 -0
- package/dist/cli/commands/init.d.ts +6 -0
- package/dist/cli/commands/list.d.ts +5 -0
- package/dist/cli/commands/search.d.ts +1 -0
- package/dist/cli/index.cjs +4844 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/utils/config.d.ts +29 -0
- package/dist/cli/utils/logger.d.ts +20 -0
- package/dist/cli/utils/registry.d.ts +23 -0
- package/package.json +14 -3
- package/src/blocks/activity-timeline/index.tsx +586 -0
- package/src/blocks/calendar-view/index.tsx +756 -0
- package/src/blocks/chat/index.tsx +1018 -0
- package/src/blocks/chat/widget.tsx +504 -0
- package/src/blocks/dashboard/index.tsx +522 -0
- package/src/blocks/empty-states/index.tsx +452 -0
- package/src/blocks/error-pages/index.tsx +426 -0
- package/src/blocks/faq/index.tsx +479 -0
- package/src/blocks/file-manager/index.tsx +890 -0
- package/src/blocks/footer/index.tsx +133 -0
- package/src/blocks/header/index.tsx +357 -0
- package/src/blocks/headtab/index.tsx +139 -0
- package/src/blocks/i18n-editor/index.tsx +1016 -0
- package/src/blocks/index.ts +80 -0
- package/src/blocks/kanban-board/index.tsx +779 -0
- package/src/blocks/landing/index.tsx +677 -0
- package/src/blocks/language-selector/index.tsx +88 -0
- package/src/blocks/layout/index.tsx +159 -0
- package/src/blocks/login/index.tsx +339 -0
- package/src/blocks/login/types.ts +131 -0
- package/src/blocks/pricing/index.tsx +564 -0
- package/src/blocks/profile/index.tsx +746 -0
- package/src/blocks/settings/index.tsx +558 -0
- package/src/blocks/sidebar/index.tsx +713 -0
- package/src/blocks/theme-creator-block/index.tsx +835 -0
- package/src/blocks/user-management/index.tsx +1037 -0
- package/src/blocks/wizard/index.tsx +719 -0
- package/src/components/DataTable/DataTable.tsx +406 -0
- package/src/components/DataTable/DataTableAdvanced.tsx +720 -0
- package/src/components/DataTable/DataTableBody.tsx +216 -0
- package/src/components/DataTable/DataTableCell.tsx +172 -0
- package/src/components/DataTable/DataTableColumnResizer.tsx +62 -0
- package/src/components/DataTable/DataTableConflictResolver.tsx +478 -0
- package/src/components/DataTable/DataTableContextMenu.tsx +219 -0
- package/src/components/DataTable/DataTableEditCell.tsx +279 -0
- package/src/components/DataTable/DataTableFilterBuilder.tsx +519 -0
- package/src/components/DataTable/DataTableFilters.tsx +535 -0
- package/src/components/DataTable/DataTableGrouping.tsx +147 -0
- package/src/components/DataTable/DataTableHeader.tsx +172 -0
- package/src/components/DataTable/DataTablePagination.tsx +125 -0
- package/src/components/DataTable/DataTableSelection.tsx +269 -0
- package/src/components/DataTable/DataTableSyncStatus.tsx +281 -0
- package/src/components/DataTable/DataTableToolbar.tsx +262 -0
- package/src/components/DataTable/README.md +446 -0
- package/src/components/DataTable/__tests__/DataTableAdvanced.test.tsx +426 -0
- package/src/components/DataTable/__tests__/DataTableEdit.test.tsx +329 -0
- package/src/components/DataTable/__tests__/useDataTableAdvanced.test.ts +455 -0
- package/src/components/DataTable/examples/EditExample.tsx +166 -0
- package/src/components/DataTable/formatters/index.ts +335 -0
- package/src/components/DataTable/hooks/__tests__/useDataTableEdit.test.ts +239 -0
- package/src/components/DataTable/hooks/useDataTable.ts +145 -0
- package/src/components/DataTable/hooks/useDataTableAdvanced.ts +342 -0
- package/src/components/DataTable/hooks/useDataTableAdvancedFilters.ts +637 -0
- package/src/components/DataTable/hooks/useDataTableColumnTemplates.ts +186 -0
- package/src/components/DataTable/hooks/useDataTableEdit.ts +167 -0
- package/src/components/DataTable/hooks/useDataTableExport.ts +227 -0
- package/src/components/DataTable/hooks/useDataTableImport.ts +216 -0
- package/src/components/DataTable/hooks/useDataTableOffline.ts +481 -0
- package/src/components/DataTable/hooks/useDataTableTheme.ts +213 -0
- package/src/components/DataTable/hooks/useDataTableVirtualization.ts +99 -0
- package/src/components/DataTable/hooks/useTableLayout.ts +85 -0
- package/src/components/DataTable/index.ts +81 -0
- package/src/components/DataTable/services/IndexedDBService.ts +504 -0
- package/src/components/DataTable/templates/index.tsx +803 -0
- package/src/components/DataTable/types.ts +504 -0
- package/src/components/DataTable/utils.ts +164 -0
- package/src/components/DataTable/workers/exportWorker.ts +213 -0
- package/src/components/accordion/index.tsx +61 -0
- package/src/components/alert/index.tsx +61 -0
- package/src/components/alert-dialog/index.tsx +146 -0
- package/src/components/aspect-ratio/index.tsx +12 -0
- package/src/components/avatar/index.tsx +54 -0
- package/src/components/badge/Badge.stories.tsx +64 -0
- package/src/components/badge/index.tsx +38 -0
- package/src/components/button/Button.stories.tsx +173 -0
- package/src/components/button/index.tsx +56 -0
- package/src/components/calendar/index.tsx +73 -0
- package/src/components/card/index.tsx +78 -0
- package/src/components/checkbox/index.tsx +34 -0
- package/src/components/code/index.tsx +229 -0
- package/src/components/collapsible/index.tsx +16 -0
- package/src/components/command/index.tsx +162 -0
- package/src/components/context-menu/index.tsx +204 -0
- package/src/components/dialog/index.tsx +126 -0
- package/src/components/dropdown-menu/index.tsx +204 -0
- package/src/components/error-boundary/ErrorBoundary.tsx +281 -0
- package/src/components/error-boundary/index.ts +7 -0
- package/src/components/form/index.tsx +183 -0
- package/src/components/hover-card/index.tsx +33 -0
- package/src/components/index.ts +368 -0
- package/src/components/input/Input.stories.tsx +100 -0
- package/src/components/input/index.tsx +27 -0
- package/src/components/input-otp/index.tsx +277 -0
- package/src/components/label/index.tsx +30 -0
- package/src/components/language-selector/index.tsx +341 -0
- package/src/components/menubar/index.tsx +240 -0
- package/src/components/navigation-menu/index.tsx +134 -0
- package/src/components/popover/index.tsx +35 -0
- package/src/components/progress/index.tsx +32 -0
- package/src/components/radio-group/index.tsx +48 -0
- package/src/components/scroll-area/index.tsx +52 -0
- package/src/components/select/index.tsx +164 -0
- package/src/components/separator/index.tsx +35 -0
- package/src/components/sheet/index.tsx +147 -0
- package/src/components/skeleton/index.tsx +22 -0
- package/src/components/slider/index.tsx +32 -0
- package/src/components/switch/index.tsx +33 -0
- package/src/components/table/index.tsx +117 -0
- package/src/components/tabs/index.tsx +59 -0
- package/src/components/textarea/index.tsx +30 -0
- package/src/components/theme-selector/index.tsx +327 -0
- package/src/components/toast/index.tsx +133 -0
- package/src/components/toaster/index.tsx +34 -0
- package/src/components/toggle/index.tsx +49 -0
- package/src/components/tooltip/index.tsx +34 -0
- package/src/components/typography/index.tsx +276 -0
- package/src/components/waka-3d-pie-chart/index.tsx +486 -0
- package/src/components/waka-achievement-unlock/index.tsx +716 -0
- package/src/components/waka-activity-feed/index.tsx +686 -0
- package/src/components/waka-address-autocomplete/index.tsx +1202 -0
- package/src/components/waka-admincrumb/index.tsx +349 -0
- package/src/components/waka-alert-stack/index.tsx +827 -0
- package/src/components/waka-allocation-matrix/index.tsx +1278 -0
- package/src/components/waka-approval-chain/index.tsx +766 -0
- package/src/components/waka-audit-log/index.tsx +1475 -0
- package/src/components/waka-autocomplete/index.tsx +358 -0
- package/src/components/waka-badge-showcase/index.tsx +704 -0
- package/src/components/waka-barcode/index.tsx +260 -0
- package/src/components/waka-biometric-prompt/index.tsx +765 -0
- package/src/components/waka-bottom-sheet/index.tsx +495 -0
- package/src/components/waka-breadcrumb/index.tsx +376 -0
- package/src/components/waka-breadcrumb-path/index.tsx +513 -0
- package/src/components/waka-budget-burn/index.tsx +1234 -0
- package/src/components/waka-capacity-planner/index.tsx +1107 -0
- package/src/components/waka-carousel/index.tsx +893 -0
- package/src/components/waka-cart-summary/index.tsx +1055 -0
- package/src/components/waka-challenge-timer/index.tsx +1044 -0
- package/src/components/waka-charts/WakaAreaChart.tsx +251 -0
- package/src/components/waka-charts/WakaBarChart.tsx +222 -0
- package/src/components/waka-charts/WakaChart.tsx +124 -0
- package/src/components/waka-charts/WakaLineChart.tsx +219 -0
- package/src/components/waka-charts/WakaMiniChart.tsx +133 -0
- package/src/components/waka-charts/WakaPieChart.tsx +214 -0
- package/src/components/waka-charts/WakaSparkline.tsx +229 -0
- package/src/components/waka-charts/dataTableHelpers.ts +109 -0
- package/src/components/waka-charts/hooks/useChartTheme.ts +123 -0
- package/src/components/waka-charts/hooks/useRechartsLoader.ts +234 -0
- package/src/components/waka-charts/index.ts +90 -0
- package/src/components/waka-charts/types.ts +330 -0
- package/src/components/waka-chat-bubble/index.tsx +1060 -0
- package/src/components/waka-checklist/index.tsx +1067 -0
- package/src/components/waka-checkout-stepper/index.tsx +976 -0
- package/src/components/waka-cohort-table/index.tsx +1011 -0
- package/src/components/waka-color-picker/index.tsx +447 -0
- package/src/components/waka-combo-counter/index.tsx +864 -0
- package/src/components/waka-combobox/index.tsx +497 -0
- package/src/components/waka-command-bar/index.tsx +403 -0
- package/src/components/waka-compare-period/index.tsx +1230 -0
- package/src/components/waka-connection-matrix/index.tsx +1053 -0
- package/src/components/waka-contribution-graph/index.tsx +552 -0
- package/src/components/waka-cost-breakdown/index.tsx +1065 -0
- package/src/components/waka-coupon-input/index.tsx +592 -0
- package/src/components/waka-credit-card-input/index.tsx +982 -0
- package/src/components/waka-daily-reward/index.tsx +762 -0
- package/src/components/waka-date-range-picker/index.tsx +378 -0
- package/src/components/waka-datetime-picker/index.tsx +793 -0
- package/src/components/waka-datetime-picker.form-integration/index.tsx +402 -0
- package/src/components/waka-deployment-lane/index.tsx +673 -0
- package/src/components/waka-device-trust/index.tsx +1259 -0
- package/src/components/waka-dock/index.tsx +285 -0
- package/src/components/waka-drawer/index.tsx +319 -0
- package/src/components/waka-empty-state/index.tsx +545 -0
- package/src/components/waka-error-shake/index.tsx +398 -0
- package/src/components/waka-feature-announcement/index.tsx +991 -0
- package/src/components/waka-file-upload/index.tsx +437 -0
- package/src/components/waka-floating-nav/index.tsx +413 -0
- package/src/components/waka-flow-diagram/index.tsx +508 -0
- package/src/components/waka-funnel-chart/index.tsx +823 -0
- package/src/components/waka-glow-card/index.tsx +246 -0
- package/src/components/waka-goal-progress/index.tsx +1025 -0
- package/src/components/waka-haptic-button/index.tsx +388 -0
- package/src/components/waka-health-pulse/index.tsx +451 -0
- package/src/components/waka-heatmap/index.tsx +1026 -0
- package/src/components/waka-hotspot/index.tsx +682 -0
- package/src/components/waka-image/index.tsx +373 -0
- package/src/components/waka-incident-timeline/index.tsx +686 -0
- package/src/components/waka-invoice-preview/index.tsx +829 -0
- package/src/components/waka-kanban/index.tsx +646 -0
- package/src/components/waka-kpi-dashboard/index.tsx +755 -0
- package/src/components/waka-leaderboard/index.tsx +746 -0
- package/src/components/waka-level-progress/index.tsx +665 -0
- package/src/components/waka-liquid-button/index.tsx +520 -0
- package/src/components/waka-loading-orbit/index.tsx +478 -0
- package/src/components/waka-loot-box/index.tsx +1091 -0
- package/src/components/waka-magic-link/index.tsx +321 -0
- package/src/components/waka-magnetic-button/index.tsx +567 -0
- package/src/components/waka-mention-input/index.tsx +953 -0
- package/src/components/waka-metric-sparkline/index.tsx +627 -0
- package/src/components/waka-milestone-road/index.tsx +1064 -0
- package/src/components/waka-modal/index.tsx +374 -0
- package/src/components/waka-morph-button/index.tsx +495 -0
- package/src/components/waka-network-topology/index.tsx +801 -0
- package/src/components/waka-notifications/index.tsx +414 -0
- package/src/components/waka-number-input/index.tsx +373 -0
- package/src/components/waka-orbital-menu/index.tsx +445 -0
- package/src/components/waka-order-tracker/index.tsx +1041 -0
- package/src/components/waka-pagination/index.tsx +393 -0
- package/src/components/waka-password-strength/index.tsx +824 -0
- package/src/components/waka-payment-method-picker/index.tsx +715 -0
- package/src/components/waka-permission-matrix/index.tsx +1302 -0
- package/src/components/waka-phone-input/index.tsx +801 -0
- package/src/components/waka-pipeline-view/index.tsx +604 -0
- package/src/components/waka-player-card/index.tsx +691 -0
- package/src/components/waka-points-popup/index.tsx +366 -0
- package/src/components/waka-power-up/index.tsx +1155 -0
- package/src/components/waka-presence-indicator/index.tsx +1181 -0
- package/src/components/waka-pricing-table/index.tsx +755 -0
- package/src/components/waka-product-card/index.tsx +786 -0
- package/src/components/waka-progress-onboarding/index.tsx +878 -0
- package/src/components/waka-pull-to-refresh/index.tsx +451 -0
- package/src/components/waka-qrcode/index.tsx +232 -0
- package/src/components/waka-quest-card/index.tsx +1275 -0
- package/src/components/waka-quota-bar/index.tsx +693 -0
- package/src/components/waka-radar-score/index.tsx +512 -0
- package/src/components/waka-rank-badge/index.tsx +813 -0
- package/src/components/waka-rating-input/index.tsx +560 -0
- package/src/components/waka-reaction-picker/index.tsx +1062 -0
- package/src/components/waka-region-map/index.tsx +730 -0
- package/src/components/waka-resource-gauge/index.tsx +654 -0
- package/src/components/waka-resource-pool/index.tsx +1035 -0
- package/src/components/waka-rich-text-editor/index.tsx +594 -0
- package/src/components/waka-rollback-slider/index.tsx +891 -0
- package/src/components/waka-sankey-diagram/index.tsx +1032 -0
- package/src/components/waka-schedule-picker/index.tsx +1060 -0
- package/src/components/waka-scratch-card/index.tsx +914 -0
- package/src/components/waka-season-pass/index.tsx +886 -0
- package/src/components/waka-security-score/index.tsx +1126 -0
- package/src/components/waka-segmented-control/index.tsx +238 -0
- package/src/components/waka-server-rack/index.tsx +764 -0
- package/src/components/waka-session-manager/index.tsx +815 -0
- package/src/components/waka-signature-pad/index.tsx +744 -0
- package/src/components/waka-skeleton-wave/index.tsx +454 -0
- package/src/components/waka-skill-tree/index.tsx +1031 -0
- package/src/components/waka-sla-tracker/index.tsx +798 -0
- package/src/components/waka-slider-range/index.tsx +765 -0
- package/src/components/waka-spin-wheel/index.tsx +671 -0
- package/src/components/waka-spinner/index.tsx +284 -0
- package/src/components/waka-spotlight/index.tsx +410 -0
- package/src/components/waka-stat/index.tsx +428 -0
- package/src/components/waka-stats-hexagon/index.tsx +824 -0
- package/src/components/waka-status-matrix/index.tsx +565 -0
- package/src/components/waka-stepper/index.tsx +489 -0
- package/src/components/waka-streak-counter/index.tsx +334 -0
- package/src/components/waka-success-explosion/index.tsx +453 -0
- package/src/components/waka-swipe-card/index.tsx +574 -0
- package/src/components/waka-tabs-morph/index.tsx +509 -0
- package/src/components/waka-tag-input/index.tsx +877 -0
- package/src/components/waka-team-banner/index.tsx +1183 -0
- package/src/components/waka-terminal-output/index.tsx +836 -0
- package/src/components/waka-theme-creator/index.tsx +762 -0
- package/src/components/waka-theme-manager/index.tsx +654 -0
- package/src/components/waka-thread-view/index.tsx +874 -0
- package/src/components/waka-tilt-card/index.tsx +250 -0
- package/src/components/waka-time-picker/index.tsx +479 -0
- package/src/components/waka-timeline/index.tsx +385 -0
- package/src/components/waka-tooltip-tour/index.tsx +855 -0
- package/src/components/waka-tour-guide/index.tsx +920 -0
- package/src/components/waka-tournament-bracket/index.tsx +1276 -0
- package/src/components/waka-tree/index.tsx +557 -0
- package/src/components/waka-treemap-chart/index.tsx +1031 -0
- package/src/components/waka-two-factor-setup/index.tsx +995 -0
- package/src/components/waka-typewriter/index.tsx +566 -0
- package/src/components/waka-typing-indicator/index.tsx +649 -0
- package/src/components/waka-versus-card/index.tsx +1026 -0
- package/src/components/waka-video/index.tsx +557 -0
- package/src/components/waka-video-call/index.tsx +1087 -0
- package/src/components/waka-virtual-list/index.tsx +327 -0
- package/src/components/waka-voice-message/index.tsx +1019 -0
- package/src/components/waka-welcome-modal/index.tsx +790 -0
- package/src/components/waka-xp-bar/index.tsx +799 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { Input } from "../input"
|
|
5
|
+
import { Textarea } from "../textarea"
|
|
6
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../select"
|
|
7
|
+
import { Checkbox } from "../checkbox"
|
|
8
|
+
import { Switch } from "../switch"
|
|
9
|
+
import { Calendar } from "../calendar"
|
|
10
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../popover"
|
|
11
|
+
import { Button } from "../button"
|
|
12
|
+
import { CalendarIcon, Check, X } from "lucide-react"
|
|
13
|
+
import { format } from "date-fns"
|
|
14
|
+
import { cn } from "./utils"
|
|
15
|
+
|
|
16
|
+
export interface EditCellConfig {
|
|
17
|
+
type: "text" | "number" | "email" | "url" | "textarea" | "select" | "checkbox" | "switch" | "date" | "datetime"
|
|
18
|
+
options?: Array<{ value: string; label: string }>
|
|
19
|
+
placeholder?: string
|
|
20
|
+
min?: number
|
|
21
|
+
max?: number
|
|
22
|
+
step?: number
|
|
23
|
+
rows?: number
|
|
24
|
+
disabled?: boolean
|
|
25
|
+
required?: boolean
|
|
26
|
+
pattern?: string
|
|
27
|
+
title?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface DataTableEditCellProps<TData> {
|
|
31
|
+
value: any
|
|
32
|
+
field: keyof TData
|
|
33
|
+
config: EditCellConfig
|
|
34
|
+
isEditing: boolean
|
|
35
|
+
error?: string
|
|
36
|
+
onChange: (value: any) => void
|
|
37
|
+
onStartEdit: () => void
|
|
38
|
+
onSave: () => void
|
|
39
|
+
onCancel: () => void
|
|
40
|
+
className?: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function DataTableEditCell<TData>({
|
|
44
|
+
value,
|
|
45
|
+
field,
|
|
46
|
+
config,
|
|
47
|
+
isEditing,
|
|
48
|
+
error,
|
|
49
|
+
onChange,
|
|
50
|
+
onStartEdit,
|
|
51
|
+
onSave,
|
|
52
|
+
onCancel,
|
|
53
|
+
className,
|
|
54
|
+
}: DataTableEditCellProps<TData>) {
|
|
55
|
+
const [tempValue, setTempValue] = React.useState(value)
|
|
56
|
+
const [isDatePickerOpen, setIsDatePickerOpen] = React.useState(false)
|
|
57
|
+
|
|
58
|
+
// Synchroniser la valeur temporaire avec la valeur externe
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
setTempValue(value)
|
|
61
|
+
}, [value])
|
|
62
|
+
|
|
63
|
+
const handleSave = () => {
|
|
64
|
+
onChange(tempValue)
|
|
65
|
+
onSave()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const handleCancel = () => {
|
|
69
|
+
setTempValue(value)
|
|
70
|
+
onCancel()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const handleKeyDown = (e: React.KeyboardEvent) => {
|
|
74
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
75
|
+
e.preventDefault()
|
|
76
|
+
handleSave()
|
|
77
|
+
} else if (e.key === "Escape") {
|
|
78
|
+
e.preventDefault()
|
|
79
|
+
handleCancel()
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Si pas en mode édition, afficher la valeur avec possibilité de clic
|
|
84
|
+
if (!isEditing) {
|
|
85
|
+
return (
|
|
86
|
+
<div
|
|
87
|
+
className={cn(
|
|
88
|
+
"cursor-pointer hover:bg-muted/50 p-1 rounded transition-colors",
|
|
89
|
+
className
|
|
90
|
+
)}
|
|
91
|
+
onClick={onStartEdit}
|
|
92
|
+
>
|
|
93
|
+
{renderDisplayValue(value, config)}
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Rendu selon le type de champ
|
|
99
|
+
const renderInput = () => {
|
|
100
|
+
switch (config.type) {
|
|
101
|
+
case "textarea":
|
|
102
|
+
return (
|
|
103
|
+
<Textarea
|
|
104
|
+
value={tempValue || ""}
|
|
105
|
+
onChange={(e) => setTempValue(e.target.value)}
|
|
106
|
+
onKeyDown={handleKeyDown}
|
|
107
|
+
placeholder={config.placeholder}
|
|
108
|
+
rows={config.rows || 3}
|
|
109
|
+
disabled={config.disabled}
|
|
110
|
+
className={cn(error && "border-destructive")}
|
|
111
|
+
/>
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
case "select":
|
|
115
|
+
return (
|
|
116
|
+
<Select
|
|
117
|
+
value={tempValue || ""}
|
|
118
|
+
onValueChange={setTempValue}
|
|
119
|
+
disabled={config.disabled}
|
|
120
|
+
>
|
|
121
|
+
<SelectTrigger className={cn(error && "border-destructive")}>
|
|
122
|
+
<SelectValue placeholder={config.placeholder} />
|
|
123
|
+
</SelectTrigger>
|
|
124
|
+
<SelectContent>
|
|
125
|
+
{config.options?.map((option) => (
|
|
126
|
+
<SelectItem key={option.value} value={option.value}>
|
|
127
|
+
{option.label}
|
|
128
|
+
</SelectItem>
|
|
129
|
+
))}
|
|
130
|
+
</SelectContent>
|
|
131
|
+
</Select>
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
case "checkbox":
|
|
135
|
+
return (
|
|
136
|
+
<Checkbox
|
|
137
|
+
checked={Boolean(tempValue)}
|
|
138
|
+
onCheckedChange={setTempValue}
|
|
139
|
+
disabled={config.disabled}
|
|
140
|
+
/>
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
case "switch":
|
|
144
|
+
return (
|
|
145
|
+
<Switch
|
|
146
|
+
checked={Boolean(tempValue)}
|
|
147
|
+
onCheckedChange={setTempValue}
|
|
148
|
+
disabled={config.disabled}
|
|
149
|
+
/>
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
case "date":
|
|
153
|
+
case "datetime":
|
|
154
|
+
return (
|
|
155
|
+
<Popover open={isDatePickerOpen} onOpenChange={setIsDatePickerOpen}>
|
|
156
|
+
<PopoverTrigger asChild>
|
|
157
|
+
<Button
|
|
158
|
+
variant="outline"
|
|
159
|
+
className={cn(
|
|
160
|
+
"w-full justify-start text-left font-normal",
|
|
161
|
+
!tempValue && "text-muted-foreground",
|
|
162
|
+
error && "border-destructive"
|
|
163
|
+
)}
|
|
164
|
+
>
|
|
165
|
+
<CalendarIcon className="mr-2 h-4 w-4" />
|
|
166
|
+
{tempValue ? format(new Date(tempValue), "PPP") : config.placeholder}
|
|
167
|
+
</Button>
|
|
168
|
+
</PopoverTrigger>
|
|
169
|
+
<PopoverContent className="w-auto p-0" align="start">
|
|
170
|
+
<Calendar
|
|
171
|
+
mode="single"
|
|
172
|
+
selected={tempValue ? new Date(tempValue) : undefined}
|
|
173
|
+
onSelect={(date) => {
|
|
174
|
+
if (date) {
|
|
175
|
+
setTempValue(config.type === "datetime" ? date.toISOString() : date.toISOString().split('T')[0])
|
|
176
|
+
setIsDatePickerOpen(false)
|
|
177
|
+
}
|
|
178
|
+
}}
|
|
179
|
+
initialFocus
|
|
180
|
+
/>
|
|
181
|
+
</PopoverContent>
|
|
182
|
+
</Popover>
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
default:
|
|
186
|
+
return (
|
|
187
|
+
<Input
|
|
188
|
+
type={config.type}
|
|
189
|
+
value={tempValue || ""}
|
|
190
|
+
onChange={(e) => setTempValue(e.target.value)}
|
|
191
|
+
onKeyDown={handleKeyDown}
|
|
192
|
+
placeholder={config.placeholder}
|
|
193
|
+
min={config.min}
|
|
194
|
+
max={config.max}
|
|
195
|
+
step={config.step}
|
|
196
|
+
disabled={config.disabled}
|
|
197
|
+
required={config.required}
|
|
198
|
+
pattern={config.pattern}
|
|
199
|
+
title={config.title}
|
|
200
|
+
className={cn(error && "border-destructive")}
|
|
201
|
+
/>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<div className={cn("relative", className)}>
|
|
208
|
+
{renderInput()}
|
|
209
|
+
|
|
210
|
+
{/* Boutons d'action */}
|
|
211
|
+
<div className="absolute right-1 top-1/2 -translate-y-1/2 flex gap-1">
|
|
212
|
+
<Button
|
|
213
|
+
size="sm"
|
|
214
|
+
variant="ghost"
|
|
215
|
+
className="h-6 w-6 p-0"
|
|
216
|
+
onClick={handleSave}
|
|
217
|
+
>
|
|
218
|
+
<Check className="h-3 w-3 text-green-600" />
|
|
219
|
+
</Button>
|
|
220
|
+
<Button
|
|
221
|
+
size="sm"
|
|
222
|
+
variant="ghost"
|
|
223
|
+
className="h-6 w-6 p-0"
|
|
224
|
+
onClick={handleCancel}
|
|
225
|
+
>
|
|
226
|
+
<X className="h-3 w-3 text-red-600" />
|
|
227
|
+
</Button>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
{/* Message d'erreur */}
|
|
231
|
+
{error && (
|
|
232
|
+
<p className="text-xs text-destructive mt-1">{error}</p>
|
|
233
|
+
)}
|
|
234
|
+
</div>
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Fonction utilitaire pour afficher la valeur selon le type
|
|
239
|
+
function renderDisplayValue(value: any, config: EditCellConfig): React.ReactNode {
|
|
240
|
+
if (value === null || value === undefined) {
|
|
241
|
+
return <span className="text-muted-foreground italic">Non défini</span>
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
switch (config.type) {
|
|
245
|
+
case "checkbox":
|
|
246
|
+
case "switch":
|
|
247
|
+
return (
|
|
248
|
+
<span className={cn(
|
|
249
|
+
"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium",
|
|
250
|
+
value ? "bg-green-100 text-green-800" : "bg-gray-100 text-gray-800"
|
|
251
|
+
)}>
|
|
252
|
+
{value ? "Oui" : "Non"}
|
|
253
|
+
</span>
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
case "date":
|
|
257
|
+
case "datetime":
|
|
258
|
+
try {
|
|
259
|
+
const date = new Date(value)
|
|
260
|
+
return format(date, config.type === "datetime" ? "PPP p" : "PPP")
|
|
261
|
+
} catch {
|
|
262
|
+
return value
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
case "select":
|
|
266
|
+
const option = config.options?.find(opt => opt.value === value)
|
|
267
|
+
return option ? option.label : value
|
|
268
|
+
|
|
269
|
+
case "textarea":
|
|
270
|
+
return (
|
|
271
|
+
<div className="max-w-xs">
|
|
272
|
+
<p className="truncate">{value}</p>
|
|
273
|
+
</div>
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
default:
|
|
277
|
+
return value
|
|
278
|
+
}
|
|
279
|
+
}
|