From cdfc2ff36ce53bd9df6e92a4e8a3c1ba77c908c4 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Sat, 29 Oct 2022 01:02:42 +0900 Subject: [PATCH 1/4] RadioGroup: Mark as deprecated --- packages/components/src/radio-group/README.md | 4 ++++ packages/components/src/radio-group/index.js | 5 +++++ packages/components/src/radio-group/stories/index.js | 11 ++++++++++- packages/components/src/radio/index.js | 5 +++++ packages/components/tsconfig.json | 2 -- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/packages/components/src/radio-group/README.md b/packages/components/src/radio-group/README.md index b446ef705e8a0..239205ec428f7 100644 --- a/packages/components/src/radio-group/README.md +++ b/packages/components/src/radio-group/README.md @@ -1,5 +1,9 @@ # RadioGroup +
+This component is deprecated. Consider using `RadioControl` or `ToggleGroupControl` instead. +
+
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
diff --git a/packages/components/src/radio-group/index.js b/packages/components/src/radio-group/index.js index 471734ca421de..fa4bb4cb0e8b5 100644 --- a/packages/components/src/radio-group/index.js +++ b/packages/components/src/radio-group/index.js @@ -1,3 +1,5 @@ +// @ts-nocheck + /** * External dependencies */ @@ -43,4 +45,7 @@ function RadioGroup( ); } +/** + * @deprecated Use `RadioControl` or `ToggleGroupControl` instead. + */ export default forwardRef( RadioGroup ); diff --git a/packages/components/src/radio-group/stories/index.js b/packages/components/src/radio-group/stories/index.js index c827c180c7fe2..d321e46961111 100644 --- a/packages/components/src/radio-group/stories/index.js +++ b/packages/components/src/radio-group/stories/index.js @@ -10,8 +10,17 @@ import Radio from '../../radio'; import RadioGroup from '../'; export default { - title: 'Components (Experimental)/RadioGroup', + title: 'Components (Deprecated)/RadioGroup', + subcomponents: { Radio }, component: RadioGroup, + parameters: { + docs: { + description: { + component: + 'This component is deprecated. Use `RadioControl` or `ToggleGroupControl` instead.', + }, + }, + }, }; export const _default = () => { diff --git a/packages/components/src/radio/index.js b/packages/components/src/radio/index.js index d7bdefbe608c9..fc39407919cab 100644 --- a/packages/components/src/radio/index.js +++ b/packages/components/src/radio/index.js @@ -1,3 +1,5 @@ +// @ts-nocheck + /** * External dependencies */ @@ -32,4 +34,7 @@ function Radio( { children, value, ...props }, ref ) { ); } +/** + * @deprecated Use `RadioControl` or `ToggleGroupControl` instead. + */ export default forwardRef( Radio ); diff --git a/packages/components/tsconfig.json b/packages/components/tsconfig.json index 5c103f27ead05..c5d62d9423779 100644 --- a/packages/components/tsconfig.json +++ b/packages/components/tsconfig.json @@ -63,8 +63,6 @@ "src/palette-edit", "src/panel", "src/query-controls", - "src/radio", - "src/radio-group", "src/responsive-wrapper", "src/sandbox", "src/snackbar", From dd36140d2c379e79021920bef1d64a6c6a3ae69e Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Sat, 29 Oct 2022 01:07:37 +0900 Subject: [PATCH 2/4] Remove separate story for Radio --- .../components/src/radio/stories/index.js | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 packages/components/src/radio/stories/index.js diff --git a/packages/components/src/radio/stories/index.js b/packages/components/src/radio/stories/index.js deleted file mode 100644 index 622935a76e076..0000000000000 --- a/packages/components/src/radio/stories/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Internal dependencies - */ -import RadioGroup from '../../radio-group'; -import Radio from '../'; - -export default { title: 'Components (Experimental)/Radio', component: Radio }; - -export const _default = () => { - // Radio components must be a descendent of a RadioGroup component. - /* eslint-disable no-restricted-syntax */ - return ( - // id is required for server side rendering - - Option 1 - Option 2 - - ); - /* eslint-enable no-restricted-syntax */ -}; From 0a355c3a04e952bd9216328daf7ce04106b532e8 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Sat, 29 Oct 2022 01:38:00 +0900 Subject: [PATCH 3/4] Move into subfolders --- packages/components/src/index.js | 2 +- packages/components/src/radio-group/index.js | 2 +- .../components/src/{ => radio-group}/radio-context/index.js | 0 packages/components/src/{ => radio-group}/radio/index.js | 2 +- packages/components/src/radio-group/stories/index.js | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename packages/components/src/{ => radio-group}/radio-context/index.js (100%) rename packages/components/src/{ => radio-group}/radio/index.js (95%) diff --git a/packages/components/src/index.js b/packages/components/src/index.js index 28f119c9237ef..dfcc483138a53 100644 --- a/packages/components/src/index.js +++ b/packages/components/src/index.js @@ -127,7 +127,7 @@ export { default as PanelRow } from './panel/row'; export { default as Placeholder } from './placeholder'; export { default as Popover } from './popover'; export { default as QueryControls } from './query-controls'; -export { default as __experimentalRadio } from './radio'; +export { default as __experimentalRadio } from './radio-group/radio'; export { default as __experimentalRadioGroup } from './radio-group'; export { default as RadioControl } from './radio-control'; export { default as RangeControl } from './range-control'; diff --git a/packages/components/src/radio-group/index.js b/packages/components/src/radio-group/index.js index fa4bb4cb0e8b5..a94493c5f2fd8 100644 --- a/packages/components/src/radio-group/index.js +++ b/packages/components/src/radio-group/index.js @@ -14,7 +14,7 @@ import { forwardRef } from '@wordpress/element'; * Internal dependencies */ import ButtonGroup from '../button-group'; -import RadioContext from '../radio-context'; +import RadioContext from './radio-context'; function RadioGroup( { label, checked, defaultChecked, disabled, onChange, ...props }, diff --git a/packages/components/src/radio-context/index.js b/packages/components/src/radio-group/radio-context/index.js similarity index 100% rename from packages/components/src/radio-context/index.js rename to packages/components/src/radio-group/radio-context/index.js diff --git a/packages/components/src/radio/index.js b/packages/components/src/radio-group/radio/index.js similarity index 95% rename from packages/components/src/radio/index.js rename to packages/components/src/radio-group/radio/index.js index fc39407919cab..446850c421b4c 100644 --- a/packages/components/src/radio/index.js +++ b/packages/components/src/radio-group/radio/index.js @@ -13,7 +13,7 @@ import { useContext, forwardRef } from '@wordpress/element'; /** * Internal dependencies */ -import Button from '../button'; +import Button from '../../button'; import RadioContext from '../radio-context'; function Radio( { children, value, ...props }, ref ) { diff --git a/packages/components/src/radio-group/stories/index.js b/packages/components/src/radio-group/stories/index.js index d321e46961111..10fb5dfd02800 100644 --- a/packages/components/src/radio-group/stories/index.js +++ b/packages/components/src/radio-group/stories/index.js @@ -6,7 +6,7 @@ import { useState } from '@wordpress/element'; /** * Internal dependencies */ -import Radio from '../../radio'; +import Radio from '../radio'; import RadioGroup from '../'; export default { From 72fa47170f60836f8b38ebe4225682127c2d5e78 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Sat, 29 Oct 2022 01:57:05 +0900 Subject: [PATCH 4/4] Update changelog --- packages/components/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 80f8a21565b1f..8593619d7e9e8 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -8,7 +8,8 @@ ### Deprecations -- `Popover`: the deprecation messages for anchor-related props (`anchorRef`, `anchorRect`, `getAnchorRect`) have been updated. ([#45195](https://github.com/WordPress/gutenberg/pull/45195)). +- `Popover`: the deprecation messages for anchor-related props (`anchorRef`, `anchorRect`, `getAnchorRect`) have been updated ([#45195](https://github.com/WordPress/gutenberg/pull/45195)). +- `RadioGroup`: Mark as deprecated, in favor of `RadioControl` and `ToggleGroupControl` ([#45389](https://github.com/WordPress/gutenberg/pull/45389)). ### New Feature