@react-aria/toggle
Advanced tools
Comparing version 3.0.0-nightly-8ab4f20de-240913 to 3.0.0-nightly-90b6fd4f7-250221
var $2jyrz$reactariautils = require("@react-aria/utils"); | ||
var $2jyrz$reactariafocus = require("@react-aria/focus"); | ||
var $2jyrz$reactariainteractions = require("@react-aria/interactions"); | ||
@@ -23,3 +22,2 @@ | ||
function $ee1b638d33c90dcc$export$cbe85ee05b554577(props, state, ref) { | ||
@@ -36,14 +34,11 @@ let { isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, value: value, name: name, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, validationState: validationState = 'valid', isInvalid: isInvalid } = props; | ||
if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility'); | ||
// This handles focusing the input on pointer down, which Safari does not do by default. | ||
// Handle press state for keyboard interactions and cases where labelProps is not used. | ||
let { pressProps: pressProps, isPressed: isPressed } = (0, $2jyrz$reactariainteractions.usePress)({ | ||
isDisabled: isDisabled | ||
}); | ||
// iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves. | ||
// Handle press state on the label. | ||
let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $2jyrz$reactariainteractions.usePress)({ | ||
isDisabled: isDisabled || isReadOnly, | ||
onPress () { | ||
state.toggle(); | ||
} | ||
isDisabled: isDisabled || isReadOnly | ||
}); | ||
let { focusableProps: focusableProps } = (0, $2jyrz$reactariafocus.useFocusable)(props, ref); | ||
let { focusableProps: focusableProps } = (0, $2jyrz$reactariainteractions.useFocusable)(props, ref); | ||
let interactions = (0, $2jyrz$reactariautils.mergeProps)(pressProps, focusableProps); | ||
@@ -55,5 +50,3 @@ let domProps = (0, $2jyrz$reactariautils.filterDOMProps)(props, { | ||
return { | ||
labelProps: (0, $2jyrz$reactariautils.mergeProps)(labelProps, { | ||
onClick: (e)=>e.preventDefault() | ||
}), | ||
labelProps: labelProps, | ||
inputProps: (0, $2jyrz$reactariautils.mergeProps)(domProps, { | ||
@@ -60,0 +53,0 @@ 'aria-invalid': isInvalid || validationState === 'invalid' || undefined, |
import {mergeProps as $bvdLj$mergeProps, filterDOMProps as $bvdLj$filterDOMProps, useFormReset as $bvdLj$useFormReset} from "@react-aria/utils"; | ||
import {useFocusable as $bvdLj$useFocusable} from "@react-aria/focus"; | ||
import {usePress as $bvdLj$usePress} from "@react-aria/interactions"; | ||
import {usePress as $bvdLj$usePress, useFocusable as $bvdLj$useFocusable} from "@react-aria/interactions"; | ||
@@ -17,3 +16,2 @@ /* | ||
function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) { | ||
@@ -30,12 +28,9 @@ let { isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, value: value, name: name, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, validationState: validationState = 'valid', isInvalid: isInvalid } = props; | ||
if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility'); | ||
// This handles focusing the input on pointer down, which Safari does not do by default. | ||
// Handle press state for keyboard interactions and cases where labelProps is not used. | ||
let { pressProps: pressProps, isPressed: isPressed } = (0, $bvdLj$usePress)({ | ||
isDisabled: isDisabled | ||
}); | ||
// iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves. | ||
// Handle press state on the label. | ||
let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $bvdLj$usePress)({ | ||
isDisabled: isDisabled || isReadOnly, | ||
onPress () { | ||
state.toggle(); | ||
} | ||
isDisabled: isDisabled || isReadOnly | ||
}); | ||
@@ -49,5 +44,3 @@ let { focusableProps: focusableProps } = (0, $bvdLj$useFocusable)(props, ref); | ||
return { | ||
labelProps: (0, $bvdLj$mergeProps)(labelProps, { | ||
onClick: (e)=>e.preventDefault() | ||
}), | ||
labelProps: labelProps, | ||
inputProps: (0, $bvdLj$mergeProps)(domProps, { | ||
@@ -54,0 +47,0 @@ 'aria-invalid': isInvalid || validationState === 'invalid' || undefined, |
{ | ||
"name": "@react-aria/toggle", | ||
"version": "3.0.0-nightly-8ab4f20de-240913", | ||
"version": "3.0.0-nightly-90b6fd4f7-250221", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,17 +25,16 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-aria/focus": "^3.0.0-nightly-8ab4f20de-240913", | ||
"@react-aria/interactions": "^3.0.0-nightly-8ab4f20de-240913", | ||
"@react-aria/utils": "^3.0.0-nightly-8ab4f20de-240913", | ||
"@react-stately/toggle": "^3.0.0-nightly-8ab4f20de-240913", | ||
"@react-types/checkbox": "^3.0.0-nightly-8ab4f20de-240913", | ||
"@react-types/shared": "^3.0.0-nightly-8ab4f20de-240913", | ||
"@react-aria/interactions": "3.0.0-nightly-90b6fd4f7-250221", | ||
"@react-aria/utils": "3.0.0-nightly-90b6fd4f7-250221", | ||
"@react-stately/toggle": "3.0.0-nightly-90b6fd4f7-250221", | ||
"@react-types/checkbox": "3.0.0-nightly-90b6fd4f7-250221", | ||
"@react-types/shared": "3.0.0-nightly-90b6fd4f7-250221", | ||
"@swc/helpers": "^0.5.0" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", | ||
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"stableVersion": "3.10.7" | ||
} | ||
} |
@@ -18,4 +18,3 @@ /* | ||
import {ToggleState} from '@react-stately/toggle'; | ||
import {useFocusable} from '@react-aria/focus'; | ||
import {usePress} from '@react-aria/interactions'; | ||
import {useFocusable, usePress} from '@react-aria/interactions'; | ||
@@ -68,3 +67,3 @@ export interface ToggleAria { | ||
// This handles focusing the input on pointer down, which Safari does not do by default. | ||
// Handle press state for keyboard interactions and cases where labelProps is not used. | ||
let {pressProps, isPressed} = usePress({ | ||
@@ -74,8 +73,5 @@ isDisabled | ||
// iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves. | ||
// Handle press state on the label. | ||
let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({ | ||
isDisabled: isDisabled || isReadOnly, | ||
onPress() { | ||
state.toggle(); | ||
} | ||
isDisabled: isDisabled || isReadOnly | ||
}); | ||
@@ -90,3 +86,3 @@ | ||
return { | ||
labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}), | ||
labelProps, | ||
inputProps: mergeProps(domProps, { | ||
@@ -93,0 +89,0 @@ 'aria-invalid': isInvalid || validationState === 'invalid' || undefined, |
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
Sorry, the diff of this file is not supported yet
33200
369
+ Added@react-aria/interactions@3.0.0-nightly-90b6fd4f7-250221(transitive)
+ Added@react-aria/ssr@3.0.0-nightly-90b6fd4f7-250221(transitive)
+ Added@react-aria/utils@3.0.0-nightly-90b6fd4f7-250221(transitive)
+ Added@react-stately/flags@3.0.0-nightly-90b6fd4f7-250221(transitive)
+ Added@react-stately/toggle@3.0.0-nightly-90b6fd4f7-250221(transitive)
+ Added@react-stately/utils@3.0.0-nightly-90b6fd4f7-250221(transitive)
+ Added@react-types/checkbox@3.0.0-nightly-90b6fd4f7-250221(transitive)
+ Added@react-types/shared@3.0.0-nightly-90b6fd4f7-250221(transitive)
- Removed@react-aria/focus@3.20.0(transitive)
- Removed@react-aria/interactions@3.24.0(transitive)
- Removed@react-aria/ssr@3.9.7(transitive)
- Removed@react-aria/utils@3.28.0(transitive)
- Removed@react-stately/flags@3.1.0(transitive)
- Removed@react-stately/toggle@3.8.2(transitive)
- Removed@react-stately/utils@3.10.5(transitive)
- Removed@react-types/checkbox@3.9.2(transitive)
- Removed@react-types/shared@3.28.0(transitive)
Updated@react-aria/interactions@3.0.0-nightly-90b6fd4f7-250221