@react-aria/radio 3.12.5 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +2 -4
- package/dist/main.js +3 -5
- package/dist/main.js.map +1 -1
- package/dist/module.js +2 -4
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +3 -0
- package/package.json +16 -20
- package/src/index.ts +3 -5
- package/dist/types.d.ts +0 -45
- package/dist/types.d.ts.map +0 -1
- package/dist/useRadio.main.js +0 -112
- package/dist/useRadio.main.js.map +0 -1
- package/dist/useRadio.mjs +0 -107
- package/dist/useRadio.module.js +0 -107
- package/dist/useRadio.module.js.map +0 -1
- package/dist/useRadioGroup.main.js +0 -134
- package/dist/useRadioGroup.main.js.map +0 -1
- package/dist/useRadioGroup.mjs +0 -129
- package/dist/useRadioGroup.module.js +0 -129
- package/dist/useRadioGroup.module.js.map +0 -1
- package/dist/utils.main.js +0 -20
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -15
- package/dist/utils.module.js +0 -15
- package/dist/utils.module.js.map +0 -1
- package/src/useRadio.ts +0 -149
- package/src/useRadioGroup.ts +0 -160
- package/src/utils.ts +0 -23
package/dist/import.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {useRadio as $
|
|
2
|
-
import {useRadioGroup as $430f30ed08ec25fa$export$62b9571f283ff5c2} from "./useRadioGroup.mjs";
|
|
1
|
+
import {useRadio as $93583b4cb5135f71$re_export$useRadio, useRadioGroup as $93583b4cb5135f71$re_export$useRadioGroup} from "react-aria/useRadioGroup";
|
|
3
2
|
|
|
4
3
|
/*
|
|
5
4
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -14,6 +13,5 @@ import {useRadioGroup as $430f30ed08ec25fa$export$62b9571f283ff5c2} from "./useR
|
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
export {$0d5c49892c1215da$export$37b0961d2f4751e2 as useRadio, $430f30ed08ec25fa$export$62b9571f283ff5c2 as useRadioGroup};
|
|
16
|
+
export {$93583b4cb5135f71$re_export$useRadio as useRadio, $93583b4cb5135f71$re_export$useRadioGroup as useRadioGroup};
|
|
19
17
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $dfcade00a56a6317$exports = require("./useRadioGroup.main.js");
|
|
1
|
+
var $dMbJt$reactariauseRadioGroup = require("react-aria/useRadioGroup");
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
function $parcel$export(e, n, v, s) {
|
|
6
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
6
|
}
|
|
8
7
|
|
|
9
|
-
$parcel$export(module.exports, "useRadio", ()
|
|
10
|
-
$parcel$export(module.exports, "useRadioGroup", ()
|
|
8
|
+
$parcel$export(module.exports, "useRadio", function () { return $dMbJt$reactariauseRadioGroup.useRadio; });
|
|
9
|
+
$parcel$export(module.exports, "useRadioGroup", function () { return $dMbJt$reactariauseRadioGroup.useRadioGroup; });
|
|
11
10
|
/*
|
|
12
11
|
* Copyright 2020 Adobe. All rights reserved.
|
|
13
12
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -21,5 +20,4 @@ $parcel$export(module.exports, "useRadioGroup", () => $dfcade00a56a6317$exports.
|
|
|
21
20
|
*/
|
|
22
21
|
|
|
23
22
|
|
|
24
|
-
|
|
25
23
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
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, useRadioGroup} from 'react-aria/useRadioGroup';\n\nexport type {RadioProps, AriaRadioProps, RadioAria, AriaRadioGroupProps, RadioGroupAria} from 'react-aria/useRadioGroup';\nexport type {Orientation} from '@react-types/shared';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {useRadio as $
|
|
2
|
-
import {useRadioGroup as $430f30ed08ec25fa$export$62b9571f283ff5c2} from "./useRadioGroup.module.js";
|
|
1
|
+
import {useRadio as $93583b4cb5135f71$re_export$useRadio, useRadioGroup as $93583b4cb5135f71$re_export$useRadioGroup} from "react-aria/useRadioGroup";
|
|
3
2
|
|
|
4
3
|
/*
|
|
5
4
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -14,6 +13,5 @@ import {useRadioGroup as $430f30ed08ec25fa$export$62b9571f283ff5c2} from "./useR
|
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
export {$0d5c49892c1215da$export$37b0961d2f4751e2 as useRadio, $430f30ed08ec25fa$export$62b9571f283ff5c2 as useRadioGroup};
|
|
16
|
+
export {$93583b4cb5135f71$re_export$useRadio as useRadio, $93583b4cb5135f71$re_export$useRadioGroup as useRadioGroup};
|
|
19
17
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
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, useRadioGroup} from 'react-aria/useRadioGroup';\n\nexport type {RadioProps, AriaRadioProps, RadioAria, AriaRadioGroupProps, RadioGroupAria} from 'react-aria/useRadioGroup';\nexport type {Orientation} from '@react-types/shared';\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/radio",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
8
|
"exports": {
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
"./dist/types.d.ts",
|
|
12
|
-
"./
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
9
|
+
".": {
|
|
10
|
+
"source": "./src/index.ts",
|
|
11
|
+
"types": "./dist/types/src/index.d.ts",
|
|
12
|
+
"import": "./dist/import.mjs",
|
|
13
|
+
"require": "./dist/main.js"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
16
|
},
|
|
17
|
-
"types": "dist/types.d.ts",
|
|
17
|
+
"types": "dist/types/src/index.d.ts",
|
|
18
18
|
"source": "src/index.ts",
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
@@ -26,16 +26,9 @@
|
|
|
26
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@react-
|
|
30
|
-
"@
|
|
31
|
-
"
|
|
32
|
-
"@react-aria/interactions": "^3.27.1",
|
|
33
|
-
"@react-aria/label": "^3.7.25",
|
|
34
|
-
"@react-aria/utils": "^3.33.1",
|
|
35
|
-
"@react-stately/radio": "^3.11.5",
|
|
36
|
-
"@react-types/radio": "^3.9.4",
|
|
37
|
-
"@react-types/shared": "^3.33.1",
|
|
38
|
-
"@swc/helpers": "^0.5.0"
|
|
29
|
+
"@react-types/shared": "^3.34.0",
|
|
30
|
+
"@swc/helpers": "^0.5.0",
|
|
31
|
+
"react-aria": "3.48.0"
|
|
39
32
|
},
|
|
40
33
|
"peerDependencies": {
|
|
41
34
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
@@ -44,5 +37,8 @@
|
|
|
44
37
|
"publishConfig": {
|
|
45
38
|
"access": "public"
|
|
46
39
|
},
|
|
47
|
-
"
|
|
40
|
+
"targets": {
|
|
41
|
+
"types": false
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
|
|
48
44
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,7 @@
|
|
|
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
|
-
export {useRadio} from '
|
|
13
|
-
|
|
14
|
-
export type {AriaRadioGroupProps,
|
|
12
|
+
export {useRadio, useRadioGroup} from 'react-aria/useRadioGroup';
|
|
13
|
+
|
|
14
|
+
export type {RadioProps, AriaRadioProps, RadioAria, AriaRadioGroupProps, RadioGroupAria} from 'react-aria/useRadioGroup';
|
|
15
15
|
export type {Orientation} from '@react-types/shared';
|
|
16
|
-
export type {RadioAria} from './useRadio';
|
|
17
|
-
export type {RadioGroupAria} from './useRadioGroup';
|
package/dist/types.d.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;ACqBA;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,CA2G1H;AC9HD,+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,CAwHhG;AClJD,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"}
|
package/dist/useRadio.main.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
var $eeb149278aae5c67$exports = require("./utils.main.js");
|
|
2
|
-
var $gWC9A$reactariautils = require("@react-aria/utils");
|
|
3
|
-
var $gWC9A$react = require("react");
|
|
4
|
-
var $gWC9A$reactariainteractions = require("@react-aria/interactions");
|
|
5
|
-
var $gWC9A$reactariaform = require("@react-aria/form");
|
|
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, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressChange: onPressChange, onPress: onPress, onPressUp: onPressUp, onClick: onClick } = props;
|
|
30
|
-
const isDisabled = props.isDisabled || state.isDisabled;
|
|
31
|
-
let hasChildren = children != null;
|
|
32
|
-
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
33
|
-
if (!hasChildren && !hasAriaLabel && process.env.NODE_ENV !== 'production') 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
|
-
// Handle press state for keyboard interactions and cases where labelProps is not used.
|
|
40
|
-
let { pressProps: pressProps, isPressed: isPressed } = (0, $gWC9A$reactariainteractions.usePress)({
|
|
41
|
-
onPressStart: onPressStart,
|
|
42
|
-
onPressEnd: onPressEnd,
|
|
43
|
-
onPressChange: onPressChange,
|
|
44
|
-
onPress: onPress,
|
|
45
|
-
onPressUp: onPressUp,
|
|
46
|
-
onClick: onClick,
|
|
47
|
-
isDisabled: isDisabled
|
|
48
|
-
});
|
|
49
|
-
// Handle press state on the label.
|
|
50
|
-
let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $gWC9A$reactariainteractions.usePress)({
|
|
51
|
-
onPressStart: onPressStart,
|
|
52
|
-
onPressEnd: onPressEnd,
|
|
53
|
-
onPressChange: onPressChange,
|
|
54
|
-
onPressUp: onPressUp,
|
|
55
|
-
onClick: onClick,
|
|
56
|
-
isDisabled: isDisabled,
|
|
57
|
-
onPress (e) {
|
|
58
|
-
var _ref_current;
|
|
59
|
-
onPress === null || onPress === void 0 ? void 0 : onPress(e);
|
|
60
|
-
state.setSelectedValue(value);
|
|
61
|
-
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
let { focusableProps: focusableProps } = (0, $gWC9A$reactariainteractions.useFocusable)((0, $gWC9A$reactariautils.mergeProps)(props, {
|
|
65
|
-
onFocus: ()=>state.setLastFocusedValue(value)
|
|
66
|
-
}), ref);
|
|
67
|
-
let interactions = (0, $gWC9A$reactariautils.mergeProps)(pressProps, focusableProps);
|
|
68
|
-
let domProps = (0, $gWC9A$reactariautils.filterDOMProps)(props, {
|
|
69
|
-
labelable: true
|
|
70
|
-
});
|
|
71
|
-
let tabIndex = -1;
|
|
72
|
-
if (state.selectedValue != null) {
|
|
73
|
-
if (state.selectedValue === value) tabIndex = 0;
|
|
74
|
-
} else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
|
|
75
|
-
if (isDisabled) tabIndex = undefined;
|
|
76
|
-
let { name: name, form: form, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $eeb149278aae5c67$exports.radioGroupData).get(state);
|
|
77
|
-
(0, $gWC9A$reactariautils.useFormReset)(ref, state.defaultSelectedValue, state.setSelectedValue);
|
|
78
|
-
(0, $gWC9A$reactariaform.useFormValidation)({
|
|
79
|
-
validationBehavior: validationBehavior
|
|
80
|
-
}, state, ref);
|
|
81
|
-
return {
|
|
82
|
-
labelProps: (0, $gWC9A$reactariautils.mergeProps)(labelProps, (0, $gWC9A$react.useMemo)(()=>({
|
|
83
|
-
onClick: (e)=>e.preventDefault(),
|
|
84
|
-
// Prevent label from being focused when mouse down on it.
|
|
85
|
-
// Note, this does not prevent the input from being focused in the `click` event.
|
|
86
|
-
onMouseDown: (e)=>e.preventDefault()
|
|
87
|
-
}), [])),
|
|
88
|
-
inputProps: (0, $gWC9A$reactariautils.mergeProps)(domProps, {
|
|
89
|
-
...interactions,
|
|
90
|
-
type: 'radio',
|
|
91
|
-
name: name,
|
|
92
|
-
form: form,
|
|
93
|
-
tabIndex: tabIndex,
|
|
94
|
-
disabled: isDisabled,
|
|
95
|
-
required: state.isRequired && validationBehavior === 'native',
|
|
96
|
-
checked: checked,
|
|
97
|
-
value: value,
|
|
98
|
-
onChange: onChange,
|
|
99
|
-
'aria-describedby': [
|
|
100
|
-
props['aria-describedby'],
|
|
101
|
-
state.isInvalid ? errorMessageId : null,
|
|
102
|
-
descriptionId
|
|
103
|
-
].filter(Boolean).join(' ') || undefined
|
|
104
|
-
}),
|
|
105
|
-
isDisabled: isDisabled,
|
|
106
|
-
isSelected: checked,
|
|
107
|
-
isPressed: isPressed || isLabelPressed
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
//# sourceMappingURL=useRadio.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+BM,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAuC;IAC7G,IAAI,SACF,KAAK,YACL,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,gBACjC,YAAY,cACZ,UAAU,iBACV,aAAa,WACb,OAAO,aACP,SAAS,WACT,OAAO,EACR,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;IAEvD,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,gBAAgB,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAC5D,QAAQ,IAAI,CAAC;IAGf,IAAI,UAAU,MAAM,aAAa,KAAK;IAEtC,IAAI,WAAW,CAAC;QACd,EAAE,eAAe;QACjB,MAAM,gBAAgB,CAAC;IACzB;IAEA,uFAAuF;IACvF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;sBACrC;oBACA;uBACA;iBACA;mBACA;iBACA;oBACA;IACF;IAEA,mCAAmC;IACnC,IAAI,EAAC,YAAY,UAAU,EAAE,WAAW,cAAc,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;sBACjE;oBACA;uBACA;mBACA;iBACA;oBACA;QACA,SAAQ,CAAC;gBAGP;YAFA,oBAAA,8BAAA,QAAU;YACV,MAAM,gBAAgB,CAAC;aACvB,eAAA,IAAI,OAAO,cAAX,mCAAA,aAAa,KAAK;QACpB;IACF;IAEA,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,yCAAW,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,QAAE,IAAI,iBAAE,aAAa,kBAAE,cAAc,sBAAE,kBAAkB,EAAC,GAAG,CAAA,GAAA,wCAAa,EAAE,GAAG,CAAC;IACzF,CAAA,GAAA,kCAAW,EAAE,KAAK,MAAM,oBAAoB,EAAE,MAAM,gBAAgB;IACpE,CAAA,GAAA,sCAAgB,EAAE;4BAAC;IAAkB,GAAG,OAAO;IAE/C,OAAO;QACL,YAAY,CAAA,GAAA,gCAAS,EACnB,YACA,CAAA,GAAA,oBAAM,EAAE,IAAO,CAAA;gBACb,SAAS,CAAA,IAAK,EAAE,cAAc;gBAE9B,0DAA0D;gBAC1D,iFAAiF;gBACjF,aAAa,CAAA,IAAK,EAAE,cAAc;YACpC,CAAA,GAAI,EAAE;QACR,YAAY,CAAA,GAAA,gCAAS,EAAE,UAAU;YAC/B,GAAG,YAAY;YACf,MAAM;kBACN;kBACA;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, useMemo} from 'react';\nimport {radioGroupData} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {RefObject} from '@react-types/shared';\nimport {useFocusable, usePress} from '@react-aria/interactions';\nimport {useFormValidation} from '@react-aria/form';\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 onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick\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 && process.env.NODE_ENV !== 'production') {\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 // Handle press state for keyboard interactions and cases where labelProps is not used.\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick,\n isDisabled\n });\n\n // Handle press state on the label.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPressUp,\n onClick,\n isDisabled,\n onPress(e) {\n onPress?.(e);\n state.setSelectedValue(value);\n ref.current?.focus();\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, form, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;\n useFormReset(ref, state.defaultSelectedValue, state.setSelectedValue);\n useFormValidation({validationBehavior}, state, ref);\n\n return {\n labelProps: mergeProps(\n labelProps,\n useMemo(() => ({\n onClick: e => e.preventDefault(),\n\n // Prevent label from being focused when mouse down on it.\n // Note, this does not prevent the input from being focused in the `click` event.\n onMouseDown: e => e.preventDefault()\n }), [])),\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name,\n form,\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"}
|
package/dist/useRadio.mjs
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
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 {useMemo as $5jJ3f$useMemo} from "react";
|
|
4
|
-
import {usePress as $5jJ3f$usePress, useFocusable as $5jJ3f$useFocusable} from "@react-aria/interactions";
|
|
5
|
-
import {useFormValidation as $5jJ3f$useFormValidation} from "@react-aria/form";
|
|
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, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressChange: onPressChange, onPress: onPress, onPressUp: onPressUp, onClick: onClick } = props;
|
|
24
|
-
const isDisabled = props.isDisabled || state.isDisabled;
|
|
25
|
-
let hasChildren = children != null;
|
|
26
|
-
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
27
|
-
if (!hasChildren && !hasAriaLabel && process.env.NODE_ENV !== 'production') 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
|
-
// Handle press state for keyboard interactions and cases where labelProps is not used.
|
|
34
|
-
let { pressProps: pressProps, isPressed: isPressed } = (0, $5jJ3f$usePress)({
|
|
35
|
-
onPressStart: onPressStart,
|
|
36
|
-
onPressEnd: onPressEnd,
|
|
37
|
-
onPressChange: onPressChange,
|
|
38
|
-
onPress: onPress,
|
|
39
|
-
onPressUp: onPressUp,
|
|
40
|
-
onClick: onClick,
|
|
41
|
-
isDisabled: isDisabled
|
|
42
|
-
});
|
|
43
|
-
// Handle press state on the label.
|
|
44
|
-
let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $5jJ3f$usePress)({
|
|
45
|
-
onPressStart: onPressStart,
|
|
46
|
-
onPressEnd: onPressEnd,
|
|
47
|
-
onPressChange: onPressChange,
|
|
48
|
-
onPressUp: onPressUp,
|
|
49
|
-
onClick: onClick,
|
|
50
|
-
isDisabled: isDisabled,
|
|
51
|
-
onPress (e) {
|
|
52
|
-
var _ref_current;
|
|
53
|
-
onPress === null || onPress === void 0 ? void 0 : onPress(e);
|
|
54
|
-
state.setSelectedValue(value);
|
|
55
|
-
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
let { focusableProps: focusableProps } = (0, $5jJ3f$useFocusable)((0, $5jJ3f$mergeProps)(props, {
|
|
59
|
-
onFocus: ()=>state.setLastFocusedValue(value)
|
|
60
|
-
}), ref);
|
|
61
|
-
let interactions = (0, $5jJ3f$mergeProps)(pressProps, focusableProps);
|
|
62
|
-
let domProps = (0, $5jJ3f$filterDOMProps)(props, {
|
|
63
|
-
labelable: true
|
|
64
|
-
});
|
|
65
|
-
let tabIndex = -1;
|
|
66
|
-
if (state.selectedValue != null) {
|
|
67
|
-
if (state.selectedValue === value) tabIndex = 0;
|
|
68
|
-
} else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
|
|
69
|
-
if (isDisabled) tabIndex = undefined;
|
|
70
|
-
let { name: name, form: form, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $884aeceb3d67f00f$export$37b65e5b5444d35c).get(state);
|
|
71
|
-
(0, $5jJ3f$useFormReset)(ref, state.defaultSelectedValue, state.setSelectedValue);
|
|
72
|
-
(0, $5jJ3f$useFormValidation)({
|
|
73
|
-
validationBehavior: validationBehavior
|
|
74
|
-
}, state, ref);
|
|
75
|
-
return {
|
|
76
|
-
labelProps: (0, $5jJ3f$mergeProps)(labelProps, (0, $5jJ3f$useMemo)(()=>({
|
|
77
|
-
onClick: (e)=>e.preventDefault(),
|
|
78
|
-
// Prevent label from being focused when mouse down on it.
|
|
79
|
-
// Note, this does not prevent the input from being focused in the `click` event.
|
|
80
|
-
onMouseDown: (e)=>e.preventDefault()
|
|
81
|
-
}), [])),
|
|
82
|
-
inputProps: (0, $5jJ3f$mergeProps)(domProps, {
|
|
83
|
-
...interactions,
|
|
84
|
-
type: 'radio',
|
|
85
|
-
name: name,
|
|
86
|
-
form: form,
|
|
87
|
-
tabIndex: tabIndex,
|
|
88
|
-
disabled: isDisabled,
|
|
89
|
-
required: state.isRequired && validationBehavior === 'native',
|
|
90
|
-
checked: checked,
|
|
91
|
-
value: value,
|
|
92
|
-
onChange: onChange,
|
|
93
|
-
'aria-describedby': [
|
|
94
|
-
props['aria-describedby'],
|
|
95
|
-
state.isInvalid ? errorMessageId : null,
|
|
96
|
-
descriptionId
|
|
97
|
-
].filter(Boolean).join(' ') || undefined
|
|
98
|
-
}),
|
|
99
|
-
isDisabled: isDisabled,
|
|
100
|
-
isSelected: checked,
|
|
101
|
-
isPressed: isPressed || isLabelPressed
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
export {$0d5c49892c1215da$export$37b0961d2f4751e2 as useRadio};
|
|
107
|
-
//# sourceMappingURL=useRadio.module.js.map
|
package/dist/useRadio.module.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
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 {useMemo as $5jJ3f$useMemo} from "react";
|
|
4
|
-
import {usePress as $5jJ3f$usePress, useFocusable as $5jJ3f$useFocusable} from "@react-aria/interactions";
|
|
5
|
-
import {useFormValidation as $5jJ3f$useFormValidation} from "@react-aria/form";
|
|
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, onPressStart: onPressStart, onPressEnd: onPressEnd, onPressChange: onPressChange, onPress: onPress, onPressUp: onPressUp, onClick: onClick } = props;
|
|
24
|
-
const isDisabled = props.isDisabled || state.isDisabled;
|
|
25
|
-
let hasChildren = children != null;
|
|
26
|
-
let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
|
|
27
|
-
if (!hasChildren && !hasAriaLabel && process.env.NODE_ENV !== 'production') 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
|
-
// Handle press state for keyboard interactions and cases where labelProps is not used.
|
|
34
|
-
let { pressProps: pressProps, isPressed: isPressed } = (0, $5jJ3f$usePress)({
|
|
35
|
-
onPressStart: onPressStart,
|
|
36
|
-
onPressEnd: onPressEnd,
|
|
37
|
-
onPressChange: onPressChange,
|
|
38
|
-
onPress: onPress,
|
|
39
|
-
onPressUp: onPressUp,
|
|
40
|
-
onClick: onClick,
|
|
41
|
-
isDisabled: isDisabled
|
|
42
|
-
});
|
|
43
|
-
// Handle press state on the label.
|
|
44
|
-
let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $5jJ3f$usePress)({
|
|
45
|
-
onPressStart: onPressStart,
|
|
46
|
-
onPressEnd: onPressEnd,
|
|
47
|
-
onPressChange: onPressChange,
|
|
48
|
-
onPressUp: onPressUp,
|
|
49
|
-
onClick: onClick,
|
|
50
|
-
isDisabled: isDisabled,
|
|
51
|
-
onPress (e) {
|
|
52
|
-
var _ref_current;
|
|
53
|
-
onPress === null || onPress === void 0 ? void 0 : onPress(e);
|
|
54
|
-
state.setSelectedValue(value);
|
|
55
|
-
(_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.focus();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
let { focusableProps: focusableProps } = (0, $5jJ3f$useFocusable)((0, $5jJ3f$mergeProps)(props, {
|
|
59
|
-
onFocus: ()=>state.setLastFocusedValue(value)
|
|
60
|
-
}), ref);
|
|
61
|
-
let interactions = (0, $5jJ3f$mergeProps)(pressProps, focusableProps);
|
|
62
|
-
let domProps = (0, $5jJ3f$filterDOMProps)(props, {
|
|
63
|
-
labelable: true
|
|
64
|
-
});
|
|
65
|
-
let tabIndex = -1;
|
|
66
|
-
if (state.selectedValue != null) {
|
|
67
|
-
if (state.selectedValue === value) tabIndex = 0;
|
|
68
|
-
} else if (state.lastFocusedValue === value || state.lastFocusedValue == null) tabIndex = 0;
|
|
69
|
-
if (isDisabled) tabIndex = undefined;
|
|
70
|
-
let { name: name, form: form, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $884aeceb3d67f00f$export$37b65e5b5444d35c).get(state);
|
|
71
|
-
(0, $5jJ3f$useFormReset)(ref, state.defaultSelectedValue, state.setSelectedValue);
|
|
72
|
-
(0, $5jJ3f$useFormValidation)({
|
|
73
|
-
validationBehavior: validationBehavior
|
|
74
|
-
}, state, ref);
|
|
75
|
-
return {
|
|
76
|
-
labelProps: (0, $5jJ3f$mergeProps)(labelProps, (0, $5jJ3f$useMemo)(()=>({
|
|
77
|
-
onClick: (e)=>e.preventDefault(),
|
|
78
|
-
// Prevent label from being focused when mouse down on it.
|
|
79
|
-
// Note, this does not prevent the input from being focused in the `click` event.
|
|
80
|
-
onMouseDown: (e)=>e.preventDefault()
|
|
81
|
-
}), [])),
|
|
82
|
-
inputProps: (0, $5jJ3f$mergeProps)(domProps, {
|
|
83
|
-
...interactions,
|
|
84
|
-
type: 'radio',
|
|
85
|
-
name: name,
|
|
86
|
-
form: form,
|
|
87
|
-
tabIndex: tabIndex,
|
|
88
|
-
disabled: isDisabled,
|
|
89
|
-
required: state.isRequired && validationBehavior === 'native',
|
|
90
|
-
checked: checked,
|
|
91
|
-
value: value,
|
|
92
|
-
onChange: onChange,
|
|
93
|
-
'aria-describedby': [
|
|
94
|
-
props['aria-describedby'],
|
|
95
|
-
state.isInvalid ? errorMessageId : null,
|
|
96
|
-
descriptionId
|
|
97
|
-
].filter(Boolean).join(' ') || undefined
|
|
98
|
-
}),
|
|
99
|
-
isDisabled: isDisabled,
|
|
100
|
-
isSelected: checked,
|
|
101
|
-
isPressed: isPressed || isLabelPressed
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
export {$0d5c49892c1215da$export$37b0961d2f4751e2 as useRadio};
|
|
107
|
-
//# sourceMappingURL=useRadio.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+BM,SAAS,0CAAS,KAAqB,EAAE,KAAsB,EAAE,GAAuC;IAC7G,IAAI,SACF,KAAK,YACL,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,gBACjC,YAAY,cACZ,UAAU,iBACV,aAAa,WACb,OAAO,aACP,SAAS,WACT,OAAO,EACR,GAAG;IAEJ,MAAM,aAAa,MAAM,UAAU,IAAI,MAAM,UAAU;IAEvD,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,gBAAgB,QAAQ,GAAG,CAAC,QAAQ,KAAK,cAC5D,QAAQ,IAAI,CAAC;IAGf,IAAI,UAAU,MAAM,aAAa,KAAK;IAEtC,IAAI,WAAW,CAAC;QACd,EAAE,eAAe;QACjB,MAAM,gBAAgB,CAAC;IACzB;IAEA,uFAAuF;IACvF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;sBACrC;oBACA;uBACA;iBACA;mBACA;iBACA;oBACA;IACF;IAEA,mCAAmC;IACnC,IAAI,EAAC,YAAY,UAAU,EAAE,WAAW,cAAc,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;sBACjE;oBACA;uBACA;mBACA;iBACA;oBACA;QACA,SAAQ,CAAC;gBAGP;YAFA,oBAAA,8BAAA,QAAU;YACV,MAAM,gBAAgB,CAAC;aACvB,eAAA,IAAI,OAAO,cAAX,mCAAA,aAAa,KAAK;QACpB;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,QAAE,IAAI,iBAAE,aAAa,kBAAE,cAAc,sBAAE,kBAAkB,EAAC,GAAG,CAAA,GAAA,yCAAa,EAAE,GAAG,CAAC;IACzF,CAAA,GAAA,mBAAW,EAAE,KAAK,MAAM,oBAAoB,EAAE,MAAM,gBAAgB;IACpE,CAAA,GAAA,wBAAgB,EAAE;4BAAC;IAAkB,GAAG,OAAO;IAE/C,OAAO;QACL,YAAY,CAAA,GAAA,iBAAS,EACnB,YACA,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;gBACb,SAAS,CAAA,IAAK,EAAE,cAAc;gBAE9B,0DAA0D;gBAC1D,iFAAiF;gBACjF,aAAa,CAAA,IAAK,EAAE,cAAc;YACpC,CAAA,GAAI,EAAE;QACR,YAAY,CAAA,GAAA,iBAAS,EAAE,UAAU;YAC/B,GAAG,YAAY;YACf,MAAM;kBACN;kBACA;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, useMemo} from 'react';\nimport {radioGroupData} from './utils';\nimport {RadioGroupState} from '@react-stately/radio';\nimport {RefObject} from '@react-types/shared';\nimport {useFocusable, usePress} from '@react-aria/interactions';\nimport {useFormValidation} from '@react-aria/form';\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 onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick\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 && process.env.NODE_ENV !== 'production') {\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 // Handle press state for keyboard interactions and cases where labelProps is not used.\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n onPressUp,\n onClick,\n isDisabled\n });\n\n // Handle press state on the label.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPressUp,\n onClick,\n isDisabled,\n onPress(e) {\n onPress?.(e);\n state.setSelectedValue(value);\n ref.current?.focus();\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, form, descriptionId, errorMessageId, validationBehavior} = radioGroupData.get(state)!;\n useFormReset(ref, state.defaultSelectedValue, state.setSelectedValue);\n useFormValidation({validationBehavior}, state, ref);\n\n return {\n labelProps: mergeProps(\n labelProps,\n useMemo(() => ({\n onClick: e => e.preventDefault(),\n\n // Prevent label from being focused when mouse down on it.\n // Note, this does not prevent the input from being focused in the `click` event.\n onMouseDown: e => e.preventDefault()\n }), [])),\n inputProps: mergeProps(domProps, {\n ...interactions,\n type: 'radio',\n name,\n form,\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"}
|