diff --git a/packages/react-material-ui/__tests__/Select.spec.tsx b/packages/react-material-ui/__tests__/Select.spec.tsx index 05f1f728..707e3636 100644 --- a/packages/react-material-ui/__tests__/Select.spec.tsx +++ b/packages/react-material-ui/__tests__/Select.spec.tsx @@ -5,7 +5,7 @@ import '@testing-library/jest-dom'; import React from 'react'; import { render, fireEvent } from '@testing-library/react'; -import Select, { SelectOptions } from '../src/components/Select/Select'; +import { Select, SelectOptions } from '../src/components/Select/Select'; describe('Select Component', () => { const options: SelectOptions[] = [ diff --git a/packages/react-material-ui/src/components/Select/Select.tsx b/packages/react-material-ui/src/components/Select/Select.tsx index 2c25e175..f36d27a5 100644 --- a/packages/react-material-ui/src/components/Select/Select.tsx +++ b/packages/react-material-ui/src/components/Select/Select.tsx @@ -10,19 +10,60 @@ import { import { FormLabel } from '../FormLabel'; import { TextProps } from 'interfaces'; +/** + * Option type for the Select component. + */ export type SelectOptions = { + /** Display label for the option */ label: string; + /** Value associated with the option */ value: string | number; + /** Whether the option is disabled */ disabled?: boolean; }; -type Props = { +/** + * Props for the Select component. + */ +export type SelectProps = TextFieldProps & { + /** Props for the container `Box` element */ containerProps?: BoxProps; + /** Props for the label component */ labelProps?: TextProps; + /** Array of selectable options */ options: SelectOptions[]; }; -const Select = (props: Props & TextFieldProps) => { +/** + * The Select component is a custom dropdown that leverages Material-UI's + * `TextField` component with a `select` prop, allowing for a selection + * from a list of options. It supports custom labels, error handling, + * and can be styled using additional props for the container and label. + * It's props extend from [Material UI's TextField](https://mui.com/material-ui/api/text-field/#props) component props, so every + * prop is interchangeable between those two. + * + * @see [Storybook - Select](https://storybook.rockets.tools/?path=/docs/select) + * + * @example + * ```tsx + *