@react-stately/radio 3.11.5 → 3.12.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 CHANGED
@@ -1,4 +1,4 @@
1
- import {useRadioGroupState as $a54cdc5c1942b639$export$bca9d026f8e704eb} from "./useRadioGroupState.mjs";
1
+ import {useRadioGroupState as $fb792fdedf0f9e40$re_export$useRadioGroupState} from "react-stately/useRadioGroupState";
2
2
 
3
3
  /*
4
4
  * Copyright 2020 Adobe. All rights reserved.
@@ -13,5 +13,5 @@ import {useRadioGroupState as $a54cdc5c1942b639$export$bca9d026f8e704eb} from ".
13
13
  */
14
14
 
15
15
 
16
- export {$a54cdc5c1942b639$export$bca9d026f8e704eb as useRadioGroupState};
16
+ export {$fb792fdedf0f9e40$re_export$useRadioGroupState as useRadioGroupState};
17
17
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,11 +1,11 @@
1
- var $307db30b5687e2e8$exports = require("./useRadioGroupState.main.js");
1
+ var $6ufoG$reactstatelyuseRadioGroupState = require("react-stately/useRadioGroupState");
2
2
 
3
3
 
4
4
  function $parcel$export(e, n, v, s) {
5
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
6
  }
7
7
 
8
- $parcel$export(module.exports, "useRadioGroupState", () => $307db30b5687e2e8$exports.useRadioGroupState);
8
+ $parcel$export(module.exports, "useRadioGroupState", function () { return $6ufoG$reactstatelyuseRadioGroupState.useRadioGroupState; });
9
9
  /*
10
10
  * Copyright 2020 Adobe. All rights reserved.
11
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
package/dist/main.js.map CHANGED
@@ -1 +1 @@
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"}
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 'react-stately/useRadioGroupState';\n\nexport type {RadioGroupProps, RadioGroupState} from 'react-stately/useRadioGroupState';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,4 +1,4 @@
1
- import {useRadioGroupState as $a54cdc5c1942b639$export$bca9d026f8e704eb} from "./useRadioGroupState.module.js";
1
+ import {useRadioGroupState as $fb792fdedf0f9e40$re_export$useRadioGroupState} from "react-stately/useRadioGroupState";
2
2
 
3
3
  /*
4
4
  * Copyright 2020 Adobe. All rights reserved.
@@ -13,5 +13,5 @@ import {useRadioGroupState as $a54cdc5c1942b639$export$bca9d026f8e704eb} from ".
13
13
  */
14
14
 
15
15
 
16
- export {$a54cdc5c1942b639$export$bca9d026f8e704eb as useRadioGroupState};
16
+ export {$fb792fdedf0f9e40$re_export$useRadioGroupState as useRadioGroupState};
17
17
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
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"}
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 'react-stately/useRadioGroupState';\n\nexport type {RadioGroupProps, RadioGroupState} from 'react-stately/useRadioGroupState';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,2 @@
1
+ export { useRadioGroupState } from 'react-stately/useRadioGroupState';
2
+ export type { RadioGroupProps, RadioGroupState } from 'react-stately/useRadioGroupState';
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@react-stately/radio",
3
- "version": "3.11.5",
3
+ "version": "3.12.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
- "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
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,17 +26,18 @@
26
26
  "url": "https://github.com/adobe/react-spectrum"
27
27
  },
28
28
  "dependencies": {
29
- "@react-stately/form": "^3.2.4",
30
- "@react-stately/utils": "^3.11.0",
31
- "@react-types/radio": "^3.9.4",
32
- "@react-types/shared": "^3.33.1",
33
- "@swc/helpers": "^0.5.0"
29
+ "@swc/helpers": "^0.5.0",
30
+ "react-stately": "3.46.0"
34
31
  },
35
32
  "peerDependencies": {
36
- "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
33
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
34
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
37
35
  },
38
36
  "publishConfig": {
39
37
  "access": "public"
40
38
  },
41
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
39
+ "targets": {
40
+ "types": false
41
+ },
42
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
42
43
  }
package/src/index.ts CHANGED
@@ -10,7 +10,6 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- export {useRadioGroupState} from './useRadioGroupState';
13
+ export {useRadioGroupState} from 'react-stately/useRadioGroupState';
14
14
 
15
- export type {RadioGroupProps} from '@react-types/radio';
16
- export type {RadioGroupState} from './useRadioGroupState';
15
+ export type {RadioGroupProps, RadioGroupState} from 'react-stately/useRadioGroupState';
package/dist/types.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import { FormValidationState } from "@react-stately/form";
2
- import { RadioGroupProps } from "@react-types/radio";
3
- import { ValidationState } from "@react-types/shared";
4
- export interface RadioGroupState extends FormValidationState {
5
- /**
6
- * The name for the group, used for native form submission.
7
- * @deprecated
8
- * @private
9
- */
10
- readonly name: string;
11
- /** Whether the radio group is disabled. */
12
- readonly isDisabled: boolean;
13
- /** Whether the radio group is read only. */
14
- readonly isReadOnly: boolean;
15
- /** Whether the radio group is required. */
16
- readonly isRequired: boolean;
17
- /**
18
- * Whether the radio group is valid or invalid.
19
- * @deprecated Use `isInvalid` instead.
20
- */
21
- readonly validationState: ValidationState | null;
22
- /** Whether the radio group is invalid. */
23
- readonly isInvalid: boolean;
24
- /** The currently selected value. */
25
- readonly selectedValue: string | null;
26
- /** The default selected value. */
27
- readonly defaultSelectedValue: string | null;
28
- /** Sets the selected value. */
29
- setSelectedValue(value: string | null): void;
30
- /** The value of the last focused radio. */
31
- readonly lastFocusedValue: string | null;
32
- /** Sets the last focused value. */
33
- setLastFocusedValue(value: string | null): void;
34
- }
35
- /**
36
- * Provides state management for a radio group component. Provides a name for the group,
37
- * and manages selection and focus state.
38
- */
39
- export function useRadioGroupState(props: RadioGroupProps): RadioGroupState;
40
- export type { RadioGroupProps } from '@react-types/radio';
41
-
42
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"mappings":";;;AAkBA,gCAAiC,SAAQ,mBAAmB;IAC1D;;;;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,2CAA2C;IAC3C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;IAEjD,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,oCAAoC;IACpC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtC,kCAAkC;IAClC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7C,+BAA+B;IAC/B,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAE7C,2CAA2C;IAC3C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC,mCAAmC;IACnC,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;CAChD;AAKD;;;GAGG;AACH,mCAAmC,KAAK,EAAE,eAAe,GAAG,eAAe,CAmC1E;ACxFD,YAAY,EAAC,eAAe,EAAC,MAAM,oBAAoB,CAAC","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 {useRadioGroupState} from './useRadioGroupState';\n\nexport type {RadioGroupProps} from '@react-types/radio';\nexport type {RadioGroupState} from './useRadioGroupState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -1,64 +0,0 @@
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 [initialValue] = (0, $cVa5U$react.useState)(selectedValue);
34
- let [lastFocusedValue, setLastFocusedValue] = (0, $cVa5U$react.useState)(null);
35
- let validation = (0, $cVa5U$reactstatelyform.useFormValidationState)({
36
- ...props,
37
- value: selectedValue
38
- });
39
- let setSelectedValue = (value)=>{
40
- if (!props.isReadOnly && !props.isDisabled) {
41
- setSelected(value);
42
- validation.commitValidation();
43
- }
44
- };
45
- let isInvalid = validation.displayValidation.isInvalid;
46
- var _props_defaultValue1;
47
- return {
48
- ...validation,
49
- name: name,
50
- selectedValue: selectedValue,
51
- defaultSelectedValue: props.value !== undefined ? initialValue : (_props_defaultValue1 = props.defaultValue) !== null && _props_defaultValue1 !== void 0 ? _props_defaultValue1 : null,
52
- setSelectedValue: setSelectedValue,
53
- lastFocusedValue: lastFocusedValue,
54
- setLastFocusedValue: setLastFocusedValue,
55
- isDisabled: props.isDisabled || false,
56
- isReadOnly: props.isReadOnly || false,
57
- isRequired: props.isRequired || false,
58
- validationState: props.validationState || (isInvalid ? 'invalid' : null),
59
- isInvalid: isInvalid
60
- };
61
- }
62
-
63
-
64
- //# sourceMappingURL=useRadioGroupState.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAkDD,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,yBAAG,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,aAAa,GAAG,CAAA,GAAA,qBAAO,EAAE;IAC9B,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;QAMa;IAJnE,OAAO;QACL,GAAG,UAAU;cACb;QACA,eAAe;QACf,sBAAsB,MAAM,KAAK,KAAK,YAAY,eAAe,CAAA,uBAAA,MAAM,YAAY,cAAlB,kCAAA,uBAAsB;0BACvF;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 /** The default selected value. */\n readonly defaultSelectedValue: 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 [initialValue] = useState(selectedValue);\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 defaultSelectedValue: props.value !== undefined ? initialValue : props.defaultValue ?? null,\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"}
@@ -1,59 +0,0 @@
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 [initialValue] = (0, $l55kx$useState)(selectedValue);
28
- let [lastFocusedValue, setLastFocusedValue] = (0, $l55kx$useState)(null);
29
- let validation = (0, $l55kx$useFormValidationState)({
30
- ...props,
31
- value: selectedValue
32
- });
33
- let setSelectedValue = (value)=>{
34
- if (!props.isReadOnly && !props.isDisabled) {
35
- setSelected(value);
36
- validation.commitValidation();
37
- }
38
- };
39
- let isInvalid = validation.displayValidation.isInvalid;
40
- var _props_defaultValue1;
41
- return {
42
- ...validation,
43
- name: name,
44
- selectedValue: selectedValue,
45
- defaultSelectedValue: props.value !== undefined ? initialValue : (_props_defaultValue1 = props.defaultValue) !== null && _props_defaultValue1 !== void 0 ? _props_defaultValue1 : null,
46
- setSelectedValue: setSelectedValue,
47
- lastFocusedValue: lastFocusedValue,
48
- setLastFocusedValue: setLastFocusedValue,
49
- isDisabled: props.isDisabled || false,
50
- isReadOnly: props.isReadOnly || false,
51
- isRequired: props.isRequired || false,
52
- validationState: props.validationState || (isInvalid ? 'invalid' : null),
53
- isInvalid: isInvalid
54
- };
55
- }
56
-
57
-
58
- export {$a54cdc5c1942b639$export$bca9d026f8e704eb as useRadioGroupState};
59
- //# sourceMappingURL=useRadioGroupState.module.js.map
@@ -1,59 +0,0 @@
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 [initialValue] = (0, $l55kx$useState)(selectedValue);
28
- let [lastFocusedValue, setLastFocusedValue] = (0, $l55kx$useState)(null);
29
- let validation = (0, $l55kx$useFormValidationState)({
30
- ...props,
31
- value: selectedValue
32
- });
33
- let setSelectedValue = (value)=>{
34
- if (!props.isReadOnly && !props.isDisabled) {
35
- setSelected(value);
36
- validation.commitValidation();
37
- }
38
- };
39
- let isInvalid = validation.displayValidation.isInvalid;
40
- var _props_defaultValue1;
41
- return {
42
- ...validation,
43
- name: name,
44
- selectedValue: selectedValue,
45
- defaultSelectedValue: props.value !== undefined ? initialValue : (_props_defaultValue1 = props.defaultValue) !== null && _props_defaultValue1 !== void 0 ? _props_defaultValue1 : null,
46
- setSelectedValue: setSelectedValue,
47
- lastFocusedValue: lastFocusedValue,
48
- setLastFocusedValue: setLastFocusedValue,
49
- isDisabled: props.isDisabled || false,
50
- isReadOnly: props.isReadOnly || false,
51
- isRequired: props.isRequired || false,
52
- validationState: props.validationState || (isInvalid ? 'invalid' : null),
53
- isInvalid: isInvalid
54
- };
55
- }
56
-
57
-
58
- export {$a54cdc5c1942b639$export$bca9d026f8e704eb as useRadioGroupState};
59
- //# sourceMappingURL=useRadioGroupState.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAkDD,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,yBAAG,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,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IAC9B,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;QAMa;IAJnE,OAAO;QACL,GAAG,UAAU;cACb;QACA,eAAe;QACf,sBAAsB,MAAM,KAAK,KAAK,YAAY,eAAe,CAAA,uBAAA,MAAM,YAAY,cAAlB,kCAAA,uBAAsB;0BACvF;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 /** The default selected value. */\n readonly defaultSelectedValue: 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 [initialValue] = useState(selectedValue);\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 defaultSelectedValue: props.value !== undefined ? initialValue : props.defaultValue ?? null,\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"}
@@ -1,103 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {FormValidationState, useFormValidationState} from '@react-stately/form';
14
- import {RadioGroupProps} from '@react-types/radio';
15
- import {useControlledState} from '@react-stately/utils';
16
- import {useMemo, useState} from 'react';
17
- import {ValidationState} from '@react-types/shared';
18
-
19
- export interface RadioGroupState extends FormValidationState {
20
- /**
21
- * The name for the group, used for native form submission.
22
- * @deprecated
23
- * @private
24
- */
25
- readonly name: string,
26
-
27
- /** Whether the radio group is disabled. */
28
- readonly isDisabled: boolean,
29
-
30
- /** Whether the radio group is read only. */
31
- readonly isReadOnly: boolean,
32
-
33
- /** Whether the radio group is required. */
34
- readonly isRequired: boolean,
35
-
36
- /**
37
- * Whether the radio group is valid or invalid.
38
- * @deprecated Use `isInvalid` instead.
39
- */
40
- readonly validationState: ValidationState | null,
41
-
42
- /** Whether the radio group is invalid. */
43
- readonly isInvalid: boolean,
44
-
45
- /** The currently selected value. */
46
- readonly selectedValue: string | null,
47
-
48
- /** The default selected value. */
49
- readonly defaultSelectedValue: string | null,
50
-
51
- /** Sets the selected value. */
52
- setSelectedValue(value: string | null): void,
53
-
54
- /** The value of the last focused radio. */
55
- readonly lastFocusedValue: string | null,
56
-
57
- /** Sets the last focused value. */
58
- setLastFocusedValue(value: string | null): void
59
- }
60
-
61
- let instance = Math.round(Math.random() * 10000000000);
62
- let i = 0;
63
-
64
- /**
65
- * Provides state management for a radio group component. Provides a name for the group,
66
- * and manages selection and focus state.
67
- */
68
- export function useRadioGroupState(props: RadioGroupProps): RadioGroupState {
69
- // Preserved here for backward compatibility. React Aria now generates the name instead of stately.
70
- let name = useMemo(() => props.name || `radio-group-${instance}-${++i}`, [props.name]);
71
- let [selectedValue, setSelected] = useControlledState(props.value, props.defaultValue ?? null, props.onChange);
72
- let [initialValue] = useState(selectedValue);
73
- let [lastFocusedValue, setLastFocusedValue] = useState<string | null>(null);
74
-
75
- let validation = useFormValidationState({
76
- ...props,
77
- value: selectedValue
78
- });
79
-
80
- let setSelectedValue = (value) => {
81
- if (!props.isReadOnly && !props.isDisabled) {
82
- setSelected(value);
83
- validation.commitValidation();
84
- }
85
- };
86
-
87
- let isInvalid = validation.displayValidation.isInvalid;
88
-
89
- return {
90
- ...validation,
91
- name,
92
- selectedValue: selectedValue,
93
- defaultSelectedValue: props.value !== undefined ? initialValue : props.defaultValue ?? null,
94
- setSelectedValue,
95
- lastFocusedValue,
96
- setLastFocusedValue,
97
- isDisabled: props.isDisabled || false,
98
- isReadOnly: props.isReadOnly || false,
99
- isRequired: props.isRequired || false,
100
- validationState: props.validationState || (isInvalid ? 'invalid' : null),
101
- isInvalid
102
- };
103
- }