@junyiacademy/ui-test 0.0.13 → 1.4.2
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/interfaces/index.d.ts +2 -2
- package/declarations/libs/ui/src/lib/menu-item/SelectMenuItem.d.ts +1 -2
- package/declarations/libs/ui/src/lib/select/OutlinedSelect.d.ts +1 -1
- package/declarations/libs/ui/src/lib/select/StandardSelect.d.ts +1 -1
- package/dist/libs/.DS_Store +0 -0
- package/dist/libs/ui/.DS_Store +0 -0
- package/dist/libs/ui/src/.DS_Store +0 -0
- package/dist/libs/ui/src/lib/menu-item/SelectMenuItem.js +7 -8
- package/dist/libs/ui/src/lib/select/OutlinedSelect.js +13 -16
- package/dist/libs/ui/src/lib/select/StandardSelect.js +5 -18
- package/dist/libs/ui/src/lib/topic-filter/TopicFilter.js +9 -5
- package/package.json +2 -2
- package/.eslintrc.json +0 -24
- package/.storybook/main.js +0 -9
- package/.storybook/preview.js +0 -10
- package/.storybook/tsconfig.json +0 -14
- package/.storybook/webpack.config.js +0 -84
- package/declarations/libs/ui/src/lib/alert/Alert.d.ts +0 -13
- package/declarations/libs/ui/src/lib/selection-item/SelectionItem.d.ts +0 -10
- package/dist/libs/ui/src/lib/alert/Alert.js +0 -72
- package/dist/libs/ui/src/lib/selection-item/SelectionItem.js +0 -16
- package/jest.config.js +0 -9
- package/src/index.ts +0 -7
- package/src/interfaces/index.tsx +0 -33
- package/src/lib/button/Button.stories.tsx +0 -50
- package/src/lib/button/Button.tsx +0 -85
- package/src/lib/button-group/ButtonGroup.stories.tsx +0 -59
- package/src/lib/button-group/ButtonGroup.tsx +0 -37
- package/src/lib/menu-item/SelectMenuItem.stories.tsx +0 -44
- package/src/lib/menu-item/SelectMenuItem.tsx +0 -45
- package/src/lib/radio/Radio.stories.tsx +0 -154
- package/src/lib/radio/Radio.tsx +0 -93
- package/src/lib/select/OutlinedSelect.tsx +0 -216
- package/src/lib/select/Select.stories.tsx +0 -421
- package/src/lib/select/Select.tsx +0 -13
- package/src/lib/select/StandardSelect.tsx +0 -179
- package/src/lib/text-field/TextField.stories.tsx +0 -160
- package/src/lib/text-field/TextField.tsx +0 -93
- package/src/lib/topic-filter/TopicFilter.stories.tsx +0 -83
- package/src/lib/topic-filter/TopicFilter.tsx +0 -204
- package/src/styles/theme.ts +0 -60
- package/src/utils/topicTree.ts +0 -197
- package/tsconfig.json +0 -16
- package/tsconfig.lib.json +0 -22
- package/tsconfig.spec.json +0 -15
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { Theme, styled } from '@material-ui/core/styles'
|
|
3
|
-
import {
|
|
4
|
-
InputLabel,
|
|
5
|
-
FormControl,
|
|
6
|
-
Select,
|
|
7
|
-
OutlinedInput,
|
|
8
|
-
FormHelperText,
|
|
9
|
-
} from '@material-ui/core'
|
|
10
|
-
import { SelectProps } from '../../interfaces'
|
|
11
|
-
|
|
12
|
-
// self-defined-components
|
|
13
|
-
const PREFIX = 'JuiOutlinedSelect'
|
|
14
|
-
|
|
15
|
-
const classes = {
|
|
16
|
-
inputLabelFocused: `${PREFIX}-inputLabelFocused`,
|
|
17
|
-
inputLabelOutlined: `${PREFIX}-inputLabelOutlined`,
|
|
18
|
-
inputLabelMarginDense: `${PREFIX}-inputLabelMarginDense`,
|
|
19
|
-
inputLabelShrink: `${PREFIX}-inputLabelShrink`,
|
|
20
|
-
inputLabelError: `${PREFIX}-inputLabelError`,
|
|
21
|
-
inputLabelDisabled: `${PREFIX}-inputLabelDisabled`,
|
|
22
|
-
outlineInputInput: `${PREFIX}-input`,
|
|
23
|
-
outlineInputRoot: `${PREFIX}-inputRoot`,
|
|
24
|
-
outlineInputInputMarginDense: `${PREFIX}-inputMarginDense`,
|
|
25
|
-
outlineInputNotchedOutline: `${PREFIX}-notchedOutline`,
|
|
26
|
-
outlineInputDisabled: `${PREFIX}-inputDisabled`,
|
|
27
|
-
outlineInputError: `${PREFIX}-outlinedInputError`,
|
|
28
|
-
outlineInputFocused: `${PREFIX}-focused`,
|
|
29
|
-
selectPaper: `${PREFIX}-menuPaper`,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface StyledFormControlProps {
|
|
33
|
-
color: 'primary' | 'secondary'
|
|
34
|
-
width: number | 'auto'
|
|
35
|
-
theme?: Theme
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const StyledFormControl = styled(
|
|
39
|
-
({ color: _color, width: _width, ...props }) => <FormControl {...props} />
|
|
40
|
-
)(({ color, width, theme }: StyledFormControlProps) => ({
|
|
41
|
-
margin: theme.spacing(1),
|
|
42
|
-
width: width,
|
|
43
|
-
backgroundColor: 'white',
|
|
44
|
-
'&:hover': {
|
|
45
|
-
[`& :not(.${classes.outlineInputDisabled}):not(.${classes.outlineInputError}) .${classes.outlineInputNotchedOutline}`]: {
|
|
46
|
-
borderColor: theme.palette[color].main,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
[`& .${classes.outlineInputError}.${classes.outlineInputFocused} .${classes.outlineInputNotchedOutline}`]: {
|
|
50
|
-
borderColor: `${theme.palette.error.main}`,
|
|
51
|
-
},
|
|
52
|
-
}))
|
|
53
|
-
|
|
54
|
-
interface StyledInputLabelProps {
|
|
55
|
-
color: 'primary' | 'secondary'
|
|
56
|
-
theme?: Theme
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const StyledInputLabel = styled(({ color: _color, ...props }) => (
|
|
60
|
-
<InputLabel
|
|
61
|
-
classes={{
|
|
62
|
-
outlined: classes.inputLabelOutlined,
|
|
63
|
-
marginDense: classes.inputLabelMarginDense,
|
|
64
|
-
shrink: classes.inputLabelShrink,
|
|
65
|
-
focused: classes.inputLabelFocused,
|
|
66
|
-
disabled: classes.inputLabelDisabled,
|
|
67
|
-
error: classes.inputLabelError,
|
|
68
|
-
}}
|
|
69
|
-
{...props}
|
|
70
|
-
/>
|
|
71
|
-
))(({ color, theme }: StyledInputLabelProps) => ({
|
|
72
|
-
color: theme.palette.text.secondary,
|
|
73
|
-
[`&.${classes.inputLabelOutlined}`]: {
|
|
74
|
-
[`&:not(.${classes.inputLabelDisabled}) .${classes.inputLabelFocused}`]: {
|
|
75
|
-
color: theme.palette.action.active,
|
|
76
|
-
},
|
|
77
|
-
[`&.${classes.inputLabelMarginDense}:not(.${classes.inputLabelShrink})`]: {
|
|
78
|
-
transform: 'translate(12px, 16px) scale(1)',
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
[`&.${classes.inputLabelShrink}:not(.${classes.inputLabelError}):not(.${classes.inputLabelDisabled}).${classes.inputLabelFocused}`]: {
|
|
82
|
-
color: theme.palette[color].main,
|
|
83
|
-
},
|
|
84
|
-
[`&.${classes.inputLabelShrink}`]: {
|
|
85
|
-
backgroundColor: '#ffffff',
|
|
86
|
-
padding: '0 2px',
|
|
87
|
-
},
|
|
88
|
-
}))
|
|
89
|
-
|
|
90
|
-
interface StyledOutlinedInputProps {
|
|
91
|
-
theme?: Theme
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const StyledOutlinedInput = styled((props) => (
|
|
95
|
-
<OutlinedInput
|
|
96
|
-
classes={{
|
|
97
|
-
root: classes.outlineInputRoot,
|
|
98
|
-
focused: classes.outlineInputFocused,
|
|
99
|
-
input: classes.outlineInputInput,
|
|
100
|
-
inputMarginDense: classes.outlineInputInputMarginDense,
|
|
101
|
-
notchedOutline: classes.outlineInputNotchedOutline,
|
|
102
|
-
disabled: classes.outlineInputDisabled,
|
|
103
|
-
error: classes.outlineInputError,
|
|
104
|
-
}}
|
|
105
|
-
{...props}
|
|
106
|
-
/>
|
|
107
|
-
))(({ theme }: StyledOutlinedInputProps) => ({
|
|
108
|
-
[`&.${classes.outlineInputRoot}.${classes.outlineInputFocused}`]: {
|
|
109
|
-
backgroundColor: theme.palette.action.selected,
|
|
110
|
-
},
|
|
111
|
-
[`& .${classes.outlineInputInput}`]: {
|
|
112
|
-
color: theme.palette.text.primary,
|
|
113
|
-
['&:focus']: {
|
|
114
|
-
background: 'rgba(0,0,0,0)',
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
[`& .${classes.outlineInputInputMarginDense}`]: {
|
|
118
|
-
padding: '14.5px 15px 14.5px 12px',
|
|
119
|
-
},
|
|
120
|
-
}))
|
|
121
|
-
|
|
122
|
-
interface StyledSelectProps {
|
|
123
|
-
paperMaxHeight: number | 'auto'
|
|
124
|
-
hasAdornment: boolean
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const StyledSelect = styled(
|
|
128
|
-
({
|
|
129
|
-
paperMaxHeight: _paperMaxHeight,
|
|
130
|
-
hasAdornment: _hasAdornment,
|
|
131
|
-
className,
|
|
132
|
-
...props
|
|
133
|
-
}) => (
|
|
134
|
-
<Select
|
|
135
|
-
MenuProps={{
|
|
136
|
-
disableAutoFocusItem: true,
|
|
137
|
-
anchorOrigin: {
|
|
138
|
-
vertical: 2,
|
|
139
|
-
horizontal: 'left',
|
|
140
|
-
},
|
|
141
|
-
transformOrigin: {
|
|
142
|
-
vertical: 'top',
|
|
143
|
-
horizontal: 'left',
|
|
144
|
-
},
|
|
145
|
-
getContentAnchorEl: null,
|
|
146
|
-
classes: {
|
|
147
|
-
paper: className,
|
|
148
|
-
},
|
|
149
|
-
}}
|
|
150
|
-
{...props}
|
|
151
|
-
/>
|
|
152
|
-
)
|
|
153
|
-
)(({ hasAdornment, paperMaxHeight }: StyledSelectProps) => ({
|
|
154
|
-
'&': {
|
|
155
|
-
maxHeight: paperMaxHeight,
|
|
156
|
-
left: hasAdornment ? '24px !important' : '70px',
|
|
157
|
-
},
|
|
158
|
-
}))
|
|
159
|
-
|
|
160
|
-
export const OutlinedSelect = ({
|
|
161
|
-
placeholder,
|
|
162
|
-
helperText,
|
|
163
|
-
InputProps,
|
|
164
|
-
SelectProps,
|
|
165
|
-
children,
|
|
166
|
-
color = 'primary',
|
|
167
|
-
size = 'medium',
|
|
168
|
-
width = 'auto',
|
|
169
|
-
paperMaxHeight = 'auto',
|
|
170
|
-
error = false,
|
|
171
|
-
hasLabel = true,
|
|
172
|
-
hasShrink = false,
|
|
173
|
-
value = '',
|
|
174
|
-
disabled = false,
|
|
175
|
-
}: SelectProps) => {
|
|
176
|
-
const hasAdornment = !!InputProps?.startAdornment
|
|
177
|
-
const hasHelperText = !!helperText
|
|
178
|
-
return (
|
|
179
|
-
<StyledFormControl
|
|
180
|
-
size={size}
|
|
181
|
-
width={width}
|
|
182
|
-
disabled={disabled}
|
|
183
|
-
error={error}
|
|
184
|
-
color={color}
|
|
185
|
-
>
|
|
186
|
-
{hasLabel && (
|
|
187
|
-
<StyledInputLabel
|
|
188
|
-
color={color}
|
|
189
|
-
variant='outlined'
|
|
190
|
-
shrink={hasShrink ? true : undefined}
|
|
191
|
-
>
|
|
192
|
-
{placeholder}
|
|
193
|
-
</StyledInputLabel>
|
|
194
|
-
)}
|
|
195
|
-
<StyledSelect
|
|
196
|
-
value={value}
|
|
197
|
-
paperMaxHeight={paperMaxHeight}
|
|
198
|
-
hasAdornment={hasAdornment}
|
|
199
|
-
input={
|
|
200
|
-
<StyledOutlinedInput
|
|
201
|
-
color={color}
|
|
202
|
-
label={hasLabel ? placeholder : undefined}
|
|
203
|
-
disabled={disabled}
|
|
204
|
-
{...InputProps}
|
|
205
|
-
/>
|
|
206
|
-
}
|
|
207
|
-
{...SelectProps}
|
|
208
|
-
>
|
|
209
|
-
{children}
|
|
210
|
-
</StyledSelect>
|
|
211
|
-
{hasHelperText && <FormHelperText>{helperText}</FormHelperText>}
|
|
212
|
-
</StyledFormControl>
|
|
213
|
-
)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export default OutlinedSelect
|
|
@@ -1,421 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|