-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMuiTextField.ts
86 lines (83 loc) · 2.62 KB
/
MuiTextField.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import {
filledInputClasses,
formHelperTextClasses,
formLabelClasses,
inputBaseClasses,
inputClasses,
outlinedInputClasses,
svgIconClasses,
} from "@mui/material"
import { includesClassNames } from "../../utils/theme"
import palette from "../palette"
import typography from "../typography"
import type Components from "./_components"
const MuiTextField: Components["MuiTextField"] = {
defaultProps: {
size: "small",
variant: "filled",
},
styleOverrides: {
root: ({ ownerState }) => ({
width: "100%",
backgroundColor: "transparent",
[`& > .${inputBaseClasses.root}`]: {
...(ownerState.disabled
? {
border: "0px !important",
borderRadius: "0px !important",
// @ts-expect-error
backgroundColor: `${palette.info!.main} !important`,
[`.${inputBaseClasses.disabled}`]: {
color: `${typography.body1!.color} !important`,
"-webkit-text-fill-color": "unset",
},
}
: {
border: "1px solid black !important",
borderRadius: "0px !important",
backgroundColor: "white !important",
}),
},
[`& > .${inputBaseClasses.root}.${inputBaseClasses.error}`]: {
// @ts-expect-error
border: `1px solid ${palette.error!.main} !important`,
},
[`& .${outlinedInputClasses.root}.${inputClasses.focused} > fieldset`]: {
borderColor: "black !important",
},
[`.${svgIconClasses.root}`]: {
color: `${typography.body1!.color} !important`,
},
[`.${filledInputClasses.root}::after`]: {
borderColor: `${typography.body1!.color} !important`,
},
[`.${formLabelClasses.root}`]: {
color: `${typography.body1!.color} !important`,
},
[`.${formHelperTextClasses.root}`]: {
fontSize: "12px !important",
},
...(ownerState.multiline === true && {
...((includesClassNames(ownerState, ["resize"]) ||
includesClassNames(ownerState, ["resize-both"])) && {
width: "auto",
[`.${inputClasses.inputMultiline}`]: {
resize: "both",
},
}),
...(includesClassNames(ownerState, ["resize-horizontal"]) && {
width: "auto",
[`.${inputClasses.inputMultiline}`]: {
resize: "horizontal",
},
}),
...(includesClassNames(ownerState, ["resize-vertical"]) && {
[`.${inputClasses.inputMultiline}`]: {
resize: "vertical",
},
}),
}),
}),
},
}
export default MuiTextField