@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,865 +0,0 @@
1
- "use client"
2
-
3
- import React, { useState, useEffect, useCallback, useRef, useMemo, createContext, useContext } from 'react'
4
- import { motion, AnimatePresence, useMotionValue, useSpring } from 'framer-motion'
5
- import { cn } from '../../lib/utils'
6
- import { Button } from '../ui/button'
7
- import { ScrollArea } from '../ui/scroll-area'
8
- import { Sheet, SheetContent, SheetTrigger } from '../ui/sheet'
9
- import { Badge } from '../ui/badge'
10
- import { Separator } from '../ui/separator'
11
- import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip'
12
- import { HoverCard, HoverCardContent, HoverCardTrigger } from '../ui/hover-card'
13
- import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
14
- import {
15
- Menu,
16
- X,
17
- ChevronRight,
18
- ChevronLeft,
19
- ChevronDown,
20
- Home,
21
- Search,
22
- Settings,
23
- HelpCircle,
24
- Moon,
25
- Sun,
26
- Monitor,
27
- MoreHorizontal,
28
- Pin,
29
- PinOff,
30
- Sparkles,
31
- Command
32
- } from 'lucide-react'
33
- import {
34
- DropdownMenu,
35
- DropdownMenuContent,
36
- DropdownMenuItem,
37
- DropdownMenuSeparator,
38
- DropdownMenuTrigger,
39
- } from '../ui/dropdown-menu'
40
-
41
- // Search Input Component - with local state to prevent focus loss
42
- const SearchInput = React.memo(({
43
- searchInputRef,
44
- searchPlaceholder,
45
- initialValue,
46
- onSearchChange,
47
- keyboardShortcuts
48
- }: {
49
- searchInputRef: React.RefObject<HTMLInputElement | null>
50
- searchPlaceholder: string
51
- initialValue: string
52
- onSearchChange: (value: string) => void
53
- keyboardShortcuts: boolean
54
- }) => {
55
- // Local state to prevent focus loss
56
- const [localValue, setLocalValue] = useState<string>(initialValue || '')
57
- const timeoutRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
58
-
59
- // Update local value when initial value changes from parent
60
- useEffect(() => {
61
- setLocalValue(initialValue)
62
- }, [initialValue])
63
-
64
- // Handle input changes locally and debounce to parent
65
- const handleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
66
- const newValue = e.target.value
67
- setLocalValue(newValue)
68
-
69
- // Clear previous timeout
70
- if (timeoutRef.current) {
71
- clearTimeout(timeoutRef.current)
72
- }
73
-
74
- // Debounce the parent update
75
- timeoutRef.current = setTimeout(() => {
76
- onSearchChange(newValue)
77
- }, 300)
78
- }, [onSearchChange])
79
-
80
- // Cleanup timeout on unmount
81
- useEffect(() => {
82
- return () => {
83
- if (timeoutRef.current) {
84
- clearTimeout(timeoutRef.current)
85
- }
86
- }
87
- }, [])
88
-
89
- return (
90
- <div className="p-4 border-b">
91
- <div className="relative">
92
- <Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none" />
93
- <input
94
- ref={searchInputRef}
95
- type="text"
96
- placeholder={searchPlaceholder}
97
- value={localValue}
98
- onChange={handleChange}
99
- autoComplete="off"
100
- autoCorrect="off"
101
- autoCapitalize="off"
102
- spellCheck="false"
103
- className="w-full h-10 pl-9 pr-9 text-sm bg-background border border-input rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
104
- />
105
- {keyboardShortcuts && (
106
- <kbd className="absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 hidden sm:flex">
107
- <span className="text-xs">⌘</span>K
108
- </kbd>
109
- )}
110
- </div>
111
- </div>
112
- )
113
- })
114
-
115
- export interface SidebarItem {
116
- id: string
117
- title: string
118
- href?: string
119
- icon?: React.ReactNode
120
- badge?: string | number
121
- badgeVariant?: 'secondary' | 'destructive' | 'outline'
122
- disabled?: boolean
123
- items?: SidebarItem[]
124
- action?: () => void
125
- tooltip?: string
126
- filteredChildren?: SidebarItem[]
127
- }
128
-
129
- export interface SidebarSection {
130
- id: string
131
- title?: string
132
- items: SidebarItem[]
133
- collapsible?: boolean
134
- defaultExpanded?: boolean
135
- showDivider?: boolean
136
- }
137
-
138
- export interface SidebarConfig {
139
- sections: SidebarSection[]
140
- footer?: SidebarSection
141
- showSearch?: boolean
142
- searchPlaceholder?: string
143
- searchQuery?: string
144
- onSearchChange?: (value: string) => void
145
- showThemeToggle?: boolean
146
- theme?: 'light' | 'dark' | 'system'
147
- onThemeChange?: (theme: 'light' | 'dark' | 'system') => void
148
- branding?: {
149
- logo?: React.ReactNode
150
- title?: string
151
- href?: string
152
- }
153
- collapsible?: boolean
154
- defaultCollapsed?: boolean
155
- floatingActionButton?: boolean
156
- floatingActionButtonPosition?: {
157
- bottom?: string
158
- left?: string
159
- right?: string
160
- top?: string
161
- }
162
- floatingActionButtonClassName?: string
163
- glassmorphism?: boolean
164
- animatedBackground?: boolean
165
- keyboardShortcuts?: boolean
166
- persistState?: boolean
167
- persistKey?: string
168
- onStateChange?: (state: SidebarState) => void
169
- customStyles?: {
170
- background?: string
171
- border?: string
172
- text?: string
173
- hover?: string
174
- active?: string
175
- }
176
- }
177
-
178
- export interface SidebarState {
179
- collapsed: boolean
180
- expandedSections: string[]
181
- searchQuery: string
182
- pinnedItems: string[]
183
- recentItems: string[]
184
- }
185
-
186
- interface SidebarProps extends SidebarConfig {
187
- className?: string
188
- activePath?: string
189
- onNavigate?: (href: string) => void
190
- }
191
-
192
- export function Sidebar({
193
- sections,
194
- footer,
195
- showSearch = true,
196
- searchPlaceholder = "Search...",
197
- searchQuery = '',
198
- onSearchChange,
199
- showThemeToggle = false,
200
- theme = 'system',
201
- onThemeChange,
202
- branding,
203
- collapsible = true,
204
- defaultCollapsed = false,
205
- floatingActionButton = true,
206
- floatingActionButtonPosition = { bottom: '1rem', left: '1rem' },
207
- floatingActionButtonClassName,
208
- glassmorphism = false,
209
- animatedBackground = false,
210
- keyboardShortcuts = true,
211
- persistState = true,
212
- persistKey = 'moonui-sidebar-state',
213
- onStateChange,
214
- customStyles,
215
- className,
216
- activePath,
217
- onNavigate
218
- }: SidebarProps) {
219
- const [isMobile, setIsMobile] = useState(false)
220
- const [isOpen, setIsOpen] = useState(false)
221
- const [collapsed, setCollapsed] = useState(defaultCollapsed)
222
- const [expandedSections, setExpandedSections] = useState<string[]>([])
223
- const [currentSearchQuery, setCurrentSearchQuery] = useState(searchQuery)
224
- const [pinnedItems, setPinnedItems] = useState<string[]>([])
225
- const searchInputRef = useRef<HTMLInputElement | null>(null)
226
- const mouseX = useMotionValue(0)
227
- const mouseY = useMotionValue(0)
228
- const springX = useSpring(mouseX, { stiffness: 300, damping: 30 })
229
- const springY = useSpring(mouseY, { stiffness: 300, damping: 30 })
230
-
231
- // Load persisted state
232
- useEffect(() => {
233
- if (persistState && typeof window !== 'undefined') {
234
- const savedState = localStorage.getItem(persistKey)
235
- if (savedState) {
236
- const state = JSON.parse(savedState) as SidebarState
237
- setCollapsed(state.collapsed)
238
- setExpandedSections(state.expandedSections)
239
- setPinnedItems(state.pinnedItems || [])
240
- }
241
- }
242
- }, [persistState, persistKey])
243
-
244
- // Save state changes
245
- useEffect(() => {
246
- if (persistState && typeof window !== 'undefined') {
247
- const state: SidebarState = {
248
- collapsed,
249
- expandedSections,
250
- searchQuery: currentSearchQuery,
251
- pinnedItems,
252
- recentItems: []
253
- }
254
- localStorage.setItem(persistKey, JSON.stringify(state))
255
- onStateChange?.(state)
256
- }
257
- }, [collapsed, expandedSections, currentSearchQuery, pinnedItems, persistState, persistKey, onStateChange])
258
-
259
- // Check mobile
260
- useEffect(() => {
261
- const checkMobile = () => {
262
- setIsMobile(window.innerWidth < 768)
263
- }
264
-
265
- checkMobile()
266
- window.addEventListener('resize', checkMobile)
267
- return () => window.removeEventListener('resize', checkMobile)
268
- }, [])
269
-
270
- // Initialize expanded sections
271
- useEffect(() => {
272
- const sectionsToExpand = sections
273
- .filter(section => section.defaultExpanded !== false)
274
- .map(section => section.id)
275
- setExpandedSections(sectionsToExpand)
276
- }, [sections])
277
-
278
- // Keyboard shortcuts
279
- useEffect(() => {
280
- if (!keyboardShortcuts) return
281
-
282
- const handleKeyDown = (e: KeyboardEvent) => {
283
- // Cmd/Ctrl + K for search
284
- if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
285
- e.preventDefault()
286
- searchInputRef.current?.focus()
287
- }
288
-
289
- // Cmd/Ctrl + B to toggle sidebar
290
- if ((e.metaKey || e.ctrlKey) && e.key === 'b') {
291
- e.preventDefault()
292
- if (isMobile) {
293
- setIsOpen(!isOpen)
294
- } else {
295
- setCollapsed(!collapsed)
296
- }
297
- }
298
- }
299
-
300
- document.addEventListener('keydown', handleKeyDown)
301
- return () => document.removeEventListener('keydown', handleKeyDown)
302
- }, [keyboardShortcuts, isMobile, isOpen, collapsed])
303
-
304
- // Mouse tracking for animated background
305
- useEffect(() => {
306
- if (!animatedBackground) return
307
-
308
- const handleMouseMove = (e: MouseEvent) => {
309
- const rect = document.querySelector('.sidebar-container')?.getBoundingClientRect()
310
- if (rect) {
311
- mouseX.set(e.clientX - rect.left)
312
- mouseY.set(e.clientY - rect.top)
313
- }
314
- }
315
-
316
- document.addEventListener('mousemove', handleMouseMove)
317
- return () => document.removeEventListener('mousemove', handleMouseMove)
318
- }, [animatedBackground, mouseX, mouseY])
319
-
320
- const toggleSection = useCallback((sectionId: string) => {
321
- setExpandedSections(prev =>
322
- prev.includes(sectionId)
323
- ? prev.filter(id => id !== sectionId)
324
- : [...prev, sectionId]
325
- )
326
- }, [])
327
-
328
- const togglePinItem = useCallback((itemId: string) => {
329
- setPinnedItems(prev =>
330
- prev.includes(itemId)
331
- ? prev.filter(id => id !== itemId)
332
- : [...prev, itemId]
333
- )
334
- }, [])
335
-
336
- const handleItemClick = useCallback((item: SidebarItem) => {
337
- if (item.action) {
338
- item.action()
339
- } else if (item.href && onNavigate) {
340
- onNavigate(item.href)
341
- if (isMobile) {
342
- setIsOpen(false)
343
- }
344
- }
345
- }, [onNavigate, isMobile])
346
-
347
- // Update search query from prop
348
- useEffect(() => {
349
- setCurrentSearchQuery(searchQuery)
350
- }, [searchQuery])
351
-
352
- // Handle search change
353
- const handleSearch = useCallback((value: string) => {
354
- onSearchChange?.(value)
355
- }, [onSearchChange])
356
-
357
- const filterItems = useCallback((items: SidebarItem[], query: string): SidebarItem[] => {
358
- if (!query) return items
359
-
360
- return items.filter(item => {
361
- const matchesTitle = item.title.toLowerCase().includes(query.toLowerCase())
362
- const hasMatchingChildren = item.items?.some(child =>
363
- child.title.toLowerCase().includes(query.toLowerCase())
364
- )
365
- return matchesTitle || hasMatchingChildren
366
- })
367
- }, [])
368
-
369
- // Filtered sections memoized to prevent re-renders
370
- const filteredSections = useMemo(() => {
371
- if (!currentSearchQuery) {
372
- return sections.map(section => ({
373
- ...section,
374
- filteredItems: section.items.map(item => ({
375
- ...item,
376
- filteredChildren: item.items
377
- }))
378
- }))
379
- }
380
-
381
- return sections.map(section => ({
382
- ...section,
383
- filteredItems: filterItems(section.items, currentSearchQuery).map(item => ({
384
- ...item,
385
- filteredChildren: item.items ? filterItems(item.items, currentSearchQuery) : undefined
386
- }))
387
- })).filter(section => section.filteredItems.length > 0)
388
- }, [sections, currentSearchQuery, filterItems])
389
-
390
- // Collapsed menü için hover content renderer
391
- const renderCollapsedHoverContent = useCallback((item: SidebarItem) => {
392
- const hasChildren = item.items && item.items.length > 0
393
-
394
- if (!hasChildren && !item.title) return null
395
-
396
- return (
397
- <div className={cn(
398
- "min-w-[200px] p-2",
399
- glassmorphism && "bg-background/95 backdrop-blur-sm"
400
- )}>
401
- <div className="font-medium px-2 py-1 text-sm">{item.title}</div>
402
- {hasChildren && (
403
- <div className="mt-1 space-y-0.5">
404
- {item.items?.map(childItem => {
405
- const isChildActive = childItem.href === activePath
406
- const hasGrandChildren = childItem.items && childItem.items.length > 0
407
-
408
- return (
409
- <div key={childItem.id} className="relative">
410
- {hasGrandChildren ? (
411
- <HoverCard openDelay={200} closeDelay={100}>
412
- <HoverCardTrigger asChild>
413
- <button
414
- onClick={() => handleItemClick(childItem)}
415
- disabled={childItem.disabled}
416
- className={cn(
417
- "w-full flex items-center justify-between gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
418
- "hover:bg-accent hover:text-accent-foreground",
419
- isChildActive && "bg-primary/10 text-primary font-medium",
420
- childItem.disabled && "opacity-50 cursor-not-allowed"
421
- )}
422
- >
423
- <div className="flex items-center gap-2">
424
- {childItem.icon && (
425
- <span className="flex-shrink-0">
426
- {childItem.icon}
427
- </span>
428
- )}
429
- <span className="truncate">{childItem.title}</span>
430
- </div>
431
- <ChevronRight className="h-3 w-3 flex-shrink-0" />
432
- </button>
433
- </HoverCardTrigger>
434
- <HoverCardContent
435
- side="right"
436
- align="start"
437
- sideOffset={10}
438
- className={cn(
439
- "p-2",
440
- glassmorphism && "bg-background/95 backdrop-blur-sm"
441
- )}
442
- >
443
- <div className="space-y-0.5">
444
- {childItem.items?.map(grandChild => {
445
- const isGrandChildActive = grandChild.href === activePath
446
- return (
447
- <button
448
- key={grandChild.id}
449
- onClick={() => handleItemClick(grandChild)}
450
- disabled={grandChild.disabled}
451
- className={cn(
452
- "w-full flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
453
- "hover:bg-accent hover:text-accent-foreground",
454
- isGrandChildActive && "bg-primary/10 text-primary font-medium",
455
- grandChild.disabled && "opacity-50 cursor-not-allowed"
456
- )}
457
- >
458
- {grandChild.icon && (
459
- <span className="flex-shrink-0">
460
- {grandChild.icon}
461
- </span>
462
- )}
463
- <span className="truncate">{grandChild.title}</span>
464
- {grandChild.badge && (
465
- <Badge
466
- variant={grandChild.badgeVariant || 'secondary'}
467
- className="ml-auto flex-shrink-0"
468
- >
469
- {grandChild.badge}
470
- </Badge>
471
- )}
472
- </button>
473
- )
474
- })}
475
- </div>
476
- </HoverCardContent>
477
- </HoverCard>
478
- ) : (
479
- <button
480
- onClick={() => handleItemClick(childItem)}
481
- disabled={childItem.disabled}
482
- className={cn(
483
- "w-full flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
484
- "hover:bg-accent hover:text-accent-foreground",
485
- isChildActive && "bg-primary/10 text-primary font-medium",
486
- childItem.disabled && "opacity-50 cursor-not-allowed"
487
- )}
488
- >
489
- {childItem.icon && (
490
- <span className="flex-shrink-0">
491
- {childItem.icon}
492
- </span>
493
- )}
494
- <span className="truncate">{childItem.title}</span>
495
- {childItem.badge && (
496
- <Badge
497
- variant={childItem.badgeVariant || 'secondary'}
498
- className="ml-auto flex-shrink-0"
499
- >
500
- {childItem.badge}
501
- </Badge>
502
- )}
503
- </button>
504
- )}
505
- </div>
506
- )
507
- })}
508
- </div>
509
- )}
510
- </div>
511
- )
512
- }, [activePath, glassmorphism, handleItemClick])
513
-
514
- const renderItem = useCallback((item: SidebarItem, depth = 0, filteredChildren?: SidebarItem[]) => {
515
- const isActive = item.href === activePath
516
- const isPinned = pinnedItems.includes(item.id)
517
- const hasChildren = item.items && item.items.length > 0
518
- const isExpanded = expandedSections.includes(item.id)
519
- const shouldShowHoverMenu = collapsed && !isMobile && depth === 0 && (hasChildren || item.title)
520
-
521
- const ItemWrapper = item.tooltip && !collapsed ? TooltipTrigger : React.Fragment
522
-
523
- const itemContent = (
524
- <button
525
- onClick={() => {
526
- if (hasChildren) {
527
- toggleSection(item.id)
528
- } else {
529
- handleItemClick(item)
530
- }
531
- }}
532
- className={cn(
533
- "w-full flex items-center gap-3 rounded-lg px-3 py-2 text-sm transition-all",
534
- "hover:bg-accent hover:text-accent-foreground",
535
- isActive && "bg-primary/10 text-primary font-medium",
536
- item.disabled && "opacity-50 cursor-not-allowed",
537
- depth > 0 && "ml-6 text-xs",
538
- collapsed && depth === 0 && "justify-center px-2",
539
- customStyles?.hover
540
- )}
541
- disabled={item.disabled}
542
- >
543
- {item.icon && (
544
- <span className={cn(
545
- "flex-shrink-0",
546
- collapsed && depth === 0 && "mx-auto"
547
- )}>
548
- {item.icon}
549
- </span>
550
- )}
551
-
552
- {(!collapsed || depth > 0) && (
553
- <>
554
- <span className="flex-1 text-left truncate">{item.title}</span>
555
-
556
- {item.badge && (
557
- <Badge
558
- variant={item.badgeVariant || 'secondary'}
559
- className="ml-auto flex-shrink-0"
560
- >
561
- {item.badge}
562
- </Badge>
563
- )}
564
-
565
- {hasChildren && depth === 0 && (
566
- <ChevronDown
567
- className={cn(
568
- "h-4 w-4 flex-shrink-0 transition-transform",
569
- isExpanded && "rotate-180"
570
- )}
571
- />
572
- )}
573
-
574
- {isPinned && (
575
- <Pin className="h-3 w-3 flex-shrink-0" />
576
- )}
577
- </>
578
- )}
579
- </button>
580
- )
581
-
582
- // Collapsed durumda hover menü göster
583
- if (shouldShowHoverMenu) {
584
- return (
585
- <div key={item.id}>
586
- <HoverCard openDelay={200} closeDelay={100}>
587
- <HoverCardTrigger asChild>
588
- {itemContent}
589
- </HoverCardTrigger>
590
- <HoverCardContent
591
- side="right"
592
- align="start"
593
- sideOffset={10}
594
- className={cn(
595
- "p-0 w-auto",
596
- glassmorphism && "bg-background/95 backdrop-blur-sm",
597
- "animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95"
598
- )}
599
- >
600
- <motion.div
601
- initial={{ opacity: 0, x: -10 }}
602
- animate={{ opacity: 1, x: 0 }}
603
- exit={{ opacity: 0, x: -10 }}
604
- transition={{ duration: 0.15 }}
605
- >
606
- {renderCollapsedHoverContent(item)}
607
- </motion.div>
608
- </HoverCardContent>
609
- </HoverCard>
610
- </div>
611
- )
612
- }
613
-
614
- return (
615
- <div key={item.id}>
616
- {item.tooltip && !collapsed ? (
617
- <TooltipProvider>
618
- <Tooltip>
619
- <ItemWrapper>
620
- {itemContent}
621
- </ItemWrapper>
622
- <TooltipContent side="right">
623
- <p>{item.tooltip}</p>
624
- </TooltipContent>
625
- </Tooltip>
626
- </TooltipProvider>
627
- ) : (
628
- itemContent
629
- )}
630
-
631
- {hasChildren && !collapsed && filteredChildren && (
632
- <AnimatePresence>
633
- {isExpanded && (
634
- <motion.div
635
- initial={{ height: 0, opacity: 0 }}
636
- animate={{ height: "auto", opacity: 1 }}
637
- exit={{ height: 0, opacity: 0 }}
638
- transition={{ duration: 0.2 }}
639
- className="overflow-hidden"
640
- >
641
- <div className="pt-1 space-y-1">
642
- {filteredChildren.map(child =>
643
- renderItem(child, depth + 1)
644
- )}
645
- </div>
646
- </motion.div>
647
- )}
648
- </AnimatePresence>
649
- )}
650
- </div>
651
- )
652
- }, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection, isMobile, glassmorphism, renderCollapsedHoverContent])
653
-
654
-
655
-
656
- // Header Component
657
- const SidebarHeader = React.memo(() => {
658
- return (
659
- <div className={cn(
660
- "flex items-center gap-3 p-4 border-b",
661
- collapsed && !isMobile && "justify-center px-2"
662
- )}>
663
- {branding && (
664
- <>
665
- {branding.logo}
666
- {(!collapsed || isMobile) && branding.title && (
667
- <span className="font-semibold text-lg">{branding.title}</span>
668
- )}
669
- </>
670
- )}
671
-
672
- {isMobile && (
673
- <Button
674
- variant="ghost"
675
- size="sm"
676
- className="ml-auto h-8 w-8 p-0"
677
- onClick={() => setIsOpen(false)}
678
- >
679
- <X className="h-4 w-4" />
680
- </Button>
681
- )}
682
-
683
- {!isMobile && collapsible && (
684
- <Button
685
- variant="ghost"
686
- size="sm"
687
- className={cn(
688
- "h-8 w-8 p-0",
689
- !collapsed && "ml-auto"
690
- )}
691
- onClick={() => setCollapsed(!collapsed)}
692
- >
693
- {collapsed ? <ChevronRight className="h-4 w-4" /> : <ChevronLeft className="h-4 w-4" />}
694
- </Button>
695
- )}
696
- </div>
697
- )
698
- })
699
-
700
-
701
- // Menu Content
702
- const SidebarMenuContent = React.memo(() => {
703
- return (
704
- <ScrollArea className="flex-1 overflow-y-auto">
705
- <div className="p-4 space-y-6">
706
- {/* Pinned Items */}
707
- {pinnedItems.length > 0 && (!collapsed || isMobile) && (
708
- <div>
709
- <h4 className="text-xs font-medium text-muted-foreground mb-2">Pinned</h4>
710
- <div className="space-y-1">
711
- {sections.flatMap(section =>
712
- section.items.filter(item => pinnedItems.includes(item.id))
713
- ).map(item => renderItem(item))}
714
- </div>
715
- <Separator className="mt-4" />
716
- </div>
717
- )}
718
-
719
- {/* Main Menu Items */}
720
- {filteredSections.map((section, index) => (
721
- <div key={section.id}>
722
- {section.title && (!collapsed || isMobile) && (
723
- <h4 className="text-xs font-medium text-muted-foreground mb-2">
724
- {section.title}
725
- </h4>
726
- )}
727
- <div className="space-y-1">
728
- {section.filteredItems.map(item => renderItem(item, 0, item.filteredChildren))}
729
- </div>
730
- {section.showDivider && index < filteredSections.length - 1 && (
731
- <Separator className="mt-4" />
732
- )}
733
- </div>
734
- ))}
735
- </div>
736
- </ScrollArea>
737
- )
738
- })
739
-
740
- // Footer Component
741
- const SidebarFooter = React.memo(() => {
742
- return footer ? (
743
- <div className="border-t p-4">
744
- <div className="space-y-1">
745
- {footer.items.map(item => renderItem(item))}
746
- </div>
747
-
748
- {showThemeToggle && (!collapsed || isMobile) && (
749
- <div className="mt-3 flex items-center justify-between">
750
- <span className="text-xs text-muted-foreground">Theme</span>
751
- <DropdownMenu>
752
- <DropdownMenuTrigger asChild>
753
- <Button variant="ghost" size="sm" className="h-7 px-2">
754
- {theme === 'light' && <Sun className="h-3 w-3" />}
755
- {theme === 'dark' && <Moon className="h-3 w-3" />}
756
- {theme === 'system' && <Monitor className="h-3 w-3" />}
757
- </Button>
758
- </DropdownMenuTrigger>
759
- <DropdownMenuContent align="end">
760
- <DropdownMenuItem onClick={() => onThemeChange?.('light')}>
761
- <Sun className="mr-2 h-4 w-4" />
762
- Light
763
- </DropdownMenuItem>
764
- <DropdownMenuItem onClick={() => onThemeChange?.('dark')}>
765
- <Moon className="mr-2 h-4 w-4" />
766
- Dark
767
- </DropdownMenuItem>
768
- <DropdownMenuItem onClick={() => onThemeChange?.('system')}>
769
- <Monitor className="mr-2 h-4 w-4" />
770
- System
771
- </DropdownMenuItem>
772
- </DropdownMenuContent>
773
- </DropdownMenu>
774
- </div>
775
- )}
776
- </div>
777
- ) : null
778
- })
779
-
780
- const SidebarContent = React.memo(() => {
781
- return (
782
- <>
783
- <SidebarHeader />
784
- {showSearch && (!collapsed || isMobile) && (
785
- <SearchInput
786
- searchInputRef={searchInputRef}
787
- searchPlaceholder={searchPlaceholder}
788
- initialValue={searchQuery}
789
- onSearchChange={handleSearch}
790
- keyboardShortcuts={keyboardShortcuts}
791
- />
792
- )}
793
- <SidebarMenuContent />
794
- <SidebarFooter />
795
- </>
796
- )
797
- })
798
-
799
- const sidebarClasses = cn(
800
- "moonui-pro flex h-full flex-col bg-background border-r",
801
- glassmorphism && "bg-background/80 backdrop-blur-xl border-white/10",
802
- collapsed && !isMobile && "w-16",
803
- !collapsed && !isMobile && "w-64",
804
- customStyles?.background,
805
- customStyles?.border,
806
- className
807
- )
808
-
809
- if (isMobile) {
810
- return (
811
- <>
812
- {floatingActionButton && (
813
- <Button
814
- onClick={() => setIsOpen(true)}
815
- className={cn(
816
- "fixed z-40 h-12 w-12 rounded-full shadow-lg md:hidden",
817
- floatingActionButtonClassName
818
- )}
819
- size="icon"
820
- style={{
821
- bottom: floatingActionButtonPosition?.bottom,
822
- left: floatingActionButtonPosition?.left,
823
- right: floatingActionButtonPosition?.right,
824
- top: floatingActionButtonPosition?.top
825
- }}
826
- >
827
- <Menu className="h-5 w-5" />
828
- </Button>
829
- )}
830
-
831
- <Sheet open={isOpen} onOpenChange={setIsOpen}>
832
- <SheetContent side="left" className="w-80 p-0">
833
- <div className={cn(sidebarClasses, "sidebar-container flex flex-col")}>
834
- {animatedBackground && (
835
- <motion.div
836
- className="absolute inset-0 opacity-30"
837
- style={{
838
- background: `radial-gradient(circle at ${springX}px ${springY}px, rgba(var(--primary-rgb), 0.15), transparent 50%)`,
839
- }}
840
- />
841
- )}
842
- <SidebarContent />
843
- </div>
844
- </SheetContent>
845
- </Sheet>
846
- </>
847
- )
848
- }
849
-
850
- return (
851
- <aside className={cn(sidebarClasses, "sidebar-container hidden md:flex flex-col")}>
852
- {animatedBackground && (
853
- <motion.div
854
- className="absolute inset-0 opacity-30"
855
- style={{
856
- background: `radial-gradient(circle at ${springX}px ${springY}px, rgba(var(--primary-rgb), 0.15), transparent 50%)`,
857
- }}
858
- />
859
- )}
860
- <SidebarContent />
861
- </aside>
862
- )
863
- }
864
-
865
- export default Sidebar