Skip to content

docs(Form): add JSDoc comments #931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/main/src/components/Form/Form.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import { DocsHeader } from '@shared/stories/DocsHeader';
<Story name="Default">
{(args) => (
<Form {...args} title={args.title}>
<FormItem label={'Sole Form Item'}>
<Input type={InputType.Text} />
</FormItem>
<FormGroup title={'Personal Data'}>
<FormItem label={'Name'}>
<Input type={InputType.Text} />
Expand All @@ -52,9 +55,6 @@ import { DocsHeader } from '@shared/stories/DocsHeader';
<CheckBox checked />
</FormItem>
</FormGroup>
<FormItem label={'Sole Form Item'}>
<Input type={InputType.Text} />
</FormItem>
<FormGroup title={'Company Data'}>
<FormItem label={'Company Name'}>
<Input type={InputType.Text} />
Expand Down Expand Up @@ -91,9 +91,9 @@ import { DocsHeader } from '@shared/stories/DocsHeader';
</Story>
</Canvas>

<ArgsTable story="." />

### Usage Notes

Please note that the `FormGroup` and `FormItem` components are only used for calculating the final layout of the `Form`,
thus they don't accept any other props then the specified ones, especially no `className`, `style` or `ref`.

<ArgsTable story="." />
thus they don't accept any other props than the specified ones, especially no `className`, `style` or `ref`.
4 changes: 3 additions & 1 deletion packages/main/src/components/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export interface FormPropTypes extends CommonProps {
}

const useStyles = createComponentStyles(styles, { name: 'Form' });

/**
* The `Form` component arranges labels and fields into groups and rows. There are different ways to visualize forms for different screen sizes.
*/
const Form: FC<FormPropTypes> = forwardRef((props: FormPropTypes, ref: Ref<HTMLDivElement>) => {
const {
title,
Expand Down
5 changes: 4 additions & 1 deletion packages/main/src/components/FormGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const useStyles = createComponentStyles(
},
{ name: 'FormGroup' }
);

/**
* The `FormGroup` encapsulates `FormItems` into groups.
* __Note:__ `FormGroup` is only used for calculating the final layout of the `Form`, thus it doesn't accept any other props than `title` and `children`, especially no `className`, `style` or `ref`.
*/
const FormGroup: FC<FormGroupProps> = (props: FormGroupProps) => {
const { title, children } = props;

Expand Down
4 changes: 3 additions & 1 deletion packages/main/src/components/FormItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ const renderLabel = (

return null;
};

/**
* The `FormItem` is only used for calculating the final layout of the `Form`, thus it doesn't accept any other props than `label` and `children`, especially no `className`, `style` or `ref`.
*/
const FormItem: FC<FormItemProps> = (props: FormItemProps) => {
const { label, children, columnIndex, rowIndex, labelSpan } = props as InternalProps;

Expand Down