@react-aria/button
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -11,3 +11,4 @@ var { | ||
filterDOMProps, | ||
mergeProps | ||
mergeProps, | ||
chain | ||
} = require("@react-aria/utils"); | ||
@@ -39,2 +40,3 @@ | ||
target, | ||
rel, | ||
type = 'button' | ||
@@ -52,3 +54,4 @@ } = props; | ||
disabled: elementType === 'input' ? isDisabled : undefined, | ||
'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled | ||
'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled, | ||
rel: elementType === 'a' ? rel : undefined | ||
}; | ||
@@ -97,2 +100,22 @@ } | ||
exports.useButton = useButton; | ||
function useToggleButton(props, state, ref) { | ||
const { | ||
isSelected | ||
} = state; | ||
const { | ||
isPressed, | ||
buttonProps | ||
} = useButton(_babelRuntimeHelpersExtends({}, props, { | ||
onPress: chain(state.toggle, props.onPress) | ||
}), ref); | ||
return { | ||
isPressed, | ||
buttonProps: mergeProps(buttonProps, { | ||
'aria-pressed': isSelected | ||
}) | ||
}; | ||
} | ||
exports.useToggleButton = useToggleButton; | ||
//# sourceMappingURL=main.js.map |
import { usePress } from "@react-aria/interactions"; | ||
import { useFocusable } from "@react-aria/focus"; | ||
import { filterDOMProps, mergeProps } from "@react-aria/utils"; | ||
import { filterDOMProps, mergeProps, chain } from "@react-aria/utils"; | ||
import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends"; | ||
@@ -24,2 +24,3 @@ | ||
target, | ||
rel, | ||
type = 'button' | ||
@@ -37,3 +38,4 @@ } = props; | ||
disabled: elementType === 'input' ? isDisabled : undefined, | ||
'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled | ||
'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled, | ||
rel: elementType === 'a' ? rel : undefined | ||
}; | ||
@@ -80,2 +82,19 @@ } | ||
} | ||
export function useToggleButton(props, state, ref) { | ||
const { | ||
isSelected | ||
} = state; | ||
const { | ||
isPressed, | ||
buttonProps | ||
} = useButton(_babelRuntimeHelpersEsmExtends({}, props, { | ||
onPress: chain(state.toggle, props.onPress) | ||
}), ref); | ||
return { | ||
isPressed, | ||
buttonProps: mergeProps(buttonProps, { | ||
'aria-pressed': isSelected | ||
}) | ||
}; | ||
} | ||
//# sourceMappingURL=module.js.map |
@@ -1,4 +0,5 @@ | ||
import { AriaButtonProps } from "@react-types/button"; | ||
import { AriaButtonProps, AriaToggleButtonProps } from "@react-types/button"; | ||
import { ButtonHTMLAttributes, RefObject } from "react"; | ||
interface ButtonAria { | ||
import { ToggleState } from "@react-stately/toggle"; | ||
export interface ButtonAria { | ||
/** Props for the button element. */ | ||
@@ -16,3 +17,4 @@ buttonProps: ButtonHTMLAttributes<HTMLButtonElement>; | ||
export function useButton(props: AriaButtonProps, ref: RefObject<HTMLElement>): ButtonAria; | ||
export function useToggleButton(props: AriaToggleButtonProps, state: ToggleState, ref: RefObject<HTMLElement>): ButtonAria; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@react-aria/button", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Spectrum UI components in React", | ||
@@ -21,7 +21,8 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-aria/focus": "^3.1.0", | ||
"@react-aria/focus": "^3.2.0", | ||
"@react-aria/i18n": "^3.1.0", | ||
"@react-aria/interactions": "^3.1.0", | ||
"@react-aria/utils": "^3.1.0", | ||
"@react-types/button": "^3.1.0" | ||
"@react-aria/interactions": "^3.2.0", | ||
"@react-aria/utils": "^3.2.0", | ||
"@react-stately/toggle": "^3.2.0", | ||
"@react-types/button": "^3.2.0" | ||
}, | ||
@@ -34,3 +35,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "211099972fe75ee581892efd01a7f89dfb9cdf69" | ||
"gitHead": "661f0f2e3b8648a75aae83043267954700059fe0" | ||
} |
@@ -14,1 +14,2 @@ /* | ||
export * from './useButton'; | ||
export * from './useToggleButton'; |
@@ -20,3 +20,4 @@ /* | ||
interface ButtonAria { | ||
export interface ButtonAria { | ||
/** Props for the button element. */ | ||
@@ -46,2 +47,3 @@ buttonProps: ButtonHTMLAttributes<HTMLButtonElement>, | ||
target, | ||
rel, | ||
type = 'button' | ||
@@ -58,3 +60,4 @@ } = props; | ||
disabled: elementType === 'input' ? isDisabled : undefined, | ||
'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled | ||
'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled, | ||
rel: elementType === 'a' ? rel : undefined | ||
}; | ||
@@ -61,0 +64,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40904
12
349
8
+ Added@react-stately/toggle@^3.2.0
+ Added@react-stately/toggle@3.7.8(transitive)
+ Added@react-types/checkbox@3.8.4(transitive)
Updated@react-aria/focus@^3.2.0
Updated@react-aria/utils@^3.2.0
Updated@react-types/button@^3.2.0