@moontra/moonui-pro 2.20.1 → 2.20.3

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 (162) hide show
  1. package/dist/index.d.ts +691 -261
  2. package/dist/index.mjs +7418 -4934
  3. package/package.json +11 -5
  4. package/plugin/index.d.ts +86 -0
  5. package/plugin/index.js +308 -0
  6. package/scripts/postbuild.js +27 -0
  7. package/scripts/postinstall.js +176 -23
  8. package/src/__tests__/use-intersection-observer.test.tsx +0 -216
  9. package/src/__tests__/use-local-storage.test.tsx +0 -174
  10. package/src/__tests__/use-pro-access.test.tsx +0 -183
  11. package/src/components/advanced-chart/advanced-chart.test.tsx +0 -281
  12. package/src/components/advanced-chart/index.tsx +0 -1242
  13. package/src/components/advanced-forms/index.tsx +0 -426
  14. package/src/components/animated-button/index.tsx +0 -385
  15. package/src/components/calendar/event-dialog.tsx +0 -372
  16. package/src/components/calendar/index.tsx +0 -1073
  17. package/src/components/calendar-pro/index.tsx +0 -1697
  18. package/src/components/color-picker/index.tsx +0 -432
  19. package/src/components/credit-card-input/index.tsx +0 -406
  20. package/src/components/dashboard/dashboard-grid.tsx +0 -462
  21. package/src/components/dashboard/demo.tsx +0 -425
  22. package/src/components/dashboard/index.tsx +0 -1046
  23. package/src/components/dashboard/time-range-picker.tsx +0 -336
  24. package/src/components/dashboard/types.ts +0 -222
  25. package/src/components/dashboard/widgets/activity-feed.tsx +0 -344
  26. package/src/components/dashboard/widgets/chart-widget.tsx +0 -418
  27. package/src/components/dashboard/widgets/metric-card.tsx +0 -343
  28. package/src/components/data-table/data-table-bulk-actions.tsx +0 -204
  29. package/src/components/data-table/data-table-column-toggle.tsx +0 -169
  30. package/src/components/data-table/data-table-export.ts +0 -156
  31. package/src/components/data-table/data-table-filter-drawer.tsx +0 -448
  32. package/src/components/data-table/data-table.test.tsx +0 -187
  33. package/src/components/data-table/index.tsx +0 -845
  34. package/src/components/draggable-list/index.tsx +0 -100
  35. package/src/components/enhanced/badge.tsx +0 -191
  36. package/src/components/enhanced/button.tsx +0 -362
  37. package/src/components/enhanced/card.tsx +0 -266
  38. package/src/components/enhanced/dialog.tsx +0 -246
  39. package/src/components/enhanced/index.ts +0 -4
  40. package/src/components/error-boundary/index.tsx +0 -109
  41. package/src/components/file-upload/file-upload.test.tsx +0 -243
  42. package/src/components/file-upload/index.tsx +0 -1660
  43. package/src/components/floating-action-button/index.tsx +0 -206
  44. package/src/components/form-wizard/form-wizard-context.tsx +0 -307
  45. package/src/components/form-wizard/form-wizard-navigation.tsx +0 -118
  46. package/src/components/form-wizard/form-wizard-progress.tsx +0 -298
  47. package/src/components/form-wizard/form-wizard-step.tsx +0 -111
  48. package/src/components/form-wizard/index.tsx +0 -102
  49. package/src/components/form-wizard/types.ts +0 -76
  50. package/src/components/gesture-drawer/index.tsx +0 -551
  51. package/src/components/github-stars/github-api.ts +0 -426
  52. package/src/components/github-stars/hooks.ts +0 -516
  53. package/src/components/github-stars/index.tsx +0 -375
  54. package/src/components/github-stars/types.ts +0 -148
  55. package/src/components/github-stars/variants.tsx +0 -513
  56. package/src/components/health-check/index.tsx +0 -439
  57. package/src/components/hover-card-3d/index.tsx +0 -530
  58. package/src/components/index.ts +0 -128
  59. package/src/components/internal/index.ts +0 -78
  60. package/src/components/kanban/add-card-modal.tsx +0 -502
  61. package/src/components/kanban/card-detail-modal.tsx +0 -761
  62. package/src/components/kanban/index.ts +0 -13
  63. package/src/components/kanban/kanban.tsx +0 -1684
  64. package/src/components/kanban/types.ts +0 -168
  65. package/src/components/lazy-component/index.tsx +0 -823
  66. package/src/components/license-error/index.tsx +0 -29
  67. package/src/components/magnetic-button/index.tsx +0 -167
  68. package/src/components/memory-efficient-data/index.tsx +0 -1016
  69. package/src/components/moonui-quiz-form/index.tsx +0 -817
  70. package/src/components/optimized-image/index.tsx +0 -425
  71. package/src/components/performance-debugger/index.tsx +0 -589
  72. package/src/components/performance-monitor/index.tsx +0 -794
  73. package/src/components/phone-number-input/index.tsx +0 -338
  74. package/src/components/pinch-zoom/index.tsx +0 -566
  75. package/src/components/quiz-form/index.tsx +0 -479
  76. package/src/components/rich-text-editor/index-old-backup.tsx +0 -437
  77. package/src/components/rich-text-editor/index.tsx +0 -2324
  78. package/src/components/rich-text-editor/slash-commands-extension.ts +0 -220
  79. package/src/components/rich-text-editor/slash-commands.css +0 -35
  80. package/src/components/rich-text-editor/table-styles.css +0 -65
  81. package/src/components/sidebar/index.tsx +0 -865
  82. package/src/components/spotlight-card/index.tsx +0 -191
  83. package/src/components/swipeable-card/index.tsx +0 -100
  84. package/src/components/timeline/index.tsx +0 -1148
  85. package/src/components/ui/accordion.tsx +0 -73
  86. package/src/components/ui/alert-dialog.tsx +0 -141
  87. package/src/components/ui/alert.tsx +0 -141
  88. package/src/components/ui/aspect-ratio.tsx +0 -245
  89. package/src/components/ui/avatar.tsx +0 -153
  90. package/src/components/ui/badge.tsx +0 -228
  91. package/src/components/ui/breadcrumb.tsx +0 -214
  92. package/src/components/ui/button.tsx +0 -222
  93. package/src/components/ui/calendar.tsx +0 -387
  94. package/src/components/ui/card.tsx +0 -214
  95. package/src/components/ui/checkbox.tsx +0 -259
  96. package/src/components/ui/collapsible.tsx +0 -135
  97. package/src/components/ui/color-picker.tsx +0 -97
  98. package/src/components/ui/command.tsx +0 -225
  99. package/src/components/ui/dialog.tsx +0 -334
  100. package/src/components/ui/dropdown-menu.tsx +0 -218
  101. package/src/components/ui/gesture-drawer.tsx +0 -11
  102. package/src/components/ui/hover-card.tsx +0 -29
  103. package/src/components/ui/index.ts +0 -190
  104. package/src/components/ui/input.tsx +0 -222
  105. package/src/components/ui/label.tsx +0 -29
  106. package/src/components/ui/lightbox.tsx +0 -606
  107. package/src/components/ui/magnetic-button.tsx +0 -129
  108. package/src/components/ui/media-gallery.tsx +0 -612
  109. package/src/components/ui/pagination.tsx +0 -123
  110. package/src/components/ui/popover.tsx +0 -185
  111. package/src/components/ui/progress.tsx +0 -30
  112. package/src/components/ui/radio-group.tsx +0 -257
  113. package/src/components/ui/scroll-area.tsx +0 -47
  114. package/src/components/ui/select.tsx +0 -374
  115. package/src/components/ui/separator.tsx +0 -145
  116. package/src/components/ui/sheet.tsx +0 -139
  117. package/src/components/ui/skeleton.tsx +0 -20
  118. package/src/components/ui/slider.tsx +0 -354
  119. package/src/components/ui/spotlight-card.tsx +0 -119
  120. package/src/components/ui/switch.tsx +0 -86
  121. package/src/components/ui/table.tsx +0 -329
  122. package/src/components/ui/tabs.tsx +0 -198
  123. package/src/components/ui/textarea.tsx +0 -28
  124. package/src/components/ui/toast.tsx +0 -317
  125. package/src/components/ui/toggle.tsx +0 -119
  126. package/src/components/ui/tooltip.tsx +0 -151
  127. package/src/components/virtual-list/index.tsx +0 -668
  128. package/src/hooks/use-chart.ts +0 -205
  129. package/src/hooks/use-data-table.ts +0 -182
  130. package/src/hooks/use-docs-pro-access.ts +0 -13
  131. package/src/hooks/use-license-check.ts +0 -65
  132. package/src/hooks/use-subscription.ts +0 -19
  133. package/src/hooks/use-toast.ts +0 -15
  134. package/src/index.ts +0 -14
  135. package/src/lib/ai-providers.ts +0 -377
  136. package/src/lib/component-metadata.ts +0 -18
  137. package/src/lib/micro-interactions.ts +0 -255
  138. package/src/lib/paddle.ts +0 -17
  139. package/src/lib/utils.ts +0 -6
  140. package/src/patterns/login-form/index.tsx +0 -276
  141. package/src/patterns/login-form/types.ts +0 -67
  142. package/src/setupTests.ts +0 -41
  143. package/src/styles/advanced-chart.css +0 -239
  144. package/src/styles/calendar.css +0 -35
  145. package/src/styles/design-system.css +0 -363
  146. package/src/styles/index.css +0 -85
  147. package/src/styles/tailwind.css +0 -7
  148. package/src/styles/tokens.css +0 -455
  149. package/src/types/moonui.d.ts +0 -22
  150. package/src/types/next-auth.d.ts +0 -21
  151. package/src/use-intersection-observer.tsx +0 -154
  152. package/src/use-local-storage.tsx +0 -71
  153. package/src/use-paddle.ts +0 -138
  154. package/src/use-performance-optimizer.ts +0 -389
  155. package/src/use-pro-access.ts +0 -141
  156. package/src/use-scroll-animation.ts +0 -219
  157. package/src/use-subscription.ts +0 -37
  158. package/src/use-toast.ts +0 -32
  159. package/src/utils/chart-helpers.ts +0 -357
  160. package/src/utils/cn.ts +0 -6
  161. package/src/utils/data-processing.ts +0 -151
  162. package/src/utils/license-validator.tsx +0 -183
@@ -1,343 +0,0 @@
1
- "use client"
2
-
3
- import React from 'react'
4
- import { motion } from 'framer-motion'
5
- import { Card } from '../../ui/card'
6
- import { cn } from '../../../lib/utils'
7
- import {
8
- TrendingUp,
9
- TrendingDown,
10
- Minus,
11
- ArrowUpRight,
12
- ArrowDownRight,
13
- MoreVertical,
14
- Maximize2,
15
- Download,
16
- Share2
17
- } from 'lucide-react'
18
- import { MetricData } from '../types'
19
- import { Button } from '../../ui/button'
20
- import {
21
- DropdownMenu,
22
- DropdownMenuContent,
23
- DropdownMenuItem,
24
- DropdownMenuTrigger,
25
- } from '../../ui/dropdown-menu'
26
- import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/tooltip'
27
-
28
- interface MetricCardProps {
29
- data: MetricData
30
- onClick?: () => void
31
- onAction?: (action: string) => void
32
- className?: string
33
- showSparkline?: boolean
34
- showForecast?: boolean
35
- interactive?: boolean
36
- glassmorphism?: boolean
37
- }
38
-
39
- export function MetricCard({
40
- data,
41
- onClick,
42
- onAction,
43
- className,
44
- showSparkline = true,
45
- showForecast = false,
46
- interactive = true,
47
- glassmorphism = false
48
- }: MetricCardProps) {
49
- const [isHovered, setIsHovered] = React.useState(false)
50
-
51
- // Renk sınıfları
52
- const colorClasses = {
53
- primary: 'text-blue-600 dark:text-blue-400',
54
- success: 'text-green-600 dark:text-green-400',
55
- warning: 'text-yellow-600 dark:text-yellow-400',
56
- danger: 'text-red-600 dark:text-red-400',
57
- info: 'text-purple-600 dark:text-purple-400'
58
- }
59
-
60
- // Değişim renkleri
61
- const getChangeColor = (type: 'increase' | 'decrease' | 'neutral') => {
62
- switch (type) {
63
- case 'increase':
64
- return 'text-green-600 dark:text-green-400'
65
- case 'decrease':
66
- return 'text-red-600 dark:text-red-400'
67
- default:
68
- return 'text-muted-foreground'
69
- }
70
- }
71
-
72
- // Değişim ikonu
73
- const getChangeIcon = (type: 'increase' | 'decrease' | 'neutral') => {
74
- switch (type) {
75
- case 'increase':
76
- return <ArrowUpRight className="h-4 w-4" />
77
- case 'decrease':
78
- return <ArrowDownRight className="h-4 w-4" />
79
- default:
80
- return <Minus className="h-4 w-4" />
81
- }
82
- }
83
-
84
- // Sparkline çizimi
85
- const renderSparkline = () => {
86
- if (!data.sparkline || data.sparkline.length < 2) return null
87
-
88
- const max = Math.max(...data.sparkline)
89
- const min = Math.min(...data.sparkline)
90
- const range = max - min || 1
91
-
92
- const points = data.sparkline
93
- .map((value, index) => {
94
- const x = (index / (data.sparkline!.length - 1)) * 100
95
- const y = 100 - ((value - min) / range) * 100
96
- return `${x},${y}`
97
- })
98
- .join(' ')
99
-
100
- const gradientId = `gradient-${data.id}`
101
-
102
- return (
103
- <motion.div
104
- className="absolute bottom-0 left-0 right-0 h-16 overflow-hidden rounded-b-lg opacity-20"
105
- initial={{ opacity: 0 }}
106
- animate={{ opacity: isHovered ? 0.3 : 0.2 }}
107
- transition={{ duration: 0.2 }}
108
- >
109
- <svg
110
- className="w-full h-full"
111
- viewBox="0 0 100 100"
112
- preserveAspectRatio="none"
113
- >
114
- <defs>
115
- <linearGradient id={gradientId} x1="0%" y1="0%" x2="0%" y2="100%">
116
- <stop offset="0%" stopColor="currentColor" stopOpacity="0.3" />
117
- <stop offset="100%" stopColor="currentColor" stopOpacity="0" />
118
- </linearGradient>
119
- </defs>
120
- <polyline
121
- fill="none"
122
- stroke="currentColor"
123
- strokeWidth="2"
124
- points={points}
125
- className={colorClasses[data.color || 'primary']}
126
- />
127
- <polygon
128
- fill={`url(#${gradientId})`}
129
- points={`0,100 ${points} 100,100`}
130
- className={colorClasses[data.color || 'primary']}
131
- />
132
- </svg>
133
- </motion.div>
134
- )
135
- }
136
-
137
- // İlerleme barı (hedef varsa)
138
- const renderProgress = () => {
139
- if (!data.target) return null
140
-
141
- const currentValue = typeof data.value === 'number' ? data.value : parseFloat(data.value as string)
142
- const progress = (currentValue / data.target) * 100
143
-
144
- return (
145
- <motion.div
146
- className="mt-3"
147
- initial={{ opacity: 0, y: 10 }}
148
- animate={{ opacity: 1, y: 0 }}
149
- transition={{ delay: 0.1 }}
150
- >
151
- <div className="flex justify-between text-xs text-muted-foreground mb-1">
152
- <span>Progress to target</span>
153
- <span>{progress.toFixed(1)}%</span>
154
- </div>
155
- <div className="h-1.5 bg-muted rounded-full overflow-hidden">
156
- <motion.div
157
- className={cn(
158
- "h-full rounded-full",
159
- progress >= 100 ? 'bg-green-500' : 'bg-primary'
160
- )}
161
- initial={{ width: 0 }}
162
- animate={{ width: `${Math.min(progress, 100)}%` }}
163
- transition={{ duration: 0.5, ease: "easeOut" }}
164
- />
165
- </div>
166
- <div className="flex justify-between text-xs text-muted-foreground mt-1">
167
- <span>{currentValue} {data.unit}</span>
168
- <span>Target: {data.target} {data.unit}</span>
169
- </div>
170
- </motion.div>
171
- )
172
- }
173
-
174
- // Değer formatı
175
- const formatValue = (value: string | number): string => {
176
- if (typeof value === 'number') {
177
- if (value >= 1000000) {
178
- return (value / 1000000).toFixed(1) + 'M'
179
- } else if (value >= 1000) {
180
- return (value / 1000).toFixed(1) + 'K'
181
- }
182
- return value.toLocaleString()
183
- }
184
- return value.toString()
185
- }
186
-
187
- // Card variants
188
- const cardVariants = {
189
- initial: { opacity: 0, y: 20 },
190
- animate: {
191
- opacity: 1,
192
- y: 0,
193
- transition: { duration: 0.3, ease: "easeOut" }
194
- },
195
- hover: interactive ? {
196
- y: -2,
197
- transition: { duration: 0.2 }
198
- } : {}
199
- }
200
-
201
- return (
202
- <motion.div
203
- variants={cardVariants}
204
- initial="initial"
205
- animate="animate"
206
- whileHover="hover"
207
- onHoverStart={() => setIsHovered(true)}
208
- onHoverEnd={() => setIsHovered(false)}
209
- >
210
- <Card
211
- className={cn(
212
- "relative overflow-hidden cursor-pointer transition-all duration-300",
213
- interactive && "hover:shadow-lg hover:shadow-primary/5",
214
- glassmorphism && "bg-background/60 backdrop-blur-md border-white/10",
215
- className
216
- )}
217
- onClick={onClick}
218
- >
219
- {/* Açık arka plan efekti */}
220
- {glassmorphism && (
221
- <div className="absolute inset-0 bg-gradient-to-br from-primary/5 to-transparent" />
222
- )}
223
-
224
- {/* Üst bar */}
225
- <div className="flex items-center justify-between p-4 pb-2">
226
- <div className="flex items-center gap-3">
227
- <motion.div
228
- className={cn(
229
- "p-2 rounded-lg",
230
- glassmorphism ? "bg-white/10 backdrop-blur" : "bg-muted"
231
- )}
232
- whileHover={{ scale: 1.05 }}
233
- whileTap={{ scale: 0.95 }}
234
- >
235
- <div className={cn("h-5 w-5", colorClasses[data.color || 'primary'])}>
236
- {data.icon}
237
- </div>
238
- </motion.div>
239
- <div>
240
- <h3 className="text-sm font-medium text-muted-foreground">{data.title}</h3>
241
- </div>
242
- </div>
243
-
244
- {/* Aksiyonlar */}
245
- {interactive && (
246
- <DropdownMenu>
247
- <DropdownMenuTrigger asChild>
248
- <Button
249
- variant="ghost"
250
- size="sm"
251
- className="h-8 w-8 p-0"
252
- onClick={(e) => e.stopPropagation()}
253
- >
254
- <MoreVertical className="h-4 w-4" />
255
- </Button>
256
- </DropdownMenuTrigger>
257
- <DropdownMenuContent align="end">
258
- <DropdownMenuItem onClick={() => onAction?.('fullscreen')}>
259
- <Maximize2 className="mr-2 h-4 w-4" />
260
- Fullscreen
261
- </DropdownMenuItem>
262
- <DropdownMenuItem onClick={() => onAction?.('export')}>
263
- <Download className="mr-2 h-4 w-4" />
264
- Export Data
265
- </DropdownMenuItem>
266
- <DropdownMenuItem onClick={() => onAction?.('share')}>
267
- <Share2 className="mr-2 h-4 w-4" />
268
- Share
269
- </DropdownMenuItem>
270
- </DropdownMenuContent>
271
- </DropdownMenu>
272
- )}
273
- </div>
274
-
275
- {/* Ana değer */}
276
- <div className="px-4 pb-4">
277
- <TooltipProvider>
278
- <Tooltip>
279
- <TooltipTrigger asChild>
280
- <motion.div
281
- className="text-3xl font-bold tracking-tight"
282
- animate={{
283
- scale: isHovered ? 1.02 : 1,
284
- }}
285
- transition={{ duration: 0.2 }}
286
- >
287
- {formatValue(data.value)}
288
- {data.unit && <span className="text-lg ml-1 text-muted-foreground">{data.unit}</span>}
289
- </motion.div>
290
- </TooltipTrigger>
291
- <TooltipContent>
292
- <p>Exact value: {data.value} {data.unit}</p>
293
- </TooltipContent>
294
- </Tooltip>
295
- </TooltipProvider>
296
-
297
- {/* Değişim göstergesi */}
298
- {data.change && (
299
- <motion.div
300
- className={cn(
301
- "flex items-center gap-1 text-sm mt-2",
302
- getChangeColor(data.change.type)
303
- )}
304
- initial={{ opacity: 0, x: -10 }}
305
- animate={{ opacity: 1, x: 0 }}
306
- transition={{ delay: 0.1 }}
307
- >
308
- {getChangeIcon(data.change.type)}
309
- <span className="font-medium">
310
- {data.change.type === 'neutral' ? '' : data.change.type === 'increase' ? '+' : '-'}
311
- {Math.abs(data.change.value)}%
312
- </span>
313
- <span className="text-muted-foreground">
314
- from {data.change.period}
315
- </span>
316
- </motion.div>
317
- )}
318
-
319
- {/* Tahmin */}
320
- {showForecast && data.forecast && (
321
- <motion.div
322
- className="flex items-center gap-1 text-xs text-muted-foreground mt-1"
323
- initial={{ opacity: 0 }}
324
- animate={{ opacity: 1 }}
325
- transition={{ delay: 0.2 }}
326
- >
327
- <TrendingUp className="h-3 w-3" />
328
- <span>Forecast: {formatValue(data.forecast)} {data.unit}</span>
329
- </motion.div>
330
- )}
331
-
332
- {/* İlerleme barı */}
333
- {renderProgress()}
334
- </div>
335
-
336
- {/* Sparkline */}
337
- {showSparkline && renderSparkline()}
338
- </Card>
339
- </motion.div>
340
- )
341
- }
342
-
343
- export default MetricCard
@@ -1,204 +0,0 @@
1
- "use client"
2
-
3
- import React from 'react'
4
- import { Loader2, MoreHorizontal, AlertTriangle } from 'lucide-react'
5
- import {
6
- DropdownMenu,
7
- DropdownMenuContent,
8
- DropdownMenuItem,
9
- DropdownMenuSeparator,
10
- DropdownMenuTrigger,
11
- } from '../ui/dropdown-menu'
12
- import {
13
- AlertDialog,
14
- AlertDialogAction,
15
- AlertDialogCancel,
16
- AlertDialogContent,
17
- AlertDialogDescription,
18
- AlertDialogFooter,
19
- AlertDialogHeader,
20
- AlertDialogTitle,
21
- } from '../ui/alert-dialog'
22
- import { Button } from '../ui/button'
23
- import { Badge } from '../ui/badge'
24
- import { cn } from '../../lib/utils'
25
-
26
- export interface BulkAction<T = any> {
27
- label: string
28
- icon?: React.ReactNode
29
- action: (selectedRows: T[]) => void | Promise<void>
30
- confirmMessage?: string
31
- confirmTitle?: string
32
- variant?: 'default' | 'destructive'
33
- disabled?: boolean | ((selectedRows: T[]) => boolean)
34
- }
35
-
36
- interface DataTableBulkActionsProps<T = any> {
37
- selectedRows: T[]
38
- actions: BulkAction<T>[]
39
- onClearSelection?: () => void
40
- className?: string
41
- }
42
-
43
- export function DataTableBulkActions<T>({
44
- selectedRows,
45
- actions,
46
- onClearSelection,
47
- className
48
- }: DataTableBulkActionsProps<T>) {
49
- const [isLoading, setIsLoading] = React.useState(false)
50
- const [pendingAction, setPendingAction] = React.useState<BulkAction<T> | null>(null)
51
-
52
- const selectedCount = selectedRows.length
53
-
54
- const handleAction = async (action: BulkAction<T>) => {
55
- if (action.confirmMessage) {
56
- setPendingAction(action)
57
- return
58
- }
59
-
60
- await executeAction(action)
61
- }
62
-
63
- const executeAction = async (action: BulkAction<T>) => {
64
- setIsLoading(true)
65
- try {
66
- await action.action(selectedRows)
67
-
68
- // Clear selection after successful action
69
- if (onClearSelection) {
70
- onClearSelection()
71
- }
72
- } catch (error) {
73
- console.error('Bulk action failed:', error)
74
- // You might want to show an error toast here
75
- } finally {
76
- setIsLoading(false)
77
- setPendingAction(null)
78
- }
79
- }
80
-
81
- const handleConfirm = async () => {
82
- if (pendingAction) {
83
- await executeAction(pendingAction)
84
- }
85
- }
86
-
87
- if (selectedCount === 0) {
88
- return null
89
- }
90
-
91
- return (
92
- <>
93
- <div className={cn("flex items-center gap-2", className)}>
94
- {/* Selected count badge */}
95
- <Badge variant="secondary" className="gap-1">
96
- <span className="font-semibold">{selectedCount}</span>
97
- <span>selected</span>
98
- </Badge>
99
-
100
- {/* Bulk actions dropdown */}
101
- <DropdownMenu>
102
- <DropdownMenuTrigger asChild>
103
- <Button
104
- variant="outline"
105
- size="sm"
106
- disabled={isLoading}
107
- className="gap-2"
108
- >
109
- {isLoading ? (
110
- <>
111
- <Loader2 className="h-4 w-4 animate-spin" />
112
- Processing...
113
- </>
114
- ) : (
115
- <>
116
- <MoreHorizontal className="h-4 w-4" />
117
- Bulk Actions
118
- </>
119
- )}
120
- </Button>
121
- </DropdownMenuTrigger>
122
- <DropdownMenuContent align="end" className="w-48">
123
- {actions.map((action, index) => {
124
- const isDisabled = typeof action.disabled === 'function'
125
- ? action.disabled(selectedRows)
126
- : action.disabled
127
-
128
- return (
129
- <DropdownMenuItem
130
- key={index}
131
- disabled={isDisabled || isLoading}
132
- onSelect={() => handleAction(action)}
133
- className={cn(
134
- "cursor-pointer",
135
- action.variant === 'destructive' && "text-destructive focus:text-destructive"
136
- )}
137
- >
138
- {action.icon && (
139
- <span className="mr-2 h-4 w-4">{action.icon}</span>
140
- )}
141
- {action.label}
142
- </DropdownMenuItem>
143
- )
144
- })}
145
-
146
- {onClearSelection && (
147
- <>
148
- <DropdownMenuSeparator />
149
- <DropdownMenuItem
150
- onSelect={onClearSelection}
151
- className="cursor-pointer text-muted-foreground"
152
- >
153
- Clear selection
154
- </DropdownMenuItem>
155
- </>
156
- )}
157
- </DropdownMenuContent>
158
- </DropdownMenu>
159
- </div>
160
-
161
- {/* Confirmation dialog */}
162
- <AlertDialog
163
- open={!!pendingAction}
164
- onOpenChange={(open) => !open && setPendingAction(null)}
165
- >
166
- <AlertDialogContent>
167
- <AlertDialogHeader>
168
- <AlertDialogTitle className="flex items-center gap-2">
169
- {pendingAction?.variant === 'destructive' && (
170
- <AlertTriangle className="h-5 w-5 text-destructive" />
171
- )}
172
- {pendingAction?.confirmTitle || 'Confirm Action'}
173
- </AlertDialogTitle>
174
- <AlertDialogDescription>
175
- {pendingAction?.confirmMessage ||
176
- `This action will affect ${selectedCount} selected item${selectedCount > 1 ? 's' : ''}. This action cannot be undone.`}
177
- </AlertDialogDescription>
178
- </AlertDialogHeader>
179
- <AlertDialogFooter>
180
- <AlertDialogCancel disabled={isLoading}>
181
- Cancel
182
- </AlertDialogCancel>
183
- <AlertDialogAction
184
- onClick={handleConfirm}
185
- disabled={isLoading}
186
- className={cn(
187
- pendingAction?.variant === 'destructive' && "bg-destructive text-destructive-foreground hover:bg-destructive/90"
188
- )}
189
- >
190
- {isLoading ? (
191
- <>
192
- <Loader2 className="mr-2 h-4 w-4 animate-spin" />
193
- Processing...
194
- </>
195
- ) : (
196
- 'Confirm'
197
- )}
198
- </AlertDialogAction>
199
- </AlertDialogFooter>
200
- </AlertDialogContent>
201
- </AlertDialog>
202
- </>
203
- )
204
- }