@react-aria/checkbox 3.14.1 → 3.14.3

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.
@@ -0,0 +1,63 @@
1
+ import {checkboxGroupData as $1ae600c947479353$export$ec98120685d4f57d} from "./utils.module.js";
2
+ import {filterDOMProps as $gtLuF$filterDOMProps, mergeProps as $gtLuF$mergeProps} from "@react-aria/utils";
3
+ import {useField as $gtLuF$useField} from "@react-aria/label";
4
+ import {useFocusWithin as $gtLuF$useFocusWithin} from "@react-aria/interactions";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ function $1e9fce0cfacc738b$export$49ff6f28c54f1cbe(props, state) {
21
+ let { isDisabled: isDisabled, name: name, validationBehavior: validationBehavior = 'aria' } = props;
22
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
23
+ let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $gtLuF$useField)({
24
+ ...props,
25
+ // Checkbox group is not an HTML input element so it
26
+ // shouldn't be labeled by a <label> element.
27
+ labelElementType: 'span',
28
+ isInvalid: isInvalid,
29
+ errorMessage: props.errorMessage || validationErrors
30
+ });
31
+ (0, $1ae600c947479353$export$ec98120685d4f57d).set(state, {
32
+ name: name,
33
+ descriptionId: descriptionProps.id,
34
+ errorMessageId: errorMessageProps.id,
35
+ validationBehavior: validationBehavior
36
+ });
37
+ let domProps = (0, $gtLuF$filterDOMProps)(props, {
38
+ labelable: true
39
+ });
40
+ let { focusWithinProps: focusWithinProps } = (0, $gtLuF$useFocusWithin)({
41
+ onBlurWithin: props.onBlur,
42
+ onFocusWithin: props.onFocus,
43
+ onFocusWithinChange: props.onFocusChange
44
+ });
45
+ return {
46
+ groupProps: (0, $gtLuF$mergeProps)(domProps, {
47
+ role: 'group',
48
+ 'aria-disabled': isDisabled || undefined,
49
+ ...fieldProps,
50
+ ...focusWithinProps
51
+ }),
52
+ labelProps: labelProps,
53
+ descriptionProps: descriptionProps,
54
+ errorMessageProps: errorMessageProps,
55
+ isInvalid: isInvalid,
56
+ validationErrors: validationErrors,
57
+ validationDetails: validationDetails
58
+ };
59
+ }
60
+
61
+
62
+ export {$1e9fce0cfacc738b$export$49ff6f28c54f1cbe as useCheckboxGroup};
63
+ //# sourceMappingURL=useCheckboxGroup.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AA2BM,SAAS,0CAAiB,KAA6B,EAAE,KAAyB;IACvF,IAAI,cAAC,UAAU,QAAE,IAAI,sBAAE,qBAAqB,QAAO,GAAG;IACtD,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,MAAM,iBAAiB;IAE9E,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC3E,GAAG,KAAK;QACR,oDAAoD;QACpD,6CAA6C;QAC7C,kBAAkB;mBAClB;QACA,cAAc,MAAM,YAAY,IAAI;IACtC;IAEA,CAAA,GAAA,yCAAgB,EAAE,GAAG,CAAC,OAAO;cAC3B;QACA,eAAe,iBAAiB,EAAE;QAClC,gBAAgB,kBAAkB,EAAE;4BACpC;IACF;IAEA,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QACtC,cAAc,MAAM,MAAM;QAC1B,eAAe,MAAM,OAAO;QAC5B,qBAAqB,MAAM,aAAa;IAC1C;IAEA,OAAO;QACL,YAAY,CAAA,GAAA,iBAAS,EAAE,UAAU;YAC/B,MAAM;YACN,iBAAiB,cAAc;YAC/B,GAAG,UAAU;YACb,GAAG,gBAAgB;QACrB;oBACA;0BACA;2BACA;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/checkbox/src/useCheckboxGroup.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 {AriaCheckboxGroupProps} from '@react-types/checkbox';\nimport {checkboxGroupData} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\n\nexport interface CheckboxGroupAria extends ValidationResult {\n /** Props for the checkbox group wrapper element. */\n groupProps: DOMAttributes,\n /** Props for the checkbox group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the checkbox group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the checkbox group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox group component.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox group.\n * @param state - State for the checkbox group, as returned by `useCheckboxGroupState`.\n */\nexport function useCheckboxGroup(props: AriaCheckboxGroupProps, state: CheckboxGroupState): CheckboxGroupAria {\n let {isDisabled, name, validationBehavior = 'aria'} = props;\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Checkbox group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n checkboxGroupData.set(state, {\n name,\n descriptionId: descriptionProps.id,\n errorMessageId: errorMessageProps.id,\n validationBehavior\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin: props.onBlur,\n onFocusWithin: props.onFocus,\n onFocusWithinChange: props.onFocusChange\n });\n\n return {\n groupProps: mergeProps(domProps, {\n role: 'group',\n 'aria-disabled': isDisabled || undefined,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useCheckboxGroup.module.js.map"}
@@ -0,0 +1,91 @@
1
+ var $468c774d7db917b7$exports = require("./useCheckbox.main.js");
2
+ var $64fc3370e682155f$exports = require("./utils.main.js");
3
+ var $2Rh3D$reactstatelyform = require("@react-stately/form");
4
+ var $2Rh3D$react = require("react");
5
+ var $2Rh3D$reactstatelytoggle = require("@react-stately/toggle");
6
+
7
+
8
+ function $parcel$export(e, n, v, s) {
9
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
+ }
11
+
12
+ $parcel$export(module.exports, "useCheckboxGroupItem", () => $07e03121d6ac83c8$export$353b32fc6898d37d);
13
+ /*
14
+ * Copyright 2020 Adobe. All rights reserved.
15
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License. You may obtain a copy
17
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software distributed under
20
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ * OF ANY KIND, either express or implied. See the License for the specific language
22
+ * governing permissions and limitations under the License.
23
+ */
24
+
25
+
26
+
27
+
28
+ function $07e03121d6ac83c8$export$353b32fc6898d37d(props, state, inputRef) {
29
+ const toggleState = (0, $2Rh3D$reactstatelytoggle.useToggleState)({
30
+ isReadOnly: props.isReadOnly || state.isReadOnly,
31
+ isSelected: state.isSelected(props.value),
32
+ onChange (isSelected) {
33
+ if (isSelected) state.addValue(props.value);
34
+ else state.removeValue(props.value);
35
+ if (props.onChange) props.onChange(isSelected);
36
+ }
37
+ });
38
+ let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $64fc3370e682155f$exports.checkboxGroupData).get(state);
39
+ var _props_validationBehavior;
40
+ validationBehavior = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : validationBehavior;
41
+ // Local validation for this checkbox.
42
+ let { realtimeValidation: realtimeValidation } = (0, $2Rh3D$reactstatelyform.useFormValidationState)({
43
+ ...props,
44
+ value: toggleState.isSelected,
45
+ // Server validation is handled at the group level.
46
+ name: undefined,
47
+ validationBehavior: 'aria'
48
+ });
49
+ // Update the checkbox group state when realtime validation changes.
50
+ let nativeValidation = (0, $2Rh3D$react.useRef)((0, $2Rh3D$reactstatelyform.DEFAULT_VALIDATION_RESULT));
51
+ let updateValidation = ()=>{
52
+ state.setInvalid(props.value, realtimeValidation.isInvalid ? realtimeValidation : nativeValidation.current);
53
+ };
54
+ (0, $2Rh3D$react.useEffect)(updateValidation);
55
+ // Combine group and checkbox level validation.
56
+ let combinedRealtimeValidation = state.realtimeValidation.isInvalid ? state.realtimeValidation : realtimeValidation;
57
+ let displayValidation = validationBehavior === 'native' ? state.displayValidation : combinedRealtimeValidation;
58
+ var _props_isRequired;
59
+ let res = (0, $468c774d7db917b7$exports.useCheckbox)({
60
+ ...props,
61
+ isReadOnly: props.isReadOnly || state.isReadOnly,
62
+ isDisabled: props.isDisabled || state.isDisabled,
63
+ name: props.name || name,
64
+ isRequired: (_props_isRequired = props.isRequired) !== null && _props_isRequired !== void 0 ? _props_isRequired : state.isRequired,
65
+ validationBehavior: validationBehavior,
66
+ [(0, $2Rh3D$reactstatelyform.privateValidationStateProp)]: {
67
+ realtimeValidation: combinedRealtimeValidation,
68
+ displayValidation: displayValidation,
69
+ resetValidation: state.resetValidation,
70
+ commitValidation: state.commitValidation,
71
+ updateValidation (v) {
72
+ nativeValidation.current = v;
73
+ updateValidation();
74
+ }
75
+ }
76
+ }, toggleState, inputRef);
77
+ return {
78
+ ...res,
79
+ inputProps: {
80
+ ...res.inputProps,
81
+ 'aria-describedby': [
82
+ props['aria-describedby'],
83
+ state.isInvalid ? errorMessageId : null,
84
+ descriptionId
85
+ ].filter(Boolean).join(' ') || undefined
86
+ }
87
+ };
88
+ }
89
+
90
+
91
+ //# sourceMappingURL=useCheckboxGroupItem.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAkBM,SAAS,0CAAqB,KAAiC,EAAE,KAAyB,EAAE,QAAqC;IACtI,MAAM,cAAc,CAAA,GAAA,wCAAa,EAAE;QACjC,YAAY,MAAM,UAAU,IAAI,MAAM,UAAU;QAChD,YAAY,MAAM,UAAU,CAAC,MAAM,KAAK;QACxC,UAAS,UAAU;YACjB,IAAI,YACF,MAAM,QAAQ,CAAC,MAAM,KAAK;iBAE1B,MAAM,WAAW,CAAC,MAAM,KAAK;YAG/B,IAAI,MAAM,QAAQ,EAChB,MAAM,QAAQ,CAAC;QAEnB;IACF;IAEA,IAAI,QAAC,IAAI,iBAAE,aAAa,kBAAE,cAAc,sBAAE,kBAAkB,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE,GAAG,CAAC;QACjE;IAArB,qBAAqB,CAAA,4BAAA,MAAM,kBAAkB,cAAxB,uCAAA,4BAA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ria/checkbox/src/useCheckboxGroupItem.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 {AriaCheckboxGroupItemProps} from '@react-types/checkbox';\nimport {CheckboxAria, useCheckbox} from './useCheckbox';\nimport {checkboxGroupData} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {DEFAULT_VALIDATION_RESULT, privateValidationStateProp, useFormValidationState} from '@react-stately/form';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {useToggleState} from '@react-stately/toggle';\nimport {ValidationResult} from '@react-types/shared';\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component contained within a checkbox group.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useCheckboxGroupState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckboxGroupItem(props: AriaCheckboxGroupItemProps, state: CheckboxGroupState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n const toggleState = useToggleState({\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isSelected: state.isSelected(props.value),\n onChange(isSelected) {\n if (isSelected) {\n state.addValue(props.value);\n } else {\n state.removeValue(props.value);\n }\n\n if (props.onChange) {\n props.onChange(isSelected);\n }\n }\n });\n\n let {name, descriptionId, errorMessageId, validationBehavior} = checkboxGroupData.get(state)!;\n validationBehavior = props.validationBehavior ?? validationBehavior;\n\n // Local validation for this checkbox.\n let {realtimeValidation} = useFormValidationState({\n ...props,\n value: toggleState.isSelected,\n // Server validation is handled at the group level.\n name: undefined,\n validationBehavior: 'aria'\n });\n\n // Update the checkbox group state when realtime validation changes.\n let nativeValidation = useRef(DEFAULT_VALIDATION_RESULT);\n let updateValidation = () => {\n state.setInvalid(props.value, realtimeValidation.isInvalid ? realtimeValidation : nativeValidation.current);\n };\n\n useEffect(updateValidation);\n\n // Combine group and checkbox level validation.\n let combinedRealtimeValidation = state.realtimeValidation.isInvalid ? state.realtimeValidation : realtimeValidation;\n let displayValidation = validationBehavior === 'native' ? state.displayValidation : combinedRealtimeValidation;\n\n let res = useCheckbox({\n ...props,\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isDisabled: props.isDisabled || state.isDisabled,\n name: props.name || name,\n isRequired: props.isRequired ?? state.isRequired,\n validationBehavior,\n [privateValidationStateProp]: {\n realtimeValidation: combinedRealtimeValidation,\n displayValidation,\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation,\n updateValidation(v: ValidationResult) {\n nativeValidation.current = v;\n updateValidation();\n }\n }\n }, toggleState, inputRef);\n\n return {\n ...res,\n inputProps: {\n ...res.inputProps,\n 'aria-describedby': [\n props['aria-describedby'],\n state.isInvalid ? errorMessageId : null,\n descriptionId\n ].filter(Boolean).join(' ') || undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useCheckboxGroupItem.main.js.map"}
@@ -0,0 +1,86 @@
1
+ import {useCheckbox as $406796ff087fe49b$export$e375f10ce42261c5} from "./useCheckbox.mjs";
2
+ import {checkboxGroupData as $1ae600c947479353$export$ec98120685d4f57d} from "./utils.mjs";
3
+ import {useFormValidationState as $6clEo$useFormValidationState, DEFAULT_VALIDATION_RESULT as $6clEo$DEFAULT_VALIDATION_RESULT, privateValidationStateProp as $6clEo$privateValidationStateProp} from "@react-stately/form";
4
+ import {useRef as $6clEo$useRef, useEffect as $6clEo$useEffect} from "react";
5
+ import {useToggleState as $6clEo$useToggleState} from "@react-stately/toggle";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $fba3e38d5ca8983f$export$353b32fc6898d37d(props, state, inputRef) {
23
+ const toggleState = (0, $6clEo$useToggleState)({
24
+ isReadOnly: props.isReadOnly || state.isReadOnly,
25
+ isSelected: state.isSelected(props.value),
26
+ onChange (isSelected) {
27
+ if (isSelected) state.addValue(props.value);
28
+ else state.removeValue(props.value);
29
+ if (props.onChange) props.onChange(isSelected);
30
+ }
31
+ });
32
+ let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $1ae600c947479353$export$ec98120685d4f57d).get(state);
33
+ var _props_validationBehavior;
34
+ validationBehavior = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : validationBehavior;
35
+ // Local validation for this checkbox.
36
+ let { realtimeValidation: realtimeValidation } = (0, $6clEo$useFormValidationState)({
37
+ ...props,
38
+ value: toggleState.isSelected,
39
+ // Server validation is handled at the group level.
40
+ name: undefined,
41
+ validationBehavior: 'aria'
42
+ });
43
+ // Update the checkbox group state when realtime validation changes.
44
+ let nativeValidation = (0, $6clEo$useRef)((0, $6clEo$DEFAULT_VALIDATION_RESULT));
45
+ let updateValidation = ()=>{
46
+ state.setInvalid(props.value, realtimeValidation.isInvalid ? realtimeValidation : nativeValidation.current);
47
+ };
48
+ (0, $6clEo$useEffect)(updateValidation);
49
+ // Combine group and checkbox level validation.
50
+ let combinedRealtimeValidation = state.realtimeValidation.isInvalid ? state.realtimeValidation : realtimeValidation;
51
+ let displayValidation = validationBehavior === 'native' ? state.displayValidation : combinedRealtimeValidation;
52
+ var _props_isRequired;
53
+ let res = (0, $406796ff087fe49b$export$e375f10ce42261c5)({
54
+ ...props,
55
+ isReadOnly: props.isReadOnly || state.isReadOnly,
56
+ isDisabled: props.isDisabled || state.isDisabled,
57
+ name: props.name || name,
58
+ isRequired: (_props_isRequired = props.isRequired) !== null && _props_isRequired !== void 0 ? _props_isRequired : state.isRequired,
59
+ validationBehavior: validationBehavior,
60
+ [(0, $6clEo$privateValidationStateProp)]: {
61
+ realtimeValidation: combinedRealtimeValidation,
62
+ displayValidation: displayValidation,
63
+ resetValidation: state.resetValidation,
64
+ commitValidation: state.commitValidation,
65
+ updateValidation (v) {
66
+ nativeValidation.current = v;
67
+ updateValidation();
68
+ }
69
+ }
70
+ }, toggleState, inputRef);
71
+ return {
72
+ ...res,
73
+ inputProps: {
74
+ ...res.inputProps,
75
+ 'aria-describedby': [
76
+ props['aria-describedby'],
77
+ state.isInvalid ? errorMessageId : null,
78
+ descriptionId
79
+ ].filter(Boolean).join(' ') || undefined
80
+ }
81
+ };
82
+ }
83
+
84
+
85
+ export {$fba3e38d5ca8983f$export$353b32fc6898d37d as useCheckboxGroupItem};
86
+ //# sourceMappingURL=useCheckboxGroupItem.module.js.map
@@ -0,0 +1,86 @@
1
+ import {useCheckbox as $406796ff087fe49b$export$e375f10ce42261c5} from "./useCheckbox.module.js";
2
+ import {checkboxGroupData as $1ae600c947479353$export$ec98120685d4f57d} from "./utils.module.js";
3
+ import {useFormValidationState as $6clEo$useFormValidationState, DEFAULT_VALIDATION_RESULT as $6clEo$DEFAULT_VALIDATION_RESULT, privateValidationStateProp as $6clEo$privateValidationStateProp} from "@react-stately/form";
4
+ import {useRef as $6clEo$useRef, useEffect as $6clEo$useEffect} from "react";
5
+ import {useToggleState as $6clEo$useToggleState} from "@react-stately/toggle";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $fba3e38d5ca8983f$export$353b32fc6898d37d(props, state, inputRef) {
23
+ const toggleState = (0, $6clEo$useToggleState)({
24
+ isReadOnly: props.isReadOnly || state.isReadOnly,
25
+ isSelected: state.isSelected(props.value),
26
+ onChange (isSelected) {
27
+ if (isSelected) state.addValue(props.value);
28
+ else state.removeValue(props.value);
29
+ if (props.onChange) props.onChange(isSelected);
30
+ }
31
+ });
32
+ let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $1ae600c947479353$export$ec98120685d4f57d).get(state);
33
+ var _props_validationBehavior;
34
+ validationBehavior = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : validationBehavior;
35
+ // Local validation for this checkbox.
36
+ let { realtimeValidation: realtimeValidation } = (0, $6clEo$useFormValidationState)({
37
+ ...props,
38
+ value: toggleState.isSelected,
39
+ // Server validation is handled at the group level.
40
+ name: undefined,
41
+ validationBehavior: 'aria'
42
+ });
43
+ // Update the checkbox group state when realtime validation changes.
44
+ let nativeValidation = (0, $6clEo$useRef)((0, $6clEo$DEFAULT_VALIDATION_RESULT));
45
+ let updateValidation = ()=>{
46
+ state.setInvalid(props.value, realtimeValidation.isInvalid ? realtimeValidation : nativeValidation.current);
47
+ };
48
+ (0, $6clEo$useEffect)(updateValidation);
49
+ // Combine group and checkbox level validation.
50
+ let combinedRealtimeValidation = state.realtimeValidation.isInvalid ? state.realtimeValidation : realtimeValidation;
51
+ let displayValidation = validationBehavior === 'native' ? state.displayValidation : combinedRealtimeValidation;
52
+ var _props_isRequired;
53
+ let res = (0, $406796ff087fe49b$export$e375f10ce42261c5)({
54
+ ...props,
55
+ isReadOnly: props.isReadOnly || state.isReadOnly,
56
+ isDisabled: props.isDisabled || state.isDisabled,
57
+ name: props.name || name,
58
+ isRequired: (_props_isRequired = props.isRequired) !== null && _props_isRequired !== void 0 ? _props_isRequired : state.isRequired,
59
+ validationBehavior: validationBehavior,
60
+ [(0, $6clEo$privateValidationStateProp)]: {
61
+ realtimeValidation: combinedRealtimeValidation,
62
+ displayValidation: displayValidation,
63
+ resetValidation: state.resetValidation,
64
+ commitValidation: state.commitValidation,
65
+ updateValidation (v) {
66
+ nativeValidation.current = v;
67
+ updateValidation();
68
+ }
69
+ }
70
+ }, toggleState, inputRef);
71
+ return {
72
+ ...res,
73
+ inputProps: {
74
+ ...res.inputProps,
75
+ 'aria-describedby': [
76
+ props['aria-describedby'],
77
+ state.isInvalid ? errorMessageId : null,
78
+ descriptionId
79
+ ].filter(Boolean).join(' ') || undefined
80
+ }
81
+ };
82
+ }
83
+
84
+
85
+ export {$fba3e38d5ca8983f$export$353b32fc6898d37d as useCheckboxGroupItem};
86
+ //# sourceMappingURL=useCheckboxGroupItem.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAkBM,SAAS,0CAAqB,KAAiC,EAAE,KAAyB,EAAE,QAAqC;IACtI,MAAM,cAAc,CAAA,GAAA,qBAAa,EAAE;QACjC,YAAY,MAAM,UAAU,IAAI,MAAM,UAAU;QAChD,YAAY,MAAM,UAAU,CAAC,MAAM,KAAK;QACxC,UAAS,UAAU;YACjB,IAAI,YACF,MAAM,QAAQ,CAAC,MAAM,KAAK;iBAE1B,MAAM,WAAW,CAAC,MAAM,KAAK;YAG/B,IAAI,MAAM,QAAQ,EAChB,MAAM,QAAQ,CAAC;QAEnB;IACF;IAEA,IAAI,QAAC,IAAI,iBAAE,aAAa,kBAAE,cAAc,sBAAE,kBAAkB,EAAC,GAAG,CAAA,GAAA,yCAAgB,EAAE,GAAG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,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;QACjC;IACF;AACF","sources":["packages/@react-aria/checkbox/src/useCheckboxGroupItem.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 {AriaCheckboxGroupItemProps} from '@react-types/checkbox';\nimport {CheckboxAria, useCheckbox} from './useCheckbox';\nimport {checkboxGroupData} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {DEFAULT_VALIDATION_RESULT, privateValidationStateProp, useFormValidationState} from '@react-stately/form';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {useToggleState} from '@react-stately/toggle';\nimport {ValidationResult} from '@react-types/shared';\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component contained within a checkbox group.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useCheckboxGroupState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckboxGroupItem(props: AriaCheckboxGroupItemProps, state: CheckboxGroupState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n const toggleState = useToggleState({\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isSelected: state.isSelected(props.value),\n onChange(isSelected) {\n if (isSelected) {\n state.addValue(props.value);\n } else {\n state.removeValue(props.value);\n }\n\n if (props.onChange) {\n props.onChange(isSelected);\n }\n }\n });\n\n let {name, descriptionId, errorMessageId, validationBehavior} = checkboxGroupData.get(state)!;\n validationBehavior = props.validationBehavior ?? validationBehavior;\n\n // Local validation for this checkbox.\n let {realtimeValidation} = useFormValidationState({\n ...props,\n value: toggleState.isSelected,\n // Server validation is handled at the group level.\n name: undefined,\n validationBehavior: 'aria'\n });\n\n // Update the checkbox group state when realtime validation changes.\n let nativeValidation = useRef(DEFAULT_VALIDATION_RESULT);\n let updateValidation = () => {\n state.setInvalid(props.value, realtimeValidation.isInvalid ? realtimeValidation : nativeValidation.current);\n };\n\n useEffect(updateValidation);\n\n // Combine group and checkbox level validation.\n let combinedRealtimeValidation = state.realtimeValidation.isInvalid ? state.realtimeValidation : realtimeValidation;\n let displayValidation = validationBehavior === 'native' ? state.displayValidation : combinedRealtimeValidation;\n\n let res = useCheckbox({\n ...props,\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isDisabled: props.isDisabled || state.isDisabled,\n name: props.name || name,\n isRequired: props.isRequired ?? state.isRequired,\n validationBehavior,\n [privateValidationStateProp]: {\n realtimeValidation: combinedRealtimeValidation,\n displayValidation,\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation,\n updateValidation(v: ValidationResult) {\n nativeValidation.current = v;\n updateValidation();\n }\n }\n }, toggleState, inputRef);\n\n return {\n ...res,\n inputProps: {\n ...res.inputProps,\n 'aria-describedby': [\n props['aria-describedby'],\n state.isInvalid ? errorMessageId : null,\n descriptionId\n ].filter(Boolean).join(' ') || undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useCheckboxGroupItem.module.js.map"}
@@ -0,0 +1,20 @@
1
+
2
+ function $parcel$export(e, n, v, s) {
3
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
+ }
5
+
6
+ $parcel$export(module.exports, "checkboxGroupData", () => $64fc3370e682155f$export$ec98120685d4f57d);
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */ const $64fc3370e682155f$export$ec98120685d4f57d = new WeakMap();
18
+
19
+
20
+ //# sourceMappingURL=utils.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAWM,MAAM,4CAAoB,IAAI","sources":["packages/@react-aria/checkbox/src/utils.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 {CheckboxGroupState} from '@react-stately/checkbox';\n\ninterface CheckboxGroupData {\n name?: string,\n descriptionId?: string,\n errorMessageId?: string,\n validationBehavior: 'aria' | 'native'\n}\n\nexport const checkboxGroupData = new WeakMap<CheckboxGroupState, CheckboxGroupData>();\n"],"names":[],"version":3,"file":"utils.main.js.map"}
package/dist/utils.mjs ADDED
@@ -0,0 +1,15 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ const $1ae600c947479353$export$ec98120685d4f57d = new WeakMap();
12
+
13
+
14
+ export {$1ae600c947479353$export$ec98120685d4f57d as checkboxGroupData};
15
+ //# sourceMappingURL=utils.module.js.map
@@ -0,0 +1,15 @@
1
+ /*
2
+ * Copyright 2020 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */ const $1ae600c947479353$export$ec98120685d4f57d = new WeakMap();
12
+
13
+
14
+ export {$1ae600c947479353$export$ec98120685d4f57d as checkboxGroupData};
15
+ //# sourceMappingURL=utils.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAWM,MAAM,4CAAoB,IAAI","sources":["packages/@react-aria/checkbox/src/utils.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 {CheckboxGroupState} from '@react-stately/checkbox';\n\ninterface CheckboxGroupData {\n name?: string,\n descriptionId?: string,\n errorMessageId?: string,\n validationBehavior: 'aria' | 'native'\n}\n\nexport const checkboxGroupData = new WeakMap<CheckboxGroupState, CheckboxGroupData>();\n"],"names":[],"version":3,"file":"utils.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/checkbox",
3
- "version": "3.14.1",
3
+ "version": "3.14.3",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,16 +22,16 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/form": "^3.0.3",
26
- "@react-aria/interactions": "^3.21.1",
27
- "@react-aria/label": "^3.7.6",
28
- "@react-aria/toggle": "^3.10.2",
29
- "@react-aria/utils": "^3.23.2",
30
- "@react-stately/checkbox": "^3.6.3",
31
- "@react-stately/form": "^3.0.1",
32
- "@react-stately/toggle": "^3.7.2",
33
- "@react-types/checkbox": "^3.7.1",
34
- "@react-types/shared": "^3.22.1",
25
+ "@react-aria/form": "^3.0.5",
26
+ "@react-aria/interactions": "^3.21.3",
27
+ "@react-aria/label": "^3.7.8",
28
+ "@react-aria/toggle": "^3.10.4",
29
+ "@react-aria/utils": "^3.24.1",
30
+ "@react-stately/checkbox": "^3.6.5",
31
+ "@react-stately/form": "^3.0.3",
32
+ "@react-stately/toggle": "^3.7.4",
33
+ "@react-types/checkbox": "^3.8.1",
34
+ "@react-types/shared": "^3.23.1",
35
35
  "@swc/helpers": "^0.5.0"
36
36
  },
37
37
  "peerDependencies": {
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "de9f84a22583fc741c29b341d14cd35ef4cca161"
43
+ "gitHead": "b77d7d594dff4dcfb5359bffbcfd18142b146433"
44
44
  }