@@ -14,7 +14,87 @@ const baseClassName = 'react-date-picker';
1414const outsideActionEvents = [ 'mousedown' , 'focusin' , 'touchstart' ] ;
1515const allViews = [ 'century' , 'decade' , 'year' , 'month' ] ;
1616
17+ const iconProps = {
18+ xmlns : 'http://www.w3.org/2000/svg' ,
19+ width : 19 ,
20+ height : 19 ,
21+ viewBox : '0 0 19 19' ,
22+ stroke : 'black' ,
23+ strokeWidth : 2 ,
24+ } ;
25+
26+ const CalendarIcon = (
27+ < svg
28+ { ...iconProps }
29+ className = { `${ baseClassName } __calendar-button__icon ${ baseClassName } __button__icon` }
30+ >
31+ < rect fill = "none" height = "15" width = "15" x = "2" y = "2" />
32+ < line x1 = "6" x2 = "6" y1 = "0" y2 = "4" />
33+ < line x1 = "13" x2 = "13" y1 = "0" y2 = "4" />
34+ </ svg >
35+ ) ;
36+
37+ const ClearIcon = (
38+ < svg
39+ { ...iconProps }
40+ className = { `${ baseClassName } __clear-button__icon ${ baseClassName } __button__icon` }
41+ >
42+ < line x1 = "4" x2 = "15" y1 = "4" y2 = "15" />
43+ < line x1 = "15" x2 = "4" y1 = "4" y2 = "15" />
44+ </ svg >
45+ ) ;
46+
47+ const isValue = PropTypes . oneOfType ( [ PropTypes . string , PropTypes . instanceOf ( Date ) ] ) ;
48+
1749export default class DatePicker extends PureComponent {
50+ static defaultProps = {
51+ calendarIcon : CalendarIcon ,
52+ clearIcon : ClearIcon ,
53+ closeCalendar : true ,
54+ isOpen : null ,
55+ openCalendarOnFocus : true ,
56+ returnValue : 'start' ,
57+ } ;
58+
59+ static propTypes = {
60+ autoFocus : PropTypes . bool ,
61+ calendarAriaLabel : PropTypes . string ,
62+ calendarClassName : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] ) ,
63+ calendarIcon : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
64+ className : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] ) ,
65+ clearAriaLabel : PropTypes . string ,
66+ clearIcon : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
67+ closeCalendar : PropTypes . bool ,
68+ 'data-testid' : PropTypes . string ,
69+ dayAriaLabel : PropTypes . string ,
70+ dayPlaceholder : PropTypes . string ,
71+ disableCalendar : PropTypes . bool ,
72+ disabled : PropTypes . bool ,
73+ format : PropTypes . string ,
74+ id : PropTypes . string ,
75+ isOpen : PropTypes . bool ,
76+ locale : PropTypes . string ,
77+ maxDate : isMaxDate ,
78+ maxDetail : PropTypes . oneOf ( allViews ) ,
79+ minDate : isMinDate ,
80+ monthAriaLabel : PropTypes . string ,
81+ monthPlaceholder : PropTypes . string ,
82+ name : PropTypes . string ,
83+ nativeInputAriaLabel : PropTypes . string ,
84+ onCalendarClose : PropTypes . func ,
85+ onCalendarOpen : PropTypes . func ,
86+ onChange : PropTypes . func ,
87+ onFocus : PropTypes . func ,
88+ openCalendarOnFocus : PropTypes . bool ,
89+ portalContainer : PropTypes . object ,
90+ required : PropTypes . bool ,
91+ returnValue : PropTypes . oneOf ( [ 'start' , 'end' , 'range' ] ) ,
92+ showLeadingZeros : PropTypes . bool ,
93+ value : PropTypes . oneOfType ( [ isValue , PropTypes . arrayOf ( isValue ) ] ) ,
94+ yearAriaLabel : PropTypes . string ,
95+ yearPlaceholder : PropTypes . string ,
96+ } ;
97+
1898 static getDerivedStateFromProps ( nextProps , prevState ) {
1999 if ( nextProps . isOpen !== prevState . isOpenProps ) {
20100 return {
@@ -314,83 +394,3 @@ export default class DatePicker extends PureComponent {
314394 ) ;
315395 }
316396}
317-
318- const iconProps = {
319- xmlns : 'http://www.w3.org/2000/svg' ,
320- width : 19 ,
321- height : 19 ,
322- viewBox : '0 0 19 19' ,
323- stroke : 'black' ,
324- strokeWidth : 2 ,
325- } ;
326-
327- const CalendarIcon = (
328- < svg
329- { ...iconProps }
330- className = { `${ baseClassName } __calendar-button__icon ${ baseClassName } __button__icon` }
331- >
332- < rect fill = "none" height = "15" width = "15" x = "2" y = "2" />
333- < line x1 = "6" x2 = "6" y1 = "0" y2 = "4" />
334- < line x1 = "13" x2 = "13" y1 = "0" y2 = "4" />
335- </ svg >
336- ) ;
337-
338- const ClearIcon = (
339- < svg
340- { ...iconProps }
341- className = { `${ baseClassName } __clear-button__icon ${ baseClassName } __button__icon` }
342- >
343- < line x1 = "4" x2 = "15" y1 = "4" y2 = "15" />
344- < line x1 = "15" x2 = "4" y1 = "4" y2 = "15" />
345- </ svg >
346- ) ;
347-
348- DatePicker . defaultProps = {
349- calendarIcon : CalendarIcon ,
350- clearIcon : ClearIcon ,
351- closeCalendar : true ,
352- isOpen : null ,
353- openCalendarOnFocus : true ,
354- returnValue : 'start' ,
355- } ;
356-
357- const isValue = PropTypes . oneOfType ( [ PropTypes . string , PropTypes . instanceOf ( Date ) ] ) ;
358-
359- DatePicker . propTypes = {
360- autoFocus : PropTypes . bool ,
361- calendarAriaLabel : PropTypes . string ,
362- calendarClassName : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] ) ,
363- calendarIcon : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
364- className : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . arrayOf ( PropTypes . string ) ] ) ,
365- clearAriaLabel : PropTypes . string ,
366- clearIcon : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
367- closeCalendar : PropTypes . bool ,
368- 'data-testid' : PropTypes . string ,
369- dayAriaLabel : PropTypes . string ,
370- dayPlaceholder : PropTypes . string ,
371- disableCalendar : PropTypes . bool ,
372- disabled : PropTypes . bool ,
373- format : PropTypes . string ,
374- id : PropTypes . string ,
375- isOpen : PropTypes . bool ,
376- locale : PropTypes . string ,
377- maxDate : isMaxDate ,
378- maxDetail : PropTypes . oneOf ( allViews ) ,
379- minDate : isMinDate ,
380- monthAriaLabel : PropTypes . string ,
381- monthPlaceholder : PropTypes . string ,
382- name : PropTypes . string ,
383- nativeInputAriaLabel : PropTypes . string ,
384- onCalendarClose : PropTypes . func ,
385- onCalendarOpen : PropTypes . func ,
386- onChange : PropTypes . func ,
387- onFocus : PropTypes . func ,
388- openCalendarOnFocus : PropTypes . bool ,
389- portalContainer : PropTypes . object ,
390- required : PropTypes . bool ,
391- returnValue : PropTypes . oneOf ( [ 'start' , 'end' , 'range' ] ) ,
392- showLeadingZeros : PropTypes . bool ,
393- value : PropTypes . oneOfType ( [ isValue , PropTypes . arrayOf ( isValue ) ] ) ,
394- yearAriaLabel : PropTypes . string ,
395- yearPlaceholder : PropTypes . string ,
396- } ;
0 commit comments