diff --git a/packages/react/src/components/form/form.stories.tsx b/packages/react/src/components/form/form.stories.tsx index f49154d57..ddd8e790b 100644 --- a/packages/react/src/components/form/form.stories.tsx +++ b/packages/react/src/components/form/form.stories.tsx @@ -35,27 +35,36 @@ interface Values { export const Playground: Story> = (props) => (
- - First name - + + + First name + + + Please fill in this field - - Last name - + + + Last name + + + Please fill in this field - - Email address - + + + Email address + + + Please fill in this field diff --git a/packages/react/src/components/input/input.stories.tsx b/packages/react/src/components/input/input.stories.tsx index 4b6cb4610..3b0fa73d8 100644 --- a/packages/react/src/components/input/input.stories.tsx +++ b/packages/react/src/components/input/input.stories.tsx @@ -1,5 +1,6 @@ import { Field, + FieldLabel, HelperText, Input, InputProps, @@ -26,9 +27,6 @@ export default { title: 'React/Input', component: Input, argTypes: { - children: { - description: 'Acts as a label for an ``.', - }, disabled: { table: { type: { summary: 'boolean' } }, }, @@ -47,7 +45,6 @@ export default { }, }, args: { - children: 'Label', disabled: false, invalid: false, placeholder: 'Placeholder', @@ -66,31 +63,25 @@ Invalid.argTypes = omit('invalid'); export const Disabled = reactMatrix(Input, { disabled }); Disabled.argTypes = omit('disabled'); -export const WithoutLabel = (props: InputProps) => ; -WithoutLabel.argTypes = omit('children'); -WithoutLabel.args = { - children: null, -}; - -interface InputWithHelperTextProps extends InputProps { +interface InputWithLabelAndHelperTextProps extends InputProps { label: string; helperText: string; } -export const WithHelperText = ({ +export const WithLabelAndHelperText = ({ label, helperText, ...restProps -}: InputWithHelperTextProps) => ( +}: InputWithLabelAndHelperTextProps) => ( - + {label} {helperText} - + + ); -WithHelperText.argTypes = omit('children'); -WithHelperText.args = { +WithLabelAndHelperText.args = { label: 'Label', helperText: 'Helper text', }; diff --git a/packages/react/src/components/input/input.tsx b/packages/react/src/components/input/input.tsx index 9f431381e..9bf5adecc 100644 --- a/packages/react/src/components/input/input.tsx +++ b/packages/react/src/components/input/input.tsx @@ -44,4 +44,19 @@ export const Input = withRef( ); Input.displayName = 'Input'; -export type InputProps = BaseProps & JSX.IntrinsicElements['input']; +export type InputProps = BaseProps & + Omit & { + /** + * @deprecated + * Use component composition instead. + * + * @example + * + * My Label + * + * + */ + children?: InputElementProps['children']; + }; + +type InputElementProps = JSX.IntrinsicElements['input']; diff --git a/packages/react/src/components/textarea/textarea.stories.tsx b/packages/react/src/components/textarea/textarea.stories.tsx index c8106e7ec..3e3319030 100644 --- a/packages/react/src/components/textarea/textarea.stories.tsx +++ b/packages/react/src/components/textarea/textarea.stories.tsx @@ -1,5 +1,6 @@ import { Field, + FieldLabel, HelperText, Textarea, TextareaProps, @@ -23,9 +24,6 @@ export default { title: 'React/Textarea', component: Textarea, argTypes: { - children: { - description: 'Acts as a label for a ` +