hensei-web/components/common/SelectTableField/index.tsx
Justin Edmund 4c5fb3c28d Rename all files and fix imports
* Renaming index.scss files to index.module.scss
* Changing `import from` to `import styles from`
2023-06-23 13:19:38 -07:00

56 lines
1.3 KiB
TypeScript

import classNames from 'classnames'
import { useEffect, useState } from 'react'
import Select from '~components/common/Select'
import TableField from '~components/common/TableField'
import styles from './index.module.scss'
interface Props {
name: string
label: string
description?: string
open: boolean
value?: string
className?: string
imageAlt?: string
imageClass?: string
imageSrc?: string[]
children: React.ReactNode
onOpenChange: () => void
onChange: (value: string) => void
onClose: () => void
}
const SelectTableField = (props: Props) => {
const [value, setValue] = useState('')
useEffect(() => {
if (props.value) setValue(props.value)
}, [props.value])
return (
<TableField
name={props.name}
className="SelectField"
imageAlt={props.imageAlt}
imageClass={props.imageClass}
imageSrc={props.imageSrc}
label={props.label}
>
<Select
name={props.name}
open={props.open}
onOpenChange={props.onOpenChange}
onValueChange={props.onChange}
onClose={props.onClose}
triggerClass={classNames({ Bound: true, Table: true })}
value={value}
overlayVisible={false}
>
{props.children}
</Select>
</TableField>
)
}
export default SelectTableField