@@ -12,12 +12,14 @@ import {
1212 DayPickerProps ,
1313 DropdownProps ,
1414} from 'react-day-picker' ;
15- import Skeleton from 'react-loading-skeleton ' ;
15+ import { clsx } from 'clsx ' ;
1616
1717import { Flex } from '../flex/flex' ;
1818import { Select } from '../select' ;
1919import { Tooltip } from '../tooltip' ;
20+ import { Skeleton } from '../skeleton' ;
2021import styles from './calendar.module.css' ;
22+ import { IconButton } from '../icon-button' ;
2123
2224interface OnDropdownOpen {
2325 onDropdownOpen ?: VoidFunction ;
@@ -36,12 +38,17 @@ export type CalendarProps = DayPickerProps &
3638
3739const root = cva ( styles . calendarRoot ) ;
3840
41+ interface DropDownComponentProps extends DropdownProps , OnDropdownOpen {
42+ disabled ?: boolean ;
43+ }
44+
3945function DropDown ( {
4046 options = [ ] ,
4147 value,
4248 onChange,
4349 onDropdownOpen,
44- } : DropdownProps & OnDropdownOpen ) {
50+ disabled,
51+ } : DropDownComponentProps ) {
4552 const [ open , setOpen ] = useState ( false ) ;
4653
4754 useEffect ( ( ) => {
@@ -69,6 +76,7 @@ function DropDown({
6976 stopPropagation = { true }
7077 size = "small"
7178 variant = "text"
79+ disabled = { disabled }
7280 >
7381 < Select . Value />
7482 </ Select . Trigger >
@@ -119,13 +127,30 @@ export const Calendar = function ({
119127 timeZone = { timeZone }
120128 components = { {
121129 Chevron : ( props ) => {
122- if ( props . orientation === 'left' ) {
123- return < ChevronLeftIcon { ...props } /> ;
124- }
125- return < ChevronRightIcon { ...props } /> ;
130+ const icon = props . orientation === 'left' ? (
131+ < ChevronLeftIcon />
132+ ) : (
133+ < ChevronRightIcon />
134+ ) ;
135+
136+ return (
137+ < IconButton
138+ { ...props }
139+ disabled = { loadingData }
140+ className = { clsx ( props . className , loadingData && styles . disabled ) }
141+ size = { 3 }
142+ aria-label = { props . orientation === 'left' ? 'Previous month' : 'Next month' }
143+ >
144+ { icon }
145+ </ IconButton >
146+ ) ;
126147 } ,
127148 Dropdown : ( props : DropdownProps ) => (
128- < DropDown { ...props } onDropdownOpen = { onDropdownOpen } />
149+ < DropDown
150+ { ...props }
151+ onDropdownOpen = { onDropdownOpen }
152+ disabled = { loadingData }
153+ />
129154 ) ,
130155 DayButton : ( props ) => {
131156 const { day, ...buttonProps } = props ;
@@ -144,12 +169,10 @@ export const Calendar = function ({
144169 MonthGrid : ( props ) =>
145170 loadingData ? (
146171 < Skeleton
147- count = { 6 }
148- height = "12px "
172+ count = { 5 }
173+ height = "18px "
149174 width = "252px"
150- style = { { marginBottom : "var(--rs-space-5)" } }
151- highlightColor = "var(--rs-color-background-base-primary)"
152- baseColor = "var(--rs-color-background-base-primary-hover)"
175+ style = { { marginBottom : "var(--rs-space-6)" } }
153176 />
154177 ) : (
155178 < table { ...props } />
0 commit comments