From 21e5e0672ad39b2d29effe9f4029161b93010a49 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Sun, 9 Oct 2022 08:54:57 +0800 Subject: [PATCH] [ui][radio list] remove disabled prop on radio list level --- apps/storybook/stories/radio-list.stories.tsx | 24 +++++++------------ packages/ui/src/RadioList/RadioList.tsx | 6 ++--- packages/ui/src/RadioList/RadioListContext.ts | 1 - packages/ui/src/RadioList/RadioListItem.tsx | 8 ++++--- 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/apps/storybook/stories/radio-list.stories.tsx b/apps/storybook/stories/radio-list.stories.tsx index 4217bd13..91ca7b72 100644 --- a/apps/storybook/stories/radio-list.stories.tsx +++ b/apps/storybook/stories/radio-list.stories.tsx @@ -29,7 +29,11 @@ export default { export function Basic({ description, label, -}: Pick, 'description' | 'label'>) { + orientation, +}: Pick< + React.ComponentProps, + 'description' | 'label' | 'orientation' +>) { const items = [ { label: 'Apple', @@ -50,7 +54,8 @@ export function Basic({ defaultValue="apple" description={description} label={label} - name="fruit"> + name="fruit" + orientation={orientation}> {items.map(({ label: itemLabel, value }) => ( ))} @@ -61,6 +66,7 @@ export function Basic({ Basic.args = { description: 'Your favorite fruit', label: 'Choose a fruit', + orientation: 'vertical', }; export function Controlled() { @@ -148,22 +154,10 @@ export function Disabled() { }, ]; - const [value, setValue] = useState('apple'); - return (
setValue(newValue)}> - {items.map(({ label: itemLabel, value: itemValue }) => ( - - ))} - - - {items.map( diff --git a/packages/ui/src/RadioList/RadioList.tsx b/packages/ui/src/RadioList/RadioList.tsx index 974491f1..6919c819 100644 --- a/packages/ui/src/RadioList/RadioList.tsx +++ b/packages/ui/src/RadioList/RadioList.tsx @@ -11,7 +11,6 @@ type Props = Readonly<{ children: ReadonlyArray>; defaultValue?: T; description?: string; - disabled?: boolean; isLabelHidden?: boolean; label: string; name?: string; @@ -27,10 +26,9 @@ export default function RadioList({ children, defaultValue, description, - disabled, - orientation = 'vertical', isLabelHidden, name, + orientation = 'vertical', label, required, value, @@ -41,7 +39,7 @@ export default function RadioList({ + value={{ defaultValue, name, onChange, value }}>