@@ -107,9 +107,7 @@ export default class PowerCalendarRangeDaysComponent extends Component<PowerCale
107107 let day = firstDay ( this . currentCenter , this . localeStartOfWeek ) ;
108108 const days : PowerCalendarDay [ ] = [ ] ;
109109 while ( isBefore ( day , theLastDay ) ) {
110- days . push (
111- this . buildDay ( day , today , this . args . calendar ) ,
112- ) ;
110+ days . push ( this . buildDay ( day , today , this . args . calendar ) ) ;
113111 day = add ( day , 1 , 'day' ) ;
114112 }
115113 return days ;
@@ -152,8 +150,15 @@ export default class PowerCalendarRangeDaysComponent extends Component<PowerCale
152150
153151 if ( ! day || ! day ?. isCurrentMonth ) {
154152 if ( this . args . calendar . actions . moveCenter ) {
155- if ( e . key === 'ArrowUp' || e . key === 'ArrowRight' || e . key === 'ArrowDown' || e . key === 'ArrowLeft' ) {
156- const currentDay = this . days . find ( x => x . id === this . focusedId ) ?. date ;
153+ if (
154+ e . key === 'ArrowUp' ||
155+ e . key === 'ArrowRight' ||
156+ e . key === 'ArrowDown' ||
157+ e . key === 'ArrowLeft'
158+ ) {
159+ const currentDay = this . days . find (
160+ ( x ) => x . id === this . focusedId ,
161+ ) ?. date ;
157162
158163 if ( currentDay ) {
159164 let date = currentDay ;
@@ -196,9 +201,20 @@ export default class PowerCalendarRangeDaysComponent extends Component<PowerCale
196201 async handleClick ( e : MouseEvent ) {
197202 const selectedDay = handleClick ( e , this . days , this . args . calendar ) ;
198203
199- if ( this . lastKeyDownWasSpace && selectedDay && ( this . args . calendar . minRange ?? 0 ) > 0 && ! this . args . calendar . selected ?. end ) {
200- const focusDay = add ( selectedDay . date , ( this . args . calendar . minRange ?? 0 ) / DAY_IN_MS , 'day' ) ;
201- const dayInCurrentCalendar = this . days . some ( x => x . id === formatDate ( focusDay , 'YYYY-MM-DD' ) && x . isCurrentMonth ) ;
204+ if (
205+ this . lastKeyDownWasSpace &&
206+ selectedDay &&
207+ ( this . args . calendar . minRange ?? 0 ) > 0 &&
208+ ! this . args . calendar . selected ?. end
209+ ) {
210+ const focusDay = add (
211+ selectedDay . date ,
212+ ( this . args . calendar . minRange ?? 0 ) / DAY_IN_MS ,
213+ 'day' ,
214+ ) ;
215+ const dayInCurrentCalendar = this . days . some (
216+ ( x ) => x . id === formatDate ( focusDay , 'YYYY-MM-DD' ) && x . isCurrentMonth ,
217+ ) ;
202218
203219 await this . focusDay ( e , focusDay , dayInCurrentCalendar ? 0 : 1 ) ;
204220 }
@@ -215,11 +231,7 @@ export default class PowerCalendarRangeDaysComponent extends Component<PowerCale
215231 this . didSetup = true ;
216232
217233 if ( this . args . isDatePicker ) {
218- scheduleOnce (
219- 'afterRender' ,
220- this ,
221- this . initialFocus . bind ( this ) ,
222- ) ;
234+ scheduleOnce ( 'afterRender' , this , this . initialFocus . bind ( this ) ) ;
223235 }
224236 } ,
225237 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -228,20 +240,20 @@ export default class PowerCalendarRangeDaysComponent extends Component<PowerCale
228240 ) ;
229241
230242 initialFocus ( ) {
231- const activeDay = this . days . find ( x => x . isSelected && ! x . isDisabled ) ;
243+ const activeDay = this . days . find ( ( x ) => x . isSelected && ! x . isDisabled ) ;
232244
233245 if ( activeDay ) {
234246 this . focusedId = activeDay . id ;
235247 } else {
236- const todayDay = this . days . find ( x => x . isToday && ! x . isDisabled ) ;
248+ const todayDay = this . days . find ( ( x ) => x . isToday && ! x . isDisabled ) ;
237249 if ( todayDay ) {
238250 this . focusedId = todayDay . id ?? '' ;
239251 } else {
240- const firstSelectableDay = this . days . find ( x => ! x . isDisabled ) ;
252+ const firstSelectableDay = this . days . find ( ( x ) => ! x . isDisabled ) ;
241253 if ( firstSelectableDay ) {
242254 this . focusedId = firstSelectableDay . id ?? '' ;
243255 } else {
244- this . focusedId = this . days . find ( x => ! x . isCurrentMonth ) ?. id ?? '' ;
256+ this . focusedId = this . days . find ( ( x ) => ! x . isCurrentMonth ) ?. id ?? '' ;
245257 }
246258 }
247259 }
@@ -250,12 +262,25 @@ export default class PowerCalendarRangeDaysComponent extends Component<PowerCale
250262 }
251263
252264 async focusDay ( e : MouseEvent | KeyboardEvent , date : Date , step : number = 0 ) {
253- if ( dayIsDisabled ( date , this . args . calendar , this . args . minDate , this . args . maxDate , this . args . disabledDates ) ) {
265+ if (
266+ dayIsDisabled (
267+ date ,
268+ this . args . calendar ,
269+ this . args . minDate ,
270+ this . args . maxDate ,
271+ this . args . disabledDates ,
272+ )
273+ ) {
254274 return ;
255275 }
256276
257277 if ( this . args . calendar . actions . moveCenter && step !== 0 ) {
258- await this . args . calendar . actions . moveCenter ( step , 'month' , this . args . calendar , e ) ;
278+ await this . args . calendar . actions . moveCenter (
279+ step ,
280+ 'month' ,
281+ this . args . calendar ,
282+ e ,
283+ ) ;
259284 }
260285
261286 this . focusedId = formatDate ( date , 'YYYY-MM-DD' ) ;
0 commit comments