@moontra/moonui-pro 2.5.14 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,6 +9,8 @@ import { Sheet, SheetContent, SheetTrigger } from '../ui/sheet'
9
9
  import { Badge } from '../ui/badge'
10
10
  import { Separator } from '../ui/separator'
11
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'
12
14
  import {
13
15
  Menu,
14
16
  X,
@@ -151,6 +153,13 @@ export interface SidebarConfig {
151
153
  collapsible?: boolean
152
154
  defaultCollapsed?: boolean
153
155
  floatingActionButton?: boolean
156
+ floatingActionButtonPosition?: {
157
+ bottom?: string
158
+ left?: string
159
+ right?: string
160
+ top?: string
161
+ }
162
+ floatingActionButtonClassName?: string
154
163
  glassmorphism?: boolean
155
164
  animatedBackground?: boolean
156
165
  keyboardShortcuts?: boolean
@@ -194,6 +203,8 @@ export function Sidebar({
194
203
  collapsible = true,
195
204
  defaultCollapsed = false,
196
205
  floatingActionButton = true,
206
+ floatingActionButtonPosition = { bottom: '1rem', left: '1rem' },
207
+ floatingActionButtonClassName,
197
208
  glassmorphism = false,
198
209
  animatedBackground = false,
199
210
  keyboardShortcuts = true,
@@ -376,11 +387,136 @@ export function Sidebar({
376
387
  })).filter(section => section.filteredItems.length > 0)
377
388
  }, [sections, currentSearchQuery, filterItems])
378
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
+
379
514
  const renderItem = useCallback((item: SidebarItem, depth = 0, filteredChildren?: SidebarItem[]) => {
380
515
  const isActive = item.href === activePath
381
516
  const isPinned = pinnedItems.includes(item.id)
382
517
  const hasChildren = item.items && item.items.length > 0
383
518
  const isExpanded = expandedSections.includes(item.id)
519
+ const shouldShowHoverMenu = collapsed && !isMobile && depth === 0 && (hasChildren || item.title)
384
520
 
385
521
  const ItemWrapper = item.tooltip && !collapsed ? TooltipTrigger : React.Fragment
386
522
 
@@ -443,6 +579,38 @@ export function Sidebar({
443
579
  </button>
444
580
  )
445
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
+
446
614
  return (
447
615
  <div key={item.id}>
448
616
  {item.tooltip && !collapsed ? (
@@ -481,7 +649,7 @@ export function Sidebar({
481
649
  )}
482
650
  </div>
483
651
  )
484
- }, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection])
652
+ }, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection, isMobile, glassmorphism, renderCollapsedHoverContent])
485
653
 
486
654
 
487
655
 
@@ -644,8 +812,17 @@ export function Sidebar({
644
812
  {floatingActionButton && (
645
813
  <Button
646
814
  onClick={() => setIsOpen(true)}
647
- className="fixed bottom-4 left-4 z-40 h-12 w-12 rounded-full shadow-lg md:hidden"
815
+ className={cn(
816
+ "fixed z-40 h-12 w-12 rounded-full shadow-lg md:hidden",
817
+ floatingActionButtonClassName
818
+ )}
648
819
  size="icon"
820
+ style={{
821
+ bottom: floatingActionButtonPosition?.bottom,
822
+ left: floatingActionButtonPosition?.left,
823
+ right: floatingActionButtonPosition?.right,
824
+ top: floatingActionButtonPosition?.top
825
+ }}
649
826
  >
650
827
  <Menu className="h-5 w-5" />
651
828
  </Button>
@@ -1,65 +1,387 @@
1
- "use client"
1
+ "use client";
2
2
 
3
- import * as React from "react"
4
- import { ChevronLeft, ChevronRight } from "lucide-react"
5
- import { DayPicker } from "react-day-picker"
6
- import { cn } from "../../lib/utils"
7
- import { buttonVariants } from "./button"
3
+ import * as React from "react";
4
+ import { ChevronLeft, ChevronRight } from "lucide-react";
5
+ import { cn } from "../../lib/utils";
6
+ import { buttonVariants } from "./button";
7
+ import {
8
+ format,
9
+ startOfMonth,
10
+ endOfMonth,
11
+ eachDayOfInterval,
12
+ getDay,
13
+ isSameMonth,
14
+ isSameDay,
15
+ isToday,
16
+ addMonths,
17
+ subMonths,
18
+ startOfWeek,
19
+ endOfWeek
20
+ } from "date-fns";
8
21
 
9
- export type CalendarProps = React.ComponentProps<typeof DayPicker>
22
+ export interface CalendarProps {
23
+ mode?: "single" | "range" | "multiple";
24
+ selected?: Date | Date[] | { from?: Date; to?: Date } | undefined;
25
+ onSelect?: (date: Date | Date[] | { from?: Date; to?: Date } | undefined) => void;
26
+ disabled?: (date: Date) => boolean;
27
+ showOutsideDays?: boolean;
28
+ className?: string;
29
+ classNames?: Record<string, string>;
30
+ numberOfMonths?: number;
31
+ defaultMonth?: Date;
32
+ initialFocus?: boolean;
33
+ }
10
34
 
11
35
  function Calendar({
36
+ mode = "single",
37
+ selected,
38
+ onSelect,
39
+ disabled,
40
+ showOutsideDays = false,
12
41
  className,
13
42
  classNames,
14
- showOutsideDays = true,
43
+ numberOfMonths = 1,
44
+ defaultMonth,
15
45
  ...props
16
46
  }: CalendarProps) {
47
+ const getInitialMonth = () => {
48
+ if (defaultMonth) return defaultMonth;
49
+ if (mode === "range" && selected) {
50
+ const range = selected as { from?: Date; to?: Date };
51
+ if (range.from && range.from instanceof Date) return range.from;
52
+ }
53
+ if (selected && selected instanceof Date) return selected;
54
+ return new Date();
55
+ };
56
+
57
+ const [currentMonth, setCurrentMonth] = React.useState(getInitialMonth());
58
+
59
+ const weekDays = [
60
+ { short: "S", full: "Sunday" },
61
+ { short: "M", full: "Monday" },
62
+ { short: "T", full: "Tuesday" },
63
+ { short: "W", full: "Wednesday" },
64
+ { short: "T", full: "Thursday" },
65
+ { short: "F", full: "Friday" },
66
+ { short: "S", full: "Saturday" }
67
+ ];
68
+
69
+ const handlePreviousMonth = () => {
70
+ setCurrentMonth(subMonths(currentMonth, 1));
71
+ };
72
+
73
+ const handleNextMonth = () => {
74
+ setCurrentMonth(addMonths(currentMonth, 1));
75
+ };
76
+
77
+ const handleDateClick = (date: Date) => {
78
+ if (disabled?.(date)) return;
79
+
80
+ if (mode === "single") {
81
+ onSelect?.(date);
82
+ } else if (mode === "range") {
83
+ const currentSelection = selected as { from?: Date; to?: Date } | undefined;
84
+ if (!currentSelection?.from || (currentSelection.from && currentSelection.to)) {
85
+ onSelect?.({ from: date, to: undefined });
86
+ } else {
87
+ if (date < currentSelection.from) {
88
+ onSelect?.({ from: date, to: currentSelection.from });
89
+ } else {
90
+ onSelect?.({ from: currentSelection.from, to: date });
91
+ }
92
+ }
93
+ }
94
+ };
95
+
96
+ const isDateSelected = (date: Date) => {
97
+ if (!selected) return false;
98
+
99
+ if (mode === "single") {
100
+ return isSameDay(date, selected as Date);
101
+ } else if (mode === "range") {
102
+ const range = selected as { from?: Date; to?: Date };
103
+ if (range.from && range.to) {
104
+ return date >= range.from && date <= range.to;
105
+ }
106
+ return range.from ? isSameDay(date, range.from) : false;
107
+ }
108
+ return false;
109
+ };
110
+
111
+ const isRangeStart = (date: Date) => {
112
+ if (mode !== "range" || !selected) return false;
113
+ const range = selected as { from?: Date; to?: Date };
114
+ return range.from ? isSameDay(date, range.from) : false;
115
+ };
116
+
117
+ const isRangeEnd = (date: Date) => {
118
+ if (mode !== "range" || !selected) return false;
119
+ const range = selected as { from?: Date; to?: Date };
120
+ return range.to ? isSameDay(date, range.to) : false;
121
+ };
122
+
123
+ const isRangeMiddle = (date: Date) => {
124
+ if (mode !== "range" || !selected) return false;
125
+ const range = selected as { from?: Date; to?: Date };
126
+ if (!range.from || !range.to) return false;
127
+ return date > range.from && date < range.to;
128
+ };
129
+
130
+ const getDaysInMonth = () => {
131
+ const start = startOfMonth(currentMonth);
132
+ const end = endOfMonth(currentMonth);
133
+ const days = eachDayOfInterval({ start, end });
134
+
135
+ // Get days from previous month to fill the first week
136
+ const firstDayOfWeek = getDay(start);
137
+ const previousMonthDays = [];
138
+ if (firstDayOfWeek > 0 && showOutsideDays) {
139
+ const previousMonthStart = startOfWeek(start);
140
+ const previousMonthEnd = new Date(start);
141
+ previousMonthEnd.setDate(previousMonthEnd.getDate() - 1);
142
+ previousMonthDays.push(...eachDayOfInterval({
143
+ start: previousMonthStart,
144
+ end: previousMonthEnd
145
+ }));
146
+ }
147
+
148
+ // Get days from next month to fill the last week
149
+ const lastDayOfWeek = getDay(end);
150
+ const nextMonthDays = [];
151
+ if (lastDayOfWeek < 6 && showOutsideDays) {
152
+ const nextMonthStart = new Date(end);
153
+ nextMonthStart.setDate(nextMonthStart.getDate() + 1);
154
+ const nextMonthEnd = endOfWeek(end);
155
+ nextMonthDays.push(...eachDayOfInterval({
156
+ start: nextMonthStart,
157
+ end: nextMonthEnd
158
+ }));
159
+ }
160
+
161
+ // Add empty cells for the first week if not showing outside days
162
+ const emptyCells = [];
163
+ if (!showOutsideDays && firstDayOfWeek > 0) {
164
+ for (let i = 0; i < firstDayOfWeek; i++) {
165
+ emptyCells.push(null);
166
+ }
167
+ }
168
+
169
+ return [...previousMonthDays, ...emptyCells, ...days, ...nextMonthDays];
170
+ };
171
+
172
+ const renderCalendar = (monthOffset: number = 0) => {
173
+ const displayMonth = addMonths(currentMonth, monthOffset);
174
+ const start = startOfMonth(displayMonth);
175
+ const end = endOfMonth(displayMonth);
176
+ const days = eachDayOfInterval({ start, end });
177
+
178
+ // Get days from previous month to fill the first week
179
+ const firstDayOfWeek = getDay(start);
180
+ const previousMonthDays = [];
181
+ if (firstDayOfWeek > 0 && showOutsideDays) {
182
+ const previousMonthStart = startOfWeek(start);
183
+ const previousMonthEnd = new Date(start);
184
+ previousMonthEnd.setDate(previousMonthEnd.getDate() - 1);
185
+ previousMonthDays.push(...eachDayOfInterval({
186
+ start: previousMonthStart,
187
+ end: previousMonthEnd
188
+ }));
189
+ }
190
+
191
+ // Get days from next month to fill the last week
192
+ const lastDayOfWeek = getDay(end);
193
+ const nextMonthDays = [];
194
+ if (lastDayOfWeek < 6 && showOutsideDays) {
195
+ const nextMonthStart = new Date(end);
196
+ nextMonthStart.setDate(nextMonthStart.getDate() + 1);
197
+ const nextMonthEnd = endOfWeek(end);
198
+ nextMonthDays.push(...eachDayOfInterval({
199
+ start: nextMonthStart,
200
+ end: nextMonthEnd
201
+ }));
202
+ }
203
+
204
+ // Add empty cells for the first week if not showing outside days
205
+ const emptyCells = [];
206
+ if (!showOutsideDays && firstDayOfWeek > 0) {
207
+ for (let i = 0; i < firstDayOfWeek; i++) {
208
+ emptyCells.push(null);
209
+ }
210
+ }
211
+
212
+ const allDays = [...previousMonthDays, ...emptyCells, ...days, ...nextMonthDays];
213
+
214
+ return (
215
+ <div className="moonui-calendar-month flex-1 min-w-0">
216
+ {/* Month header for multi-month display */}
217
+ {numberOfMonths > 1 && (
218
+ <div className="flex items-center justify-center pb-2">
219
+ <h3 className="text-xs sm:text-sm font-medium">
220
+ {displayMonth instanceof Date && !isNaN(displayMonth.getTime())
221
+ ? format(displayMonth, "MMMM yyyy")
222
+ : ""}
223
+ </h3>
224
+ </div>
225
+ )}
226
+
227
+ {/* Week days header for each month */}
228
+ <div className="grid grid-cols-7 gap-0 mb-1">
229
+ {weekDays.map((day, index) => (
230
+ <div
231
+ key={`weekday-${monthOffset}-${index}`}
232
+ className="text-muted-foreground text-[0.65rem] sm:text-[0.75rem] font-normal h-6 sm:h-7 w-full flex items-center justify-center"
233
+ title={day.full}
234
+ >
235
+ {day.short}
236
+ </div>
237
+ ))}
238
+ </div>
239
+
240
+ {/* Days grid */}
241
+ <div className="grid grid-cols-7 gap-0">
242
+ {allDays.map((date, index) => {
243
+ if (!date) {
244
+ return <div key={`empty-${monthOffset}-${index}`} className="h-8 sm:h-9 w-full" />;
245
+ }
246
+
247
+ const isOutsideMonth = !isSameMonth(date, displayMonth);
248
+ const isDisabled = disabled?.(date) || false;
249
+ const isSelected = isDateSelected(date);
250
+ const isTodayDate = isToday(date);
251
+ const rangeStart = isRangeStart(date);
252
+ const rangeEnd = isRangeEnd(date);
253
+ const rangeMiddle = isRangeMiddle(date);
254
+
255
+ return (
256
+ <button
257
+ key={date.toISOString()}
258
+ onClick={() => handleDateClick(date)}
259
+ disabled={isDisabled}
260
+ className={cn(
261
+ "h-8 sm:h-9 w-full p-0 font-normal",
262
+ "inline-flex items-center justify-center rounded-md",
263
+ "hover:bg-muted transition-colors text-xs sm:text-sm",
264
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
265
+ isOutsideMonth && "text-muted-foreground/50",
266
+ isDisabled && "text-muted-foreground/30 cursor-not-allowed hover:bg-transparent",
267
+ isSelected && !rangeMiddle && "bg-primary text-primary-foreground font-medium hover:bg-primary hover:text-primary-foreground",
268
+ isTodayDate && !isSelected && "bg-accent text-accent-foreground",
269
+ rangeMiddle && "bg-accent rounded-none",
270
+ rangeStart && "rounded-r-none",
271
+ rangeEnd && "rounded-l-none"
272
+ )}
273
+ type="button"
274
+ >
275
+ {date instanceof Date && !isNaN(date.getTime())
276
+ ? format(date, "d")
277
+ : ""}
278
+ </button>
279
+ );
280
+ })}
281
+ </div>
282
+ </div>
283
+ );
284
+ };
285
+
17
286
  return (
18
- <DayPicker
19
- showOutsideDays={showOutsideDays}
20
- className={cn("moonui-calendar p-3", className)}
21
- classNames={{
22
- months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
23
- month: "space-y-4",
24
- caption: "flex justify-center pt-1 relative items-center",
25
- caption_label: "text-sm font-medium",
26
- nav: "space-x-1 flex items-center",
27
- nav_button: cn(
28
- buttonVariants({ variant: "outline" }),
29
- "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
30
- ),
31
- nav_button_previous: "absolute left-1",
32
- nav_button_next: "absolute right-1",
33
- table: "w-full border-collapse space-y-1",
34
- head_row: "flex w-full",
35
- head_cell:
36
- "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
37
- row: "flex w-full mt-2",
38
- cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
39
- day: cn(
40
- buttonVariants({ variant: "ghost" }),
41
- "h-9 w-9 p-0 font-normal aria-selected:opacity-100"
42
- ),
43
- day_range_end: "day-range-end",
44
- day_selected:
45
- "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
46
- day_today: "bg-accent text-accent-foreground",
47
- day_outside:
48
- "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
49
- day_disabled: "text-muted-foreground opacity-50",
50
- day_range_middle:
51
- "aria-selected:bg-accent aria-selected:text-accent-foreground",
52
- day_hidden: "invisible",
53
- ...classNames,
54
- }}
55
- components={{
56
- // IconLeft: () => <ChevronLeft className="h-4 w-4" />,
57
- // IconRight: () => <ChevronRight className="h-4 w-4" />,
58
- }}
59
- {...props}
60
- />
61
- )
287
+ <div className={cn("moonui-calendar p-2 sm:p-3", className)}>
288
+ {/* Header - only show for single month */}
289
+ {numberOfMonths === 1 && (
290
+ <div className="flex items-center justify-between px-1 pb-3">
291
+ <button
292
+ onClick={handlePreviousMonth}
293
+ className={cn(
294
+ buttonVariants({ variant: "outline" }),
295
+ "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
296
+ )}
297
+ type="button"
298
+ >
299
+ <ChevronLeft className="h-4 w-4" />
300
+ </button>
301
+
302
+ <h2 className="text-sm font-medium">
303
+ {currentMonth instanceof Date && !isNaN(currentMonth.getTime())
304
+ ? format(currentMonth, "MMMM yyyy")
305
+ : ""
306
+ }
307
+ </h2>
308
+
309
+ <button
310
+ onClick={handleNextMonth}
311
+ className={cn(
312
+ buttonVariants({ variant: "outline" }),
313
+ "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
314
+ )}
315
+ type="button"
316
+ >
317
+ <ChevronRight className="h-4 w-4" />
318
+ </button>
319
+ </div>
320
+ )}
321
+
322
+ {/* Navigation for multiple months */}
323
+ {numberOfMonths > 1 && (
324
+ <div className="flex items-center justify-between px-1 pb-3">
325
+ <button
326
+ onClick={handlePreviousMonth}
327
+ className={cn(
328
+ buttonVariants({ variant: "outline" }),
329
+ "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
330
+ )}
331
+ type="button"
332
+ >
333
+ <ChevronLeft className="h-4 w-4" />
334
+ </button>
335
+
336
+ <h2 className="text-xs sm:text-sm font-medium text-center">
337
+ {currentMonth instanceof Date && !isNaN(currentMonth.getTime())
338
+ ? `${format(currentMonth, "MMM yyyy")} - ${format(addMonths(currentMonth, numberOfMonths - 1), "MMM yyyy")}`
339
+ : ""
340
+ }
341
+ </h2>
342
+
343
+ <button
344
+ onClick={handleNextMonth}
345
+ className={cn(
346
+ buttonVariants({ variant: "outline" }),
347
+ "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
348
+ )}
349
+ type="button"
350
+ >
351
+ <ChevronRight className="h-4 w-4" />
352
+ </button>
353
+ </div>
354
+ )}
355
+
356
+ {/* Week days header for single month */}
357
+ {numberOfMonths === 1 && (
358
+ <div className="grid grid-cols-7 gap-0 mb-1">
359
+ {weekDays.map((day, index) => (
360
+ <div
361
+ key={`weekday-${index}`}
362
+ className="text-muted-foreground text-[0.65rem] sm:text-[0.75rem] font-normal h-6 sm:h-7 w-full flex items-center justify-center"
363
+ title={day.full}
364
+ >
365
+ {day.short}
366
+ </div>
367
+ ))}
368
+ </div>
369
+ )}
370
+
371
+ {/* Calendar(s) */}
372
+ <div className={cn(
373
+ numberOfMonths > 1 && "flex flex-col sm:flex-row gap-2 sm:gap-4"
374
+ )}>
375
+ {Array.from({ length: numberOfMonths }).map((_, i) => (
376
+ <div key={i} className="flex-1">
377
+ {renderCalendar(i)}
378
+ </div>
379
+ ))}
380
+ </div>
381
+ </div>
382
+ );
62
383
  }
63
- Calendar.displayName = "Calendar"
64
384
 
65
- export { Calendar }
385
+ Calendar.displayName = "Calendar";
386
+
387
+ export { Calendar };