@react-aria/button
Advanced tools
Comparing version 3.0.0-rc.1 to 3.0.0-rc.2
@@ -1,12 +0,12 @@ | ||
var _babelRuntimeHelpersEsmObjectSpread = $parcel$interopDefault(require("@babel/runtime/helpers/esm/objectSpread2")); | ||
var _babelRuntimeHelpersObjectSpread = $parcel$interopDefault(require("@babel/runtime/helpers/objectSpread2")); | ||
var _temp = require("@react-aria/utils"); | ||
var mergeProps = require("@react-aria/utils").mergeProps; | ||
var chain = _temp.chain; | ||
var mergeProps = _temp.mergeProps; | ||
var _temp = require("@react-aria/interactions"); | ||
var useDOMPropsResponder = _temp.useDOMPropsResponder; | ||
var usePress = _temp.usePress; | ||
var useFocusable = require("@react-aria/focus").useFocusable; | ||
var usePress = require("@react-aria/interactions").usePress; | ||
function $parcel$interopDefault(a) { | ||
@@ -26,2 +26,3 @@ return a && a.__esModule ? a.default : a; | ||
href = props.href, | ||
target = props.target, | ||
tabIndex = props.tabIndex, | ||
@@ -40,4 +41,7 @@ isSelected = props.isSelected, | ||
tabIndex: isDisabled ? undefined : tabIndex || 0, | ||
'aria-disabled': isDisabled || undefined, | ||
href: elementType === 'a' && isDisabled ? undefined : href | ||
href: elementType === 'a' && isDisabled ? undefined : href, | ||
target: elementType === 'a' ? target : undefined, | ||
type: elementType === 'input' ? type : undefined, | ||
disabled: elementType === 'input' ? isDisabled : undefined, | ||
'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled | ||
}; | ||
@@ -47,9 +51,4 @@ } | ||
var _usePress = usePress({ | ||
// Safari does not focus buttons automatically when interacting with them, so do it manually | ||
onPressStart: chain(onPressStart, function (e) { | ||
return e.target.focus(); | ||
}), | ||
onPressEnd: chain(onPressEnd, function (e) { | ||
return e.target.focus(); | ||
}), | ||
onPressStart: onPressStart, | ||
onPressEnd: onPressEnd, | ||
onPressChange: onPressChange, | ||
@@ -63,2 +62,5 @@ onPress: onPress, | ||
var _useDOMPropsResponder = useDOMPropsResponder(ref), | ||
contextProps = _useDOMPropsResponder.contextProps; | ||
var _useFocusable = useFocusable(props, ref), | ||
@@ -68,8 +70,10 @@ focusableProps = _useFocusable.focusableProps; | ||
var handlers = mergeProps(pressProps, focusableProps); | ||
var interactions = mergeProps(contextProps, handlers); | ||
return { | ||
isPressed: isPressed, | ||
// Used to indicate press state for visual | ||
buttonProps: mergeProps(handlers, _babelRuntimeHelpersEsmObjectSpread({ | ||
buttonProps: mergeProps(interactions, _babelRuntimeHelpersObjectSpread({ | ||
'aria-haspopup': ariaHasPopup, | ||
'aria-expanded': ariaExpanded || ariaHasPopup && isSelected, | ||
'aria-checked': isSelected, | ||
'aria-invalid': validationState === 'invalid' ? true : null, | ||
@@ -76,0 +80,0 @@ disabled: isDisabled, |
import _babelRuntimeHelpersEsmObjectSpread from "@babel/runtime/helpers/esm/objectSpread2"; | ||
import { chain, mergeProps } from "@react-aria/utils"; | ||
import { mergeProps } from "@react-aria/utils"; | ||
import { useDOMPropsResponder, usePress } from "@react-aria/interactions"; | ||
import { useFocusable } from "@react-aria/focus"; | ||
import { usePress } from "@react-aria/interactions"; | ||
export function useButton(props, ref) { | ||
@@ -16,2 +16,3 @@ let { | ||
href, | ||
target, | ||
tabIndex, | ||
@@ -30,4 +31,7 @@ isSelected, | ||
tabIndex: isDisabled ? undefined : tabIndex || 0, | ||
'aria-disabled': isDisabled || undefined, | ||
href: elementType === 'a' && isDisabled ? undefined : href | ||
href: elementType === 'a' && isDisabled ? undefined : href, | ||
target: elementType === 'a' ? target : undefined, | ||
type: elementType === 'input' ? type : undefined, | ||
disabled: elementType === 'input' ? isDisabled : undefined, | ||
'aria-disabled': !isDisabled || elementType === 'input' ? undefined : isDisabled | ||
}; | ||
@@ -40,5 +44,4 @@ } | ||
} = usePress({ | ||
// Safari does not focus buttons automatically when interacting with them, so do it manually | ||
onPressStart: chain(onPressStart, e => e.target.focus()), | ||
onPressEnd: chain(onPressEnd, e => e.target.focus()), | ||
onPressStart, | ||
onPressEnd, | ||
onPressChange, | ||
@@ -50,11 +53,16 @@ onPress, | ||
let { | ||
contextProps | ||
} = useDOMPropsResponder(ref); | ||
let { | ||
focusableProps | ||
} = useFocusable(props, ref); | ||
let handlers = mergeProps(pressProps, focusableProps); | ||
let interactions = mergeProps(contextProps, handlers); | ||
return { | ||
isPressed, | ||
// Used to indicate press state for visual | ||
buttonProps: mergeProps(handlers, _babelRuntimeHelpersEsmObjectSpread({ | ||
buttonProps: mergeProps(interactions, _babelRuntimeHelpersEsmObjectSpread({ | ||
'aria-haspopup': ariaHasPopup, | ||
'aria-expanded': ariaExpanded || ariaHasPopup && isSelected, | ||
'aria-checked': isSelected, | ||
'aria-invalid': validationState === 'invalid' ? true : null, | ||
@@ -61,0 +69,0 @@ disabled: isDisabled, |
{ | ||
"name": "@react-aria/button", | ||
"version": "3.0.0-rc.1", | ||
"version": "3.0.0-rc.2", | ||
"description": "Spectrum UI components in React", | ||
@@ -20,10 +20,10 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-aria/focus": "^3.0.0-rc.1", | ||
"@react-aria/interactions": "^3.0.0-rc.1", | ||
"@react-aria/utils": "^3.0.0-rc.1", | ||
"@react-types/button": "^3.0.0-rc.1" | ||
"@react-aria/focus": "^3.0.0-rc.2", | ||
"@react-aria/i18n": "^3.0.0-rc.2", | ||
"@react-aria/interactions": "^3.0.0-rc.2", | ||
"@react-aria/utils": "^3.0.0-rc.2", | ||
"@react-types/button": "^3.0.0-rc.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.0", | ||
"react-dom": "^16.8.0" | ||
"react": "^16.8.0" | ||
}, | ||
@@ -33,3 +33,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "5a9784f0bb6c25af7422215efb31ef72caeb9600" | ||
"gitHead": "207e6ee9076905c96638a7f81a367758872e1410" | ||
} |
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
18727
7
163
+ Added@react-aria/i18n@^3.0.0-rc.2
+ Added@formatjs/ecma402-abstract@2.2.3(transitive)
+ Added@formatjs/fast-memoize@2.2.3(transitive)
+ Added@formatjs/icu-messageformat-parser@2.9.3(transitive)
+ Added@formatjs/icu-skeleton-parser@1.8.7(transitive)
+ Added@formatjs/intl-localematcher@0.5.7(transitive)
+ Added@internationalized/date@3.5.6(transitive)
+ Added@internationalized/message@3.1.5(transitive)
+ Added@internationalized/number@3.5.4(transitive)
+ Added@internationalized/string@3.2.4(transitive)
+ Added@react-aria/i18n@3.12.3(transitive)
+ Addedintl-messageformat@10.7.6(transitive)
- Removedreact-dom@16.14.0(transitive)
- Removedscheduler@0.19.1(transitive)