@junyiacademy/ui-test 0.0.9 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/declarations/libs/ui/src/index.d.ts +2 -3
  2. package/declarations/libs/ui/src/interfaces/index.d.ts +18 -0
  3. package/declarations/libs/ui/src/lib/TopicFilter.d.ts +1 -1
  4. package/declarations/libs/ui/src/lib/menu-item/SelectMenuItem.d.ts +1 -1
  5. package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +2 -21
  6. package/declarations/libs/ui/src/lib/select/Select.d.ts +3 -0
  7. package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +2 -18
  8. package/declarations/libs/ui/src/lib/topic-filter/TopicFilter.d.ts +13 -0
  9. package/dist/libs/ui/src/index.js +4 -6
  10. package/dist/libs/ui/src/lib/TopicFilter.js +3 -1
  11. package/dist/libs/ui/src/lib/select/OutlinedSelect.js +24 -7
  12. package/dist/libs/ui/src/lib/select/Select.js +16 -0
  13. package/dist/libs/ui/src/lib/select/StandardSelect.js +16 -3
  14. package/dist/libs/ui/src/lib/topic-filter/TopicFilter.js +120 -0
  15. package/package.json +1 -1
  16. package/src/index.ts +2 -3
  17. package/src/interfaces/index.tsx +25 -0
  18. package/src/lib/select/OutlinedSelect.tsx +37 -44
  19. package/src/lib/select/Select.stories.tsx +421 -0
  20. package/src/lib/select/Select.tsx +13 -0
  21. package/src/lib/select/StandardSelect.tsx +24 -33
  22. package/src/lib/{TopicFilter.stories.tsx → topic-filter/TopicFilter.stories.tsx} +10 -7
  23. package/src/lib/{TopicFilter.tsx → topic-filter/TopicFilter.tsx} +5 -5
  24. package/src/lib/TopicFilter.spec.tsx +0 -10
  25. package/src/lib/menu-item/SelectMenuItem.spec.tsx +0 -10
  26. package/src/lib/select/OutlinedSelect.spec.tsx +0 -10
  27. package/src/lib/select/OutlinedSelect.stories.tsx +0 -245
  28. package/src/lib/select/StandardSelect.stories.tsx +0 -221
@@ -1,14 +1,13 @@
1
- import React, { ChangeEvent } from 'react'
1
+ import React from 'react'
2
2
  import { Theme, styled } from '@material-ui/core/styles'
3
3
  import {
4
4
  InputLabel,
5
5
  FormControl,
6
6
  Select,
7
7
  OutlinedInput,
8
- SelectProps,
9
- OutlinedInputProps,
10
8
  FormHelperText,
11
9
  } from '@material-ui/core'
10
+ import { SelectProps } from '../../interfaces'
12
11
 
13
12
  // self-defined-components
14
13
  const PREFIX = 'JuiOutlinedSelect'
@@ -21,10 +20,12 @@ const classes = {
21
20
  inputLabelError: `${PREFIX}-inputLabelError`,
22
21
  inputLabelDisabled: `${PREFIX}-inputLabelDisabled`,
23
22
  outlineInputInput: `${PREFIX}-input`,
23
+ outlineInputRoot: `${PREFIX}-inputRoot`,
24
24
  outlineInputInputMarginDense: `${PREFIX}-inputMarginDense`,
25
25
  outlineInputNotchedOutline: `${PREFIX}-notchedOutline`,
26
26
  outlineInputDisabled: `${PREFIX}-inputDisabled`,
27
27
  outlineInputError: `${PREFIX}-outlinedInputError`,
28
+ outlineInputFocused: `${PREFIX}-focused`,
28
29
  selectPaper: `${PREFIX}-menuPaper`,
29
30
  }
30
31
 
@@ -45,6 +46,9 @@ const StyledFormControl = styled(
45
46
  borderColor: theme.palette[color].main,
46
47
  },
47
48
  },
49
+ [`& .${classes.outlineInputError}.${classes.outlineInputFocused} .${classes.outlineInputNotchedOutline}`]: {
50
+ borderColor: `${theme.palette.error.main}`,
51
+ },
48
52
  }))
49
53
 
50
54
  interface StyledInputLabelProps {
@@ -90,6 +94,8 @@ interface StyledOutlinedInputProps {
90
94
  const StyledOutlinedInput = styled((props) => (
91
95
  <OutlinedInput
92
96
  classes={{
97
+ root: classes.outlineInputRoot,
98
+ focused: classes.outlineInputFocused,
93
99
  input: classes.outlineInputInput,
94
100
  inputMarginDense: classes.outlineInputInputMarginDense,
95
101
  notchedOutline: classes.outlineInputNotchedOutline,
@@ -99,8 +105,14 @@ const StyledOutlinedInput = styled((props) => (
99
105
  {...props}
100
106
  />
101
107
  ))(({ theme }: StyledOutlinedInputProps) => ({
108
+ [`&.${classes.outlineInputRoot}.${classes.outlineInputFocused}`]: {
109
+ backgroundColor: theme.palette.action.selected,
110
+ },
102
111
  [`& .${classes.outlineInputInput}`]: {
103
112
  color: theme.palette.text.primary,
113
+ ['&:focus']: {
114
+ background: 'rgba(0,0,0,0)',
115
+ },
104
116
  },
105
117
  [`& .${classes.outlineInputInputMarginDense}`]: {
106
118
  padding: '14.5px 15px 14.5px 12px',
@@ -131,38 +143,26 @@ const StyledSelect = styled(
131
143
  horizontal: 'left',
132
144
  },
133
145
  getContentAnchorEl: null,
134
- classes: { paper: className },
146
+ classes: {
147
+ paper: className,
148
+ },
135
149
  }}
136
150
  {...props}
137
151
  />
138
152
  )
139
153
  )(({ hasAdornment, paperMaxHeight }: StyledSelectProps) => ({
140
- '&&': {
154
+ '&': {
141
155
  maxHeight: paperMaxHeight,
142
156
  left: hasAdornment ? '24px !important' : '70px',
143
157
  },
144
158
  }))
145
159
 
146
- export interface OutlinedSelectProps {
147
- color?: 'primary' | 'secondary'
148
- size?: 'medium' | 'small'
149
- width?: number | 'auto'
150
- paperMaxHeight?: number | 'auto'
151
- error?: boolean
152
- hasLabel?: boolean
153
- hasShrink?: boolean
154
- placeholder: string
155
- helperText?: string
156
- value?: unknown
157
- disabled?: boolean
158
- SelectProps?: object | Partial<SelectProps>
159
- OutlinedInputProps?: Partial<OutlinedInputProps> & {
160
- onChange: (e: ChangeEvent<HTMLInputElement>) => void
161
- }
162
- children?: React.ReactNode
163
- }
164
-
165
- const OutlinedSelect = ({
160
+ export const OutlinedSelect = ({
161
+ placeholder,
162
+ helperText,
163
+ InputProps,
164
+ SelectProps,
165
+ children,
166
166
  color = 'primary',
167
167
  size = 'medium',
168
168
  width = 'auto',
@@ -170,15 +170,10 @@ const OutlinedSelect = ({
170
170
  error = false,
171
171
  hasLabel = true,
172
172
  hasShrink = false,
173
- placeholder,
174
- helperText = '',
175
173
  value = '',
176
174
  disabled = false,
177
- SelectProps,
178
- OutlinedInputProps,
179
- children,
180
- }: OutlinedSelectProps) => {
181
- const hasAdornment = !!OutlinedInputProps?.startAdornment
175
+ }: SelectProps) => {
176
+ const hasAdornment = !!InputProps?.startAdornment
182
177
  const hasHelperText = !!helperText
183
178
  return (
184
179
  <StyledFormControl
@@ -188,17 +183,15 @@ const OutlinedSelect = ({
188
183
  error={error}
189
184
  color={color}
190
185
  >
191
- {hasLabel ? (
192
- hasShrink ? (
193
- <StyledInputLabel color={color} variant='outlined' shrink>
194
- {placeholder}
195
- </StyledInputLabel>
196
- ) : (
197
- <StyledInputLabel color={color} variant='outlined'>
198
- {placeholder}
199
- </StyledInputLabel>
200
- )
201
- ) : null}
186
+ {hasLabel && (
187
+ <StyledInputLabel
188
+ color={color}
189
+ variant='outlined'
190
+ shrink={hasShrink ? true : undefined}
191
+ >
192
+ {placeholder}
193
+ </StyledInputLabel>
194
+ )}
202
195
  <StyledSelect
203
196
  value={value}
204
197
  paperMaxHeight={paperMaxHeight}
@@ -208,7 +201,7 @@ const OutlinedSelect = ({
208
201
  color={color}
209
202
  label={hasLabel ? placeholder : undefined}
210
203
  disabled={disabled}
211
- {...OutlinedInputProps}
204
+ {...InputProps}
212
205
  />
213
206
  }
214
207
  {...SelectProps}
@@ -0,0 +1,421 @@
1
+ import React, { useState } from 'react'
2
+ import { Story, Meta } from '@storybook/react'
3
+ import { Theme, styled } from '@material-ui/core/styles'
4
+ import { InputAdornment } from '@material-ui/core'
5
+ import { Visibility } from '@material-ui/icons'
6
+ import { Select } from './Select'
7
+ import SelectMenuItem from '../menu-item/SelectMenuItem'
8
+ import { SelectProps } from '../../interfaces'
9
+
10
+ export default {
11
+ component: Select,
12
+ title: 'Select',
13
+ argTypes: {
14
+ color: {
15
+ type: { name: 'string', required: false },
16
+ description:
17
+ 'The color of the component. It supports those theme colors that make sense for this component.',
18
+ table: {
19
+ type: { summary: 'primary | secondary' },
20
+ defaultValue: { summary: 'primary' },
21
+ },
22
+ options: ['primary', 'secondary'],
23
+ control: { type: 'radio' },
24
+ },
25
+ size: {
26
+ type: { name: 'string', required: false },
27
+ description: `Adjust size`,
28
+ table: {
29
+ type: { summary: 'medium | small' },
30
+ defaultValue: { summary: 'medium' },
31
+ },
32
+ options: ['small', 'medium'],
33
+ control: { type: 'radio' },
34
+ },
35
+ width: {
36
+ type: { name: 'number', required: false },
37
+ description: `Adjust width`,
38
+ table: {
39
+ type: { summary: 'number' },
40
+ defaultValue: { summary: 'auto' },
41
+ },
42
+ control: { type: 'number' },
43
+ },
44
+ paperMaxHeight: {
45
+ type: { name: 'number', required: false },
46
+ description: `Adjust select menu paper max height.`,
47
+ table: {
48
+ type: { summary: 'number' },
49
+ defaultValue: { summary: 'auto' },
50
+ },
51
+ control: { type: 'number' },
52
+ },
53
+ hasLabel: {
54
+ type: { name: 'boolean', required: false },
55
+ description:
56
+ 'If true, the label is displayed. Always true on StandardSelect.',
57
+ table: {
58
+ type: { summary: 'boolean' },
59
+ defaultValue: { summary: true },
60
+ },
61
+ control: { type: 'boolean' },
62
+ },
63
+ hasShrink: {
64
+ type: { name: 'boolean', required: false },
65
+ description: 'If true, the label is displayed and shrunk.',
66
+ table: {
67
+ type: { summary: 'boolean' },
68
+ defaultValue: { summary: false },
69
+ },
70
+ control: { type: 'boolean' },
71
+ },
72
+ placeholder: {
73
+ type: { name: 'string', required: true },
74
+ description: `The label title`,
75
+ table: {
76
+ type: { summary: 'string' },
77
+ defaultValue: { summary: '請選擇' },
78
+ },
79
+ control: { type: 'text' },
80
+ },
81
+ value: {
82
+ type: { name: 'any', required: false },
83
+ description: `The input value. Providing an empty string will select no options. This prop is required when the native prop is false (default). Set to an empty string '' if you don't want any of the available options to be selected.
84
+ If the value is an object it must have reference equality with the option in order to be selected. If the value is not an object, the string representation must match with the string representation of the option in order to be selected.`,
85
+ table: {
86
+ type: { summary: 'any' },
87
+ defaultValue: { summary: '' },
88
+ },
89
+ },
90
+ disabled: {
91
+ type: { name: 'boolean', required: false },
92
+ description: 'If true, the input element will be disabled.',
93
+ table: {
94
+ type: { summary: 'boolean' },
95
+ defaultValue: { summary: false },
96
+ },
97
+ control: { type: 'boolean' },
98
+ },
99
+ error: {
100
+ type: { name: 'boolean', required: false },
101
+ description: 'If true, the label will be displayed in an error state.',
102
+ table: {
103
+ type: { summary: 'boolean' },
104
+ defaultValue: { summary: false },
105
+ },
106
+ control: { type: 'boolean' },
107
+ },
108
+ helperText: {
109
+ type: { name: 'string', required: true },
110
+ description: `Display the helper text.`,
111
+ table: {
112
+ type: { summary: 'string' },
113
+ defaultValue: { summary: '' },
114
+ },
115
+ control: { type: 'text' },
116
+ },
117
+ SelectProps: {
118
+ type: { name: 'any', required: false },
119
+ description: 'Attributes applied to inner Select element.',
120
+ table: {
121
+ type: { summary: 'any' },
122
+ },
123
+ },
124
+ CommonInputProps: {
125
+ type: { name: 'any', required: false },
126
+ description:
127
+ 'Attributes applied to to inner OutlinedInput element on OutlinedSelect or Input element on StandardSelect.',
128
+ table: {
129
+ type: { summary: 'any' },
130
+ },
131
+ },
132
+ },
133
+ } as Meta
134
+
135
+ const PLACEHOLDER = 'Please select an option'
136
+ const ERROR_PLACEHOLDER = 'Please select an option'
137
+ const PREFIX = 'JuiSelect'
138
+
139
+ const classes = {
140
+ inputAdornmentRoot: `${PREFIX}-inputAdornmentRoot`,
141
+ }
142
+
143
+ interface StyledInputAdornmentProps {
144
+ disabled: boolean
145
+ theme?: Theme
146
+ }
147
+
148
+ const StyledInputAdornment = styled(({ disabled: _disabled, ...props }) => (
149
+ <InputAdornment
150
+ classes={{
151
+ root: classes.inputAdornmentRoot,
152
+ }}
153
+ {...props}
154
+ />
155
+ ))(({ disabled, theme }: StyledInputAdornmentProps) => ({
156
+ height: '100%',
157
+ [`&.${classes.inputAdornmentRoot}`]: {
158
+ color: disabled
159
+ ? theme.palette.action.disabled
160
+ : theme.palette.action.active,
161
+ },
162
+ }))
163
+
164
+ // Outlined Select start with here.
165
+ interface OutlinedSelectWithMenuProps {
166
+ startAdornment?: React.ReactNode
167
+ }
168
+
169
+ const OutlinedSelectWithMenu = ({
170
+ startAdornment,
171
+ ...props
172
+ }: SelectProps & OutlinedSelectWithMenuProps) => {
173
+ const [item, setItem] = useState<string>('')
174
+
175
+ const handleChange = (event) => {
176
+ setItem(event.target.value)
177
+ }
178
+ return (
179
+ <Select
180
+ variant='outlined'
181
+ InputProps={{
182
+ onChange: (e) => {
183
+ handleChange(e)
184
+ },
185
+ startAdornment,
186
+ }}
187
+ value={item}
188
+ {...props}
189
+ >
190
+ <SelectMenuItem width={props.width} value='' disabled>
191
+ {PLACEHOLDER}
192
+ </SelectMenuItem>
193
+ <SelectMenuItem width={props.width} value='Test'>
194
+ This is a select menu item
195
+ </SelectMenuItem>
196
+ <SelectMenuItem width={props.width} value='Example'>
197
+ Example
198
+ </SelectMenuItem>
199
+ </Select>
200
+ )
201
+ }
202
+
203
+ const OutlinedValueOnlyStory: Story<SelectProps> = (args) => (
204
+ <OutlinedSelectWithMenu {...args} />
205
+ )
206
+
207
+ export const OutlinedValueOnly = OutlinedValueOnlyStory.bind({})
208
+
209
+ OutlinedValueOnly.args = {
210
+ color: 'primary',
211
+ size: 'medium',
212
+ width: 220,
213
+ paperMaxHeight: 412,
214
+ hasLabel: true,
215
+ placeholder: PLACEHOLDER,
216
+ helperText: 'Pick your choice',
217
+ disabled: false,
218
+ SelectProps: {},
219
+ }
220
+
221
+ const OutlinedSelectWithError = ({
222
+ startAdornment,
223
+ ...props
224
+ }: SelectProps & OutlinedSelectWithMenuProps) => {
225
+ const [item, setItem] = useState<string>('')
226
+
227
+ const handleChange = (event) => {
228
+ setItem(event.target.value)
229
+ }
230
+ return (
231
+ <Select
232
+ variant='outlined'
233
+ InputProps={{
234
+ onChange: (e) => {
235
+ handleChange(e)
236
+ },
237
+ startAdornment,
238
+ }}
239
+ value={item}
240
+ error={item === ''}
241
+ helperText={item === '' ? ERROR_PLACEHOLDER : ''}
242
+ {...props}
243
+ >
244
+ <SelectMenuItem width={props.width} value='' disabled>
245
+ {PLACEHOLDER}
246
+ </SelectMenuItem>
247
+ <SelectMenuItem width={props.width} value='Option1'>
248
+ This is a select menu item
249
+ </SelectMenuItem>
250
+ <SelectMenuItem width={props.width} value='Option2'>
251
+ This is option 2
252
+ </SelectMenuItem>
253
+ </Select>
254
+ )
255
+ }
256
+
257
+ const OutlinedWithErrorStory: Story<SelectProps> = (args) => (
258
+ <OutlinedSelectWithError {...args} />
259
+ )
260
+
261
+ export const OutlinedWithError = OutlinedWithErrorStory.bind({})
262
+
263
+ OutlinedWithError.args = {
264
+ color: 'primary',
265
+ size: 'medium',
266
+ width: 220,
267
+ paperMaxHeight: 412,
268
+ hasLabel: true,
269
+ placeholder: PLACEHOLDER,
270
+ disabled: false,
271
+ SelectProps: {},
272
+ }
273
+
274
+ const OutlinedWithPrefixStory: Story<SelectProps> = (args) => (
275
+ <OutlinedSelectWithMenu
276
+ startAdornment={
277
+ <StyledInputAdornment position='start' disabled={args.disabled}>
278
+ <Visibility />
279
+ </StyledInputAdornment>
280
+ }
281
+ {...args}
282
+ />
283
+ )
284
+
285
+ export const OutlinedWithPrefix = OutlinedWithPrefixStory.bind({})
286
+
287
+ OutlinedWithPrefix.args = {
288
+ color: 'primary',
289
+ size: 'medium',
290
+ width: 220,
291
+ paperMaxHeight: 412,
292
+ hasLabel: true,
293
+ placeholder: PLACEHOLDER,
294
+ helperText: 'Pick your choice',
295
+ disabled: false,
296
+ SelectProps: {},
297
+ }
298
+
299
+ // Standard Select start with here.
300
+ const StandardSelectWithMenu = (props: SelectProps) => {
301
+ const [item, setItem] = useState<string>('')
302
+
303
+ const handleChange = (event) => {
304
+ setItem(event.target.value)
305
+ }
306
+
307
+ return (
308
+ <Select
309
+ variant='standard'
310
+ value={item}
311
+ SelectProps={{
312
+ onChange: (e) => {
313
+ handleChange(e)
314
+ },
315
+ }}
316
+ {...props}
317
+ >
318
+ <SelectMenuItem width={props.width} value='' disabled>
319
+ {PLACEHOLDER}
320
+ </SelectMenuItem>
321
+ <SelectMenuItem width={props.width} value='Option1'>
322
+ This is a select menu item
323
+ </SelectMenuItem>
324
+ <SelectMenuItem width={props.width} value='Option2'>
325
+ This is option 2
326
+ </SelectMenuItem>
327
+ </Select>
328
+ )
329
+ }
330
+
331
+ const StandardValueOnlyStory: Story<SelectProps> = (args) => (
332
+ <StandardSelectWithMenu {...args} />
333
+ )
334
+
335
+ export const StandardValueOnly = StandardValueOnlyStory.bind({})
336
+
337
+ StandardValueOnly.args = {
338
+ color: 'primary',
339
+ size: 'medium',
340
+ width: 300,
341
+ paperMaxHeight: 300,
342
+ hasShrink: false,
343
+ placeholder: PLACEHOLDER,
344
+ helperText: 'Pick your choice',
345
+ disabled: false,
346
+ }
347
+
348
+ const StandardSelectWithError = (props: SelectProps) => {
349
+ const [item, setItem] = useState<string>('')
350
+
351
+ const handleChange = (event) => {
352
+ setItem(event.target.value)
353
+ }
354
+
355
+ return (
356
+ <Select
357
+ variant='standard'
358
+ value={item}
359
+ SelectProps={{
360
+ onChange: (e) => {
361
+ handleChange(e)
362
+ },
363
+ }}
364
+ error={item === ''}
365
+ helperText={item === '' ? ERROR_PLACEHOLDER : ''}
366
+ {...props}
367
+ >
368
+ <SelectMenuItem width={props.width} value='' disabled>
369
+ {PLACEHOLDER}
370
+ </SelectMenuItem>
371
+ <SelectMenuItem width={props.width} value={'Test'}>
372
+ This is a select menu item, This is a select menu item
373
+ </SelectMenuItem>
374
+ <SelectMenuItem width={props.width} value={'Example'}>
375
+ Example
376
+ </SelectMenuItem>
377
+ </Select>
378
+ )
379
+ }
380
+
381
+ const StandardWithErrorStory: Story<SelectProps> = (args) => (
382
+ <StandardSelectWithError {...args} />
383
+ )
384
+
385
+ export const StandardWithError = StandardWithErrorStory.bind({})
386
+
387
+ StandardWithError.args = {
388
+ color: 'primary',
389
+ size: 'medium',
390
+ width: 300,
391
+ paperMaxHeight: 300,
392
+ hasShrink: false,
393
+ placeholder: PLACEHOLDER,
394
+ disabled: false,
395
+ }
396
+
397
+ const StandardWithPrefixStory: Story<SelectProps> = (args) => (
398
+ <StandardSelectWithMenu
399
+ InputProps={{
400
+ startAdornment: (
401
+ <StyledInputAdornment position='start' disabled={args.disabled}>
402
+ <Visibility />
403
+ </StyledInputAdornment>
404
+ ),
405
+ }}
406
+ {...args}
407
+ />
408
+ )
409
+
410
+ export const StandardWithPrefix = StandardWithPrefixStory.bind({})
411
+
412
+ StandardWithPrefix.args = {
413
+ color: 'primary',
414
+ size: 'medium',
415
+ width: 300,
416
+ paperMaxHeight: 300,
417
+ hasShrink: false,
418
+ placeholder: PLACEHOLDER,
419
+ helperText: 'Pick your choice',
420
+ disabled: false,
421
+ }
@@ -0,0 +1,13 @@
1
+ import React from 'react'
2
+ import { OutlinedSelect } from './OutlinedSelect'
3
+ import { StandardSelect } from './StandardSelect'
4
+ import { SelectProps } from '../../interfaces'
5
+
6
+ export function Select({ variant, ...props }: SelectProps) {
7
+ if (variant === 'outlined') {
8
+ return <OutlinedSelect {...props} />
9
+ }
10
+ return <StandardSelect {...props} />
11
+ }
12
+
13
+ export default Select
@@ -4,12 +4,10 @@ import {
4
4
  InputLabel,
5
5
  FormControl,
6
6
  Select,
7
- SelectProps,
8
7
  Input,
9
- InputProps,
10
8
  FormHelperText,
11
- InputAdornment,
12
9
  } from '@material-ui/core'
10
+ import { SelectProps } from '../../interfaces'
13
11
 
14
12
  // self-defined-components
15
13
  const PREFIX = 'JuiStandardSelect'
@@ -18,6 +16,9 @@ const classes = {
18
16
  inputLabelFocused: `${PREFIX}-inputLabelFocused`,
19
17
  inputLabelMarginDense: `${PREFIX}-inputLabelMarginDense`,
20
18
  inputLabelError: `${PREFIX}-inputLabelError`,
19
+ inputRoot: `${PREFIX}-inputRoot`,
20
+ inputFocused: `${PREFIX}-inputFocused`,
21
+ inputInput: `${PREFIX}-input`,
21
22
  inputUnderline: `${PREFIX}-inputUnderline`,
22
23
  inputError: `${PREFIX}-inputError`,
23
24
  inputDisabled: `${PREFIX}-inputDisabled`,
@@ -92,7 +93,6 @@ const StyledSelect = styled(
92
93
  maxHeight: paperMaxHeight,
93
94
  left: hasAdornment ? '48px !important' : '70px',
94
95
  },
95
- [`&.${classes.selectDisabled}`]: {},
96
96
  }))
97
97
 
98
98
  interface StyledInputProps {
@@ -103,6 +103,9 @@ interface StyledInputProps {
103
103
  const StyledInput = styled(({ color: _color, ...props }) => (
104
104
  <Input
105
105
  classes={{
106
+ root: classes.inputRoot,
107
+ focused: classes.inputFocused,
108
+ input: classes.inputInput,
106
109
  disabled: classes.inputDisabled,
107
110
  underline: classes.inputUnderline,
108
111
  error: classes.inputError,
@@ -111,6 +114,14 @@ const StyledInput = styled(({ color: _color, ...props }) => (
111
114
  />
112
115
  ))(({ color, theme }: StyledInputProps) => ({
113
116
  color: theme.palette.text.primary,
117
+ [`&.${classes.inputRoot}.${classes.inputFocused}`]: {
118
+ backgroundColor: theme.palette.action.selected,
119
+ },
120
+ [`& .${classes.inputInput}`]: {
121
+ ['&:focus']: {
122
+ background: 'rgba(0,0,0,0)',
123
+ },
124
+ },
114
125
  [`&.${classes.inputUnderline}:not(.${classes.inputDisabled}):not(.${classes.inputError})`]: {
115
126
  [`&:after,&:hover:before`]: {
116
127
  borderBottomColor: theme.palette[color].main,
@@ -123,37 +134,21 @@ const StyledInput = styled(({ color: _color, ...props }) => (
123
134
  },
124
135
  }))
125
136
 
126
- export interface StandardSelectProps {
127
- color?: 'primary' | 'secondary'
128
- size?: 'medium' | 'small'
129
- width?: number | 'auto'
130
- paperMaxHeight?: number | 'auto'
131
- error?: boolean
132
- hasShrink?: boolean
133
- placeholder: string
134
- helperText?: string
135
- InputProps?: object & Partial<InputProps>
136
- value?: unknown
137
- disabled?: boolean
138
- SelectProps?: object | Partial<SelectProps>
139
- children?: React.ReactNode
140
- }
141
-
142
137
  export function StandardSelect({
138
+ placeholder,
139
+ helperText,
140
+ InputProps,
141
+ SelectProps,
142
+ children,
143
143
  color = 'primary',
144
144
  size = 'medium',
145
145
  width = 'auto',
146
146
  paperMaxHeight = 'auto',
147
147
  error = false,
148
148
  hasShrink = false,
149
- placeholder,
150
- helperText,
151
- InputProps,
152
149
  value = '',
153
- SelectProps,
154
150
  disabled = false,
155
- children,
156
- }: StandardSelectProps) {
151
+ }: SelectProps) {
157
152
  const hasAdornment = !!InputProps?.startAdornment
158
153
  const hasHelperText = !!helperText
159
154
  return (
@@ -164,13 +159,9 @@ export function StandardSelect({
164
159
  disabled={disabled}
165
160
  error={error}
166
161
  >
167
- {hasShrink ? (
168
- <StyledInputLabel color={color} shrink>
169
- {placeholder}
170
- </StyledInputLabel>
171
- ) : (
172
- <StyledInputLabel color={color}>{placeholder}</StyledInputLabel>
173
- )}
162
+ <StyledInputLabel color={color} shrink={hasShrink ? true : undefined}>
163
+ {placeholder}
164
+ </StyledInputLabel>
174
165
  <StyledSelect
175
166
  value={value}
176
167
  paperMaxHeight={paperMaxHeight}