@moontra/moonui-pro 2.5.14 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +88 -24
- package/dist/index.mjs +4258 -1236
- package/package.json +1 -1
- package/src/components/dashboard/demo.tsx +116 -2
- package/src/components/dashboard/index.tsx +318 -22
- package/src/components/dashboard/time-range-picker.tsx +317 -261
- package/src/components/sidebar/index.tsx +160 -1
- package/src/components/ui/calendar.tsx +376 -54
- package/src/components/ui/hover-card.tsx +29 -0
- package/src/components/ui/index.ts +4 -0
- package/src/styles/calendar.css +17 -81
|
@@ -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,
|
|
@@ -376,11 +378,136 @@ export function Sidebar({
|
|
|
376
378
|
})).filter(section => section.filteredItems.length > 0)
|
|
377
379
|
}, [sections, currentSearchQuery, filterItems])
|
|
378
380
|
|
|
381
|
+
// Collapsed menü için hover content renderer
|
|
382
|
+
const renderCollapsedHoverContent = useCallback((item: SidebarItem) => {
|
|
383
|
+
const hasChildren = item.items && item.items.length > 0
|
|
384
|
+
|
|
385
|
+
if (!hasChildren && !item.title) return null
|
|
386
|
+
|
|
387
|
+
return (
|
|
388
|
+
<div className={cn(
|
|
389
|
+
"min-w-[200px] p-2",
|
|
390
|
+
glassmorphism && "bg-background/95 backdrop-blur-sm"
|
|
391
|
+
)}>
|
|
392
|
+
<div className="font-medium px-2 py-1 text-sm">{item.title}</div>
|
|
393
|
+
{hasChildren && (
|
|
394
|
+
<div className="mt-1 space-y-0.5">
|
|
395
|
+
{item.items?.map(childItem => {
|
|
396
|
+
const isChildActive = childItem.href === activePath
|
|
397
|
+
const hasGrandChildren = childItem.items && childItem.items.length > 0
|
|
398
|
+
|
|
399
|
+
return (
|
|
400
|
+
<div key={childItem.id} className="relative">
|
|
401
|
+
{hasGrandChildren ? (
|
|
402
|
+
<HoverCard openDelay={200} closeDelay={100}>
|
|
403
|
+
<HoverCardTrigger asChild>
|
|
404
|
+
<button
|
|
405
|
+
onClick={() => handleItemClick(childItem)}
|
|
406
|
+
disabled={childItem.disabled}
|
|
407
|
+
className={cn(
|
|
408
|
+
"w-full flex items-center justify-between gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
|
|
409
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
410
|
+
isChildActive && "bg-primary/10 text-primary font-medium",
|
|
411
|
+
childItem.disabled && "opacity-50 cursor-not-allowed"
|
|
412
|
+
)}
|
|
413
|
+
>
|
|
414
|
+
<div className="flex items-center gap-2">
|
|
415
|
+
{childItem.icon && (
|
|
416
|
+
<span className="flex-shrink-0">
|
|
417
|
+
{childItem.icon}
|
|
418
|
+
</span>
|
|
419
|
+
)}
|
|
420
|
+
<span className="truncate">{childItem.title}</span>
|
|
421
|
+
</div>
|
|
422
|
+
<ChevronRight className="h-3 w-3 flex-shrink-0" />
|
|
423
|
+
</button>
|
|
424
|
+
</HoverCardTrigger>
|
|
425
|
+
<HoverCardContent
|
|
426
|
+
side="right"
|
|
427
|
+
align="start"
|
|
428
|
+
sideOffset={10}
|
|
429
|
+
className={cn(
|
|
430
|
+
"p-2",
|
|
431
|
+
glassmorphism && "bg-background/95 backdrop-blur-sm"
|
|
432
|
+
)}
|
|
433
|
+
>
|
|
434
|
+
<div className="space-y-0.5">
|
|
435
|
+
{childItem.items?.map(grandChild => {
|
|
436
|
+
const isGrandChildActive = grandChild.href === activePath
|
|
437
|
+
return (
|
|
438
|
+
<button
|
|
439
|
+
key={grandChild.id}
|
|
440
|
+
onClick={() => handleItemClick(grandChild)}
|
|
441
|
+
disabled={grandChild.disabled}
|
|
442
|
+
className={cn(
|
|
443
|
+
"w-full flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
|
|
444
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
445
|
+
isGrandChildActive && "bg-primary/10 text-primary font-medium",
|
|
446
|
+
grandChild.disabled && "opacity-50 cursor-not-allowed"
|
|
447
|
+
)}
|
|
448
|
+
>
|
|
449
|
+
{grandChild.icon && (
|
|
450
|
+
<span className="flex-shrink-0">
|
|
451
|
+
{grandChild.icon}
|
|
452
|
+
</span>
|
|
453
|
+
)}
|
|
454
|
+
<span className="truncate">{grandChild.title}</span>
|
|
455
|
+
{grandChild.badge && (
|
|
456
|
+
<Badge
|
|
457
|
+
variant={grandChild.badgeVariant || 'secondary'}
|
|
458
|
+
className="ml-auto flex-shrink-0"
|
|
459
|
+
>
|
|
460
|
+
{grandChild.badge}
|
|
461
|
+
</Badge>
|
|
462
|
+
)}
|
|
463
|
+
</button>
|
|
464
|
+
)
|
|
465
|
+
})}
|
|
466
|
+
</div>
|
|
467
|
+
</HoverCardContent>
|
|
468
|
+
</HoverCard>
|
|
469
|
+
) : (
|
|
470
|
+
<button
|
|
471
|
+
onClick={() => handleItemClick(childItem)}
|
|
472
|
+
disabled={childItem.disabled}
|
|
473
|
+
className={cn(
|
|
474
|
+
"w-full flex items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors",
|
|
475
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
476
|
+
isChildActive && "bg-primary/10 text-primary font-medium",
|
|
477
|
+
childItem.disabled && "opacity-50 cursor-not-allowed"
|
|
478
|
+
)}
|
|
479
|
+
>
|
|
480
|
+
{childItem.icon && (
|
|
481
|
+
<span className="flex-shrink-0">
|
|
482
|
+
{childItem.icon}
|
|
483
|
+
</span>
|
|
484
|
+
)}
|
|
485
|
+
<span className="truncate">{childItem.title}</span>
|
|
486
|
+
{childItem.badge && (
|
|
487
|
+
<Badge
|
|
488
|
+
variant={childItem.badgeVariant || 'secondary'}
|
|
489
|
+
className="ml-auto flex-shrink-0"
|
|
490
|
+
>
|
|
491
|
+
{childItem.badge}
|
|
492
|
+
</Badge>
|
|
493
|
+
)}
|
|
494
|
+
</button>
|
|
495
|
+
)}
|
|
496
|
+
</div>
|
|
497
|
+
)
|
|
498
|
+
})}
|
|
499
|
+
</div>
|
|
500
|
+
)}
|
|
501
|
+
</div>
|
|
502
|
+
)
|
|
503
|
+
}, [activePath, glassmorphism, handleItemClick])
|
|
504
|
+
|
|
379
505
|
const renderItem = useCallback((item: SidebarItem, depth = 0, filteredChildren?: SidebarItem[]) => {
|
|
380
506
|
const isActive = item.href === activePath
|
|
381
507
|
const isPinned = pinnedItems.includes(item.id)
|
|
382
508
|
const hasChildren = item.items && item.items.length > 0
|
|
383
509
|
const isExpanded = expandedSections.includes(item.id)
|
|
510
|
+
const shouldShowHoverMenu = collapsed && !isMobile && depth === 0 && (hasChildren || item.title)
|
|
384
511
|
|
|
385
512
|
const ItemWrapper = item.tooltip && !collapsed ? TooltipTrigger : React.Fragment
|
|
386
513
|
|
|
@@ -443,6 +570,38 @@ export function Sidebar({
|
|
|
443
570
|
</button>
|
|
444
571
|
)
|
|
445
572
|
|
|
573
|
+
// Collapsed durumda hover menü göster
|
|
574
|
+
if (shouldShowHoverMenu) {
|
|
575
|
+
return (
|
|
576
|
+
<div key={item.id}>
|
|
577
|
+
<HoverCard openDelay={200} closeDelay={100}>
|
|
578
|
+
<HoverCardTrigger asChild>
|
|
579
|
+
{itemContent}
|
|
580
|
+
</HoverCardTrigger>
|
|
581
|
+
<HoverCardContent
|
|
582
|
+
side="right"
|
|
583
|
+
align="start"
|
|
584
|
+
sideOffset={10}
|
|
585
|
+
className={cn(
|
|
586
|
+
"p-0 w-auto",
|
|
587
|
+
glassmorphism && "bg-background/95 backdrop-blur-sm",
|
|
588
|
+
"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"
|
|
589
|
+
)}
|
|
590
|
+
>
|
|
591
|
+
<motion.div
|
|
592
|
+
initial={{ opacity: 0, x: -10 }}
|
|
593
|
+
animate={{ opacity: 1, x: 0 }}
|
|
594
|
+
exit={{ opacity: 0, x: -10 }}
|
|
595
|
+
transition={{ duration: 0.15 }}
|
|
596
|
+
>
|
|
597
|
+
{renderCollapsedHoverContent(item)}
|
|
598
|
+
</motion.div>
|
|
599
|
+
</HoverCardContent>
|
|
600
|
+
</HoverCard>
|
|
601
|
+
</div>
|
|
602
|
+
)
|
|
603
|
+
}
|
|
604
|
+
|
|
446
605
|
return (
|
|
447
606
|
<div key={item.id}>
|
|
448
607
|
{item.tooltip && !collapsed ? (
|
|
@@ -481,7 +640,7 @@ export function Sidebar({
|
|
|
481
640
|
)}
|
|
482
641
|
</div>
|
|
483
642
|
)
|
|
484
|
-
}, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection])
|
|
643
|
+
}, [activePath, pinnedItems, expandedSections, collapsed, customStyles, handleItemClick, toggleSection, isMobile, glassmorphism, renderCollapsedHoverContent])
|
|
485
644
|
|
|
486
645
|
|
|
487
646
|
|
|
@@ -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 {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
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
|
|
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
|
-
|
|
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
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
385
|
+
Calendar.displayName = "Calendar";
|
|
386
|
+
|
|
387
|
+
export { Calendar };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card"
|
|
5
|
+
|
|
6
|
+
import { cn } from "../../lib/utils"
|
|
7
|
+
|
|
8
|
+
const HoverCard = HoverCardPrimitive.Root
|
|
9
|
+
|
|
10
|
+
const HoverCardTrigger = HoverCardPrimitive.Trigger
|
|
11
|
+
|
|
12
|
+
const HoverCardContent = React.forwardRef<
|
|
13
|
+
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
|
14
|
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
|
15
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
16
|
+
<HoverCardPrimitive.Content
|
|
17
|
+
ref={ref}
|
|
18
|
+
align={align}
|
|
19
|
+
sideOffset={sideOffset}
|
|
20
|
+
className={cn(
|
|
21
|
+
"z-50 w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
22
|
+
className
|
|
23
|
+
)}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
))
|
|
27
|
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName
|
|
28
|
+
|
|
29
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent }
|
|
@@ -166,4 +166,8 @@ export {
|
|
|
166
166
|
Tooltip, TooltipTrigger, TooltipContent, TooltipProvider
|
|
167
167
|
} from './tooltip';
|
|
168
168
|
|
|
169
|
+
export {
|
|
170
|
+
HoverCard, HoverCardTrigger, HoverCardContent
|
|
171
|
+
} from './hover-card';
|
|
172
|
+
|
|
169
173
|
// Note: Micro-interaction components are exported from their individual directories
|