mirror of
https://github.com/Steffo99/bluelib.git
synced 2024-12-25 13:04:20 +00:00
44 lines
991 B
TypeScript
44 lines
991 B
TypeScript
|
import * as React from "react"
|
||
|
import * as ReactDOM from "react-dom"
|
||
|
import * as Types from "../../types"
|
||
|
import {BaseElement} from "../BaseElement"
|
||
|
import mergeClassNames from "classnames"
|
||
|
|
||
|
|
||
|
interface SelectProps {
|
||
|
disabled?: boolean,
|
||
|
|
||
|
onChange?: (contents: string) => boolean,
|
||
|
value?: string,
|
||
|
|
||
|
children: React.ReactNode,
|
||
|
|
||
|
[props: string]: any,
|
||
|
}
|
||
|
|
||
|
|
||
|
export function Select({onChange, children, ...props}: SelectProps): JSX.Element {
|
||
|
props.bluelibClassNames = mergeClassNames(props.bluelibClassNames, "input", "input-select")
|
||
|
|
||
|
const onChangeWrapper = React.useCallback(
|
||
|
|
||
|
(event: React.ChangeEvent<HTMLInputElement>): boolean => {
|
||
|
const contents = event.target.value
|
||
|
|
||
|
if(onChange) {
|
||
|
return onChange(contents)
|
||
|
}
|
||
|
|
||
|
return false
|
||
|
},
|
||
|
|
||
|
[onChange]
|
||
|
)
|
||
|
|
||
|
return (
|
||
|
<BaseElement kind={"select"} multiple={false} {...props}>
|
||
|
// TODO
|
||
|
</BaseElement>
|
||
|
)
|
||
|
}
|