mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	chore(react/settings): allow combo to have any possible object structure
This commit is contained in:
		| @@ -1,10 +1,12 @@ | |||||||
| interface FormSelectProps { | interface FormSelectProps<T> { | ||||||
|     currentValue?: string; |     currentValue?: string; | ||||||
|     onChange(newValue: string): void; |     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 ( |     return ( | ||||||
|         <select |         <select | ||||||
|             class="form-select" |             class="form-select" | ||||||
| @@ -13,10 +15,10 @@ export default function FormSelect({ currentValue, values, onChange }: FormSelec | |||||||
|             {values.map(item => { |             {values.map(item => { | ||||||
|                 return ( |                 return ( | ||||||
|                     <option |                     <option | ||||||
|                         value={item.val} |                         value={item[keyProperty] as any} | ||||||
|                         selected={item.val === currentValue} |                         selected={item[keyProperty] === currentValue} | ||||||
|                     > |                     > | ||||||
|                         {item.title} |                         {item[titleProperty] as any} | ||||||
|                     </option> |                     </option> | ||||||
|                 ); |                 ); | ||||||
|             })} |             })} | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user