Skip to content

Commit

Permalink
Replace React.PropTypes with prop-types package
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewzey committed Apr 17, 2017
1 parent d3b00cb commit 9a8d509
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 84 deletions.
9 changes: 5 additions & 4 deletions example/components/code-snippet.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/* global hljs */
import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
import cx from 'classnames';

const CodeSnippet = createReactClass({
propTypes: {
children: React.PropTypes.node.isRequired,
language: React.PropTypes.string.isRequired,
toggle: React.PropTypes.bool,
visible: React.PropTypes.bool,
children: PropTypes.node.isRequired,
language: PropTypes.string.isRequired,
toggle: PropTypes.bool,
visible: PropTypes.bool,
},

getDefaultProps() {
Expand Down
7 changes: 4 additions & 3 deletions example/components/quick-selection/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import _ from 'underscore';
import Selection from './selection';

const QuickSelection = createReactClass({
propTypes: {
dates: React.PropTypes.object.isRequired,
value: React.PropTypes.object,
onSelect: React.PropTypes.func.isRequired,
dates: PropTypes.object.isRequired,
value: PropTypes.object,
onSelect: PropTypes.func.isRequired,
},

isCurrentlySelected(date) {
Expand Down
11 changes: 6 additions & 5 deletions example/components/quick-selection/selection.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';

const Selection = createReactClass({
propTypes: {
className: React.PropTypes.string.isRequired,
date: React.PropTypes.object.isRequired,
disabled: React.PropTypes.bool.isRequired,
label: React.PropTypes.string.isRequired,
onSelect: React.PropTypes.func.isRequired,
className: PropTypes.string.isRequired,
date: PropTypes.object.isRequired,
disabled: PropTypes.bool.isRequired,
label: PropTypes.string.isRequired,
onSelect: PropTypes.func.isRequired,
},

getDefaultProps() {
Expand Down
3 changes: 2 additions & 1 deletion example/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable react/no-multi-comp */

import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import moment from 'moment';
import {} from 'moment-range';
Expand Down Expand Up @@ -28,7 +29,7 @@ function processCodeSnippet(src) {

const DatePickerRange = createReactClass({
propTypes: {
value: React.PropTypes.object,
value: PropTypes.object,
},

getInitialState() {
Expand Down
55 changes: 28 additions & 27 deletions src/DateRangePicker.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import moment from 'moment';
import {} from 'moment-range';
Expand Down Expand Up @@ -29,33 +30,33 @@ const DateRangePicker = createReactClass({
mixins: [BemMixin, PureRenderMixin],

propTypes: {
bemBlock: React.PropTypes.string,
bemNamespace: React.PropTypes.string,
className: React.PropTypes.string,
dateStates: React.PropTypes.array, // an array of date ranges and their states
defaultState: React.PropTypes.string,
disableNavigation: React.PropTypes.bool,
firstOfWeek: React.PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]),
helpMessage: React.PropTypes.string,
initialDate: React.PropTypes.instanceOf(Date),
initialFromValue: React.PropTypes.bool,
initialMonth: React.PropTypes.number, // Overrides values derived from initialDate/initialRange
initialRange: React.PropTypes.object,
initialYear: React.PropTypes.number, // Overrides values derived from initialDate/initialRange
locale: React.PropTypes.string,
maximumDate: React.PropTypes.instanceOf(Date),
minimumDate: React.PropTypes.instanceOf(Date),
numberOfCalendars: React.PropTypes.number,
onHighlightDate: React.PropTypes.func, // triggered when a date is highlighted (hovered)
onHighlightRange: React.PropTypes.func, // triggered when a range is highlighted (hovered)
onSelect: React.PropTypes.func, // triggered when a date or range is selectec
onSelectStart: React.PropTypes.func, // triggered when the first date in a range is selected
paginationArrowComponent: React.PropTypes.func,
selectedLabel: React.PropTypes.string,
selectionType: React.PropTypes.oneOf(['single', 'range']),
singleDateRange: React.PropTypes.bool,
showLegend: React.PropTypes.bool,
stateDefinitions: React.PropTypes.object,
bemBlock: PropTypes.string,
bemNamespace: PropTypes.string,
className: PropTypes.string,
dateStates: PropTypes.array, // an array of date ranges and their states
defaultState: PropTypes.string,
disableNavigation: PropTypes.bool,
firstOfWeek: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]),
helpMessage: PropTypes.string,
initialDate: PropTypes.instanceOf(Date),
initialFromValue: PropTypes.bool,
initialMonth: PropTypes.number, // Overrides values derived from initialDate/initialRange
initialRange: PropTypes.object,
initialYear: PropTypes.number, // Overrides values derived from initialDate/initialRange
locale: PropTypes.string,
maximumDate: PropTypes.instanceOf(Date),
minimumDate: PropTypes.instanceOf(Date),
numberOfCalendars: PropTypes.number,
onHighlightDate: PropTypes.func, // triggered when a date is highlighted (hovered)
onHighlightRange: PropTypes.func, // triggered when a range is highlighted (hovered)
onSelect: PropTypes.func, // triggered when a date or range is selectec
onSelectStart: PropTypes.func, // triggered when the first date in a range is selected
paginationArrowComponent: PropTypes.func,
selectedLabel: PropTypes.string,
selectionType: PropTypes.oneOf(['single', 'range']),
singleDateRange: PropTypes.bool,
showLegend: PropTypes.bool,
stateDefinitions: PropTypes.object,
value: CustomPropTypes.momentOrMomentRange,
},

Expand Down
5 changes: 3 additions & 2 deletions src/Legend.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';

import BemMixin from './utils/BemMixin';
Expand All @@ -10,8 +11,8 @@ const Legend = createReactClass({
mixins: [BemMixin, PureRenderMixin],

propTypes: {
selectedLabel: React.PropTypes.string.isRequired,
stateDefinitions: React.PropTypes.object.isRequired,
selectedLabel: PropTypes.string.isRequired,
stateDefinitions: PropTypes.object.isRequired,
},

render() {
Expand Down
7 changes: 4 additions & 3 deletions src/PaginationArrow.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';

import BemMixin from './utils/BemMixin';
Expand All @@ -10,9 +11,9 @@ const PaginationArrow = createReactClass({
mixins: [BemMixin, PureRenderMixin],

propTypes: {
disabled: React.PropTypes.bool,
onTrigger: React.PropTypes.func,
direction: React.PropTypes.oneOf(['next', 'previous']),
disabled: PropTypes.bool,
onTrigger: PropTypes.func,
direction: PropTypes.oneOf(['next', 'previous']),
},

getDefaultProps() {
Expand Down
35 changes: 18 additions & 17 deletions src/calendar/CalendarDate.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';

import Immutable from 'immutable';
Expand All @@ -19,27 +20,27 @@ const CalendarDate = createReactClass({
propTypes: {
date: CustomPropTypes.moment,

firstOfMonth: React.PropTypes.object.isRequired,
firstOfMonth: PropTypes.object.isRequired,

isSelectedDate: React.PropTypes.bool,
isSelectedRangeStart: React.PropTypes.bool,
isSelectedRangeEnd: React.PropTypes.bool,
isInSelectedRange: React.PropTypes.bool,
isSelectedDate: PropTypes.bool,
isSelectedRangeStart: PropTypes.bool,
isSelectedRangeEnd: PropTypes.bool,
isInSelectedRange: PropTypes.bool,

isHighlightedDate: React.PropTypes.bool,
isHighlightedRangeStart: React.PropTypes.bool,
isHighlightedRangeEnd: React.PropTypes.bool,
isInHighlightedRange: React.PropTypes.bool,
isHighlightedDate: PropTypes.bool,
isHighlightedRangeStart: PropTypes.bool,
isHighlightedRangeEnd: PropTypes.bool,
isInHighlightedRange: PropTypes.bool,

highlightedDate: React.PropTypes.object,
dateStates: React.PropTypes.instanceOf(Immutable.List),
isDisabled: React.PropTypes.bool,
isToday: React.PropTypes.bool,
highlightedDate: PropTypes.object,
dateStates: PropTypes.instanceOf(Immutable.List),
isDisabled: PropTypes.bool,
isToday: PropTypes.bool,

dateRangesForDate: React.PropTypes.func,
onHighlightDate: React.PropTypes.func,
onUnHighlightDate: React.PropTypes.func,
onSelectDate: React.PropTypes.func,
dateRangesForDate: PropTypes.func,
onHighlightDate: PropTypes.func,
onUnHighlightDate: PropTypes.func,
onSelectDate: PropTypes.func,
},

getInitialState() {
Expand Down
5 changes: 3 additions & 2 deletions src/calendar/CalendarDatePeriod.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';

import BemMixin from '../utils/BemMixin';
Expand All @@ -9,8 +10,8 @@ const CalendarDatePeriod = createReactClass({
mixins: [BemMixin, PureRenderMixin],

propTypes: {
color: React.PropTypes.string,
period: React.PropTypes.string,
color: PropTypes.string,
period: PropTypes.string,
},

render() {
Expand Down
3 changes: 2 additions & 1 deletion src/calendar/CalendarHighlight.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';

import BemMixin from '../utils/BemMixin';
Expand All @@ -9,7 +10,7 @@ const CalendarHighlight = createReactClass({
mixins: [BemMixin, PureRenderMixin],

propTypes: {
modifier: React.PropTypes.string,
modifier: PropTypes.string,
},

render() {
Expand Down
19 changes: 10 additions & 9 deletions src/calendar/CalendarMonth.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';
import moment from 'moment';
import 'moment-range';
Expand All @@ -14,18 +15,18 @@ const CalendarMonth = createReactClass({
mixins: [BemMixin, PureRenderMixin],

propTypes: {
dateComponent: React.PropTypes.func,
disableNavigation: React.PropTypes.bool,
dateComponent: PropTypes.func,
disableNavigation: PropTypes.bool,
enabledRange: CustomPropTypes.momentRange,
firstOfMonth: CustomPropTypes.moment,
firstOfWeek: React.PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]),
hideSelection: React.PropTypes.bool,
highlightedDate: React.PropTypes.object,
highlightedRange: React.PropTypes.object,
onMonthChange: React.PropTypes.func,
onYearChange: React.PropTypes.func,
firstOfWeek: PropTypes.oneOf([0, 1, 2, 3, 4, 5, 6]),
hideSelection: PropTypes.bool,
highlightedDate: PropTypes.object,
highlightedRange: PropTypes.object,
onMonthChange: PropTypes.func,
onYearChange: PropTypes.func,
value: CustomPropTypes.momentOrMomentRange,
locale: React.PropTypes.string,
locale: PropTypes.string,
},

setLocale(locale) {
Expand Down
5 changes: 3 additions & 2 deletions src/calendar/CalendarSelection.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
import createReactClass from 'create-react-class';

import BemMixin from '../utils/BemMixin';
Expand All @@ -9,8 +10,8 @@ const CalendarSelection = createReactClass({
mixins: [BemMixin, PureRenderMixin],

propTypes: {
modifier: React.PropTypes.string,
pending: React.PropTypes.bool.isRequired,
modifier: PropTypes.string,
pending: PropTypes.bool.isRequired,
},

render() {
Expand Down
13 changes: 7 additions & 6 deletions src/utils/BemMixin.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import React from 'react';
import PropTypes from 'prop-types';
import bemCx from './bemCx';


const BemMixin = {
propTypes: {
bemNamespace: React.PropTypes.string,
bemBlock: React.PropTypes.string,
bemNamespace: PropTypes.string,
bemBlock: PropTypes.string,
},

contextTypes: {
bemNamespace: React.PropTypes.string,
bemBlock: React.PropTypes.string,
bemNamespace: PropTypes.string,
bemBlock: PropTypes.string,
},

childContextTypes: {
bemNamespace: React.PropTypes.string,
bemBlock: React.PropTypes.string,
bemNamespace: PropTypes.string,
bemBlock: PropTypes.string,
},

getChildContext() {
Expand Down
5 changes: 3 additions & 2 deletions src/utils/tests/BemMixin.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';

import BemMixin from '../BemMixin';

describe('BemMixin', function () {

beforeEach(function () {
this.types = {
bemNamespace: React.PropTypes.string,
bemBlock: React.PropTypes.string,
bemNamespace: PropTypes.string,
bemBlock: PropTypes.string,
};
BemMixin.props = {};
BemMixin.context = {};
Expand Down

0 comments on commit 9a8d509

Please sign in to comment.