diff --git a/apps/storybook/stories/select.stories.tsx b/apps/storybook/stories/select.stories.tsx index 8050a030..e7b02537 100644 --- a/apps/storybook/stories/select.stories.tsx +++ b/apps/storybook/stories/select.stories.tsx @@ -7,6 +7,9 @@ const SelectDisplays: ReadonlyArray = ['inline', 'block']; export default { argTypes: { + disabled: { + control: 'boolean', + }, display: { control: { type: 'select' }, options: SelectDisplays, @@ -72,7 +75,7 @@ export function Display() { const [value, setValue] = useState('apple'); return ( -
+
+
+ ); +} + +export function HiddenLabel() { + const [value, setValue] = useState('apple'); + + return ( +
+
); } diff --git a/packages/ui/src/Select/Select.tsx b/packages/ui/src/Select/Select.tsx index 7f63c316..fe1fd708 100644 --- a/packages/ui/src/Select/Select.tsx +++ b/packages/ui/src/Select/Select.tsx @@ -1,6 +1,13 @@ import clsx from 'clsx'; +import type { ForwardedRef, SelectHTMLAttributes } from 'react'; +import { forwardRef } from 'react'; import { useId } from 'react'; +type Attributes = Pick< + SelectHTMLAttributes, + 'disabled' | 'name' | 'onBlur' | 'onFocus' | 'required' +>; + export type SelectItem = Readonly<{ label: string; value: T; @@ -16,17 +23,22 @@ type Props = Readonly<{ onChange: (value: string) => void; options: ReadonlyArray>; value: T; -}>; +}> & + Readonly; -export default function Select({ - display, - label, - isLabelHidden, - name, - options, - value, - onChange, -}: Props) { +function Select( + { + display, + disabled, + label, + isLabelHidden, + options, + value, + onChange, + ...props + }: Props, + ref: ForwardedRef, +) { const id = useId(); return ( @@ -40,17 +52,20 @@ export default function Select({ {label}