1
+ import Chip from '@material-ui/core/Chip' ;
2
+ import MenuItem from '@material-ui/core/MenuItem' ;
3
+ import Paper from '@material-ui/core/Paper' ;
4
+ import TextField from '@material-ui/core/TextField' ;
5
+ import Typography from '@material-ui/core/Typography' ;
6
+ import CancelIcon from '@material-ui/icons/Cancel' ;
7
+ import classNames from 'classnames' ;
8
+ import * as React from 'react' ;
9
+
10
+ function NoOptionsMessage ( props : any ) {
11
+ return (
12
+ < Typography
13
+ color = 'textSecondary'
14
+ className = { props . selectProps . classes . noOptionsMessage }
15
+ { ...props . innerProps }
16
+ >
17
+ { props . children }
18
+ </ Typography >
19
+ ) ;
20
+ }
21
+
22
+ function inputComponent ( { inputRef, ...props } : any ) {
23
+ return < div ref = { inputRef } { ...props } /> ;
24
+ }
25
+
26
+ function Control ( props : any ) {
27
+ return (
28
+ < TextField
29
+ fullWidth
30
+ InputProps = { {
31
+ inputComponent,
32
+ inputProps : {
33
+ className : props . selectProps . classes . input ,
34
+ inputRef : props . innerRef ,
35
+ children : props . children ,
36
+ ...props . innerProps ,
37
+ } ,
38
+ } }
39
+ { ...props . selectProps . textFieldProps }
40
+ />
41
+ ) ;
42
+ }
43
+
44
+ function Option ( props : any ) {
45
+ return (
46
+ < MenuItem
47
+ buttonRef = { props . innerRef }
48
+ selected = { props . isFocused }
49
+ component = 'div'
50
+ style = { {
51
+ fontWeight : props . isSelected ? 500 : 400 ,
52
+ } }
53
+ { ...props . innerProps }
54
+ >
55
+ { props . children }
56
+ </ MenuItem >
57
+ ) ;
58
+ }
59
+
60
+ function Placeholder ( props : any ) {
61
+ return (
62
+ < Typography
63
+ color = 'textSecondary'
64
+ className = { props . selectProps . classes . placeholder }
65
+ { ...props . innerProps }
66
+ >
67
+ { props . children }
68
+ </ Typography >
69
+ ) ;
70
+ }
71
+
72
+ function SingleValue ( props : any ) {
73
+ return (
74
+ < Typography className = { props . selectProps . classes . singleValue } { ...props . innerProps } >
75
+ { props . children }
76
+ </ Typography >
77
+ ) ;
78
+ }
79
+
80
+ function ValueContainer ( props : any ) {
81
+ return < div className = { props . selectProps . classes . valueContainer } > { props . children } </ div > ;
82
+ }
83
+
84
+ function MultiValue ( props : any ) {
85
+ return (
86
+ < Chip
87
+ tabIndex = { - 1 }
88
+ label = { props . children }
89
+ className = { classNames ( props . selectProps . classes . chip , {
90
+ [ props . selectProps . classes . chipFocused ] : props . isFocused ,
91
+ } ) }
92
+ onDelete = { props . removeProps . onClick }
93
+ deleteIcon = { < CancelIcon { ...props . removeProps } /> }
94
+ />
95
+ ) ;
96
+ }
97
+
98
+ function Menu ( props : any ) {
99
+ return (
100
+ < Paper square className = { props . selectProps . classes . paper } { ...props . innerProps } >
101
+ { props . children }
102
+ </ Paper >
103
+ ) ;
104
+ }
105
+
106
+ const components = {
107
+ Control,
108
+ Menu,
109
+ MultiValue,
110
+ NoOptionsMessage,
111
+ Option,
112
+ Placeholder,
113
+ SingleValue,
114
+ ValueContainer,
115
+ } ;
116
+
117
+ export default components ;
0 commit comments