File tree Expand file tree Collapse file tree 3 files changed +48
-14
lines changed
packages/pluggableWidgets/date-time-picker-web/src Expand file tree Collapse file tree 3 files changed +48
-14
lines changed Original file line number Diff line number Diff line change 11import { ReactElement } from "react" ;
22import { DateTimePickerPreviewProps } from "../typings/DateTimePickerProps" ;
3- import { DatePicker } from "./components/DatePicker" ;
43import "./ui/DateTimePicker.scss" ;
54
65export function preview ( props : DateTimePickerPreviewProps ) : ReactElement {
7- console . info ( "Rendering DateTimePicker preview with props:" , props ) ;
8- return < DatePicker label = { props . label } /> ;
6+ const label = props . showLabel ? props . label : null ;
7+ const portalId = `datepicker_` + Math . random ( ) ;
8+
9+ return (
10+ < div className = "widget-datetimepicker" >
11+ { label ? (
12+ < div className = "widget-datetimepicker-label-wrapper" >
13+ < div id = { portalId } />
14+
15+ < label className = "widget-datetimepicker-label" id = "datepicker-label" >
16+ { label }
17+ </ label >
18+ </ div >
19+ ) : (
20+ < span className = "sr-only" id = "datepicker-label" >
21+ Date picker
22+ </ span >
23+ ) }
24+
25+ < div className = "widget-datetimepicker-wrapper" >
26+ < div className = "react-datepicker-wrapper" >
27+ < div className = "react-datepicker__input-container" >
28+ < input
29+ className = "widget-datetimepicker-input react-datepicker-ignore-onclickoutside"
30+ placeholder = { props . placeholder ?? "" }
31+ readOnly
32+ type = "text"
33+ value = { props . dateAttribute ? `[${ props . dateAttribute } ]` : "[Date time picker]" }
34+ />
35+ </ div >
36+ </ div >
37+
38+ < button aria-label = "Show calendar" className = "widget-datetimepicker-input-button" type = "button" >
39+ < span className = "mx-icon-filled mx-icon-calendar" />
40+ </ button >
41+ </ div >
42+ </ div >
43+ ) ;
944}
Original file line number Diff line number Diff line change @@ -35,19 +35,19 @@ export function DateTimePickerContainer(props: DateTimePickerContainerProps) {
3535 data-focusindex = { props . tabIndex }
3636 style = { props . style }
3737 >
38- < div className = "widget-datetimepicker-label-wrapper" >
39- < div id = { portalId } />
38+ { label ? (
39+ < div className = "widget-datetimepicker-label-wrapper" >
40+ < div id = { portalId } />
4041
41- { label ? (
4242 < label className = "widget-datetimepicker-label" id = { pickerProps . ariaLabelledBy } >
4343 { label }
4444 </ label >
45- ) : (
46- < span className = "sr-only" id = { pickerProps . ariaLabelledBy } >
47- Date picker
48- </ span >
49- ) }
50- </ div >
45+ </ div >
46+ ) : (
47+ < span className = "sr-only" id = { pickerProps . ariaLabelledBy } >
48+ Date picker
49+ </ span >
50+ ) }
5151
5252 < div className = "widget-datetimepicker-wrapper" >
5353 < ReactDatePicker { ...pickerProps } ref = { controller . pickerRef } />
Original file line number Diff line number Diff line change 2222 & -wrapper {
2323 align-items : center ;
2424 display : flex ;
25- flex : 0 0 75% ;
26- max-width : 75% ;
25+ flex : 1 ;
2726 padding : 0 16px ;
2827 }
2928
You can’t perform that action at this time.
0 commit comments