This repository was archived by the owner on Jan 9, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,20 +2,23 @@ import React from 'react'
22import { Typeahead } from 'react-bootstrap-typeahead'
33import 'react-bootstrap-typeahead/css/Typeahead.css'
44
5- type SelectOption = { label : string ; value : any }
5+ interface SelectOption < T > {
6+ label : string
7+ value : T
8+ }
69
7- interface Props {
10+ interface Props < T > {
811 id : string
9- options : SelectOption [ ]
10- defaultSelected ?: SelectOption [ ]
11- onChange ?: ( values : string [ ] ) => void
12+ options : SelectOption < T > [ ]
13+ defaultSelected ?: SelectOption < T > [ ]
14+ onChange ?: ( values : T [ ] ) => void
1215 placeholder ?: string
1316 multiple ?: boolean
1417 disabled ?: boolean
1518 isInvalid ?: boolean
1619}
1720
18- const Select = ( props : Props ) => {
21+ function Select < T > ( props : Props < T > ) {
1922 const {
2023 id,
2124 options,
@@ -28,11 +31,11 @@ const Select = (props: Props) => {
2831 } = props
2932
3033 return (
31- < Typeahead < SelectOption >
34+ < Typeahead < SelectOption < T > >
3235 id = { id }
3336 options = { options as any }
3437 selected = { defaultSelected }
35- onChange = { ( selected : SelectOption [ ] ) => {
38+ onChange = { ( selected : SelectOption < T > [ ] ) => {
3639 if ( onChange !== undefined ) {
3740 onChange ( selected . map ( ( option ) => option . value ) )
3841 }
You can’t perform that action at this time.
0 commit comments