@@ -20,35 +20,13 @@ import React, {
2020 useImperativeHandle ,
2121 useState ,
2222} 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" ;
2924import { days , months , validDate , years } from "./utils" ;
3025
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-
4626interface IDateSelectorProps {
47- classes : any ;
4827 id : string ;
4928 label : string ;
5029 disableOptions ?: boolean ;
51- addSwitch ?: boolean ;
5230 tooltip ?: string ;
5331 borderBottom ?: boolean ;
5432 value ?: string ;
@@ -58,11 +36,9 @@ interface IDateSelectorProps {
5836const DateSelector = forwardRef (
5937 (
6038 {
61- classes,
6239 id,
6340 label,
6441 disableOptions = false ,
65- addSwitch = false ,
6642 tooltip = "" ,
6743 borderBottom = false ,
6844 onDateChange,
@@ -72,7 +48,6 @@ const DateSelector = forwardRef(
7248 ) => {
7349 useImperativeHandle ( ref , ( ) => ( { resetDate } ) ) ;
7450
75- const [ dateEnabled , setDateEnabled ] = useState < boolean > ( false ) ;
7651 const [ month , setMonth ] = useState < string > ( "" ) ;
7752 const [ day , setDay ] = useState < string > ( "" ) ;
7853 const [ year , setYear ] = useState < string > ( "" ) ;
@@ -104,8 +79,6 @@ const DateSelector = forwardRef(
10479 const isDateDisabled = ( ) => {
10580 if ( disableOptions ) {
10681 return disableOptions ;
107- } else if ( addSwitch ) {
108- return ! dateEnabled ;
10982 } else {
11083 return false ;
11184 }
@@ -116,45 +89,43 @@ const DateSelector = forwardRef(
11689 const yearsForDrop = [ { value : "" , label : "<Year>" } , ...years ] ;
11790
11891 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+ } ,
152112 } }
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 >
155126 ) }
156- </ Grid >
157- </ div >
127+ </ InputLabel >
128+ </ Box >
158129 < Box sx = { { display : "flex" , gap : 12 } } >
159130 < Select
160131 id = { `${ id } -month` }
@@ -190,11 +161,14 @@ const DateSelector = forwardRef(
190161 options = { yearsForDrop }
191162 label = { "" }
192163 disabled = { isDateDisabled ( ) }
164+ sx = { {
165+ marginBottom : 12 ,
166+ } }
193167 />
194168 </ Box >
195- </ Grid >
169+ </ Box >
196170 ) ;
197171 } ,
198172) ;
199173
200- export default withStyles ( styles ) ( DateSelector ) ;
174+ export default DateSelector ;
0 commit comments