@react-stately/radio 3.10.2 → 3.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +1 -52
- package/dist/main.js +2 -53
- package/dist/main.js.map +1 -1
- package/dist/module.js +1 -52
- package/dist/module.js.map +1 -1
- package/dist/useRadioGroupState.main.js +61 -0
- package/dist/useRadioGroupState.main.js.map +1 -0
- package/dist/useRadioGroupState.mjs +56 -0
- package/dist/useRadioGroupState.module.js +56 -0
- package/dist/useRadioGroupState.module.js.map +1 -0
- package/package.json +6 -6
package/dist/import.mjs
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {useControlledState as $fQ2SF$useControlledState} from "@react-stately/utils";
|
|
3
|
-
import {useMemo as $fQ2SF$useMemo, useState as $fQ2SF$useState} from "react";
|
|
1
|
+
import {useRadioGroupState as $a54cdc5c1942b639$export$bca9d026f8e704eb} from "./useRadioGroupState.mjs";
|
|
4
2
|
|
|
5
3
|
/*
|
|
6
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
-
* governing permissions and limitations under the License.
|
|
15
|
-
*/ /*
|
|
16
4
|
* Copyright 2020 Adobe. All rights reserved.
|
|
17
5
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
18
6
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -25,44 +13,5 @@ import {useMemo as $fQ2SF$useMemo, useState as $fQ2SF$useState} from "react";
|
|
|
25
13
|
*/
|
|
26
14
|
|
|
27
15
|
|
|
28
|
-
let $a54cdc5c1942b639$var$instance = Math.round(Math.random() * 10000000000);
|
|
29
|
-
let $a54cdc5c1942b639$var$i = 0;
|
|
30
|
-
function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
31
|
-
// Preserved here for backward compatibility. React Aria now generates the name instead of stately.
|
|
32
|
-
let name = (0, $fQ2SF$useMemo)(()=>props.name || `radio-group-${$a54cdc5c1942b639$var$instance}-${++$a54cdc5c1942b639$var$i}`, [
|
|
33
|
-
props.name
|
|
34
|
-
]);
|
|
35
|
-
var _props_defaultValue;
|
|
36
|
-
let [selectedValue, setSelected] = (0, $fQ2SF$useControlledState)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
37
|
-
let [lastFocusedValue, setLastFocusedValue] = (0, $fQ2SF$useState)(null);
|
|
38
|
-
let validation = (0, $fQ2SF$useFormValidationState)({
|
|
39
|
-
...props,
|
|
40
|
-
value: selectedValue
|
|
41
|
-
});
|
|
42
|
-
let setSelectedValue = (value)=>{
|
|
43
|
-
if (!props.isReadOnly && !props.isDisabled) {
|
|
44
|
-
setSelected(value);
|
|
45
|
-
validation.commitValidation();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
let isInvalid = validation.displayValidation.isInvalid;
|
|
49
|
-
return {
|
|
50
|
-
...validation,
|
|
51
|
-
name: name,
|
|
52
|
-
selectedValue: selectedValue,
|
|
53
|
-
setSelectedValue: setSelectedValue,
|
|
54
|
-
lastFocusedValue: lastFocusedValue,
|
|
55
|
-
setLastFocusedValue: setLastFocusedValue,
|
|
56
|
-
isDisabled: props.isDisabled || false,
|
|
57
|
-
isReadOnly: props.isReadOnly || false,
|
|
58
|
-
isRequired: props.isRequired || false,
|
|
59
|
-
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
60
|
-
isInvalid: isInvalid
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
16
|
export {$a54cdc5c1942b639$export$bca9d026f8e704eb as useRadioGroupState};
|
|
68
17
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $6fRYN$reactstatelyutils = require("@react-stately/utils");
|
|
3
|
-
var $6fRYN$react = require("react");
|
|
1
|
+
var $307db30b5687e2e8$exports = require("./useRadioGroupState.main.js");
|
|
4
2
|
|
|
5
3
|
|
|
6
4
|
function $parcel$export(e, n, v, s) {
|
|
7
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
6
|
}
|
|
9
7
|
|
|
10
|
-
$parcel$export(module.exports, "useRadioGroupState", () => $307db30b5687e2e8$
|
|
8
|
+
$parcel$export(module.exports, "useRadioGroupState", () => $307db30b5687e2e8$exports.useRadioGroupState);
|
|
11
9
|
/*
|
|
12
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
-
* governing permissions and limitations under the License.
|
|
21
|
-
*/ /*
|
|
22
10
|
* Copyright 2020 Adobe. All rights reserved.
|
|
23
11
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
24
12
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -31,43 +19,4 @@ $parcel$export(module.exports, "useRadioGroupState", () => $307db30b5687e2e8$exp
|
|
|
31
19
|
*/
|
|
32
20
|
|
|
33
21
|
|
|
34
|
-
let $307db30b5687e2e8$var$instance = Math.round(Math.random() * 10000000000);
|
|
35
|
-
let $307db30b5687e2e8$var$i = 0;
|
|
36
|
-
function $307db30b5687e2e8$export$bca9d026f8e704eb(props) {
|
|
37
|
-
// Preserved here for backward compatibility. React Aria now generates the name instead of stately.
|
|
38
|
-
let name = (0, $6fRYN$react.useMemo)(()=>props.name || `radio-group-${$307db30b5687e2e8$var$instance}-${++$307db30b5687e2e8$var$i}`, [
|
|
39
|
-
props.name
|
|
40
|
-
]);
|
|
41
|
-
var _props_defaultValue;
|
|
42
|
-
let [selectedValue, setSelected] = (0, $6fRYN$reactstatelyutils.useControlledState)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
43
|
-
let [lastFocusedValue, setLastFocusedValue] = (0, $6fRYN$react.useState)(null);
|
|
44
|
-
let validation = (0, $6fRYN$reactstatelyform.useFormValidationState)({
|
|
45
|
-
...props,
|
|
46
|
-
value: selectedValue
|
|
47
|
-
});
|
|
48
|
-
let setSelectedValue = (value)=>{
|
|
49
|
-
if (!props.isReadOnly && !props.isDisabled) {
|
|
50
|
-
setSelected(value);
|
|
51
|
-
validation.commitValidation();
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
let isInvalid = validation.displayValidation.isInvalid;
|
|
55
|
-
return {
|
|
56
|
-
...validation,
|
|
57
|
-
name: name,
|
|
58
|
-
selectedValue: selectedValue,
|
|
59
|
-
setSelectedValue: setSelectedValue,
|
|
60
|
-
lastFocusedValue: lastFocusedValue,
|
|
61
|
-
setLastFocusedValue: setLastFocusedValue,
|
|
62
|
-
isDisabled: props.isDisabled || false,
|
|
63
|
-
isReadOnly: props.isReadOnly || false,
|
|
64
|
-
isRequired: props.isRequired || false,
|
|
65
|
-
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
66
|
-
isInvalid: isInvalid
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
22
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/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 */\n\nexport {useRadioGroupState} from './useRadioGroupState';\n\nexport type {RadioGroupProps} from '@react-types/radio';\nexport type {RadioGroupState} from './useRadioGroupState';\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {useControlledState as $fQ2SF$useControlledState} from "@react-stately/utils";
|
|
3
|
-
import {useMemo as $fQ2SF$useMemo, useState as $fQ2SF$useState} from "react";
|
|
1
|
+
import {useRadioGroupState as $a54cdc5c1942b639$export$bca9d026f8e704eb} from "./useRadioGroupState.module.js";
|
|
4
2
|
|
|
5
3
|
/*
|
|
6
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
-
* governing permissions and limitations under the License.
|
|
15
|
-
*/ /*
|
|
16
4
|
* Copyright 2020 Adobe. All rights reserved.
|
|
17
5
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
18
6
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -25,44 +13,5 @@ import {useMemo as $fQ2SF$useMemo, useState as $fQ2SF$useState} from "react";
|
|
|
25
13
|
*/
|
|
26
14
|
|
|
27
15
|
|
|
28
|
-
let $a54cdc5c1942b639$var$instance = Math.round(Math.random() * 10000000000);
|
|
29
|
-
let $a54cdc5c1942b639$var$i = 0;
|
|
30
|
-
function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
31
|
-
// Preserved here for backward compatibility. React Aria now generates the name instead of stately.
|
|
32
|
-
let name = (0, $fQ2SF$useMemo)(()=>props.name || `radio-group-${$a54cdc5c1942b639$var$instance}-${++$a54cdc5c1942b639$var$i}`, [
|
|
33
|
-
props.name
|
|
34
|
-
]);
|
|
35
|
-
var _props_defaultValue;
|
|
36
|
-
let [selectedValue, setSelected] = (0, $fQ2SF$useControlledState)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
37
|
-
let [lastFocusedValue, setLastFocusedValue] = (0, $fQ2SF$useState)(null);
|
|
38
|
-
let validation = (0, $fQ2SF$useFormValidationState)({
|
|
39
|
-
...props,
|
|
40
|
-
value: selectedValue
|
|
41
|
-
});
|
|
42
|
-
let setSelectedValue = (value)=>{
|
|
43
|
-
if (!props.isReadOnly && !props.isDisabled) {
|
|
44
|
-
setSelected(value);
|
|
45
|
-
validation.commitValidation();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
let isInvalid = validation.displayValidation.isInvalid;
|
|
49
|
-
return {
|
|
50
|
-
...validation,
|
|
51
|
-
name: name,
|
|
52
|
-
selectedValue: selectedValue,
|
|
53
|
-
setSelectedValue: setSelectedValue,
|
|
54
|
-
lastFocusedValue: lastFocusedValue,
|
|
55
|
-
setLastFocusedValue: setLastFocusedValue,
|
|
56
|
-
isDisabled: props.isDisabled || false,
|
|
57
|
-
isReadOnly: props.isReadOnly || false,
|
|
58
|
-
isRequired: props.isRequired || false,
|
|
59
|
-
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
60
|
-
isInvalid: isInvalid
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
16
|
export {$a54cdc5c1942b639$export$bca9d026f8e704eb as useRadioGroupState};
|
|
68
17
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/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 */\n\nexport {useRadioGroupState} from './useRadioGroupState';\n\nexport type {RadioGroupProps} from '@react-types/radio';\nexport type {RadioGroupState} from './useRadioGroupState';\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var $cVa5U$reactstatelyform = require("@react-stately/form");
|
|
2
|
+
var $cVa5U$reactstatelyutils = require("@react-stately/utils");
|
|
3
|
+
var $cVa5U$react = require("react");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$export(e, n, v, s) {
|
|
7
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
$parcel$export(module.exports, "useRadioGroupState", () => $307db30b5687e2e8$export$bca9d026f8e704eb);
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
* governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
let $307db30b5687e2e8$var$instance = Math.round(Math.random() * 10000000000);
|
|
25
|
+
let $307db30b5687e2e8$var$i = 0;
|
|
26
|
+
function $307db30b5687e2e8$export$bca9d026f8e704eb(props) {
|
|
27
|
+
// Preserved here for backward compatibility. React Aria now generates the name instead of stately.
|
|
28
|
+
let name = (0, $cVa5U$react.useMemo)(()=>props.name || `radio-group-${$307db30b5687e2e8$var$instance}-${++$307db30b5687e2e8$var$i}`, [
|
|
29
|
+
props.name
|
|
30
|
+
]);
|
|
31
|
+
var _props_defaultValue;
|
|
32
|
+
let [selectedValue, setSelected] = (0, $cVa5U$reactstatelyutils.useControlledState)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
33
|
+
let [lastFocusedValue, setLastFocusedValue] = (0, $cVa5U$react.useState)(null);
|
|
34
|
+
let validation = (0, $cVa5U$reactstatelyform.useFormValidationState)({
|
|
35
|
+
...props,
|
|
36
|
+
value: selectedValue
|
|
37
|
+
});
|
|
38
|
+
let setSelectedValue = (value)=>{
|
|
39
|
+
if (!props.isReadOnly && !props.isDisabled) {
|
|
40
|
+
setSelected(value);
|
|
41
|
+
validation.commitValidation();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
let isInvalid = validation.displayValidation.isInvalid;
|
|
45
|
+
return {
|
|
46
|
+
...validation,
|
|
47
|
+
name: name,
|
|
48
|
+
selectedValue: selectedValue,
|
|
49
|
+
setSelectedValue: setSelectedValue,
|
|
50
|
+
lastFocusedValue: lastFocusedValue,
|
|
51
|
+
setLastFocusedValue: setLastFocusedValue,
|
|
52
|
+
isDisabled: props.isDisabled || false,
|
|
53
|
+
isReadOnly: props.isReadOnly || false,
|
|
54
|
+
isRequired: props.isRequired || false,
|
|
55
|
+
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
56
|
+
isInvalid: isInvalid
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=useRadioGroupState.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA+CD,IAAI,iCAAW,KAAK,KAAK,CAAC,KAAK,MAAM,KAAK;AAC1C,IAAI,0BAAI;AAMD,SAAS,0CAAmB,KAAsB;IACvD,mGAAmG;IACnG,IAAI,OAAO,CAAA,GAAA,oBAAM,EAAE,IAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,+BAAS,CAAC,EAAE,EAAE,wBAAE,CAAC,EAAE;QAAC,MAAM,IAAI;KAAC;QAClB;IAAnE,IAAI,CAAC,eAAe,YAAY,GAAG,CAAA,GAAA,2CAAiB,EAAE,MAAM,KAAK,EAAE,CAAA,sBAAA,MAAM,YAAY,cAAlB,iCAAA,sBAAsB,MAAM,MAAM,QAAQ;IAC7G,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,qBAAO,EAAiB;IAEtE,IAAI,aAAa,CAAA,GAAA,8CAAqB,EAAE;QACtC,GAAG,KAAK;QACR,OAAO;IACT;IAEA,IAAI,mBAAmB,CAAC;QACtB,IAAI,CAAC,MAAM,UAAU,IAAI,CAAC,MAAM,UAAU,EAAE;YAC1C,YAAY;YACZ,WAAW,gBAAgB;QAC7B;IACF;IAEA,IAAI,YAAY,WAAW,iBAAiB,CAAC,SAAS;IAEtD,OAAO;QACL,GAAG,UAAU;cACb;QACA,eAAe;0BACf;0BACA;6BACA;QACA,YAAY,MAAM,UAAU,IAAI;QAChC,YAAY,MAAM,UAAU,IAAI;QAChC,YAAY,MAAM,UAAU,IAAI;QAChC,iBAAiB,MAAM,eAAe,IAAK,CAAA,YAAY,YAAY,IAAG;mBACtE;IACF;AACF","sources":["packages/@react-stately/radio/src/useRadioGroupState.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 {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {RadioGroupProps} from '@react-types/radio';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\nimport {ValidationState} from '@react-types/shared';\n\nexport interface RadioGroupState extends FormValidationState {\n /**\n * The name for the group, used for native form submission.\n * @deprecated\n * @private\n */\n readonly name: string,\n\n /** Whether the radio group is disabled. */\n readonly isDisabled: boolean,\n\n /** Whether the radio group is read only. */\n readonly isReadOnly: boolean,\n\n /** Whether the radio group is required. */\n readonly isRequired: boolean,\n\n /**\n * Whether the radio group is valid or invalid.\n * @deprecated Use `isInvalid` instead.\n */\n readonly validationState: ValidationState | null,\n\n /** Whether the radio group is invalid. */\n readonly isInvalid: boolean,\n\n /** The currently selected value. */\n readonly selectedValue: string | null,\n\n /** Sets the selected value. */\n setSelectedValue(value: string | null): void,\n\n /** The value of the last focused radio. */\n readonly lastFocusedValue: string | null,\n\n /** Sets the last focused value. */\n setLastFocusedValue(value: string | null): void\n}\n\nlet instance = Math.round(Math.random() * 10000000000);\nlet i = 0;\n\n/**\n * Provides state management for a radio group component. Provides a name for the group,\n * and manages selection and focus state.\n */\nexport function useRadioGroupState(props: RadioGroupProps): RadioGroupState {\n // Preserved here for backward compatibility. React Aria now generates the name instead of stately.\n let name = useMemo(() => props.name || `radio-group-${instance}-${++i}`, [props.name]);\n let [selectedValue, setSelected] = useControlledState(props.value, props.defaultValue ?? null, props.onChange);\n let [lastFocusedValue, setLastFocusedValue] = useState<string | null>(null);\n\n let validation = useFormValidationState({\n ...props,\n value: selectedValue\n });\n\n let setSelectedValue = (value) => {\n if (!props.isReadOnly && !props.isDisabled) {\n setSelected(value);\n validation.commitValidation();\n }\n };\n\n let isInvalid = validation.displayValidation.isInvalid;\n\n return {\n ...validation,\n name,\n selectedValue: selectedValue,\n setSelectedValue,\n lastFocusedValue,\n setLastFocusedValue,\n isDisabled: props.isDisabled || false,\n isReadOnly: props.isReadOnly || false,\n isRequired: props.isRequired || false,\n validationState: props.validationState || (isInvalid ? 'invalid' : null),\n isInvalid\n };\n}\n"],"names":[],"version":3,"file":"useRadioGroupState.main.js.map"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {useFormValidationState as $l55kx$useFormValidationState} from "@react-stately/form";
|
|
2
|
+
import {useControlledState as $l55kx$useControlledState} from "@react-stately/utils";
|
|
3
|
+
import {useMemo as $l55kx$useMemo, useState as $l55kx$useState} from "react";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
let $a54cdc5c1942b639$var$instance = Math.round(Math.random() * 10000000000);
|
|
19
|
+
let $a54cdc5c1942b639$var$i = 0;
|
|
20
|
+
function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
21
|
+
// Preserved here for backward compatibility. React Aria now generates the name instead of stately.
|
|
22
|
+
let name = (0, $l55kx$useMemo)(()=>props.name || `radio-group-${$a54cdc5c1942b639$var$instance}-${++$a54cdc5c1942b639$var$i}`, [
|
|
23
|
+
props.name
|
|
24
|
+
]);
|
|
25
|
+
var _props_defaultValue;
|
|
26
|
+
let [selectedValue, setSelected] = (0, $l55kx$useControlledState)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
27
|
+
let [lastFocusedValue, setLastFocusedValue] = (0, $l55kx$useState)(null);
|
|
28
|
+
let validation = (0, $l55kx$useFormValidationState)({
|
|
29
|
+
...props,
|
|
30
|
+
value: selectedValue
|
|
31
|
+
});
|
|
32
|
+
let setSelectedValue = (value)=>{
|
|
33
|
+
if (!props.isReadOnly && !props.isDisabled) {
|
|
34
|
+
setSelected(value);
|
|
35
|
+
validation.commitValidation();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
let isInvalid = validation.displayValidation.isInvalid;
|
|
39
|
+
return {
|
|
40
|
+
...validation,
|
|
41
|
+
name: name,
|
|
42
|
+
selectedValue: selectedValue,
|
|
43
|
+
setSelectedValue: setSelectedValue,
|
|
44
|
+
lastFocusedValue: lastFocusedValue,
|
|
45
|
+
setLastFocusedValue: setLastFocusedValue,
|
|
46
|
+
isDisabled: props.isDisabled || false,
|
|
47
|
+
isReadOnly: props.isReadOnly || false,
|
|
48
|
+
isRequired: props.isRequired || false,
|
|
49
|
+
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
50
|
+
isInvalid: isInvalid
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
export {$a54cdc5c1942b639$export$bca9d026f8e704eb as useRadioGroupState};
|
|
56
|
+
//# sourceMappingURL=useRadioGroupState.mjs.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {useFormValidationState as $l55kx$useFormValidationState} from "@react-stately/form";
|
|
2
|
+
import {useControlledState as $l55kx$useControlledState} from "@react-stately/utils";
|
|
3
|
+
import {useMemo as $l55kx$useMemo, useState as $l55kx$useState} from "react";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
let $a54cdc5c1942b639$var$instance = Math.round(Math.random() * 10000000000);
|
|
19
|
+
let $a54cdc5c1942b639$var$i = 0;
|
|
20
|
+
function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
21
|
+
// Preserved here for backward compatibility. React Aria now generates the name instead of stately.
|
|
22
|
+
let name = (0, $l55kx$useMemo)(()=>props.name || `radio-group-${$a54cdc5c1942b639$var$instance}-${++$a54cdc5c1942b639$var$i}`, [
|
|
23
|
+
props.name
|
|
24
|
+
]);
|
|
25
|
+
var _props_defaultValue;
|
|
26
|
+
let [selectedValue, setSelected] = (0, $l55kx$useControlledState)(props.value, (_props_defaultValue = props.defaultValue) !== null && _props_defaultValue !== void 0 ? _props_defaultValue : null, props.onChange);
|
|
27
|
+
let [lastFocusedValue, setLastFocusedValue] = (0, $l55kx$useState)(null);
|
|
28
|
+
let validation = (0, $l55kx$useFormValidationState)({
|
|
29
|
+
...props,
|
|
30
|
+
value: selectedValue
|
|
31
|
+
});
|
|
32
|
+
let setSelectedValue = (value)=>{
|
|
33
|
+
if (!props.isReadOnly && !props.isDisabled) {
|
|
34
|
+
setSelected(value);
|
|
35
|
+
validation.commitValidation();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
let isInvalid = validation.displayValidation.isInvalid;
|
|
39
|
+
return {
|
|
40
|
+
...validation,
|
|
41
|
+
name: name,
|
|
42
|
+
selectedValue: selectedValue,
|
|
43
|
+
setSelectedValue: setSelectedValue,
|
|
44
|
+
lastFocusedValue: lastFocusedValue,
|
|
45
|
+
setLastFocusedValue: setLastFocusedValue,
|
|
46
|
+
isDisabled: props.isDisabled || false,
|
|
47
|
+
isReadOnly: props.isReadOnly || false,
|
|
48
|
+
isRequired: props.isRequired || false,
|
|
49
|
+
validationState: props.validationState || (isInvalid ? "invalid" : null),
|
|
50
|
+
isInvalid: isInvalid
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
export {$a54cdc5c1942b639$export$bca9d026f8e704eb as useRadioGroupState};
|
|
56
|
+
//# sourceMappingURL=useRadioGroupState.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA+CD,IAAI,iCAAW,KAAK,KAAK,CAAC,KAAK,MAAM,KAAK;AAC1C,IAAI,0BAAI;AAMD,SAAS,0CAAmB,KAAsB;IACvD,mGAAmG;IACnG,IAAI,OAAO,CAAA,GAAA,cAAM,EAAE,IAAM,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,+BAAS,CAAC,EAAE,EAAE,wBAAE,CAAC,EAAE;QAAC,MAAM,IAAI;KAAC;QAClB;IAAnE,IAAI,CAAC,eAAe,YAAY,GAAG,CAAA,GAAA,yBAAiB,EAAE,MAAM,KAAK,EAAE,CAAA,sBAAA,MAAM,YAAY,cAAlB,iCAAA,sBAAsB,MAAM,MAAM,QAAQ;IAC7G,IAAI,CAAC,kBAAkB,oBAAoB,GAAG,CAAA,GAAA,eAAO,EAAiB;IAEtE,IAAI,aAAa,CAAA,GAAA,6BAAqB,EAAE;QACtC,GAAG,KAAK;QACR,OAAO;IACT;IAEA,IAAI,mBAAmB,CAAC;QACtB,IAAI,CAAC,MAAM,UAAU,IAAI,CAAC,MAAM,UAAU,EAAE;YAC1C,YAAY;YACZ,WAAW,gBAAgB;QAC7B;IACF;IAEA,IAAI,YAAY,WAAW,iBAAiB,CAAC,SAAS;IAEtD,OAAO;QACL,GAAG,UAAU;cACb;QACA,eAAe;0BACf;0BACA;6BACA;QACA,YAAY,MAAM,UAAU,IAAI;QAChC,YAAY,MAAM,UAAU,IAAI;QAChC,YAAY,MAAM,UAAU,IAAI;QAChC,iBAAiB,MAAM,eAAe,IAAK,CAAA,YAAY,YAAY,IAAG;mBACtE;IACF;AACF","sources":["packages/@react-stately/radio/src/useRadioGroupState.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 {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {RadioGroupProps} from '@react-types/radio';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\nimport {ValidationState} from '@react-types/shared';\n\nexport interface RadioGroupState extends FormValidationState {\n /**\n * The name for the group, used for native form submission.\n * @deprecated\n * @private\n */\n readonly name: string,\n\n /** Whether the radio group is disabled. */\n readonly isDisabled: boolean,\n\n /** Whether the radio group is read only. */\n readonly isReadOnly: boolean,\n\n /** Whether the radio group is required. */\n readonly isRequired: boolean,\n\n /**\n * Whether the radio group is valid or invalid.\n * @deprecated Use `isInvalid` instead.\n */\n readonly validationState: ValidationState | null,\n\n /** Whether the radio group is invalid. */\n readonly isInvalid: boolean,\n\n /** The currently selected value. */\n readonly selectedValue: string | null,\n\n /** Sets the selected value. */\n setSelectedValue(value: string | null): void,\n\n /** The value of the last focused radio. */\n readonly lastFocusedValue: string | null,\n\n /** Sets the last focused value. */\n setLastFocusedValue(value: string | null): void\n}\n\nlet instance = Math.round(Math.random() * 10000000000);\nlet i = 0;\n\n/**\n * Provides state management for a radio group component. Provides a name for the group,\n * and manages selection and focus state.\n */\nexport function useRadioGroupState(props: RadioGroupProps): RadioGroupState {\n // Preserved here for backward compatibility. React Aria now generates the name instead of stately.\n let name = useMemo(() => props.name || `radio-group-${instance}-${++i}`, [props.name]);\n let [selectedValue, setSelected] = useControlledState(props.value, props.defaultValue ?? null, props.onChange);\n let [lastFocusedValue, setLastFocusedValue] = useState<string | null>(null);\n\n let validation = useFormValidationState({\n ...props,\n value: selectedValue\n });\n\n let setSelectedValue = (value) => {\n if (!props.isReadOnly && !props.isDisabled) {\n setSelected(value);\n validation.commitValidation();\n }\n };\n\n let isInvalid = validation.displayValidation.isInvalid;\n\n return {\n ...validation,\n name,\n selectedValue: selectedValue,\n setSelectedValue,\n lastFocusedValue,\n setLastFocusedValue,\n isDisabled: props.isDisabled || false,\n isReadOnly: props.isReadOnly || false,\n isRequired: props.isRequired || false,\n validationState: props.validationState || (isInvalid ? 'invalid' : null),\n isInvalid\n };\n}\n"],"names":[],"version":3,"file":"useRadioGroupState.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/radio",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.3",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-stately/form": "^3.0.
|
|
26
|
-
"@react-stately/utils": "^3.
|
|
27
|
-
"@react-types/radio": "^3.
|
|
28
|
-
"@react-types/shared": "^3.
|
|
25
|
+
"@react-stately/form": "^3.0.2",
|
|
26
|
+
"@react-stately/utils": "^3.10.0",
|
|
27
|
+
"@react-types/radio": "^3.8.0",
|
|
28
|
+
"@react-types/shared": "^3.23.0",
|
|
29
29
|
"@swc/helpers": "^0.5.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
|
|
38
38
|
}
|