@@ -3,7 +3,7 @@ import React from 'react';
33import { Calendar as CalendarIcon } from '@gravity-ui/icons' ;
44import { Button , Icon , Popup , useFocusWithin } from '@gravity-ui/uikit' ;
55
6- import { Calendar } from '../Calendar' ;
6+ import { Calendar , type CalendarProps } from '../Calendar' ;
77import { DateField } from '../DateField' ;
88import { getButtonSizeForInput } from '../utils/getButtonSizeForInput' ;
99
@@ -16,8 +16,9 @@ interface DesktopCalendarProps {
1616 anchorRef : React . RefObject < HTMLElement > ;
1717 props : DatePickerProps ;
1818 state : DatePickerState ;
19+ renderCalendar ?: ( props : CalendarProps ) => React . ReactNode ;
1920}
20- export function DesktopCalendar ( { anchorRef, props, state} : DesktopCalendarProps ) {
21+ export function DesktopCalendar ( { anchorRef, props, state, renderCalendar } : DesktopCalendarProps ) {
2122 const { focusWithinProps} = useFocusWithin ( {
2223 isDisabled : ! state . isOpen ,
2324 onBlurWithin : ( ) => {
@@ -29,6 +30,22 @@ export function DesktopCalendar({anchorRef, props, state}: DesktopCalendarProps)
2930 return null ;
3031 }
3132
33+ const calendarProps : CalendarProps = {
34+ autoFocus : true ,
35+ size : props . size === 's' ? 'm' : props . size ,
36+ disabled : props . disabled ,
37+ readOnly : props . readOnly ,
38+ onUpdate : ( d ) => {
39+ state . setDateValue ( d ) ;
40+ } ,
41+ defaultFocusedValue : state . dateValue ?? undefined ,
42+ value : state . dateValue ,
43+ minValue : props . minValue ,
44+ maxValue : props . maxValue ,
45+ isDateUnavailable : props . isDateUnavailable ,
46+ timeZone : props . timeZone ,
47+ } ;
48+
3249 return (
3350 < Popup
3451 open = { state . isOpen }
@@ -38,23 +55,12 @@ export function DesktopCalendar({anchorRef, props, state}: DesktopCalendarProps)
3855 } }
3956 restoreFocus
4057 >
41- < div { ...focusWithinProps } className = { b ( 'popup-content' ) } >
42- < Calendar
43- // eslint-disable-next-line jsx-a11y/no-autofocus
44- autoFocus
45- size = { props . size === 's' ? 'm' : props . size }
46- disabled = { props . disabled }
47- readOnly = { props . readOnly }
48- onUpdate = { ( d ) => {
49- state . setDateValue ( d ) ;
50- } }
51- defaultFocusedValue = { state . dateValue ?? undefined }
52- value = { state . dateValue }
53- minValue = { props . minValue }
54- maxValue = { props . maxValue }
55- isDateUnavailable = { props . isDateUnavailable }
56- timeZone = { props . timeZone }
57- />
58+ < div { ...focusWithinProps } className = { b ( 'popup-content' ) } tabIndex = { - 1 } >
59+ { typeof renderCalendar === 'function' ? (
60+ renderCalendar ( calendarProps )
61+ ) : (
62+ < Calendar { ...calendarProps } />
63+ ) }
5864 { state . hasTime && (
5965 < div className = { b ( 'time-field-wrapper' ) } >
6066 < DateField
0 commit comments