Files
editor/src/components/InputSelect.tsx
Harel M 656264f2bc Migration of jsx files to tsx 3 (#851)
This is in continue to:
- #850
- #848

The last files should be converted as part of this PR, there are only a
handful left.
2023-12-25 15:48:46 +02:00

35 lines
919 B
TypeScript

import React from 'react'
export type InputSelectProps = {
value: string
"data-wd-key"?: string
options: [string, any][] | string[]
style?: object
onChange(value: string | [string, any]): unknown
title?: string
'aria-label'?: string
};
export default class InputSelect extends React.Component<InputSelectProps> {
render() {
let options = this.props.options;
if(options.length > 0 && !Array.isArray(options[0])) {
options = options.map((v) => [v, v]) as [string, any][];
}
return <select
className="maputnik-select"
data-wd-key={this.props["data-wd-key"]}
style={this.props.style}
title={this.props.title}
value={this.props.value}
onChange={e => this.props.onChange(e.target.value)}
aria-label={this.props['aria-label']}
>
{ options.map(([val, label]) => <option key={val} value={val}>{label}</option>) }
</select>
}
}