1 | 'use client';
|
2 |
|
3 | import * as React from 'react';
|
4 | import PropTypes from 'prop-types';
|
5 | import refType from '@mui/utils/refType';
|
6 | import composeClasses from '@mui/utils/composeClasses';
|
7 | import NotchedOutline from "./NotchedOutline.js";
|
8 | import useFormControl from "../FormControl/useFormControl.js";
|
9 | import formControlState from "../FormControl/formControlState.js";
|
10 | import rootShouldForwardProp from "../styles/rootShouldForwardProp.js";
|
11 | import { styled } from "../zero-styled/index.js";
|
12 | import memoTheme from "../utils/memoTheme.js";
|
13 | import createSimplePaletteValueFilter from "../utils/createSimplePaletteValueFilter.js";
|
14 | import { useDefaultProps } from "../DefaultPropsProvider/index.js";
|
15 | import outlinedInputClasses, { getOutlinedInputUtilityClass } from "./outlinedInputClasses.js";
|
16 | import InputBase, { rootOverridesResolver as inputBaseRootOverridesResolver, inputOverridesResolver as inputBaseInputOverridesResolver, InputBaseRoot, InputBaseInput } from "../InputBase/InputBase.js";
|
17 | import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
18 | const useUtilityClasses = ownerState => {
|
19 | const {
|
20 | classes
|
21 | } = ownerState;
|
22 | const slots = {
|
23 | root: ['root'],
|
24 | notchedOutline: ['notchedOutline'],
|
25 | input: ['input']
|
26 | };
|
27 | const composedClasses = composeClasses(slots, getOutlinedInputUtilityClass, classes);
|
28 | return {
|
29 | ...classes,
|
30 |
|
31 | ...composedClasses
|
32 | };
|
33 | };
|
34 | const OutlinedInputRoot = styled(InputBaseRoot, {
|
35 | shouldForwardProp: prop => rootShouldForwardProp(prop) || prop === 'classes',
|
36 | name: 'MuiOutlinedInput',
|
37 | slot: 'Root',
|
38 | overridesResolver: inputBaseRootOverridesResolver
|
39 | })(memoTheme(({
|
40 | theme
|
41 | }) => {
|
42 | const borderColor = theme.palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)';
|
43 | return {
|
44 | position: 'relative',
|
45 | borderRadius: (theme.vars || theme).shape.borderRadius,
|
46 | [`&:hover .${outlinedInputClasses.notchedOutline}`]: {
|
47 | borderColor: (theme.vars || theme).palette.text.primary
|
48 | },
|
49 |
|
50 | '@media (hover: none)': {
|
51 | [`&:hover .${outlinedInputClasses.notchedOutline}`]: {
|
52 | borderColor: theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / 0.23)` : borderColor
|
53 | }
|
54 | },
|
55 | [`&.${outlinedInputClasses.focused} .${outlinedInputClasses.notchedOutline}`]: {
|
56 | borderWidth: 2
|
57 | },
|
58 | variants: [...Object.entries(theme.palette).filter(createSimplePaletteValueFilter()).map(([color]) => ({
|
59 | props: {
|
60 | color
|
61 | },
|
62 | style: {
|
63 | [`&.${outlinedInputClasses.focused} .${outlinedInputClasses.notchedOutline}`]: {
|
64 | borderColor: (theme.vars || theme).palette[color].main
|
65 | }
|
66 | }
|
67 | })), {
|
68 | props: {},
|
69 |
|
70 | style: {
|
71 | [`&.${outlinedInputClasses.error} .${outlinedInputClasses.notchedOutline}`]: {
|
72 | borderColor: (theme.vars || theme).palette.error.main
|
73 | },
|
74 | [`&.${outlinedInputClasses.disabled} .${outlinedInputClasses.notchedOutline}`]: {
|
75 | borderColor: (theme.vars || theme).palette.action.disabled
|
76 | }
|
77 | }
|
78 | }, {
|
79 | props: ({
|
80 | ownerState
|
81 | }) => ownerState.startAdornment,
|
82 | style: {
|
83 | paddingLeft: 14
|
84 | }
|
85 | }, {
|
86 | props: ({
|
87 | ownerState
|
88 | }) => ownerState.endAdornment,
|
89 | style: {
|
90 | paddingRight: 14
|
91 | }
|
92 | }, {
|
93 | props: ({
|
94 | ownerState
|
95 | }) => ownerState.multiline,
|
96 | style: {
|
97 | padding: '16.5px 14px'
|
98 | }
|
99 | }, {
|
100 | props: ({
|
101 | ownerState,
|
102 | size
|
103 | }) => ownerState.multiline && size === 'small',
|
104 | style: {
|
105 | padding: '8.5px 14px'
|
106 | }
|
107 | }]
|
108 | };
|
109 | }));
|
110 | const NotchedOutlineRoot = styled(NotchedOutline, {
|
111 | name: 'MuiOutlinedInput',
|
112 | slot: 'NotchedOutline',
|
113 | overridesResolver: (props, styles) => styles.notchedOutline
|
114 | })(memoTheme(({
|
115 | theme
|
116 | }) => {
|
117 | const borderColor = theme.palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)';
|
118 | return {
|
119 | borderColor: theme.vars ? `rgba(${theme.vars.palette.common.onBackgroundChannel} / 0.23)` : borderColor
|
120 | };
|
121 | }));
|
122 | const OutlinedInputInput = styled(InputBaseInput, {
|
123 | name: 'MuiOutlinedInput',
|
124 | slot: 'Input',
|
125 | overridesResolver: inputBaseInputOverridesResolver
|
126 | })(memoTheme(({
|
127 | theme
|
128 | }) => ({
|
129 | padding: '16.5px 14px',
|
130 | ...(!theme.vars && {
|
131 | '&:-webkit-autofill': {
|
132 | WebkitBoxShadow: theme.palette.mode === 'light' ? null : '0 0 0 100px #266798 inset',
|
133 | WebkitTextFillColor: theme.palette.mode === 'light' ? null : '#fff',
|
134 | caretColor: theme.palette.mode === 'light' ? null : '#fff',
|
135 | borderRadius: 'inherit'
|
136 | }
|
137 | }),
|
138 | ...(theme.vars && {
|
139 | '&:-webkit-autofill': {
|
140 | borderRadius: 'inherit'
|
141 | },
|
142 | [theme.getColorSchemeSelector('dark')]: {
|
143 | '&:-webkit-autofill': {
|
144 | WebkitBoxShadow: '0 0 0 100px #266798 inset',
|
145 | WebkitTextFillColor: '#fff',
|
146 | caretColor: '#fff'
|
147 | }
|
148 | }
|
149 | }),
|
150 | variants: [{
|
151 | props: {
|
152 | size: 'small'
|
153 | },
|
154 | style: {
|
155 | padding: '8.5px 14px'
|
156 | }
|
157 | }, {
|
158 | props: ({
|
159 | ownerState
|
160 | }) => ownerState.multiline,
|
161 | style: {
|
162 | padding: 0
|
163 | }
|
164 | }, {
|
165 | props: ({
|
166 | ownerState
|
167 | }) => ownerState.startAdornment,
|
168 | style: {
|
169 | paddingLeft: 0
|
170 | }
|
171 | }, {
|
172 | props: ({
|
173 | ownerState
|
174 | }) => ownerState.endAdornment,
|
175 | style: {
|
176 | paddingRight: 0
|
177 | }
|
178 | }]
|
179 | })));
|
180 | const OutlinedInput = React.forwardRef(function OutlinedInput(inProps, ref) {
|
181 | var _React$Fragment;
|
182 | const props = useDefaultProps({
|
183 | props: inProps,
|
184 | name: 'MuiOutlinedInput'
|
185 | });
|
186 | const {
|
187 | components = {},
|
188 | fullWidth = false,
|
189 | inputComponent = 'input',
|
190 | label,
|
191 | multiline = false,
|
192 | notched,
|
193 | slots = {},
|
194 | type = 'text',
|
195 | ...other
|
196 | } = props;
|
197 | const classes = useUtilityClasses(props);
|
198 | const muiFormControl = useFormControl();
|
199 | const fcs = formControlState({
|
200 | props,
|
201 | muiFormControl,
|
202 | states: ['color', 'disabled', 'error', 'focused', 'hiddenLabel', 'size', 'required']
|
203 | });
|
204 | const ownerState = {
|
205 | ...props,
|
206 | color: fcs.color || 'primary',
|
207 | disabled: fcs.disabled,
|
208 | error: fcs.error,
|
209 | focused: fcs.focused,
|
210 | formControl: muiFormControl,
|
211 | fullWidth,
|
212 | hiddenLabel: fcs.hiddenLabel,
|
213 | multiline,
|
214 | size: fcs.size,
|
215 | type
|
216 | };
|
217 | const RootSlot = slots.root ?? components.Root ?? OutlinedInputRoot;
|
218 | const InputSlot = slots.input ?? components.Input ?? OutlinedInputInput;
|
219 | return _jsx(InputBase, {
|
220 | slots: {
|
221 | root: RootSlot,
|
222 | input: InputSlot
|
223 | },
|
224 | renderSuffix: state => _jsx(NotchedOutlineRoot, {
|
225 | ownerState: ownerState,
|
226 | className: classes.notchedOutline,
|
227 | label: label != null && label !== '' && fcs.required ? _React$Fragment || (_React$Fragment = _jsxs(React.Fragment, {
|
228 | children: [label, "\u2009", '*']
|
229 | })) : label,
|
230 | notched: typeof notched !== 'undefined' ? notched : Boolean(state.startAdornment || state.filled || state.focused)
|
231 | }),
|
232 | fullWidth: fullWidth,
|
233 | inputComponent: inputComponent,
|
234 | multiline: multiline,
|
235 | ref: ref,
|
236 | type: type,
|
237 | ...other,
|
238 | classes: {
|
239 | ...classes,
|
240 | notchedOutline: null
|
241 | }
|
242 | });
|
243 | });
|
244 | process.env.NODE_ENV !== "production" ? OutlinedInput.propTypes = {
|
245 |
|
246 |
|
247 |
|
248 |
|
249 | |
250 |
|
251 |
|
252 |
|
253 |
|
254 | autoComplete: PropTypes.string,
|
255 | |
256 |
|
257 |
|
258 | autoFocus: PropTypes.bool,
|
259 | |
260 |
|
261 |
|
262 | classes: PropTypes.object,
|
263 | |
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 | color: PropTypes .oneOfType([PropTypes.oneOf(['primary', 'secondary']), PropTypes.string]),
|
270 | |
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 | components: PropTypes.shape({
|
278 | Input: PropTypes.elementType,
|
279 | Root: PropTypes.elementType
|
280 | }),
|
281 | |
282 |
|
283 |
|
284 | defaultValue: PropTypes.any,
|
285 | |
286 |
|
287 |
|
288 |
|
289 | disabled: PropTypes.bool,
|
290 | |
291 |
|
292 |
|
293 | endAdornment: PropTypes.node,
|
294 | |
295 |
|
296 |
|
297 |
|
298 | error: PropTypes.bool,
|
299 | |
300 |
|
301 |
|
302 |
|
303 | fullWidth: PropTypes.bool,
|
304 | |
305 |
|
306 |
|
307 | id: PropTypes.string,
|
308 | |
309 |
|
310 |
|
311 |
|
312 |
|
313 | inputComponent: PropTypes.elementType,
|
314 | |
315 |
|
316 |
|
317 |
|
318 | inputProps: PropTypes.object,
|
319 | |
320 |
|
321 |
|
322 | inputRef: refType,
|
323 | |
324 |
|
325 |
|
326 |
|
327 | label: PropTypes.node,
|
328 | |
329 |
|
330 |
|
331 |
|
332 |
|
333 | margin: PropTypes.oneOf(['dense', 'none']),
|
334 | |
335 |
|
336 |
|
337 | maxRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
338 | |
339 |
|
340 |
|
341 | minRows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
342 | |
343 |
|
344 |
|
345 |
|
346 | multiline: PropTypes.bool,
|
347 | |
348 |
|
349 |
|
350 | name: PropTypes.string,
|
351 | |
352 |
|
353 |
|
354 | notched: PropTypes.bool,
|
355 | |
356 |
|
357 |
|
358 |
|
359 |
|
360 |
|
361 | onChange: PropTypes.func,
|
362 | |
363 |
|
364 |
|
365 | placeholder: PropTypes.string,
|
366 | |
367 |
|
368 |
|
369 |
|
370 | readOnly: PropTypes.bool,
|
371 | |
372 |
|
373 |
|
374 |
|
375 | required: PropTypes.bool,
|
376 | |
377 |
|
378 |
|
379 | rows: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
380 | |
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 | slots: PropTypes.shape({
|
388 | input: PropTypes.elementType,
|
389 | root: PropTypes.elementType
|
390 | }),
|
391 | |
392 |
|
393 |
|
394 | startAdornment: PropTypes.node,
|
395 | |
396 |
|
397 |
|
398 | sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
399 | |
400 |
|
401 |
|
402 |
|
403 | type: PropTypes.string,
|
404 | |
405 |
|
406 |
|
407 | value: PropTypes.any
|
408 | } : void 0;
|
409 | if (OutlinedInput) {
|
410 | OutlinedInput.muiName = 'Input';
|
411 | }
|
412 | export default OutlinedInput; |
\ | No newline at end of file |