1 | 'use client';
|
2 |
|
3 | import * as React from 'react';
|
4 | import clsx from 'clsx';
|
5 | import PropTypes from 'prop-types';
|
6 | import composeClasses from '@mui/utils/composeClasses';
|
7 | import NativeSelectInput from "./NativeSelectInput.js";
|
8 | import formControlState from "../FormControl/formControlState.js";
|
9 | import useFormControl from "../FormControl/useFormControl.js";
|
10 | import ArrowDropDownIcon from "../internal/svg-icons/ArrowDropDown.js";
|
11 | import Input from "../Input/index.js";
|
12 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
13 | import { getNativeSelectUtilityClasses } from "./nativeSelectClasses.js";
|
14 | import { jsx as _jsx } from "react/jsx-runtime";
|
15 | const useUtilityClasses = ownerState => {
|
16 | const {
|
17 | classes
|
18 | } = ownerState;
|
19 | const slots = {
|
20 | root: ['root']
|
21 | };
|
22 | return composeClasses(slots, getNativeSelectUtilityClasses, classes);
|
23 | };
|
24 | const defaultInput = _jsx(Input, {});
|
25 |
|
26 |
|
27 |
|
28 | const NativeSelect = React.forwardRef(function NativeSelect(inProps, ref) {
|
29 | const props = useDefaultProps({
|
30 | name: 'MuiNativeSelect',
|
31 | props: inProps
|
32 | });
|
33 | const {
|
34 | className,
|
35 | children,
|
36 | classes: classesProp = {},
|
37 | IconComponent = ArrowDropDownIcon,
|
38 | input = defaultInput,
|
39 | inputProps,
|
40 | variant,
|
41 | ...other
|
42 | } = props;
|
43 | const muiFormControl = useFormControl();
|
44 | const fcs = formControlState({
|
45 | props,
|
46 | muiFormControl,
|
47 | states: ['variant']
|
48 | });
|
49 | const ownerState = {
|
50 | ...props,
|
51 | classes: classesProp
|
52 | };
|
53 | const classes = useUtilityClasses(ownerState);
|
54 | const {
|
55 | root,
|
56 | ...otherClasses
|
57 | } = classesProp;
|
58 | return _jsx(React.Fragment, {
|
59 | children: React.cloneElement(input, {
|
60 |
|
61 |
|
62 | inputComponent: NativeSelectInput,
|
63 | inputProps: {
|
64 | children,
|
65 | classes: otherClasses,
|
66 | IconComponent,
|
67 | variant: fcs.variant,
|
68 | type: undefined,
|
69 |
|
70 | ...inputProps,
|
71 | ...(input ? input.props.inputProps : {})
|
72 | },
|
73 | ref,
|
74 | ...other,
|
75 | className: clsx(classes.root, input.props.className, className)
|
76 | })
|
77 | });
|
78 | });
|
79 | process.env.NODE_ENV !== "production" ? NativeSelect.propTypes = {
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | |
85 |
|
86 |
|
87 |
|
88 | children: PropTypes.node,
|
89 | |
90 |
|
91 |
|
92 |
|
93 | classes: PropTypes.object,
|
94 | |
95 |
|
96 |
|
97 | className: PropTypes.string,
|
98 | |
99 |
|
100 |
|
101 |
|
102 | IconComponent: PropTypes.elementType,
|
103 | |
104 |
|
105 |
|
106 |
|
107 | input: PropTypes.element,
|
108 | |
109 |
|
110 |
|
111 | inputProps: PropTypes.object,
|
112 | |
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 | onChange: PropTypes.func,
|
119 | |
120 |
|
121 |
|
122 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
123 | |
124 |
|
125 |
|
126 | value: PropTypes.any,
|
127 | |
128 |
|
129 |
|
130 | variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
131 | } : void 0;
|
132 | NativeSelect.muiName = 'Select';
|
133 | export default NativeSelect; |
\ | No newline at end of file |