@react-stately/radio 3.10.14 → 3.11.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/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/useRadioGroupState.main.js +3 -0
- package/dist/useRadioGroupState.main.js.map +1 -1
- package/dist/useRadioGroupState.mjs +3 -0
- package/dist/useRadioGroupState.module.js +3 -0
- package/dist/useRadioGroupState.module.js.map +1 -1
- package/package.json +6 -6
- package/src/useRadioGroupState.ts +5 -0
package/dist/types.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface RadioGroupState extends FormValidationState {
|
|
|
23
23
|
readonly isInvalid: boolean;
|
|
24
24
|
/** The currently selected value. */
|
|
25
25
|
readonly selectedValue: string | null;
|
|
26
|
+
/** The default selected value. */
|
|
27
|
+
readonly defaultSelectedValue: string | null;
|
|
26
28
|
/** Sets the selected value. */
|
|
27
29
|
setSelectedValue(value: string | null): void;
|
|
28
30
|
/** The value of the last focused radio. */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,+BAA+B;IAC/B,gBAAgB,CAAC,KAAK,EAA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io/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"}
|
|
@@ -30,6 +30,7 @@ function $307db30b5687e2e8$export$bca9d026f8e704eb(props) {
|
|
|
30
30
|
]);
|
|
31
31
|
var _props_defaultValue;
|
|
32
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);
|
|
33
34
|
let [lastFocusedValue, setLastFocusedValue] = (0, $cVa5U$react.useState)(null);
|
|
34
35
|
let validation = (0, $cVa5U$reactstatelyform.useFormValidationState)({
|
|
35
36
|
...props,
|
|
@@ -42,10 +43,12 @@ function $307db30b5687e2e8$export$bca9d026f8e704eb(props) {
|
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
45
|
let isInvalid = validation.displayValidation.isInvalid;
|
|
46
|
+
var _props_defaultValue1;
|
|
45
47
|
return {
|
|
46
48
|
...validation,
|
|
47
49
|
name: name,
|
|
48
50
|
selectedValue: selectedValue,
|
|
51
|
+
defaultSelectedValue: props.value !== undefined ? initialValue : (_props_defaultValue1 = props.defaultValue) !== null && _props_defaultValue1 !== void 0 ? _props_defaultValue1 : null,
|
|
49
52
|
setSelectedValue: setSelectedValue,
|
|
50
53
|
lastFocusedValue: lastFocusedValue,
|
|
51
54
|
setLastFocusedValue: setLastFocusedValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;
|
|
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"}
|
|
@@ -24,6 +24,7 @@ function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
|
24
24
|
]);
|
|
25
25
|
var _props_defaultValue;
|
|
26
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);
|
|
27
28
|
let [lastFocusedValue, setLastFocusedValue] = (0, $l55kx$useState)(null);
|
|
28
29
|
let validation = (0, $l55kx$useFormValidationState)({
|
|
29
30
|
...props,
|
|
@@ -36,10 +37,12 @@ function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
let isInvalid = validation.displayValidation.isInvalid;
|
|
40
|
+
var _props_defaultValue1;
|
|
39
41
|
return {
|
|
40
42
|
...validation,
|
|
41
43
|
name: name,
|
|
42
44
|
selectedValue: selectedValue,
|
|
45
|
+
defaultSelectedValue: props.value !== undefined ? initialValue : (_props_defaultValue1 = props.defaultValue) !== null && _props_defaultValue1 !== void 0 ? _props_defaultValue1 : null,
|
|
43
46
|
setSelectedValue: setSelectedValue,
|
|
44
47
|
lastFocusedValue: lastFocusedValue,
|
|
45
48
|
setLastFocusedValue: setLastFocusedValue,
|
|
@@ -24,6 +24,7 @@ function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
|
24
24
|
]);
|
|
25
25
|
var _props_defaultValue;
|
|
26
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);
|
|
27
28
|
let [lastFocusedValue, setLastFocusedValue] = (0, $l55kx$useState)(null);
|
|
28
29
|
let validation = (0, $l55kx$useFormValidationState)({
|
|
29
30
|
...props,
|
|
@@ -36,10 +37,12 @@ function $a54cdc5c1942b639$export$bca9d026f8e704eb(props) {
|
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
let isInvalid = validation.displayValidation.isInvalid;
|
|
40
|
+
var _props_defaultValue1;
|
|
39
41
|
return {
|
|
40
42
|
...validation,
|
|
41
43
|
name: name,
|
|
42
44
|
selectedValue: selectedValue,
|
|
45
|
+
defaultSelectedValue: props.value !== undefined ? initialValue : (_props_defaultValue1 = props.defaultValue) !== null && _props_defaultValue1 !== void 0 ? _props_defaultValue1 : null,
|
|
43
46
|
setSelectedValue: setSelectedValue,
|
|
44
47
|
lastFocusedValue: lastFocusedValue,
|
|
45
48
|
setLastFocusedValue: setLastFocusedValue,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;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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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/radio",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@react-stately/form": "^3.
|
|
30
|
-
"@react-stately/utils": "^3.10.
|
|
31
|
-
"@react-types/radio": "^3.
|
|
32
|
-
"@react-types/shared": "^3.
|
|
29
|
+
"@react-stately/form": "^3.2.0",
|
|
30
|
+
"@react-stately/utils": "^3.10.8",
|
|
31
|
+
"@react-types/radio": "^3.9.0",
|
|
32
|
+
"@react-types/shared": "^3.31.0",
|
|
33
33
|
"@swc/helpers": "^0.5.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "8b9348ff255e018b2dd9b27e2a45507cadfa1d35"
|
|
42
42
|
}
|
|
@@ -45,6 +45,9 @@ export interface RadioGroupState extends FormValidationState {
|
|
|
45
45
|
/** The currently selected value. */
|
|
46
46
|
readonly selectedValue: string | null,
|
|
47
47
|
|
|
48
|
+
/** The default selected value. */
|
|
49
|
+
readonly defaultSelectedValue: string | null,
|
|
50
|
+
|
|
48
51
|
/** Sets the selected value. */
|
|
49
52
|
setSelectedValue(value: string | null): void,
|
|
50
53
|
|
|
@@ -66,6 +69,7 @@ export function useRadioGroupState(props: RadioGroupProps): RadioGroupState {
|
|
|
66
69
|
// Preserved here for backward compatibility. React Aria now generates the name instead of stately.
|
|
67
70
|
let name = useMemo(() => props.name || `radio-group-${instance}-${++i}`, [props.name]);
|
|
68
71
|
let [selectedValue, setSelected] = useControlledState(props.value, props.defaultValue ?? null, props.onChange);
|
|
72
|
+
let [initialValue] = useState(selectedValue);
|
|
69
73
|
let [lastFocusedValue, setLastFocusedValue] = useState<string | null>(null);
|
|
70
74
|
|
|
71
75
|
let validation = useFormValidationState({
|
|
@@ -86,6 +90,7 @@ export function useRadioGroupState(props: RadioGroupProps): RadioGroupState {
|
|
|
86
90
|
...validation,
|
|
87
91
|
name,
|
|
88
92
|
selectedValue: selectedValue,
|
|
93
|
+
defaultSelectedValue: props.value !== undefined ? initialValue : props.defaultValue ?? null,
|
|
89
94
|
setSelectedValue,
|
|
90
95
|
lastFocusedValue,
|
|
91
96
|
setLastFocusedValue,
|