From a0b9ce4787f14f8d76438bcc6d0bae5997ce3a06 Mon Sep 17 00:00:00 2001 From: Niels van Midden Date: Mon, 24 Apr 2017 15:56:23 +0200 Subject: [PATCH] Decouple Proptypes from React --- package.json | 3 +++ src/PinchableBaseMixin.js | 11 ++++++----- src/PinchableMixin.js | 7 ++++--- src/TappableMixin.js | 37 +++++++++++++++++++------------------ src/getComponent.js | 13 +++++++------ 5 files changed, 39 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index b7d6d64..f3cb5e6 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "url": "https://github.com/JedWatson/react-tappable.git" }, "peerDependencies": { + "prop-types": "^15.5.8", "react": "^0.14 || ^15.0.0-rc || ^15.0.0", "react-dom": "^0.14 || ^15.0.0-rc || ^15.0.0" }, @@ -18,11 +19,13 @@ "eslint": "^1.6.0", "eslint-plugin-react": "^3.5.1", "gulp": "^3.9.1", + "prop-types": "^15.5.8", "react": "^0.14 || ^15.0.0-rc || ^15.0.0", "react-component-gulp-tasks": "^0.7.7", "react-dom": "^0.14 || ^15.0.0-rc || ^15.0.0" }, "browserify-shim": { + "prop-types": "global:PropTypes", "react": "global:React", "react-dom": "global:ReactDOM" }, diff --git a/src/PinchableBaseMixin.js b/src/PinchableBaseMixin.js index a064acf..66d0253 100644 --- a/src/PinchableBaseMixin.js +++ b/src/PinchableBaseMixin.js @@ -1,13 +1,14 @@ +var PropTypes = require('prop-types'); var React = require('react'); var Mixin = { propTypes: { - preventDefault: React.PropTypes.bool, // whether to preventDefault on all events - stopPropagation: React.PropTypes.bool, // whether to stopPropagation on all events + preventDefault: PropTypes.bool, // whether to preventDefault on all events + stopPropagation: PropTypes.bool, // whether to stopPropagation on all events - onTouchStart: React.PropTypes.func, // pass-through touch event - onTouchMove: React.PropTypes.func, // pass-through touch event - onTouchEnd: React.PropTypes.func // pass-through touch event + onTouchStart: PropTypes.func, // pass-through touch event + onTouchMove: PropTypes.func, // pass-through touch event + onTouchEnd: PropTypes.func // pass-through touch event }, getInitialState: function () { diff --git a/src/PinchableMixin.js b/src/PinchableMixin.js index ed29bc5..64984e1 100644 --- a/src/PinchableMixin.js +++ b/src/PinchableMixin.js @@ -1,3 +1,4 @@ +var PropTypes = require('prop-types'); var React = require('react'); function getPinchProps (touches) { @@ -13,9 +14,9 @@ function getPinchProps (touches) { var Mixin = { propTypes: { - onPinchStart: React.PropTypes.func, // fires when a pinch gesture is started - onPinchMove: React.PropTypes.func, // fires on every touch-move when a pinch action is active - onPinchEnd: React.PropTypes.func // fires when a pinch action ends + onPinchStart: PropTypes.func, // fires when a pinch gesture is started + onPinchMove: PropTypes.func, // fires on every touch-move when a pinch action is active + onPinchEnd: PropTypes.func // fires when a pinch action ends }, onPinchStart: function (event) { diff --git a/src/TappableMixin.js b/src/TappableMixin.js index 264cae7..ab09645 100644 --- a/src/TappableMixin.js +++ b/src/TappableMixin.js @@ -1,3 +1,4 @@ +var PropTypes = require('prop-types'); var React = require('react'); var ReactDOM = require('react-dom'); @@ -16,24 +17,24 @@ function getTouchProps (touch) { var Mixin = { propTypes: { - moveThreshold: React.PropTypes.number, // pixels to move before cancelling tap - activeDelay: React.PropTypes.number, // ms to wait before adding the `-active` class - pressDelay: React.PropTypes.number, // ms to wait before detecting a press - pressMoveThreshold: React.PropTypes.number, // pixels to move before cancelling press - preventDefault: React.PropTypes.bool, // whether to preventDefault on all events - stopPropagation: React.PropTypes.bool, // whether to stopPropagation on all events - - onTap: React.PropTypes.func, // fires when a tap is detected - onPress: React.PropTypes.func, // fires when a press is detected - onTouchStart: React.PropTypes.func, // pass-through touch event - onTouchMove: React.PropTypes.func, // pass-through touch event - onTouchEnd: React.PropTypes.func, // pass-through touch event - onMouseDown: React.PropTypes.func, // pass-through mouse event - onMouseUp: React.PropTypes.func, // pass-through mouse event - onMouseMove: React.PropTypes.func, // pass-through mouse event - onMouseOut: React.PropTypes.func, // pass-through mouse event - onKeyDown: React.PropTypes.func, // pass-through key event - onKeyUp: React.PropTypes.func, // pass-through key event + moveThreshold: PropTypes.number, // pixels to move before cancelling tap + activeDelay: PropTypes.number, // ms to wait before adding the `-active` class + pressDelay: PropTypes.number, // ms to wait before detecting a press + pressMoveThreshold: PropTypes.number, // pixels to move before cancelling press + preventDefault: PropTypes.bool, // whether to preventDefault on all events + stopPropagation: PropTypes.bool, // whether to stopPropagation on all events + + onTap: PropTypes.func, // fires when a tap is detected + onPress: PropTypes.func, // fires when a press is detected + onTouchStart: PropTypes.func, // pass-through touch event + onTouchMove: PropTypes.func, // pass-through touch event + onTouchEnd: PropTypes.func, // pass-through touch event + onMouseDown: PropTypes.func, // pass-through mouse event + onMouseUp: PropTypes.func, // pass-through mouse event + onMouseMove: PropTypes.func, // pass-through mouse event + onMouseOut: PropTypes.func, // pass-through mouse event + onKeyDown: PropTypes.func, // pass-through key event + onKeyUp: PropTypes.func, // pass-through key event }, getDefaultProps: function () { diff --git a/src/getComponent.js b/src/getComponent.js index 9d03c25..4c8e552 100644 --- a/src/getComponent.js +++ b/src/getComponent.js @@ -1,3 +1,4 @@ +var PropTypes = require('prop-types'); var React = require('react'); var touchStyles = require('./touchStyles'); @@ -12,12 +13,12 @@ module.exports = function (mixins) { mixins: mixins, propTypes: { - component: React.PropTypes.any, // component to create - className: React.PropTypes.string, // optional className - classBase: React.PropTypes.string, // base for generated classNames - classes: React.PropTypes.object, // object containing the active and inactive class names - style: React.PropTypes.object, // additional style properties for the component - disabled: React.PropTypes.bool // only applies to buttons + component: PropTypes.any, // component to create + className: PropTypes.string, // optional className + classBase: PropTypes.string, // base for generated classNames + classes: PropTypes.object, // object containing the active and inactive class names + style: PropTypes.object, // additional style properties for the component + disabled: PropTypes.bool // only applies to buttons }, getDefaultProps: function () {