planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

7
node_modules/redux-notifications/.babelrc generated vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"presets": [
"es2015",
"stage-0",
"react",
]
}

22
node_modules/redux-notifications/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,22 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
[*.scss]
indent_size = 4
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

5
node_modules/redux-notifications/.eslintignore generated vendored Normal file
View File

@@ -0,0 +1,5 @@
lib/*
**/dist/*
**/node_modules/*
**/server.js
**/webpack.config*.js

28
node_modules/redux-notifications/.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,28 @@
{
"root": true,
"parser": "babel-eslint",
"extends": "eslint-config-airbnb",
"env": {
"browser": true,
"node": true,
"mocha": true,
},
"rules": {
"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2,
"react/jsx-quotes": 0,
"react/jsx-filename-extension": 0,
"jsx-quotes": 2,
"comma-dangle": 0,
"indent": [2, 2, {"SwitchCase": 1}],
"max-len": 0,
"no-console": 0,
"no-alert": 0,
"no-param-reassign": 0,
"no-shadow": 0,
"no-undef": 2,
},
"plugins": [
"react"
]
}

11
node_modules/redux-notifications/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,11 @@
.DS_Store
*.log
examples
test
coverage
_book
book.json
docs
demo
dist
dist_demo

51
node_modules/redux-notifications/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,51 @@
# Redux-Notifications Changelog
### 4.0.1 (June 27 2017)
- Fix dependencies & add peerdependencies [#63](https://github.com/indexiatech/re-notif/pull/63)
### 4.0.0 (June 27 2017)
- Remove import of styles.css [#56](https://github.com/indexiatech/re-notif/pull/56)
### 3.2.1 (June 27 2017)
- Fix dependencies & add peerdependencies [#63](https://github.com/indexiatech/re-notif/pull/63)
### 3.2.0 (June 27 2017)
- Migrate from React.PropTypes [#59](https://github.com/indexiatech/re-notif/pull/59)
- Moving to new transition group method [#58](https://github.com/indexiatech/re-notif/pull/58)
- Allow HTML/React elements in message content [#53](https://github.com/indexiatech/re-notif/pull/53)
- Use Object-assign to support IE [#54](https://github.com/indexiatech/re-notif/pull/54/)
### 3.1.0 (December 14 2016)
- Give CustomComponent access to notification data [#51](https://github.com/indexiatech/re-notif/pull/51)
### 3.0.0 (October 15 2016)
- Remove CSS from Notifs component, let user optionally import [#47](https://github.com/indexiatech/re-notif/pull/47)
- Use stateless components for Notifs
- Improve `CustomComponent` API [#41](https://github.com/indexiatech/re-notif/pull/41)
- Do not display notifications with the same ID [#45](https://github.com/indexiatech/re-notif/pull/45)
- Drop peerDependencies
- Update devDependencies
### 2.1.0 (June 28 2016)
- Fixed custom component rendering
- Pass ID to notif component
- Fix `notifDismiss(id)` method
### 2.0.0 (June 28 2016)
- MARJOR: Renamed package to `redux-notifications` on NPM
- Proper linting
- Removed unused code
- #9 Support for React 15
- Document API changes
- Remove unused props
- Add default styles
- #3 Support for manual closing
### 1.0.1 (October 25 2015)
- Version Bump
### 1.0.0 (October 21 2015)
- React 0.14 support.
- Better demo env structure.
- Express instead of Webpack dev server.
- Demo with Bootstrap instead of PureCss.

28
node_modules/redux-notifications/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,28 @@
Copyright (c) 2015, indexiatech
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of re-notif nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

130
node_modules/redux-notifications/README.md generated vendored Normal file
View File

@@ -0,0 +1,130 @@
# `redux-notifications`
> :warning: The previous package `re-notif` has been deprecated on NPM and renamed to `redux-notifications`. A list of changes can be found in the Changelog. Please update your applications accordingly.
[React](https://github.com/facebook/react) & [Redux](https://github.com/rackt/redux) based notifications center.
Thanks to Redux, the notification objects are maintained within Redux Store's State and are fired by Actions.
## Implementation
##### 1. Installation
`npm install --save redux-notifications`
##### 2. The next thing you need to do is to add the `redux-notifications` `reducer` to Redux.
```js
import { createStore, combineReducers } from 'redux'
import { reducer as notifReducer } from 'redux-notifications';
combineReducers({
notifs: notifReducer,
// ... more reducers here ...
})
```
##### 3. Add the `Notifs` component at the root of your app
```js
import { Provider } from 'react-redux'
import { Notifs } from 'redux-notifications';
<Provider store={store}>
<div>
// ... other things like router ...
<Notifs />
</div>
</Provider>
```
##### 4. Optionally import default CSS
`redux-notifications` uses [react-css-transition-group](https://facebook.github.io/react/docs/animation.html#high-level-api-reactcsstransitiongroup) with the following classes:
- .notif-transition-enter
- .notif-transition-enter-active
- .notif-transition-leave
- .notif-transition-leave-active
To import the default stylesheet:
```js
import 'redux-notifications/lib/styles.css';
```
## Sending notifications
Thanks to Redux, sending notification is simply done by firing an `Action`:
``` javascript
import { reducer as notifReducer, actions as notifActions, Notifs } from 'redux-notifications';
const { notifSend } = notifActions;
class Demo extends React.Component {
send() {
this.props.dispatch(notifSend({
message: 'hello world',
kind: 'info',
dismissAfter: 2000
}));
}
render() {
<button onClick={this.send}>Send Notification</button>
}
}
```
## Actions
#### `actions.notifSend({config})`
##### `config.message : node` [required]
> The notification message, can be one of: `string`, `integer`, `element` or `array` containing these types.
##### `config.kind : string` [optional] [default:'info']
> The notification kind, can be one of: `info`, `success`, `warning`, `danger`.
##### `config.id : string` [optional] [default:Date.now()]
> Set an ID for the notification. If not set, defaults to Date.now().
##### `config.dismissAfter : integer` [optional] [default:null]
> Auto dismiss the notification after the given number of milliseconds.
#### `actions.notifClear()`
> Clear all current notifications.
#### `actions.notifDismiss(id)`
> Dismiss a notification by ID
---
## Notifs Component
#### `<Notifs CustomComponent={ReactComponent}/>`
##### `CustomComponent : React component`
> A custom react component can be used instead of the default Notif component
##### `className : string` [optional] [default:null]
> Pass a custom classname to the <Notifs /> component.
##### `componentClassName : string` [optional] [default:'notif']
> The base className for each Notif component. Can be used to override CSS styles.
##### `transitionEnterTimeout : integer` [optional] [default:600]
> Define the react-transition-group enter timeout is milliseconds.
##### `transitionLeaveTimeout : integer` [optional] [default:600]
> Define the react-transition-group leave timeout is milliseconds.
##### `actionLabel : string`
> Label for action click
##### `onActionClick : func`
> Function when action is clicked. Requires `actionLabel` prop
## Development
```
git clone https://github.com/indexiatech/re-notif.git
cd re-notif
npm install
npm run start
```
Listening on localhost:9000

51
node_modules/redux-notifications/lib/actions.js generated vendored Normal file
View File

@@ -0,0 +1,51 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.notifSend = notifSend;
exports.notifDismiss = notifDismiss;
exports.notifClear = notifClear;
var objectAssign = require('object-assign');
var NOTIF_SEND = exports.NOTIF_SEND = 'NOTIF_SEND';
var NOTIF_DISMISS = exports.NOTIF_DISMISS = 'NOTIF_DISMISS';
var NOTIF_CLEAR = exports.NOTIF_CLEAR = 'NOTIF_CLEAR';
/**
* Publish a notification,
* - if `dismissAfter` was set, the notification will be auto dismissed after the given period.
* - if id wasn't specified, a time based id will be generated.``
*/
function notifSend(notif) {
var payload = objectAssign({}, notif);
if (!payload.id) {
payload.id = new Date().getTime();
}
return function (dispatch) {
dispatch({ type: NOTIF_SEND, payload: payload });
if (payload.dismissAfter) {
setTimeout(function () {
dispatch({
type: NOTIF_DISMISS,
payload: payload.id
});
}, payload.dismissAfter);
}
};
}
/**
* Dismiss a notification by the given id.
*/
function notifDismiss(id) {
return { type: NOTIF_DISMISS, payload: id };
}
/**
* Clear all notifications
*/
function notifClear() {
return { type: NOTIF_CLEAR };
}

View File

@@ -0,0 +1,74 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Notif = function Notif(_ref) {
var kind = _ref.kind,
componentClassName = _ref.componentClassName,
actionLabel = _ref.actionLabel,
onActionClick = _ref.onActionClick,
id = _ref.id,
message = _ref.message;
var handleActionClick = function handleActionClick(ev) {
ev.preventDefault();
if (!onActionClick) {
return;
}
onActionClick(id);
};
return _react2.default.createElement(
'div',
{ className: componentClassName + ' ' + componentClassName + '--' + kind },
_react2.default.createElement('div', { className: componentClassName + '__icon' }),
_react2.default.createElement(
'div',
{ className: componentClassName + '__content' },
_react2.default.createElement(
'span',
{ className: componentClassName + '__message' },
message
)
),
actionLabel && _react2.default.createElement(
'span',
{ className: componentClassName + '__action' },
_react2.default.createElement(
'button',
{ onClick: handleActionClick },
actionLabel
)
),
_react2.default.createElement('div', { className: componentClassName + '__close' })
);
};
Notif.defaultProps = {
kind: 'info'
};
Notif.propTypes = {
id: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number]).isRequired,
message: _propTypes2.default.node.isRequired,
kind: _propTypes2.default.oneOf(['success', 'info', 'warning', 'danger']).isRequired,
componentClassName: _propTypes2.default.string,
onActionClick: _propTypes2.default.func,
actionLabel: _propTypes2.default.string
};
exports.default = Notif;

View File

@@ -0,0 +1,99 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactRedux = require('react-redux');
var _CSSTransitionGroup = require('react-transition-group/CSSTransitionGroup');
var _CSSTransitionGroup2 = _interopRequireDefault(_CSSTransitionGroup);
var _Notif = require('./Notif');
var _Notif2 = _interopRequireDefault(_Notif);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// This checks to see if object is immutable and properly access it
var getter = function getter(obj, propName) {
return obj.get ? obj.get(propName) : obj[propName];
};
var Notifs = function Notifs(props) {
var notifications = props.notifications,
className = props.className,
componentClassName = props.componentClassName,
CustomComponent = props.CustomComponent,
transitionEnterTimeout = props.transitionEnterTimeout,
transitionLeaveTimeout = props.transitionLeaveTimeout;
var renderedNotifications = notifications.map(function (notification) {
if (CustomComponent) {
return _react2.default.createElement(CustomComponent, _extends({}, props, {
componentClassName: componentClassName,
key: getter(notification, 'id'),
id: getter(notification, 'id'),
message: getter(notification, 'message'),
kind: getter(notification, 'kind')
}));
}
return _react2.default.createElement(_Notif2.default, _extends({}, props, {
componentClassName: componentClassName,
key: getter(notification, 'id'),
id: getter(notification, 'id'),
message: getter(notification, 'message'),
kind: getter(notification, 'kind')
}));
});
var classes = [componentClassName + '__container', className].join(' ').split();
return _react2.default.createElement(
'div',
{ className: classes },
_react2.default.createElement(
_CSSTransitionGroup2.default,
{
transitionName: componentClassName + '-transition',
transitionEnterTimeout: transitionEnterTimeout,
transitionLeaveTimeout: transitionLeaveTimeout
},
renderedNotifications
)
);
};
Notifs.defaultProps = {
className: null,
componentClassName: 'notif',
CustomComponent: null,
transitionEnterTimeout: 600,
transitionLeaveTimeout: 600
};
Notifs.propTypes = {
notifications: _propTypes2.default.array.isRequired,
className: _propTypes2.default.string,
CustomComponent: _propTypes2.default.oneOfType([_propTypes2.default.func, _propTypes2.default.node, _propTypes2.default.element]),
componentClassName: _propTypes2.default.string,
transitionEnterTimeout: _propTypes2.default.number,
transitionLeaveTimeout: _propTypes2.default.number
};
function mapStateToProps(state) {
return { notifications: state.get ? state.get('notifs') : state.notifs };
}
exports.default = (0, _reactRedux.connect)(mapStateToProps)(Notifs);

26
node_modules/redux-notifications/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.reducer = exports.actions = exports.Notifs = undefined;
var _reducer = require('./reducer');
var _reducer2 = _interopRequireDefault(_reducer);
var _actions = require('./actions');
var actions = _interopRequireWildcard(_actions);
var _Notifs = require('./components/Notifs');
var _Notifs2 = _interopRequireDefault(_Notifs);
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 }; }
exports.Notifs = _Notifs2.default;
exports.actions = actions;
exports.reducer = _reducer2.default;

33
node_modules/redux-notifications/lib/reducer.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = notifs;
var _actions = require('./actions');
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); } }
function notifs() {
var domain = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var action = arguments[1];
if (!action || !action.type) return domain;
switch (action.type) {
case _actions.NOTIF_SEND:
return [action.payload].concat(_toConsumableArray(domain.filter(function (_ref) {
var id = _ref.id;
return id !== action.payload.id;
})));
case _actions.NOTIF_DISMISS:
return domain.filter(function (notif) {
return notif.id !== action.payload;
});
case _actions.NOTIF_CLEAR:
return [];
default:
return domain;
}
}

57
node_modules/redux-notifications/lib/styles.css generated vendored Normal file
View File

@@ -0,0 +1,57 @@
.notif-transition-enter {
opacity : 0.01;
transition : opacity .5s ease-in;
}
.notif-transition-enter-active {
opacity : 1;
}
.notif-transition-leave {
opacity : 1;
transition : opacity .5s ease-in;
}
.notif-transition-leave-active {
opacity : 0.01;
}
.notif {
position : relative;
font : 1rem normal Helvetica, sans-serif;
overflow : hidden;
border-radius : 4px;
margin-bottom : 2px;
max-height : 400px;
box-sizing : border-box;
box-shadow : 0 0 1px 1px rgba(10, 10, 11, .125);
padding : 0.5rem;
color : #fff;
}
.notif--success {
background-color: #64ce83;
}
.notif--info {
background-color: #3ea2ff;
}
.notif--warning {
background-color: #ff7f48;
}
.notif--danger {
background-color: #e74c3c;
}
.notif__container {
position : fixed;
top : 10px;
right : 0;
left : 0;
z-index : 1000;
width : 80%;
max-width : 400px;
margin : auto;
}

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Jason Quense
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,91 @@
# dom-helpers
tiny modular DOM lib for ie8+
## Install
```sh
npm i -S dom-helpers
```
Mostly just naive wrappers around common DOM API inconsistencies, Cross browser work is minimal and mostly taken from jQuery. This library doesn't do a lot to normalize behavior across browsers, it mostly seeks to provide a common interface, and eliminate the need to write the same damn `if (ie8)` statements in every project.
For example `events.on` works in all browsers ie8+ but it uses the native event system so actual event oddities will continue to exist. If you need __robust__ cross-browser support, use jQuery. If you are just tired of rewriting:
```js
if (document.addEventListener)
return (node, eventName, handler, capture) =>
node.addEventListener(eventName, handler, capture || false);
else if (document.attachEvent)
return (node, eventName, handler) =>
node.attachEvent('on' + eventName, handler);
```
over and over again, or you need a ok `getComputedStyle` polyfill but don't want to include all of jQuery, use this.
dom-helpers does expect certain, polyfillable, es5 features to be present for which you can use `es5-shim` for ie8
The real advantage to this collection is that any method can be required individually, meaning tools like Browserify or webpack will only include the exact methods you use. This is great for environments where jQuery doesn't make sense, such as `React` where you only occasionally need to do direct DOM manipulation.
Each level of the module can be required as a whole or you can drill down for a specific method or section:
```js
var helpers = require('dom-helpers')
var query = require('dom-helpers/query')
var offset = require('dom-helpers/query/offset')
// style is a function
require('dom-helpers/style')(node, { width: '40px' })
//and a namespace
var gcs = require('dom-helpers/style/getComputedStyle')
```
- dom-helpers
- `ownerDocument(element)`: returns the element's document owner
- `ownerWindow(element)`: returns the element's document window
- `activeElement`: return focused element safely
- query
+ `querySelectorAll(element, selector)`: optimized qsa, uses `getElementBy{Id|TagName|ClassName}` if it can.
+ `contains(container, element)`
+ `height(element, useClientHeight)`
+ `width(element, useClientWidth)`
+ `matches(element, selector)`: `matches()` polyfill that works in ie8
+ `offset(element)` -> `{ top: Number, left: Number, height: Number, width: Number}`
+ `offsetParent(element)`: return the parent node that the element is offset from
+ `position(element, [offsetParent]`: return "offset" of the node to its offsetParent, optionally you can specify the offset parent if different than the "real" one
+ `scrollTop(element, [value])`
+ `scrollLeft(element, [value])`
+ `scrollParent(element)`
- class
- `addClass(element, className)`
- `removeClass(element, className)`
- `hasClass(element, className)`
- `style(element, propName, [value])` or `style(element, objectOfPropValues)`
+ `removeStyle(element, styleName)`
+ `getComputedStyle(element)` -> `getPropertyValue(name)`
- transition
+ `animate(node, properties, duration, easing, callback)` programmatically start css transitions
+ `end(node, handler, [duration])` listens for transition end, and ensures that the handler if called even if the transition fails to fire its end event. Will attempt to read duration from the element, otherwise one can be provided
+ `properties`: Object containing the various vendor specific transition and transform properties for your browser
```js
{
transform: // transform property: 'transform'
end: // transitionend
property: // transition-property
timing: // transition-timing
delay: // transition-delay
duration: // transition-duration
}
```
- events
+ `on(node, eventName, handler, [capture])`: capture is silently ignored in ie8
+ `off(node, eventName, handler, [capture])`: capture is silently ignored in ie8
+ `listen(node, eventName, handler, [capture])`: wraps `on` and returns a function that calls `off` for you
+ `filter(selector, fn)`: returns a function handler that only fires when the target matches or is contained in the selector ex: `events.on(list, 'click', events.filter('li > a', handler))`
- util
+ `requestAnimationFrame(cb)` returns an ID for canceling
* `requestAnimationFrame.cancel(id)`
+ `scrollbarSize([recalc])` returns the scrollbar's width size in pixels
+ `scrollTo(element, [scrollParent])`

View File

@@ -0,0 +1,22 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = activeElement;
var _ownerDocument = _interopRequireDefault(require("./ownerDocument"));
function activeElement(doc) {
if (doc === void 0) {
doc = (0, _ownerDocument.default)();
}
try {
return doc.activeElement;
} catch (e) {
/* ie throws if no active element */
}
}
module.exports = exports["default"];

View File

@@ -0,0 +1,14 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = addClass;
var _hasClass = _interopRequireDefault(require("./hasClass"));
function addClass(element, className) {
if (element.classList) element.classList.add(className);else if (!(0, _hasClass.default)(element, className)) if (typeof element.className === 'string') element.className = element.className + ' ' + className;else element.setAttribute('class', (element.className && element.className.baseVal || '') + ' ' + className);
}
module.exports = exports["default"];

View File

@@ -0,0 +1,10 @@
"use strict";
exports.__esModule = true;
exports.default = hasClass;
function hasClass(element, className) {
if (element.classList) return !!className && element.classList.contains(className);else return (" " + (element.className.baseVal || element.className) + " ").indexOf(" " + className + " ") !== -1;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,24 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _addClass = _interopRequireDefault(require("./addClass"));
exports.addClass = _addClass.default;
var _removeClass = _interopRequireDefault(require("./removeClass"));
exports.removeClass = _removeClass.default;
var _hasClass = _interopRequireDefault(require("./hasClass"));
exports.hasClass = _hasClass.default;
var _default = {
addClass: _addClass.default,
removeClass: _removeClass.default,
hasClass: _hasClass.default
};
exports.default = _default;

View File

@@ -0,0 +1,9 @@
'use strict';
function replaceClassName(origClass, classToRemove) {
return origClass.replace(new RegExp('(^|\\s)' + classToRemove + '(?:\\s|$)', 'g'), '$1').replace(/\s+/g, ' ').replace(/^\s*|\s*$/g, '');
}
module.exports = function removeClass(element, className) {
if (element.classList) element.classList.remove(className);else if (typeof element.className === 'string') element.className = replaceClassName(element.className, className);else element.setAttribute('class', replaceClassName(element.className && element.className.baseVal || '', className));
};

View File

@@ -0,0 +1,23 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = filterEvents;
var _contains = _interopRequireDefault(require("../query/contains"));
var _querySelectorAll = _interopRequireDefault(require("../query/querySelectorAll"));
function filterEvents(selector, handler) {
return function filterHandler(e) {
var top = e.currentTarget,
target = e.target,
matches = (0, _querySelectorAll.default)(top, selector);
if (matches.some(function (match) {
return (0, _contains.default)(match, target);
})) handler.call(this, e);
};
}
module.exports = exports["default"];

View File

@@ -0,0 +1,29 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _on = _interopRequireDefault(require("./on"));
exports.on = _on.default;
var _off = _interopRequireDefault(require("./off"));
exports.off = _off.default;
var _filter = _interopRequireDefault(require("./filter"));
exports.filter = _filter.default;
var _listen = _interopRequireDefault(require("./listen"));
exports.listen = _listen.default;
var _default = {
on: _on.default,
off: _off.default,
filter: _filter.default,
listen: _listen.default
};
exports.default = _default;

View File

@@ -0,0 +1,27 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _inDOM = _interopRequireDefault(require("../util/inDOM"));
var _on = _interopRequireDefault(require("./on"));
var _off = _interopRequireDefault(require("./off"));
var listen = function listen() {};
if (_inDOM.default) {
listen = function listen(node, eventName, handler, capture) {
(0, _on.default)(node, eventName, handler, capture);
return function () {
(0, _off.default)(node, eventName, handler, capture);
};
};
}
var _default = listen;
exports.default = _default;
module.exports = exports["default"];

View File

@@ -0,0 +1,24 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _inDOM = _interopRequireDefault(require("../util/inDOM"));
var off = function off() {};
if (_inDOM.default) {
off = function () {
if (document.addEventListener) return function (node, eventName, handler, capture) {
return node.removeEventListener(eventName, handler, capture || false);
};else if (document.attachEvent) return function (node, eventName, handler) {
return node.detachEvent('on' + eventName, handler);
};
}();
}
var _default = off;
exports.default = _default;
module.exports = exports["default"];

View File

@@ -0,0 +1,29 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _inDOM = _interopRequireDefault(require("../util/inDOM"));
var on = function on() {};
if (_inDOM.default) {
on = function () {
if (document.addEventListener) return function (node, eventName, handler, capture) {
return node.addEventListener(eventName, handler, capture || false);
};else if (document.attachEvent) return function (node, eventName, handler) {
return node.attachEvent('on' + eventName, function (e) {
e = e || window.event;
e.target = e.target || e.srcElement;
e.currentTarget = node;
handler.call(node, e);
});
};
}();
}
var _default = on;
exports.default = _default;
module.exports = exports["default"];

View File

@@ -0,0 +1,63 @@
'use strict';
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
var _exportNames = {
style: true,
activeElement: true,
ownerDocument: true,
ownerWindow: true,
requestAnimationFrame: true
};
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _style = _interopRequireDefault(require("./style"));
exports.style = _style.default;
var _events = _interopRequireWildcard(require("./events"));
Object.keys(_events).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
exports[key] = _events[key];
});
var _query = _interopRequireWildcard(require("./query"));
Object.keys(_query).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
exports[key] = _query[key];
});
var _activeElement = _interopRequireDefault(require("./activeElement"));
exports.activeElement = _activeElement.default;
var _ownerDocument = _interopRequireDefault(require("./ownerDocument"));
exports.ownerDocument = _ownerDocument.default;
var _ownerWindow = _interopRequireDefault(require("./ownerWindow"));
exports.ownerWindow = _ownerWindow.default;
var _requestAnimationFrame = _interopRequireDefault(require("./util/requestAnimationFrame"));
exports.requestAnimationFrame = _requestAnimationFrame.default;
var _default = (0, _extends2.default)({}, _events.default, _query.default, {
style: _style.default,
activeElement: _activeElement.default,
ownerDocument: _ownerDocument.default,
ownerWindow: _ownerWindow.default,
requestAnimationFrame: _requestAnimationFrame.default
});
exports.default = _default;

View File

@@ -0,0 +1,10 @@
"use strict";
exports.__esModule = true;
exports.default = ownerDocument;
function ownerDocument(node) {
return node && node.ownerDocument || document;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,15 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = ownerWindow;
var _ownerDocument = _interopRequireDefault(require("./ownerDocument"));
function ownerWindow(node) {
var doc = (0, _ownerDocument.default)(node);
return doc && doc.defaultView || doc.parentWindow;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,34 @@
{
"name": "dom-helpers",
"version": "3.4.0",
"description": "tiny modular DOM lib for ie8+",
"author": {
"name": "Jason Quense",
"email": "monastic.panic@gmail.com"
},
"repository": "jquense/dom-helpers",
"license": "MIT",
"main": "index.js",
"keywords": [
"dom-helpers",
"react-component",
"dom",
"api",
"cross-browser",
"style",
"event",
"height",
"width",
"dom-helpers",
"class",
"classlist",
"css"
],
"release": {
"publishDir": "lib",
"conventionalCommits": true
},
"dependencies": {
"@babel/runtime": "^7.1.2"
}
}

View File

@@ -0,0 +1,22 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = closest;
var _matches = _interopRequireDefault(require("./matches"));
var isDoc = function isDoc(obj) {
return obj != null && obj.nodeType === obj.DOCUMENT_NODE;
};
function closest(node, selector, context) {
while (node && (isDoc(node) || !(0, _matches.default)(node, selector))) {
node = node !== context && !isDoc(node) ? node.parentNode : undefined;
}
return node;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,33 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _inDOM = _interopRequireDefault(require("../util/inDOM"));
var _default = function () {
// HTML DOM and SVG DOM may have different support levels,
// so we need to check on context instead of a document root element.
return _inDOM.default ? function (context, node) {
if (context.contains) {
return context.contains(node);
} else if (context.compareDocumentPosition) {
return context === node || !!(context.compareDocumentPosition(node) & 16);
} else {
return fallback(context, node);
}
} : fallback;
}();
exports.default = _default;
function fallback(context, node) {
if (node) do {
if (node === context) return true;
} while (node = node.parentNode);
return false;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,17 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = height;
var _offset = _interopRequireDefault(require("./offset"));
var _isWindow = _interopRequireDefault(require("./isWindow"));
function height(node, client) {
var win = (0, _isWindow.default)(node);
return win ? win.innerHeight : client ? node.clientHeight : (0, _offset.default)(node).height;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,64 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _matches = _interopRequireDefault(require("./matches"));
exports.matches = _matches.default;
var _height = _interopRequireDefault(require("./height"));
exports.height = _height.default;
var _width = _interopRequireDefault(require("./width"));
exports.width = _width.default;
var _offset = _interopRequireDefault(require("./offset"));
exports.offset = _offset.default;
var _offsetParent = _interopRequireDefault(require("./offsetParent"));
exports.offsetParent = _offsetParent.default;
var _position = _interopRequireDefault(require("./position"));
exports.position = _position.default;
var _contains = _interopRequireDefault(require("./contains"));
exports.contains = _contains.default;
var _scrollParent = _interopRequireDefault(require("./scrollParent"));
exports.scrollParent = _scrollParent.default;
var _scrollTop = _interopRequireDefault(require("./scrollTop"));
exports.scrollTop = _scrollTop.default;
var _querySelectorAll = _interopRequireDefault(require("./querySelectorAll"));
exports.querySelectorAll = _querySelectorAll.default;
var _closest = _interopRequireDefault(require("./closest"));
exports.closest = _closest.default;
var _default = {
matches: _matches.default,
height: _height.default,
width: _width.default,
offset: _offset.default,
offsetParent: _offsetParent.default,
position: _position.default,
contains: _contains.default,
scrollParent: _scrollParent.default,
scrollTop: _scrollTop.default,
querySelectorAll: _querySelectorAll.default,
closest: _closest.default
};
exports.default = _default;

View File

@@ -0,0 +1,10 @@
"use strict";
exports.__esModule = true;
exports.default = getWindow;
function getWindow(node) {
return node === node.window ? node : node.nodeType === 9 ? node.defaultView || node.parentWindow : false;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,37 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = matches;
var _inDOM = _interopRequireDefault(require("../util/inDOM"));
var _querySelectorAll = _interopRequireDefault(require("./querySelectorAll"));
var matchesCache;
function matches(node, selector) {
if (!matchesCache && _inDOM.default) {
var body = document.body;
var nativeMatch = body.matches || body.matchesSelector || body.webkitMatchesSelector || body.mozMatchesSelector || body.msMatchesSelector;
matchesCache = nativeMatch ? function (node, selector) {
return nativeMatch.call(node, selector);
} : ie8MatchesSelector;
}
return matchesCache ? matchesCache(node, selector) : null;
}
function ie8MatchesSelector(node, selector) {
var matches = (0, _querySelectorAll.default)(node.document || node.ownerDocument, selector),
i = 0;
while (matches[i] && matches[i] !== node) {
i++;
}
return !!matches[i];
}
module.exports = exports["default"];

View File

@@ -0,0 +1,38 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = offset;
var _contains = _interopRequireDefault(require("./contains"));
var _isWindow = _interopRequireDefault(require("./isWindow"));
var _ownerDocument = _interopRequireDefault(require("../ownerDocument"));
function offset(node) {
var doc = (0, _ownerDocument.default)(node),
win = (0, _isWindow.default)(doc),
docElem = doc && doc.documentElement,
box = {
top: 0,
left: 0,
height: 0,
width: 0
};
if (!doc) return; // Make sure it's not a disconnected DOM node
if (!(0, _contains.default)(docElem, node)) return box;
if (node.getBoundingClientRect !== undefined) box = node.getBoundingClientRect(); // IE8 getBoundingClientRect doesn't support width & height
box = {
top: box.top + (win.pageYOffset || docElem.scrollTop) - (docElem.clientTop || 0),
left: box.left + (win.pageXOffset || docElem.scrollLeft) - (docElem.clientLeft || 0),
width: (box.width == null ? node.offsetWidth : box.width) || 0,
height: (box.height == null ? node.offsetHeight : box.height) || 0
};
return box;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,27 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = offsetParent;
var _ownerDocument = _interopRequireDefault(require("../ownerDocument"));
var _style = _interopRequireDefault(require("../style"));
function nodeName(node) {
return node.nodeName && node.nodeName.toLowerCase();
}
function offsetParent(node) {
var doc = (0, _ownerDocument.default)(node),
offsetParent = node && node.offsetParent;
while (offsetParent && nodeName(node) !== 'html' && (0, _style.default)(offsetParent, 'position') === 'static') {
offsetParent = offsetParent.offsetParent;
}
return offsetParent || doc.documentElement;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,49 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = position;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _offset = _interopRequireDefault(require("./offset"));
var _offsetParent = _interopRequireDefault(require("./offsetParent"));
var _scrollTop = _interopRequireDefault(require("./scrollTop"));
var _scrollLeft = _interopRequireDefault(require("./scrollLeft"));
var _style = _interopRequireDefault(require("../style"));
function nodeName(node) {
return node.nodeName && node.nodeName.toLowerCase();
}
function position(node, offsetParent) {
var parentOffset = {
top: 0,
left: 0
},
offset; // Fixed elements are offset from window (parentOffset = {top:0, left: 0},
// because it is its only offset parent
if ((0, _style.default)(node, 'position') === 'fixed') {
offset = node.getBoundingClientRect();
} else {
offsetParent = offsetParent || (0, _offsetParent.default)(node);
offset = (0, _offset.default)(node);
if (nodeName(offsetParent) !== 'html') parentOffset = (0, _offset.default)(offsetParent);
parentOffset.top += parseInt((0, _style.default)(offsetParent, 'borderTopWidth'), 10) - (0, _scrollTop.default)(offsetParent) || 0;
parentOffset.left += parseInt((0, _style.default)(offsetParent, 'borderLeftWidth'), 10) - (0, _scrollLeft.default)(offsetParent) || 0;
} // Subtract parent offsets and node margins
return (0, _extends2.default)({}, offset, {
top: offset.top - parentOffset.top - (parseInt((0, _style.default)(node, 'marginTop'), 10) || 0),
left: offset.left - parentOffset.left - (parseInt((0, _style.default)(node, 'marginLeft'), 10) || 0)
});
}
module.exports = exports["default"];

View File

@@ -0,0 +1,31 @@
"use strict";
exports.__esModule = true;
exports.default = qsa;
// Zepto.js
// (c) 2010-2015 Thomas Fuchs
// Zepto.js may be freely distributed under the MIT license.
var simpleSelectorRE = /^[\w-]*$/;
var toArray = Function.prototype.bind.call(Function.prototype.call, [].slice);
function qsa(element, selector) {
var maybeID = selector[0] === '#',
maybeClass = selector[0] === '.',
nameOnly = maybeID || maybeClass ? selector.slice(1) : selector,
isSimple = simpleSelectorRE.test(nameOnly),
found;
if (isSimple) {
if (maybeID) {
element = element.getElementById ? element : document;
return (found = element.getElementById(nameOnly)) ? [found] : [];
}
if (element.getElementsByClassName && maybeClass) return toArray(element.getElementsByClassName(nameOnly));
return toArray(element.getElementsByTagName(selector));
}
return toArray(element.querySelectorAll(selector));
}
module.exports = exports["default"];

View File

@@ -0,0 +1,16 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = scrollTop;
var _isWindow = _interopRequireDefault(require("./isWindow"));
function scrollTop(node, val) {
var win = (0, _isWindow.default)(node);
if (val === undefined) return win ? 'pageXOffset' in win ? win.pageXOffset : win.document.documentElement.scrollLeft : node.scrollLeft;
if (win) win.scrollTo(val, 'pageYOffset' in win ? win.pageYOffset : win.document.documentElement.scrollTop);else node.scrollLeft = val;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,28 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = scrollPrarent;
var _style = _interopRequireDefault(require("../style"));
var _height = _interopRequireDefault(require("./height"));
function scrollPrarent(node) {
var position = (0, _style.default)(node, 'position'),
excludeStatic = position === 'absolute',
ownerDoc = node.ownerDocument;
if (position === 'fixed') return ownerDoc || document;
while ((node = node.parentNode) && node.nodeType !== 9) {
var isStatic = excludeStatic && (0, _style.default)(node, 'position') === 'static',
style = (0, _style.default)(node, 'overflow') + (0, _style.default)(node, 'overflow-y') + (0, _style.default)(node, 'overflow-x');
if (isStatic) continue;
if (/(auto|scroll)/.test(style) && (0, _height.default)(node) < node.scrollHeight) return node;
}
return document;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,16 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = scrollTop;
var _isWindow = _interopRequireDefault(require("./isWindow"));
function scrollTop(node, val) {
var win = (0, _isWindow.default)(node);
if (val === undefined) return win ? 'pageYOffset' in win ? win.pageYOffset : win.document.documentElement.scrollTop : node.scrollTop;
if (win) win.scrollTo('pageXOffset' in win ? win.pageXOffset : win.document.documentElement.scrollLeft, val);else node.scrollTop = val;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,17 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = width;
var _offset = _interopRequireDefault(require("./offset"));
var _isWindow = _interopRequireDefault(require("./isWindow"));
function width(node, client) {
var win = (0, _isWindow.default)(node);
return win ? win.innerWidth : client ? node.clientWidth : (0, _offset.default)(node).width;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,44 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = _getComputedStyle;
var _camelizeStyle = _interopRequireDefault(require("../util/camelizeStyle"));
var rposition = /^(top|right|bottom|left)$/;
var rnumnonpx = /^([+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|))(?!px)[a-z%]+$/i;
function _getComputedStyle(node) {
if (!node) throw new TypeError('No Element passed to `getComputedStyle()`');
var doc = node.ownerDocument;
return 'defaultView' in doc ? doc.defaultView.opener ? node.ownerDocument.defaultView.getComputedStyle(node, null) : window.getComputedStyle(node, null) : {
//ie 8 "magic" from: https://github.com/jquery/jquery/blob/1.11-stable/src/css/curCSS.js#L72
getPropertyValue: function getPropertyValue(prop) {
var style = node.style;
prop = (0, _camelizeStyle.default)(prop);
if (prop == 'float') prop = 'styleFloat';
var current = node.currentStyle[prop] || null;
if (current == null && style && style[prop]) current = style[prop];
if (rnumnonpx.test(current) && !rposition.test(prop)) {
// Remember the original values
var left = style.left;
var runStyle = node.runtimeStyle;
var rsLeft = runStyle && runStyle.left; // Put in the new values to get a computed value out
if (rsLeft) runStyle.left = node.currentStyle.left;
style.left = prop === 'fontSize' ? '1em' : current;
current = style.pixelLeft + 'px'; // Revert the changed values
style.left = left;
if (rsLeft) runStyle.left = rsLeft;
}
return current;
}
};
}
module.exports = exports["default"];

View File

@@ -0,0 +1,52 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = style;
var _camelizeStyle = _interopRequireDefault(require("../util/camelizeStyle"));
var _hyphenateStyle = _interopRequireDefault(require("../util/hyphenateStyle"));
var _getComputedStyle2 = _interopRequireDefault(require("./getComputedStyle"));
var _removeStyle = _interopRequireDefault(require("./removeStyle"));
var _properties = require("../transition/properties");
var _isTransform = _interopRequireDefault(require("../transition/isTransform"));
function style(node, property, value) {
var css = '';
var transforms = '';
var props = property;
if (typeof property === 'string') {
if (value === undefined) {
return node.style[(0, _camelizeStyle.default)(property)] || (0, _getComputedStyle2.default)(node).getPropertyValue((0, _hyphenateStyle.default)(property));
} else {
(props = {})[property] = value;
}
}
Object.keys(props).forEach(function (key) {
var value = props[key];
if (!value && value !== 0) {
(0, _removeStyle.default)(node, (0, _hyphenateStyle.default)(key));
} else if ((0, _isTransform.default)(key)) {
transforms += key + "(" + value + ") ";
} else {
css += (0, _hyphenateStyle.default)(key) + ": " + value + ";";
}
});
if (transforms) {
css += _properties.transform + ": " + transforms + ";";
}
node.style.cssText += ';' + css;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,10 @@
"use strict";
exports.__esModule = true;
exports.default = removeStyle;
function removeStyle(node, key) {
return 'removeProperty' in node.style ? node.style.removeProperty(key) : node.style.removeAttribute(key);
}
module.exports = exports["default"];

View File

@@ -0,0 +1,111 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _hyphenate = _interopRequireDefault(require("../util/hyphenate"));
var _style = _interopRequireDefault(require("../style"));
var _on = _interopRequireDefault(require("../events/on"));
var _off = _interopRequireDefault(require("../events/off"));
var _properties = _interopRequireDefault(require("./properties"));
var _isTransform = _interopRequireDefault(require("./isTransform"));
var reset = {};
reset[_properties.default.property] = reset[_properties.default.duration] = reset[_properties.default.delay] = reset[_properties.default.timing] = ''; // super lean animate function for transitions
// doesn't support all translations to keep it matching the jquery API
/**
* code in part from: Zepto 1.1.4 | zeptojs.com/license
*/
function _animate(_ref) {
var node = _ref.node,
properties = _ref.properties,
_ref$duration = _ref.duration,
duration = _ref$duration === void 0 ? 200 : _ref$duration,
easing = _ref.easing,
callback = _ref.callback;
var cssProperties = [],
fakeEvent = {
target: node,
currentTarget: node
},
cssValues = {},
transforms = '',
fired;
if (!_properties.default.end) duration = 0;
Object.keys(properties).forEach(function (key) {
if ((0, _isTransform.default)(key)) transforms += key + "(" + properties[key] + ") ";else {
cssValues[key] = properties[key];
cssProperties.push((0, _hyphenate.default)(key));
}
});
if (transforms) {
cssValues[_properties.default.transform] = transforms;
cssProperties.push(_properties.default.transform);
}
if (duration > 0) {
cssValues[_properties.default.property] = cssProperties.join(', ');
cssValues[_properties.default.duration] = duration / 1000 + 's';
cssValues[_properties.default.delay] = 0 + 's';
cssValues[_properties.default.timing] = easing || 'linear';
(0, _on.default)(node, _properties.default.end, done);
setTimeout(function () {
if (!fired) done(fakeEvent);
}, duration + 500);
} //eslint-disable-next-line no-unused-expressions
node.clientLeft; // trigger page reflow
(0, _style.default)(node, cssValues);
if (duration <= 0) setTimeout(done.bind(null, fakeEvent), 0);
return {
cancel: function cancel() {
if (fired) return;
fired = true;
(0, _off.default)(node, _properties.default.end, done);
(0, _style.default)(node, reset);
}
};
function done(event) {
if (event.target !== event.currentTarget) return;
fired = true;
(0, _off.default)(event.target, _properties.default.end, done);
(0, _style.default)(node, reset);
callback && callback.call(this);
}
}
function animate(node, properties, duration, easing, callback) {
if (arguments.length === 1 && typeof node === 'object') {
return _animate(node);
}
if (typeof easing === 'function') {
callback = easing;
easing = null;
}
return _animate({
node: node,
properties: properties,
duration: duration,
easing: easing,
callback: callback
});
}
var _default = animate;
exports.default = _default;
module.exports = exports["default"];

View File

@@ -0,0 +1,45 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _properties = _interopRequireDefault(require("./properties"));
var _style = _interopRequireDefault(require("../style"));
function onEnd(node, handler, duration) {
var fakeEvent = {
target: node,
currentTarget: node
},
backup;
if (!_properties.default.end) duration = 0;else if (duration == null) duration = parseDuration(node) || 0;
if (_properties.default.end) {
node.addEventListener(_properties.default.end, done, false);
backup = setTimeout(function () {
return done(fakeEvent);
}, (duration || 100) * 1.5);
} else setTimeout(done.bind(null, fakeEvent), 0);
function done(event) {
if (event.target !== event.currentTarget) return;
clearTimeout(backup);
event.target.removeEventListener(_properties.default.end, done);
handler.call(this);
}
}
onEnd._parseDuration = parseDuration;
var _default = onEnd;
exports.default = _default;
function parseDuration(node) {
var str = (0, _style.default)(node, _properties.default.duration),
mult = str.indexOf('ms') === -1 ? 1000 : 1;
return parseFloat(str) * mult;
}
module.exports = exports["default"];

View File

@@ -0,0 +1,19 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _end = _interopRequireDefault(require("./end"));
exports.end = _end.default;
var _properties = _interopRequireDefault(require("./properties"));
exports.properties = _properties.default;
var _default = {
end: _end.default,
properties: _properties.default
};
exports.default = _default;

View File

@@ -0,0 +1,11 @@
"use strict";
exports.__esModule = true;
exports.default = isTransform;
var supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i;
function isTransform(property) {
return !!(property && supportedTransforms.test(property));
}
module.exports = exports["default"];

View File

@@ -0,0 +1,92 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = exports.animationEnd = exports.animationDelay = exports.animationTiming = exports.animationDuration = exports.animationName = exports.transitionEnd = exports.transitionDuration = exports.transitionDelay = exports.transitionTiming = exports.transitionProperty = exports.transform = void 0;
var _inDOM = _interopRequireDefault(require("../util/inDOM"));
var transform = 'transform';
exports.transform = transform;
var prefix, transitionEnd, animationEnd;
exports.animationEnd = animationEnd;
exports.transitionEnd = transitionEnd;
var transitionProperty, transitionDuration, transitionTiming, transitionDelay;
exports.transitionDelay = transitionDelay;
exports.transitionTiming = transitionTiming;
exports.transitionDuration = transitionDuration;
exports.transitionProperty = transitionProperty;
var animationName, animationDuration, animationTiming, animationDelay;
exports.animationDelay = animationDelay;
exports.animationTiming = animationTiming;
exports.animationDuration = animationDuration;
exports.animationName = animationName;
if (_inDOM.default) {
var _getTransitionPropert = getTransitionProperties();
prefix = _getTransitionPropert.prefix;
exports.transitionEnd = transitionEnd = _getTransitionPropert.transitionEnd;
exports.animationEnd = animationEnd = _getTransitionPropert.animationEnd;
exports.transform = transform = prefix + "-" + transform;
exports.transitionProperty = transitionProperty = prefix + "-transition-property";
exports.transitionDuration = transitionDuration = prefix + "-transition-duration";
exports.transitionDelay = transitionDelay = prefix + "-transition-delay";
exports.transitionTiming = transitionTiming = prefix + "-transition-timing-function";
exports.animationName = animationName = prefix + "-animation-name";
exports.animationDuration = animationDuration = prefix + "-animation-duration";
exports.animationTiming = animationTiming = prefix + "-animation-delay";
exports.animationDelay = animationDelay = prefix + "-animation-timing-function";
}
var _default = {
transform: transform,
end: transitionEnd,
property: transitionProperty,
timing: transitionTiming,
delay: transitionDelay,
duration: transitionDuration
};
exports.default = _default;
function getTransitionProperties() {
var style = document.createElement('div').style;
var vendorMap = {
O: function O(e) {
return "o" + e.toLowerCase();
},
Moz: function Moz(e) {
return e.toLowerCase();
},
Webkit: function Webkit(e) {
return "webkit" + e;
},
ms: function ms(e) {
return "MS" + e;
}
};
var vendors = Object.keys(vendorMap);
var transitionEnd, animationEnd;
var prefix = '';
for (var i = 0; i < vendors.length; i++) {
var vendor = vendors[i];
if (vendor + "TransitionProperty" in style) {
prefix = "-" + vendor.toLowerCase();
transitionEnd = vendorMap[vendor]('TransitionEnd');
animationEnd = vendorMap[vendor]('AnimationEnd');
break;
}
}
if (!transitionEnd && 'transitionProperty' in style) transitionEnd = 'transitionend';
if (!animationEnd && 'animationName' in style) animationEnd = 'animationend';
style = null;
return {
animationEnd: animationEnd,
transitionEnd: transitionEnd,
prefix: prefix
};
}

View File

@@ -0,0 +1,13 @@
"use strict";
exports.__esModule = true;
exports.default = camelize;
var rHyphen = /-(.)/g;
function camelize(string) {
return string.replace(rHyphen, function (_, chr) {
return chr.toUpperCase();
});
}
module.exports = exports["default"];

View File

@@ -0,0 +1,21 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = camelizeStyleName;
var _camelize = _interopRequireDefault(require("./camelize"));
/**
* Copyright 2014-2015, Facebook, Inc.
* All rights reserved.
* https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/camelizeStyleName.js
*/
var msPattern = /^-ms-/;
function camelizeStyleName(string) {
return (0, _camelize.default)(string.replace(msPattern, 'ms-'));
}
module.exports = exports["default"];

View File

@@ -0,0 +1,11 @@
"use strict";
exports.__esModule = true;
exports.default = hyphenate;
var rUpper = /([A-Z])/g;
function hyphenate(string) {
return string.replace(rUpper, '-$1').toLowerCase();
}
module.exports = exports["default"];

View File

@@ -0,0 +1,21 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = hyphenateStyleName;
var _hyphenate = _interopRequireDefault(require("./hyphenate"));
/**
* Copyright 2013-2014, Facebook, Inc.
* All rights reserved.
* https://github.com/facebook/react/blob/2aeb8a2a6beb00617a4217f7f8284924fa2ad819/src/vendor/core/hyphenateStyleName.js
*/
var msPattern = /^ms-/;
function hyphenateStyleName(string) {
return (0, _hyphenate.default)(string).replace(msPattern, '-ms-');
}
module.exports = exports["default"];

View File

@@ -0,0 +1,9 @@
"use strict";
exports.__esModule = true;
exports.default = void 0;
var _default = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
exports.default = _default;
module.exports = exports["default"];

View File

@@ -0,0 +1,54 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _inDOM = _interopRequireDefault(require("./inDOM"));
var vendors = ['', 'webkit', 'moz', 'o', 'ms'];
var cancel = 'clearTimeout';
var raf = fallback;
var compatRaf;
var getKey = function getKey(vendor, k) {
return vendor + (!vendor ? k : k[0].toUpperCase() + k.substr(1)) + 'AnimationFrame';
};
if (_inDOM.default) {
vendors.some(function (vendor) {
var rafKey = getKey(vendor, 'request');
if (rafKey in window) {
cancel = getKey(vendor, 'cancel');
return raf = function raf(cb) {
return window[rafKey](cb);
};
}
});
}
/* https://github.com/component/raf */
var prev = new Date().getTime();
function fallback(fn) {
var curr = new Date().getTime(),
ms = Math.max(0, 16 - (curr - prev)),
req = setTimeout(fn, ms);
prev = curr;
return req;
}
compatRaf = function compatRaf(cb) {
return raf(cb);
};
compatRaf.cancel = function (id) {
window[cancel] && typeof window[cancel] === 'function' && window[cancel](id);
};
var _default = compatRaf;
exports.default = _default;
module.exports = exports["default"];

View File

@@ -0,0 +1,53 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = scrollTo;
var _offset = _interopRequireDefault(require("../query/offset"));
var _height = _interopRequireDefault(require("../query/height"));
var _scrollParent = _interopRequireDefault(require("../query/scrollParent"));
var _scrollTop = _interopRequireDefault(require("../query/scrollTop"));
var _requestAnimationFrame = _interopRequireDefault(require("./requestAnimationFrame"));
var _isWindow = _interopRequireDefault(require("../query/isWindow"));
function scrollTo(selected, scrollParent) {
var offset = (0, _offset.default)(selected);
var poff = {
top: 0,
left: 0
};
var list, listScrollTop, selectedTop, isWin;
var selectedHeight, listHeight, bottom;
if (!selected) return;
list = scrollParent || (0, _scrollParent.default)(selected);
isWin = (0, _isWindow.default)(list);
listScrollTop = (0, _scrollTop.default)(list);
listHeight = (0, _height.default)(list, true);
isWin = (0, _isWindow.default)(list);
if (!isWin) poff = (0, _offset.default)(list);
offset = {
top: offset.top - poff.top,
left: offset.left - poff.left,
height: offset.height,
width: offset.width
};
selectedHeight = offset.height;
selectedTop = offset.top + (isWin ? 0 : listScrollTop);
bottom = selectedTop + selectedHeight;
listScrollTop = listScrollTop > selectedTop ? selectedTop : bottom > listScrollTop + listHeight ? bottom - listHeight : listScrollTop;
var id = (0, _requestAnimationFrame.default)(function () {
return (0, _scrollTop.default)(list, listScrollTop);
});
return function () {
return _requestAnimationFrame.default.cancel(id);
};
}
module.exports = exports["default"];

View File

@@ -0,0 +1,30 @@
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = scrollbarSize;
var _inDOM = _interopRequireDefault(require("./inDOM"));
var size;
function scrollbarSize(recalc) {
if (!size && size !== 0 || recalc) {
if (_inDOM.default) {
var scrollDiv = document.createElement('div');
scrollDiv.style.position = 'absolute';
scrollDiv.style.top = '-9999px';
scrollDiv.style.width = '50px';
scrollDiv.style.height = '50px';
scrollDiv.style.overflow = 'scroll';
document.body.appendChild(scrollDiv);
size = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
}
}
return size;
}
module.exports = exports["default"];

View File

@@ -0,0 +1 @@
All notable changes are described on the [Releases](https://github.com/reactjs/react-redux/releases) page.

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Dan Abramov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,45 @@
React Redux
=========================
Official React bindings for [Redux](https://github.com/reactjs/redux).
Performant and flexible.
[![build status](https://img.shields.io/travis/reactjs/react-redux/master.svg?style=flat-square)](https://travis-ci.org/reactjs/react-redux) [![npm version](https://img.shields.io/npm/v/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux)
[![npm downloads](https://img.shields.io/npm/dm/react-redux.svg?style=flat-square)](https://www.npmjs.com/package/react-redux)
[![redux channel on slack](https://img.shields.io/badge/slack-redux@reactiflux-61DAFB.svg?style=flat-square)](http://www.reactiflux.com)
## Installation
React Redux requires **React 0.14 or later.**
```
npm install --save react-redux
```
This assumes that youre using [npm](http://npmjs.com/) package manager with a module bundler like [Webpack](http://webpack.github.io) or [Browserify](http://browserify.org/) to consume [CommonJS modules](http://webpack.github.io/docs/commonjs.html).
If you dont yet use [npm](http://npmjs.com/) or a modern module bundler, and would rather prefer a single-file [UMD](https://github.com/umdjs/umd) build that makes `ReactRedux` available as a global object, you can grab a pre-built version from [cdnjs](https://cdnjs.com/libraries/react-redux). We *dont* recommend this approach for any serious application, as most of the libraries complementary to Redux are only available on [npm](http://npmjs.com/).
## React Native
As of React Native 0.18, React Redux 4.x should work with React Native. If you have any issues with React Redux 4.x on React Native, run `npm ls react` and make sure you dont have a duplicate React installation in your `node_modules`. We recommend that you use `npm@3.x` which is better at avoiding these kinds of issues.
If you are on an older version of React Native, youll need to keep using [React Redux 3.x branch and documentation](https://github.com/reactjs/react-redux/tree/v3.1.0) because of [this problem](https://github.com/facebook/react-native/issues/2985).
## Documentation
- [Redux: Usage with React](http://redux.js.org/docs/basics/UsageWithReact.html)
- [API](docs/api.md#api)
- [`<Provider store>`](docs/api.md#provider-store)
- [`connect([mapStateToProps], [mapDispatchToProps], [mergeProps], [options])`](docs/api.md#connectmapstatetoprops-mapdispatchtoprops-mergeprops-options)
- [Troubleshooting](docs/troubleshooting.md#troubleshooting)
## How Does It Work?
We do a deep dive on how React Redux works in [this readthesource episode](https://www.youtube.com/watch?v=VJ38wSFbM3A).
Enjoy!
## License
MIT

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,82 @@
'use strict';
exports.__esModule = true;
exports["default"] = undefined;
var _react = require('react');
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _storeShape = require('../utils/storeShape');
var _storeShape2 = _interopRequireDefault(_storeShape);
var _warning = require('../utils/warning');
var _warning2 = _interopRequireDefault(_warning);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var didWarnAboutReceivingStore = false;
function warnAboutReceivingStore() {
if (didWarnAboutReceivingStore) {
return;
}
didWarnAboutReceivingStore = true;
(0, _warning2["default"])('<Provider> does not support changing `store` on the fly. ' + 'It is most likely that you see this error because you updated to ' + 'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' + 'automatically. See https://github.com/reactjs/react-redux/releases/' + 'tag/v2.0.0 for the migration instructions.');
}
var Provider = function (_Component) {
_inherits(Provider, _Component);
Provider.prototype.getChildContext = function getChildContext() {
return { store: this.store };
};
function Provider(props, context) {
_classCallCheck(this, Provider);
var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
_this.store = props.store;
return _this;
}
Provider.prototype.render = function render() {
return _react.Children.only(this.props.children);
};
return Provider;
}(_react.Component);
exports["default"] = Provider;
if (process.env.NODE_ENV !== 'production') {
Provider.prototype.componentWillReceiveProps = function (nextProps) {
var store = this.store;
var nextStore = nextProps.store;
if (store !== nextStore) {
warnAboutReceivingStore();
}
};
}
Provider.propTypes = {
store: _storeShape2["default"].isRequired,
children: _propTypes2["default"].element.isRequired
};
Provider.childContextTypes = {
store: _storeShape2["default"].isRequired
};

View File

@@ -0,0 +1,395 @@
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports["default"] = connect;
var _react = require('react');
var _storeShape = require('../utils/storeShape');
var _storeShape2 = _interopRequireDefault(_storeShape);
var _shallowEqual = require('../utils/shallowEqual');
var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
var _wrapActionCreators = require('../utils/wrapActionCreators');
var _wrapActionCreators2 = _interopRequireDefault(_wrapActionCreators);
var _warning = require('../utils/warning');
var _warning2 = _interopRequireDefault(_warning);
var _isPlainObject = require('lodash/isPlainObject');
var _isPlainObject2 = _interopRequireDefault(_isPlainObject);
var _hoistNonReactStatics = require('hoist-non-react-statics');
var _hoistNonReactStatics2 = _interopRequireDefault(_hoistNonReactStatics);
var _invariant = require('invariant');
var _invariant2 = _interopRequireDefault(_invariant);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var defaultMapStateToProps = function defaultMapStateToProps(state) {
return {};
}; // eslint-disable-line no-unused-vars
var defaultMapDispatchToProps = function defaultMapDispatchToProps(dispatch) {
return { dispatch: dispatch };
};
var defaultMergeProps = function defaultMergeProps(stateProps, dispatchProps, parentProps) {
return _extends({}, parentProps, stateProps, dispatchProps);
};
function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
}
var errorObject = { value: null };
function tryCatch(fn, ctx) {
try {
return fn.apply(ctx);
} catch (e) {
errorObject.value = e;
return errorObject;
}
}
// Helps track hot reloading.
var nextVersion = 0;
function connect(mapStateToProps, mapDispatchToProps, mergeProps) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var shouldSubscribe = Boolean(mapStateToProps);
var mapState = mapStateToProps || defaultMapStateToProps;
var mapDispatch = void 0;
if (typeof mapDispatchToProps === 'function') {
mapDispatch = mapDispatchToProps;
} else if (!mapDispatchToProps) {
mapDispatch = defaultMapDispatchToProps;
} else {
mapDispatch = (0, _wrapActionCreators2["default"])(mapDispatchToProps);
}
var finalMergeProps = mergeProps || defaultMergeProps;
var _options$pure = options.pure,
pure = _options$pure === undefined ? true : _options$pure,
_options$withRef = options.withRef,
withRef = _options$withRef === undefined ? false : _options$withRef;
var checkMergedEquals = pure && finalMergeProps !== defaultMergeProps;
// Helps track hot reloading.
var version = nextVersion++;
return function wrapWithConnect(WrappedComponent) {
var connectDisplayName = 'Connect(' + getDisplayName(WrappedComponent) + ')';
function checkStateShape(props, methodName) {
if (!(0, _isPlainObject2["default"])(props)) {
(0, _warning2["default"])(methodName + '() in ' + connectDisplayName + ' must return a plain object. ' + ('Instead received ' + props + '.'));
}
}
function computeMergedProps(stateProps, dispatchProps, parentProps) {
var mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps);
if (process.env.NODE_ENV !== 'production') {
checkStateShape(mergedProps, 'mergeProps');
}
return mergedProps;
}
var Connect = function (_Component) {
_inherits(Connect, _Component);
Connect.prototype.shouldComponentUpdate = function shouldComponentUpdate() {
return !pure || this.haveOwnPropsChanged || this.hasStoreStateChanged;
};
function Connect(props, context) {
_classCallCheck(this, Connect);
var _this = _possibleConstructorReturn(this, _Component.call(this, props, context));
_this.version = version;
_this.store = props.store || context.store;
(0, _invariant2["default"])(_this.store, 'Could not find "store" in either the context or ' + ('props of "' + connectDisplayName + '". ') + 'Either wrap the root component in a <Provider>, ' + ('or explicitly pass "store" as a prop to "' + connectDisplayName + '".'));
var storeState = _this.store.getState();
_this.state = { storeState: storeState };
_this.clearCache();
return _this;
}
Connect.prototype.computeStateProps = function computeStateProps(store, props) {
if (!this.finalMapStateToProps) {
return this.configureFinalMapState(store, props);
}
var state = store.getState();
var stateProps = this.doStatePropsDependOnOwnProps ? this.finalMapStateToProps(state, props) : this.finalMapStateToProps(state);
if (process.env.NODE_ENV !== 'production') {
checkStateShape(stateProps, 'mapStateToProps');
}
return stateProps;
};
Connect.prototype.configureFinalMapState = function configureFinalMapState(store, props) {
var mappedState = mapState(store.getState(), props);
var isFactory = typeof mappedState === 'function';
this.finalMapStateToProps = isFactory ? mappedState : mapState;
this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1;
if (isFactory) {
return this.computeStateProps(store, props);
}
if (process.env.NODE_ENV !== 'production') {
checkStateShape(mappedState, 'mapStateToProps');
}
return mappedState;
};
Connect.prototype.computeDispatchProps = function computeDispatchProps(store, props) {
if (!this.finalMapDispatchToProps) {
return this.configureFinalMapDispatch(store, props);
}
var dispatch = store.dispatch;
var dispatchProps = this.doDispatchPropsDependOnOwnProps ? this.finalMapDispatchToProps(dispatch, props) : this.finalMapDispatchToProps(dispatch);
if (process.env.NODE_ENV !== 'production') {
checkStateShape(dispatchProps, 'mapDispatchToProps');
}
return dispatchProps;
};
Connect.prototype.configureFinalMapDispatch = function configureFinalMapDispatch(store, props) {
var mappedDispatch = mapDispatch(store.dispatch, props);
var isFactory = typeof mappedDispatch === 'function';
this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch;
this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1;
if (isFactory) {
return this.computeDispatchProps(store, props);
}
if (process.env.NODE_ENV !== 'production') {
checkStateShape(mappedDispatch, 'mapDispatchToProps');
}
return mappedDispatch;
};
Connect.prototype.updateStatePropsIfNeeded = function updateStatePropsIfNeeded() {
var nextStateProps = this.computeStateProps(this.store, this.props);
if (this.stateProps && (0, _shallowEqual2["default"])(nextStateProps, this.stateProps)) {
return false;
}
this.stateProps = nextStateProps;
return true;
};
Connect.prototype.updateDispatchPropsIfNeeded = function updateDispatchPropsIfNeeded() {
var nextDispatchProps = this.computeDispatchProps(this.store, this.props);
if (this.dispatchProps && (0, _shallowEqual2["default"])(nextDispatchProps, this.dispatchProps)) {
return false;
}
this.dispatchProps = nextDispatchProps;
return true;
};
Connect.prototype.updateMergedPropsIfNeeded = function updateMergedPropsIfNeeded() {
var nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props);
if (this.mergedProps && checkMergedEquals && (0, _shallowEqual2["default"])(nextMergedProps, this.mergedProps)) {
return false;
}
this.mergedProps = nextMergedProps;
return true;
};
Connect.prototype.isSubscribed = function isSubscribed() {
return typeof this.unsubscribe === 'function';
};
Connect.prototype.trySubscribe = function trySubscribe() {
if (shouldSubscribe && !this.unsubscribe) {
this.unsubscribe = this.store.subscribe(this.handleChange.bind(this));
this.handleChange();
}
};
Connect.prototype.tryUnsubscribe = function tryUnsubscribe() {
if (this.unsubscribe) {
this.unsubscribe();
this.unsubscribe = null;
}
};
Connect.prototype.componentDidMount = function componentDidMount() {
this.trySubscribe();
};
Connect.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (!pure || !(0, _shallowEqual2["default"])(nextProps, this.props)) {
this.haveOwnPropsChanged = true;
}
};
Connect.prototype.componentWillUnmount = function componentWillUnmount() {
this.tryUnsubscribe();
this.clearCache();
};
Connect.prototype.clearCache = function clearCache() {
this.dispatchProps = null;
this.stateProps = null;
this.mergedProps = null;
this.haveOwnPropsChanged = true;
this.hasStoreStateChanged = true;
this.haveStatePropsBeenPrecalculated = false;
this.statePropsPrecalculationError = null;
this.renderedElement = null;
this.finalMapDispatchToProps = null;
this.finalMapStateToProps = null;
};
Connect.prototype.handleChange = function handleChange() {
if (!this.unsubscribe) {
return;
}
var storeState = this.store.getState();
var prevStoreState = this.state.storeState;
if (pure && prevStoreState === storeState) {
return;
}
if (pure && !this.doStatePropsDependOnOwnProps) {
var haveStatePropsChanged = tryCatch(this.updateStatePropsIfNeeded, this);
if (!haveStatePropsChanged) {
return;
}
if (haveStatePropsChanged === errorObject) {
this.statePropsPrecalculationError = errorObject.value;
}
this.haveStatePropsBeenPrecalculated = true;
}
this.hasStoreStateChanged = true;
this.setState({ storeState: storeState });
};
Connect.prototype.getWrappedInstance = function getWrappedInstance() {
(0, _invariant2["default"])(withRef, 'To access the wrapped instance, you need to specify ' + '{ withRef: true } as the fourth argument of the connect() call.');
return this.refs.wrappedInstance;
};
Connect.prototype.render = function render() {
var haveOwnPropsChanged = this.haveOwnPropsChanged,
hasStoreStateChanged = this.hasStoreStateChanged,
haveStatePropsBeenPrecalculated = this.haveStatePropsBeenPrecalculated,
statePropsPrecalculationError = this.statePropsPrecalculationError,
renderedElement = this.renderedElement;
this.haveOwnPropsChanged = false;
this.hasStoreStateChanged = false;
this.haveStatePropsBeenPrecalculated = false;
this.statePropsPrecalculationError = null;
if (statePropsPrecalculationError) {
throw statePropsPrecalculationError;
}
var shouldUpdateStateProps = true;
var shouldUpdateDispatchProps = true;
if (pure && renderedElement) {
shouldUpdateStateProps = hasStoreStateChanged || haveOwnPropsChanged && this.doStatePropsDependOnOwnProps;
shouldUpdateDispatchProps = haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps;
}
var haveStatePropsChanged = false;
var haveDispatchPropsChanged = false;
if (haveStatePropsBeenPrecalculated) {
haveStatePropsChanged = true;
} else if (shouldUpdateStateProps) {
haveStatePropsChanged = this.updateStatePropsIfNeeded();
}
if (shouldUpdateDispatchProps) {
haveDispatchPropsChanged = this.updateDispatchPropsIfNeeded();
}
var haveMergedPropsChanged = true;
if (haveStatePropsChanged || haveDispatchPropsChanged || haveOwnPropsChanged) {
haveMergedPropsChanged = this.updateMergedPropsIfNeeded();
} else {
haveMergedPropsChanged = false;
}
if (!haveMergedPropsChanged && renderedElement) {
return renderedElement;
}
if (withRef) {
this.renderedElement = (0, _react.createElement)(WrappedComponent, _extends({}, this.mergedProps, {
ref: 'wrappedInstance'
}));
} else {
this.renderedElement = (0, _react.createElement)(WrappedComponent, this.mergedProps);
}
return this.renderedElement;
};
return Connect;
}(_react.Component);
Connect.displayName = connectDisplayName;
Connect.WrappedComponent = WrappedComponent;
Connect.contextTypes = {
store: _storeShape2["default"]
};
Connect.propTypes = {
store: _storeShape2["default"]
};
if (process.env.NODE_ENV !== 'production') {
Connect.prototype.componentWillUpdate = function componentWillUpdate() {
if (this.version === version) {
return;
}
// We are hot reloading!
this.version = version;
this.trySubscribe();
this.clearCache();
};
}
return (0, _hoistNonReactStatics2["default"])(Connect, WrappedComponent);
};
}

View File

@@ -0,0 +1,17 @@
'use strict';
exports.__esModule = true;
exports.connect = exports.Provider = undefined;
var _Provider = require('./components/Provider');
var _Provider2 = _interopRequireDefault(_Provider);
var _connect = require('./components/connect');
var _connect2 = _interopRequireDefault(_connect);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports.Provider = _Provider2["default"];
exports.connect = _connect2["default"];

View File

@@ -0,0 +1,26 @@
"use strict";
exports.__esModule = true;
exports["default"] = shallowEqual;
function shallowEqual(objA, objB) {
if (objA === objB) {
return true;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
// Test for A's keys different from B.
var hasOwn = Object.prototype.hasOwnProperty;
for (var i = 0; i < keysA.length; i++) {
if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
return false;
}
}
return true;
}

View File

@@ -0,0 +1,15 @@
'use strict';
exports.__esModule = true;
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
exports["default"] = _propTypes2["default"].shape({
subscribe: _propTypes2["default"].func.isRequired,
dispatch: _propTypes2["default"].func.isRequired,
getState: _propTypes2["default"].func.isRequired
});

View File

@@ -0,0 +1,25 @@
'use strict';
exports.__esModule = true;
exports["default"] = warning;
/**
* Prints a warning in the console if it exists.
*
* @param {String} message The warning message.
* @returns {void}
*/
function warning(message) {
/* eslint-disable no-console */
if (typeof console !== 'undefined' && typeof console.error === 'function') {
console.error(message);
}
/* eslint-enable no-console */
try {
// This error was thrown as a convenience so that if you enable
// "break on all exceptions" in your console,
// it would pause the execution at this line.
throw new Error(message);
/* eslint-disable no-empty */
} catch (e) {}
/* eslint-enable no-empty */
}

View File

@@ -0,0 +1,12 @@
'use strict';
exports.__esModule = true;
exports["default"] = wrapActionCreators;
var _redux = require('redux');
function wrapActionCreators(actionCreators) {
return function (dispatch) {
return (0, _redux.bindActionCreators)(actionCreators, dispatch);
};
}

View File

@@ -0,0 +1,107 @@
{
"name": "react-redux",
"version": "4.4.10",
"description": "Official React bindings for Redux",
"main": "./lib/index.js",
"scripts": {
"build:lib": "babel src --out-dir lib",
"build:umd": "cross-env NODE_ENV=development webpack src/index.js dist/react-redux.js",
"build:umd:min": "cross-env NODE_ENV=production webpack src/index.js dist/react-redux.min.js",
"build": "npm run build:lib && npm run build:umd && npm run build:umd:min && node ./prepublish",
"clean": "rimraf lib dist coverage",
"lint": "eslint src test",
"prepublish": "npm run clean && npm run build",
"test": "mocha --compilers js:babel-register --recursive --require ./test/setup.js",
"test:watch": "npm test -- --watch",
"test:cov": "babel-node ./node_modules/isparta/bin/isparta cover ./node_modules/mocha/bin/_mocha -- --recursive"
},
"repository": {
"type": "git",
"url": "https://github.com/reactjs/react-redux.git"
},
"files": [
"dist",
"lib",
"src"
],
"keywords": [
"react",
"reactjs",
"hot",
"reload",
"hmr",
"live",
"edit",
"flux",
"redux"
],
"author": "Dan Abramov <dan.abramov@me.com> (http://github.com/gaearon)",
"license": "MIT",
"bugs": {
"url": "https://github.com/gaearon/react-redux/issues"
},
"homepage": "https://github.com/gaearon/react-redux",
"devDependencies": {
"babel-cli": "^6.3.17",
"babel-core": "^6.26.3",
"babel-eslint": "^5.0.0-beta9",
"babel-loader": "^6.2.0",
"babel-plugin-check-es2015-constants": "^6.3.13",
"babel-plugin-syntax-jsx": "^6.3.13",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-transform-es2015-arrow-functions": "^6.3.13",
"babel-plugin-transform-es2015-block-scoped-functions": "^6.3.13",
"babel-plugin-transform-es2015-block-scoping": "^6.3.13",
"babel-plugin-transform-es2015-classes": "^6.3.13",
"babel-plugin-transform-es2015-computed-properties": "^6.3.13",
"babel-plugin-transform-es2015-destructuring": "^6.3.13",
"babel-plugin-transform-es2015-for-of": "^6.3.13",
"babel-plugin-transform-es2015-function-name": "^6.3.13",
"babel-plugin-transform-es2015-literals": "^6.3.13",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"babel-plugin-transform-es2015-object-super": "^6.3.13",
"babel-plugin-transform-es2015-parameters": "^6.3.13",
"babel-plugin-transform-es2015-shorthand-properties": "^6.3.13",
"babel-plugin-transform-es2015-spread": "^6.3.13",
"babel-plugin-transform-es2015-sticky-regex": "^6.3.13",
"babel-plugin-transform-es2015-template-literals": "^6.3.13",
"babel-plugin-transform-es2015-unicode-regex": "^6.3.13",
"babel-plugin-transform-object-rest-spread": "^6.3.13",
"babel-plugin-transform-react-display-name": "^6.4.0",
"babel-plugin-transform-react-jsx": "^6.4.0",
"babel-register": "^6.3.13",
"cross-env": "^1.0.7",
"es3ify": "^0.2.0",
"eslint": "^1.7.1",
"eslint-config-rackt": "1.1.0",
"eslint-plugin-react": "^3.6.3",
"expect": "^1.8.0",
"glob": "^6.0.4",
"isparta": "4.0.0",
"istanbul": "^0.4.5",
"jsdom": "~5.4.3",
"mocha": "^2.2.5",
"react": "^15.5.0",
"react-dom": "^15.5.0",
"redux": "^3.0.0",
"rimraf": "^2.6.3",
"webpack": "^1.11.0"
},
"dependencies": {
"create-react-class": "^15.5.1",
"hoist-non-react-statics": "^3.3.0",
"invariant": "^2.0.0",
"lodash": "^4.17.11",
"loose-envify": "^1.4.0",
"prop-types": "^15.7.2"
},
"peerDependencies": {
"react": "^0.14.0 || ^15.0.0-0 || ^15.4.0-0 || ^16.0.0-0",
"redux": "^2.0.0 || ^3.0.0"
},
"browserify": {
"transform": [
"loose-envify"
]
}
}

View File

@@ -0,0 +1,54 @@
import { Component, Children } from 'react'
import PropTypes from 'prop-types'
import storeShape from '../utils/storeShape'
import warning from '../utils/warning'
let didWarnAboutReceivingStore = false
function warnAboutReceivingStore() {
if (didWarnAboutReceivingStore) {
return
}
didWarnAboutReceivingStore = true
warning(
'<Provider> does not support changing `store` on the fly. ' +
'It is most likely that you see this error because you updated to ' +
'Redux 2.x and React Redux 2.x which no longer hot reload reducers ' +
'automatically. See https://github.com/reactjs/react-redux/releases/' +
'tag/v2.0.0 for the migration instructions.'
)
}
export default class Provider extends Component {
getChildContext() {
return { store: this.store }
}
constructor(props, context) {
super(props, context)
this.store = props.store
}
render() {
return Children.only(this.props.children)
}
}
if (process.env.NODE_ENV !== 'production') {
Provider.prototype.componentWillReceiveProps = function (nextProps) {
const { store } = this
const { store: nextStore } = nextProps
if (store !== nextStore) {
warnAboutReceivingStore()
}
}
}
Provider.propTypes = {
store: storeShape.isRequired,
children: PropTypes.element.isRequired
}
Provider.childContextTypes = {
store: storeShape.isRequired
}

View File

@@ -0,0 +1,367 @@
import { Component, createElement } from 'react'
import storeShape from '../utils/storeShape'
import shallowEqual from '../utils/shallowEqual'
import wrapActionCreators from '../utils/wrapActionCreators'
import warning from '../utils/warning'
import isPlainObject from 'lodash/isPlainObject'
import hoistStatics from 'hoist-non-react-statics'
import invariant from 'invariant'
const defaultMapStateToProps = state => ({}) // eslint-disable-line no-unused-vars
const defaultMapDispatchToProps = dispatch => ({ dispatch })
const defaultMergeProps = (stateProps, dispatchProps, parentProps) => ({
...parentProps,
...stateProps,
...dispatchProps
})
function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component'
}
let errorObject = { value: null }
function tryCatch(fn, ctx) {
try {
return fn.apply(ctx)
} catch (e) {
errorObject.value = e
return errorObject
}
}
// Helps track hot reloading.
let nextVersion = 0
export default function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) {
const shouldSubscribe = Boolean(mapStateToProps)
const mapState = mapStateToProps || defaultMapStateToProps
let mapDispatch
if (typeof mapDispatchToProps === 'function') {
mapDispatch = mapDispatchToProps
} else if (!mapDispatchToProps) {
mapDispatch = defaultMapDispatchToProps
} else {
mapDispatch = wrapActionCreators(mapDispatchToProps)
}
const finalMergeProps = mergeProps || defaultMergeProps
const { pure = true, withRef = false } = options
const checkMergedEquals = pure && finalMergeProps !== defaultMergeProps
// Helps track hot reloading.
const version = nextVersion++
return function wrapWithConnect(WrappedComponent) {
const connectDisplayName = `Connect(${getDisplayName(WrappedComponent)})`
function checkStateShape(props, methodName) {
if (!isPlainObject(props)) {
warning(
`${methodName}() in ${connectDisplayName} must return a plain object. ` +
`Instead received ${props}.`
)
}
}
function computeMergedProps(stateProps, dispatchProps, parentProps) {
const mergedProps = finalMergeProps(stateProps, dispatchProps, parentProps)
if (process.env.NODE_ENV !== 'production') {
checkStateShape(mergedProps, 'mergeProps')
}
return mergedProps
}
class Connect extends Component {
shouldComponentUpdate() {
return !pure || this.haveOwnPropsChanged || this.hasStoreStateChanged
}
constructor(props, context) {
super(props, context)
this.version = version
this.store = props.store || context.store
invariant(this.store,
`Could not find "store" in either the context or ` +
`props of "${connectDisplayName}". ` +
`Either wrap the root component in a <Provider>, ` +
`or explicitly pass "store" as a prop to "${connectDisplayName}".`
)
const storeState = this.store.getState()
this.state = { storeState }
this.clearCache()
}
computeStateProps(store, props) {
if (!this.finalMapStateToProps) {
return this.configureFinalMapState(store, props)
}
const state = store.getState()
const stateProps = this.doStatePropsDependOnOwnProps ?
this.finalMapStateToProps(state, props) :
this.finalMapStateToProps(state)
if (process.env.NODE_ENV !== 'production') {
checkStateShape(stateProps, 'mapStateToProps')
}
return stateProps
}
configureFinalMapState(store, props) {
const mappedState = mapState(store.getState(), props)
const isFactory = typeof mappedState === 'function'
this.finalMapStateToProps = isFactory ? mappedState : mapState
this.doStatePropsDependOnOwnProps = this.finalMapStateToProps.length !== 1
if (isFactory) {
return this.computeStateProps(store, props)
}
if (process.env.NODE_ENV !== 'production') {
checkStateShape(mappedState, 'mapStateToProps')
}
return mappedState
}
computeDispatchProps(store, props) {
if (!this.finalMapDispatchToProps) {
return this.configureFinalMapDispatch(store, props)
}
const { dispatch } = store
const dispatchProps = this.doDispatchPropsDependOnOwnProps ?
this.finalMapDispatchToProps(dispatch, props) :
this.finalMapDispatchToProps(dispatch)
if (process.env.NODE_ENV !== 'production') {
checkStateShape(dispatchProps, 'mapDispatchToProps')
}
return dispatchProps
}
configureFinalMapDispatch(store, props) {
const mappedDispatch = mapDispatch(store.dispatch, props)
const isFactory = typeof mappedDispatch === 'function'
this.finalMapDispatchToProps = isFactory ? mappedDispatch : mapDispatch
this.doDispatchPropsDependOnOwnProps = this.finalMapDispatchToProps.length !== 1
if (isFactory) {
return this.computeDispatchProps(store, props)
}
if (process.env.NODE_ENV !== 'production') {
checkStateShape(mappedDispatch, 'mapDispatchToProps')
}
return mappedDispatch
}
updateStatePropsIfNeeded() {
const nextStateProps = this.computeStateProps(this.store, this.props)
if (this.stateProps && shallowEqual(nextStateProps, this.stateProps)) {
return false
}
this.stateProps = nextStateProps
return true
}
updateDispatchPropsIfNeeded() {
const nextDispatchProps = this.computeDispatchProps(this.store, this.props)
if (this.dispatchProps && shallowEqual(nextDispatchProps, this.dispatchProps)) {
return false
}
this.dispatchProps = nextDispatchProps
return true
}
updateMergedPropsIfNeeded() {
const nextMergedProps = computeMergedProps(this.stateProps, this.dispatchProps, this.props)
if (this.mergedProps && checkMergedEquals && shallowEqual(nextMergedProps, this.mergedProps)) {
return false
}
this.mergedProps = nextMergedProps
return true
}
isSubscribed() {
return typeof this.unsubscribe === 'function'
}
trySubscribe() {
if (shouldSubscribe && !this.unsubscribe) {
this.unsubscribe = this.store.subscribe(this.handleChange.bind(this))
this.handleChange()
}
}
tryUnsubscribe() {
if (this.unsubscribe) {
this.unsubscribe()
this.unsubscribe = null
}
}
componentDidMount() {
this.trySubscribe()
}
componentWillReceiveProps(nextProps) {
if (!pure || !shallowEqual(nextProps, this.props)) {
this.haveOwnPropsChanged = true
}
}
componentWillUnmount() {
this.tryUnsubscribe()
this.clearCache()
}
clearCache() {
this.dispatchProps = null
this.stateProps = null
this.mergedProps = null
this.haveOwnPropsChanged = true
this.hasStoreStateChanged = true
this.haveStatePropsBeenPrecalculated = false
this.statePropsPrecalculationError = null
this.renderedElement = null
this.finalMapDispatchToProps = null
this.finalMapStateToProps = null
}
handleChange() {
if (!this.unsubscribe) {
return
}
const storeState = this.store.getState()
const prevStoreState = this.state.storeState
if (pure && prevStoreState === storeState) {
return
}
if (pure && !this.doStatePropsDependOnOwnProps) {
const haveStatePropsChanged = tryCatch(this.updateStatePropsIfNeeded, this)
if (!haveStatePropsChanged) {
return
}
if (haveStatePropsChanged === errorObject) {
this.statePropsPrecalculationError = errorObject.value
}
this.haveStatePropsBeenPrecalculated = true
}
this.hasStoreStateChanged = true
this.setState({ storeState })
}
getWrappedInstance() {
invariant(withRef,
`To access the wrapped instance, you need to specify ` +
`{ withRef: true } as the fourth argument of the connect() call.`
)
return this.refs.wrappedInstance
}
render() {
const {
haveOwnPropsChanged,
hasStoreStateChanged,
haveStatePropsBeenPrecalculated,
statePropsPrecalculationError,
renderedElement
} = this
this.haveOwnPropsChanged = false
this.hasStoreStateChanged = false
this.haveStatePropsBeenPrecalculated = false
this.statePropsPrecalculationError = null
if (statePropsPrecalculationError) {
throw statePropsPrecalculationError
}
let shouldUpdateStateProps = true
let shouldUpdateDispatchProps = true
if (pure && renderedElement) {
shouldUpdateStateProps = hasStoreStateChanged || (
haveOwnPropsChanged && this.doStatePropsDependOnOwnProps
)
shouldUpdateDispatchProps =
haveOwnPropsChanged && this.doDispatchPropsDependOnOwnProps
}
let haveStatePropsChanged = false
let haveDispatchPropsChanged = false
if (haveStatePropsBeenPrecalculated) {
haveStatePropsChanged = true
} else if (shouldUpdateStateProps) {
haveStatePropsChanged = this.updateStatePropsIfNeeded()
}
if (shouldUpdateDispatchProps) {
haveDispatchPropsChanged = this.updateDispatchPropsIfNeeded()
}
let haveMergedPropsChanged = true
if (
haveStatePropsChanged ||
haveDispatchPropsChanged ||
haveOwnPropsChanged
) {
haveMergedPropsChanged = this.updateMergedPropsIfNeeded()
} else {
haveMergedPropsChanged = false
}
if (!haveMergedPropsChanged && renderedElement) {
return renderedElement
}
if (withRef) {
this.renderedElement = createElement(WrappedComponent, {
...this.mergedProps,
ref: 'wrappedInstance'
})
} else {
this.renderedElement = createElement(WrappedComponent,
this.mergedProps
)
}
return this.renderedElement
}
}
Connect.displayName = connectDisplayName
Connect.WrappedComponent = WrappedComponent
Connect.contextTypes = {
store: storeShape
}
Connect.propTypes = {
store: storeShape
}
if (process.env.NODE_ENV !== 'production') {
Connect.prototype.componentWillUpdate = function componentWillUpdate() {
if (this.version === version) {
return
}
// We are hot reloading!
this.version = version
this.trySubscribe()
this.clearCache()
}
}
return hoistStatics(Connect, WrappedComponent)
}
}

View File

@@ -0,0 +1,4 @@
import Provider from './components/Provider'
import connect from './components/connect'
export { Provider, connect }

View File

@@ -0,0 +1,23 @@
export default function shallowEqual(objA, objB) {
if (objA === objB) {
return true
}
const keysA = Object.keys(objA)
const keysB = Object.keys(objB)
if (keysA.length !== keysB.length) {
return false
}
// Test for A's keys different from B.
const hasOwn = Object.prototype.hasOwnProperty
for (let i = 0; i < keysA.length; i++) {
if (!hasOwn.call(objB, keysA[i]) ||
objA[keysA[i]] !== objB[keysA[i]]) {
return false
}
}
return true
}

View File

@@ -0,0 +1,7 @@
import PropTypes from 'prop-types'
export default PropTypes.shape({
subscribe: PropTypes.func.isRequired,
dispatch: PropTypes.func.isRequired,
getState: PropTypes.func.isRequired
})

View File

@@ -0,0 +1,21 @@
/**
* Prints a warning in the console if it exists.
*
* @param {String} message The warning message.
* @returns {void}
*/
export default function warning(message) {
/* eslint-disable no-console */
if (typeof console !== 'undefined' && typeof console.error === 'function') {
console.error(message)
}
/* eslint-enable no-console */
try {
// This error was thrown as a convenience so that if you enable
// "break on all exceptions" in your console,
// it would pause the execution at this line.
throw new Error(message)
/* eslint-disable no-empty */
} catch (e) {}
/* eslint-enable no-empty */
}

View File

@@ -0,0 +1,5 @@
import { bindActionCreators } from 'redux'
export default function wrapActionCreators(actionCreators) {
return dispatch => bindActionCreators(actionCreators, dispatch)
}

View File

@@ -0,0 +1,94 @@
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _TransitionGroup = require('./TransitionGroup');
var _TransitionGroup2 = _interopRequireDefault(_TransitionGroup);
var _CSSTransitionGroupChild = require('./CSSTransitionGroupChild');
var _CSSTransitionGroupChild2 = _interopRequireDefault(_CSSTransitionGroupChild);
var _PropTypes = require('./utils/PropTypes');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var propTypes = {
transitionName: _PropTypes.nameShape.isRequired,
transitionAppear: _propTypes2.default.bool,
transitionEnter: _propTypes2.default.bool,
transitionLeave: _propTypes2.default.bool,
transitionAppearTimeout: (0, _PropTypes.transitionTimeout)('Appear'),
transitionEnterTimeout: (0, _PropTypes.transitionTimeout)('Enter'),
transitionLeaveTimeout: (0, _PropTypes.transitionTimeout)('Leave')
};
var defaultProps = {
transitionAppear: false,
transitionEnter: true,
transitionLeave: true
};
var CSSTransitionGroup = function (_React$Component) {
_inherits(CSSTransitionGroup, _React$Component);
function CSSTransitionGroup() {
var _temp, _this, _ret;
_classCallCheck(this, CSSTransitionGroup);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this._wrapChild = function (child) {
return _react2.default.createElement(_CSSTransitionGroupChild2.default, {
name: _this.props.transitionName,
appear: _this.props.transitionAppear,
enter: _this.props.transitionEnter,
leave: _this.props.transitionLeave,
appearTimeout: _this.props.transitionAppearTimeout,
enterTimeout: _this.props.transitionEnterTimeout,
leaveTimeout: _this.props.transitionLeaveTimeout
}, child);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
// We need to provide this childFactory so that
// ReactCSSTransitionGroupChild can receive updates to name, enter, and
// leave while it is leaving.
CSSTransitionGroup.prototype.render = function render() {
return _react2.default.createElement(_TransitionGroup2.default, _extends({}, this.props, { childFactory: this._wrapChild }));
};
return CSSTransitionGroup;
}(_react2.default.Component);
CSSTransitionGroup.displayName = 'CSSTransitionGroup';
CSSTransitionGroup.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
CSSTransitionGroup.defaultProps = defaultProps;
exports.default = CSSTransitionGroup;
module.exports = exports['default'];

View File

@@ -0,0 +1,229 @@
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _addClass = require('dom-helpers/class/addClass');
var _addClass2 = _interopRequireDefault(_addClass);
var _removeClass = require('dom-helpers/class/removeClass');
var _removeClass2 = _interopRequireDefault(_removeClass);
var _requestAnimationFrame = require('dom-helpers/util/requestAnimationFrame');
var _requestAnimationFrame2 = _interopRequireDefault(_requestAnimationFrame);
var _properties = require('dom-helpers/transition/properties');
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _reactDom = require('react-dom');
var _PropTypes = require('./utils/PropTypes');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var events = [];
if (_properties.transitionEnd) events.push(_properties.transitionEnd);
if (_properties.animationEnd) events.push(_properties.animationEnd);
function addEndListener(node, listener) {
if (events.length) {
events.forEach(function (e) {
return node.addEventListener(e, listener, false);
});
} else {
setTimeout(listener, 0);
}
return function () {
if (!events.length) return;
events.forEach(function (e) {
return node.removeEventListener(e, listener, false);
});
};
}
var propTypes = {
children: _propTypes2.default.node,
name: _PropTypes.nameShape.isRequired,
// Once we require timeouts to be specified, we can remove the
// boolean flags (appear etc.) and just accept a number
// or a bool for the timeout flags (appearTimeout etc.)
appear: _propTypes2.default.bool,
enter: _propTypes2.default.bool,
leave: _propTypes2.default.bool,
appearTimeout: _propTypes2.default.number,
enterTimeout: _propTypes2.default.number,
leaveTimeout: _propTypes2.default.number
};
var CSSTransitionGroupChild = function (_React$Component) {
_inherits(CSSTransitionGroupChild, _React$Component);
function CSSTransitionGroupChild() {
var _temp, _this, _ret;
_classCallCheck(this, CSSTransitionGroupChild);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.componentWillAppear = function (done) {
if (_this.props.appear) {
_this.transition('appear', done, _this.props.appearTimeout);
} else {
done();
}
}, _this.componentWillEnter = function (done) {
if (_this.props.enter) {
_this.transition('enter', done, _this.props.enterTimeout);
} else {
done();
}
}, _this.componentWillLeave = function (done) {
if (_this.props.leave) {
_this.transition('leave', done, _this.props.leaveTimeout);
} else {
done();
}
}, _temp), _possibleConstructorReturn(_this, _ret);
}
CSSTransitionGroupChild.prototype.componentWillMount = function componentWillMount() {
this.classNameAndNodeQueue = [];
this.transitionTimeouts = [];
};
CSSTransitionGroupChild.prototype.componentWillUnmount = function componentWillUnmount() {
this.unmounted = true;
if (this.timeout) {
clearTimeout(this.timeout);
}
this.transitionTimeouts.forEach(function (timeout) {
clearTimeout(timeout);
});
this.classNameAndNodeQueue.length = 0;
};
CSSTransitionGroupChild.prototype.transition = function transition(animationType, finishCallback, timeout) {
var node = (0, _reactDom.findDOMNode)(this);
if (!node) {
if (finishCallback) {
finishCallback();
}
return;
}
var className = this.props.name[animationType] || this.props.name + '-' + animationType;
var activeClassName = this.props.name[animationType + 'Active'] || className + '-active';
var timer = null;
var removeListeners = void 0;
(0, _addClass2.default)(node, className);
// Need to do this to actually trigger a transition.
this.queueClassAndNode(activeClassName, node);
// Clean-up the animation after the specified delay
var finish = function finish(e) {
if (e && e.target !== node) {
return;
}
clearTimeout(timer);
if (removeListeners) removeListeners();
(0, _removeClass2.default)(node, className);
(0, _removeClass2.default)(node, activeClassName);
if (removeListeners) removeListeners();
// Usually this optional callback is used for informing an owner of
// a leave animation and telling it to remove the child.
if (finishCallback) {
finishCallback();
}
};
if (timeout) {
timer = setTimeout(finish, timeout);
this.transitionTimeouts.push(timer);
} else if (_properties.transitionEnd) {
removeListeners = addEndListener(node, finish);
}
};
CSSTransitionGroupChild.prototype.queueClassAndNode = function queueClassAndNode(className, node) {
var _this2 = this;
this.classNameAndNodeQueue.push({
className: className,
node: node
});
if (!this.rafHandle) {
this.rafHandle = (0, _requestAnimationFrame2.default)(function () {
return _this2.flushClassNameAndNodeQueue();
});
}
};
CSSTransitionGroupChild.prototype.flushClassNameAndNodeQueue = function flushClassNameAndNodeQueue() {
if (!this.unmounted) {
this.classNameAndNodeQueue.forEach(function (obj) {
// This is for to force a repaint,
// which is necessary in order to transition styles when adding a class name.
/* eslint-disable no-unused-expressions */
obj.node.scrollTop;
/* eslint-enable no-unused-expressions */
(0, _addClass2.default)(obj.node, obj.className);
});
}
this.classNameAndNodeQueue.length = 0;
this.rafHandle = null;
};
CSSTransitionGroupChild.prototype.render = function render() {
var props = _extends({}, this.props);
delete props.name;
delete props.appear;
delete props.enter;
delete props.leave;
delete props.appearTimeout;
delete props.enterTimeout;
delete props.leaveTimeout;
delete props.children;
return _react2.default.cloneElement(_react2.default.Children.only(this.props.children), props);
};
return CSSTransitionGroupChild;
}(_react2.default.Component);
CSSTransitionGroupChild.displayName = 'CSSTransitionGroupChild';
CSSTransitionGroupChild.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
exports.default = CSSTransitionGroupChild;
module.exports = exports['default'];

View File

@@ -0,0 +1,269 @@
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _chainFunction = require('chain-function');
var _chainFunction2 = _interopRequireDefault(_chainFunction);
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _warning = require('warning');
var _warning2 = _interopRequireDefault(_warning);
var _ChildMapping = require('./utils/ChildMapping');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var propTypes = {
component: _propTypes2.default.any,
childFactory: _propTypes2.default.func,
children: _propTypes2.default.node
};
var defaultProps = {
component: 'span',
childFactory: function childFactory(child) {
return child;
}
};
var TransitionGroup = function (_React$Component) {
_inherits(TransitionGroup, _React$Component);
function TransitionGroup(props, context) {
_classCallCheck(this, TransitionGroup);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));
_this.performAppear = function (key, component) {
_this.currentlyTransitioningKeys[key] = true;
if (component.componentWillAppear) {
component.componentWillAppear(_this._handleDoneAppearing.bind(_this, key, component));
} else {
_this._handleDoneAppearing(key, component);
}
};
_this._handleDoneAppearing = function (key, component) {
if (component.componentDidAppear) {
component.componentDidAppear();
}
delete _this.currentlyTransitioningKeys[key];
var currentChildMapping = (0, _ChildMapping.getChildMapping)(_this.props.children);
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
// This was removed before it had fully appeared. Remove it.
_this.performLeave(key, component);
}
};
_this.performEnter = function (key, component) {
_this.currentlyTransitioningKeys[key] = true;
if (component.componentWillEnter) {
component.componentWillEnter(_this._handleDoneEntering.bind(_this, key, component));
} else {
_this._handleDoneEntering(key, component);
}
};
_this._handleDoneEntering = function (key, component) {
if (component.componentDidEnter) {
component.componentDidEnter();
}
delete _this.currentlyTransitioningKeys[key];
var currentChildMapping = (0, _ChildMapping.getChildMapping)(_this.props.children);
if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {
// This was removed before it had fully entered. Remove it.
_this.performLeave(key, component);
}
};
_this.performLeave = function (key, component) {
_this.currentlyTransitioningKeys[key] = true;
if (component.componentWillLeave) {
component.componentWillLeave(_this._handleDoneLeaving.bind(_this, key, component));
} else {
// Note that this is somewhat dangerous b/c it calls setState()
// again, effectively mutating the component before all the work
// is done.
_this._handleDoneLeaving(key, component);
}
};
_this._handleDoneLeaving = function (key, component) {
if (component.componentDidLeave) {
component.componentDidLeave();
}
delete _this.currentlyTransitioningKeys[key];
var currentChildMapping = (0, _ChildMapping.getChildMapping)(_this.props.children);
if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {
// This entered again before it fully left. Add it again.
_this.keysToEnter.push(key);
} else {
_this.setState(function (state) {
var newChildren = _extends({}, state.children);
delete newChildren[key];
return { children: newChildren };
});
}
};
_this.childRefs = Object.create(null);
_this.state = {
children: (0, _ChildMapping.getChildMapping)(props.children)
};
return _this;
}
TransitionGroup.prototype.componentWillMount = function componentWillMount() {
this.currentlyTransitioningKeys = {};
this.keysToEnter = [];
this.keysToLeave = [];
};
TransitionGroup.prototype.componentDidMount = function componentDidMount() {
var initialChildMapping = this.state.children;
for (var key in initialChildMapping) {
if (initialChildMapping[key]) {
this.performAppear(key, this.childRefs[key]);
}
}
};
TransitionGroup.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
var nextChildMapping = (0, _ChildMapping.getChildMapping)(nextProps.children);
var prevChildMapping = this.state.children;
this.setState({
children: (0, _ChildMapping.mergeChildMappings)(prevChildMapping, nextChildMapping)
});
for (var key in nextChildMapping) {
var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
if (nextChildMapping[key] && !hasPrev && !this.currentlyTransitioningKeys[key]) {
this.keysToEnter.push(key);
}
}
for (var _key in prevChildMapping) {
var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(_key);
if (prevChildMapping[_key] && !hasNext && !this.currentlyTransitioningKeys[_key]) {
this.keysToLeave.push(_key);
}
}
// If we want to someday check for reordering, we could do it here.
};
TransitionGroup.prototype.componentDidUpdate = function componentDidUpdate() {
var _this2 = this;
var keysToEnter = this.keysToEnter;
this.keysToEnter = [];
keysToEnter.forEach(function (key) {
return _this2.performEnter(key, _this2.childRefs[key]);
});
var keysToLeave = this.keysToLeave;
this.keysToLeave = [];
keysToLeave.forEach(function (key) {
return _this2.performLeave(key, _this2.childRefs[key]);
});
};
TransitionGroup.prototype.render = function render() {
var _this3 = this;
// TODO: we could get rid of the need for the wrapper node
// by cloning a single child
var childrenToRender = [];
var _loop = function _loop(key) {
var child = _this3.state.children[key];
if (child) {
var isCallbackRef = typeof child.ref !== 'string';
var factoryChild = _this3.props.childFactory(child);
var ref = function ref(r) {
_this3.childRefs[key] = r;
};
process.env.NODE_ENV !== 'production' ? (0, _warning2.default)(isCallbackRef, 'string refs are not supported on children of TransitionGroup and will be ignored. ' + 'Please use a callback ref instead: https://facebook.github.io/react/docs/refs-and-the-dom.html#the-ref-callback-attribute') : void 0;
// Always chaining the refs leads to problems when the childFactory
// wraps the child. The child ref callback gets called twice with the
// wrapper and the child. So we only need to chain the ref if the
// factoryChild is not different from child.
if (factoryChild === child && isCallbackRef) {
ref = (0, _chainFunction2.default)(child.ref, ref);
}
// You may need to apply reactive updates to a child as it is leaving.
// The normal React way to do it won't work since the child will have
// already been removed. In case you need this behavior you can provide
// a childFactory function to wrap every child, even the ones that are
// leaving.
childrenToRender.push(_react2.default.cloneElement(factoryChild, {
key: key,
ref: ref
}));
}
};
for (var key in this.state.children) {
_loop(key);
}
// Do not forward TransitionGroup props to primitive DOM nodes
var props = _extends({}, this.props);
delete props.transitionLeave;
delete props.transitionName;
delete props.transitionAppear;
delete props.transitionEnter;
delete props.childFactory;
delete props.transitionLeaveTimeout;
delete props.transitionEnterTimeout;
delete props.transitionAppearTimeout;
delete props.component;
return _react2.default.createElement(this.props.component, props, childrenToRender);
};
return TransitionGroup;
}(_react2.default.Component);
TransitionGroup.displayName = 'TransitionGroup';
TransitionGroup.propTypes = process.env.NODE_ENV !== "production" ? propTypes : {};
TransitionGroup.defaultProps = defaultProps;
exports.default = TransitionGroup;
module.exports = exports['default'];

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,16 @@
'use strict';
var _CSSTransitionGroup = require('./CSSTransitionGroup');
var _CSSTransitionGroup2 = _interopRequireDefault(_CSSTransitionGroup);
var _TransitionGroup = require('./TransitionGroup');
var _TransitionGroup2 = _interopRequireDefault(_TransitionGroup);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = {
TransitionGroup: _TransitionGroup2.default,
CSSTransitionGroup: _CSSTransitionGroup2.default
};

View File

@@ -0,0 +1,48 @@
{
"name": "react-transition-group",
"version": "1.2.1",
"description": "A react component toolset for managing animations",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/reactjs/react-transition-group.git"
},
"keywords": [
"react",
"transition",
"addons",
"transition-group",
"animation",
"css",
"transitions"
],
"author": "",
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/reactjs/react-transition-group/issues"
},
"homepage": "https://github.com/reactjs/react-transition-group#readme",
"jest": {
"testRegex": "-test\\.js",
"roots": [
"<rootDir>/test"
],
"timers": "fake"
},
"peerDependencies": {
"react": "^15.0.0 || ^16.0.0",
"react-dom": "^15.0.0 || ^16.0.0"
},
"dependencies": {
"chain-function": "^1.0.0",
"dom-helpers": "^3.2.0",
"loose-envify": "^1.3.1",
"prop-types": "^15.5.6",
"warning": "^3.0.0"
},
"browserify": {
"transform": [
"loose-envify"
]
}
}

View File

@@ -0,0 +1,91 @@
'use strict';
exports.__esModule = true;
exports.getChildMapping = getChildMapping;
exports.mergeChildMappings = mergeChildMappings;
var _react = require('react');
/**
* Given `this.props.children`, return an object mapping key to child.
*
* @param {*} children `this.props.children`
* @return {object} Mapping of key to child
*/
function getChildMapping(children) {
if (!children) {
return children;
}
var result = {};
_react.Children.map(children, function (child) {
return child;
}).forEach(function (child) {
result[child.key] = child;
});
return result;
}
/**
* When you're adding or removing children some may be added or removed in the
* same render pass. We want to show *both* since we want to simultaneously
* animate elements in and out. This function takes a previous set of keys
* and a new set of keys and merges them with its best guess of the correct
* ordering. In the future we may expose some of the utilities in
* ReactMultiChild to make this easy, but for now React itself does not
* directly have this concept of the union of prevChildren and nextChildren
* so we implement it here.
*
* @param {object} prev prev children as returned from
* `ReactTransitionChildMapping.getChildMapping()`.
* @param {object} next next children as returned from
* `ReactTransitionChildMapping.getChildMapping()`.
* @return {object} a key set that contains all keys in `prev` and all keys
* in `next` in a reasonable order.
*/
function mergeChildMappings(prev, next) {
prev = prev || {};
next = next || {};
function getValueForKey(key) {
if (next.hasOwnProperty(key)) {
return next[key];
}
return prev[key];
}
// For each key of `next`, the list of keys to insert before that key in
// the combined list
var nextKeysPending = {};
var pendingKeys = [];
for (var prevKey in prev) {
if (next.hasOwnProperty(prevKey)) {
if (pendingKeys.length) {
nextKeysPending[prevKey] = pendingKeys;
pendingKeys = [];
}
} else {
pendingKeys.push(prevKey);
}
}
var i = void 0;
var childMapping = {};
for (var nextKey in next) {
if (nextKeysPending.hasOwnProperty(nextKey)) {
for (i = 0; i < nextKeysPending[nextKey].length; i++) {
var pendingNextKey = nextKeysPending[nextKey][i];
childMapping[nextKeysPending[nextKey][i]] = getValueForKey(pendingNextKey);
}
}
childMapping[nextKey] = getValueForKey(nextKey);
}
// Finally, add the keys which didn't appear before any key in `next`
for (i = 0; i < pendingKeys.length; i++) {
childMapping[pendingKeys[i]] = getValueForKey(pendingKeys[i]);
}
return childMapping;
}

View File

@@ -0,0 +1,49 @@
'use strict';
exports.__esModule = true;
exports.nameShape = undefined;
exports.transitionTimeout = transitionTimeout;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function transitionTimeout(transitionType) {
var timeoutPropName = 'transition' + transitionType + 'Timeout';
var enabledPropName = 'transition' + transitionType;
return function (props) {
// If the transition is enabled
if (props[enabledPropName]) {
// If no timeout duration is provided
if (props[timeoutPropName] == null) {
return new Error(timeoutPropName + ' wasn\'t supplied to CSSTransitionGroup: ' + 'this can cause unreliable animations and won\'t be supported in ' + 'a future version of React. See ' + 'https://fb.me/react-animation-transition-group-timeout for more ' + 'information.');
// If the duration isn't a number
} else if (typeof props[timeoutPropName] !== 'number') {
return new Error(timeoutPropName + ' must be a number (in milliseconds)');
}
}
return null;
};
}
var nameShape = exports.nameShape = _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.shape({
enter: _propTypes2.default.string,
leave: _propTypes2.default.string,
active: _propTypes2.default.string
}), _propTypes2.default.shape({
enter: _propTypes2.default.string,
enterActive: _propTypes2.default.string,
leave: _propTypes2.default.string,
leaveActive: _propTypes2.default.string,
appear: _propTypes2.default.string,
appearActive: _propTypes2.default.string
})]);

View File

@@ -0,0 +1,4 @@
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
Every release, along with the migration instructions, is documented on the Github [Releases](https://github.com/reactjs/redux/releases) page.

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015-present Dan Abramov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,235 @@
# <a href='http://redux.js.org'><img src='https://camo.githubusercontent.com/f28b5bc7822f1b7bb28a96d8d09e7d79169248fc/687474703a2f2f692e696d6775722e636f6d2f4a65567164514d2e706e67' height='60'></a>
Redux is a predictable state container for JavaScript apps.
(If you're looking for a WordPress framework, check out [Redux Framework](https://reduxframework.com/).)
It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. On top of that, it provides a great developer experience, such as [live code editing combined with a time traveling debugger](https://github.com/gaearon/redux-devtools).
You can use Redux together with [React](https://facebook.github.io/react/), or with any other view library.
It is tiny (2kB, including dependencies).
[![build status](https://img.shields.io/travis/reactjs/redux/master.svg?style=flat-square)](https://travis-ci.org/reactjs/redux)
[![npm version](https://img.shields.io/npm/v/redux.svg?style=flat-square)](https://www.npmjs.com/package/redux)
[![npm downloads](https://img.shields.io/npm/dm/redux.svg?style=flat-square)](https://www.npmjs.com/package/redux)
[![redux channel on discord](https://img.shields.io/badge/discord-%23redux%20%40%20reactiflux-61dafb.svg?style=flat-square)](https://discord.gg/0ZcbPKXt5bZ6au5t)
[![#rackt on freenode](https://img.shields.io/badge/irc-%23rackt%20%40%20freenode-61DAFB.svg?style=flat-square)](https://webchat.freenode.net/)
[![Changelog #187](https://img.shields.io/badge/changelog-%23187-lightgrey.svg?style=flat-square)](https://changelog.com/187)
>**Learn Redux from its creator:**
>**[Part 1: Getting Started with Redux](https://egghead.io/series/getting-started-with-redux) (30 free videos)**<br>
>**[Part 2: Building React Applications with Idiomatic Redux](https://egghead.io/courses/building-react-applications-with-idiomatic-redux) (27 free videos)**
### Testimonials
>[“Love what you're doing with Redux”](https://twitter.com/jingc/status/616608251463909376)
>Jing Chen, creator of Flux
>[“I asked for comments on Redux in FB's internal JS discussion group, and it was universally praised. Really awesome work.”](https://twitter.com/fisherwebdev/status/616286955693682688)
>Bill Fisher, author of Flux documentation
>[“It's cool that you are inventing a better Flux by not doing Flux at all.”](https://twitter.com/andrestaltz/status/616271392930201604)
>André Staltz, creator of Cycle
### Before Proceeding Further
>**Also read:**
>**[You Might Not Need Redux](https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367)**
### Developer Experience
I wrote Redux while working on my React Europe talk called [“Hot Reloading with Time Travel”](https://www.youtube.com/watch?v=xsSnOQynTHs). My goal was to create a state management library with minimal API but completely predictable behavior, so it is possible to implement logging, hot reloading, time travel, universal apps, record and replay, without any buy-in from the developer.
### Influences
Redux evolves the ideas of [Flux](http://facebook.github.io/flux/), but avoids its complexity by taking cues from [Elm](https://github.com/evancz/elm-architecture-tutorial/).
Whether you have used them or not, Redux only takes a few minutes to get started with.
### Installation
To install the stable version:
```
npm install --save redux
```
This assumes you are using [npm](https://www.npmjs.com/) as your package manager.
If you're not, you can [access these files on unpkg](https://unpkg.com/redux/), download them, or point your package manager to them.
Most commonly people consume Redux as a collection of [CommonJS](http://webpack.github.io/docs/commonjs.html) modules. These modules are what you get when you import `redux` in a [Webpack](https://webpack.js.org/), [Browserify](http://browserify.org/), or a Node environment. If you like to live on the edge and use [Rollup](http://rollupjs.org), we support that as well.
If you don't use a module bundler, it's also fine. The `redux` npm package includes precompiled production and development [UMD](https://github.com/umdjs/umd) builds in the [`dist` folder](https://unpkg.com/redux/dist/). They can be used directly without a bundler and are thus compatible with many popular JavaScript module loaders and environments. For example, you can drop a UMD build as a [`<script>` tag](https://unpkg.com/redux/dist/redux.js) on the page, or [tell Bower to install it](https://github.com/reactjs/redux/pull/1181#issuecomment-167361975). The UMD builds make Redux available as a `window.Redux` global variable.
The Redux source code is written in ES2015 but we precompile both CommonJS and UMD builds to ES5 so they work in [any modern browser](http://caniuse.com/#feat=es5). You don't need to use Babel or a module bundler to [get started with Redux](https://github.com/reactjs/redux/blob/master/examples/counter-vanilla/index.html).
#### Complementary Packages
Most likely, you'll also need [the React bindings](https://github.com/reactjs/react-redux) and [the developer tools](https://github.com/gaearon/redux-devtools).
```
npm install --save react-redux
npm install --save-dev redux-devtools
```
Note that unlike Redux itself, many packages in the Redux ecosystem don't provide UMD builds, so we recommend using CommonJS module bundlers like [Webpack](https://webpack.js.org/) and [Browserify](http://browserify.org/) for the most comfortable development experience.
### The Gist
The whole state of your app is stored in an object tree inside a single *store*.
The only way to change the state tree is to emit an *action*, an object describing what happened.
To specify how the actions transform the state tree, you write pure *reducers*.
That's it!
```js
import { createStore } from 'redux'
/**
* This is a reducer, a pure function with (state, action) => state signature.
* It describes how an action transforms the state into the next state.
*
* The shape of the state is up to you: it can be a primitive, an array, an object,
* or even an Immutable.js data structure. The only important part is that you should
* not mutate the state object, but return a new object if the state changes.
*
* In this example, we use a `switch` statement and strings, but you can use a helper that
* follows a different convention (such as function maps) if it makes sense for your
* project.
*/
function counter(state = 0, action) {
switch (action.type) {
case 'INCREMENT':
return state + 1
case 'DECREMENT':
return state - 1
default:
return state
}
}
// Create a Redux store holding the state of your app.
// Its API is { subscribe, dispatch, getState }.
let store = createStore(counter)
// You can use subscribe() to update the UI in response to state changes.
// Normally you'd use a view binding library (e.g. React Redux) rather than subscribe() directly.
// However it can also be handy to persist the current state in the localStorage.
store.subscribe(() =>
console.log(store.getState())
)
// The only way to mutate the internal state is to dispatch an action.
// The actions can be serialized, logged or stored and later replayed.
store.dispatch({ type: 'INCREMENT' })
// 1
store.dispatch({ type: 'INCREMENT' })
// 2
store.dispatch({ type: 'DECREMENT' })
// 1
```
Instead of mutating the state directly, you specify the mutations you want to happen with plain objects called *actions*. Then you write a special function called a *reducer* to decide how every action transforms the entire application's state.
If you're coming from Flux, there is a single important difference you need to understand. Redux doesn't have a Dispatcher or support many stores. Instead, there is just a single store with a single root reducing function. As your app grows, instead of adding stores, you split the root reducer into smaller reducers independently operating on the different parts of the state tree. This is exactly like how there is just one root component in a React app, but it is composed out of many small components.
This architecture might seem like an overkill for a counter app, but the beauty of this pattern is how well it scales to large and complex apps. It also enables very powerful developer tools, because it is possible to trace every mutation to the action that caused it. You can record user sessions and reproduce them just by replaying every action.
### Learn Redux from Its Creator
[Getting Started with Redux](https://egghead.io/series/getting-started-with-redux) is a video course consisting of 30 videos narrated by Dan Abramov, author of Redux. It is designed to complement the “Basics” part of the docs while bringing additional insights about immutability, testing, Redux best practices, and using Redux with React. **This course is free and will always be.**
>[“Great course on egghead.io by @dan_abramov - instead of just showing you how to use #redux, it also shows how and why redux was built!”](https://twitter.com/sandrinodm/status/670548531422326785)
>Sandrino Di Mattia
>[“Plowing through @dan_abramov 'Getting Started with Redux' - its amazing how much simpler concepts get with video.”](https://twitter.com/chrisdhanaraj/status/670328025553219584)
>Chris Dhanaraj
>[“This video series on Redux by @dan_abramov on @eggheadio is spectacular!”](https://twitter.com/eddiezane/status/670333133242408960)
>Eddie Zaneski
>[“Come for the name hype. Stay for the rock solid fundamentals. (Thanks, and great job @dan_abramov and @eggheadio!)”](https://twitter.com/danott/status/669909126554607617)
>Dan
>[“This series of videos on Redux by @dan_abramov is repeatedly blowing my mind - gunna do some serious refactoring”](https://twitter.com/gelatindesign/status/669658358643892224)
>Laurence Roberts
So, what are you waiting for?
#### [Watch the 30 Free Videos!](https://egghead.io/series/getting-started-with-redux)
If you enjoyed my course, consider supporting Egghead by [buying a subscription](https://egghead.io/pricing). Subscribers have access to the source code for the example in every one of my videos, as well as to tons of advanced lessons on other topics, including JavaScript in depth, React, Angular, and more. Many [Egghead instructors](https://egghead.io/instructors) are also open source library authors, so buying a subscription is a nice way to thank them for the work that they've done.
### Documentation
* [Introduction](http://redux.js.org/docs/introduction/index.html)
* [Basics](http://redux.js.org/docs/basics/index.html)
* [Advanced](http://redux.js.org/docs/advanced/index.html)
* [Recipes](http://redux.js.org/docs/recipes/index.html)
* [FAQ](http://redux.js.org/docs/FAQ.html)
* [Troubleshooting](http://redux.js.org/docs/Troubleshooting.html)
* [Glossary](http://redux.js.org/docs/Glossary.html)
* [API Reference](http://redux.js.org/docs/api/index.html)
For PDF, ePub, and MOBI exports for offline reading, and instructions on how to create them, please see: [paulkogel/redux-offline-docs](https://github.com/paulkogel/redux-offline-docs).
For Offline docs, please see: [devdocs](http://devdocs.io/redux/)
### Examples
Almost all examples have a corresponding CodeSandbox sandbox. This is an interactive version of the code that you can play with online.
* [Counter Vanilla](http://redux.js.org/docs/introduction/Examples.html#counter-vanilla) ([source](https://github.com/reactjs/redux/tree/master/examples/counter-vanilla))
* [Counter](http://redux.js.org/docs/introduction/Examples.html#counter) ([source](https://github.com/reactjs/redux/tree/master/examples/counter), [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/counter))
* [Todos](http://redux.js.org/docs/introduction/Examples.html#todos) ([source](https://github.com/reactjs/redux/tree/master/examples/todos), [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/todos))
* [Todos with Undo](http://redux.js.org/docs/introduction/Examples.html#todos-with-undo) ([source](https://github.com/reactjs/redux/tree/master/examples/todos-with-undo), [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/todos-with-undo))
* [TodoMVC](http://redux.js.org/docs/introduction/Examples.html#todomvc) ([source](https://github.com/reactjs/redux/tree/master/examples/todomvc), [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/todomvc))
* [Shopping Cart](http://redux.js.org/docs/introduction/Examples.html#shopping-cart) ([source](https://github.com/reactjs/redux/tree/master/examples/shopping-cart), [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/shopping-cart))
* [Tree View](http://redux.js.org/docs/introduction/Examples.html#tree-view) ([source](https://github.com/reactjs/redux/tree/master/examples/tree-view), [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/tree-view))
* [Async](http://redux.js.org/docs/introduction/Examples.html#async) ([source](https://github.com/reactjs/redux/tree/master/examples/async), [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/async))
* [Universal](http://redux.js.org/docs/introduction/Examples.html#universal) ([source](https://github.com/reactjs/redux/tree/master/examples/universal))
* [Real World](http://redux.js.org/docs/introduction/Examples.html#real-world) ([source](https://github.com/reactjs/redux/tree/master/examples/real-world), [sandbox](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/real-world))
If you're new to the NPM ecosystem and have troubles getting a project up and running, or aren't sure where to paste the gist above, check out [simplest-redux-example](https://github.com/jackielii/simplest-redux-example) that uses Redux together with React and Browserify.
### Discussion
Join the [#redux](https://discord.gg/0ZcbPKXt5bZ6au5t) channel of the [Reactiflux](http://www.reactiflux.com) Discord community.
### Thanks
* [The Elm Architecture](https://github.com/evancz/elm-architecture-tutorial) for a great intro to modeling state updates with reducers;
* [Turning the database inside-out](http://www.confluent.io/blog/turning-the-database-inside-out-with-apache-samza/) for blowing my mind;
* [Developing ClojureScript with Figwheel](https://www.youtube.com/watch?v=j-kj2qwJa_E) for convincing me that re-evaluation should “just work”;
* [Webpack](https://webpack.js.org/concepts/hot-module-replacement/) for Hot Module Replacement;
* [Flummox](https://github.com/acdlite/flummox) for teaching me to approach Flux without boilerplate or singletons;
* [disto](https://github.com/threepointone/disto) for a proof of concept of hot reloadable Stores;
* [NuclearJS](https://github.com/optimizely/nuclear-js) for proving this architecture can be performant;
* [Om](https://github.com/omcljs/om) for popularizing the idea of a single state atom;
* [Cycle](https://github.com/cyclejs/cycle-core) for showing how often a function is the best tool;
* [React](https://github.com/facebook/react) for the pragmatic innovation.
Special thanks to [Jamie Paton](http://jdpaton.github.io) for handing over the `redux` NPM package name.
### Logo
You can find the official logo [on GitHub](https://github.com/reactjs/redux/tree/master/logo).
### Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
Every release, along with the migration instructions, is documented on the Github [Releases](https://github.com/reactjs/redux/releases) page.
### Patrons
The work on Redux was [funded by the community](https://www.patreon.com/reactdx).
Meet some of the outstanding companies that made it possible:
* [Webflow](https://github.com/webflow)
* [Ximedes](https://www.ximedes.com/)
[See the full list of Redux patrons.](PATRONS.md), as well as the always-growing list of [people and companies that use Redux](https://github.com/reactjs/redux/issues/310).
### License
MIT

View File

@@ -0,0 +1,784 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.Redux = global.Redux || {})));
}(this, (function (exports) { 'use strict';
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();
/** Built-in value references. */
var Symbol = root.Symbol;
/** Used for built-in method references. */
var objectProto$1 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto$1.toString;
/** Built-in value references. */
var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty$1.call(value, symToStringTag$1),
tag = value[symToStringTag$1];
try {
value[symToStringTag$1] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag$1] = tag;
} else {
delete value[symToStringTag$1];
}
}
return result;
}
/** Used for built-in method references. */
var objectProto$2 = Object.prototype;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString$1 = objectProto$2.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString$1.call(value);
}
/** `Object#toString` result references. */
var nullTag = '[object Null]';
var undefinedTag = '[object Undefined]';
/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}
/**
* Creates a unary function that invokes `func` with its argument transformed.
*
* @private
* @param {Function} func The function to wrap.
* @param {Function} transform The argument transform.
* @returns {Function} Returns the new function.
*/
function overArg(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
/** Built-in value references. */
var getPrototype = overArg(Object.getPrototypeOf, Object);
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == 'object';
}
/** `Object#toString` result references. */
var objectTag = '[object Object]';
/** Used for built-in method references. */
var funcProto = Function.prototype;
var objectProto = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Used to infer the `Object` constructor. */
var objectCtorString = funcToString.call(Object);
/**
* Checks if `value` is a plain object, that is, an object created by the
* `Object` constructor or one with a `[[Prototype]]` of `null`.
*
* @static
* @memberOf _
* @since 0.8.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
* @example
*
* function Foo() {
* this.a = 1;
* }
*
* _.isPlainObject(new Foo);
* // => false
*
* _.isPlainObject([1, 2, 3]);
* // => false
*
* _.isPlainObject({ 'x': 0, 'y': 0 });
* // => true
*
* _.isPlainObject(Object.create(null));
* // => true
*/
function isPlainObject(value) {
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
return false;
}
var proto = getPrototype(value);
if (proto === null) {
return true;
}
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
funcToString.call(Ctor) == objectCtorString;
}
function symbolObservablePonyfill(root) {
var result;
var Symbol = root.Symbol;
if (typeof Symbol === 'function') {
if (Symbol.observable) {
result = Symbol.observable;
} else {
result = Symbol('observable');
Symbol.observable = result;
}
} else {
result = '@@observable';
}
return result;
}
/* global window */
var root$2;
if (typeof self !== 'undefined') {
root$2 = self;
} else if (typeof window !== 'undefined') {
root$2 = window;
} else if (typeof global !== 'undefined') {
root$2 = global;
} else if (typeof module !== 'undefined') {
root$2 = module;
} else {
root$2 = Function('return this')();
}
var result = symbolObservablePonyfill(root$2);
/**
* These are private action types reserved by Redux.
* For any unknown actions, you must return the current state.
* If the current state is undefined, you must return the initial state.
* Do not reference these action types directly in your code.
*/
var ActionTypes = {
INIT: '@@redux/INIT'
/**
* Creates a Redux store that holds the state tree.
* The only way to change the data in the store is to call `dispatch()` on it.
*
* There should only be a single store in your app. To specify how different
* parts of the state tree respond to actions, you may combine several reducers
* into a single reducer function by using `combineReducers`.
*
* @param {Function} reducer A function that returns the next state tree, given
* the current state tree and the action to handle.
*
* @param {any} [preloadedState] The initial state. You may optionally specify it
* to hydrate the state from the server in universal apps, or to restore a
* previously serialized user session.
* If you use `combineReducers` to produce the root reducer function, this must be
* an object with the same shape as `combineReducers` keys.
*
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
* to enhance the store with third-party capabilities such as middleware,
* time travel, persistence, etc. The only store enhancer that ships with Redux
* is `applyMiddleware()`.
*
* @returns {Store} A Redux store that lets you read the state, dispatch actions
* and subscribe to changes.
*/
};function createStore(reducer, preloadedState, enhancer) {
var _ref2;
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
enhancer = preloadedState;
preloadedState = undefined;
}
if (typeof enhancer !== 'undefined') {
if (typeof enhancer !== 'function') {
throw new Error('Expected the enhancer to be a function.');
}
return enhancer(createStore)(reducer, preloadedState);
}
if (typeof reducer !== 'function') {
throw new Error('Expected the reducer to be a function.');
}
var currentReducer = reducer;
var currentState = preloadedState;
var currentListeners = [];
var nextListeners = currentListeners;
var isDispatching = false;
function ensureCanMutateNextListeners() {
if (nextListeners === currentListeners) {
nextListeners = currentListeners.slice();
}
}
/**
* Reads the state tree managed by the store.
*
* @returns {any} The current state tree of your application.
*/
function getState() {
return currentState;
}
/**
* Adds a change listener. It will be called any time an action is dispatched,
* and some part of the state tree may potentially have changed. You may then
* call `getState()` to read the current state tree inside the callback.
*
* You may call `dispatch()` from a change listener, with the following
* caveats:
*
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
* If you subscribe or unsubscribe while the listeners are being invoked, this
* will not have any effect on the `dispatch()` that is currently in progress.
* However, the next `dispatch()` call, whether nested or not, will use a more
* recent snapshot of the subscription list.
*
* 2. The listener should not expect to see all state changes, as the state
* might have been updated multiple times during a nested `dispatch()` before
* the listener is called. It is, however, guaranteed that all subscribers
* registered before the `dispatch()` started will be called with the latest
* state by the time it exits.
*
* @param {Function} listener A callback to be invoked on every dispatch.
* @returns {Function} A function to remove this change listener.
*/
function subscribe(listener) {
if (typeof listener !== 'function') {
throw new Error('Expected listener to be a function.');
}
var isSubscribed = true;
ensureCanMutateNextListeners();
nextListeners.push(listener);
return function unsubscribe() {
if (!isSubscribed) {
return;
}
isSubscribed = false;
ensureCanMutateNextListeners();
var index = nextListeners.indexOf(listener);
nextListeners.splice(index, 1);
};
}
/**
* Dispatches an action. It is the only way to trigger a state change.
*
* The `reducer` function, used to create the store, will be called with the
* current state tree and the given `action`. Its return value will
* be considered the **next** state of the tree, and the change listeners
* will be notified.
*
* The base implementation only supports plain object actions. If you want to
* dispatch a Promise, an Observable, a thunk, or something else, you need to
* wrap your store creating function into the corresponding middleware. For
* example, see the documentation for the `redux-thunk` package. Even the
* middleware will eventually dispatch plain object actions using this method.
*
* @param {Object} action A plain object representing “what changed”. It is
* a good idea to keep actions serializable so you can record and replay user
* sessions, or use the time travelling `redux-devtools`. An action must have
* a `type` property which may not be `undefined`. It is a good idea to use
* string constants for action types.
*
* @returns {Object} For convenience, the same action object you dispatched.
*
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
* return something else (for example, a Promise you can await).
*/
function dispatch(action) {
if (!isPlainObject(action)) {
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
}
if (typeof action.type === 'undefined') {
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
}
if (isDispatching) {
throw new Error('Reducers may not dispatch actions.');
}
try {
isDispatching = true;
currentState = currentReducer(currentState, action);
} finally {
isDispatching = false;
}
var listeners = currentListeners = nextListeners;
for (var i = 0; i < listeners.length; i++) {
var listener = listeners[i];
listener();
}
return action;
}
/**
* Replaces the reducer currently used by the store to calculate the state.
*
* You might need this if your app implements code splitting and you want to
* load some of the reducers dynamically. You might also need this if you
* implement a hot reloading mechanism for Redux.
*
* @param {Function} nextReducer The reducer for the store to use instead.
* @returns {void}
*/
function replaceReducer(nextReducer) {
if (typeof nextReducer !== 'function') {
throw new Error('Expected the nextReducer to be a function.');
}
currentReducer = nextReducer;
dispatch({ type: ActionTypes.INIT });
}
/**
* Interoperability point for observable/reactive libraries.
* @returns {observable} A minimal observable of state changes.
* For more information, see the observable proposal:
* https://github.com/tc39/proposal-observable
*/
function observable() {
var _ref;
var outerSubscribe = subscribe;
return _ref = {
/**
* The minimal observable subscription method.
* @param {Object} observer Any object that can be used as an observer.
* The observer object should have a `next` method.
* @returns {subscription} An object with an `unsubscribe` method that can
* be used to unsubscribe the observable from the store, and prevent further
* emission of values from the observable.
*/
subscribe: function subscribe(observer) {
if (typeof observer !== 'object') {
throw new TypeError('Expected the observer to be an object.');
}
function observeState() {
if (observer.next) {
observer.next(getState());
}
}
observeState();
var unsubscribe = outerSubscribe(observeState);
return { unsubscribe: unsubscribe };
}
}, _ref[result] = function () {
return this;
}, _ref;
}
// When a store is created, an "INIT" action is dispatched so that every
// reducer returns their initial state. This effectively populates
// the initial state tree.
dispatch({ type: ActionTypes.INIT });
return _ref2 = {
dispatch: dispatch,
subscribe: subscribe,
getState: getState,
replaceReducer: replaceReducer
}, _ref2[result] = observable, _ref2;
}
/**
* Prints a warning in the console if it exists.
*
* @param {String} message The warning message.
* @returns {void}
*/
function warning(message) {
/* eslint-disable no-console */
if (typeof console !== 'undefined' && typeof console.error === 'function') {
console.error(message);
}
/* eslint-enable no-console */
try {
// This error was thrown as a convenience so that if you enable
// "break on all exceptions" in your console,
// it would pause the execution at this line.
throw new Error(message);
/* eslint-disable no-empty */
} catch (e) {}
/* eslint-enable no-empty */
}
function getUndefinedStateErrorMessage(key, action) {
var actionType = action && action.type;
var actionName = actionType && '"' + actionType.toString() + '"' || 'an action';
return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state. ' + 'If you want this reducer to hold no value, you can return null instead of undefined.';
}
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
var reducerKeys = Object.keys(reducers);
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
if (reducerKeys.length === 0) {
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
}
if (!isPlainObject(inputState)) {
return 'The ' + argumentName + ' has unexpected type of "' + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"');
}
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
});
unexpectedKeys.forEach(function (key) {
unexpectedKeyCache[key] = true;
});
if (unexpectedKeys.length > 0) {
return 'Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + '. ') + 'Expected to find one of the known reducer keys instead: ' + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.');
}
}
function assertReducerShape(reducers) {
Object.keys(reducers).forEach(function (key) {
var reducer = reducers[key];
var initialState = reducer(undefined, { type: ActionTypes.INIT });
if (typeof initialState === 'undefined') {
throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined. If you don\'t want to set a value for this reducer, ' + 'you can use null instead of undefined.');
}
var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.');
if (typeof reducer(undefined, { type: type }) === 'undefined') {
throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined, but can be null.');
}
});
}
/**
* Turns an object whose values are different reducer functions, into a single
* reducer function. It will call every child reducer, and gather their results
* into a single state object, whose keys correspond to the keys of the passed
* reducer functions.
*
* @param {Object} reducers An object whose values correspond to different
* reducer functions that need to be combined into one. One handy way to obtain
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
* undefined for any action. Instead, they should return their initial state
* if the state passed to them was undefined, and the current state for any
* unrecognized action.
*
* @returns {Function} A reducer function that invokes every reducer inside the
* passed object, and builds a state object with the same shape.
*/
function combineReducers(reducers) {
var reducerKeys = Object.keys(reducers);
var finalReducers = {};
for (var i = 0; i < reducerKeys.length; i++) {
var key = reducerKeys[i];
{
if (typeof reducers[key] === 'undefined') {
warning('No reducer provided for key "' + key + '"');
}
}
if (typeof reducers[key] === 'function') {
finalReducers[key] = reducers[key];
}
}
var finalReducerKeys = Object.keys(finalReducers);
var unexpectedKeyCache = void 0;
{
unexpectedKeyCache = {};
}
var shapeAssertionError = void 0;
try {
assertReducerShape(finalReducers);
} catch (e) {
shapeAssertionError = e;
}
return function combination() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments[1];
if (shapeAssertionError) {
throw shapeAssertionError;
}
{
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
if (warningMessage) {
warning(warningMessage);
}
}
var hasChanged = false;
var nextState = {};
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
var _key = finalReducerKeys[_i];
var reducer = finalReducers[_key];
var previousStateForKey = state[_key];
var nextStateForKey = reducer(previousStateForKey, action);
if (typeof nextStateForKey === 'undefined') {
var errorMessage = getUndefinedStateErrorMessage(_key, action);
throw new Error(errorMessage);
}
nextState[_key] = nextStateForKey;
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
}
return hasChanged ? nextState : state;
};
}
function bindActionCreator(actionCreator, dispatch) {
return function () {
return dispatch(actionCreator.apply(undefined, arguments));
};
}
/**
* Turns an object whose values are action creators, into an object with the
* same keys, but with every function wrapped into a `dispatch` call so they
* may be invoked directly. This is just a convenience method, as you can call
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
*
* For convenience, you can also pass a single function as the first argument,
* and get a function in return.
*
* @param {Function|Object} actionCreators An object whose values are action
* creator functions. One handy way to obtain it is to use ES6 `import * as`
* syntax. You may also pass a single function.
*
* @param {Function} dispatch The `dispatch` function available on your Redux
* store.
*
* @returns {Function|Object} The object mimicking the original object, but with
* every action creator wrapped into the `dispatch` call. If you passed a
* function as `actionCreators`, the return value will also be a single
* function.
*/
function bindActionCreators(actionCreators, dispatch) {
if (typeof actionCreators === 'function') {
return bindActionCreator(actionCreators, dispatch);
}
if (typeof actionCreators !== 'object' || actionCreators === null) {
throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');
}
var keys = Object.keys(actionCreators);
var boundActionCreators = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var actionCreator = actionCreators[key];
if (typeof actionCreator === 'function') {
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
}
}
return boundActionCreators;
}
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
* @param {...Function} funcs The functions to compose.
* @returns {Function} A function obtained by composing the argument functions
* from right to left. For example, compose(f, g, h) is identical to doing
* (...args) => f(g(h(...args))).
*/
function compose() {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
if (funcs.length === 0) {
return function (arg) {
return arg;
};
}
if (funcs.length === 1) {
return funcs[0];
}
return funcs.reduce(function (a, b) {
return function () {
return a(b.apply(undefined, arguments));
};
});
}
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
/**
* Creates a store enhancer that applies middleware to the dispatch method
* of the Redux store. This is handy for a variety of tasks, such as expressing
* asynchronous actions in a concise manner, or logging every action payload.
*
* See `redux-thunk` package as an example of the Redux middleware.
*
* Because middleware is potentially asynchronous, this should be the first
* store enhancer in the composition chain.
*
* Note that each middleware will be given the `dispatch` and `getState` functions
* as named arguments.
*
* @param {...Function} middlewares The middleware chain to be applied.
* @returns {Function} A store enhancer applying the middleware.
*/
function applyMiddleware() {
for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) {
middlewares[_key] = arguments[_key];
}
return function (createStore) {
return function (reducer, preloadedState, enhancer) {
var store = createStore(reducer, preloadedState, enhancer);
var _dispatch = store.dispatch;
var chain = [];
var middlewareAPI = {
getState: store.getState,
dispatch: function dispatch(action) {
return _dispatch(action);
}
};
chain = middlewares.map(function (middleware) {
return middleware(middlewareAPI);
});
_dispatch = compose.apply(undefined, chain)(store.dispatch);
return _extends({}, store, {
dispatch: _dispatch
});
};
};
}
/*
* This is a dummy function to check if the function name has been altered by minification.
* If the function has been minified and NODE_ENV !== 'production', warn the user.
*/
function isCrushed() {}
if ("development" !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
warning('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.');
}
exports.createStore = createStore;
exports.combineReducers = combineReducers;
exports.bindActionCreators = bindActionCreators;
exports.applyMiddleware = applyMiddleware;
exports.compose = compose;
Object.defineProperty(exports, '__esModule', { value: true });
})));

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,48 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
import compose from './compose';
/**
* Creates a store enhancer that applies middleware to the dispatch method
* of the Redux store. This is handy for a variety of tasks, such as expressing
* asynchronous actions in a concise manner, or logging every action payload.
*
* See `redux-thunk` package as an example of the Redux middleware.
*
* Because middleware is potentially asynchronous, this should be the first
* store enhancer in the composition chain.
*
* Note that each middleware will be given the `dispatch` and `getState` functions
* as named arguments.
*
* @param {...Function} middlewares The middleware chain to be applied.
* @returns {Function} A store enhancer applying the middleware.
*/
export default function applyMiddleware() {
for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) {
middlewares[_key] = arguments[_key];
}
return function (createStore) {
return function (reducer, preloadedState, enhancer) {
var store = createStore(reducer, preloadedState, enhancer);
var _dispatch = store.dispatch;
var chain = [];
var middlewareAPI = {
getState: store.getState,
dispatch: function dispatch(action) {
return _dispatch(action);
}
};
chain = middlewares.map(function (middleware) {
return middleware(middlewareAPI);
});
_dispatch = compose.apply(undefined, chain)(store.dispatch);
return _extends({}, store, {
dispatch: _dispatch
});
};
};
}

View File

@@ -0,0 +1,47 @@
function bindActionCreator(actionCreator, dispatch) {
return function () {
return dispatch(actionCreator.apply(undefined, arguments));
};
}
/**
* Turns an object whose values are action creators, into an object with the
* same keys, but with every function wrapped into a `dispatch` call so they
* may be invoked directly. This is just a convenience method, as you can call
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
*
* For convenience, you can also pass a single function as the first argument,
* and get a function in return.
*
* @param {Function|Object} actionCreators An object whose values are action
* creator functions. One handy way to obtain it is to use ES6 `import * as`
* syntax. You may also pass a single function.
*
* @param {Function} dispatch The `dispatch` function available on your Redux
* store.
*
* @returns {Function|Object} The object mimicking the original object, but with
* every action creator wrapped into the `dispatch` call. If you passed a
* function as `actionCreators`, the return value will also be a single
* function.
*/
export default function bindActionCreators(actionCreators, dispatch) {
if (typeof actionCreators === 'function') {
return bindActionCreator(actionCreators, dispatch);
}
if (typeof actionCreators !== 'object' || actionCreators === null) {
throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');
}
var keys = Object.keys(actionCreators);
var boundActionCreators = {};
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var actionCreator = actionCreators[key];
if (typeof actionCreator === 'function') {
boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
}
}
return boundActionCreators;
}

View File

@@ -0,0 +1,130 @@
import { ActionTypes } from './createStore';
import isPlainObject from 'lodash-es/isPlainObject';
import warning from './utils/warning';
function getUndefinedStateErrorMessage(key, action) {
var actionType = action && action.type;
var actionName = actionType && '"' + actionType.toString() + '"' || 'an action';
return 'Given action ' + actionName + ', reducer "' + key + '" returned undefined. ' + 'To ignore an action, you must explicitly return the previous state. ' + 'If you want this reducer to hold no value, you can return null instead of undefined.';
}
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
var reducerKeys = Object.keys(reducers);
var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
if (reducerKeys.length === 0) {
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
}
if (!isPlainObject(inputState)) {
return 'The ' + argumentName + ' has unexpected type of "' + {}.toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"');
}
var unexpectedKeys = Object.keys(inputState).filter(function (key) {
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
});
unexpectedKeys.forEach(function (key) {
unexpectedKeyCache[key] = true;
});
if (unexpectedKeys.length > 0) {
return 'Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + '. ') + 'Expected to find one of the known reducer keys instead: ' + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.');
}
}
function assertReducerShape(reducers) {
Object.keys(reducers).forEach(function (key) {
var reducer = reducers[key];
var initialState = reducer(undefined, { type: ActionTypes.INIT });
if (typeof initialState === 'undefined') {
throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined. If you don\'t want to set a value for this reducer, ' + 'you can use null instead of undefined.');
}
var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.');
if (typeof reducer(undefined, { type: type }) === 'undefined') {
throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined, but can be null.');
}
});
}
/**
* Turns an object whose values are different reducer functions, into a single
* reducer function. It will call every child reducer, and gather their results
* into a single state object, whose keys correspond to the keys of the passed
* reducer functions.
*
* @param {Object} reducers An object whose values correspond to different
* reducer functions that need to be combined into one. One handy way to obtain
* it is to use ES6 `import * as reducers` syntax. The reducers may never return
* undefined for any action. Instead, they should return their initial state
* if the state passed to them was undefined, and the current state for any
* unrecognized action.
*
* @returns {Function} A reducer function that invokes every reducer inside the
* passed object, and builds a state object with the same shape.
*/
export default function combineReducers(reducers) {
var reducerKeys = Object.keys(reducers);
var finalReducers = {};
for (var i = 0; i < reducerKeys.length; i++) {
var key = reducerKeys[i];
if (process.env.NODE_ENV !== 'production') {
if (typeof reducers[key] === 'undefined') {
warning('No reducer provided for key "' + key + '"');
}
}
if (typeof reducers[key] === 'function') {
finalReducers[key] = reducers[key];
}
}
var finalReducerKeys = Object.keys(finalReducers);
var unexpectedKeyCache = void 0;
if (process.env.NODE_ENV !== 'production') {
unexpectedKeyCache = {};
}
var shapeAssertionError = void 0;
try {
assertReducerShape(finalReducers);
} catch (e) {
shapeAssertionError = e;
}
return function combination() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments[1];
if (shapeAssertionError) {
throw shapeAssertionError;
}
if (process.env.NODE_ENV !== 'production') {
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
if (warningMessage) {
warning(warningMessage);
}
}
var hasChanged = false;
var nextState = {};
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
var _key = finalReducerKeys[_i];
var reducer = finalReducers[_key];
var previousStateForKey = state[_key];
var nextStateForKey = reducer(previousStateForKey, action);
if (typeof nextStateForKey === 'undefined') {
var errorMessage = getUndefinedStateErrorMessage(_key, action);
throw new Error(errorMessage);
}
nextState[_key] = nextStateForKey;
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
}
return hasChanged ? nextState : state;
};
}

View File

@@ -0,0 +1,32 @@
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
* @param {...Function} funcs The functions to compose.
* @returns {Function} A function obtained by composing the argument functions
* from right to left. For example, compose(f, g, h) is identical to doing
* (...args) => f(g(h(...args))).
*/
export default function compose() {
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) {
funcs[_key] = arguments[_key];
}
if (funcs.length === 0) {
return function (arg) {
return arg;
};
}
if (funcs.length === 1) {
return funcs[0];
}
return funcs.reduce(function (a, b) {
return function () {
return a(b.apply(undefined, arguments));
};
});
}

View File

@@ -0,0 +1,248 @@
import isPlainObject from 'lodash-es/isPlainObject';
import $$observable from 'symbol-observable';
/**
* These are private action types reserved by Redux.
* For any unknown actions, you must return the current state.
* If the current state is undefined, you must return the initial state.
* Do not reference these action types directly in your code.
*/
export var ActionTypes = {
INIT: '@@redux/INIT'
/**
* Creates a Redux store that holds the state tree.
* The only way to change the data in the store is to call `dispatch()` on it.
*
* There should only be a single store in your app. To specify how different
* parts of the state tree respond to actions, you may combine several reducers
* into a single reducer function by using `combineReducers`.
*
* @param {Function} reducer A function that returns the next state tree, given
* the current state tree and the action to handle.
*
* @param {any} [preloadedState] The initial state. You may optionally specify it
* to hydrate the state from the server in universal apps, or to restore a
* previously serialized user session.
* If you use `combineReducers` to produce the root reducer function, this must be
* an object with the same shape as `combineReducers` keys.
*
* @param {Function} [enhancer] The store enhancer. You may optionally specify it
* to enhance the store with third-party capabilities such as middleware,
* time travel, persistence, etc. The only store enhancer that ships with Redux
* is `applyMiddleware()`.
*
* @returns {Store} A Redux store that lets you read the state, dispatch actions
* and subscribe to changes.
*/
};export default function createStore(reducer, preloadedState, enhancer) {
var _ref2;
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
enhancer = preloadedState;
preloadedState = undefined;
}
if (typeof enhancer !== 'undefined') {
if (typeof enhancer !== 'function') {
throw new Error('Expected the enhancer to be a function.');
}
return enhancer(createStore)(reducer, preloadedState);
}
if (typeof reducer !== 'function') {
throw new Error('Expected the reducer to be a function.');
}
var currentReducer = reducer;
var currentState = preloadedState;
var currentListeners = [];
var nextListeners = currentListeners;
var isDispatching = false;
function ensureCanMutateNextListeners() {
if (nextListeners === currentListeners) {
nextListeners = currentListeners.slice();
}
}
/**
* Reads the state tree managed by the store.
*
* @returns {any} The current state tree of your application.
*/
function getState() {
return currentState;
}
/**
* Adds a change listener. It will be called any time an action is dispatched,
* and some part of the state tree may potentially have changed. You may then
* call `getState()` to read the current state tree inside the callback.
*
* You may call `dispatch()` from a change listener, with the following
* caveats:
*
* 1. The subscriptions are snapshotted just before every `dispatch()` call.
* If you subscribe or unsubscribe while the listeners are being invoked, this
* will not have any effect on the `dispatch()` that is currently in progress.
* However, the next `dispatch()` call, whether nested or not, will use a more
* recent snapshot of the subscription list.
*
* 2. The listener should not expect to see all state changes, as the state
* might have been updated multiple times during a nested `dispatch()` before
* the listener is called. It is, however, guaranteed that all subscribers
* registered before the `dispatch()` started will be called with the latest
* state by the time it exits.
*
* @param {Function} listener A callback to be invoked on every dispatch.
* @returns {Function} A function to remove this change listener.
*/
function subscribe(listener) {
if (typeof listener !== 'function') {
throw new Error('Expected listener to be a function.');
}
var isSubscribed = true;
ensureCanMutateNextListeners();
nextListeners.push(listener);
return function unsubscribe() {
if (!isSubscribed) {
return;
}
isSubscribed = false;
ensureCanMutateNextListeners();
var index = nextListeners.indexOf(listener);
nextListeners.splice(index, 1);
};
}
/**
* Dispatches an action. It is the only way to trigger a state change.
*
* The `reducer` function, used to create the store, will be called with the
* current state tree and the given `action`. Its return value will
* be considered the **next** state of the tree, and the change listeners
* will be notified.
*
* The base implementation only supports plain object actions. If you want to
* dispatch a Promise, an Observable, a thunk, or something else, you need to
* wrap your store creating function into the corresponding middleware. For
* example, see the documentation for the `redux-thunk` package. Even the
* middleware will eventually dispatch plain object actions using this method.
*
* @param {Object} action A plain object representing “what changed”. It is
* a good idea to keep actions serializable so you can record and replay user
* sessions, or use the time travelling `redux-devtools`. An action must have
* a `type` property which may not be `undefined`. It is a good idea to use
* string constants for action types.
*
* @returns {Object} For convenience, the same action object you dispatched.
*
* Note that, if you use a custom middleware, it may wrap `dispatch()` to
* return something else (for example, a Promise you can await).
*/
function dispatch(action) {
if (!isPlainObject(action)) {
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
}
if (typeof action.type === 'undefined') {
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
}
if (isDispatching) {
throw new Error('Reducers may not dispatch actions.');
}
try {
isDispatching = true;
currentState = currentReducer(currentState, action);
} finally {
isDispatching = false;
}
var listeners = currentListeners = nextListeners;
for (var i = 0; i < listeners.length; i++) {
var listener = listeners[i];
listener();
}
return action;
}
/**
* Replaces the reducer currently used by the store to calculate the state.
*
* You might need this if your app implements code splitting and you want to
* load some of the reducers dynamically. You might also need this if you
* implement a hot reloading mechanism for Redux.
*
* @param {Function} nextReducer The reducer for the store to use instead.
* @returns {void}
*/
function replaceReducer(nextReducer) {
if (typeof nextReducer !== 'function') {
throw new Error('Expected the nextReducer to be a function.');
}
currentReducer = nextReducer;
dispatch({ type: ActionTypes.INIT });
}
/**
* Interoperability point for observable/reactive libraries.
* @returns {observable} A minimal observable of state changes.
* For more information, see the observable proposal:
* https://github.com/tc39/proposal-observable
*/
function observable() {
var _ref;
var outerSubscribe = subscribe;
return _ref = {
/**
* The minimal observable subscription method.
* @param {Object} observer Any object that can be used as an observer.
* The observer object should have a `next` method.
* @returns {subscription} An object with an `unsubscribe` method that can
* be used to unsubscribe the observable from the store, and prevent further
* emission of values from the observable.
*/
subscribe: function subscribe(observer) {
if (typeof observer !== 'object') {
throw new TypeError('Expected the observer to be an object.');
}
function observeState() {
if (observer.next) {
observer.next(getState());
}
}
observeState();
var unsubscribe = outerSubscribe(observeState);
return { unsubscribe: unsubscribe };
}
}, _ref[$$observable] = function () {
return this;
}, _ref;
}
// When a store is created, an "INIT" action is dispatched so that every
// reducer returns their initial state. This effectively populates
// the initial state tree.
dispatch({ type: ActionTypes.INIT });
return _ref2 = {
dispatch: dispatch,
subscribe: subscribe,
getState: getState,
replaceReducer: replaceReducer
}, _ref2[$$observable] = observable, _ref2;
}

View File

@@ -0,0 +1,18 @@
import createStore from './createStore';
import combineReducers from './combineReducers';
import bindActionCreators from './bindActionCreators';
import applyMiddleware from './applyMiddleware';
import compose from './compose';
import warning from './utils/warning';
/*
* This is a dummy function to check if the function name has been altered by minification.
* If the function has been minified and NODE_ENV !== 'production', warn the user.
*/
function isCrushed() {}
if (process.env.NODE_ENV !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
warning('You are currently using minified code outside of NODE_ENV === \'production\'. ' + 'This means that you are running a slower development build of Redux. ' + 'You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + 'or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + 'to ensure you have the correct code for your production build.');
}
export { createStore, combineReducers, bindActionCreators, applyMiddleware, compose };

Some files were not shown because too many files have changed in this diff Show More