Skip to content

Commit 4cbeeaf

Browse files
authoredMar 6, 2023
Code changes for React Aria Components (adobe#4150)
1 parent 05be974 commit 4cbeeaf

File tree

77 files changed

+400
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+400
-217
lines changed
 

‎packages/@react-aria/calendar/src/useCalendarCell.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export function useCalendarCell(props: AriaCalendarCellProps, state: CalendarSta
172172
// again to trigger onPressStart. Cancel presses immediately when the pointer exits.
173173
shouldCancelOnPointerExit: 'anchorDate' in state && !!state.anchorDate,
174174
preventFocusOnPress: true,
175-
isDisabled: !isSelectable,
175+
isDisabled: !isSelectable || state.isReadOnly,
176176
onPressStart(e) {
177177
if (state.isReadOnly) {
178178
state.setFocusedDate(date);

‎packages/@react-aria/checkbox/src/useCheckbox.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ import {useToggle} from '@react-aria/toggle';
1717

1818
export interface CheckboxAria {
1919
/** Props for the input element. */
20-
inputProps: InputHTMLAttributes<HTMLInputElement>
20+
inputProps: InputHTMLAttributes<HTMLInputElement>,
21+
/** Whether the checkbox is selected. */
22+
isSelected: boolean,
23+
/** Whether the checkbox is in a pressed state. */
24+
isPressed: boolean,
25+
/** Whether the checkbox is disabled. */
26+
isDisabled: boolean,
27+
/** Whether the checkbox is read only. */
28+
isReadOnly: boolean
2129
}
2230

2331
/**
@@ -29,8 +37,7 @@ export interface CheckboxAria {
2937
* @param inputRef - A ref for the HTML input element.
3038
*/
3139
export function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {
32-
let {inputProps} = useToggle(props, state, inputRef);
33-
let {isSelected} = state;
40+
let {inputProps, isSelected, isPressed, isDisabled, isReadOnly} = useToggle(props, state, inputRef);
3441

3542
let {isIndeterminate} = props;
3643
useEffect(() => {
@@ -45,6 +52,10 @@ export function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputR
4552
inputProps: {
4653
...inputProps,
4754
checked: isSelected
48-
}
55+
},
56+
isSelected,
57+
isPressed,
58+
isDisabled,
59+
isReadOnly
4960
};
5061
}

0 commit comments

Comments
 (0)
Failed to load comments.