Skip to content

Commit fc51c2a

Browse files
authored
fix: upgrade react-day-picker and update calendar component (#129)
1 parent 0de2a16 commit fc51c2a

3 files changed

Lines changed: 46 additions & 37 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"js-cookie": "^3.0.5",
4545
"lucide-react": "^0.488.0",
4646
"react": "^19.1.0",
47-
"react-day-picker": "8.10.1",
47+
"react-day-picker": "9.6.6",
4848
"react-dom": "^19.1.0",
4949
"react-hook-form": "^7.55.0",
5050
"react-top-loading-bar": "^3.0.2",

pnpm-lock.yaml

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

src/components/ui/calendar.tsx

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as React from 'react'
2-
import { ChevronLeft, ChevronRight } from 'lucide-react'
32
import { DayPicker } from 'react-day-picker'
43
import { cn } from '@/lib/utils'
54
import { buttonVariants } from '@/components/ui/button'
@@ -14,56 +13,54 @@ function Calendar({
1413
<DayPicker
1514
showOutsideDays={showOutsideDays}
1615
className={cn('p-3', className)}
16+
mode='single'
1717
classNames={{
1818
months: 'flex flex-col sm:flex-row gap-2',
1919
month: 'flex flex-col gap-4',
20-
caption: 'flex justify-center pt-1 relative items-center w-full',
20+
month_caption: 'flex justify-center pt-1 relative items-center w-full',
2121
caption_label: 'text-sm font-medium',
2222
nav: 'flex items-center gap-1',
23-
nav_button: cn(
23+
button_previous: cn(
2424
buttonVariants({ variant: 'outline' }),
25-
'size-7 bg-transparent p-0 opacity-50 hover:opacity-100'
25+
'size-7 bg-transparent p-0 opacity-50 hover:opacity-100 z-10',
26+
'absolute left-4 top-3'
2627
),
27-
nav_button_previous: 'absolute left-1',
28-
nav_button_next: 'absolute right-1',
29-
table: 'w-full border-collapse space-x-1',
30-
head_row: 'flex',
31-
head_cell:
28+
button_next: cn(
29+
buttonVariants({ variant: 'outline' }),
30+
'size-7 bg-transparent p-0 opacity-50 hover:opacity-100 z-10',
31+
'absolute right-4 top-3'
32+
),
33+
month_grid: 'w-full border-collapse space-x-1',
34+
weekdays: 'flex',
35+
weekday:
3236
'text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]',
33-
row: 'flex w-full mt-2',
34-
cell: cn(
37+
week: 'flex w-full mt-2',
38+
day: cn(
3539
'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',
3640
props.mode === 'range'
3741
? '[&: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'
38-
: '[&:has([aria-selected])]:rounded-md'
42+
: 'aria-selected:rounded-md [&[aria-selected="true"]>button]:hover:bg-foreground [&[aria-selected="true"]>button]:hover:text-background/85'
3943
),
40-
day: cn(
44+
day_button: cn(
4145
buttonVariants({ variant: 'ghost' }),
4246
'size-8 p-0 font-normal aria-selected:opacity-100'
4347
),
44-
day_range_start:
48+
day_selected: 'opacity-100 bg-yellow-500',
49+
range_start:
4550
'day-range-start aria-selected:bg-primary aria-selected:text-primary-foreground',
46-
day_range_end:
51+
range_end:
4752
'day-range-end aria-selected:bg-primary aria-selected:text-primary-foreground',
48-
day_selected:
53+
selected:
4954
'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground',
50-
day_today: 'bg-accent text-accent-foreground',
51-
day_outside:
55+
today: 'bg-accent text-accent-foreground rounded-md',
56+
outside:
5257
'day-outside text-muted-foreground aria-selected:text-muted-foreground',
53-
day_disabled: 'text-muted-foreground opacity-50',
54-
day_range_middle:
58+
disabled: 'text-muted-foreground opacity-50',
59+
range_middle:
5560
'aria-selected:bg-accent aria-selected:text-accent-foreground',
56-
day_hidden: 'invisible',
61+
hidden: 'invisible',
5762
...classNames,
5863
}}
59-
components={{
60-
IconLeft: ({ className, ...props }) => (
61-
<ChevronLeft className={cn('size-4', className)} {...props} />
62-
),
63-
IconRight: ({ className, ...props }) => (
64-
<ChevronRight className={cn('size-4', className)} {...props} />
65-
),
66-
}}
6764
{...props}
6865
/>
6966
)

0 commit comments

Comments
 (0)