Skip to content

Commit

Permalink
feat: Toggle label or placeholder via types
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Nov 14, 2024
1 parent b5f66ad commit d17220b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion editor.planx.uk/src/ui/shared/SelectMultiple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,20 @@ type OptionalAutocompleteProps<T> = Partial<
Omit<AutocompleteProps<T, true, true, false, "div">, "multiple">
>;

type Props<T> = {
type WithLabel<T> = {
label: string;
placeholder?: never;
} & RequiredAutocompleteProps<T> &
OptionalAutocompleteProps<T>;

type WithPlaceholder<T> = {
label?: never;
placeholder: string;
} & RequiredAutocompleteProps<T> &
OptionalAutocompleteProps<T>;

type Props<T> = WithLabel<T> | WithPlaceholder<T>;

const StyledAutocomplete = styled(Autocomplete)(({ theme }) => ({
marginTop: theme.spacing(2),
"& > div > label": {
Expand Down Expand Up @@ -120,6 +129,7 @@ export function SelectMultiple<T>(props: Props<T>) {
InputProps={{
...params.InputProps,
notched: false,
placeholder: props?.placeholder
}}
label={props.label}
/>
Expand Down

0 comments on commit d17220b

Please sign in to comment.