UNPKG

2.63 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/esm/extends";
2import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import clsx from 'clsx';
6import { refType } from '@material-ui/utils';
7import capitalize from '../utils/capitalize';
8/**
9 * @ignore - internal component.
10 */
11
12const NativeSelectInput = /*#__PURE__*/React.forwardRef(function NativeSelectInput(props, ref) {
13 const {
14 classes,
15 className,
16 disabled,
17 IconComponent,
18 inputRef,
19 variant = 'standard'
20 } = props,
21 other = _objectWithoutPropertiesLoose(props, ["classes", "className", "disabled", "IconComponent", "inputRef", "variant"]);
22
23 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("select", _extends({
24 className: clsx(classes.root, // TODO v5: merge root and select
25 classes.select, classes[variant], className, disabled && classes.disabled),
26 disabled: disabled,
27 ref: inputRef || ref
28 }, other)), props.multiple ? null : /*#__PURE__*/React.createElement(IconComponent, {
29 className: clsx(classes.icon, classes[`icon${capitalize(variant)}`], disabled && classes.disabled)
30 }));
31});
32process.env.NODE_ENV !== "production" ? NativeSelectInput.propTypes = {
33 /**
34 * The option elements to populate the select with.
35 * Can be some `<option>` elements.
36 */
37 children: PropTypes.node,
38
39 /**
40 * Override or extend the styles applied to the component.
41 * See [CSS API](#css) below for more details.
42 */
43 classes: PropTypes.object.isRequired,
44
45 /**
46 * The CSS class name of the select element.
47 */
48 className: PropTypes.string,
49
50 /**
51 * If `true`, the select will be disabled.
52 */
53 disabled: PropTypes.bool,
54
55 /**
56 * The icon that displays the arrow.
57 */
58 IconComponent: PropTypes.elementType.isRequired,
59
60 /**
61 * Use that prop to pass a ref to the native select element.
62 * @deprecated
63 */
64 inputRef: refType,
65
66 /**
67 * @ignore
68 */
69 multiple: PropTypes.bool,
70
71 /**
72 * Name attribute of the `select` or hidden `input` element.
73 */
74 name: PropTypes.string,
75
76 /**
77 * Callback function fired when a menu item is selected.
78 *
79 * @param {object} event The event source of the callback.
80 * You can pull out the new value by accessing `event.target.value` (string).
81 */
82 onChange: PropTypes.func,
83
84 /**
85 * The input value.
86 */
87 value: PropTypes.any,
88
89 /**
90 * The variant to use.
91 */
92 variant: PropTypes.oneOf(['standard', 'outlined', 'filled'])
93} : void 0;
94export default NativeSelectInput;
\No newline at end of file