@@ -54,37 +54,76 @@ var FIRST_DAY_OF_WEEK = [
5454] ;
5555
5656var SHOWING_DATE = [
57- 'default' ,
58- 'none' ,
5957 'all' ,
60- 'decoratedDisabled' ,
58+ 'none'
6159] ;
6260
6361var SELECTION_MODES = [
6462 'none' ,
65- 'single' ,
6663 'range' ,
67- 'multiple' ,
64+ 'single' ,
65+ 'multiple'
6866] ;
6967
68+ const colorType = function ( props , propName , componentName , ...rest ) {
69+ var checker = function ( ) {
70+ var color = props [ propName ] ;
71+ var regex = / ^ # ( [ 0 - 9 A - F a - f ] { 6 } | [ 0 - 9 A - F a - f ] { 8 } ) $ / ;
72+ if ( color && ! regex . test ( color ) ) {
73+ return new Error ( 'Only accept color formats: #RRGGBB and #AARRGGBB' ) ;
74+ }
75+ } ;
76+ return PropTypes . string ( props , propName , componentName , ...rest ) || checker ( ) ;
77+ } ;
78+
79+ const ColorValidator = function ( props , propName , componentName , ...rest ) {
80+ var checker = function ( ) {
81+ var color = props [ propName ] ;
82+ var regex = / ^ # ( [ 0 - 9 A - F a - f ] { 6 } | [ 0 - 9 A - F a - f ] { 8 } ) $ / ;
83+ if ( color && ! regex . test ( color ) ) {
84+ return new Error ( 'Color accept formats: #RRGGBB and #AARRGGBB' ) ;
85+ }
86+ } ;
87+ return PropTypes . string ( props , propName , componentName , ...rest ) || checker ( ) ;
88+ } ;
89+
90+ const DatesValidator = function ( props , propName , componentName , ...rest ) {
91+ console . log ( 'DatesValidator' ) ;
92+ var checker = function ( ) {
93+ var date = props [ propName ] ;
94+ var regex = / ^ ( 1 9 | 2 0 ) \d \d [ / ] ( 0 [ 1 - 9 ] | 1 [ 0 1 2 ] ) [ / ] ( 0 [ 1 - 9 ] | [ 1 2 ] [ 0 - 9 ] | 3 [ 0 1 ] ) / ;
95+ if ( date && ! regex . test ( date ) ) {
96+ return new Error ( 'Date should be: YYYY/MM/DD' ) ;
97+ }
98+ } ;
99+ return PropTypes . string ( props , propName , componentName , ...rest ) || checker ( ) ;
100+ } ;
70101
71102ReactMaterialCalendarView . propTypes = {
72103 ...View . propTypes ,
73104 width : PropTypes . number . isRequired ,
74105 height : PropTypes . number ,
106+ // Tile size
75107 tileWidth : PropTypes . number ,
76108 tileHeight : PropTypes . number ,
77109 tileSize : PropTypes . number ,
110+ // Toolbar options
78111 topbarVisible : PropTypes . bool ,
79- arrowColor : PropTypes . string ,
112+ arrowColor : ColorValidator ,
113+ // Calendar config
80114 firstDayOfWeek : PropTypes . oneOf ( FIRST_DAY_OF_WEEK ) ,
81- minimumDate : PropTypes . string ,
82- maximumDate : PropTypes . string ,
115+ minimumDate : DatesValidator ,
116+ maximumDate : DatesValidator ,
83117 datesSelection : PropTypes . oneOf ( SELECTION_MODES ) ,
84118 showOtherDates : PropTypes . oneOf ( SHOWING_DATE ) ,
85- currentDate : PropTypes . string ,
86- onDateChange : PropTypes . func ,
87- onMonthChange : PropTypes . func ,
119+ // Set date
120+ currentDate : DatesValidator ,
121+ selectedDates : PropTypes . arrayOf ( DatesValidator ) ,
122+ eventsDates : PropTypes . arrayOf ( DatesValidator ) ,
123+ // Color customizations
124+ selectionColor : ColorValidator ,
125+ weekendsColor : ColorValidator ,
126+ eventsColor : ColorValidator ,
88127} ;
89128
90129ReactMaterialCalendarView . defaultProps = {
0 commit comments