1
- import { TextField , Chip } from '@material-ui/core '
1
+ import classNames from 'classnames '
2
2
import Box from '@mui/material/Box'
3
- import { makeStyles } from '@material-ui/core'
3
+ import { TextField , Chip , makeStyles } from '@material-ui/core'
4
+
5
+ import { Select } from '@postgres.ai/shared/components/Select'
4
6
import { InfoIcon } from '@postgres.ai/shared/icons/Info'
5
7
import { Tooltip } from '@postgres.ai/shared/components/Tooltip'
8
+
6
9
import { uniqueDatabases } from '../utils'
7
10
8
11
import styles from '../styles.module.scss'
9
- import classNames from 'classnames'
10
12
11
13
const useStyles = makeStyles (
12
14
{
@@ -15,6 +17,16 @@ const useStyles = makeStyles(
15
17
borderColor : '#000 !important' ,
16
18
} ,
17
19
} ,
20
+ selectField : {
21
+ marginTop : '0' ,
22
+ '& .MuiInputBase-root' : {
23
+ padding : '6px' ,
24
+ } ,
25
+
26
+ '& .MuiSelect-select:focus' : {
27
+ backgroundColor : 'inherit' ,
28
+ } ,
29
+ } ,
18
30
} ,
19
31
{ index : 1 } ,
20
32
)
@@ -67,7 +79,10 @@ export const InputWithChip = ({
67
79
value : string
68
80
onChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void
69
81
tooltipText : ( ) => React . ReactNode
70
- handleDeleteDatabase : ( event : any , database : string ) => void
82
+ handleDeleteDatabase : (
83
+ event : React . FormEvent < HTMLInputElement > ,
84
+ database : string ,
85
+ ) => void
71
86
label : string
72
87
id : string
73
88
disabled : boolean | undefined
@@ -122,3 +137,46 @@ export const InputWithChip = ({
122
137
</ Box >
123
138
)
124
139
}
140
+
141
+ export const SelectWithTooltip = ( {
142
+ value,
143
+ label,
144
+ error,
145
+ onChange,
146
+ tooltipText,
147
+ disabled,
148
+ items,
149
+ } : {
150
+ value : string
151
+ onChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void
152
+ tooltipText : ( ) => React . ReactNode
153
+ label : string
154
+ error ?: boolean
155
+ disabled : boolean | undefined
156
+ items : { value : string ; children : React . ReactNode } [ ]
157
+ } ) => {
158
+ const classes = useStyles ( )
159
+
160
+ return (
161
+ < Box mt = { 2 } mb = { 2 } >
162
+ < Box mb = { 1 } display = "flex" alignItems = "center" >
163
+ < Select
164
+ className = { classNames (
165
+ classes . selectField ,
166
+ ! disabled && classes . textField ,
167
+ styles . textField ,
168
+ ) }
169
+ label = { label }
170
+ error = { error }
171
+ value = { value }
172
+ disabled = { disabled }
173
+ onChange = { onChange }
174
+ items = { items }
175
+ />
176
+ < Tooltip interactive content = { < p > { tooltipText ( ) } </ p > } >
177
+ < InfoIcon className = { styles . infoIcon } />
178
+ </ Tooltip >
179
+ </ Box >
180
+ </ Box >
181
+ )
182
+ }
0 commit comments