@@ -87,14 +87,24 @@ export interface DatePickerProps<T extends DateValue> extends Omit<AriaDatePicke
87
87
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.
88
88
* @default 'react-aria-DatePicker'
89
89
*/
90
- className ?: ClassNameOrFunction < DatePickerRenderProps >
90
+ className ?: ClassNameOrFunction < DatePickerRenderProps > ,
91
+ /**
92
+ * Whether the trigger remains pressed when the overlay is open.
93
+ * @default true
94
+ */
95
+ isTriggerPressedWhenOpen ?: boolean
91
96
}
92
97
export interface DateRangePickerProps < T extends DateValue > extends Omit < AriaDateRangePickerProps < T > , 'label' | 'description' | 'errorMessage' | 'validationState' | 'validationBehavior' > , Pick < DateRangePickerStateOptions < T > , 'shouldCloseOnSelect' > , RACValidation , RenderProps < DateRangePickerRenderProps > , SlotProps , GlobalDOMAttributes < HTMLDivElement > {
93
98
/**
94
99
* The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state.
95
100
* @default 'react-aria-DateRangePicker'
96
101
*/
97
- className ?: ClassNameOrFunction < DateRangePickerRenderProps >
102
+ className ?: ClassNameOrFunction < DateRangePickerRenderProps > ,
103
+ /**
104
+ * Whether the trigger remains pressed when the overlay is open.
105
+ * @default true
106
+ */
107
+ isTriggerPressedWhenOpen ?: boolean
98
108
}
99
109
100
110
export const DatePickerContext = createContext < ContextValue < DatePickerProps < any > , HTMLDivElement > > ( null ) ;
@@ -112,6 +122,7 @@ export const DatePicker = /*#__PURE__*/ (forwardRef as forwardRefType)(function
112
122
[ props , ref ] = useContextProps ( props , ref , DatePickerContext ) ;
113
123
let { validationBehavior : formValidationBehavior } = useSlottedContext ( FormContext ) || { } ;
114
124
let validationBehavior = props . validationBehavior ?? formValidationBehavior ?? 'native' ;
125
+ let { isTriggerPressedWhenOpen = true } = props ;
115
126
let state = useDatePickerState ( {
116
127
...props ,
117
128
validationBehavior
@@ -174,7 +185,7 @@ export const DatePicker = /*#__PURE__*/ (forwardRef as forwardRefType)(function
174
185
[ DatePickerStateContext , state ] ,
175
186
[ GroupContext , { ...groupProps , ref : groupRef , isInvalid : state . isInvalid } ] ,
176
187
[ DateFieldContext , fieldProps ] ,
177
- [ ButtonContext , { ...buttonProps , isPressed : state . isOpen } ] ,
188
+ [ ButtonContext , { ...buttonProps , isPressed : isTriggerPressedWhenOpen && state . isOpen } ] ,
178
189
[ LabelContext , { ...labelProps , ref : labelRef , elementType : 'span' } ] ,
179
190
[ CalendarContext , calendarProps ] ,
180
191
[ OverlayTriggerStateContext , state ] ,
@@ -221,6 +232,7 @@ export const DateRangePicker = /*#__PURE__*/ (forwardRef as forwardRefType)(func
221
232
[ props , ref ] = useContextProps ( props , ref , DateRangePickerContext ) ;
222
233
let { validationBehavior : formValidationBehavior } = useSlottedContext ( FormContext ) || { } ;
223
234
let validationBehavior = props . validationBehavior ?? formValidationBehavior ?? 'native' ;
235
+ let { isTriggerPressedWhenOpen = true } = props ;
224
236
let state = useDateRangePickerState ( {
225
237
...props ,
226
238
validationBehavior
@@ -283,7 +295,7 @@ export const DateRangePicker = /*#__PURE__*/ (forwardRef as forwardRefType)(func
283
295
values = { [
284
296
[ DateRangePickerStateContext , state ] ,
285
297
[ GroupContext , { ...groupProps , ref : groupRef , isInvalid : state . isInvalid } ] ,
286
- [ ButtonContext , { ...buttonProps , isPressed : state . isOpen } ] ,
298
+ [ ButtonContext , { ...buttonProps , isPressed : isTriggerPressedWhenOpen && state . isOpen } ] ,
287
299
[ LabelContext , { ...labelProps , ref : labelRef , elementType : 'span' } ] ,
288
300
[ RangeCalendarContext , calendarProps ] ,
289
301
[ OverlayTriggerStateContext , state ] ,
0 commit comments