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