( props: AriaToggleButtonOptions<ElementType>, state: ToggleState, ref: RefObject<any> )
| 106 | * states or modes. |
| 107 | */ |
| 108 | export function useToggleButton( |
| 109 | props: AriaToggleButtonOptions<ElementType>, |
| 110 | state: ToggleState, |
| 111 | ref: RefObject<any> |
| 112 | ): ToggleButtonAria<HTMLAttributes<any>> { |
| 113 | const {isSelected} = state; |
| 114 | const {isPressed, buttonProps} = useButton( |
| 115 | { |
| 116 | ...props, |
| 117 | onPress: chain(state.toggle, props.onPress) |
| 118 | }, |
| 119 | ref |
| 120 | ); |
| 121 | |
| 122 | return { |
| 123 | isPressed, |
| 124 | isSelected, |
| 125 | isDisabled: props.isDisabled || false, |
| 126 | buttonProps: mergeProps(buttonProps, { |
| 127 | 'aria-pressed': isSelected |
| 128 | }) |
| 129 | }; |
| 130 | } |
no test coverage detected