@@ -16,7 +16,99 @@ const allViews = ['hour', 'minute', 'second'];
1616const baseClassName = 'react-datetime-picker' ;
1717const outsideActionEvents = [ 'mousedown' , 'focusin' , 'touchstart' ] ;
1818
19+ const iconProps = {
20+ xmlns : 'http://www.w3.org/2000/svg' ,
21+ width : 19 ,
22+ height : 19 ,
23+ viewBox : '0 0 19 19' ,
24+ stroke : 'black' ,
25+ strokeWidth : 2 ,
26+ } ;
27+
28+ const CalendarIcon = (
29+ < svg
30+ { ...iconProps }
31+ className = { `${ baseClassName } __calendar-button__icon ${ baseClassName } __button__icon` }
32+ >
33+ < rect fill = "none" height = "15" width = "15" x = "2" y = "2" />
34+ < line x1 = "6" x2 = "6" y1 = "0" y2 = "4" />
35+ < line x1 = "13" x2 = "13" y1 = "0" y2 = "4" />
36+ </ svg >
37+ ) ;
38+
39+ const ClearIcon = (
40+ < svg
41+ { ...iconProps }
42+ className = { `${ baseClassName } __clear-button__icon ${ baseClassName } __button__icon` }
43+ >
44+ < line x1 = "4" x2 = "15" y1 = "4" y2 = "15" />
45+ < line x1 = "15" x2 = "4" y1 = "4" y2 = "15" />
46+ </ svg >
47+ ) ;
48+
49+ const isValue = PropTypes . oneOfType ( [ PropTypes . string , PropTypes . instanceOf ( Date ) ] ) ;
50+
1951export default class DateTimePicker extends PureComponent {
52+ static defaultProps = {
53+ calendarIcon : CalendarIcon ,
54+ clearIcon : ClearIcon ,
55+ closeWidgets : true ,
56+ isCalendarOpen : null ,
57+ isClockOpen : null ,
58+ maxDetail : 'minute' ,
59+ openWidgetsOnFocus : true ,
60+ } ;
61+
62+ static propTypes = {
63+ amPmAriaLabel : PropTypes . string ,
64+ autoFocus : PropTypes . bool ,
65+ calendarAriaLabel : PropTypes . string ,
66+ calendarClassName : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] ) ,
67+ calendarIcon : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
68+ className : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] ) ,
69+ clearAriaLabel : PropTypes . string ,
70+ clearIcon : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
71+ clockClassName : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] ) ,
72+ closeWidgets : PropTypes . bool ,
73+ 'data-testid' : PropTypes . string ,
74+ dayAriaLabel : PropTypes . string ,
75+ dayPlaceholder : PropTypes . string ,
76+ disableCalendar : PropTypes . bool ,
77+ disableClock : PropTypes . bool ,
78+ disabled : PropTypes . bool ,
79+ format : PropTypes . string ,
80+ hourAriaLabel : PropTypes . string ,
81+ hourPlaceholder : PropTypes . string ,
82+ id : PropTypes . string ,
83+ isCalendarOpen : PropTypes . bool ,
84+ isClockOpen : PropTypes . bool ,
85+ locale : PropTypes . string ,
86+ maxDate : isMaxDate ,
87+ maxDetail : PropTypes . oneOf ( allViews ) ,
88+ minDate : isMinDate ,
89+ minuteAriaLabel : PropTypes . string ,
90+ minutePlaceholder : PropTypes . string ,
91+ monthAriaLabel : PropTypes . string ,
92+ monthPlaceholder : PropTypes . string ,
93+ name : PropTypes . string ,
94+ nativeInputAriaLabel : PropTypes . string ,
95+ onCalendarClose : PropTypes . func ,
96+ onCalendarOpen : PropTypes . func ,
97+ onChange : PropTypes . func ,
98+ onClockClose : PropTypes . func ,
99+ onClockOpen : PropTypes . func ,
100+ onFocus : PropTypes . func ,
101+ openWidgetsOnFocus : PropTypes . bool ,
102+ portalContainer : PropTypes . object ,
103+ required : PropTypes . bool ,
104+ secondAriaLabel : PropTypes . string ,
105+ secondPlaceholder : PropTypes . string ,
106+ showLeadingZeros : PropTypes . bool ,
107+ value : PropTypes . oneOfType ( [ isValue , PropTypes . arrayOf ( isValue ) ] ) ,
108+ yearAriaLabel : PropTypes . string ,
109+ yearPlaceholder : PropTypes . string ,
110+ } ;
111+
20112 static getDerivedStateFromProps ( nextProps , prevState ) {
21113 const nextState = { } ;
22114
@@ -475,95 +567,3 @@ export default class DateTimePicker extends PureComponent {
475567 ) ;
476568 }
477569}
478-
479- const iconProps = {
480- xmlns : 'http://www.w3.org/2000/svg' ,
481- width : 19 ,
482- height : 19 ,
483- viewBox : '0 0 19 19' ,
484- stroke : 'black' ,
485- strokeWidth : 2 ,
486- } ;
487-
488- const CalendarIcon = (
489- < svg
490- { ...iconProps }
491- className = { `${ baseClassName } __calendar-button__icon ${ baseClassName } __button__icon` }
492- >
493- < rect fill = "none" height = "15" width = "15" x = "2" y = "2" />
494- < line x1 = "6" x2 = "6" y1 = "0" y2 = "4" />
495- < line x1 = "13" x2 = "13" y1 = "0" y2 = "4" />
496- </ svg >
497- ) ;
498-
499- const ClearIcon = (
500- < svg
501- { ...iconProps }
502- className = { `${ baseClassName } __clear-button__icon ${ baseClassName } __button__icon` }
503- >
504- < line x1 = "4" x2 = "15" y1 = "4" y2 = "15" />
505- < line x1 = "15" x2 = "4" y1 = "4" y2 = "15" />
506- </ svg >
507- ) ;
508-
509- DateTimePicker . defaultProps = {
510- calendarIcon : CalendarIcon ,
511- clearIcon : ClearIcon ,
512- closeWidgets : true ,
513- isCalendarOpen : null ,
514- isClockOpen : null ,
515- maxDetail : 'minute' ,
516- openWidgetsOnFocus : true ,
517- } ;
518-
519- const isValue = PropTypes . oneOfType ( [ PropTypes . string , PropTypes . instanceOf ( Date ) ] ) ;
520-
521- DateTimePicker . propTypes = {
522- amPmAriaLabel : PropTypes . string ,
523- autoFocus : PropTypes . bool ,
524- calendarAriaLabel : PropTypes . string ,
525- calendarClassName : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] ) ,
526- calendarIcon : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
527- className : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] ) ,
528- clearAriaLabel : PropTypes . string ,
529- clearIcon : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
530- clockClassName : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] ) ,
531- closeWidgets : PropTypes . bool ,
532- 'data-testid' : PropTypes . string ,
533- dayAriaLabel : PropTypes . string ,
534- dayPlaceholder : PropTypes . string ,
535- disableCalendar : PropTypes . bool ,
536- disableClock : PropTypes . bool ,
537- disabled : PropTypes . bool ,
538- format : PropTypes . string ,
539- hourAriaLabel : PropTypes . string ,
540- hourPlaceholder : PropTypes . string ,
541- id : PropTypes . string ,
542- isCalendarOpen : PropTypes . bool ,
543- isClockOpen : PropTypes . bool ,
544- locale : PropTypes . string ,
545- maxDate : isMaxDate ,
546- maxDetail : PropTypes . oneOf ( allViews ) ,
547- minDate : isMinDate ,
548- minuteAriaLabel : PropTypes . string ,
549- minutePlaceholder : PropTypes . string ,
550- monthAriaLabel : PropTypes . string ,
551- monthPlaceholder : PropTypes . string ,
552- name : PropTypes . string ,
553- nativeInputAriaLabel : PropTypes . string ,
554- onCalendarClose : PropTypes . func ,
555- onCalendarOpen : PropTypes . func ,
556- onChange : PropTypes . func ,
557- onClockClose : PropTypes . func ,
558- onClockOpen : PropTypes . func ,
559- onFocus : PropTypes . func ,
560- openWidgetsOnFocus : PropTypes . bool ,
561- portalContainer : PropTypes . object ,
562- required : PropTypes . bool ,
563- secondAriaLabel : PropTypes . string ,
564- secondPlaceholder : PropTypes . string ,
565- showLeadingZeros : PropTypes . bool ,
566- value : PropTypes . oneOfType ( [ isValue , PropTypes . arrayOf ( isValue ) ] ) ,
567- yearAriaLabel : PropTypes . string ,
568- yearPlaceholder : PropTypes . string ,
569- } ;
0 commit comments