Skip to content

Commit 9fd6110

Browse files
committed
Switch to prop-types package due to deprecation of React.PropTypes.
https://facebook.github.io/react/blog/2017/04/07/react-v15.5.0.html
1 parent f0bb5ca commit 9fd6110

File tree

6 files changed

+145
-142
lines changed

6 files changed

+145
-142
lines changed

README.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ AppRegistry.registerComponent('Example', () => Example);
9494
#### Props / API
9595
This is the list of all the props you can pass to the component so that you can customize it:
9696
###### Initial data and onDateSelected handler
97-
* startingDate: React.PropTypes.any - Date to be used for centering the calendar/showing the week based on that date. It is internaly wrapped by `moment` so it accepts both `Date` and `moment Date`.
98-
* selectedDate: React.PropTypes.any - Date to be used as pre selected Date. It is internaly wrapped by `moment` so it accepts both `Date` and `moment Date`.
99-
* onDateSelected: React.PropTypes.func - Function to be used as a callback when a date is selected. It returns `moment Date`
100-
* onWeekChanged: React.PropTypes.func - Function to be used as a callback when a week is changed. It returns `moment Date`
101-
* useIsoWeekday: React.PropTypes.bool - start week on ISO day of week (default true). If false, starts week on _startingDate_ parameter.
102-
* minDate: React.PropTypes.any - minimum date that the calendar may navigate to. A week is allowed if minDate falls within the current week.
103-
* maxDate: React.PropTypes.any - maximum date that the calendar may navigate to. A week is allowed if maxDate falls within the current week.
104-
* datesWhitelist: React.PropTypes.array - Dates that are enabled (accepts both `Date` and `moment Date`). Ranges may be specified with an object entry in the array:
97+
* startingDate: PropTypes.any - Date to be used for centering the calendar/showing the week based on that date. It is internaly wrapped by `moment` so it accepts both `Date` and `moment Date`.
98+
* selectedDate: PropTypes.any - Date to be used as pre selected Date. It is internaly wrapped by `moment` so it accepts both `Date` and `moment Date`.
99+
* onDateSelected: PropTypes.func - Function to be used as a callback when a date is selected. It returns `moment Date`
100+
* onWeekChanged: PropTypes.func - Function to be used as a callback when a week is changed. It returns `moment Date`
101+
* useIsoWeekday: PropTypes.bool - start week on ISO day of week (default true). If false, starts week on _startingDate_ parameter.
102+
* minDate: PropTypes.any - minimum date that the calendar may navigate to. A week is allowed if minDate falls within the current week.
103+
* maxDate: PropTypes.any - maximum date that the calendar may navigate to. A week is allowed if maxDate falls within the current week.
104+
* datesWhitelist: PropTypes.array - Dates that are enabled (accepts both `Date` and `moment Date`). Ranges may be specified with an object entry in the array:
105105
```
106106
// Date range format
107107
{
@@ -110,44 +110,44 @@ This is the list of all the props you can pass to the component so that you can
110110
}
111111
```
112112
This may be overridden by _datesBlacklist_.
113-
* datesBlacklist: React.PropTypes.array - Dates that are disabled. Same format as _datesWhitelist_. This overrides dates in _datesWhitelist_.
113+
* datesBlacklist: PropTypes.array - Dates that are disabled. Same format as _datesWhitelist_. This overrides dates in _datesWhitelist_.
114114

115115
###### Show or hide components
116-
* showMonth: React.PropTypes.bool - Show (default true) or hide (false) the month label.
117-
* showDate: React.PropTypes.bool - Show (default true) or hide (false) all the dates.
118-
* showDayName: React.PropTypes.bool - Show (default true) or hide (false) the day name label.
119-
* showDayNumber: React.PropTypes.bool - Show (default true) or hide (false) the day number label.
116+
* showMonth: PropTypes.bool - Show (default true) or hide (false) the month label.
117+
* showDate: PropTypes.bool - Show (default true) or hide (false) all the dates.
118+
* showDayName: PropTypes.bool - Show (default true) or hide (false) the day name label.
119+
* showDayNumber: PropTypes.bool - Show (default true) or hide (false) the day number label.
120120

121121
###### Top level style
122-
* style: React.PropTypes.any - Style for the top level CalendarStrip component
122+
* style: PropTypes.any - Style for the top level CalendarStrip component
123123

124124
###### Icon
125-
* iconLeft: React.PropTypes.any - Icon to be used for the left icon. It accepts require statement with url to the image (`require('./img/icon.png')`), or object with remote uri `{uri: 'http://example.com/image.png'}`
126-
* iconRight: React.PropTypes.any - Icon to be used for the right icon. It accepts require statement with url to the image (`require('./img/icon.png')`), or object with remote uri `{uri: 'http://example.com/image.png'}`
127-
* iconStyle: React.PropTypes.any - Style that is applied to both left and right icons. It is applied before *iconLeftStyle* or *iconLeftStyle*.
128-
* iconLeftStyle: React.PropTypes.any - Style for left icon. It will override all of the other styles applied to icons.
129-
* iconRightStyle: React.PropTypes.any - Style for right icon. It will override all of the other styles applied to icons.
130-
* iconContainer: React.PropTypes.any - Style for the container of icons. (Example usage is to add `flex` property to it so in the portrait mode, it will shrink the dates strip)
131-
* leftSelector: React.PropTypes.any - Component for the left selector control. May be an instance of any React component. This overrides the icon* props above. Passing in an empty array `[]` hides this control.
132-
* rightSelector: React.PropTypes.any - same as above but for the right selector control.
125+
* iconLeft: PropTypes.any - Icon to be used for the left icon. It accepts require statement with url to the image (`require('./img/icon.png')`), or object with remote uri `{uri: 'http://example.com/image.png'}`
126+
* iconRight: PropTypes.any - Icon to be used for the right icon. It accepts require statement with url to the image (`require('./img/icon.png')`), or object with remote uri `{uri: 'http://example.com/image.png'}`
127+
* iconStyle: PropTypes.any - Style that is applied to both left and right icons. It is applied before *iconLeftStyle* or *iconLeftStyle*.
128+
* iconLeftStyle: PropTypes.any - Style for left icon. It will override all of the other styles applied to icons.
129+
* iconRightStyle: PropTypes.any - Style for right icon. It will override all of the other styles applied to icons.
130+
* iconContainer: PropTypes.any - Style for the container of icons. (Example usage is to add `flex` property to it so in the portrait mode, it will shrink the dates strip)
131+
* leftSelector: PropTypes.any - Component for the left selector control. May be an instance of any React component. This overrides the icon* props above. Passing in an empty array `[]` hides this control.
132+
* rightSelector: PropTypes.any - same as above but for the right selector control.
133133

134134
###### Header style and formatting
135-
* calendarHeaderStyle: React.PropTypes.any - Style for the header text of the calendar.
136-
* calendarHeaderFormat: React.PropTypes.string - Format for the header text of the calendar. For options, refere to [moments documentation](http://momentjs.com/docs/#/displaying/format/)
135+
* calendarHeaderStyle: PropTypes.any - Style for the header text of the calendar.
136+
* calendarHeaderFormat: PropTypes.string - Format for the header text of the calendar. For options, refere to [moments documentation](http://momentjs.com/docs/#/displaying/format/)
137137

138138
###### Date name and number styling
139-
* dateNameStyle: React.PropTypes.any - Style for the name of the day on work days in dates strip.
140-
* dateNumberStyle: React.PropTypes.any - Style for the number of the day on work days in dates strip.
141-
* weekendDateNameStyle: React.PropTypes.any - Style for the name of the day on weekend days in dates strip.
142-
* weekendDateNumberStyle: React.PropTypes.any - Style for the number of the day on weekend days in dates strip.
143-
* styleWeekend: React.PropTypes.bool - (default true) Whether to style weekend dates separately.
144-
* highlightDateNameStyle: React.PropTypes.any - Style for the selected name of the day in dates strip.
145-
* highlightDateNumberStyle: React.PropTypes.any - Style for the selected number of the day in dates strip.
146-
147-
* disabledDateNameStyle: React.PropTypes.any - Style for disabled name of the day in dates strip (controlled by datesWhitelist & datesBlacklist).
148-
* disabledDateNumberStyle: React.PropTypes.any - Style for disabled number of the day in dates strip (controlled by datesWhitelist & datesBlacklist).
149-
* disabledDateOpacity: React.PropTypes.number - (default 0.3) Opacity of disabled dates strip.
150-
* customDatesStyles: React.PropTypes.array - Custom per-date styling, overriding the styles above. Object format:
139+
* dateNameStyle: PropTypes.any - Style for the name of the day on work days in dates strip.
140+
* dateNumberStyle: PropTypes.any - Style for the number of the day on work days in dates strip.
141+
* weekendDateNameStyle: PropTypes.any - Style for the name of the day on weekend days in dates strip.
142+
* weekendDateNumberStyle: PropTypes.any - Style for the number of the day on weekend days in dates strip.
143+
* styleWeekend: PropTypes.bool - (default true) Whether to style weekend dates separately.
144+
* highlightDateNameStyle: PropTypes.any - Style for the selected name of the day in dates strip.
145+
* highlightDateNumberStyle: PropTypes.any - Style for the selected number of the day in dates strip.
146+
147+
* disabledDateNameStyle: PropTypes.any - Style for disabled name of the day in dates strip (controlled by datesWhitelist & datesBlacklist).
148+
* disabledDateNumberStyle: PropTypes.any - Style for disabled number of the day in dates strip (controlled by datesWhitelist & datesBlacklist).
149+
* disabledDateOpacity: PropTypes.number - (default 0.3) Opacity of disabled dates strip.
150+
* customDatesStyles: PropTypes.array - Custom per-date styling, overriding the styles above. Object format:
151151
* startDate: anything parseable by Moment.
152152
* endDate: (optional) specify a range. If no endDate is supplied, startDate is treated as a single date.
153153
* dateNameStyle: (optional, see above)
@@ -184,7 +184,7 @@ This is the list of all the props you can pass to the component so that you can
184184
The week strip and day selection have configurable opacity animations. If they are not specified in the props, by default the animations are disabled.
185185

186186
**Week strip animation**
187-
* calendarAnimation: React.PropTypes.object - options for animating the week.
187+
* calendarAnimation: PropTypes.object - options for animating the week.
188188
* type: `sequence` or `parallel`
189189
* duration: duration of animation in milliseconds.
190190

@@ -197,27 +197,27 @@ This is the list of all the props you can pass to the component so that you can
197197
![alt text](https://raw.githubusercontent.com/BugiDev/react-native-calendar-strip/master/example/gifs/parallel.gif "react-native-calendar-strip parallel animation demo")
198198

199199
**Day selection animation**
200-
* daySelectionAnimation: React.PropTypes.object -
200+
* daySelectionAnimation: PropTypes.object -
201201
* type: `border` or `background`. 'border' animates a circular border around a date. 'background' animates the background of the date.
202202
* duration: duration of animation in milliseconds.
203-
* borderWidth: React.PropTypes.number - Selected day's border width. Required if the type is set to _border_.
204-
* borderHighlightColor: React.PropTypes.string - Selected day's border color. Required if the type is set to _border_.
205-
* highlightColor: React.PropTypes.string - Highlighted color of selected date. Required if the type is set to _background_.
203+
* borderWidth: PropTypes.number - Selected day's border width. Required if the type is set to _border_.
204+
* borderHighlightColor: PropTypes.string - Selected day's border color. Required if the type is set to _border_.
205+
* highlightColor: PropTypes.string - Highlighted color of selected date. Required if the type is set to _background_.
206206
* animType, animUpdateType, animProperty, and animSpringDamping are optional config options passed to [LayoutAnimation](https://facebook.github.io/react-native/docs/layoutanimation.html)
207207

208208
Border example:
209209

210210
![alt text](https://raw.githubusercontent.com/BugiDev/react-native-calendar-strip/master/example/gifs/border-small.gif "react-native-calendar-strip border animation demo")
211211

212212
If you chose the `background` type of animation, the selected date will animate the circular background color from `calendarColor` to `daySelectionAnimation.highlightColor`. That is why, when this type is chosen, you have to define both of these colors.
213-
* calendarColor: React.PropTypes.string - Background color of the whole calendar strip. `!important` This is also the color of the circular background of the date so that highlighting the date will appear 'from background'. The top level style of this component can override this property.
213+
* calendarColor: PropTypes.string - Background color of the whole calendar strip. `!important` This is also the color of the circular background of the date so that highlighting the date will appear 'from background'. The top level style of this component can override this property.
214214

215215
Background example:
216216

217217
![alt text](https://raw.githubusercontent.com/BugiDev/react-native-calendar-strip/master/example/gifs/background-small.gif "react-native-calendar-strip simple demo")
218218

219219
###### Localization
220-
* locale: React.PropTypes.object - Locale for dates
220+
* locale: PropTypes.object - Locale for dates
221221

222222
This prop is used for adding localization to react-native-calendar-strip component. The localization rules are the same as moments and can be found in [moments documentation](http://momentjs.com/docs/#/i18n/)
223223

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "react-native-calendar-strip",
3-
"version": "1.0.0",
3+
"version": "1.1.0",
44
"description": "Easy to use and visually stunning calendar component for React Native",
55
"main": "index.js",
66
"directories": {
77
"example": "example"
88
},
99
"dependencies": {
10-
"moment": "^2.17.1"
10+
"moment": "^2.17.1",
11+
"prop-types": "^15.5.10"
1112
},
1213
"devDependencies": {
1314
"babel-eslint": "^6.1.2",
@@ -26,7 +27,7 @@
2627
},
2728
"jest": {
2829
"preset": "react-native",
29-
"verbose":true,
30+
"verbose": true,
3031
"coverageDirectory": "./coverage/",
3132
"collectCoverageFrom": [
3233
"src/**/*.js",

src/CalendarDay.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
*/
44

55
import React, {Component} from 'react';
6+
import PropTypes from 'prop-types';
7+
68
import {
79
StyleSheet,
810
Text,
@@ -16,29 +18,29 @@ import styles from './Calendar.style.js';
1618
export default class CalendarDay extends Component {
1719

1820
static propTypes = {
19-
date: React.PropTypes.object.isRequired,
20-
onDateSelected: React.PropTypes.func.isRequired,
21-
selected: React.PropTypes.bool.isRequired,
22-
enabled: React.PropTypes.bool.isRequired,
23-
24-
showDayName: React.PropTypes.bool,
25-
showDayNumber: React.PropTypes.bool,
26-
27-
calendarColor: React.PropTypes.string,
28-
29-
dateNameStyle: React.PropTypes.any,
30-
dateNumberStyle: React.PropTypes.any,
31-
weekendDateNameStyle: React.PropTypes.any,
32-
weekendDateNumberStyle: React.PropTypes.any,
33-
highlightDateNameStyle: React.PropTypes.any,
34-
highlightDateNumberStyle: React.PropTypes.any,
35-
disabledDateNameStyle: React.PropTypes.any,
36-
disabledDateNumberStyle: React.PropTypes.any,
37-
disabledDateOpacity: React.PropTypes.number,
38-
styleWeekend: React.PropTypes.bool,
39-
customStyle: React.PropTypes.object,
40-
41-
daySelectionAnimation: React.PropTypes.object
21+
date: PropTypes.object.isRequired,
22+
onDateSelected: PropTypes.func.isRequired,
23+
selected: PropTypes.bool.isRequired,
24+
enabled: PropTypes.bool.isRequired,
25+
26+
showDayName: PropTypes.bool,
27+
showDayNumber: PropTypes.bool,
28+
29+
calendarColor: PropTypes.string,
30+
31+
dateNameStyle: PropTypes.any,
32+
dateNumberStyle: PropTypes.any,
33+
weekendDateNameStyle: PropTypes.any,
34+
weekendDateNumberStyle: PropTypes.any,
35+
highlightDateNameStyle: PropTypes.any,
36+
highlightDateNumberStyle: PropTypes.any,
37+
disabledDateNameStyle: PropTypes.any,
38+
disabledDateNumberStyle: PropTypes.any,
39+
disabledDateOpacity: PropTypes.number,
40+
styleWeekend: PropTypes.bool,
41+
customStyle: PropTypes.object,
42+
43+
daySelectionAnimation: PropTypes.object
4244
};
4345

4446
// Reference: https://medium.com/@Jpoliachik/react-native-s-layoutanimation-is-awesome-4a4d317afd3e

src/CalendarHeader.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React, {Component} from 'react';
22
import {Text} from 'react-native';
3-
43
import styles from './Calendar.style.js';
4+
import PropTypes from 'prop-types';
55

66
class CalendarHeader extends Component {
77
static propTypes = {
8-
calendarHeaderFormat: React.PropTypes.string.isRequired,
9-
calendarHeaderStyle: React.PropTypes.oneOfType([
10-
React.PropTypes.object,
11-
React.PropTypes.number
8+
calendarHeaderFormat: PropTypes.string.isRequired,
9+
calendarHeaderStyle: PropTypes.oneOfType([
10+
PropTypes.object,
11+
PropTypes.number
1212
]),
13-
datesForWeek: React.PropTypes.array.isRequired
13+
datesForWeek: PropTypes.array.isRequired
1414
};
1515

1616
shouldComponentUpdate(nextProps) {

0 commit comments

Comments
 (0)