mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-28 23:07:13 -04:00
Improve typings for select options
This commit is contained in:
@@ -1,12 +1,17 @@
|
||||
import classNames from 'classnames';
|
||||
import React, { ChangeEvent, SyntheticEvent, useCallback } from 'react';
|
||||
import React, {
|
||||
ChangeEvent,
|
||||
ComponentProps,
|
||||
SyntheticEvent,
|
||||
useCallback,
|
||||
} from 'react';
|
||||
import { InputChanged } from 'typings/inputs';
|
||||
import styles from './SelectInput.css';
|
||||
|
||||
interface SelectInputOption {
|
||||
key: string;
|
||||
export interface SelectInputOption
|
||||
extends Pick<ComponentProps<'option'>, 'disabled'> {
|
||||
key: string | number;
|
||||
value: string | number | (() => string | number);
|
||||
isDisabled?: boolean;
|
||||
}
|
||||
|
||||
interface SelectInputProps<T> {
|
||||
@@ -62,20 +67,10 @@ function SelectInput<T>({
|
||||
onBlur={onBlur}
|
||||
>
|
||||
{values.map((option) => {
|
||||
const {
|
||||
key,
|
||||
value: optionValue,
|
||||
isDisabled: optionIsDisabled = false,
|
||||
...otherOptionProps
|
||||
} = option;
|
||||
const { key, value: optionValue, ...otherOptionProps } = option;
|
||||
|
||||
return (
|
||||
<option
|
||||
key={key}
|
||||
value={key}
|
||||
disabled={optionIsDisabled}
|
||||
{...otherOptionProps}
|
||||
>
|
||||
<option key={key} value={key} {...otherOptionProps}>
|
||||
{typeof optionValue === 'function' ? optionValue() : optionValue}
|
||||
</option>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user