From 2017129baf91678e42ae384c5ae17fc06d6aba7c Mon Sep 17 00:00:00 2001 From: Yuki Kodama Date: Wed, 13 Apr 2016 15:32:46 +0900 Subject: [PATCH] Bump 0.5.4 --- README.md | 20 +++++++++++++++++++- lib/reducer.js | 2 +- lib/utils.js | 23 ++++++++++++++++++++--- package.json | 2 +- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2000a4d..e8059d1 100644 --- a/README.md +++ b/README.md @@ -80,12 +80,30 @@ import { reducer as tooltip } from 'redux-tooltip'; // ... export default combineReducers( - { your, reducers, ..., tooltip } + { your, awesome, reducers, ..., tooltip } ); ``` That's it! +#### [Optional] 4. Insert `redux-tooltip` middleware with yours + +If you want to use 'delay' feature, please insert `redux-tooltip` middleware to enable the feature. + +``` +import { middleware as tooltip } from 'redux-tooltip'; + +// ... + +const store = createStore( + reducer, + initialstate, + applyMiddleware( + your, awesome, middlewares, ..., tooltip + ) +); +``` + ## API ### `` diff --git a/lib/reducer.js b/lib/reducer.js index 5e584b3..7025938 100644 --- a/lib/reducer.js +++ b/lib/reducer.js @@ -59,7 +59,7 @@ function tooltip() { var action = arguments[1]; // Check usage of deprecated props - (0, _utils.deprecatedWarning)(action.payload); + (0, _utils.deprecatedWarning)(action); var handler = handlers[action.type]; return handler ? handler(state, action) : state; diff --git a/lib/utils.js b/lib/utils.js index 41d3d6f..3baceb8 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -24,6 +24,12 @@ var _isDom = require('is-dom'); var _isDom2 = _interopRequireDefault(_isDom); +var _actions = require('./actions'); + +var actions = _interopRequireWildcard(_actions); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } @@ -286,11 +292,22 @@ function resolve(obj) { return names; } -function deprecatedWarning(props) { - if (props && props.el) { +var actionTypes = Object.keys(actions).map(function (k) { + return actions[k]; +}).filter(function (e) { + return typeof e === 'string'; +}); +function deprecatedWarning(action) { + var type = action.type; + var payload = action.payload; + + if (actionTypes.indexOf(action.type) === -1) { + return; // Ignore non-related actions + } + if (payload && payload.el) { console.warn('DEPRECATED: Use \'origin\' instead of \'el\' in props for Tooltip component or \'show\' action.'); } - if (props && props.el && props.origin) { + if (payload && payload.el && payload.origin) { console.warn('Do not pass both \'origin\' and \'el\' props at the same time.'); } } diff --git a/package.json b/package.json index 0b1cf08..11dab03 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redux-tooltip", - "version": "0.5.3", + "version": "0.5.4", "description": "A tooltip React component for Redux", "main": "./lib/index.js", "repository": {