@junyiacademy/ui-test 0.0.4 → 0.0.8
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.
- package/declarations/libs/ui/src/lib/selection-item/SelectionItem.d.ts +10 -0
- package/dist/libs/ui/src/lib/selection-item/SelectionItem.js +16 -0
- package/package.json +1 -1
- package/src/lib/TopicFilter.tsx +5 -14
- package/src/lib/menu-item/SelectMenuItem.tsx +5 -11
- package/src/lib/radio/Radio.stories.tsx +3 -2
- package/src/lib/select/OutlinedSelect.stories.tsx +79 -58
- package/src/lib/select/OutlinedSelect.tsx +34 -79
- package/src/lib/select/StandardSelect.stories.tsx +45 -29
- package/src/lib/select/StandardSelect.tsx +14 -50
- package/src/lib/text-field/TextField.stories.tsx +35 -1
- package/declarations/libs/ui/src/index.d.ts +0 -8
- package/declarations/libs/ui/src/interfaces/index.d.ts +0 -8
- package/declarations/libs/ui/src/lib/TopicFilter.d.ts +0 -13
- package/declarations/libs/ui/src/lib/button/Button.d.ts +0 -6
- package/declarations/libs/ui/src/lib/button-group/ButtonGroup.d.ts +0 -3
- package/declarations/libs/ui/src/lib/menu-item/SelectMenuItem.d.ts +0 -9
- package/declarations/libs/ui/src/lib/radio/Radio.d.ts +0 -10
- package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +0 -24
- package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +0 -20
- package/declarations/libs/ui/src/lib/text-field/TextField.d.ts +0 -3
- package/dist/libs/ui/src/index.js +0 -22
- package/dist/libs/ui/src/interfaces/index.js +0 -2
- package/dist/libs/ui/src/lib/TopicFilter.js +0 -123
- package/dist/libs/ui/src/lib/button/Button.js +0 -71
- package/dist/libs/ui/src/lib/button-group/ButtonGroup.js +0 -33
- package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +0 -30
- package/dist/libs/ui/src/lib/radio/Radio.js +0 -43
- package/dist/libs/ui/src/lib/select/OutlinedSelect.js +0 -132
- package/dist/libs/ui/src/lib/select/StandardSelect.js +0 -105
- package/dist/libs/ui/src/lib/text-field/TextField.js +0 -75
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SelectionItem = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const core_1 = require("@material-ui/core");
|
|
7
|
+
const Radio_1 = require("../radio/Radio");
|
|
8
|
+
function SelectionItem({ handleInput, label1, value1, label2, value2, isError, }) {
|
|
9
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
10
|
+
react_1.default.createElement(core_1.RadioGroup, { onChange: handleInput },
|
|
11
|
+
react_1.default.createElement(Radio_1.Radio, { label: label1, value: value1 }),
|
|
12
|
+
react_1.default.createElement(Radio_1.Radio, { label: label2, value: value2 })),
|
|
13
|
+
isError && react_1.default.createElement(core_1.FormHelperText, null, "\u8ACB\u9078\u64C7")));
|
|
14
|
+
}
|
|
15
|
+
exports.SelectionItem = SelectionItem;
|
|
16
|
+
exports.default = SelectionItem;
|
package/package.json
CHANGED
package/src/lib/TopicFilter.tsx
CHANGED
|
@@ -11,10 +11,6 @@ const PLACEHOLDER = '請選擇'
|
|
|
11
11
|
// self-defined-components
|
|
12
12
|
const PREFIX = 'JuiTopicFilter'
|
|
13
13
|
|
|
14
|
-
const classes = {
|
|
15
|
-
root: `${PREFIX}-arrowIcon`,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
14
|
const FiltersWrapper = styled('div')({
|
|
19
15
|
display: 'flex',
|
|
20
16
|
alignItems: 'center',
|
|
@@ -30,15 +26,13 @@ interface StyledArrowRightRoundedIconProps {
|
|
|
30
26
|
theme?: Theme
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
const StyledArrowRightRoundedIcon = styled(
|
|
34
|
-
|
|
35
|
-
))(({ theme }: StyledArrowRightRoundedIconProps) => ({
|
|
36
|
-
[`&.${classes.root}`]: {
|
|
29
|
+
const StyledArrowRightRoundedIcon = styled(ArrowRightRoundedIcon)(
|
|
30
|
+
({ theme }: StyledArrowRightRoundedIconProps) => ({
|
|
37
31
|
margin: theme.spacing(-1, -1.5),
|
|
38
32
|
fontSize: theme.spacing(7),
|
|
39
33
|
color: '#444',
|
|
40
|
-
}
|
|
41
|
-
|
|
34
|
+
})
|
|
35
|
+
)
|
|
42
36
|
|
|
43
37
|
export interface TopicFilterProps {
|
|
44
38
|
topicTree: ITopicTreeNode
|
|
@@ -149,12 +143,9 @@ const TopicFilter = ({
|
|
|
149
143
|
<OutlinedSelect
|
|
150
144
|
size='small'
|
|
151
145
|
width={220}
|
|
152
|
-
|
|
153
|
-
error={false}
|
|
146
|
+
paperMaxHeight={412}
|
|
154
147
|
hasLabel={hasLabel}
|
|
155
|
-
hasShrink={false}
|
|
156
148
|
placeholder={PLACEHOLDER}
|
|
157
|
-
hasAdornment={false}
|
|
158
149
|
value={selectedTopicIds?.[layerNumber] || ''}
|
|
159
150
|
SelectProps={{
|
|
160
151
|
'data-testid': `layered-topic-${layerNumber}`,
|
|
@@ -6,7 +6,6 @@ import { MenuItem, MenuItemProps } from '@material-ui/core'
|
|
|
6
6
|
const PREFIX = 'JuiSelectMenuItem'
|
|
7
7
|
|
|
8
8
|
const classes = {
|
|
9
|
-
menuItemRoot: `${PREFIX}-menuItem`,
|
|
10
9
|
menuItemSelected: `${PREFIX}-menuItemSelected`,
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -16,18 +15,13 @@ interface StyledMenuItemProps {
|
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
const StyledMenuItem = styled(({ width: _width, ...props }) => (
|
|
19
|
-
<MenuItem
|
|
20
|
-
classes={{ root: classes.menuItemRoot, selected: classes.menuItemSelected }}
|
|
21
|
-
{...props}
|
|
22
|
-
/>
|
|
18
|
+
<MenuItem classes={{ selected: classes.menuItemSelected }} {...props} />
|
|
23
19
|
))(({ width, theme }: StyledMenuItemProps) => ({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
color: theme.palette.text.primary,
|
|
28
|
-
},
|
|
20
|
+
width: width,
|
|
21
|
+
whiteSpace: 'unset',
|
|
22
|
+
color: theme.palette.text.primary,
|
|
29
23
|
[`& .${classes.menuItemSelected}`]: {
|
|
30
|
-
backgroundColor:
|
|
24
|
+
backgroundColor: theme.palette.grey[300],
|
|
31
25
|
},
|
|
32
26
|
}))
|
|
33
27
|
|
|
@@ -25,10 +25,11 @@ export default {
|
|
|
25
25
|
type: { name: 'string', required: false },
|
|
26
26
|
description: 'The position of the label.',
|
|
27
27
|
table: {
|
|
28
|
-
type: { summary: '
|
|
28
|
+
type: { summary: 'end' },
|
|
29
29
|
defaultValue: { summary: 'end' },
|
|
30
|
+
category: 'not comparable with caption',
|
|
30
31
|
},
|
|
31
|
-
options: ['
|
|
32
|
+
options: ['end'],
|
|
32
33
|
control: { type: 'radio' },
|
|
33
34
|
},
|
|
34
35
|
color: {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
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'
|
|
3
6
|
import OutlinedSelect, { OutlinedSelectProps } from './OutlinedSelect'
|
|
4
7
|
import SelectMenuItem from '../menu-item/SelectMenuItem'
|
|
5
8
|
|
|
@@ -29,7 +32,6 @@ export default {
|
|
|
29
32
|
},
|
|
30
33
|
options: ['small', 'medium'],
|
|
31
34
|
control: { type: 'radio' },
|
|
32
|
-
defaultValue: 'medium',
|
|
33
35
|
},
|
|
34
36
|
width: {
|
|
35
37
|
type: { name: 'number', required: false },
|
|
@@ -39,7 +41,6 @@ export default {
|
|
|
39
41
|
defaultValue: { summary: 'auto' },
|
|
40
42
|
},
|
|
41
43
|
control: { type: 'number' },
|
|
42
|
-
defaultValue: '220',
|
|
43
44
|
},
|
|
44
45
|
paperMaxHeight: {
|
|
45
46
|
type: { name: 'number', required: false },
|
|
@@ -49,27 +50,24 @@ export default {
|
|
|
49
50
|
defaultValue: { summary: 'auto' },
|
|
50
51
|
},
|
|
51
52
|
control: { type: 'number' },
|
|
52
|
-
defaultValue: '412',
|
|
53
53
|
},
|
|
54
|
-
|
|
54
|
+
hasInputLabel: {
|
|
55
55
|
type: { name: 'boolean', required: false },
|
|
56
|
-
description: '
|
|
56
|
+
description: 'If true, the label is displayed.',
|
|
57
57
|
table: {
|
|
58
58
|
type: { summary: 'boolean' },
|
|
59
59
|
defaultValue: { summary: true },
|
|
60
60
|
},
|
|
61
61
|
control: { type: 'boolean' },
|
|
62
|
-
defaultValue: true,
|
|
63
62
|
},
|
|
64
63
|
hasShrink: {
|
|
65
64
|
type: { name: 'boolean', required: false },
|
|
66
|
-
description: '
|
|
65
|
+
description: 'If true, the label is displayed and shrunk.',
|
|
67
66
|
table: {
|
|
68
67
|
type: { summary: 'boolean' },
|
|
69
68
|
defaultValue: { summary: false },
|
|
70
69
|
},
|
|
71
70
|
control: { type: 'boolean' },
|
|
72
|
-
defaultValue: false,
|
|
73
71
|
},
|
|
74
72
|
placeholder: {
|
|
75
73
|
type: { name: 'string', required: true },
|
|
@@ -79,7 +77,6 @@ export default {
|
|
|
79
77
|
defaultValue: { summary: '請選擇' },
|
|
80
78
|
},
|
|
81
79
|
control: { type: 'text' },
|
|
82
|
-
defaultValue: '請選擇',
|
|
83
80
|
},
|
|
84
81
|
value: {
|
|
85
82
|
type: { name: 'any', required: false },
|
|
@@ -108,33 +105,14 @@ export default {
|
|
|
108
105
|
},
|
|
109
106
|
control: { type: 'boolean' },
|
|
110
107
|
},
|
|
111
|
-
hasHelperText: {
|
|
112
|
-
type: { name: 'boolean', required: false },
|
|
113
|
-
description: 'If true, the helper text will be displayed.',
|
|
114
|
-
table: {
|
|
115
|
-
type: { summary: 'boolean' },
|
|
116
|
-
defaultValue: { summary: false },
|
|
117
|
-
},
|
|
118
|
-
control: { type: 'boolean' },
|
|
119
|
-
},
|
|
120
108
|
helperText: {
|
|
121
109
|
type: { name: 'string', required: true },
|
|
122
|
-
description: `
|
|
110
|
+
description: `Display the helper text.`,
|
|
123
111
|
table: {
|
|
124
112
|
type: { summary: 'string' },
|
|
125
|
-
defaultValue: { summary: '
|
|
113
|
+
defaultValue: { summary: '' },
|
|
126
114
|
},
|
|
127
115
|
control: { type: 'text' },
|
|
128
|
-
defaultValue: 'Helper text.',
|
|
129
|
-
},
|
|
130
|
-
hasAdornment: {
|
|
131
|
-
type: { name: 'boolean', required: false },
|
|
132
|
-
description: 'If true, the prefix adornment will be displayed.',
|
|
133
|
-
table: {
|
|
134
|
-
type: { summary: 'boolean' },
|
|
135
|
-
defaultValue: { summary: false },
|
|
136
|
-
},
|
|
137
|
-
control: { type: 'boolean' },
|
|
138
116
|
},
|
|
139
117
|
SelectProps: {
|
|
140
118
|
type: { name: 'any', required: false },
|
|
@@ -153,39 +131,66 @@ export default {
|
|
|
153
131
|
},
|
|
154
132
|
} as Meta
|
|
155
133
|
|
|
156
|
-
const
|
|
157
|
-
const [item, setItem] = useState<string>('')
|
|
134
|
+
const PREFIX = 'JuiOutlinedSelect'
|
|
158
135
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
136
|
+
const classes = {
|
|
137
|
+
outlineInputAdornmentRoot: `${PREFIX}-outlineInputAdornmentRoot`,
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
interface StyledInputAdornmentProps {
|
|
141
|
+
disabled: boolean
|
|
142
|
+
theme?: Theme
|
|
143
|
+
}
|
|
162
144
|
|
|
145
|
+
const StyledInputAdornment = styled(({ disabled: _disabled, ...props }) => (
|
|
146
|
+
<InputAdornment
|
|
147
|
+
classes={{
|
|
148
|
+
root: classes.outlineInputAdornmentRoot,
|
|
149
|
+
}}
|
|
150
|
+
{...props}
|
|
151
|
+
/>
|
|
152
|
+
))(({ disabled, theme }: StyledInputAdornmentProps) => ({
|
|
153
|
+
[`&.${classes.outlineInputAdornmentRoot}`]: {
|
|
154
|
+
color: disabled
|
|
155
|
+
? theme.palette.action.disabled
|
|
156
|
+
: theme.palette.action.active,
|
|
157
|
+
},
|
|
158
|
+
}))
|
|
159
|
+
|
|
160
|
+
const OutlinedSelectWithMenu = (props: OutlinedSelectProps) => {
|
|
163
161
|
return (
|
|
164
|
-
<OutlinedSelect
|
|
165
|
-
value={item}
|
|
166
|
-
OutlinedInputProps={{
|
|
167
|
-
onChange: (e) => {
|
|
168
|
-
handleChange(e)
|
|
169
|
-
},
|
|
170
|
-
}}
|
|
171
|
-
{...props}
|
|
172
|
-
>
|
|
162
|
+
<OutlinedSelect {...props}>
|
|
173
163
|
<SelectMenuItem width={220} value='' disabled>
|
|
174
164
|
{PLACEHOLDER}
|
|
175
165
|
</SelectMenuItem>
|
|
176
|
-
<SelectMenuItem width={220} value=
|
|
166
|
+
<SelectMenuItem width={220} value='Test'>
|
|
177
167
|
This is a select menu item
|
|
178
168
|
</SelectMenuItem>
|
|
179
|
-
<SelectMenuItem width={220} value=
|
|
169
|
+
<SelectMenuItem width={220} value='Example'>
|
|
180
170
|
Example
|
|
181
171
|
</SelectMenuItem>
|
|
182
172
|
</OutlinedSelect>
|
|
183
173
|
)
|
|
184
174
|
}
|
|
185
175
|
|
|
186
|
-
const ValueOnlyStory: Story<OutlinedSelectProps> = (args) =>
|
|
187
|
-
|
|
188
|
-
|
|
176
|
+
const ValueOnlyStory: Story<OutlinedSelectProps> = (args) => {
|
|
177
|
+
const [item, setItem] = useState<string>('')
|
|
178
|
+
|
|
179
|
+
const handleChange = (event) => {
|
|
180
|
+
setItem(event.target.value)
|
|
181
|
+
}
|
|
182
|
+
return (
|
|
183
|
+
<OutlinedSelectWithMenu
|
|
184
|
+
OutlinedInputProps={{
|
|
185
|
+
onChange: (e) => {
|
|
186
|
+
handleChange(e)
|
|
187
|
+
},
|
|
188
|
+
}}
|
|
189
|
+
value={item}
|
|
190
|
+
{...args}
|
|
191
|
+
/>
|
|
192
|
+
)
|
|
193
|
+
}
|
|
189
194
|
|
|
190
195
|
export const ValueOnly = ValueOnlyStory.bind({})
|
|
191
196
|
|
|
@@ -194,18 +199,36 @@ ValueOnly.args = {
|
|
|
194
199
|
size: 'medium',
|
|
195
200
|
width: 220,
|
|
196
201
|
paperMaxHeight: 412,
|
|
197
|
-
|
|
202
|
+
hasInputLabel: true,
|
|
198
203
|
placeholder: PLACEHOLDER,
|
|
199
|
-
hasHelperText: false,
|
|
200
204
|
helperText: 'test',
|
|
201
|
-
hasAdornment: false,
|
|
202
205
|
disabled: false,
|
|
203
206
|
SelectProps: {},
|
|
204
207
|
}
|
|
205
208
|
|
|
206
|
-
const WithPrefixStory: Story<OutlinedSelectProps> = (args) =>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
const WithPrefixStory: Story<OutlinedSelectProps> = (args) => {
|
|
210
|
+
const [item, setItem] = useState<string>('')
|
|
211
|
+
|
|
212
|
+
const handleChange = (event) => {
|
|
213
|
+
setItem(event.target.value)
|
|
214
|
+
}
|
|
215
|
+
return (
|
|
216
|
+
<OutlinedSelectWithMenu
|
|
217
|
+
OutlinedInputProps={{
|
|
218
|
+
onChange: (e) => {
|
|
219
|
+
handleChange(e)
|
|
220
|
+
},
|
|
221
|
+
startAdornment: (
|
|
222
|
+
<StyledInputAdornment position='start' disabled={args.disabled}>
|
|
223
|
+
<Visibility />
|
|
224
|
+
</StyledInputAdornment>
|
|
225
|
+
),
|
|
226
|
+
}}
|
|
227
|
+
value={item}
|
|
228
|
+
{...args}
|
|
229
|
+
/>
|
|
230
|
+
)
|
|
231
|
+
}
|
|
209
232
|
|
|
210
233
|
export const WithPrefix = WithPrefixStory.bind({})
|
|
211
234
|
|
|
@@ -214,11 +237,9 @@ WithPrefix.args = {
|
|
|
214
237
|
size: 'medium',
|
|
215
238
|
width: 220,
|
|
216
239
|
paperMaxHeight: 412,
|
|
217
|
-
|
|
240
|
+
hasInputLabel: true,
|
|
218
241
|
placeholder: PLACEHOLDER,
|
|
219
|
-
hasHelperText: false,
|
|
220
242
|
helperText: 'test',
|
|
221
|
-
hasAdornment: true,
|
|
222
243
|
disabled: false,
|
|
223
244
|
SelectProps: {},
|
|
224
245
|
}
|
|
@@ -8,28 +8,23 @@ import {
|
|
|
8
8
|
SelectProps,
|
|
9
9
|
OutlinedInputProps,
|
|
10
10
|
FormHelperText,
|
|
11
|
-
InputAdornment,
|
|
12
11
|
} from '@material-ui/core'
|
|
13
|
-
import VisibilityIcon from '@material-ui/icons/Visibility'
|
|
14
12
|
|
|
15
13
|
// self-defined-components
|
|
16
14
|
const PREFIX = 'JuiOutlinedSelect'
|
|
17
15
|
|
|
18
16
|
const classes = {
|
|
19
|
-
inputLabelRoot: `${PREFIX}-inputLabel`,
|
|
20
17
|
inputLabelFocused: `${PREFIX}-inputLabelFocused`,
|
|
21
18
|
inputLabelOutlined: `${PREFIX}-inputLabelOutlined`,
|
|
22
19
|
inputLabelMarginDense: `${PREFIX}-inputLabelMarginDense`,
|
|
23
20
|
inputLabelShrink: `${PREFIX}-inputLabelShrink`,
|
|
24
21
|
inputLabelError: `${PREFIX}-inputLabelError`,
|
|
25
22
|
inputLabelDisabled: `${PREFIX}-inputLabelDisabled`,
|
|
26
|
-
outlineInputRoot: `${PREFIX}-outlineInput`,
|
|
27
23
|
outlineInputInput: `${PREFIX}-input`,
|
|
28
24
|
outlineInputInputMarginDense: `${PREFIX}-inputMarginDense`,
|
|
29
25
|
outlineInputNotchedOutline: `${PREFIX}-notchedOutline`,
|
|
30
26
|
outlineInputDisabled: `${PREFIX}-inputDisabled`,
|
|
31
27
|
outlineInputError: `${PREFIX}-outlinedInputError`,
|
|
32
|
-
outlineInputAdornmentRoot: `${PREFIX}-outlineInputAdornmentRoot`,
|
|
33
28
|
selectPaper: `${PREFIX}-menuPaper`,
|
|
34
29
|
}
|
|
35
30
|
|
|
@@ -60,7 +55,6 @@ interface StyledInputLabelProps {
|
|
|
60
55
|
const StyledInputLabel = styled(({ color: _color, ...props }) => (
|
|
61
56
|
<InputLabel
|
|
62
57
|
classes={{
|
|
63
|
-
root: classes.inputLabelRoot,
|
|
64
58
|
outlined: classes.inputLabelOutlined,
|
|
65
59
|
marginDense: classes.inputLabelMarginDense,
|
|
66
60
|
shrink: classes.inputLabelShrink,
|
|
@@ -71,9 +65,7 @@ const StyledInputLabel = styled(({ color: _color, ...props }) => (
|
|
|
71
65
|
{...props}
|
|
72
66
|
/>
|
|
73
67
|
))(({ color, theme }: StyledInputLabelProps) => ({
|
|
74
|
-
|
|
75
|
-
color: theme.palette.text.secondary,
|
|
76
|
-
},
|
|
68
|
+
color: theme.palette.text.secondary,
|
|
77
69
|
[`&.${classes.inputLabelOutlined}`]: {
|
|
78
70
|
[`&:not(.${classes.inputLabelDisabled}) .${classes.inputLabelFocused}`]: {
|
|
79
71
|
color: theme.palette.action.active,
|
|
@@ -85,16 +77,16 @@ const StyledInputLabel = styled(({ color: _color, ...props }) => (
|
|
|
85
77
|
[`&.${classes.inputLabelShrink}:not(.${classes.inputLabelError}):not(.${classes.inputLabelDisabled}).${classes.inputLabelFocused}`]: {
|
|
86
78
|
color: theme.palette[color].main,
|
|
87
79
|
},
|
|
88
|
-
[`&.${classes.inputLabelShrink}.${classes.inputLabelError}:not(.${classes.inputLabelDisabled})`]: {
|
|
89
|
-
color: theme.palette.error.main,
|
|
90
|
-
},
|
|
91
|
-
[`&.${classes.inputLabelMarginDense}`]: {},
|
|
92
80
|
[`&.${classes.inputLabelShrink}`]: {
|
|
93
81
|
backgroundColor: '#ffffff',
|
|
94
82
|
padding: '0 2px',
|
|
95
83
|
},
|
|
96
84
|
}))
|
|
97
85
|
|
|
86
|
+
interface StyledOutlinedInputProps {
|
|
87
|
+
theme?: Theme
|
|
88
|
+
}
|
|
89
|
+
|
|
98
90
|
const StyledOutlinedInput = styled((props) => (
|
|
99
91
|
<OutlinedInput
|
|
100
92
|
classes={{
|
|
@@ -106,25 +98,23 @@ const StyledOutlinedInput = styled((props) => (
|
|
|
106
98
|
}}
|
|
107
99
|
{...props}
|
|
108
100
|
/>
|
|
109
|
-
))({
|
|
101
|
+
))(({ theme }: StyledOutlinedInputProps) => ({
|
|
110
102
|
[`& .${classes.outlineInputInput}`]: {
|
|
111
|
-
color:
|
|
103
|
+
color: theme.palette.text.primary,
|
|
112
104
|
},
|
|
113
105
|
[`& .${classes.outlineInputInputMarginDense}`]: {
|
|
114
106
|
padding: '14.5px 15px 14.5px 12px',
|
|
115
107
|
},
|
|
116
|
-
|
|
117
|
-
[`&.${classes.outlineInputDisabled}`]: {},
|
|
118
|
-
})
|
|
108
|
+
}))
|
|
119
109
|
|
|
120
110
|
interface StyledSelectProps {
|
|
121
|
-
|
|
111
|
+
paperMaxHeight: number | 'auto'
|
|
122
112
|
hasAdornment: boolean
|
|
123
113
|
}
|
|
124
114
|
|
|
125
115
|
const StyledSelect = styled(
|
|
126
116
|
({
|
|
127
|
-
|
|
117
|
+
paperMaxHeight: _paperMaxHeight,
|
|
128
118
|
hasAdornment: _hasAdornment,
|
|
129
119
|
className,
|
|
130
120
|
...props
|
|
@@ -146,45 +136,23 @@ const StyledSelect = styled(
|
|
|
146
136
|
{...props}
|
|
147
137
|
/>
|
|
148
138
|
)
|
|
149
|
-
)(({ hasAdornment,
|
|
139
|
+
)(({ hasAdornment, paperMaxHeight }: StyledSelectProps) => ({
|
|
150
140
|
'&&': {
|
|
151
|
-
maxHeight:
|
|
141
|
+
maxHeight: paperMaxHeight,
|
|
152
142
|
left: hasAdornment ? '24px !important' : '70px',
|
|
153
143
|
},
|
|
154
144
|
}))
|
|
155
145
|
|
|
156
|
-
interface StyledInputAdornmentProps {
|
|
157
|
-
disabled: boolean
|
|
158
|
-
theme?: Theme
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const StyledInputAdornment = styled(({ disabled: _disabled, ...props }) => (
|
|
162
|
-
<InputAdornment
|
|
163
|
-
classes={{
|
|
164
|
-
root: classes.outlineInputAdornmentRoot,
|
|
165
|
-
}}
|
|
166
|
-
{...props}
|
|
167
|
-
/>
|
|
168
|
-
))(({ disabled, theme }: StyledInputAdornmentProps) => ({
|
|
169
|
-
[`&.${classes.outlineInputAdornmentRoot}`]: {
|
|
170
|
-
color: disabled
|
|
171
|
-
? theme.palette.action.disabled
|
|
172
|
-
: theme.palette.action.active,
|
|
173
|
-
},
|
|
174
|
-
}))
|
|
175
|
-
|
|
176
146
|
export interface OutlinedSelectProps {
|
|
177
147
|
color?: 'primary' | 'secondary'
|
|
178
148
|
size?: 'medium' | 'small'
|
|
179
149
|
width?: number | 'auto'
|
|
180
|
-
|
|
150
|
+
paperMaxHeight?: number | 'auto'
|
|
181
151
|
error?: boolean
|
|
182
152
|
hasLabel?: boolean
|
|
183
153
|
hasShrink?: boolean
|
|
184
154
|
placeholder: string
|
|
185
|
-
hasHelperText?: boolean
|
|
186
155
|
helperText?: string
|
|
187
|
-
hasAdornment?: boolean
|
|
188
156
|
value?: unknown
|
|
189
157
|
disabled?: boolean
|
|
190
158
|
SelectProps?: object | Partial<SelectProps>
|
|
@@ -198,20 +166,20 @@ const OutlinedSelect = ({
|
|
|
198
166
|
color = 'primary',
|
|
199
167
|
size = 'medium',
|
|
200
168
|
width = 'auto',
|
|
201
|
-
|
|
169
|
+
paperMaxHeight = 'auto',
|
|
202
170
|
error = false,
|
|
203
171
|
hasLabel = true,
|
|
204
172
|
hasShrink = false,
|
|
205
173
|
placeholder,
|
|
206
|
-
hasHelperText = false,
|
|
207
174
|
helperText = '',
|
|
208
|
-
hasAdornment = false,
|
|
209
175
|
value = '',
|
|
210
176
|
disabled = false,
|
|
211
177
|
SelectProps,
|
|
212
178
|
OutlinedInputProps,
|
|
213
179
|
children,
|
|
214
180
|
}: OutlinedSelectProps) => {
|
|
181
|
+
const hasAdornment = !!OutlinedInputProps?.startAdornment
|
|
182
|
+
const hasHelperText = !!helperText
|
|
215
183
|
return (
|
|
216
184
|
<StyledFormControl
|
|
217
185
|
size={size}
|
|
@@ -220,41 +188,28 @@ const OutlinedSelect = ({
|
|
|
220
188
|
error={error}
|
|
221
189
|
color={color}
|
|
222
190
|
>
|
|
223
|
-
{
|
|
224
|
-
|
|
225
|
-
{
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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}
|
|
233
202
|
<StyledSelect
|
|
234
203
|
value={value}
|
|
235
|
-
|
|
204
|
+
paperMaxHeight={paperMaxHeight}
|
|
236
205
|
hasAdornment={hasAdornment}
|
|
237
206
|
input={
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
<StyledInputAdornment position='start' disabled={disabled}>
|
|
245
|
-
<VisibilityIcon />
|
|
246
|
-
</StyledInputAdornment>
|
|
247
|
-
}
|
|
248
|
-
{...OutlinedInputProps}
|
|
249
|
-
/>
|
|
250
|
-
) : (
|
|
251
|
-
<StyledOutlinedInput
|
|
252
|
-
color={color}
|
|
253
|
-
label={hasLabel ? placeholder : undefined}
|
|
254
|
-
disabled={disabled}
|
|
255
|
-
{...OutlinedInputProps}
|
|
256
|
-
/>
|
|
257
|
-
)
|
|
207
|
+
<StyledOutlinedInput
|
|
208
|
+
color={color}
|
|
209
|
+
label={hasLabel ? placeholder : undefined}
|
|
210
|
+
disabled={disabled}
|
|
211
|
+
{...OutlinedInputProps}
|
|
212
|
+
/>
|
|
258
213
|
}
|
|
259
214
|
{...SelectProps}
|
|
260
215
|
>
|