@@ -20,35 +20,13 @@ import React, {
20
20
useImperativeHandle ,
21
21
useState ,
22
22
} from "react" ;
23
- import clsx from "clsx" ;
24
- import { Box , Grid , HelpIcon , InputLabel , Select , Switch , Tooltip } from "mds" ;
25
- import { Theme } from "@mui/material/styles" ;
26
- import createStyles from "@mui/styles/createStyles" ;
27
- import withStyles from "@mui/styles/withStyles" ;
28
- import { fieldBasic , tooltipHelper } from "../common/styleLibrary" ;
23
+ import { Box , HelpIcon , InputLabel , Select , Tooltip } from "mds" ;
29
24
import { days , months , validDate , years } from "./utils" ;
30
25
31
- const styles = ( theme : Theme ) =>
32
- createStyles ( {
33
- ...fieldBasic ,
34
- ...tooltipHelper ,
35
- fieldContainer : {
36
- ...fieldBasic . fieldContainer ,
37
- display : "flex" ,
38
- alignItems : "center" ,
39
- justifyContent : "space-between" ,
40
- paddingBottom : 10 ,
41
- marginTop : 11 ,
42
- marginBottom : 6 ,
43
- } ,
44
- } ) ;
45
-
46
26
interface IDateSelectorProps {
47
- classes : any ;
48
27
id : string ;
49
28
label : string ;
50
29
disableOptions ?: boolean ;
51
- addSwitch ?: boolean ;
52
30
tooltip ?: string ;
53
31
borderBottom ?: boolean ;
54
32
value ?: string ;
@@ -58,11 +36,9 @@ interface IDateSelectorProps {
58
36
const DateSelector = forwardRef (
59
37
(
60
38
{
61
- classes,
62
39
id,
63
40
label,
64
41
disableOptions = false ,
65
- addSwitch = false ,
66
42
tooltip = "" ,
67
43
borderBottom = false ,
68
44
onDateChange,
@@ -72,7 +48,6 @@ const DateSelector = forwardRef(
72
48
) => {
73
49
useImperativeHandle ( ref , ( ) => ( { resetDate } ) ) ;
74
50
75
- const [ dateEnabled , setDateEnabled ] = useState < boolean > ( false ) ;
76
51
const [ month , setMonth ] = useState < string > ( "" ) ;
77
52
const [ day , setDay ] = useState < string > ( "" ) ;
78
53
const [ year , setYear ] = useState < string > ( "" ) ;
@@ -104,8 +79,6 @@ const DateSelector = forwardRef(
104
79
const isDateDisabled = ( ) => {
105
80
if ( disableOptions ) {
106
81
return disableOptions ;
107
- } else if ( addSwitch ) {
108
- return ! dateEnabled ;
109
82
} else {
110
83
return false ;
111
84
}
@@ -116,45 +89,43 @@ const DateSelector = forwardRef(
116
89
const yearsForDrop = [ { value : "" , label : "<Year>" } , ...years ] ;
117
90
118
91
return (
119
- < Grid
120
- item
121
- xs = { 12 }
122
- className = { clsx ( classes . fieldContainer , {
123
- [ classes . fieldContainerBorder ] : borderBottom ,
124
- } ) }
125
- >
126
- < div className = { classes . labelContainer } >
127
- < Grid container >
128
- < InputLabel htmlFor = { id } >
129
- < span > { label } </ span >
130
- { tooltip !== "" && (
131
- < div className = { classes . tooltipContainer } >
132
- < Tooltip tooltip = { tooltip } placement = "top" >
133
- < div className = { classes . tooltip } >
134
- < HelpIcon />
135
- </ div >
136
- </ Tooltip >
137
- </ div >
138
- ) }
139
- </ InputLabel >
140
- { addSwitch && (
141
- < Switch
142
- indicatorLabels = { [ "Specific Date" , "Default (7 Days)" ] }
143
- checked = { dateEnabled }
144
- value = { "date_enabled" }
145
- id = "date-status"
146
- name = "date-status"
147
- onChange = { ( e ) => {
148
- setDateEnabled ( e . target . checked ) ;
149
- if ( ! e . target . checked ) {
150
- onDateChange ( "" , true ) ;
151
- }
92
+ < Box className = { "inputItem" } >
93
+ < Box
94
+ sx = { {
95
+ display : "flex" ,
96
+ alignItems : "center" ,
97
+ gap : 5 ,
98
+ marginBottom : 5 ,
99
+ } }
100
+ >
101
+ < InputLabel htmlFor = { id } >
102
+ < span > { label } </ span >
103
+ { tooltip !== "" && (
104
+ < Box
105
+ sx = { {
106
+ marginLeft : 5 ,
107
+ display : "flex" ,
108
+ alignItems : "center" ,
109
+ "& .min-icon" : {
110
+ width : 13 ,
111
+ } ,
152
112
} }
153
- switchOnly
154
- />
113
+ >
114
+ < Tooltip tooltip = { tooltip } placement = "top" >
115
+ < Box
116
+ sx = { {
117
+ "& .min-icon" : {
118
+ width : 13 ,
119
+ } ,
120
+ } }
121
+ >
122
+ < HelpIcon />
123
+ </ Box >
124
+ </ Tooltip >
125
+ </ Box >
155
126
) }
156
- </ Grid >
157
- </ div >
127
+ </ InputLabel >
128
+ </ Box >
158
129
< Box sx = { { display : "flex" , gap : 12 } } >
159
130
< Select
160
131
id = { `${ id } -month` }
@@ -190,11 +161,14 @@ const DateSelector = forwardRef(
190
161
options = { yearsForDrop }
191
162
label = { "" }
192
163
disabled = { isDateDisabled ( ) }
164
+ sx = { {
165
+ marginBottom : 12 ,
166
+ } }
193
167
/>
194
168
</ Box >
195
- </ Grid >
169
+ </ Box >
196
170
) ;
197
171
} ,
198
172
) ;
199
173
200
- export default withStyles ( styles ) ( DateSelector ) ;
174
+ export default DateSelector ;
0 commit comments