@@ -93,6 +93,7 @@ type Props = BaseProps & {
93
93
currentMonth ?: Date ;
94
94
activeDates ?: DateStatus [ ] ;
95
95
filledWeeks ?: boolean ;
96
+ _today ?: Date ;
96
97
onClickDate ?: ( selectedValue : Date ) => void ;
97
98
/**
98
99
* @description 日付が無効かどうかを判定する関数です。無効な日付はクリック不可になります。
@@ -108,6 +109,7 @@ const Calendar: FC<Props> = ({
108
109
currentMonth = new Date ( ) ,
109
110
activeDates,
110
111
filledWeeks,
112
+ _today,
111
113
onClickDate,
112
114
disabledDate,
113
115
} ) => {
@@ -126,6 +128,18 @@ const Calendar: FC<Props> = ({
126
128
} ) ;
127
129
}
128
130
131
+ function getItemDate ( item : CalendarDataItem ) {
132
+ return new Date (
133
+ currentMonth . getFullYear ( ) ,
134
+ currentMonth . getMonth ( ) ,
135
+ Number ( item . label )
136
+ ) ;
137
+ }
138
+
139
+ function getIsToday ( a : Date ) {
140
+ return a . toDateString ( ) === ( _today || new Date ( ) ) . toDateString ( ) ;
141
+ }
142
+
129
143
function getItemStyleState (
130
144
item : CalendarDataItem ,
131
145
dateStatus ?: DateStatus
@@ -139,13 +153,7 @@ const Calendar: FC<Props> = ({
139
153
if ( item . isOutOfCurrentMonth ) {
140
154
return ;
141
155
}
142
- onClickDate ?.(
143
- new Date (
144
- currentMonth . getFullYear ( ) ,
145
- currentMonth . getMonth ( ) ,
146
- Number ( item . label )
147
- )
148
- ) ;
156
+ onClickDate ?.( getItemDate ( item ) ) ;
149
157
}
150
158
const calendarItems = calendarData . map ( ( weekDateItems ) => {
151
159
return weekDateItems . map ( ( item ) => {
@@ -214,6 +222,7 @@ const Calendar: FC<Props> = ({
214
222
const item = adjacent . current . item ;
215
223
const itemStyle = adjacent . current . itemStyle ;
216
224
const activeDateStatus = adjacent . current . activeDateStatus ;
225
+ const isToday = getIsToday ( getItemDate ( item ) ) ;
217
226
return (
218
227
< td
219
228
key = { `${ item . label } -${ col } ` }
@@ -244,7 +253,14 @@ const Calendar: FC<Props> = ({
244
253
adjacent . current . itemStyle === "primary"
245
254
) }
246
255
>
247
- < div className = { styles . calendarItemInteractiveStyle } >
256
+ < div
257
+ className = { clsx (
258
+ styles . calendarItemInteractiveStyle ,
259
+ ! item . isOutOfCurrentMonth &&
260
+ isToday &&
261
+ styles . calendarItemInteractiveTodayStyle
262
+ ) }
263
+ >
248
264
{ item . label }
249
265
</ div >
250
266
</ div >
0 commit comments