@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,612 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import { cva, type VariantProps } from "class-variance-authority"
5
- import { motion, AnimatePresence } from "framer-motion"
6
- import { Grid3x3, LayoutGrid, Square, Columns, Filter, SortAsc, Image as ImageIcon, Video, X, Loader2 } from "lucide-react"
7
-
8
- import { cn } from "../../lib/utils"
9
- import {
10
- MoonUILightboxProviderPro,
11
- MoonUILightboxTriggerPro,
12
- MoonUILightboxContentPro,
13
- type MediaItem
14
- } from "./lightbox"
15
-
16
- /**
17
- * Premium Media Gallery Component
18
- *
19
- * Advanced gallery component for displaying images and videos in responsive layouts
20
- * with filtering, sorting, lightbox integration, and smooth animations.
21
- * Perfect for portfolios, product galleries, and media showcases.
22
- */
23
-
24
- const galleryVariants = cva(
25
- "w-full",
26
- {
27
- variants: {
28
- layout: {
29
- grid: "grid gap-4",
30
- masonry: "",
31
- horizontal: "flex overflow-x-auto gap-4 pb-4 snap-x snap-mandatory [&>*]:snap-center",
32
- justified: "flex flex-wrap gap-2",
33
- },
34
- columns: {
35
- 1: "grid-cols-1",
36
- 2: "grid-cols-1 sm:grid-cols-2",
37
- 3: "grid-cols-1 sm:grid-cols-2 md:grid-cols-3",
38
- 4: "grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4",
39
- 5: "grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5",
40
- 6: "grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6",
41
- },
42
- },
43
- defaultVariants: {
44
- layout: "grid",
45
- columns: 3,
46
- },
47
- }
48
- )
49
-
50
- const galleryItemVariants = cva(
51
- "relative overflow-hidden cursor-pointer group",
52
- {
53
- variants: {
54
- variant: {
55
- default: "rounded-lg",
56
- card: "rounded-lg shadow-sm border border-border bg-card",
57
- ghost: "rounded-lg hover:bg-accent/50",
58
- outline: "rounded-lg border-2 border-transparent hover:border-primary",
59
- glass: "rounded-lg backdrop-blur-md bg-white/10 border border-white/20",
60
- },
61
- aspectRatio: {
62
- square: "aspect-square",
63
- video: "aspect-video",
64
- portrait: "aspect-[3/4]",
65
- auto: "",
66
- },
67
- hover: {
68
- none: "",
69
- zoom: "transition-transform duration-300 hover:scale-105",
70
- lift: "transition-all duration-300 hover:-translate-y-1 hover:shadow-lg",
71
- glow: "transition-all duration-300 hover:shadow-lg hover:shadow-primary/20",
72
- },
73
- },
74
- defaultVariants: {
75
- variant: "default",
76
- aspectRatio: "square",
77
- hover: "zoom",
78
- },
79
- }
80
- )
81
-
82
- interface GalleryCategory {
83
- id: string
84
- label: string
85
- icon?: React.ReactNode
86
- }
87
-
88
- interface GallerySortOption {
89
- id: string
90
- label: string
91
- compareFn: (a: MediaItem, b: MediaItem) => number
92
- }
93
-
94
- interface MoonUIMediaGalleryProProps
95
- extends React.HTMLAttributes<HTMLDivElement>,
96
- VariantProps<typeof galleryVariants> {
97
- items: MediaItem[]
98
- variant?: VariantProps<typeof galleryItemVariants>["variant"]
99
- aspectRatio?: VariantProps<typeof galleryItemVariants>["aspectRatio"]
100
- hover?: VariantProps<typeof galleryItemVariants>["hover"]
101
- enableLightbox?: boolean
102
- enableFiltering?: boolean
103
- enableSorting?: boolean
104
- categories?: GalleryCategory[]
105
- sortOptions?: GallerySortOption[]
106
- defaultCategory?: string
107
- defaultSort?: string
108
- showItemType?: boolean
109
- showOverlay?: boolean
110
- overlayContent?: (item: MediaItem, index: number) => React.ReactNode
111
- loadingState?: boolean
112
- skeletonCount?: number
113
- emptyState?: React.ReactNode
114
- onItemClick?: (item: MediaItem, index: number) => void
115
- lazyLoad?: boolean
116
- infiniteScroll?: boolean
117
- onLoadMore?: () => void
118
- hasMore?: boolean
119
- lightboxProps?: Partial<React.ComponentProps<typeof MoonUILightboxContentPro>>
120
- }
121
-
122
- const MoonUIMediaGalleryPro = React.forwardRef<
123
- HTMLDivElement,
124
- MoonUIMediaGalleryProProps
125
- >(({
126
- className,
127
- items,
128
- layout,
129
- columns,
130
- variant,
131
- aspectRatio,
132
- hover,
133
- enableLightbox = true,
134
- enableFiltering = false,
135
- enableSorting = false,
136
- categories = [],
137
- sortOptions = [],
138
- defaultCategory = "all",
139
- defaultSort = "default",
140
- showItemType = true,
141
- showOverlay = true,
142
- overlayContent,
143
- loadingState = false,
144
- skeletonCount = 6,
145
- emptyState,
146
- onItemClick,
147
- lazyLoad = true,
148
- infiniteScroll = false,
149
- onLoadMore,
150
- hasMore = false,
151
- lightboxProps,
152
- ...props
153
- }, ref) => {
154
- const [activeCategory, setActiveCategory] = React.useState(defaultCategory)
155
- const [activeSort, setActiveSort] = React.useState(defaultSort)
156
- const [showFilters, setShowFilters] = React.useState(false)
157
- const [loadedImages, setLoadedImages] = React.useState<Set<number>>(new Set())
158
- const observerRef = React.useRef<IntersectionObserver | null>(null)
159
- const loadMoreRef = React.useRef<HTMLDivElement>(null)
160
-
161
- // Filter items by category
162
- const filteredItems = React.useMemo(() => {
163
- if (!enableFiltering || activeCategory === "all") return items
164
-
165
- return items.filter(item => {
166
- // Check if item has category property
167
- if ('category' in item && typeof item.category === 'string') {
168
- return item.category === activeCategory
169
- }
170
- // Fallback to type-based filtering
171
- if (activeCategory === "image") return item.type === "image"
172
- if (activeCategory === "video") return item.type === "video"
173
- return true
174
- })
175
- }, [items, activeCategory, enableFiltering])
176
-
177
- // Sort items
178
- const sortedItems = React.useMemo(() => {
179
- if (!enableSorting || activeSort === "default") return filteredItems
180
-
181
- const sortOption = sortOptions.find(opt => opt.id === activeSort)
182
- if (!sortOption) return filteredItems
183
-
184
- return [...filteredItems].sort(sortOption.compareFn)
185
- }, [filteredItems, activeSort, enableSorting, sortOptions])
186
-
187
- // Default categories if none provided
188
- const defaultCategories: GalleryCategory[] = [
189
- { id: "all", label: "All" },
190
- { id: "image", label: "Images", icon: <ImageIcon className="h-4 w-4" /> },
191
- { id: "video", label: "Videos", icon: <Video className="h-4 w-4" /> },
192
- ]
193
-
194
- const finalCategories = categories.length > 0 ? categories : defaultCategories
195
-
196
- // Lazy loading
197
- React.useEffect(() => {
198
- if (!lazyLoad) return
199
-
200
- observerRef.current = new IntersectionObserver(
201
- (entries) => {
202
- entries.forEach((entry) => {
203
- if (entry.isIntersecting) {
204
- const index = parseInt(entry.target.getAttribute("data-index") || "0")
205
- setLoadedImages(prev => new Set(prev).add(index))
206
- }
207
- })
208
- },
209
- { rootMargin: "50px" }
210
- )
211
-
212
- return () => {
213
- observerRef.current?.disconnect()
214
- }
215
- }, [lazyLoad])
216
-
217
- // Infinite scroll
218
- React.useEffect(() => {
219
- if (!infiniteScroll || !onLoadMore || !hasMore) return
220
-
221
- const observer = new IntersectionObserver(
222
- (entries) => {
223
- if (entries[0].isIntersecting) {
224
- onLoadMore()
225
- }
226
- },
227
- { rootMargin: "100px" }
228
- )
229
-
230
- if (loadMoreRef.current) {
231
- observer.observe(loadMoreRef.current)
232
- }
233
-
234
- return () => observer.disconnect()
235
- }, [infiniteScroll, onLoadMore, hasMore])
236
-
237
- const handleItemClick = (item: MediaItem, index: number) => {
238
- if (onItemClick) {
239
- onItemClick(item, index)
240
- }
241
- }
242
-
243
- const renderGalleryItem = (item: MediaItem, index: number) => {
244
- const isLoaded = !lazyLoad || loadedImages.has(index)
245
-
246
- const itemContent = (
247
- <motion.div
248
- key={index}
249
- className={cn(
250
- galleryItemVariants({
251
- variant,
252
- aspectRatio: layout === "masonry" || layout === "justified" ? "auto" : aspectRatio,
253
- hover
254
- }),
255
- layout === "masonry" && "break-inside-avoid mb-4 inline-block w-full",
256
- layout === "justified" && "flex-grow"
257
- )}
258
- style={layout === "justified" ? { flexBasis: "200px", maxWidth: "400px" } : undefined}
259
- initial={{ opacity: 0, scale: 0.9 }}
260
- animate={{ opacity: 1, scale: 1 }}
261
- transition={{ duration: 0.3, delay: index * 0.05 }}
262
- data-index={index}
263
- ref={(el) => {
264
- if (el && observerRef.current && !loadedImages.has(index)) {
265
- observerRef.current.observe(el)
266
- }
267
- }}
268
- onClick={() => handleItemClick(item, index)}
269
- >
270
- {item.type === "image" ? (
271
- <div className={cn(
272
- "relative w-full",
273
- layout === "masonry" || layout === "justified" ? "" : "h-full"
274
- )}>
275
- <img
276
- src={item.thumbnail || item.src}
277
- alt={item.alt || `Gallery item ${index + 1}`}
278
- className={cn(
279
- "w-full object-cover",
280
- layout === "masonry" ? "h-auto" : "h-full",
281
- isLoaded ? "opacity-100" : "opacity-0",
282
- "transition-opacity duration-300"
283
- )}
284
- loading={lazyLoad ? "lazy" : undefined}
285
- onLoad={() => setLoadedImages(prev => new Set(prev).add(index))}
286
- />
287
- {!isLoaded && (
288
- <div className={cn(
289
- "absolute inset-0 w-full bg-muted animate-pulse",
290
- layout === "masonry" ? "h-64" : "h-full",
291
- layout === "masonry" && "aspect-[3/4]"
292
- )} />
293
- )}
294
- </div>
295
- ) : (
296
- <div className={cn(
297
- "relative w-full bg-black",
298
- layout === "masonry" ? "" : "h-full"
299
- )}>
300
- {isLoaded && (item.thumbnail || item.poster) && (
301
- <img
302
- src={item.thumbnail || item.poster}
303
- alt={item.alt || `Video thumbnail ${index + 1}`}
304
- className={cn(
305
- "w-full object-cover",
306
- layout === "masonry" ? "h-auto" : "h-full"
307
- )}
308
- loading={lazyLoad ? "lazy" : undefined}
309
- />
310
- )}
311
- <div className="absolute inset-0 flex items-center justify-center">
312
- <div className="w-12 h-12 bg-black/70 rounded-full flex items-center justify-center">
313
- <Video className="h-6 w-6 text-white" />
314
- </div>
315
- </div>
316
- </div>
317
- )}
318
-
319
- {/* Overlay */}
320
- {showOverlay && (
321
- <div className="absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300">
322
- {overlayContent ? (
323
- overlayContent(item, index)
324
- ) : (
325
- <div className="absolute bottom-0 left-0 right-0 p-4 text-white">
326
- {item.title && (
327
- <h3 className="text-sm font-semibold mb-1">{item.title}</h3>
328
- )}
329
- {item.description && (
330
- <p className="text-xs opacity-90 line-clamp-2">{item.description}</p>
331
- )}
332
- </div>
333
- )}
334
-
335
- {showItemType && (
336
- <div className="absolute top-2 right-2">
337
- <div className="w-8 h-8 bg-white/20 backdrop-blur-sm rounded-full flex items-center justify-center">
338
- {item.type === "image" ? (
339
- <ImageIcon className="h-4 w-4 text-white" />
340
- ) : (
341
- <Video className="h-4 w-4 text-white" />
342
- )}
343
- </div>
344
- </div>
345
- )}
346
- </div>
347
- )}
348
- </motion.div>
349
- )
350
-
351
- // If lightbox is enabled and we're in the main gallery content, wrap with trigger
352
- if (enableLightbox) {
353
- return (
354
- <MoonUILightboxTriggerPro key={index} index={index}>
355
- {itemContent}
356
- </MoonUILightboxTriggerPro>
357
- )
358
- }
359
-
360
- return itemContent
361
- }
362
-
363
- const renderSkeleton = () => (
364
- <div className={cn(galleryItemVariants({ variant, aspectRatio }))}>
365
- <div className="w-full h-full bg-muted animate-pulse" />
366
- </div>
367
- )
368
-
369
- const galleryContent = (
370
- <>
371
- {/* Filters and Sorting */}
372
- {(enableFiltering || enableSorting) && (
373
- <div className="mb-6">
374
- <div className="flex items-center justify-between mb-4">
375
- <div className="flex items-center gap-4">
376
- {enableFiltering && (
377
- <button
378
- onClick={() => setShowFilters(!showFilters)}
379
- className={cn(
380
- "flex items-center gap-2 px-4 py-2 rounded-lg border transition-colors",
381
- showFilters
382
- ? "bg-primary text-primary-foreground border-primary"
383
- : "bg-background border-border hover:bg-accent"
384
- )}
385
- >
386
- <Filter className="h-4 w-4" />
387
- Filters
388
- </button>
389
- )}
390
- {enableSorting && sortOptions.length > 0 && (
391
- <select
392
- value={activeSort}
393
- onChange={(e) => setActiveSort(e.target.value)}
394
- className="px-4 py-2 rounded-lg border bg-background"
395
- >
396
- <option value="default">Default order</option>
397
- {sortOptions.map(option => (
398
- <option key={option.id} value={option.id}>
399
- {option.label}
400
- </option>
401
- ))}
402
- </select>
403
- )}
404
- </div>
405
- <div className="text-sm text-muted-foreground">
406
- {sortedItems.length} items
407
- </div>
408
- </div>
409
-
410
- {/* Category filters */}
411
- <AnimatePresence>
412
- {showFilters && enableFiltering && (
413
- <motion.div
414
- initial={{ height: 0, opacity: 0 }}
415
- animate={{ height: "auto", opacity: 1 }}
416
- exit={{ height: 0, opacity: 0 }}
417
- transition={{ duration: 0.2 }}
418
- className="overflow-hidden"
419
- >
420
- <div className="flex flex-wrap gap-2 pb-4">
421
- {finalCategories.map(category => (
422
- <button
423
- key={category.id}
424
- onClick={() => setActiveCategory(category.id)}
425
- className={cn(
426
- "flex items-center gap-2 px-3 py-1.5 rounded-full text-sm transition-colors",
427
- activeCategory === category.id
428
- ? "bg-primary text-primary-foreground"
429
- : "bg-muted hover:bg-accent"
430
- )}
431
- >
432
- {category.icon}
433
- {category.label}
434
- </button>
435
- ))}
436
- </div>
437
- </motion.div>
438
- )}
439
- </AnimatePresence>
440
- </div>
441
- )}
442
-
443
- {/* Gallery */}
444
- <div
445
- ref={ref}
446
- className={cn(
447
- layout === "masonry"
448
- ? "columns-1 sm:columns-2 md:columns-3 lg:columns-4 gap-4"
449
- : galleryVariants({ layout, columns }),
450
- className
451
- )}
452
- style={layout === "masonry" ? { columnGap: "1rem" } : undefined}
453
- {...props}
454
- >
455
- {loadingState ? (
456
- <>
457
- {Array.from({ length: skeletonCount }).map((_, i) => (
458
- <React.Fragment key={i}>{renderSkeleton()}</React.Fragment>
459
- ))}
460
- </>
461
- ) : sortedItems.length > 0 ? (
462
- sortedItems.map((item, index) => renderGalleryItem(item, index))
463
- ) : (
464
- emptyState || (
465
- <div className="col-span-full flex flex-col items-center justify-center py-12 text-center">
466
- <ImageIcon className="h-12 w-12 text-muted-foreground mb-4" />
467
- <p className="text-muted-foreground">No media items found</p>
468
- </div>
469
- )
470
- )}
471
- </div>
472
-
473
- {/* Load more trigger */}
474
- {infiniteScroll && hasMore && (
475
- <div ref={loadMoreRef} className="flex justify-center py-8">
476
- <Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
477
- </div>
478
- )}
479
- </>
480
- )
481
-
482
- if (enableLightbox) {
483
- return (
484
- <MoonUILightboxProviderPro items={sortedItems}>
485
- {galleryContent}
486
- <MoonUILightboxContentPro showThumbnails showNavigation backdrop="blur" {...lightboxProps} />
487
- </MoonUILightboxProviderPro>
488
- )
489
- }
490
-
491
- return galleryContent
492
- })
493
- MoonUIMediaGalleryPro.displayName = "MoonUIMediaGalleryPro"
494
-
495
- // Gallery item component for custom layouts
496
- interface MoonUIGalleryItemProProps
497
- extends React.HTMLAttributes<HTMLDivElement>,
498
- VariantProps<typeof galleryItemVariants> {
499
- item: MediaItem
500
- index?: number
501
- showType?: boolean
502
- showOverlay?: boolean
503
- overlayContent?: React.ReactNode
504
- onLoad?: () => void
505
- }
506
-
507
- const MoonUIGalleryItemPro = React.forwardRef<
508
- HTMLDivElement,
509
- MoonUIGalleryItemProProps
510
- >(({
511
- className,
512
- item,
513
- index = 0,
514
- variant,
515
- aspectRatio,
516
- hover,
517
- showType = true,
518
- showOverlay = true,
519
- overlayContent,
520
- onLoad,
521
- ...props
522
- }, ref) => {
523
- const [isLoaded, setIsLoaded] = React.useState(false)
524
-
525
- const handleLoad = () => {
526
- setIsLoaded(true)
527
- onLoad?.()
528
- }
529
-
530
- return (
531
- <div
532
- ref={ref}
533
- className={cn(galleryItemVariants({ variant, aspectRatio, hover }), className)}
534
- {...props}
535
- >
536
- {item.type === "image" ? (
537
- <img
538
- src={item.src}
539
- alt={item.alt || `Gallery item ${index + 1}`}
540
- className={cn(
541
- "w-full h-full object-cover transition-opacity duration-300",
542
- isLoaded ? "opacity-100" : "opacity-0"
543
- )}
544
- onLoad={handleLoad}
545
- />
546
- ) : (
547
- <div className="relative w-full h-full bg-black">
548
- {item.poster && (
549
- <img
550
- src={item.poster}
551
- alt={item.alt || `Video thumbnail ${index + 1}`}
552
- className="w-full h-full object-cover"
553
- onLoad={handleLoad}
554
- />
555
- )}
556
- <div className="absolute inset-0 flex items-center justify-center">
557
- <div className="w-12 h-12 bg-black/70 rounded-full flex items-center justify-center">
558
- <Video className="h-6 w-6 text-white" />
559
- </div>
560
- </div>
561
- </div>
562
- )}
563
-
564
- {!isLoaded && (
565
- <div className="absolute inset-0 bg-muted animate-pulse" />
566
- )}
567
-
568
- {showOverlay && isLoaded && (
569
- <div className="absolute inset-0 bg-gradient-to-t from-black/70 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300">
570
- {overlayContent || (
571
- <div className="absolute bottom-0 left-0 right-0 p-4 text-white">
572
- {item.title && (
573
- <h3 className="text-sm font-semibold mb-1">{item.title}</h3>
574
- )}
575
- {item.description && (
576
- <p className="text-xs opacity-90 line-clamp-2">{item.description}</p>
577
- )}
578
- </div>
579
- )}
580
-
581
- {showType && (
582
- <div className="absolute top-2 right-2">
583
- <div className="w-8 h-8 bg-white/20 backdrop-blur-sm rounded-full flex items-center justify-center">
584
- {item.type === "image" ? (
585
- <ImageIcon className="h-4 w-4 text-white" />
586
- ) : (
587
- <Video className="h-4 w-4 text-white" />
588
- )}
589
- </div>
590
- </div>
591
- )}
592
- </div>
593
- )}
594
- </div>
595
- )
596
- })
597
- MoonUIGalleryItemPro.displayName = "MoonUIGalleryItemPro"
598
-
599
- export {
600
- MoonUIMediaGalleryPro,
601
- MoonUIGalleryItemPro,
602
- galleryVariants,
603
- galleryItemVariants,
604
- type GalleryCategory,
605
- type GallerySortOption,
606
- }
607
-
608
- // Clean exports
609
- export {
610
- MoonUIMediaGalleryPro as MediaGallery,
611
- MoonUIGalleryItemPro as GalleryItem,
612
- }