@junyiacademy/ui-test 0.0.11 → 1.4.0

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 (31) hide show
  1. package/declarations/libs/ui/src/index.d.ts +2 -3
  2. package/declarations/libs/ui/src/interfaces/index.d.ts +19 -0
  3. package/declarations/libs/ui/src/lib/menu-item/SelectMenuItem.d.ts +2 -2
  4. package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +2 -19
  5. package/declarations/libs/ui/src/lib/select/Select.d.ts +3 -0
  6. package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +2 -15
  7. package/declarations/libs/ui/src/lib/topic-filter/TopicFilter.d.ts +13 -0
  8. package/dist/libs/ui/src/index.js +4 -6
  9. package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +4 -1
  10. package/dist/libs/ui/src/lib/select/OutlinedSelect.js +30 -14
  11. package/dist/libs/ui/src/lib/select/Select.js +16 -0
  12. package/dist/libs/ui/src/lib/select/StandardSelect.js +13 -5
  13. package/dist/libs/ui/src/lib/topic-filter/TopicFilter.js +121 -0
  14. package/package.json +2 -2
  15. package/src/index.ts +2 -3
  16. package/src/interfaces/index.tsx +26 -0
  17. package/src/lib/menu-item/SelectMenuItem.tsx +6 -3
  18. package/src/lib/select/OutlinedSelect.tsx +38 -37
  19. package/src/lib/select/{StandardSelect.stories.tsx → Select.stories.tsx} +119 -34
  20. package/src/lib/select/Select.tsx +13 -0
  21. package/src/lib/select/StandardSelect.tsx +22 -25
  22. package/src/lib/{TopicFilter.stories.tsx → topic-filter/TopicFilter.stories.tsx} +1 -1
  23. package/src/lib/{TopicFilter.tsx → topic-filter/TopicFilter.tsx} +14 -9
  24. package/declarations/libs/ui/src/lib/alert/Alert.d.ts +0 -13
  25. package/declarations/libs/ui/src/lib/selection-item/SelectionItem.d.ts +0 -10
  26. package/dist/libs/ui/src/lib/alert/Alert.js +0 -72
  27. package/dist/libs/ui/src/lib/selection-item/SelectionItem.js +0 -16
  28. package/src/lib/TopicFilter.spec.tsx +0 -10
  29. package/src/lib/menu-item/SelectMenuItem.spec.tsx +0 -10
  30. package/src/lib/select/OutlinedSelect.spec.tsx +0 -10
  31. package/src/lib/select/OutlinedSelect.stories.tsx +0 -238
@@ -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,24 +20,29 @@ 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
 
31
32
  interface StyledFormControlProps {
32
33
  color: 'primary' | 'secondary'
33
- width: number | 'auto'
34
+ width: number | string
35
+ selectMargin: number | string
34
36
  theme?: Theme
35
37
  }
36
38
 
37
39
  const StyledFormControl = styled(
38
- ({ color: _color, width: _width, ...props }) => <FormControl {...props} />
39
- )(({ color, width, theme }: StyledFormControlProps) => ({
40
- margin: theme.spacing(1),
41
- width: width,
40
+ ({ color: _color, width: _width, selectMargin: _selectMargin, ...props }) => (
41
+ <FormControl {...props} />
42
+ )
43
+ )(({ color, width, selectMargin, theme }: StyledFormControlProps) => ({
44
+ width,
45
+ margin: selectMargin,
42
46
  backgroundColor: 'white',
43
47
  '&:hover': {
44
48
  [`& :not(.${classes.outlineInputDisabled}):not(.${classes.outlineInputError}) .${classes.outlineInputNotchedOutline}`]: {
@@ -90,7 +94,9 @@ interface StyledOutlinedInputProps {
90
94
  const StyledOutlinedInput = styled((props) => (
91
95
  <OutlinedInput
92
96
  classes={{
97
+ root: classes.outlineInputRoot,
93
98
  input: classes.outlineInputInput,
99
+ focused: classes.outlineInputFocused,
94
100
  inputMarginDense: classes.outlineInputInputMarginDense,
95
101
  notchedOutline: classes.outlineInputNotchedOutline,
96
102
  disabled: classes.outlineInputDisabled,
@@ -99,16 +105,24 @@ const StyledOutlinedInput = styled((props) => (
99
105
  {...props}
100
106
  />
101
107
  ))(({ theme }: StyledOutlinedInputProps) => ({
108
+ [`&.${classes.outlineInputRoot}`]: {
109
+ [`&.${classes.outlineInputError}.${classes.outlineInputFocused} .${classes.outlineInputNotchedOutline}`]: {
110
+ borderColor: `${theme.palette.error.main}`,
111
+ },
112
+ [`& .${classes.outlineInputInputMarginDense}`]: {
113
+ padding: '14.5px 15px 14.5px 12px',
114
+ },
115
+ },
102
116
  [`& .${classes.outlineInputInput}`]: {
103
117
  color: theme.palette.text.primary,
104
- },
105
- [`& .${classes.outlineInputInputMarginDense}`]: {
106
- padding: '14.5px 15px 14.5px 12px',
118
+ ['&:focus']: {
119
+ background: 'rgba(0,0,0,0)',
120
+ },
107
121
  },
108
122
  }))
109
123
 
110
124
  interface StyledSelectProps {
111
- paperMaxHeight: number | 'auto'
125
+ paperMaxHeight: number | string
112
126
  hasAdornment: boolean
113
127
  }
114
128
 
@@ -131,7 +145,9 @@ const StyledSelect = styled(
131
145
  horizontal: 'left',
132
146
  },
133
147
  getContentAnchorEl: null,
134
- classes: { paper: className },
148
+ classes: {
149
+ paper: className,
150
+ },
135
151
  }}
136
152
  {...props}
137
153
  />
@@ -143,45 +159,30 @@ const StyledSelect = styled(
143
159
  },
144
160
  }))
145
161
 
146
- export interface OutlinedSelectProps extends SelectProps {
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
- disabled?: boolean
157
- SelectProps?: object | Partial<SelectProps>
158
- OutlinedInputProps?: Partial<OutlinedInputProps> & {
159
- onChange: (e: ChangeEvent<HTMLInputElement>) => void
160
- }
161
- }
162
-
163
- const OutlinedSelect = ({
162
+ export const OutlinedSelect = ({
164
163
  placeholder,
164
+ helperText,
165
+ InputProps,
165
166
  SelectProps,
166
- OutlinedInputProps,
167
167
  children,
168
168
  color = 'primary',
169
- size = 'medium',
169
+ size = 'small',
170
170
  width = 'auto',
171
+ selectMargin = 0,
171
172
  paperMaxHeight = 'auto',
172
173
  error = false,
173
174
  hasLabel = true,
174
175
  hasShrink = false,
175
- helperText = '',
176
176
  value = '',
177
177
  disabled = false,
178
- }: OutlinedSelectProps) => {
179
- const hasAdornment = !!OutlinedInputProps?.startAdornment
178
+ }: SelectProps) => {
179
+ const hasAdornment = !!InputProps?.startAdornment
180
180
  const hasHelperText = !!helperText
181
181
  return (
182
182
  <StyledFormControl
183
183
  size={size}
184
184
  width={width}
185
+ selectMargin={selectMargin}
185
186
  disabled={disabled}
186
187
  error={error}
187
188
  color={color}
@@ -204,7 +205,7 @@ const OutlinedSelect = ({
204
205
  color={color}
205
206
  label={hasLabel ? placeholder : undefined}
206
207
  disabled={disabled}
207
- {...OutlinedInputProps}
208
+ {...InputProps}
208
209
  />
209
210
  }
210
211
  {...SelectProps}
@@ -3,14 +3,13 @@ import { Story, Meta } from '@storybook/react'
3
3
  import { Theme, styled } from '@material-ui/core/styles'
4
4
  import { InputAdornment } from '@material-ui/core'
5
5
  import { Visibility } from '@material-ui/icons'
6
- import { StandardSelect, StandardSelectProps } from './StandardSelect'
6
+ import { Select } from './Select'
7
7
  import SelectMenuItem from '../menu-item/SelectMenuItem'
8
-
9
- const PLACEHOLDER = '請選擇'
8
+ import { SelectProps } from '../../interfaces'
10
9
 
11
10
  export default {
12
- component: StandardSelect,
13
- title: 'StandardSelect',
11
+ component: Select,
12
+ title: 'Select',
14
13
  argTypes: {
15
14
  color: {
16
15
  type: { name: 'string', required: false },
@@ -23,40 +22,69 @@ export default {
23
22
  options: ['primary', 'secondary'],
24
23
  control: { type: 'radio' },
25
24
  },
25
+ variant: {
26
+ type: { name: 'string', required: false },
27
+ description: 'The variant to use.',
28
+ table: {
29
+ type: { summary: 'standard | outlined' },
30
+ defaultValue: { summary: 'standard' },
31
+ },
32
+ options: ['standard', 'outlined'],
33
+ control: { type: 'radio' },
34
+ },
26
35
  size: {
27
36
  type: { name: 'string', required: false },
28
37
  description: `Adjust size`,
29
38
  table: {
30
39
  type: { summary: 'medium | small' },
31
- defaultValue: { summary: 'medium' },
40
+ defaultValue: { summary: 'small' },
32
41
  },
33
42
  options: ['small', 'medium'],
34
43
  control: { type: 'radio' },
35
44
  },
36
45
  width: {
37
- type: { name: 'number', required: false },
46
+ type: { name: 'number | string', required: false },
38
47
  description: `Adjust width`,
39
48
  table: {
40
- type: { summary: 'number' },
49
+ type: { summary: 'number | string' },
41
50
  defaultValue: { summary: 'auto' },
42
51
  },
43
52
  control: { type: 'number' },
44
53
  },
54
+ selectMargin: {
55
+ type: { name: 'number | string', required: false },
56
+ description: `Adjust margin`,
57
+ table: {
58
+ type: { summary: 'number | string' },
59
+ defaultValue: { summary: '0' },
60
+ },
61
+ control: { type: 'number' },
62
+ },
45
63
  paperMaxHeight: {
46
- type: { name: 'number', required: false },
64
+ type: { name: 'number | string', required: false },
47
65
  description: `Adjust select menu paper max height.`,
48
66
  table: {
49
- type: { summary: 'number' },
67
+ type: { summary: 'number | string' },
50
68
  defaultValue: { summary: 'auto' },
51
69
  },
52
70
  control: { type: 'number' },
53
71
  },
72
+ hasLabel: {
73
+ type: { name: 'boolean', required: false },
74
+ description:
75
+ 'If true, the label is displayed. Always true on StandardSelect.',
76
+ table: {
77
+ type: { summary: 'boolean' },
78
+ defaultValue: { summary: true },
79
+ },
80
+ control: { type: 'boolean' },
81
+ },
54
82
  hasShrink: {
55
83
  type: { name: 'boolean', required: false },
56
84
  description: 'If true, the label is displayed and shrunk.',
57
85
  table: {
58
86
  type: { summary: 'boolean' },
59
- defaultValue: { summary: true },
87
+ defaultValue: { summary: false },
60
88
  },
61
89
  control: { type: 'boolean' },
62
90
  },
@@ -105,16 +133,17 @@ export default {
105
133
  },
106
134
  control: { type: 'text' },
107
135
  },
108
- InputProps: {
136
+ SelectProps: {
109
137
  type: { name: 'any', required: false },
110
- description: 'Attributes applied to inner Input element.',
138
+ description: 'Attributes applied to inner Select element.',
111
139
  table: {
112
140
  type: { summary: 'any' },
113
141
  },
114
142
  },
115
- SelectProps: {
143
+ CommonInputProps: {
116
144
  type: { name: 'any', required: false },
117
- description: 'Attributes applied to inner Select element.',
145
+ description:
146
+ 'Attributes applied to to inner OutlinedInput element on OutlinedSelect or Input element on StandardSelect.',
118
147
  table: {
119
148
  type: { summary: 'any' },
120
149
  },
@@ -122,14 +151,17 @@ export default {
122
151
  },
123
152
  } as Meta
124
153
 
125
- const PREFIX = 'JuiStandardSelect'
154
+ const PLACEHOLDER = 'Please select an option'
155
+ const ERROR_PLACEHOLDER = 'Please select an option'
156
+ const PREFIX = 'JuiSelect'
126
157
 
127
158
  const classes = {
128
159
  inputAdornmentRoot: `${PREFIX}-inputAdornmentRoot`,
129
160
  }
161
+
130
162
  interface StyledInputAdornmentProps {
131
- theme: Theme
132
163
  disabled: boolean
164
+ theme?: Theme
133
165
  }
134
166
 
135
167
  const StyledInputAdornment = styled(({ disabled: _disabled, ...props }) => (
@@ -140,6 +172,7 @@ const StyledInputAdornment = styled(({ disabled: _disabled, ...props }) => (
140
172
  {...props}
141
173
  />
142
174
  ))(({ disabled, theme }: StyledInputAdornmentProps) => ({
175
+ height: '100%',
143
176
  [`&.${classes.inputAdornmentRoot}`]: {
144
177
  color: disabled
145
178
  ? theme.palette.action.disabled
@@ -147,7 +180,8 @@ const StyledInputAdornment = styled(({ disabled: _disabled, ...props }) => (
147
180
  },
148
181
  }))
149
182
 
150
- const StandardSelectWithMenu = (props: StandardSelectProps) => {
183
+ // Standard Select start with here.
184
+ const SelectWithMenu = (props: SelectProps) => {
151
185
  const [item, setItem] = useState<string>('')
152
186
 
153
187
  const handleChange = (event) => {
@@ -155,7 +189,7 @@ const StandardSelectWithMenu = (props: StandardSelectProps) => {
155
189
  }
156
190
 
157
191
  return (
158
- <StandardSelect
192
+ <Select
159
193
  value={item}
160
194
  SelectProps={{
161
195
  onChange: (e) => {
@@ -164,38 +198,88 @@ const StandardSelectWithMenu = (props: StandardSelectProps) => {
164
198
  }}
165
199
  {...props}
166
200
  >
167
- <SelectMenuItem width={300} value='' disabled>
201
+ <SelectMenuItem width={props.width} value='' disabled>
168
202
  {PLACEHOLDER}
169
203
  </SelectMenuItem>
170
- <SelectMenuItem width={300} value={'Test'}>
171
- This is a select menu item, This is a select menu item
204
+ <SelectMenuItem width={props.width} value='Option1'>
205
+ This is a select menu item
172
206
  </SelectMenuItem>
173
- <SelectMenuItem width={300} value={'Example'}>
174
- Example
207
+ <SelectMenuItem width={props.width} value='Option2'>
208
+ This is option 2
175
209
  </SelectMenuItem>
176
- </StandardSelect>
210
+ </Select>
177
211
  )
178
212
  }
179
213
 
180
- const ValueOnlyStory: Story<StandardSelectProps> = (args) => (
181
- <StandardSelectWithMenu {...args} />
214
+ const ValueOnlyStory: Story<SelectProps> = (args) => (
215
+ <SelectWithMenu {...args} />
182
216
  )
183
217
 
184
218
  export const ValueOnly = ValueOnlyStory.bind({})
185
219
 
186
220
  ValueOnly.args = {
187
221
  color: 'primary',
188
- size: 'medium',
189
- width: 220,
222
+ variant: 'standard',
223
+ size: 'small',
224
+ width: 300,
225
+ paperMaxHeight: 300,
226
+ hasShrink: false,
227
+ placeholder: PLACEHOLDER,
228
+ helperText: 'Pick your choice',
229
+ disabled: false,
230
+ }
231
+
232
+ const SelectWithError = (props: SelectProps) => {
233
+ const [item, setItem] = useState<string>('')
234
+
235
+ const handleChange = (event) => {
236
+ setItem(event.target.value)
237
+ }
238
+
239
+ return (
240
+ <Select
241
+ value={item}
242
+ SelectProps={{
243
+ onChange: (e) => {
244
+ handleChange(e)
245
+ },
246
+ }}
247
+ error={item === ''}
248
+ helperText={item === '' ? ERROR_PLACEHOLDER : ''}
249
+ {...props}
250
+ >
251
+ <SelectMenuItem width={props.width} value='' disabled>
252
+ {PLACEHOLDER}
253
+ </SelectMenuItem>
254
+ <SelectMenuItem width={props.width} value={'Test'}>
255
+ This is a select menu item, This is a select menu item
256
+ </SelectMenuItem>
257
+ <SelectMenuItem width={props.width} value={'Example'}>
258
+ Example
259
+ </SelectMenuItem>
260
+ </Select>
261
+ )
262
+ }
263
+
264
+ const WithErrorStory: Story<SelectProps> = (args) => (
265
+ <SelectWithError {...args} />
266
+ )
267
+
268
+ export const WithError = WithErrorStory.bind({})
269
+
270
+ WithError.args = {
271
+ color: 'primary',
272
+ variant: 'standard',
273
+ size: 'small',
274
+ width: 300,
190
275
  paperMaxHeight: 300,
191
276
  hasShrink: false,
192
277
  placeholder: PLACEHOLDER,
193
- helperText: 'test',
194
278
  disabled: false,
195
279
  }
196
280
 
197
- const WithPrefixStory: Story<StandardSelectProps> = (args) => (
198
- <StandardSelectWithMenu
281
+ const WithPrefixStory: Story<SelectProps> = (args) => (
282
+ <SelectWithMenu
199
283
  InputProps={{
200
284
  startAdornment: (
201
285
  <StyledInputAdornment position='start' disabled={args.disabled}>
@@ -211,11 +295,12 @@ export const WithPrefix = WithPrefixStory.bind({})
211
295
 
212
296
  WithPrefix.args = {
213
297
  color: 'primary',
214
- size: 'medium',
298
+ variant: 'standard',
299
+ size: 'small',
215
300
  width: 300,
216
301
  paperMaxHeight: 300,
217
302
  hasShrink: false,
218
303
  placeholder: PLACEHOLDER,
219
- helperText: 'test',
304
+ helperText: 'Pick your choice',
220
305
  disabled: false,
221
306
  }
@@ -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,8 @@ const classes = {
18
16
  inputLabelFocused: `${PREFIX}-inputLabelFocused`,
19
17
  inputLabelMarginDense: `${PREFIX}-inputLabelMarginDense`,
20
18
  inputLabelError: `${PREFIX}-inputLabelError`,
19
+ inputFocused: `${PREFIX}-inputFocused`,
20
+ inputInput: `${PREFIX}-input`,
21
21
  inputUnderline: `${PREFIX}-inputUnderline`,
22
22
  inputError: `${PREFIX}-inputError`,
23
23
  inputDisabled: `${PREFIX}-inputDisabled`,
@@ -28,15 +28,18 @@ const classes = {
28
28
 
29
29
  interface StyledFormControlProps {
30
30
  color: 'primary' | 'secondary'
31
- width: number | 'auto'
31
+ width: number | string
32
+ selectMargin: number | string
32
33
  theme?: Theme
33
34
  }
34
35
 
35
- const StyledFormControl = styled(({ width: _width, ...props }) => (
36
- <FormControl {...props} />
37
- ))(({ width, theme }: StyledFormControlProps) => ({
36
+ const StyledFormControl = styled(
37
+ ({ width: _width, selectMargin: _selectMargin, ...props }) => (
38
+ <FormControl {...props} />
39
+ )
40
+ )(({ width, selectMargin, theme }: StyledFormControlProps) => ({
38
41
  width,
39
- margin: theme.spacing(0, 4, 4, 4),
42
+ margin: selectMargin,
40
43
  }))
41
44
 
42
45
  interface StyledInputLabelProps {
@@ -64,7 +67,7 @@ const StyledInputLabel = styled(({ color: _color, ...props }) => (
64
67
  }))
65
68
 
66
69
  interface StyledSelectProps {
67
- paperMaxHeight: number | 'auto'
70
+ paperMaxHeight: number | string
68
71
  hasAdornment: boolean
69
72
  }
70
73
 
@@ -102,6 +105,7 @@ interface StyledInputProps {
102
105
  const StyledInput = styled(({ color: _color, ...props }) => (
103
106
  <Input
104
107
  classes={{
108
+ input: classes.inputInput,
105
109
  disabled: classes.inputDisabled,
106
110
  underline: classes.inputUnderline,
107
111
  error: classes.inputError,
@@ -110,6 +114,11 @@ const StyledInput = styled(({ color: _color, ...props }) => (
110
114
  />
111
115
  ))(({ color, theme }: StyledInputProps) => ({
112
116
  color: theme.palette.text.primary,
117
+ [`& .${classes.inputInput}`]: {
118
+ ['&:focus']: {
119
+ background: 'rgba(0,0,0,0)',
120
+ },
121
+ },
113
122
  [`&.${classes.inputUnderline}:not(.${classes.inputDisabled}):not(.${classes.inputError})`]: {
114
123
  [`&:after,&:hover:before`]: {
115
124
  borderBottomColor: theme.palette[color].main,
@@ -122,20 +131,6 @@ const StyledInput = styled(({ color: _color, ...props }) => (
122
131
  },
123
132
  }))
124
133
 
125
- export interface StandardSelectProps extends SelectProps {
126
- color?: 'primary' | 'secondary'
127
- size?: 'medium' | 'small'
128
- width?: number | 'auto'
129
- paperMaxHeight?: number | 'auto'
130
- error?: boolean
131
- hasShrink?: boolean
132
- placeholder: string
133
- helperText?: string
134
- InputProps?: object & Partial<InputProps>
135
- disabled?: boolean
136
- SelectProps?: object | Partial<SelectProps>
137
- }
138
-
139
134
  export function StandardSelect({
140
135
  placeholder,
141
136
  helperText,
@@ -143,14 +138,15 @@ export function StandardSelect({
143
138
  SelectProps,
144
139
  children,
145
140
  color = 'primary',
146
- size = 'medium',
141
+ size = 'small',
147
142
  width = 'auto',
143
+ selectMargin = '0',
148
144
  paperMaxHeight = 'auto',
149
145
  error = false,
150
146
  hasShrink = false,
151
147
  value = '',
152
148
  disabled = false,
153
- }: StandardSelectProps) {
149
+ }: SelectProps) {
154
150
  const hasAdornment = !!InputProps?.startAdornment
155
151
  const hasHelperText = !!helperText
156
152
  return (
@@ -158,6 +154,7 @@ export function StandardSelect({
158
154
  color={color}
159
155
  size={size}
160
156
  width={width}
157
+ selectMargin={selectMargin}
161
158
  disabled={disabled}
162
159
  error={error}
163
160
  >
@@ -4,7 +4,7 @@ import {
4
4
  TopicFilter as JuiTopicFilter,
5
5
  TopicFilterProps as JuiTopicFilterProps,
6
6
  } from './TopicFilter'
7
- import { topicTree } from '../utils/topicTree'
7
+ import { topicTree } from '../../utils/topicTree'
8
8
 
9
9
  export default {
10
10
  component: JuiTopicFilter,
@@ -1,9 +1,9 @@
1
1
  import React, { useState, useEffect } from 'react'
2
- import { Theme, styled } from '@material-ui/core/styles'
2
+ import { Theme, styled, useTheme } from '@material-ui/core/styles'
3
3
  import ArrowRightRoundedIcon from '@material-ui/icons/ArrowRightRounded'
4
- import type { ITopicTreeNode } from '../interfaces'
5
- import OutlinedSelect from './select/OutlinedSelect'
6
- import SelectMenuItem from './menu-item/SelectMenuItem'
4
+ import type { ITopicTreeNode } from '../../interfaces'
5
+ import Select from '../select/Select'
6
+ import SelectMenuItem from '../menu-item/SelectMenuItem'
7
7
 
8
8
  // self-defined-configs
9
9
  const PLACEHOLDER = '請選擇'
@@ -52,6 +52,7 @@ export const TopicFilter = ({
52
52
  hasArrow,
53
53
  initSelectedTopicIds,
54
54
  }: TopicFilterProps) => {
55
+ const theme = useTheme()
55
56
  const [selectedTopicIds, setSelectedTopicIds] = useState([])
56
57
  const [layeredTopicList, setLayeredTopicList] = useState([])
57
58
  const [isFocusedList, setIsFocusedList] = useState([])
@@ -125,12 +126,14 @@ export const TopicFilter = ({
125
126
 
126
127
  if (layeredTopicList.length === 0) {
127
128
  return (
128
- <OutlinedSelect
129
+ <Select
130
+ variant='outlined'
129
131
  size='small'
130
132
  width={220}
133
+ selectMargin={theme.spacing(1)}
131
134
  placeholder='載入資料中...'
132
135
  disabled
133
- ></OutlinedSelect>
136
+ ></Select>
134
137
  )
135
138
  }
136
139
  return (
@@ -140,9 +143,11 @@ export const TopicFilter = ({
140
143
  isFocusedList[layerNumber] || !selectedTopicIds[layerNumber]
141
144
  return (
142
145
  <SelectWrapper key={layeredTopic.id}>
143
- <OutlinedSelect
146
+ <Select
147
+ variant='outlined'
144
148
  size='small'
145
149
  width={220}
150
+ selectMargin={theme.spacing(1)}
146
151
  paperMaxHeight={412}
147
152
  hasLabel={hasLabel}
148
153
  placeholder={PLACEHOLDER}
@@ -150,7 +155,7 @@ export const TopicFilter = ({
150
155
  SelectProps={{
151
156
  'data-testid': `layered-topic-${layerNumber}`,
152
157
  }}
153
- OutlinedInputProps={{
158
+ InputProps={{
154
159
  inputProps: {
155
160
  'aria-label': `layered-topic-${layerNumber}`,
156
161
  },
@@ -187,7 +192,7 @@ export const TopicFilter = ({
187
192
  {childTopic.title}
188
193
  </SelectMenuItem>
189
194
  ))}
190
- </OutlinedSelect>
195
+ </Select>
191
196
  {hasArrow && layerNumber !== layeredTopicList.length - 1 && (
192
197
  <StyledArrowRightRoundedIcon
193
198
  fontSize='large'
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { AlertProps as MuiAlertProps } from '@material-ui/lab';
3
- export interface AlertProps extends MuiAlertProps {
4
- severity?: 'success' | 'info' | 'warning' | 'error';
5
- action?: boolean;
6
- buttonLink?: string;
7
- isNewTab?: boolean;
8
- cross?: boolean;
9
- handleCrossClick?: () => void;
10
- children?: React.ReactNode;
11
- }
12
- export declare const JuiAlert: ({ severity, action, buttonLink, isNewTab, cross, handleCrossClick, children, ...otherProps }: AlertProps) => JSX.Element;
13
- export default JuiAlert;
@@ -1,10 +0,0 @@
1
- export interface SelectionItemProps {
2
- handleInput: () => {};
3
- label1: string;
4
- value1: string;
5
- label2: string;
6
- value2: string;
7
- isError: boolean;
8
- }
9
- export declare function SelectionItem({ handleInput, label1, value1, label2, value2, isError, }: SelectionItemProps): JSX.Element;
10
- export default SelectionItem;