@@ -12,12 +12,14 @@ import {
12
12
DayPickerProps ,
13
13
DropdownProps ,
14
14
} from 'react-day-picker' ;
15
- import Skeleton from 'react-loading-skeleton ' ;
15
+ import { clsx } from 'clsx ' ;
16
16
17
17
import { Flex } from '../flex/flex' ;
18
18
import { Select } from '../select' ;
19
19
import { Tooltip } from '../tooltip' ;
20
+ import { Skeleton } from '../skeleton' ;
20
21
import styles from './calendar.module.css' ;
22
+ import { IconButton } from '../icon-button' ;
21
23
22
24
interface OnDropdownOpen {
23
25
onDropdownOpen ?: VoidFunction ;
@@ -36,12 +38,17 @@ export type CalendarProps = DayPickerProps &
36
38
37
39
const root = cva ( styles . calendarRoot ) ;
38
40
41
+ interface DropDownComponentProps extends DropdownProps , OnDropdownOpen {
42
+ disabled ?: boolean ;
43
+ }
44
+
39
45
function DropDown ( {
40
46
options = [ ] ,
41
47
value,
42
48
onChange,
43
49
onDropdownOpen,
44
- } : DropdownProps & OnDropdownOpen ) {
50
+ disabled,
51
+ } : DropDownComponentProps ) {
45
52
const [ open , setOpen ] = useState ( false ) ;
46
53
47
54
useEffect ( ( ) => {
@@ -69,6 +76,7 @@ function DropDown({
69
76
stopPropagation = { true }
70
77
size = "small"
71
78
variant = "text"
79
+ disabled = { disabled }
72
80
>
73
81
< Select . Value />
74
82
</ Select . Trigger >
@@ -119,13 +127,30 @@ export const Calendar = function ({
119
127
timeZone = { timeZone }
120
128
components = { {
121
129
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
+ ) ;
126
147
} ,
127
148
Dropdown : ( props : DropdownProps ) => (
128
- < DropDown { ...props } onDropdownOpen = { onDropdownOpen } />
149
+ < DropDown
150
+ { ...props }
151
+ onDropdownOpen = { onDropdownOpen }
152
+ disabled = { loadingData }
153
+ />
129
154
) ,
130
155
DayButton : ( props ) => {
131
156
const { day, ...buttonProps } = props ;
@@ -144,12 +169,10 @@ export const Calendar = function ({
144
169
MonthGrid : ( props ) =>
145
170
loadingData ? (
146
171
< Skeleton
147
- count = { 6 }
148
- height = "12px "
172
+ count = { 5 }
173
+ height = "18px "
149
174
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)" } }
153
176
/>
154
177
) : (
155
178
< table { ...props } />
0 commit comments