1 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
2 | import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3 | import _extends from "@babel/runtime/helpers/esm/extends";
|
4 |
|
5 | var _span;
|
6 |
|
7 | import * as React from 'react';
|
8 | import PropTypes from 'prop-types';
|
9 | import clsx from 'clsx';
|
10 | import { unstable_composeClasses as composeClasses } from '@mui/base';
|
11 | import capitalize from '../utils/capitalize';
|
12 | import Typography from '../Typography';
|
13 | import FormControlContext from '../FormControl/FormControlContext';
|
14 | import useFormControl from '../FormControl/useFormControl';
|
15 | import styled from '../styles/styled';
|
16 | import inputAdornmentClasses, { getInputAdornmentUtilityClass } from './inputAdornmentClasses';
|
17 | import useThemeProps from '../styles/useThemeProps';
|
18 | import { jsx as _jsx } from "react/jsx-runtime";
|
19 | import { jsxs as _jsxs } from "react/jsx-runtime";
|
20 |
|
21 | var overridesResolver = function overridesResolver(props, styles) {
|
22 | var ownerState = props.ownerState;
|
23 | return [styles.root, styles["position".concat(capitalize(ownerState.position))], ownerState.disablePointerEvents === true && styles.disablePointerEvents, styles[ownerState.variant]];
|
24 | };
|
25 |
|
26 | var useUtilityClasses = function useUtilityClasses(ownerState) {
|
27 | var classes = ownerState.classes,
|
28 | disablePointerEvents = ownerState.disablePointerEvents,
|
29 | hiddenLabel = ownerState.hiddenLabel,
|
30 | position = ownerState.position,
|
31 | size = ownerState.size,
|
32 | variant = ownerState.variant;
|
33 | var slots = {
|
34 | root: ['root', disablePointerEvents && 'disablePointerEvents', position && "position".concat(capitalize(position)), variant, hiddenLabel && 'hiddenLabel', size && "size".concat(capitalize(size))]
|
35 | };
|
36 | return composeClasses(slots, getInputAdornmentUtilityClass, classes);
|
37 | };
|
38 |
|
39 | var InputAdornmentRoot = styled('div', {
|
40 | name: 'MuiInputAdornment',
|
41 | slot: 'Root',
|
42 | overridesResolver: overridesResolver
|
43 | })(function (_ref) {
|
44 | var theme = _ref.theme,
|
45 | ownerState = _ref.ownerState;
|
46 | return _extends({
|
47 | display: 'flex',
|
48 | height: '0.01em',
|
49 |
|
50 | maxHeight: '2em',
|
51 | alignItems: 'center',
|
52 | whiteSpace: 'nowrap',
|
53 | color: (theme.vars || theme).palette.action.active
|
54 | }, ownerState.variant === 'filled' && _defineProperty({}, "&.".concat(inputAdornmentClasses.positionStart, "&:not(.").concat(inputAdornmentClasses.hiddenLabel, ")"), {
|
55 | marginTop: 16
|
56 | }), ownerState.position === 'start' && {
|
57 |
|
58 | marginRight: 8
|
59 | }, ownerState.position === 'end' && {
|
60 |
|
61 | marginLeft: 8
|
62 | }, ownerState.disablePointerEvents === true && {
|
63 |
|
64 | pointerEvents: 'none'
|
65 | });
|
66 | });
|
67 | var InputAdornment = React.forwardRef(function InputAdornment(inProps, ref) {
|
68 | var props = useThemeProps({
|
69 | props: inProps,
|
70 | name: 'MuiInputAdornment'
|
71 | });
|
72 |
|
73 | var children = props.children,
|
74 | className = props.className,
|
75 | _props$component = props.component,
|
76 | component = _props$component === void 0 ? 'div' : _props$component,
|
77 | _props$disablePointer = props.disablePointerEvents,
|
78 | disablePointerEvents = _props$disablePointer === void 0 ? false : _props$disablePointer,
|
79 | _props$disableTypogra = props.disableTypography,
|
80 | disableTypography = _props$disableTypogra === void 0 ? false : _props$disableTypogra,
|
81 | position = props.position,
|
82 | variantProp = props.variant,
|
83 | other = _objectWithoutProperties(props, ["children", "className", "component", "disablePointerEvents", "disableTypography", "position", "variant"]);
|
84 |
|
85 | var muiFormControl = useFormControl() || {};
|
86 | var variant = variantProp;
|
87 |
|
88 | if (variantProp && muiFormControl.variant) {
|
89 | if (process.env.NODE_ENV !== 'production') {
|
90 | if (variantProp === muiFormControl.variant) {
|
91 | console.error('MUI: The `InputAdornment` variant infers the variant prop ' + 'you do not have to provide one.');
|
92 | }
|
93 | }
|
94 | }
|
95 |
|
96 | if (muiFormControl && !variant) {
|
97 | variant = muiFormControl.variant;
|
98 | }
|
99 |
|
100 | var ownerState = _extends({}, props, {
|
101 | hiddenLabel: muiFormControl.hiddenLabel,
|
102 | size: muiFormControl.size,
|
103 | disablePointerEvents: disablePointerEvents,
|
104 | position: position,
|
105 | variant: variant
|
106 | });
|
107 |
|
108 | var classes = useUtilityClasses(ownerState);
|
109 | return _jsx(FormControlContext.Provider, {
|
110 | value: null,
|
111 | children: _jsx(InputAdornmentRoot, _extends({
|
112 | as: component,
|
113 | ownerState: ownerState,
|
114 | className: clsx(classes.root, className),
|
115 | ref: ref
|
116 | }, other, {
|
117 | children: typeof children === 'string' && !disableTypography ? _jsx(Typography, {
|
118 | color: "text.secondary",
|
119 | children: children
|
120 | }) : _jsxs(React.Fragment, {
|
121 | children: [position === 'start' ?
|
122 |
|
123 | _span || (_span = _jsx("span", {
|
124 | className: "notranslate",
|
125 | children: "\u200B"
|
126 | })) : null, children]
|
127 | })
|
128 | }))
|
129 | });
|
130 | });
|
131 | process.env.NODE_ENV !== "production" ? InputAdornment.propTypes
|
132 |
|
133 | = {
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | |
140 |
|
141 |
|
142 | children: PropTypes.node,
|
143 |
|
144 | |
145 |
|
146 |
|
147 | classes: PropTypes.object,
|
148 |
|
149 | |
150 |
|
151 |
|
152 | className: PropTypes.string,
|
153 |
|
154 | |
155 |
|
156 |
|
157 |
|
158 | component: PropTypes.elementType,
|
159 |
|
160 | |
161 |
|
162 |
|
163 |
|
164 |
|
165 | disablePointerEvents: PropTypes.bool,
|
166 |
|
167 | |
168 |
|
169 |
|
170 |
|
171 | disableTypography: PropTypes.bool,
|
172 |
|
173 | |
174 |
|
175 |
|
176 | position: PropTypes.oneOf(['end', 'start']).isRequired,
|
177 |
|
178 | |
179 |
|
180 |
|
181 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
182 |
|
183 | |
184 |
|
185 |
|
186 |
|
187 |
|
188 | variant: PropTypes.oneOf(['filled', 'outlined', 'standard'])
|
189 | } : void 0;
|
190 | export default InputAdornment; |
\ | No newline at end of file |