mirror of
https://github.com/zadam/trilium.git
synced 2025-11-12 06:40:50 +08:00
chore(react/settings): allow combo to have any possible object structure
This commit is contained in:
parent
d42a949602
commit
83b22b4861
1 changed files with 8 additions and 6 deletions
|
|
@ -1,10 +1,12 @@
|
|||
interface FormSelectProps {
|
||||
interface FormSelectProps<T> {
|
||||
currentValue?: string;
|
||||
onChange(newValue: string): void;
|
||||
values: { val: string, title: string }[];
|
||||
values: T[];
|
||||
keyProperty: keyof T;
|
||||
titleProperty: keyof T;
|
||||
}
|
||||
|
||||
export default function FormSelect({ currentValue, values, onChange }: FormSelectProps) {
|
||||
export default function FormSelect<T>({ currentValue, values, onChange, keyProperty, titleProperty }: FormSelectProps<T>) {
|
||||
return (
|
||||
<select
|
||||
class="form-select"
|
||||
|
|
@ -13,10 +15,10 @@ export default function FormSelect({ currentValue, values, onChange }: FormSelec
|
|||
{values.map(item => {
|
||||
return (
|
||||
<option
|
||||
value={item.val}
|
||||
selected={item.val === currentValue}
|
||||
value={item[keyProperty] as any}
|
||||
selected={item[keyProperty] === currentValue}
|
||||
>
|
||||
{item.title}
|
||||
{item[titleProperty] as any}
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue