@react-stately/radio 3.2.1 → 3.3.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/main.js CHANGED
@@ -1,39 +1,56 @@
1
- var {
2
- useMemo,
3
- useState
4
- } = require("react");
5
-
6
- var {
7
- useControlledState
8
- } = require("@react-stately/utils");
9
-
10
- let $d0ad1e5f2b737cb6c44a515e014bc7c0$var$instance = Math.round(Math.random() * 10000000000);
11
- let $d0ad1e5f2b737cb6c44a515e014bc7c0$var$i = 0;
12
- /**
13
- * Provides state management for a radio group component. Provides a name for the group,
14
- * and manages selection and focus state.
15
- */
16
-
17
- function useRadioGroupState(props) {
18
- // Preserved here for backward compatibility. React Aria now generates the name instead of stately.
19
- let name = useMemo(() => props.name || "radio-group-" + $d0ad1e5f2b737cb6c44a515e014bc7c0$var$instance + "-" + ++$d0ad1e5f2b737cb6c44a515e014bc7c0$var$i, [props.name]);
20
- let [selectedValue, setSelected] = useControlledState(props.value, props.defaultValue, props.onChange);
21
- let [lastFocusedValue, setLastFocusedValue] = useState(null);
22
-
23
- let setSelectedValue = value => {
24
- if (!props.isReadOnly) {
25
- setSelected(value);
1
+ var $5PLXi$reactstatelyutils = require("@react-stately/utils");
2
+ var $5PLXi$react = require("react");
3
+
4
+ function $parcel$exportWildcard(dest, source) {
5
+ Object.keys(source).forEach(function(key) {
6
+ if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
7
+ return;
26
8
  }
27
- };
28
-
29
- return {
30
- name,
31
- selectedValue,
32
- setSelectedValue,
33
- lastFocusedValue,
34
- setLastFocusedValue
35
- };
9
+
10
+ Object.defineProperty(dest, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return source[key];
14
+ }
15
+ });
16
+ });
17
+
18
+ return dest;
36
19
  }
20
+ function $parcel$export(e, n, v, s) {
21
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
22
+ }
23
+ var $f1190db867f71966$exports = {};
24
+
25
+ $parcel$export($f1190db867f71966$exports, "useRadioGroupState", () => $f1190db867f71966$export$bca9d026f8e704eb);
26
+
27
+
28
+ let $f1190db867f71966$var$instance = Math.round(Math.random() * 10000000000);
29
+ let $f1190db867f71966$var$i = 0;
30
+ function $f1190db867f71966$export$bca9d026f8e704eb(props) {
31
+ // Preserved here for backward compatibility. React Aria now generates the name instead of stately.
32
+ let name = $5PLXi$react.useMemo(()=>props.name || `radio-group-${$f1190db867f71966$var$instance}-${++$f1190db867f71966$var$i}`
33
+ , [
34
+ props.name
35
+ ]);
36
+ let [selectedValue, setSelected] = $5PLXi$reactstatelyutils.useControlledState(props.value, props.defaultValue, props.onChange);
37
+ let [lastFocusedValue, setLastFocusedValue] = $5PLXi$react.useState(null);
38
+ let setSelectedValue = (value)=>{
39
+ if (!props.isReadOnly && !props.isDisabled) setSelected(value);
40
+ };
41
+ return {
42
+ name: name,
43
+ selectedValue: selectedValue,
44
+ setSelectedValue: setSelectedValue,
45
+ lastFocusedValue: lastFocusedValue,
46
+ setLastFocusedValue: setLastFocusedValue,
47
+ isDisabled: props.isDisabled || false,
48
+ isReadOnly: props.isReadOnly || false
49
+ };
50
+ }
51
+
52
+
53
+ $parcel$exportWildcard(module.exports, $f1190db867f71966$exports);
54
+
37
55
 
38
- exports.useRadioGroupState = useRadioGroupState;
39
56
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAqCA,IAAIA,8CAAQ,GAAGC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgB,WAA3B,CAAf;AACA,IAAIC,uCAAC,GAAG,CAAR;AAEA;;;;;AAIO,SAASC,kBAAT,CAA4BC,KAA5B,EAAsE;AAC3E;AACA,MAAIC,IAAI,GAAGC,OAAO,CAAC,MAAMF,KAAK,CAACC,IAAN,qBAA6BP,8CAA7B,SAAyC,EAAEI,uCAAlD,EAAuD,CAACE,KAAK,CAACC,IAAP,CAAvD,CAAlB;AACA,MAAI,CAACE,aAAD,EAAgBC,WAAhB,IAA+BC,kBAAkB,CAACL,KAAK,CAACM,KAAP,EAAcN,KAAK,CAACO,YAApB,EAAkCP,KAAK,CAACQ,QAAxC,CAArD;AACA,MAAI,CAACC,gBAAD,EAAmBC,mBAAnB,IAA0CC,QAAQ,CAAC,IAAD,CAAtD;;AAEA,MAAIC,gBAAgB,GAAIN,KAAD,IAAW;AAChC,QAAI,CAACN,KAAK,CAACa,UAAX,EAAuB;AACrBT,MAAAA,WAAW,CAACE,KAAD,CAAX;AACD;AACF,GAJD;;AAMA,SAAO;AACLL,IAAAA,IADK;AAELE,IAAAA,aAFK;AAGLS,IAAAA,gBAHK;AAILH,IAAAA,gBAJK;AAKLC,IAAAA;AALK,GAAP;AAOD","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 {RadioGroupProps} from '@react-types/radio';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\n\nexport interface RadioGroupState {\n /**\n * The name for the group, used for native form submission.\n * @deprecated\n * @private\n */\n readonly name: string,\n\n /** The currently selected value. */\n readonly selectedValue: string | null,\n\n /** Sets the selected value. */\n setSelectedValue(value: string): 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): 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, props.onChange);\n let [lastFocusedValue, setLastFocusedValue] = useState(null);\n\n let setSelectedValue = (value) => {\n if (!props.isReadOnly) {\n setSelected(value);\n }\n };\n\n return {\n name,\n selectedValue,\n setSelectedValue,\n lastFocusedValue,\n setLastFocusedValue\n };\n}\n"],"names":["instance","Math","round","random","i","useRadioGroupState","props","name","useMemo","selectedValue","setSelected","useControlledState","value","defaultValue","onChange","lastFocusedValue","setLastFocusedValue","useState","setSelectedValue","isReadOnly"],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AC2CA,GAAG,CAAC,8BAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW;AACrD,GAAG,CAAC,uBAAC,GAAG,CAAC;SAMO,yCAAkB,CAAC,KAAsB,EAAoB,CAAC;IAC5E,EAAmG,AAAnG,iGAAmG;IACnG,GAAG,CAAC,IAAI,GAAG,oBAAO,KAAO,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,8BAAQ,CAAC,CAAC,IAAI,uBAAC;MAAI,CAAC;QAAA,KAAK,CAAC,IAAI;IAAA,CAAC;IACrF,GAAG,EAAE,aAAa,EAAE,WAAW,IAAI,2CAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ;IACrG,GAAG,EAAE,gBAAgB,EAAE,mBAAmB,IAAI,qBAAQ,CAAC,IAAI;IAE3D,GAAG,CAAC,gBAAgB,IAAI,KAAK,GAAK,CAAC;QACjC,EAAE,GAAG,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU,EACxC,WAAW,CAAC,KAAK;IAErB,CAAC;IAED,MAAM,CAAC,CAAC;cACN,IAAI;uBACJ,aAAa;0BACb,gBAAgB;0BAChB,gBAAgB;6BAChB,mBAAmB;QACnB,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK;QACrC,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK;IACvC,CAAC;AACH,CAAC","sources":["packages/@react-stately/radio/src/index.ts","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\nexport * from './useRadioGroupState';\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 {RadioGroupProps} from '@react-types/radio';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\n\nexport interface RadioGroupState {\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 /** The currently selected value. */\n readonly selectedValue: string | null,\n\n /** Sets the selected value. */\n setSelectedValue(value: string): 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): 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, props.onChange);\n let [lastFocusedValue, setLastFocusedValue] = useState(null);\n\n let setSelectedValue = (value) => {\n if (!props.isReadOnly && !props.isDisabled) {\n setSelected(value);\n }\n };\n\n return {\n name,\n selectedValue,\n setSelectedValue,\n lastFocusedValue,\n setLastFocusedValue,\n isDisabled: props.isDisabled || false,\n isReadOnly: props.isReadOnly || false\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,30 +1,40 @@
1
- import { useMemo, useState } from "react";
2
- import { useControlledState } from "@react-stately/utils";
3
- let $eaf77ba5e143129c6bb329a6e66020d3$var$instance = Math.round(Math.random() * 10000000000);
4
- let $eaf77ba5e143129c6bb329a6e66020d3$var$i = 0;
5
- /**
6
- * Provides state management for a radio group component. Provides a name for the group,
7
- * and manages selection and focus state.
8
- */
9
-
10
- export function useRadioGroupState(props) {
11
- // Preserved here for backward compatibility. React Aria now generates the name instead of stately.
12
- let name = useMemo(() => props.name || "radio-group-" + $eaf77ba5e143129c6bb329a6e66020d3$var$instance + "-" + ++$eaf77ba5e143129c6bb329a6e66020d3$var$i, [props.name]);
13
- let [selectedValue, setSelected] = useControlledState(props.value, props.defaultValue, props.onChange);
14
- let [lastFocusedValue, setLastFocusedValue] = useState(null);
15
-
16
- let setSelectedValue = value => {
17
- if (!props.isReadOnly) {
18
- setSelected(value);
19
- }
20
- };
21
-
22
- return {
23
- name,
24
- selectedValue,
25
- setSelectedValue,
26
- lastFocusedValue,
27
- setLastFocusedValue
28
- };
1
+ import {useControlledState as $cKWHA$useControlledState} from "@react-stately/utils";
2
+ import {useMemo as $cKWHA$useMemo, useState as $cKWHA$useState} from "react";
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+ var $abdd678977242949$exports = {};
8
+
9
+ $parcel$export($abdd678977242949$exports, "useRadioGroupState", () => $abdd678977242949$export$bca9d026f8e704eb);
10
+
11
+
12
+ let $abdd678977242949$var$instance = Math.round(Math.random() * 10000000000);
13
+ let $abdd678977242949$var$i = 0;
14
+ function $abdd678977242949$export$bca9d026f8e704eb(props) {
15
+ // Preserved here for backward compatibility. React Aria now generates the name instead of stately.
16
+ let name = $cKWHA$useMemo(()=>props.name || `radio-group-${$abdd678977242949$var$instance}-${++$abdd678977242949$var$i}`
17
+ , [
18
+ props.name
19
+ ]);
20
+ let [selectedValue, setSelected] = $cKWHA$useControlledState(props.value, props.defaultValue, props.onChange);
21
+ let [lastFocusedValue, setLastFocusedValue] = $cKWHA$useState(null);
22
+ let setSelectedValue = (value)=>{
23
+ if (!props.isReadOnly && !props.isDisabled) setSelected(value);
24
+ };
25
+ return {
26
+ name: name,
27
+ selectedValue: selectedValue,
28
+ setSelectedValue: setSelectedValue,
29
+ lastFocusedValue: lastFocusedValue,
30
+ setLastFocusedValue: setLastFocusedValue,
31
+ isDisabled: props.isDisabled || false,
32
+ isReadOnly: props.isReadOnly || false
33
+ };
29
34
  }
35
+
36
+
37
+
38
+
39
+ export {$abdd678977242949$export$bca9d026f8e704eb as useRadioGroupState};
30
40
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;AAqCA,IAAIA,8CAAQ,GAAGC,IAAI,CAACC,KAAL,CAAWD,IAAI,CAACE,MAAL,KAAgB,WAA3B,CAAf;AACA,IAAIC,uCAAC,GAAG,CAAR;AAEA;;;;;OAIO,SAASC,kBAAT,CAA4BC,KAA5B,EAAsE;AAC3E;AACA,MAAIC,IAAI,GAAGC,OAAO,CAAC,MAAMF,KAAK,CAACC,IAAN,qBAA6BP,8CAA7B,SAAyC,EAAEI,uCAAlD,EAAuD,CAACE,KAAK,CAACC,IAAP,CAAvD,CAAlB;AACA,MAAI,CAACE,aAAD,EAAgBC,WAAhB,IAA+BC,kBAAkB,CAACL,KAAK,CAACM,KAAP,EAAcN,KAAK,CAACO,YAApB,EAAkCP,KAAK,CAACQ,QAAxC,CAArD;AACA,MAAI,CAACC,gBAAD,EAAmBC,mBAAnB,IAA0CC,QAAQ,CAAC,IAAD,CAAtD;;AAEA,MAAIC,gBAAgB,GAAIN,KAAD,IAAW;AAChC,QAAI,CAACN,KAAK,CAACa,UAAX,EAAuB;AACrBT,MAAAA,WAAW,CAACE,KAAD,CAAX;AACD;AACF,GAJD;;AAMA,SAAO;AACLL,IAAAA,IADK;AAELE,IAAAA,aAFK;AAGLS,IAAAA,gBAHK;AAILH,IAAAA,gBAJK;AAKLC,IAAAA;AALK,GAAP;AAOD","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 {RadioGroupProps} from '@react-types/radio';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\n\nexport interface RadioGroupState {\n /**\n * The name for the group, used for native form submission.\n * @deprecated\n * @private\n */\n readonly name: string,\n\n /** The currently selected value. */\n readonly selectedValue: string | null,\n\n /** Sets the selected value. */\n setSelectedValue(value: string): 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): 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, props.onChange);\n let [lastFocusedValue, setLastFocusedValue] = useState(null);\n\n let setSelectedValue = (value) => {\n if (!props.isReadOnly) {\n setSelected(value);\n }\n };\n\n return {\n name,\n selectedValue,\n setSelectedValue,\n lastFocusedValue,\n setLastFocusedValue\n };\n}\n"],"names":["instance","Math","round","random","i","useRadioGroupState","props","name","useMemo","selectedValue","setSelected","useControlledState","value","defaultValue","onChange","lastFocusedValue","setLastFocusedValue","useState","setSelectedValue","isReadOnly"],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;;;;;AC2CA,GAAG,CAAC,8BAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,KAAK,WAAW;AACrD,GAAG,CAAC,uBAAC,GAAG,CAAC;SAMO,yCAAkB,CAAC,KAAsB,EAAoB,CAAC;IAC5E,EAAmG,AAAnG,iGAAmG;IACnG,GAAG,CAAC,IAAI,GAAG,cAAO,KAAO,KAAK,CAAC,IAAI,KAAK,YAAY,EAAE,8BAAQ,CAAC,CAAC,IAAI,uBAAC;MAAI,CAAC;QAAA,KAAK,CAAC,IAAI;IAAA,CAAC;IACrF,GAAG,EAAE,aAAa,EAAE,WAAW,IAAI,yBAAkB,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,QAAQ;IACrG,GAAG,EAAE,gBAAgB,EAAE,mBAAmB,IAAI,eAAQ,CAAC,IAAI;IAE3D,GAAG,CAAC,gBAAgB,IAAI,KAAK,GAAK,CAAC;QACjC,EAAE,GAAG,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU,EACxC,WAAW,CAAC,KAAK;IAErB,CAAC;IAED,MAAM,CAAC,CAAC;cACN,IAAI;uBACJ,aAAa;0BACb,gBAAgB;0BAChB,gBAAgB;6BAChB,mBAAmB;QACnB,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK;QACrC,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK;IACvC,CAAC;AACH,CAAC","sources":["packages/@react-stately/radio/src/index.ts","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\nexport * from './useRadioGroupState';\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 {RadioGroupProps} from '@react-types/radio';\nimport {useControlledState} from '@react-stately/utils';\nimport {useMemo, useState} from 'react';\n\nexport interface RadioGroupState {\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 /** The currently selected value. */\n readonly selectedValue: string | null,\n\n /** Sets the selected value. */\n setSelectedValue(value: string): 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): 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, props.onChange);\n let [lastFocusedValue, setLastFocusedValue] = useState(null);\n\n let setSelectedValue = (value) => {\n if (!props.isReadOnly && !props.isDisabled) {\n setSelected(value);\n }\n };\n\n return {\n name,\n selectedValue,\n setSelectedValue,\n lastFocusedValue,\n setLastFocusedValue,\n isDisabled: props.isDisabled || false,\n isReadOnly: props.isReadOnly || false\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/dist/types.d.ts CHANGED
@@ -6,6 +6,10 @@ export interface RadioGroupState {
6
6
  * @private
7
7
  */
8
8
  readonly name: string;
9
+ /** Whether the radio group is disabled. */
10
+ readonly isDisabled: boolean;
11
+ /** Whether the radio group is read only. */
12
+ readonly isReadOnly: boolean;
9
13
  /** The currently selected value. */
10
14
  readonly selectedValue: string | null;
11
15
  /** Sets the selected value. */
@@ -1 +1 @@
1
- {"mappings":"A;AAgBA;IACE;A;A;A;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,oCAAoC;IACpC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC,+BAA+B;IAC/B,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC,2CAA2C;IAC3C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC,mCAAmC;IACnC,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACzC;AAKD;A;A;GAGG;AACH,mCAAmC,KAAK,EAAE,eAAe,GAAG,eAAe,CAmB1E","sources":["./packages/@react-stately/radio/src/packages/@react-stately/radio/src/useRadioGroupState.ts","./packages/@react-stately/radio/src/packages/@react-stately/radio/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";AAgBA;IACE;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,2CAA2C;IAC3C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,oCAAoC;IACpC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC,+BAA+B;IAC/B,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC,2CAA2C;IAC3C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC,mCAAmC;IACnC,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CACzC;AAKD;;;GAGG;AACH,mCAAmC,KAAK,EAAE,eAAe,GAAG,eAAe,CAqB1E","sources":["packages/@react-stately/radio/src/packages/@react-stately/radio/src/useRadioGroupState.ts","packages/@react-stately/radio/src/packages/@react-stately/radio/src/index.ts","packages/@react-stately/radio/src/index.ts"],"sourcesContent":[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 */\n\nexport * from './useRadioGroupState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/radio",
3
- "version": "3.2.1",
3
+ "version": "3.3.3",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,8 +18,8 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-stately/utils": "^3.1.1",
22
- "@react-types/radio": "^3.1.1"
21
+ "@react-stately/utils": "^3.4.0",
22
+ "@react-types/radio": "^3.1.3"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": "^16.8.0 || ^17.0.0-rc.1"
@@ -27,5 +27,5 @@
27
27
  "publishConfig": {
28
28
  "access": "public"
29
29
  },
30
- "gitHead": "0778f71a3c13e1e24388a23b6d525e3b9f5b98f1"
30
+ "gitHead": "54c2366c4f31bd4bf619126131cd583c12972acc"
31
31
  }
@@ -22,6 +22,12 @@ export interface RadioGroupState {
22
22
  */
23
23
  readonly name: string,
24
24
 
25
+ /** Whether the radio group is disabled. */
26
+ readonly isDisabled: boolean,
27
+
28
+ /** Whether the radio group is read only. */
29
+ readonly isReadOnly: boolean,
30
+
25
31
  /** The currently selected value. */
26
32
  readonly selectedValue: string | null,
27
33
 
@@ -49,7 +55,7 @@ export function useRadioGroupState(props: RadioGroupProps): RadioGroupState {
49
55
  let [lastFocusedValue, setLastFocusedValue] = useState(null);
50
56
 
51
57
  let setSelectedValue = (value) => {
52
- if (!props.isReadOnly) {
58
+ if (!props.isReadOnly && !props.isDisabled) {
53
59
  setSelected(value);
54
60
  }
55
61
  };
@@ -59,6 +65,8 @@ export function useRadioGroupState(props: RadioGroupProps): RadioGroupState {
59
65
  selectedValue,
60
66
  setSelectedValue,
61
67
  lastFocusedValue,
62
- setLastFocusedValue
68
+ setLastFocusedValue,
69
+ isDisabled: props.isDisabled || false,
70
+ isReadOnly: props.isReadOnly || false
63
71
  };
64
72
  }