@react-aria/radio 3.0.0-nightly-641446f65-240905

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @react-aria/radio
2
+
3
+ This package is part of [react-spectrum](https://github.com/adobe/react-spectrum). See the repo for more details.
@@ -0,0 +1,19 @@
1
+ import {useRadio as $0d5c49892c1215da$export$37b0961d2f4751e2} from "./useRadio.mjs";
2
+ import {useRadioGroup as $430f30ed08ec25fa$export$62b9571f283ff5c2} from "./useRadioGroup.mjs";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+
17
+
18
+ export {$0d5c49892c1215da$export$37b0961d2f4751e2 as useRadio, $430f30ed08ec25fa$export$62b9571f283ff5c2 as useRadioGroup};
19
+ //# sourceMappingURL=module.js.map
package/dist/main.js ADDED
@@ -0,0 +1,25 @@
1
+ var $e184702b1b7f1863$exports = require("./useRadio.main.js");
2
+ var $dfcade00a56a6317$exports = require("./useRadioGroup.main.js");
3
+
4
+
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+
9
+ $parcel$export(module.exports, "useRadio", () => $e184702b1b7f1863$exports.useRadio);
10
+ $parcel$export(module.exports, "useRadioGroup", () => $dfcade00a56a6317$exports.useRadioGroup);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+
24
+
25
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/radio/src/index.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 */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {Orientation} from '@react-types/shared';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js ADDED
@@ -0,0 +1,19 @@
1
+ import {useRadio as $0d5c49892c1215da$export$37b0961d2f4751e2} from "./useRadio.module.js";
2
+ import {useRadioGroup as $430f30ed08ec25fa$export$62b9571f283ff5c2} from "./useRadioGroup.module.js";
3
+
4
+ /*
5
+ * Copyright 2020 Adobe. All rights reserved.
6
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License. You may obtain a copy
8
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software distributed under
11
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
+ * OF ANY KIND, either express or implied. See the License for the specific language
13
+ * governing permissions and limitations under the License.
14
+ */
15
+
16
+
17
+
18
+ export {$0d5c49892c1215da$export$37b0961d2f4751e2 as useRadio, $430f30ed08ec25fa$export$62b9571f283ff5c2 as useRadioGroup};
19
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/radio/src/index.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 */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {Orientation} from '@react-types/shared';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,45 @@
1
+ import { AriaRadioProps, AriaRadioGroupProps } from "@react-types/radio";
2
+ import { InputHTMLAttributes, LabelHTMLAttributes } from "react";
3
+ import { RadioGroupState } from "@react-stately/radio";
4
+ import { RefObject, DOMAttributes, ValidationResult } from "@react-types/shared";
5
+ export interface RadioAria {
6
+ /** Props for the label wrapper element. */
7
+ labelProps: LabelHTMLAttributes<HTMLLabelElement>;
8
+ /** Props for the input element. */
9
+ inputProps: InputHTMLAttributes<HTMLInputElement>;
10
+ /** Whether the radio is disabled. */
11
+ isDisabled: boolean;
12
+ /** Whether the radio is currently selected. */
13
+ isSelected: boolean;
14
+ /** Whether the radio is in a pressed state. */
15
+ isPressed: boolean;
16
+ }
17
+ /**
18
+ * Provides the behavior and accessibility implementation for an individual
19
+ * radio button in a radio group.
20
+ * @param props - Props for the radio.
21
+ * @param state - State for the radio group, as returned by `useRadioGroupState`.
22
+ * @param ref - Ref to the HTML input element.
23
+ */
24
+ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLInputElement | null>): RadioAria;
25
+ export interface RadioGroupAria extends ValidationResult {
26
+ /** Props for the radio group wrapper element. */
27
+ radioGroupProps: DOMAttributes;
28
+ /** Props for the radio group's visible label (if any). */
29
+ labelProps: DOMAttributes;
30
+ /** Props for the radio group description element, if any. */
31
+ descriptionProps: DOMAttributes;
32
+ /** Props for the radio group error message element, if any. */
33
+ errorMessageProps: DOMAttributes;
34
+ }
35
+ /**
36
+ * Provides the behavior and accessibility implementation for a radio group component.
37
+ * Radio groups allow users to select a single item from a list of mutually exclusive options.
38
+ * @param props - Props for the radio group.
39
+ * @param state - State for the radio group, as returned by `useRadioGroupState`.
40
+ */
41
+ export function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria;
42
+ export type { AriaRadioGroupProps, AriaRadioProps } from '@react-types/radio';
43
+ export type { Orientation } from '@react-types/shared';
44
+
45
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;ACsBA;IACE,2CAA2C;IAC3C,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,qCAAqC;IACrC,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;GAMG;AACH,yBAAyB,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,SAAS,CA8E1H;AClGD,+BAAgC,SAAQ,gBAAgB;IACtD,iDAAiD;IACjD,eAAe,EAAE,aAAa,CAAC;IAC/B,0DAA0D;IAC1D,UAAU,EAAE,aAAa,CAAC;IAC1B,6DAA6D;IAC7D,gBAAgB,EAAE,aAAa,CAAC;IAChC,+DAA+D;IAC/D,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAED;;;;;GAKG;AACH,8BAA8B,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,eAAe,GAAG,cAAc,CAmHhG;AC7ID,YAAY,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAC5E,YAAY,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/radio/src/packages/@react-aria/radio/src/utils.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/useRadioGroup.ts","packages/@react-aria/radio/src/packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/index.ts"],"sourcesContent":[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 {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {Orientation} from '@react-types/shared';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -0,0 +1,93 @@
1
+ var $eeb149278aae5c67$exports = require("./utils.main.js");
2
+ var $gWC9A$reactariautils = require("@react-aria/utils");
3
+ var $gWC9A$reactariafocus = require("@react-aria/focus");
4
+ var $gWC9A$reactariaform = require("@react-aria/form");
5
+ var $gWC9A$reactariainteractions = require("@react-aria/interactions");
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, "useRadio", () => $e184702b1b7f1863$export$37b0961d2f4751e2);
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 $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
29
+ let { value: value, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby } = props;
30
+ const isDisabled = props.isDisabled || state.isDisabled;
31
+ let hasChildren = children != null;
32
+ let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
33
+ if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility');
34
+ let checked = state.selectedValue === value;
35
+ let onChange = (e)=>{
36
+ e.stopPropagation();
37
+ state.setSelectedValue(value);
38
+ };
39
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $gWC9A$reactariainteractions.usePress)({
40
+ isDisabled: isDisabled
41
+ });
42
+ // iOS does not toggle radios if you drag off and back onto the label, so handle it ourselves.
43
+ let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $gWC9A$reactariainteractions.usePress)({
44
+ isDisabled: isDisabled,
45
+ onPress () {
46
+ state.setSelectedValue(value);
47
+ }
48
+ });
49
+ let { focusableProps: focusableProps } = (0, $gWC9A$reactariafocus.useFocusable)((0, $gWC9A$reactariautils.mergeProps)(props, {
50
+ onFocus: ()=>state.setLastFocusedValue(value)
51
+ }), ref);
52
+ let interactions = (0, $gWC9A$reactariautils.mergeProps)(pressProps, focusableProps);
53
+ let domProps = (0, $gWC9A$reactariautils.filterDOMProps)(props, {
54
+ labelable: true
55
+ });
56
+ let tabIndex = -1;
57
+ if (state.selectedValue != null) {
58
+ if (state.selectedValue === value) tabIndex = 0;
59
+ } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
60
+ if (isDisabled) tabIndex = undefined;
61
+ let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $eeb149278aae5c67$exports.radioGroupData).get(state);
62
+ (0, $gWC9A$reactariautils.useFormReset)(ref, state.selectedValue, state.setSelectedValue);
63
+ (0, $gWC9A$reactariaform.useFormValidation)({
64
+ validationBehavior: validationBehavior
65
+ }, state, ref);
66
+ return {
67
+ labelProps: (0, $gWC9A$reactariautils.mergeProps)(labelProps, {
68
+ onClick: (e)=>e.preventDefault()
69
+ }),
70
+ inputProps: (0, $gWC9A$reactariautils.mergeProps)(domProps, {
71
+ ...interactions,
72
+ type: 'radio',
73
+ name: name,
74
+ tabIndex: tabIndex,
75
+ disabled: isDisabled,
76
+ required: state.isRequired && validationBehavior === 'native',
77
+ checked: checked,
78
+ value: value,
79
+ onChange: onChange,
80
+ 'aria-describedby': [
81
+ props['aria-describedby'],
82
+ state.isInvalid ? errorMessageId : null,
83
+ descriptionId
84
+ ].filter(Boolean).join(' ') || undefined
85
+ }),
86
+ isDisabled: isDisabled,
87
+ isSelected: checked,
88
+ isPressed: isPressed || isLabelPressed
89
+ };
90
+ }
91
+
92
+
93
+ //# sourceMappingURL=useRadio.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAgCM,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAuC;IAC7G,IAAI,SACF,KAAK,YACL,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,EAClC,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;IAEvD,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,IAAI,UAAU,MAAM,aAAa,KAAK;IAEtC,IAAI,WAAW,CAAC;QACd,EAAE,eAAe;QACjB,MAAM,gBAAgB,CAAC;IACzB;IAEA,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBACrC;IACF;IAEA,8FAA8F;IAC9F,IAAI,EAAC,YAAY,UAAU,EAAE,WAAW,cAAc,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBACjE;QACA;YACE,MAAM,gBAAgB,CAAC;QACzB;IACF;IAEA,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW,EAAE,CAAA,GAAA,gCAAS,EAAE,OAAO;QACpD,SAAS,IAAM,MAAM,mBAAmB,CAAC;IAC3C,IAAI;IACJ,IAAI,eAAe,CAAA,GAAA,gCAAS,EAAE,YAAY;IAC1C,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,WAA+B;IACnC,IAAI,MAAM,aAAa,IAAI,MACzB;QAAA,IAAI,MAAM,aAAa,KAAK,OAC1B,WAAW;IACb,OACK,IAAI,MAAM,gBAAgB,KAAK,SAAS,MAAM,gBAAgB,IAAI,MACvE,WAAW;IAEb,IAAI,YACF,WAAW;IAGb,IAAI,QAAC,IAAI,iBAAE,aAAa,kBAAE,cAAc,sBAAE,kBAAkB,EAAC,GAAG,CAAA,GAAA,wCAAa,EAAE,GAAG,CAAC;IACnF,CAAA,GAAA,kCAAW,EAAE,KAAK,MAAM,aAAa,EAAE,MAAM,gBAAgB;IAC7D,CAAA,GAAA,sCAAgB,EAAE;4BAAC;IAAkB,GAAG,OAAO;IAE/C,OAAO;QACL,YAAY,CAAA,GAAA,gCAAS,EAAE,YAAY;YAAC,SAAS,CAAA,IAAK,EAAE,cAAc;QAAE;QACpE,YAAY,CAAA,GAAA,gCAAS,EAAE,UAAU;YAC/B,GAAG,YAAY;YACf,MAAM;kBACN;sBACA;YACA,UAAU;YACV,UAAU,MAAM,UAAU,IAAI,uBAAuB;qBACrD;mBACA;sBACA;YACA,oBAAoB;gBAClB,KAAK,CAAC,mBAAmB;gBACzB,MAAM,SAAS,GAAG,iBAAiB;gBACnC;aACD,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;QACjC;oBACA;QACA,YAAY;QACZ,WAAW,aAAa;IAC1B;AACF","sources":["packages/@react-aria/radio/src/useRadio.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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\nimport {radioGroupData} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {RefObject} from '@react-types/shared';\nimport {useFocusable} from '@react-aria/focus';\nimport {useFormValidation} from '@react-aria/form';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the radio is disabled. */\n isDisabled: boolean,\n /** Whether the radio is currently selected. */\n isSelected: boolean,\n /** Whether the radio is in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an individual\n * radio button in a radio group.\n * @param props - Props for the radio.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLInputElement | null>): RadioAria {\n let {\n value,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby\n } = props;\n\n const isDisabled = props.isDisabled || state.isDisabled;\n\n let hasChildren = children != null;\n let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;\n if (!hasChildren && !hasAriaLabel) {\n console.warn('If you do not provide children, you must specify an aria-label for accessibility');\n }\n\n let checked = state.selectedValue === value;\n\n let onChange = (e) => {\n e.stopPropagation();\n state.setSelectedValue(value);\n };\n\n let {pressProps, isPressed} = usePress({\n isDisabled\n });\n\n // iOS does not toggle radios if you drag off and back onto the label, so handle it ourselves.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n isDisabled,\n onPress() {\n state.setSelectedValue(value);\n }\n });\n\n let {focusableProps} = useFocusable(mergeProps(props, {\n onFocus: () => state.setLastFocusedValue(value)\n }), ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n let tabIndex: number | undefined = -1;\n if (state.selectedValue != null) {\n if (state.selectedValue === value) {\n tabIndex = 0;\n }\n } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) {\n tabIndex = 0;\n }\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n let {name, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;\n useFormReset(ref, state.selectedValue, state.setSelectedValue);\n useFormValidation({validationBehavior}, state, ref);\n\n return {\n labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name,\n tabIndex,\n disabled: isDisabled,\n required: state.isRequired && validationBehavior === 'native',\n checked,\n value,\n onChange,\n 'aria-describedby': [\n props['aria-describedby'],\n state.isInvalid ? errorMessageId : null,\n descriptionId\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked,\n isPressed: isPressed || isLabelPressed\n };\n}\n"],"names":[],"version":3,"file":"useRadio.main.js.map"}
@@ -0,0 +1,88 @@
1
+ import {radioGroupData as $884aeceb3d67f00f$export$37b65e5b5444d35c} from "./utils.mjs";
2
+ import {mergeProps as $5jJ3f$mergeProps, filterDOMProps as $5jJ3f$filterDOMProps, useFormReset as $5jJ3f$useFormReset} from "@react-aria/utils";
3
+ import {useFocusable as $5jJ3f$useFocusable} from "@react-aria/focus";
4
+ import {useFormValidation as $5jJ3f$useFormValidation} from "@react-aria/form";
5
+ import {usePress as $5jJ3f$usePress} from "@react-aria/interactions";
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 $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
23
+ let { value: value, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby } = props;
24
+ const isDisabled = props.isDisabled || state.isDisabled;
25
+ let hasChildren = children != null;
26
+ let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
27
+ if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility');
28
+ let checked = state.selectedValue === value;
29
+ let onChange = (e)=>{
30
+ e.stopPropagation();
31
+ state.setSelectedValue(value);
32
+ };
33
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $5jJ3f$usePress)({
34
+ isDisabled: isDisabled
35
+ });
36
+ // iOS does not toggle radios if you drag off and back onto the label, so handle it ourselves.
37
+ let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $5jJ3f$usePress)({
38
+ isDisabled: isDisabled,
39
+ onPress () {
40
+ state.setSelectedValue(value);
41
+ }
42
+ });
43
+ let { focusableProps: focusableProps } = (0, $5jJ3f$useFocusable)((0, $5jJ3f$mergeProps)(props, {
44
+ onFocus: ()=>state.setLastFocusedValue(value)
45
+ }), ref);
46
+ let interactions = (0, $5jJ3f$mergeProps)(pressProps, focusableProps);
47
+ let domProps = (0, $5jJ3f$filterDOMProps)(props, {
48
+ labelable: true
49
+ });
50
+ let tabIndex = -1;
51
+ if (state.selectedValue != null) {
52
+ if (state.selectedValue === value) tabIndex = 0;
53
+ } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
54
+ if (isDisabled) tabIndex = undefined;
55
+ let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $884aeceb3d67f00f$export$37b65e5b5444d35c).get(state);
56
+ (0, $5jJ3f$useFormReset)(ref, state.selectedValue, state.setSelectedValue);
57
+ (0, $5jJ3f$useFormValidation)({
58
+ validationBehavior: validationBehavior
59
+ }, state, ref);
60
+ return {
61
+ labelProps: (0, $5jJ3f$mergeProps)(labelProps, {
62
+ onClick: (e)=>e.preventDefault()
63
+ }),
64
+ inputProps: (0, $5jJ3f$mergeProps)(domProps, {
65
+ ...interactions,
66
+ type: 'radio',
67
+ name: name,
68
+ tabIndex: tabIndex,
69
+ disabled: isDisabled,
70
+ required: state.isRequired && validationBehavior === 'native',
71
+ checked: checked,
72
+ value: value,
73
+ onChange: onChange,
74
+ 'aria-describedby': [
75
+ props['aria-describedby'],
76
+ state.isInvalid ? errorMessageId : null,
77
+ descriptionId
78
+ ].filter(Boolean).join(' ') || undefined
79
+ }),
80
+ isDisabled: isDisabled,
81
+ isSelected: checked,
82
+ isPressed: isPressed || isLabelPressed
83
+ };
84
+ }
85
+
86
+
87
+ export {$0d5c49892c1215da$export$37b0961d2f4751e2 as useRadio};
88
+ //# sourceMappingURL=useRadio.module.js.map
@@ -0,0 +1,88 @@
1
+ import {radioGroupData as $884aeceb3d67f00f$export$37b65e5b5444d35c} from "./utils.module.js";
2
+ import {mergeProps as $5jJ3f$mergeProps, filterDOMProps as $5jJ3f$filterDOMProps, useFormReset as $5jJ3f$useFormReset} from "@react-aria/utils";
3
+ import {useFocusable as $5jJ3f$useFocusable} from "@react-aria/focus";
4
+ import {useFormValidation as $5jJ3f$useFormValidation} from "@react-aria/form";
5
+ import {usePress as $5jJ3f$usePress} from "@react-aria/interactions";
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 $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
23
+ let { value: value, children: children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby } = props;
24
+ const isDisabled = props.isDisabled || state.isDisabled;
25
+ let hasChildren = children != null;
26
+ let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
27
+ if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility');
28
+ let checked = state.selectedValue === value;
29
+ let onChange = (e)=>{
30
+ e.stopPropagation();
31
+ state.setSelectedValue(value);
32
+ };
33
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $5jJ3f$usePress)({
34
+ isDisabled: isDisabled
35
+ });
36
+ // iOS does not toggle radios if you drag off and back onto the label, so handle it ourselves.
37
+ let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $5jJ3f$usePress)({
38
+ isDisabled: isDisabled,
39
+ onPress () {
40
+ state.setSelectedValue(value);
41
+ }
42
+ });
43
+ let { focusableProps: focusableProps } = (0, $5jJ3f$useFocusable)((0, $5jJ3f$mergeProps)(props, {
44
+ onFocus: ()=>state.setLastFocusedValue(value)
45
+ }), ref);
46
+ let interactions = (0, $5jJ3f$mergeProps)(pressProps, focusableProps);
47
+ let domProps = (0, $5jJ3f$filterDOMProps)(props, {
48
+ labelable: true
49
+ });
50
+ let tabIndex = -1;
51
+ if (state.selectedValue != null) {
52
+ if (state.selectedValue === value) tabIndex = 0;
53
+ } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
54
+ if (isDisabled) tabIndex = undefined;
55
+ let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $884aeceb3d67f00f$export$37b65e5b5444d35c).get(state);
56
+ (0, $5jJ3f$useFormReset)(ref, state.selectedValue, state.setSelectedValue);
57
+ (0, $5jJ3f$useFormValidation)({
58
+ validationBehavior: validationBehavior
59
+ }, state, ref);
60
+ return {
61
+ labelProps: (0, $5jJ3f$mergeProps)(labelProps, {
62
+ onClick: (e)=>e.preventDefault()
63
+ }),
64
+ inputProps: (0, $5jJ3f$mergeProps)(domProps, {
65
+ ...interactions,
66
+ type: 'radio',
67
+ name: name,
68
+ tabIndex: tabIndex,
69
+ disabled: isDisabled,
70
+ required: state.isRequired && validationBehavior === 'native',
71
+ checked: checked,
72
+ value: value,
73
+ onChange: onChange,
74
+ 'aria-describedby': [
75
+ props['aria-describedby'],
76
+ state.isInvalid ? errorMessageId : null,
77
+ descriptionId
78
+ ].filter(Boolean).join(' ') || undefined
79
+ }),
80
+ isDisabled: isDisabled,
81
+ isSelected: checked,
82
+ isPressed: isPressed || isLabelPressed
83
+ };
84
+ }
85
+
86
+
87
+ export {$0d5c49892c1215da$export$37b0961d2f4751e2 as useRadio};
88
+ //# sourceMappingURL=useRadio.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAgCM,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAuC;IAC7G,IAAI,SACF,KAAK,YACL,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,EAClC,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;IAEvD,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,IAAI,UAAU,MAAM,aAAa,KAAK;IAEtC,IAAI,WAAW,CAAC;QACd,EAAE,eAAe;QACjB,MAAM,gBAAgB,CAAC;IACzB;IAEA,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;oBACrC;IACF;IAEA,8FAA8F;IAC9F,IAAI,EAAC,YAAY,UAAU,EAAE,WAAW,cAAc,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;oBACjE;QACA;YACE,MAAM,gBAAgB,CAAC;QACzB;IACF;IAEA,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE,CAAA,GAAA,iBAAS,EAAE,OAAO;QACpD,SAAS,IAAM,MAAM,mBAAmB,CAAC;IAC3C,IAAI;IACJ,IAAI,eAAe,CAAA,GAAA,iBAAS,EAAE,YAAY;IAC1C,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,WAA+B;IACnC,IAAI,MAAM,aAAa,IAAI,MACzB;QAAA,IAAI,MAAM,aAAa,KAAK,OAC1B,WAAW;IACb,OACK,IAAI,MAAM,gBAAgB,KAAK,SAAS,MAAM,gBAAgB,IAAI,MACvE,WAAW;IAEb,IAAI,YACF,WAAW;IAGb,IAAI,QAAC,IAAI,iBAAE,aAAa,kBAAE,cAAc,sBAAE,kBAAkB,EAAC,GAAG,CAAA,GAAA,yCAAa,EAAE,GAAG,CAAC;IACnF,CAAA,GAAA,mBAAW,EAAE,KAAK,MAAM,aAAa,EAAE,MAAM,gBAAgB;IAC7D,CAAA,GAAA,wBAAgB,EAAE;4BAAC;IAAkB,GAAG,OAAO;IAE/C,OAAO;QACL,YAAY,CAAA,GAAA,iBAAS,EAAE,YAAY;YAAC,SAAS,CAAA,IAAK,EAAE,cAAc;QAAE;QACpE,YAAY,CAAA,GAAA,iBAAS,EAAE,UAAU;YAC/B,GAAG,YAAY;YACf,MAAM;kBACN;sBACA;YACA,UAAU;YACV,UAAU,MAAM,UAAU,IAAI,uBAAuB;qBACrD;mBACA;sBACA;YACA,oBAAoB;gBAClB,KAAK,CAAC,mBAAmB;gBACzB,MAAM,SAAS,GAAG,iBAAiB;gBACnC;aACD,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;QACjC;oBACA;QACA,YAAY;QACZ,WAAW,aAAa;IAC1B;AACF","sources":["packages/@react-aria/radio/src/useRadio.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 {AriaRadioProps} from '@react-types/radio';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, LabelHTMLAttributes} from 'react';\nimport {radioGroupData} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {RefObject} from '@react-types/shared';\nimport {useFocusable} from '@react-aria/focus';\nimport {useFormValidation} from '@react-aria/form';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the radio is disabled. */\n isDisabled: boolean,\n /** Whether the radio is currently selected. */\n isSelected: boolean,\n /** Whether the radio is in a pressed state. */\n isPressed: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for an individual\n * radio button in a radio group.\n * @param props - Props for the radio.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLInputElement | null>): RadioAria {\n let {\n value,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby\n } = props;\n\n const isDisabled = props.isDisabled || state.isDisabled;\n\n let hasChildren = children != null;\n let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;\n if (!hasChildren && !hasAriaLabel) {\n console.warn('If you do not provide children, you must specify an aria-label for accessibility');\n }\n\n let checked = state.selectedValue === value;\n\n let onChange = (e) => {\n e.stopPropagation();\n state.setSelectedValue(value);\n };\n\n let {pressProps, isPressed} = usePress({\n isDisabled\n });\n\n // iOS does not toggle radios if you drag off and back onto the label, so handle it ourselves.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n isDisabled,\n onPress() {\n state.setSelectedValue(value);\n }\n });\n\n let {focusableProps} = useFocusable(mergeProps(props, {\n onFocus: () => state.setLastFocusedValue(value)\n }), ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n let tabIndex: number | undefined = -1;\n if (state.selectedValue != null) {\n if (state.selectedValue === value) {\n tabIndex = 0;\n }\n } else if (state.lastFocusedValue === value || state.lastFocusedValue == null) {\n tabIndex = 0;\n }\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n let {name, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;\n useFormReset(ref, state.selectedValue, state.setSelectedValue);\n useFormValidation({validationBehavior}, state, ref);\n\n return {\n labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name,\n tabIndex,\n disabled: isDisabled,\n required: state.isRequired && validationBehavior === 'native',\n checked,\n value,\n onChange,\n 'aria-describedby': [\n props['aria-describedby'],\n state.isInvalid ? errorMessageId : null,\n descriptionId\n ].filter(Boolean).join(' ') || undefined\n }),\n isDisabled,\n isSelected: checked,\n isPressed: isPressed || isLabelPressed\n };\n}\n"],"names":[],"version":3,"file":"useRadio.module.js.map"}
@@ -0,0 +1,132 @@
1
+ var $eeb149278aae5c67$exports = require("./utils.main.js");
2
+ var $bNSfM$reactariautils = require("@react-aria/utils");
3
+ var $bNSfM$reactariafocus = require("@react-aria/focus");
4
+ var $bNSfM$reactarialabel = require("@react-aria/label");
5
+ var $bNSfM$reactariainteractions = require("@react-aria/interactions");
6
+ var $bNSfM$reactariai18n = require("@react-aria/i18n");
7
+
8
+
9
+ function $parcel$export(e, n, v, s) {
10
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
11
+ }
12
+
13
+ $parcel$export(module.exports, "useRadioGroup", () => $dfcade00a56a6317$export$62b9571f283ff5c2);
14
+ /*
15
+ * Copyright 2020 Adobe. All rights reserved.
16
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License. You may obtain a copy
18
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software distributed under
21
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
+ * OF ANY KIND, either express or implied. See the License for the specific language
23
+ * governing permissions and limitations under the License.
24
+ */
25
+
26
+
27
+
28
+
29
+
30
+ function $dfcade00a56a6317$export$62b9571f283ff5c2(props, state) {
31
+ let { name: name, isReadOnly: isReadOnly, isRequired: isRequired, isDisabled: isDisabled, orientation: orientation = 'vertical', validationBehavior: validationBehavior = 'aria' } = props;
32
+ let { direction: direction } = (0, $bNSfM$reactariai18n.useLocale)();
33
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
34
+ let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $bNSfM$reactarialabel.useField)({
35
+ ...props,
36
+ // Radio group is not an HTML input element so it
37
+ // shouldn't be labeled by a <label> element.
38
+ labelElementType: 'span',
39
+ isInvalid: state.isInvalid,
40
+ errorMessage: props.errorMessage || validationErrors
41
+ });
42
+ let domProps = (0, $bNSfM$reactariautils.filterDOMProps)(props, {
43
+ labelable: true
44
+ });
45
+ // When the radio group loses focus, reset the focusable radio to null if
46
+ // there is no selection. This allows tabbing into the group from either
47
+ // direction to go to the first or last radio.
48
+ let { focusWithinProps: focusWithinProps } = (0, $bNSfM$reactariainteractions.useFocusWithin)({
49
+ onBlurWithin (e) {
50
+ var _props_onBlur;
51
+ (_props_onBlur = props.onBlur) === null || _props_onBlur === void 0 ? void 0 : _props_onBlur.call(props, e);
52
+ if (!state.selectedValue) state.setLastFocusedValue(null);
53
+ },
54
+ onFocusWithin: props.onFocus,
55
+ onFocusWithinChange: props.onFocusChange
56
+ });
57
+ let onKeyDown = (e)=>{
58
+ let nextDir;
59
+ switch(e.key){
60
+ case 'ArrowRight':
61
+ if (direction === 'rtl' && orientation !== 'vertical') nextDir = 'prev';
62
+ else nextDir = 'next';
63
+ break;
64
+ case 'ArrowLeft':
65
+ if (direction === 'rtl' && orientation !== 'vertical') nextDir = 'next';
66
+ else nextDir = 'prev';
67
+ break;
68
+ case 'ArrowDown':
69
+ nextDir = 'next';
70
+ break;
71
+ case 'ArrowUp':
72
+ nextDir = 'prev';
73
+ break;
74
+ default:
75
+ return;
76
+ }
77
+ e.preventDefault();
78
+ let walker = (0, $bNSfM$reactariafocus.getFocusableTreeWalker)(e.currentTarget, {
79
+ from: e.target
80
+ });
81
+ let nextElem;
82
+ if (nextDir === 'next') {
83
+ nextElem = walker.nextNode();
84
+ if (!nextElem) {
85
+ walker.currentNode = e.currentTarget;
86
+ nextElem = walker.firstChild();
87
+ }
88
+ } else {
89
+ nextElem = walker.previousNode();
90
+ if (!nextElem) {
91
+ walker.currentNode = e.currentTarget;
92
+ nextElem = walker.lastChild();
93
+ }
94
+ }
95
+ if (nextElem) {
96
+ // Call focus on nextElem so that keyboard navigation scrolls the radio into view
97
+ nextElem.focus();
98
+ state.setSelectedValue(nextElem.value);
99
+ }
100
+ };
101
+ let groupName = (0, $bNSfM$reactariautils.useId)(name);
102
+ (0, $eeb149278aae5c67$exports.radioGroupData).set(state, {
103
+ name: groupName,
104
+ descriptionId: descriptionProps.id,
105
+ errorMessageId: errorMessageProps.id,
106
+ validationBehavior: validationBehavior
107
+ });
108
+ return {
109
+ radioGroupProps: (0, $bNSfM$reactariautils.mergeProps)(domProps, {
110
+ // https://www.w3.org/TR/wai-aria-1.2/#radiogroup
111
+ role: 'radiogroup',
112
+ onKeyDown: onKeyDown,
113
+ 'aria-invalid': state.isInvalid || undefined,
114
+ 'aria-errormessage': props['aria-errormessage'],
115
+ 'aria-readonly': isReadOnly || undefined,
116
+ 'aria-required': isRequired || undefined,
117
+ 'aria-disabled': isDisabled || undefined,
118
+ 'aria-orientation': orientation,
119
+ ...fieldProps,
120
+ ...focusWithinProps
121
+ }),
122
+ labelProps: labelProps,
123
+ descriptionProps: descriptionProps,
124
+ errorMessageProps: errorMessageProps,
125
+ isInvalid: isInvalid,
126
+ validationErrors: validationErrors,
127
+ validationDetails: validationDetails
128
+ };
129
+ }
130
+
131
+
132
+ //# sourceMappingURL=useRadioGroup.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA6BM,SAAS,0CAAc,KAA0B,EAAE,KAAsB;IAC9E,IAAI,QACF,IAAI,cACJ,UAAU,cACV,UAAU,cACV,UAAU,eACV,cAAc,gCACd,qBAAqB,QACtB,GAAG;IACJ,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAE1B,IAAI,aAAC,SAAS,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,MAAM,iBAAiB;IAC9E,IAAI,cAAC,UAAU,cAAE,UAAU,oBAAE,gBAAgB,qBAAE,iBAAiB,EAAC,GAAG,CAAA,GAAA,8BAAO,EAAE;QAC3E,GAAG,KAAK;QACR,iDAAiD;QACjD,6CAA6C;QAC7C,kBAAkB;QAClB,WAAW,MAAM,SAAS;QAC1B,cAAc,MAAM,YAAY,IAAI;IACtC;IAEA,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,yEAAyE;IACzE,wEAAwE;IACxE,8CAA8C;IAC9C,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAa,EAAE;QACtC,cAAa,CAAC;gBACZ;aAAA,gBAAA,MAAM,MAAM,cAAZ,oCAAA,mBAAA,OAAe;YACf,IAAI,CAAC,MAAM,aAAa,EACtB,MAAM,mBAAmB,CAAC;QAE9B;QACA,eAAe,MAAM,OAAO;QAC5B,qBAAqB,MAAM,aAAa;IAC1C;IAEA,IAAI,YAAY,CAAC;QACf,IAAI;QACJ,OAAQ,EAAE,GAAG;YACX,KAAK;gBACH,IAAI,cAAc,SAAS,gBAAgB,YACzC,UAAU;qBAEV,UAAU;gBAEZ;YACF,KAAK;gBACH,IAAI,cAAc,SAAS,gBAAgB,YACzC,UAAU;qBAEV,UAAU;gBAEZ;YACF,KAAK;gBACH,UAAU;gBACV;YACF,KAAK;gBACH,UAAU;gBACV;YACF;gBACE;QACJ;QACA,EAAE,cAAc;QAChB,IAAI,SAAS,CAAA,GAAA,4CAAqB,EAAE,EAAE,aAAa,EAAE;YAAC,MAAM,EAAE,MAAM;QAAA;QACpE,IAAI;QACJ,IAAI,YAAY,QAAQ;YACtB,WAAW,OAAO,QAAQ;YAC1B,IAAI,CAAC,UAAU;gBACb,OAAO,WAAW,GAAG,EAAE,aAAa;gBACpC,WAAW,OAAO,UAAU;YAC9B;QACF,OAAO;YACL,WAAW,OAAO,YAAY;YAC9B,IAAI,CAAC,UAAU;gBACb,OAAO,WAAW,GAAG,EAAE,aAAa;gBACpC,WAAW,OAAO,SAAS;YAC7B;QACF;QACA,IAAI,UAAU;YACZ,iFAAiF;YACjF,SAAS,KAAK;YACd,MAAM,gBAAgB,CAAC,SAAS,KAAK;QACvC;IACF;IAEA,IAAI,YAAY,CAAA,GAAA,2BAAI,EAAE;IACtB,CAAA,GAAA,wCAAa,EAAE,GAAG,CAAC,OAAO;QACxB,MAAM;QACN,eAAe,iBAAiB,EAAE;QAClC,gBAAgB,kBAAkB,EAAE;4BACpC;IACF;IAEA,OAAO;QACL,iBAAiB,CAAA,GAAA,gCAAS,EAAE,UAAU;YACpC,iDAAiD;YACjD,MAAM;uBACN;YACA,gBAAgB,MAAM,SAAS,IAAI;YACnC,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;YAC/B,oBAAoB;YACpB,GAAG,UAAU;YACb,GAAG,gBAAgB;QACrB;oBACA;0BACA;2BACA;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/radio/src/useRadioGroup.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 {AriaRadioGroupProps} from '@react-types/radio';\nimport {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupData} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria extends ValidationResult {\n /** Props for the radio group wrapper element. */\n radioGroupProps: DOMAttributes,\n /** Props for the radio group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the radio group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the radio group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a radio group component.\n * Radio groups allow users to select a single item from a list of mutually exclusive options.\n * @param props - Props for the radio group.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n */\nexport function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria {\n let {\n name,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical',\n validationBehavior = 'aria'\n } = props;\n let {direction} = useLocale();\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Radio group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span',\n isInvalid: state.isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // When the radio group loses focus, reset the focusable radio to null if\n // there is no selection. This allows tabbing into the group from either\n // direction to go to the first or last radio.\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin(e) {\n props.onBlur?.(e);\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n },\n onFocusWithin: props.onFocus,\n onFocusWithinChange: props.onFocusChange\n });\n\n let onKeyDown = (e) => {\n let nextDir;\n switch (e.key) {\n case 'ArrowRight':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'prev';\n } else {\n nextDir = 'next';\n }\n break;\n case 'ArrowLeft':\n if (direction === 'rtl' && orientation !== 'vertical') {\n nextDir = 'next';\n } else {\n nextDir = 'prev';\n }\n break;\n case 'ArrowDown':\n nextDir = 'next';\n break;\n case 'ArrowUp':\n nextDir = 'prev';\n break;\n default:\n return;\n }\n e.preventDefault();\n let walker = getFocusableTreeWalker(e.currentTarget, {from: e.target});\n let nextElem;\n if (nextDir === 'next') {\n nextElem = walker.nextNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.firstChild();\n }\n } else {\n nextElem = walker.previousNode();\n if (!nextElem) {\n walker.currentNode = e.currentTarget;\n nextElem = walker.lastChild();\n }\n }\n if (nextElem) {\n // Call focus on nextElem so that keyboard navigation scrolls the radio into view\n nextElem.focus();\n state.setSelectedValue(nextElem.value);\n }\n };\n\n let groupName = useId(name);\n radioGroupData.set(state, {\n name: groupName,\n descriptionId: descriptionProps.id,\n errorMessageId: errorMessageProps.id,\n validationBehavior\n });\n\n return {\n radioGroupProps: mergeProps(domProps, {\n // https://www.w3.org/TR/wai-aria-1.2/#radiogroup\n role: 'radiogroup',\n onKeyDown,\n 'aria-invalid': state.isInvalid || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n 'aria-disabled': isDisabled || undefined,\n 'aria-orientation': orientation,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useRadioGroup.main.js.map"}