@react-aria/toggle
Advanced tools
Comparing version
@@ -23,3 +23,3 @@ var $2jyrz$reactariautils = require("@react-aria/utils"); | ||
function $ee1b638d33c90dcc$export$cbe85ee05b554577(props, state, ref) { | ||
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; | ||
let { isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, value: value, name: name, form: form, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, validationState: validationState = 'valid', isInvalid: isInvalid, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressChange: onPressChange, onPress: onPress, onPressUp: onPressUp, onClick: onClick } = props; | ||
let onChange = (e)=>{ | ||
@@ -36,2 +36,8 @@ // since we spread props on label, onChange will end up there as well as in here. | ||
let { pressProps: pressProps, isPressed: isPressed } = (0, $2jyrz$reactariainteractions.usePress)({ | ||
onPressStart: onPressStart, | ||
onPressEnd: onPressEnd, | ||
onPressChange: onPressChange, | ||
onPress: onPress, | ||
onPressUp: onPressUp, | ||
onClick: onClick, | ||
isDisabled: isDisabled | ||
@@ -41,4 +47,10 @@ }); | ||
let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $2jyrz$reactariainteractions.usePress)({ | ||
onPress () { | ||
onPressStart: onPressStart, | ||
onPressEnd: onPressEnd, | ||
onPressChange: onPressChange, | ||
onPressUp: onPressUp, | ||
onClick: onClick, | ||
onPress (e) { | ||
var _ref_current; | ||
onPress === null || onPress === void 0 ? void 0 : onPress(e); | ||
state.toggle(); | ||
@@ -54,3 +66,3 @@ (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus(); | ||
}); | ||
(0, $2jyrz$reactariautils.useFormReset)(ref, state.isSelected, state.setSelected); | ||
(0, $2jyrz$reactariautils.useFormReset)(ref, state.defaultSelected, state.setSelected); | ||
return { | ||
@@ -71,2 +83,3 @@ labelProps: (0, $2jyrz$reactariautils.mergeProps)(labelProps, { | ||
name: name, | ||
form: form, | ||
type: 'checkbox', | ||
@@ -73,0 +86,0 @@ ...interactions |
@@ -17,3 +17,3 @@ import {mergeProps as $bvdLj$mergeProps, filterDOMProps as $bvdLj$filterDOMProps, useFormReset as $bvdLj$useFormReset} from "@react-aria/utils"; | ||
function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) { | ||
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; | ||
let { isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, value: value, name: name, form: form, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, validationState: validationState = 'valid', isInvalid: isInvalid, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressChange: onPressChange, onPress: onPress, onPressUp: onPressUp, onClick: onClick } = props; | ||
let onChange = (e)=>{ | ||
@@ -30,2 +30,8 @@ // since we spread props on label, onChange will end up there as well as in here. | ||
let { pressProps: pressProps, isPressed: isPressed } = (0, $bvdLj$usePress)({ | ||
onPressStart: onPressStart, | ||
onPressEnd: onPressEnd, | ||
onPressChange: onPressChange, | ||
onPress: onPress, | ||
onPressUp: onPressUp, | ||
onClick: onClick, | ||
isDisabled: isDisabled | ||
@@ -35,4 +41,10 @@ }); | ||
let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $bvdLj$usePress)({ | ||
onPress () { | ||
onPressStart: onPressStart, | ||
onPressEnd: onPressEnd, | ||
onPressChange: onPressChange, | ||
onPressUp: onPressUp, | ||
onClick: onClick, | ||
onPress (e) { | ||
var _ref_current; | ||
onPress === null || onPress === void 0 ? void 0 : onPress(e); | ||
state.toggle(); | ||
@@ -48,3 +60,3 @@ (_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus(); | ||
}); | ||
(0, $bvdLj$useFormReset)(ref, state.isSelected, state.setSelected); | ||
(0, $bvdLj$useFormReset)(ref, state.defaultSelected, state.setSelected); | ||
return { | ||
@@ -65,2 +77,3 @@ labelProps: (0, $bvdLj$mergeProps)(labelProps, { | ||
name: name, | ||
form: form, | ||
type: 'checkbox', | ||
@@ -67,0 +80,0 @@ ...interactions |
{ | ||
"name": "@react-aria/toggle", | ||
"version": "3.0.0-nightly-c1fd8af79-250512", | ||
"version": "3.0.0-nightly-c22d474da-250729", | ||
"description": "Spectrum UI components in React", | ||
@@ -9,3 +9,7 @@ "license": "Apache-2.0", | ||
"exports": { | ||
"types": "./dist/types.d.ts", | ||
"source": "./src/index.ts", | ||
"types": [ | ||
"./dist/types.d.ts", | ||
"./src/index.ts" | ||
], | ||
"import": "./dist/import.mjs", | ||
@@ -26,7 +30,7 @@ "require": "./dist/main.js" | ||
"dependencies": { | ||
"@react-aria/interactions": "3.0.0-nightly-c1fd8af79-250512", | ||
"@react-aria/utils": "3.0.0-nightly-c1fd8af79-250512", | ||
"@react-stately/toggle": "3.0.0-nightly-c1fd8af79-250512", | ||
"@react-types/checkbox": "3.0.0-nightly-c1fd8af79-250512", | ||
"@react-types/shared": "3.0.0-nightly-c1fd8af79-250512", | ||
"@react-aria/interactions": "3.0.0-nightly-c22d474da-250729", | ||
"@react-aria/utils": "3.0.0-nightly-c22d474da-250729", | ||
"@react-stately/toggle": "3.0.0-nightly-c22d474da-250729", | ||
"@react-types/checkbox": "3.0.0-nightly-c22d474da-250729", | ||
"@react-types/shared": "3.0.0-nightly-c22d474da-250729", | ||
"@swc/helpers": "^0.5.0" | ||
@@ -33,0 +37,0 @@ }, |
@@ -46,2 +46,3 @@ /* | ||
name, | ||
form, | ||
children, | ||
@@ -51,3 +52,9 @@ 'aria-label': ariaLabel, | ||
validationState = 'valid', | ||
isInvalid | ||
isInvalid, | ||
onPressStart, | ||
onPressEnd, | ||
onPressChange, | ||
onPress, | ||
onPressUp, | ||
onClick | ||
} = props; | ||
@@ -70,2 +77,8 @@ | ||
let {pressProps, isPressed} = usePress({ | ||
onPressStart, | ||
onPressEnd, | ||
onPressChange, | ||
onPress, | ||
onPressUp, | ||
onClick, | ||
isDisabled | ||
@@ -76,3 +89,9 @@ }); | ||
let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({ | ||
onPress() { | ||
onPressStart, | ||
onPressEnd, | ||
onPressChange, | ||
onPressUp, | ||
onClick, | ||
onPress(e) { | ||
onPress?.(e); | ||
state.toggle(); | ||
@@ -88,3 +107,3 @@ ref.current?.focus(); | ||
useFormReset(ref, state.isSelected, state.setSelected); | ||
useFormReset(ref, state.defaultSelected, state.setSelected); | ||
@@ -102,2 +121,3 @@ return { | ||
name, | ||
form, | ||
type: 'checkbox', | ||
@@ -104,0 +124,0 @@ ...interactions |
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
38287
9.22%456
15.74%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated