@react-aria/checkbox 3.14.8 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types.d.ts.map +1 -1
- package/dist/useCheckbox.main.js +16 -2
- package/dist/useCheckbox.main.js.map +1 -1
- package/dist/useCheckbox.mjs +16 -2
- package/dist/useCheckbox.module.js +16 -2
- package/dist/useCheckbox.module.js.map +1 -1
- package/package.json +13 -13
- package/src/useCheckbox.ts +19 -2
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;
|
|
1
|
+
{"mappings":";;;;;AAsBA,6BAA8B,SAAQ,gBAAgB;IACpD,2CAA2C;IAC3C,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,wCAAwC;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,kDAAkD;IAClD,SAAS,EAAE,OAAO,CAAC;IACnB,wCAAwC;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;GAOG;AACH,4BAA4B,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,YAAY,CAmDpI;AE5ED,kCAAmC,SAAQ,gBAAgB;IACzD,oDAAoD;IACpD,UAAU,EAAE,aAAa,CAAC;IAC1B,6DAA6D;IAC7D,UAAU,EAAE,aAAa,CAAC;IAC1B,gEAAgE;IAChE,gBAAgB,EAAE,aAAa,CAAC;IAChC,kEAAkE;IAClE,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED;;;;;GAKG;AACH,iCAAiC,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,kBAAkB,GAAG,iBAAiB,CA0C5G;AC1DD;;;;;;GAMG;AACH,qCAAqC,KAAK,EAAE,0BAA0B,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,YAAY,CAuE7J;ACpFD,YAAY,EAAC,0BAA0B,EAAE,sBAAsB,EAAE,iBAAiB,EAAC,MAAM,uBAAuB,CAAC","sources":["packages/@react-aria/checkbox/src/packages/@react-aria/checkbox/src/useCheckbox.ts","packages/@react-aria/checkbox/src/packages/@react-aria/checkbox/src/utils.ts","packages/@react-aria/checkbox/src/packages/@react-aria/checkbox/src/useCheckboxGroup.ts","packages/@react-aria/checkbox/src/packages/@react-aria/checkbox/src/useCheckboxGroupItem.ts","packages/@react-aria/checkbox/src/packages/@react-aria/checkbox/src/index.ts","packages/@react-aria/checkbox/src/index.ts"],"sourcesContent":[null,null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport type {CheckboxAria} from './useCheckbox';\nexport {useCheckbox} from './useCheckbox';\nexport {useCheckboxGroup} from './useCheckboxGroup';\nexport {useCheckboxGroupItem} from './useCheckboxGroupItem';\nexport type {AriaCheckboxGroupItemProps, AriaCheckboxGroupProps, AriaCheckboxProps} from '@react-types/checkbox';\nexport type {CheckboxGroupAria} from './useCheckboxGroup';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/dist/useCheckbox.main.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
var $ar5WQ$react = require("react");
|
|
2
|
-
var $ar5WQ$
|
|
2
|
+
var $ar5WQ$reactariautils = require("@react-aria/utils");
|
|
3
3
|
var $ar5WQ$reactstatelyform = require("@react-stately/form");
|
|
4
|
+
var $ar5WQ$reactariaform = require("@react-aria/form");
|
|
5
|
+
var $ar5WQ$reactariainteractions = require("@react-aria/interactions");
|
|
4
6
|
var $ar5WQ$reactariatoggle = require("@react-aria/toggle");
|
|
5
7
|
|
|
6
8
|
|
|
@@ -23,6 +25,8 @@ $parcel$export(module.exports, "useCheckbox", () => $468c774d7db917b7$export$e37
|
|
|
23
25
|
|
|
24
26
|
|
|
25
27
|
|
|
28
|
+
|
|
29
|
+
|
|
26
30
|
function $468c774d7db917b7$export$e375f10ce42261c5(props, state, inputRef) {
|
|
27
31
|
// Create validation state here because it doesn't make sense to add to general useToggleState.
|
|
28
32
|
let validationState = (0, $ar5WQ$reactstatelyform.useFormValidationState)({
|
|
@@ -41,8 +45,18 @@ function $468c774d7db917b7$export$e375f10ce42261c5(props, state, inputRef) {
|
|
|
41
45
|
// https://css-tricks.com/indeterminate-checkboxes/
|
|
42
46
|
if (inputRef.current) inputRef.current.indeterminate = !!isIndeterminate;
|
|
43
47
|
});
|
|
48
|
+
// Reset validation state on label press for checkbox with a hidden input.
|
|
49
|
+
let { pressProps: pressProps } = (0, $ar5WQ$reactariainteractions.usePress)({
|
|
50
|
+
isDisabled: isDisabled || isReadOnly,
|
|
51
|
+
onPress () {
|
|
52
|
+
// @ts-expect-error
|
|
53
|
+
let { [(0, $ar5WQ$reactstatelyform.privateValidationStateProp)]: groupValidationState } = props;
|
|
54
|
+
let { commitValidation: commitValidation } = groupValidationState ? groupValidationState : validationState;
|
|
55
|
+
commitValidation();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
44
58
|
return {
|
|
45
|
-
labelProps: labelProps,
|
|
59
|
+
labelProps: (0, $ar5WQ$reactariautils.mergeProps)(labelProps, pressProps),
|
|
46
60
|
inputProps: {
|
|
47
61
|
...inputProps,
|
|
48
62
|
checked: isSelected,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAmCM,SAAS,0CAAY,KAAwB,EAAE,KAAkB,EAAE,QAA4C;IACpH,+FAA+F;IAC/F,IAAI,kBAAkB,CAAA,GAAA,8CAAqB,EAAE;QAAC,GAAG,KAAK;QAAE,OAAO,MAAM,UAAU;IAAA;IAC/E,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,gBAAgB,iBAAiB;IACxF,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,aAAE,SAAS,cAAE,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,gCAAQ,EAAE;QACtF,GAAG,KAAK;mBACR;IACF,GAAG,OAAO;IAEV,CAAA,GAAA,sCAAgB,EAAE,OAAO,iBAAiB;IAE1C,IAAI,mBAAC,eAAe,cAAE,UAAU,sBAAE,qBAAqB,QAAO,GAAG;IACjE,CAAA,GAAA,sBAAQ,EAAE;QACR,qEAAqE;QACrE,mDAAmD;QACnD,IAAI,SAAS,OAAO,EAClB,SAAS,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC;IAEvC;IAEA,0EAA0E;IAC1E,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,YAAY,cAAc;QAC1B;YACE,mBAAmB;YACnB,IAAI,EAAC,CAAC,CAAA,GAAA,kDAAyB,EAAE,EAAE,oBAAoB,EAAC,GAAG;YAE3D,IAAI,oBAAC,gBAAgB,EAAC,GAAG,uBACvB,uBACA;YAEF;QACF;IACF;IAEA,OAAO;QACL,YAAY,CAAA,GAAA,gCAAS,EAAE,YAAY;QACnC,YAAY;YACV,GAAG,UAAU;YACb,SAAS;YACT,iBAAiB,AAAC,cAAc,uBAAuB,UAAW;YAClE,UAAU,cAAc,uBAAuB;QACjD;oBACA;mBACA;oBACA;oBACA;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/checkbox/src/useCheckbox.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaCheckboxProps} from '@react-types/checkbox';\nimport {InputHTMLAttributes, LabelHTMLAttributes, useEffect} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {privateValidationStateProp, useFormValidationState} from '@react-stately/form';\nimport {RefObject, ValidationResult} from '@react-types/shared';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useFormValidation} from '@react-aria/form';\nimport {usePress} from '@react-aria/interactions';\nimport {useToggle} from '@react-aria/toggle';\n\nexport interface CheckboxAria extends ValidationResult {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the checkbox is selected. */\n isSelected: boolean,\n /** Whether the checkbox is in a pressed state. */\n isPressed: boolean,\n /** Whether the checkbox is disabled. */\n isDisabled: boolean,\n /** Whether the checkbox is read only. */\n isReadOnly: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component.\n * Checkboxes allow users to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useToggleState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement | null>): CheckboxAria {\n // Create validation state here because it doesn't make sense to add to general useToggleState.\n let validationState = useFormValidationState({...props, value: state.isSelected});\n let {isInvalid, validationErrors, validationDetails} = validationState.displayValidation;\n let {labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly} = useToggle({\n ...props,\n isInvalid\n }, state, inputRef);\n\n useFormValidation(props, validationState, inputRef);\n\n let {isIndeterminate, isRequired, validationBehavior = 'aria'} = props;\n useEffect(() => {\n // indeterminate is a property, but it can only be set via javascript\n // https://css-tricks.com/indeterminate-checkboxes/\n if (inputRef.current) {\n inputRef.current.indeterminate = !!isIndeterminate;\n }\n });\n\n // Reset validation state on label press for checkbox with a hidden input.\n let {pressProps} = usePress({\n isDisabled: isDisabled || isReadOnly,\n onPress() {\n // @ts-expect-error\n let {[privateValidationStateProp]: groupValidationState} = props;\n \n let {commitValidation} = groupValidationState\n ? groupValidationState\n : validationState;\n \n commitValidation();\n }\n });\n\n return {\n labelProps: mergeProps(labelProps, pressProps),\n inputProps: {\n ...inputProps,\n checked: isSelected,\n 'aria-required': (isRequired && validationBehavior === 'aria') || undefined,\n required: isRequired && validationBehavior === 'native'\n },\n isSelected,\n isPressed,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useCheckbox.main.js.map"}
|
package/dist/useCheckbox.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {useEffect as $jNP0e$useEffect} from "react";
|
|
2
|
+
import {mergeProps as $jNP0e$mergeProps} from "@react-aria/utils";
|
|
3
|
+
import {useFormValidationState as $jNP0e$useFormValidationState, privateValidationStateProp as $jNP0e$privateValidationStateProp} from "@react-stately/form";
|
|
2
4
|
import {useFormValidation as $jNP0e$useFormValidation} from "@react-aria/form";
|
|
3
|
-
import {
|
|
5
|
+
import {usePress as $jNP0e$usePress} from "@react-aria/interactions";
|
|
4
6
|
import {useToggle as $jNP0e$useToggle} from "@react-aria/toggle";
|
|
5
7
|
|
|
6
8
|
/*
|
|
@@ -17,6 +19,8 @@ import {useToggle as $jNP0e$useToggle} from "@react-aria/toggle";
|
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
|
|
22
|
+
|
|
23
|
+
|
|
20
24
|
function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
|
|
21
25
|
// Create validation state here because it doesn't make sense to add to general useToggleState.
|
|
22
26
|
let validationState = (0, $jNP0e$useFormValidationState)({
|
|
@@ -35,8 +39,18 @@ function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
|
|
|
35
39
|
// https://css-tricks.com/indeterminate-checkboxes/
|
|
36
40
|
if (inputRef.current) inputRef.current.indeterminate = !!isIndeterminate;
|
|
37
41
|
});
|
|
42
|
+
// Reset validation state on label press for checkbox with a hidden input.
|
|
43
|
+
let { pressProps: pressProps } = (0, $jNP0e$usePress)({
|
|
44
|
+
isDisabled: isDisabled || isReadOnly,
|
|
45
|
+
onPress () {
|
|
46
|
+
// @ts-expect-error
|
|
47
|
+
let { [(0, $jNP0e$privateValidationStateProp)]: groupValidationState } = props;
|
|
48
|
+
let { commitValidation: commitValidation } = groupValidationState ? groupValidationState : validationState;
|
|
49
|
+
commitValidation();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
38
52
|
return {
|
|
39
|
-
labelProps: labelProps,
|
|
53
|
+
labelProps: (0, $jNP0e$mergeProps)(labelProps, pressProps),
|
|
40
54
|
inputProps: {
|
|
41
55
|
...inputProps,
|
|
42
56
|
checked: isSelected,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {useEffect as $jNP0e$useEffect} from "react";
|
|
2
|
+
import {mergeProps as $jNP0e$mergeProps} from "@react-aria/utils";
|
|
3
|
+
import {useFormValidationState as $jNP0e$useFormValidationState, privateValidationStateProp as $jNP0e$privateValidationStateProp} from "@react-stately/form";
|
|
2
4
|
import {useFormValidation as $jNP0e$useFormValidation} from "@react-aria/form";
|
|
3
|
-
import {
|
|
5
|
+
import {usePress as $jNP0e$usePress} from "@react-aria/interactions";
|
|
4
6
|
import {useToggle as $jNP0e$useToggle} from "@react-aria/toggle";
|
|
5
7
|
|
|
6
8
|
/*
|
|
@@ -17,6 +19,8 @@ import {useToggle as $jNP0e$useToggle} from "@react-aria/toggle";
|
|
|
17
19
|
|
|
18
20
|
|
|
19
21
|
|
|
22
|
+
|
|
23
|
+
|
|
20
24
|
function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
|
|
21
25
|
// Create validation state here because it doesn't make sense to add to general useToggleState.
|
|
22
26
|
let validationState = (0, $jNP0e$useFormValidationState)({
|
|
@@ -35,8 +39,18 @@ function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
|
|
|
35
39
|
// https://css-tricks.com/indeterminate-checkboxes/
|
|
36
40
|
if (inputRef.current) inputRef.current.indeterminate = !!isIndeterminate;
|
|
37
41
|
});
|
|
42
|
+
// Reset validation state on label press for checkbox with a hidden input.
|
|
43
|
+
let { pressProps: pressProps } = (0, $jNP0e$usePress)({
|
|
44
|
+
isDisabled: isDisabled || isReadOnly,
|
|
45
|
+
onPress () {
|
|
46
|
+
// @ts-expect-error
|
|
47
|
+
let { [(0, $jNP0e$privateValidationStateProp)]: groupValidationState } = props;
|
|
48
|
+
let { commitValidation: commitValidation } = groupValidationState ? groupValidationState : validationState;
|
|
49
|
+
commitValidation();
|
|
50
|
+
}
|
|
51
|
+
});
|
|
38
52
|
return {
|
|
39
|
-
labelProps: labelProps,
|
|
53
|
+
labelProps: (0, $jNP0e$mergeProps)(labelProps, pressProps),
|
|
40
54
|
inputProps: {
|
|
41
55
|
...inputProps,
|
|
42
56
|
checked: isSelected,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAmCM,SAAS,0CAAY,KAAwB,EAAE,KAAkB,EAAE,QAA4C;IACpH,+FAA+F;IAC/F,IAAI,kBAAkB,CAAA,GAAA,6BAAqB,EAAE;QAAC,GAAG,KAAK;QAAE,OAAO,MAAM,UAAU;IAAA;IAC/E,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,gBAAgB,iBAAiB;IACxF,IAAI,cAAC,UAAU,cAAE,UAAU,cAAE,UAAU,aAAE,SAAS,cAAE,UAAU,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,gBAAQ,EAAE;QACtF,GAAG,KAAK;mBACR;IACF,GAAG,OAAO;IAEV,CAAA,GAAA,wBAAgB,EAAE,OAAO,iBAAiB;IAE1C,IAAI,mBAAC,eAAe,cAAE,UAAU,sBAAE,qBAAqB,QAAO,GAAG;IACjE,CAAA,GAAA,gBAAQ,EAAE;QACR,qEAAqE;QACrE,mDAAmD;QACnD,IAAI,SAAS,OAAO,EAClB,SAAS,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC;IAEvC;IAEA,0EAA0E;IAC1E,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,YAAY,cAAc;QAC1B;YACE,mBAAmB;YACnB,IAAI,EAAC,CAAC,CAAA,GAAA,iCAAyB,EAAE,EAAE,oBAAoB,EAAC,GAAG;YAE3D,IAAI,oBAAC,gBAAgB,EAAC,GAAG,uBACvB,uBACA;YAEF;QACF;IACF;IAEA,OAAO;QACL,YAAY,CAAA,GAAA,iBAAS,EAAE,YAAY;QACnC,YAAY;YACV,GAAG,UAAU;YACb,SAAS;YACT,iBAAiB,AAAC,cAAc,uBAAuB,UAAW;YAClE,UAAU,cAAc,uBAAuB;QACjD;oBACA;mBACA;oBACA;oBACA;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/checkbox/src/useCheckbox.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaCheckboxProps} from '@react-types/checkbox';\nimport {InputHTMLAttributes, LabelHTMLAttributes, useEffect} from 'react';\nimport {mergeProps} from '@react-aria/utils';\nimport {privateValidationStateProp, useFormValidationState} from '@react-stately/form';\nimport {RefObject, ValidationResult} from '@react-types/shared';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useFormValidation} from '@react-aria/form';\nimport {usePress} from '@react-aria/interactions';\nimport {useToggle} from '@react-aria/toggle';\n\nexport interface CheckboxAria extends ValidationResult {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the checkbox is selected. */\n isSelected: boolean,\n /** Whether the checkbox is in a pressed state. */\n isPressed: boolean,\n /** Whether the checkbox is disabled. */\n isDisabled: boolean,\n /** Whether the checkbox is read only. */\n isReadOnly: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component.\n * Checkboxes allow users to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useToggleState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement | null>): CheckboxAria {\n // Create validation state here because it doesn't make sense to add to general useToggleState.\n let validationState = useFormValidationState({...props, value: state.isSelected});\n let {isInvalid, validationErrors, validationDetails} = validationState.displayValidation;\n let {labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly} = useToggle({\n ...props,\n isInvalid\n }, state, inputRef);\n\n useFormValidation(props, validationState, inputRef);\n\n let {isIndeterminate, isRequired, validationBehavior = 'aria'} = props;\n useEffect(() => {\n // indeterminate is a property, but it can only be set via javascript\n // https://css-tricks.com/indeterminate-checkboxes/\n if (inputRef.current) {\n inputRef.current.indeterminate = !!isIndeterminate;\n }\n });\n\n // Reset validation state on label press for checkbox with a hidden input.\n let {pressProps} = usePress({\n isDisabled: isDisabled || isReadOnly,\n onPress() {\n // @ts-expect-error\n let {[privateValidationStateProp]: groupValidationState} = props;\n \n let {commitValidation} = groupValidationState\n ? groupValidationState\n : validationState;\n \n commitValidation();\n }\n });\n\n return {\n labelProps: mergeProps(labelProps, pressProps),\n inputProps: {\n ...inputProps,\n checked: isSelected,\n 'aria-required': (isRequired && validationBehavior === 'aria') || undefined,\n required: isRequired && validationBehavior === 'native'\n },\n isSelected,\n isPressed,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useCheckbox.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/checkbox",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,23 +22,23 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/form": "^3.0.
|
|
26
|
-
"@react-aria/interactions": "^3.22.
|
|
27
|
-
"@react-aria/label": "^3.7.
|
|
28
|
-
"@react-aria/toggle": "^3.10.
|
|
29
|
-
"@react-aria/utils": "^3.
|
|
30
|
-
"@react-stately/checkbox": "^3.6.
|
|
31
|
-
"@react-stately/form": "^3.0
|
|
32
|
-
"@react-stately/toggle": "^3.
|
|
33
|
-
"@react-types/checkbox": "^3.
|
|
34
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@react-aria/form": "^3.0.11",
|
|
26
|
+
"@react-aria/interactions": "^3.22.5",
|
|
27
|
+
"@react-aria/label": "^3.7.13",
|
|
28
|
+
"@react-aria/toggle": "^3.10.10",
|
|
29
|
+
"@react-aria/utils": "^3.26.0",
|
|
30
|
+
"@react-stately/checkbox": "^3.6.10",
|
|
31
|
+
"@react-stately/form": "^3.1.0",
|
|
32
|
+
"@react-stately/toggle": "^3.8.0",
|
|
33
|
+
"@react-types/checkbox": "^3.9.0",
|
|
34
|
+
"@react-types/shared": "^3.26.0",
|
|
35
35
|
"@swc/helpers": "^0.5.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
38
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
|
|
44
44
|
}
|
package/src/useCheckbox.ts
CHANGED
|
@@ -12,10 +12,12 @@
|
|
|
12
12
|
|
|
13
13
|
import {AriaCheckboxProps} from '@react-types/checkbox';
|
|
14
14
|
import {InputHTMLAttributes, LabelHTMLAttributes, useEffect} from 'react';
|
|
15
|
+
import {mergeProps} from '@react-aria/utils';
|
|
16
|
+
import {privateValidationStateProp, useFormValidationState} from '@react-stately/form';
|
|
15
17
|
import {RefObject, ValidationResult} from '@react-types/shared';
|
|
16
18
|
import {ToggleState} from '@react-stately/toggle';
|
|
17
19
|
import {useFormValidation} from '@react-aria/form';
|
|
18
|
-
import {
|
|
20
|
+
import {usePress} from '@react-aria/interactions';
|
|
19
21
|
import {useToggle} from '@react-aria/toggle';
|
|
20
22
|
|
|
21
23
|
export interface CheckboxAria extends ValidationResult {
|
|
@@ -61,8 +63,23 @@ export function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputR
|
|
|
61
63
|
}
|
|
62
64
|
});
|
|
63
65
|
|
|
66
|
+
// Reset validation state on label press for checkbox with a hidden input.
|
|
67
|
+
let {pressProps} = usePress({
|
|
68
|
+
isDisabled: isDisabled || isReadOnly,
|
|
69
|
+
onPress() {
|
|
70
|
+
// @ts-expect-error
|
|
71
|
+
let {[privateValidationStateProp]: groupValidationState} = props;
|
|
72
|
+
|
|
73
|
+
let {commitValidation} = groupValidationState
|
|
74
|
+
? groupValidationState
|
|
75
|
+
: validationState;
|
|
76
|
+
|
|
77
|
+
commitValidation();
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
64
81
|
return {
|
|
65
|
-
labelProps,
|
|
82
|
+
labelProps: mergeProps(labelProps, pressProps),
|
|
66
83
|
inputProps: {
|
|
67
84
|
...inputProps,
|
|
68
85
|
checked: isSelected,
|