Skip to content

Commit e6c52df

Browse files
authored
fix(date-fns) - revert to previous version (#965)
* fix(date-fns) - revert to previous version * carets
1 parent 96c1f33 commit e6c52df

4 files changed

Lines changed: 72 additions & 65 deletions

File tree

example/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 20 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
"class-variance-authority": "0.7.1",
104104
"clsx": "2.1.1",
105105
"cmdk": "1.1.1",
106-
"date-fns": "4.1.0",
106+
"date-fns": "3.6.0",
107107
"dompurify": "3.4.0",
108108
"fast-deep-equal": "3.1.3",
109109
"lodash.capitalize": "4.2.1",
@@ -114,7 +114,7 @@
114114
"lodash.omitby": "4.6.0",
115115
"lucide-react": "1.8.0",
116116
"postcss": "8.5.10",
117-
"react-day-picker": "9.14.0",
117+
"react-day-picker": "8.10.1",
118118
"react-flagpack": "2.0.6",
119119
"react-hook-form": "7.72.1",
120120
"tailwind-merge": "3.5.0",

src/components/ui/calendar.tsx

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,71 @@ import { ChevronLeft, ChevronRight } from 'lucide-react';
33
import { DayPicker } from 'react-day-picker';
44

55
import { cn } from '@/src/lib/utils';
6-
7-
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
6+
import { buttonVariants } from '@/src/components/ui/button';
87

98
function Calendar({
109
className,
1110
classNames,
1211
showOutsideDays = true,
1312
...props
14-
}: CalendarProps) {
13+
}: React.ComponentProps<typeof DayPicker>) {
1514
return (
1615
<DayPicker
1716
showOutsideDays={showOutsideDays}
1817
className={cn('p-3', className)}
1918
classNames={{
20-
months: 'flex flex-col sm:flex-row gap-4',
21-
month: 'flex flex-col gap-y-4',
22-
month_caption: 'flex h-8 w-full items-center justify-center relative',
23-
caption_label: 'font-medium text-sm mt-1',
24-
nav: 'flex items-center justify-between absolute left-0 right-0 z-10',
25-
month_grid: 'w-full border-collapse mt-1',
26-
weekdays: 'flex',
27-
weekday:
28-
'text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]',
29-
week: 'flex w-full mt-2',
30-
day: 'h-9 w-9 text-center text-sm p-0 relative',
19+
months: 'flex flex-col sm:flex-row gap-2',
20+
month: 'flex flex-col gap-4',
21+
caption: 'flex justify-center pt-1 relative items-center w-full',
22+
caption_label: 'text-sm font-medium',
23+
nav: 'flex items-center gap-1',
24+
nav_button: cn(
25+
buttonVariants({ variant: 'outline' }),
26+
'size-7 bg-transparent p-0 opacity-50 hover:opacity-100',
27+
),
28+
nav_button_previous: 'absolute left-1',
29+
nav_button_next: 'absolute right-1',
30+
table: 'w-full border-collapse space-x-1',
31+
head_row: 'flex',
32+
head_cell:
33+
'text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]',
34+
row: 'flex w-full mt-2',
35+
cell: cn(
36+
'relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-range-end)]:rounded-r-md',
37+
props.mode === 'range'
38+
? '[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md'
39+
: '[&:has([aria-selected])]:rounded-md',
40+
),
41+
day: cn(
42+
buttonVariants({ variant: 'ghost' }),
43+
'size-8 p-0 font-normal aria-selected:opacity-100',
44+
),
45+
day_range_start:
46+
'day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground',
47+
day_range_end:
48+
'day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground',
49+
day_selected:
50+
'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground',
51+
day_today: 'bg-accent text-accent-foreground',
52+
day_outside:
53+
'day-outside text-muted-foreground aria-selected:text-muted-foreground',
54+
day_disabled: 'text-muted-foreground opacity-50',
55+
day_range_middle:
56+
'aria-selected:bg-accent aria-selected:text-accent-foreground',
57+
day_hidden: 'invisible',
3158
...classNames,
3259
}}
3360
components={{
34-
Chevron: ({ orientation, ...props }) => {
35-
if (orientation === 'left') {
36-
return <ChevronLeft {...props} />;
37-
}
38-
return <ChevronRight {...props} />;
39-
},
61+
IconLeft: ({ className, ...props }) => (
62+
<ChevronLeft className={cn('size-4', className)} {...props} />
63+
),
64+
IconRight: ({ className, ...props }) => (
65+
<ChevronRight className={cn('size-4', className)} {...props} />
66+
),
4067
}}
4168
{...props}
4269
/>
4370
);
4471
}
45-
Calendar.displayName = 'Calendar';
4672

4773
export { Calendar };

0 commit comments

Comments
 (0)