@react-aria/radio 3.2.0 → 3.3.1
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/main.js +5 -24
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -10
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +13 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -9
- package/src/index.ts +5 -3
- package/src/useRadio.ts +10 -4
- package/src/useRadioGroup.ts +4 -4
package/dist/main.js
CHANGED
|
@@ -4,28 +4,12 @@ var $fMEGB$reactariainteractions = require("@react-aria/interactions");
|
|
|
4
4
|
var $fMEGB$reactarialabel = require("@react-aria/label");
|
|
5
5
|
var $fMEGB$reactariai18n = require("@react-aria/i18n");
|
|
6
6
|
|
|
7
|
-
function $parcel$exportWildcard(dest, source) {
|
|
8
|
-
Object.keys(source).forEach(function(key) {
|
|
9
|
-
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(dest, key, {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function get() {
|
|
16
|
-
return source[key];
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
return dest;
|
|
22
|
-
}
|
|
23
7
|
function $parcel$export(e, n, v, s) {
|
|
24
8
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
25
9
|
}
|
|
26
|
-
var $e184702b1b7f1863$exports = {};
|
|
27
10
|
|
|
28
|
-
$parcel$export(
|
|
11
|
+
$parcel$export(module.exports, "useRadio", () => $e184702b1b7f1863$export$37b0961d2f4751e2);
|
|
12
|
+
$parcel$export(module.exports, "useRadioGroup", () => $dfcade00a56a6317$export$62b9571f283ff5c2);
|
|
29
13
|
|
|
30
14
|
const $eeb149278aae5c67$export$3b7b268d09480394 = new WeakMap();
|
|
31
15
|
|
|
@@ -65,14 +49,13 @@ function $e184702b1b7f1863$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
65
49
|
checked: checked,
|
|
66
50
|
value: value,
|
|
67
51
|
onChange: onChange
|
|
68
|
-
})
|
|
52
|
+
}),
|
|
53
|
+
isDisabled: isDisabled,
|
|
54
|
+
isSelected: checked
|
|
69
55
|
};
|
|
70
56
|
}
|
|
71
57
|
|
|
72
58
|
|
|
73
|
-
var $dfcade00a56a6317$exports = {};
|
|
74
|
-
|
|
75
|
-
$parcel$export($dfcade00a56a6317$exports, "useRadioGroup", () => $dfcade00a56a6317$export$62b9571f283ff5c2);
|
|
76
59
|
|
|
77
60
|
|
|
78
61
|
|
|
@@ -164,8 +147,6 @@ function $dfcade00a56a6317$export$62b9571f283ff5c2(props, state) {
|
|
|
164
147
|
}
|
|
165
148
|
|
|
166
149
|
|
|
167
|
-
$parcel$exportWildcard(module.exports, $e184702b1b7f1863$exports);
|
|
168
|
-
$parcel$exportWildcard(module.exports, $dfcade00a56a6317$exports);
|
|
169
150
|
|
|
170
151
|
|
|
171
152
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEcO,KAAK,CAAC,yCAAe,GAAG,GAAG,CAAC,OAAO;;;;;SDkB1B,yCAAQ,CAAC,KAAqB,EAAE,KAAsB,EAAE,GAA2B,EAAa,CAAC;IAC/G,GAAG,CAAC,CAAC,QACH,KAAK,aACL,QAAQ,GACR,CAAY,aAAE,SAAS,GACvB,CAAiB,kBAAE,cAAc,EACnC,CAAC,GAAG,KAAK;IAET,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU;IAEvD,GAAG,CAAC,WAAW,GAAG,QAAQ,IAAI,IAAI;IAClC,GAAG,CAAC,YAAY,GAAG,SAAS,IAAI,IAAI,IAAI,cAAc,IAAI,IAAI;IAC9D,EA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AE,UAAU,IAAI,SAAS;YACxC,CAAkB,mBAAE,WAAW;eAC5B,UAAU;eACV,gBAAgB;QACrB,CAAC;oBACD,UAAU;IACZ,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/utils.ts","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\nexport * from './useRadio';\nexport * from './useRadioGroup';\n","/*\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} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\ninterface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLElement>\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<HTMLElement>): 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} = usePress({\n isDisabled\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 = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange\n })\n };\n}\n","/*\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 {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\n","/*\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 {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: HTMLAttributes<HTMLElement>,\n /** Props for the radio group's visible label (if any). */\n labelProps: HTMLAttributes<HTMLElement>\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 validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps} = useLabel({\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 });\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() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\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 radioGroupNames.set(state, groupName);\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': validationState === 'invalid' || 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 };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AEcO,KAAK,CAAC,yCAAe,GAAG,GAAG,CAAC,OAAO;;;;;SDsB1B,yCAAQ,CAAC,KAAqB,EAAE,KAAsB,EAAE,GAAgC,EAAa,CAAC;IACpH,GAAG,CAAC,CAAC,QACH,KAAK,aACL,QAAQ,GACR,CAAY,aAAE,SAAS,GACvB,CAAiB,kBAAE,cAAc,EACnC,CAAC,GAAG,KAAK;IAET,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU;IAEvD,GAAG,CAAC,WAAW,GAAG,QAAQ,IAAI,IA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BAAE,KAAK,CAAC,CAAmB;YAC9C,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAkB,mBAAE,WAAW;eAC5B,UAAU;eACV,gBAAgB;QACrB,CAAC;oBACD,UAAU;IACZ,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/utils.ts","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 */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n","/*\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} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\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}\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>): 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} = usePress({\n isDisabled\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 = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange\n }),\n isDisabled,\n isSelected: checked\n };\n}\n","/*\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 {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\n","/*\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} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria {\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}\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 validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps} = useLabel({\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 });\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() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\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 radioGroupNames.set(state, groupName);\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': validationState === 'invalid' || 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 };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -4,12 +4,6 @@ import {usePress as $4vDl6$usePress, useFocusWithin as $4vDl6$useFocusWithin} fr
|
|
|
4
4
|
import {useLabel as $4vDl6$useLabel} from "@react-aria/label";
|
|
5
5
|
import {useLocale as $4vDl6$useLocale} from "@react-aria/i18n";
|
|
6
6
|
|
|
7
|
-
function $parcel$export(e, n, v, s) {
|
|
8
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
9
|
-
}
|
|
10
|
-
var $0d5c49892c1215da$exports = {};
|
|
11
|
-
|
|
12
|
-
$parcel$export($0d5c49892c1215da$exports, "useRadio", () => $0d5c49892c1215da$export$37b0961d2f4751e2);
|
|
13
7
|
|
|
14
8
|
const $884aeceb3d67f00f$export$3b7b268d09480394 = new WeakMap();
|
|
15
9
|
|
|
@@ -49,14 +43,13 @@ function $0d5c49892c1215da$export$37b0961d2f4751e2(props, state, ref) {
|
|
|
49
43
|
checked: checked,
|
|
50
44
|
value: value,
|
|
51
45
|
onChange: onChange
|
|
52
|
-
})
|
|
46
|
+
}),
|
|
47
|
+
isDisabled: isDisabled,
|
|
48
|
+
isSelected: checked
|
|
53
49
|
};
|
|
54
50
|
}
|
|
55
51
|
|
|
56
52
|
|
|
57
|
-
var $430f30ed08ec25fa$exports = {};
|
|
58
|
-
|
|
59
|
-
$parcel$export($430f30ed08ec25fa$exports, "useRadioGroup", () => $430f30ed08ec25fa$export$62b9571f283ff5c2);
|
|
60
53
|
|
|
61
54
|
|
|
62
55
|
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AEcO,KAAK,CAAC,yCAAe,GAAG,GAAG,CAAC,OAAO;;;;;SDkB1B,yCAAQ,CAAC,KAAqB,EAAE,KAAsB,EAAE,GAA2B,EAAa,CAAC;IAC/G,GAAG,CAAC,CAAC,QACH,KAAK,aACL,QAAQ,GACR,CAAY,aAAE,SAAS,GACvB,CAAiB,kBAAE,cAAc,EACnC,CAAC,GAAG,KAAK;IAET,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,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S,YAAI,SAAS;YAC1D,CAAmB,oBAAE,KAAK,CAAC,CAAmB;YAC9C,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAkB,mBAAE,WAAW;eAC5B,UAAU;eACV,gBAAgB;QACrB,CAAC;oBACD,UAAU;IACZ,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/utils.ts","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\nexport * from './useRadio';\nexport * from './useRadioGroup';\n","/*\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} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\ninterface RadioAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLElement>\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<HTMLElement>): 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} = usePress({\n isDisabled\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 = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange\n })\n };\n}\n","/*\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 {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\n","/*\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 {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {HTMLAttributes} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface RadioGroupAria {\n /** Props for the radio group wrapper element. */\n radioGroupProps: HTMLAttributes<HTMLElement>,\n /** Props for the radio group's visible label (if any). */\n labelProps: HTMLAttributes<HTMLElement>\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 validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps} = useLabel({\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 });\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() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\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 radioGroupNames.set(state, groupName);\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': validationState === 'invalid' || 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 };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;AEcO,KAAK,CAAC,yCAAe,GAAG,GAAG,CAAC,OAAO;;;;;SDsB1B,yCAAQ,CAAC,KAAqB,EAAE,KAAsB,EAAE,GAAgC,EAAa,CAAC;IACpH,GAAG,CAAC,CAAC,QACH,KAAK,aACL,QAAQ,GACR,CAAY,aAAE,SAAS,GACvB,CAAiB,kBAAE,cAAc,EAC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,CAAC;YACrC,EAAiD,AAAjD,+CAAiD;YACjD,IAAI,EAAE,CAAY;uBAClB,SAAS;YACT,CAAc,eAAE,eAAe,KAAK,CAAS,YAAI,SAAS;YAC1D,CAAmB,oBAAE,KAAK,CAAC,CAAmB;YAC9C,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAkB,mBAAE,WAAW;eAC5B,UAAU;eACV,gBAAgB;QACrB,CAAC;oBACD,UAAU;IACZ,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/radio/src/index.ts","packages/@react-aria/radio/src/useRadio.ts","packages/@react-aria/radio/src/utils.ts","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 */\nexport {useRadio} from './useRadio';\nexport {useRadioGroup} from './useRadioGroup';\nexport type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';\nexport type {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n","/*\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} from '@react-aria/utils';\nimport {InputHTMLAttributes, RefObject} from 'react';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface RadioAria {\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}\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>): 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} = usePress({\n isDisabled\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 = state.lastFocusedValue === value || state.lastFocusedValue == null ? 0 : -1;\n if (isDisabled) {\n tabIndex = undefined;\n }\n\n return {\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name: radioGroupNames.get(state),\n tabIndex,\n disabled: isDisabled,\n checked,\n value,\n onChange\n }),\n isDisabled,\n isSelected: checked\n };\n}\n","/*\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 {RadioGroupState} from '@react-stately/radio';\n\nexport const radioGroupNames = new WeakMap<RadioGroupState, string>();\n","/*\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} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {getFocusableTreeWalker} from '@react-aria/focus';\nimport {radioGroupNames} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {useFocusWithin} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\nexport interface RadioGroupAria {\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}\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 validationState,\n isReadOnly,\n isRequired,\n isDisabled,\n orientation = 'vertical'\n } = props;\n let {direction} = useLocale();\n\n let {labelProps, fieldProps} = useLabel({\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 });\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() {\n if (!state.selectedValue) {\n state.setLastFocusedValue(null);\n }\n }\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 radioGroupNames.set(state, groupName);\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': validationState === 'invalid' || 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 };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { AriaRadioProps, AriaRadioGroupProps } from "@react-types/radio";
|
|
2
|
-
import { InputHTMLAttributes, RefObject
|
|
2
|
+
import { InputHTMLAttributes, RefObject } from "react";
|
|
3
3
|
import { RadioGroupState } from "@react-stately/radio";
|
|
4
|
-
|
|
4
|
+
import { DOMAttributes } from "@react-types/shared";
|
|
5
|
+
export interface RadioAria {
|
|
5
6
|
/** Props for the input element. */
|
|
6
|
-
inputProps: InputHTMLAttributes<
|
|
7
|
+
inputProps: InputHTMLAttributes<HTMLInputElement>;
|
|
8
|
+
/** Whether the radio is disabled. */
|
|
9
|
+
isDisabled: boolean;
|
|
10
|
+
/** Whether the radio is currently selected. */
|
|
11
|
+
isSelected: boolean;
|
|
7
12
|
}
|
|
8
13
|
/**
|
|
9
14
|
* Provides the behavior and accessibility implementation for an individual
|
|
@@ -12,12 +17,12 @@ interface RadioAria {
|
|
|
12
17
|
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
13
18
|
* @param ref - Ref to the HTML input element.
|
|
14
19
|
*/
|
|
15
|
-
export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<
|
|
16
|
-
interface RadioGroupAria {
|
|
20
|
+
export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLInputElement>): RadioAria;
|
|
21
|
+
export interface RadioGroupAria {
|
|
17
22
|
/** Props for the radio group wrapper element. */
|
|
18
|
-
radioGroupProps:
|
|
23
|
+
radioGroupProps: DOMAttributes;
|
|
19
24
|
/** Props for the radio group's visible label (if any). */
|
|
20
|
-
labelProps:
|
|
25
|
+
labelProps: DOMAttributes;
|
|
21
26
|
}
|
|
22
27
|
/**
|
|
23
28
|
* Provides the behavior and accessibility implementation for a radio group component.
|
|
@@ -26,5 +31,6 @@ interface RadioGroupAria {
|
|
|
26
31
|
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
27
32
|
*/
|
|
28
33
|
export function useRadioGroup(props: AriaRadioGroupProps, state: RadioGroupState): RadioGroupAria;
|
|
34
|
+
export type { AriaRadioGroupProps, AriaRadioProps } from '@react-types/radio';
|
|
29
35
|
|
|
30
36
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;ACoBA;IACE,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAClD,qCAAqC;IACrC,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;GAMG;AACH,yBAAyB,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,UAAU,gBAAgB,CAAC,GAAG,SAAS,CAmDnH;ACjED;IACE,iDAAiD;IACjD,eAAe,EAAE,aAAa,CAAC;IAC/B,0DAA0D;IAC1D,UAAU,EAAE,aAAa,CAAA;CAC1B;AAED;;;;;GAKG;AACH,8BAA8B,KAAK,EAAE,mBAAmB,EAAE,KAAK,EAAE,eAAe,GAAG,cAAc,CAmGhG;ACzHD,YAAY,EAAC,mBAAmB,EAAE,cAAc,EAAC,MAAM,oBAAoB,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 {RadioAria} from './useRadio';\nexport type {RadioGroupAria} from './useRadioGroup';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/radio",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,13 +18,14 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-aria/focus": "^3.
|
|
22
|
-
"@react-aria/i18n": "^3.
|
|
23
|
-
"@react-aria/interactions": "^3.
|
|
24
|
-
"@react-aria/label": "^3.
|
|
25
|
-
"@react-aria/utils": "^3.13.
|
|
26
|
-
"@react-stately/radio": "^3.
|
|
27
|
-
"@react-types/radio": "^3.2.
|
|
21
|
+
"@react-aria/focus": "^3.8.0",
|
|
22
|
+
"@react-aria/i18n": "^3.6.0",
|
|
23
|
+
"@react-aria/interactions": "^3.11.0",
|
|
24
|
+
"@react-aria/label": "^3.4.1",
|
|
25
|
+
"@react-aria/utils": "^3.13.3",
|
|
26
|
+
"@react-stately/radio": "^3.5.1",
|
|
27
|
+
"@react-types/radio": "^3.2.3",
|
|
28
|
+
"@react-types/shared": "^3.14.1"
|
|
28
29
|
},
|
|
29
30
|
"peerDependencies": {
|
|
30
31
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
@@ -32,5 +33,5 @@
|
|
|
32
33
|
"publishConfig": {
|
|
33
34
|
"access": "public"
|
|
34
35
|
},
|
|
35
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "b03ef51e6317547dd0a840f151e59d039b1e1fd3"
|
|
36
37
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
export
|
|
12
|
+
export {useRadio} from './useRadio';
|
|
13
|
+
export {useRadioGroup} from './useRadioGroup';
|
|
14
|
+
export type {AriaRadioGroupProps, AriaRadioProps} from '@react-types/radio';
|
|
15
|
+
export type {RadioAria} from './useRadio';
|
|
16
|
+
export type {RadioGroupAria} from './useRadioGroup';
|
package/src/useRadio.ts
CHANGED
|
@@ -18,9 +18,13 @@ import {RadioGroupState} from '@react-stately/radio';
|
|
|
18
18
|
import {useFocusable} from '@react-aria/focus';
|
|
19
19
|
import {usePress} from '@react-aria/interactions';
|
|
20
20
|
|
|
21
|
-
interface RadioAria {
|
|
21
|
+
export interface RadioAria {
|
|
22
22
|
/** Props for the input element. */
|
|
23
|
-
inputProps: InputHTMLAttributes<
|
|
23
|
+
inputProps: InputHTMLAttributes<HTMLInputElement>,
|
|
24
|
+
/** Whether the radio is disabled. */
|
|
25
|
+
isDisabled: boolean,
|
|
26
|
+
/** Whether the radio is currently selected. */
|
|
27
|
+
isSelected: boolean
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
/**
|
|
@@ -30,7 +34,7 @@ interface RadioAria {
|
|
|
30
34
|
* @param state - State for the radio group, as returned by `useRadioGroupState`.
|
|
31
35
|
* @param ref - Ref to the HTML input element.
|
|
32
36
|
*/
|
|
33
|
-
export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<
|
|
37
|
+
export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: RefObject<HTMLInputElement>): RadioAria {
|
|
34
38
|
let {
|
|
35
39
|
value,
|
|
36
40
|
children,
|
|
@@ -77,6 +81,8 @@ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: Ref
|
|
|
77
81
|
checked,
|
|
78
82
|
value,
|
|
79
83
|
onChange
|
|
80
|
-
})
|
|
84
|
+
}),
|
|
85
|
+
isDisabled,
|
|
86
|
+
isSelected: checked
|
|
81
87
|
};
|
|
82
88
|
}
|
package/src/useRadioGroup.ts
CHANGED
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import {AriaRadioGroupProps} from '@react-types/radio';
|
|
14
|
+
import {DOMAttributes} from '@react-types/shared';
|
|
14
15
|
import {filterDOMProps, mergeProps, useId} from '@react-aria/utils';
|
|
15
16
|
import {getFocusableTreeWalker} from '@react-aria/focus';
|
|
16
|
-
import {HTMLAttributes} from 'react';
|
|
17
17
|
import {radioGroupNames} from './utils';
|
|
18
18
|
import {RadioGroupState} from '@react-stately/radio';
|
|
19
19
|
import {useFocusWithin} from '@react-aria/interactions';
|
|
20
20
|
import {useLabel} from '@react-aria/label';
|
|
21
21
|
import {useLocale} from '@react-aria/i18n';
|
|
22
22
|
|
|
23
|
-
interface RadioGroupAria {
|
|
23
|
+
export interface RadioGroupAria {
|
|
24
24
|
/** Props for the radio group wrapper element. */
|
|
25
|
-
radioGroupProps:
|
|
25
|
+
radioGroupProps: DOMAttributes,
|
|
26
26
|
/** Props for the radio group's visible label (if any). */
|
|
27
|
-
labelProps:
|
|
27
|
+
labelProps: DOMAttributes
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
/**
|