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 _styles = require("@material-ui/styles");
|
21 |
|
22 | var _SelectInput = _interopRequireDefault(require("./SelectInput"));
|
23 |
|
24 | var _formControlState = _interopRequireDefault(require("../FormControl/formControlState"));
|
25 |
|
26 | var _useFormControl = _interopRequireDefault(require("../FormControl/useFormControl"));
|
27 |
|
28 | var _withStyles = _interopRequireDefault(require("../styles/withStyles"));
|
29 |
|
30 | var _ArrowDropDown = _interopRequireDefault(require("../internal/svg-icons/ArrowDropDown"));
|
31 |
|
32 | var _Input = _interopRequireDefault(require("../Input"));
|
33 |
|
34 | var _NativeSelect = require("../NativeSelect/NativeSelect");
|
35 |
|
36 | var _NativeSelectInput = _interopRequireDefault(require("../NativeSelect/NativeSelectInput"));
|
37 |
|
38 | var _FilledInput = _interopRequireDefault(require("../FilledInput"));
|
39 |
|
40 | var _OutlinedInput = _interopRequireDefault(require("../OutlinedInput"));
|
41 |
|
42 | var styles = _NativeSelect.styles;
|
43 | exports.styles = styles;
|
44 |
|
45 | var _ref = React.createElement(_Input.default, null);
|
46 |
|
47 | var _ref2 = React.createElement(_FilledInput.default, null);
|
48 |
|
49 | var Select = React.forwardRef(function Select(props, ref) {
|
50 | var _props$autoWidth = props.autoWidth,
|
51 | autoWidth = _props$autoWidth === void 0 ? false : _props$autoWidth,
|
52 | children = props.children,
|
53 | classes = props.classes,
|
54 | _props$displayEmpty = props.displayEmpty,
|
55 | displayEmpty = _props$displayEmpty === void 0 ? false : _props$displayEmpty,
|
56 | _props$IconComponent = props.IconComponent,
|
57 | IconComponent = _props$IconComponent === void 0 ? _ArrowDropDown.default : _props$IconComponent,
|
58 | id = props.id,
|
59 | input = props.input,
|
60 | inputProps = props.inputProps,
|
61 | label = props.label,
|
62 | labelId = props.labelId,
|
63 | _props$labelWidth = props.labelWidth,
|
64 | labelWidth = _props$labelWidth === void 0 ? 0 : _props$labelWidth,
|
65 | MenuProps = props.MenuProps,
|
66 | _props$multiple = props.multiple,
|
67 | multiple = _props$multiple === void 0 ? false : _props$multiple,
|
68 | _props$native = props.native,
|
69 | native = _props$native === void 0 ? false : _props$native,
|
70 | onClose = props.onClose,
|
71 | onOpen = props.onOpen,
|
72 | open = props.open,
|
73 | renderValue = props.renderValue,
|
74 | SelectDisplayProps = props.SelectDisplayProps,
|
75 | _props$variant = props.variant,
|
76 | variantProps = _props$variant === void 0 ? 'standard' : _props$variant,
|
77 | other = (0, _objectWithoutProperties2.default)(props, ["autoWidth", "children", "classes", "displayEmpty", "IconComponent", "id", "input", "inputProps", "label", "labelId", "labelWidth", "MenuProps", "multiple", "native", "onClose", "onOpen", "open", "renderValue", "SelectDisplayProps", "variant"]);
|
78 | var inputComponent = native ? _NativeSelectInput.default : _SelectInput.default;
|
79 | var muiFormControl = (0, _useFormControl.default)();
|
80 | var fcs = (0, _formControlState.default)({
|
81 | props: props,
|
82 | muiFormControl: muiFormControl,
|
83 | states: ['variant']
|
84 | });
|
85 | var variant = fcs.variant || variantProps;
|
86 | var InputComponent = input || {
|
87 | standard: _ref,
|
88 | outlined: React.createElement(_OutlinedInput.default, {
|
89 | label: label,
|
90 | labelWidth: labelWidth
|
91 | }),
|
92 | filled: _ref2
|
93 | }[variant];
|
94 | return React.cloneElement(InputComponent, (0, _extends2.default)({
|
95 |
|
96 |
|
97 | inputComponent: inputComponent,
|
98 | inputProps: (0, _extends2.default)({
|
99 | children: children,
|
100 | IconComponent: IconComponent,
|
101 | variant: variant,
|
102 | type: undefined,
|
103 |
|
104 | multiple: multiple
|
105 | }, native ? {
|
106 | id: id
|
107 | } : {
|
108 | autoWidth: autoWidth,
|
109 | displayEmpty: displayEmpty,
|
110 | labelId: labelId,
|
111 | MenuProps: MenuProps,
|
112 | onClose: onClose,
|
113 | onOpen: onOpen,
|
114 | open: open,
|
115 | renderValue: renderValue,
|
116 | SelectDisplayProps: (0, _extends2.default)({
|
117 | id: id
|
118 | }, SelectDisplayProps)
|
119 | }, inputProps, {
|
120 | classes: inputProps ? (0, _styles.mergeClasses)({
|
121 | baseClasses: classes,
|
122 | newClasses: inputProps.classes,
|
123 | Component: Select
|
124 | }) : classes
|
125 | }, input ? input.props.inputProps : {}),
|
126 | ref: ref
|
127 | }, other));
|
128 | });
|
129 | process.env.NODE_ENV !== "production" ? Select.propTypes = {
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | |
136 |
|
137 |
|
138 |
|
139 | autoWidth: _propTypes.default.bool,
|
140 |
|
141 | |
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 | children: _propTypes.default.node,
|
148 |
|
149 | |
150 |
|
151 |
|
152 |
|
153 | classes: _propTypes.default.object,
|
154 |
|
155 | |
156 |
|
157 |
|
158 | defaultValue: _propTypes.default.any,
|
159 |
|
160 | |
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 | displayEmpty: _propTypes.default.bool,
|
167 |
|
168 | |
169 |
|
170 |
|
171 | IconComponent: _propTypes.default.elementType,
|
172 |
|
173 | |
174 |
|
175 |
|
176 | id: _propTypes.default.string,
|
177 |
|
178 | |
179 |
|
180 |
|
181 | input: _propTypes.default.element,
|
182 |
|
183 | |
184 |
|
185 |
|
186 |
|
187 | inputProps: _propTypes.default.object,
|
188 |
|
189 | |
190 |
|
191 |
|
192 | label: _propTypes.default.node,
|
193 |
|
194 | |
195 |
|
196 |
|
197 |
|
198 | labelId: _propTypes.default.string,
|
199 |
|
200 | |
201 |
|
202 |
|
203 | labelWidth: _propTypes.default.number,
|
204 |
|
205 | |
206 |
|
207 |
|
208 | MenuProps: _propTypes.default.object,
|
209 |
|
210 | |
211 |
|
212 |
|
213 | multiple: _propTypes.default.bool,
|
214 |
|
215 | |
216 |
|
217 |
|
218 | native: _propTypes.default.bool,
|
219 |
|
220 | |
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 | onChange: _propTypes.default.func,
|
228 |
|
229 | |
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 | onClose: _propTypes.default.func,
|
236 |
|
237 | |
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 | onOpen: _propTypes.default.func,
|
244 |
|
245 | |
246 |
|
247 |
|
248 |
|
249 | open: _propTypes.default.bool,
|
250 |
|
251 | |
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 | renderValue: _propTypes.default.func,
|
259 |
|
260 | |
261 |
|
262 |
|
263 | SelectDisplayProps: _propTypes.default.object,
|
264 |
|
265 | |
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 | value: _propTypes.default.any,
|
274 |
|
275 | |
276 |
|
277 |
|
278 | variant: _propTypes.default.oneOf(['filled', 'outlined', 'standard'])
|
279 | } : void 0;
|
280 | Select.muiName = 'Select';
|
281 |
|
282 | var _default = (0, _withStyles.default)(styles, {
|
283 | name: 'MuiSelect'
|
284 | })(Select);
|
285 |
|
286 | exports.default = _default; |
\ | No newline at end of file |