1 | "use strict";
|
2 |
|
3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
4 |
|
5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = exports.styles = void 0;
|
11 |
|
12 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13 |
|
14 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
15 |
|
16 | var React = _interopRequireWildcard(require("react"));
|
17 |
|
18 | var _propTypes = _interopRequireDefault(require("prop-types"));
|
19 |
|
20 | var _NativeSelectInput = _interopRequireDefault(require("./NativeSelectInput"));
|
21 |
|
22 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
23 |
|
24 | var _formControlState = _interopRequireDefault(require("../FormControl/formControlState"));
|
25 |
|
26 | var _useFormControl = _interopRequireDefault(require("../FormControl/useFormControl"));
|
27 |
|
28 | var _ArrowDropDown = _interopRequireDefault(require("../internal/svg-icons/ArrowDropDown"));
|
29 |
|
30 | var _Input = _interopRequireDefault(require("../Input"));
|
31 |
|
32 | var styles = function styles(theme) {
|
33 | return {
|
34 |
|
35 | root: {},
|
36 |
|
37 |
|
38 | select: {
|
39 | '-moz-appearance': 'none',
|
40 |
|
41 | '-webkit-appearance': 'none',
|
42 |
|
43 |
|
44 |
|
45 | userSelect: 'none',
|
46 | borderRadius: 0,
|
47 |
|
48 | minWidth: 16,
|
49 |
|
50 | cursor: 'pointer',
|
51 | '&:focus': {
|
52 |
|
53 | backgroundColor: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.05)' : 'rgba(255, 255, 255, 0.05)',
|
54 | borderRadius: 0
|
55 |
|
56 | },
|
57 |
|
58 | '&::-ms-expand': {
|
59 | display: 'none'
|
60 | },
|
61 | '&$disabled': {
|
62 | cursor: 'default'
|
63 | },
|
64 | '&[multiple]': {
|
65 | height: 'auto'
|
66 | },
|
67 | '&:not([multiple]) option, &:not([multiple]) optgroup': {
|
68 | backgroundColor: theme.palette.background.paper
|
69 | },
|
70 | '&&': {
|
71 | paddingRight: 24
|
72 | }
|
73 | },
|
74 |
|
75 |
|
76 | filled: {
|
77 | '&&': {
|
78 | paddingRight: 32
|
79 | }
|
80 | },
|
81 |
|
82 |
|
83 | outlined: {
|
84 | borderRadius: theme.shape.borderRadius,
|
85 | '&&': {
|
86 | paddingRight: 32
|
87 | }
|
88 | },
|
89 |
|
90 |
|
91 | selectMenu: {
|
92 | height: 'auto',
|
93 |
|
94 | minHeight: '1.1876em',
|
95 |
|
96 | textOverflow: 'ellipsis',
|
97 | whiteSpace: 'nowrap',
|
98 | overflow: 'hidden'
|
99 | },
|
100 |
|
101 |
|
102 | disabled: {},
|
103 |
|
104 |
|
105 | icon: {
|
106 |
|
107 |
|
108 | position: 'absolute',
|
109 | right: 0,
|
110 | top: 'calc(50% - 12px)',
|
111 |
|
112 | pointerEvents: 'none',
|
113 |
|
114 | color: theme.palette.action.active,
|
115 | '&$disabled': {
|
116 | color: theme.palette.action.disabled
|
117 | }
|
118 | },
|
119 |
|
120 |
|
121 | iconOpen: {
|
122 | transform: 'rotate(180deg)'
|
123 | },
|
124 |
|
125 |
|
126 | iconFilled: {
|
127 | right: 7
|
128 | },
|
129 |
|
130 |
|
131 | iconOutlined: {
|
132 | right: 7
|
133 | },
|
134 |
|
135 |
|
136 | nativeInput: {
|
137 | bottom: 0,
|
138 | left: 0,
|
139 | position: 'absolute',
|
140 | opacity: 0,
|
141 | pointerEvents: 'none',
|
142 | width: '100%'
|
143 | }
|
144 | };
|
145 | };
|
146 |
|
147 | exports.styles = styles;
|
148 | var defaultInput = React.createElement(_Input.default, null);
|
149 |
|
150 |
|
151 |
|
152 |
|
153 | var NativeSelect = React.forwardRef(function NativeSelect(props, ref) {
|
154 | var children = props.children,
|
155 | classes = props.classes,
|
156 | _props$IconComponent = props.IconComponent,
|
157 | IconComponent = _props$IconComponent === void 0 ? _ArrowDropDown.default : _props$IconComponent,
|
158 | _props$input = props.input,
|
159 | input = _props$input === void 0 ? defaultInput : _props$input,
|
160 | inputProps = props.inputProps,
|
161 | variant = props.variant,
|
162 | other = (0, _objectWithoutProperties2.default)(props, ["children", "classes", "IconComponent", "input", "inputProps", "variant"]);
|
163 | var muiFormControl = (0, _useFormControl.default)();
|
164 | var fcs = (0, _formControlState.default)({
|
165 | props: props,
|
166 | muiFormControl: muiFormControl,
|
167 | states: ['variant']
|
168 | });
|
169 | return React.cloneElement(input, (0, _extends2.default)({
|
170 |
|
171 |
|
172 | inputComponent: _NativeSelectInput.default,
|
173 | inputProps: (0, _extends2.default)({
|
174 | children: children,
|
175 | classes: classes,
|
176 | IconComponent: IconComponent,
|
177 | variant: fcs.variant,
|
178 | type: undefined
|
179 | }, inputProps, input ? input.props.inputProps : {}),
|
180 | ref: ref
|
181 | }, other));
|
182 | });
|
183 | process.env.NODE_ENV !== "production" ? NativeSelect.propTypes = {
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 | |
190 |
|
191 |
|
192 |
|
193 | children: _propTypes.default.node,
|
194 |
|
195 | |
196 |
|
197 |
|
198 |
|
199 | classes: _propTypes.default.object,
|
200 |
|
201 | |
202 |
|
203 |
|
204 | IconComponent: _propTypes.default.elementType,
|
205 |
|
206 | |
207 |
|
208 |
|
209 | input: _propTypes.default.element,
|
210 |
|
211 | |
212 |
|
213 |
|
214 | inputProps: _propTypes.default.object,
|
215 |
|
216 | |
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 | onChange: _propTypes.default.func,
|
223 |
|
224 | |
225 |
|
226 |
|
227 | value: _propTypes.default.any,
|
228 |
|
229 | |
230 |
|
231 |
|
232 | variant: _propTypes.default.oneOf(['filled', 'outlined', 'standard'])
|
233 | } : void 0;
|
234 | NativeSelect.muiName = 'Select';
|
235 |
|
236 | var _default = (0, _withStyles.default)(styles, {
|
237 | name: 'MuiNativeSelect'
|
238 | })(NativeSelect);
|
239 |
|
240 | exports.default = _default; |
\ | No newline at end of file |