├── .babelrc
├── .travis.yml
├── .eslintignore
├── test
├── mocha.opts
├── utils
│ ├── rafPolyfill.js
│ ├── enzyme.js
│ └── dom.js
└── __tests__
│ ├── const.js
│ ├── actions.js
│ ├── reducer.js
│ └── notifications.js
├── example
└── src
│ ├── .gitignore
│ ├── store.js
│ ├── example.js
│ ├── index.html
│ ├── example.less
│ └── components
│ └── container.js
├── src
├── const.js
├── reducer.js
├── actions.js
└── notifications.js
├── .editorconfig
├── lib
├── const.js
├── reducer.js
├── actions.js
└── notifications.js
├── .gitignore
├── bower.json
├── .eslintrc
├── gulpfile.js
├── LICENSE
├── package.json
├── README.md
└── dist
└── react-notification-system-redux.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["airbnb", "stage-1", "stage-2"]
3 | }
4 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "6"
4 | - "5"
5 | - "4"
6 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | .publish/*
2 | dist/*
3 | example/dist/*
4 | lib/*
5 | node_modules/*
6 |
--------------------------------------------------------------------------------
/test/mocha.opts:
--------------------------------------------------------------------------------
1 | --compilers js:babel-register
2 | --require test/utils/dom.js
3 | --require test/utils/enzyme.js
4 | --reporter spec
5 |
--------------------------------------------------------------------------------
/test/utils/rafPolyfill.js:
--------------------------------------------------------------------------------
1 | const raf = global.requestAnimationFrame = (cb) => {
2 | setTimeout(cb, 0);
3 | };
4 |
5 | export default raf;
--------------------------------------------------------------------------------
/test/utils/enzyme.js:
--------------------------------------------------------------------------------
1 | import './rafPolyfill';
2 | import { configure } from 'enzyme';
3 | import Adapter from 'enzyme-adapter-react-16';
4 |
5 | configure({ adapter: new Adapter() });
6 |
--------------------------------------------------------------------------------
/example/src/.gitignore:
--------------------------------------------------------------------------------
1 | ## This file is here to ensure it is included in the gh-pages branch,
2 | ## when `gulp deploy` is used to push updates to the demo site.
3 |
4 | # Dependency directory
5 | node_modules
6 |
--------------------------------------------------------------------------------
/src/const.js:
--------------------------------------------------------------------------------
1 | export const RNS_SHOW_NOTIFICATION = 'RNS_SHOW_NOTIFICATION';
2 | export const RNS_HIDE_NOTIFICATION = 'RNS_HIDE_NOTIFICATION';
3 | export const RNS_REMOVE_ALL_NOTIFICATIONS = 'RNS_REMOVE_ALL_NOTIFICATIONS';
4 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # This file is for unifying the coding style for different editors and IDEs
2 | # editorconfig.org
3 | root = true
4 |
5 | [*]
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = false
9 | insert_final_newline = true
10 | indent_style = tab
11 |
12 | [*.json]
13 | indent_style = space
14 | indent_size = 2
15 |
--------------------------------------------------------------------------------
/example/src/store.js:
--------------------------------------------------------------------------------
1 | import {createStore, combineReducers} from 'redux';
2 |
3 | import {reducer as notifications} from 'react-notification-system-redux';
4 |
5 | export function configureStore(initialState = {}) {
6 | return createStore(
7 | combineReducers({
8 | notifications
9 | }),
10 | initialState
11 | );
12 | }
13 |
--------------------------------------------------------------------------------
/lib/const.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 | var RNS_SHOW_NOTIFICATION = exports.RNS_SHOW_NOTIFICATION = 'RNS_SHOW_NOTIFICATION';
7 | var RNS_HIDE_NOTIFICATION = exports.RNS_HIDE_NOTIFICATION = 'RNS_HIDE_NOTIFICATION';
8 | var RNS_REMOVE_ALL_NOTIFICATIONS = exports.RNS_REMOVE_ALL_NOTIFICATIONS = 'RNS_REMOVE_ALL_NOTIFICATIONS';
--------------------------------------------------------------------------------
/test/__tests__/const.js:
--------------------------------------------------------------------------------
1 | import { expect } from 'chai';
2 | import * as Constants from '../../src/const';
3 |
4 | describe('constants', () => {
5 | it('should be defined', () => {
6 | expect(Constants.RNS_SHOW_NOTIFICATION).to.be.defined;
7 | expect(Constants.RNS_HIDE_NOTIFICATION).to.be.defined;
8 | expect(Constants.RNS_REMOVE_ALL_NOTIFICATIONS).to.be.defined;
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Coverage tools
11 | lib-cov
12 | coverage
13 | coverage.html
14 | .cover*
15 |
16 | # Dependency directory
17 | node_modules
18 |
19 | # Example build directory
20 | example/dist
21 | .publish
22 |
23 | # Editor and other tmp files
24 | *.swp
25 | *.un~
26 | *.iml
27 | *.ipr
28 | *.iws
29 | *.sublime-*
30 | .idea/
31 | *.DS_Store
32 | .vscode
33 |
--------------------------------------------------------------------------------
/example/src/example.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 |
4 | import {Provider} from 'react-redux';
5 | import {configureStore} from './store';
6 |
7 | import Container from './components/container';
8 |
9 | const store = configureStore();
10 |
11 | window.appStore = store; //In case you want to see what's inside by executing appStore in console;
12 |
13 | class App extends React.Component {
14 | render() {
15 | return (
16 |
17 |
18 |
19 | );
20 | }
21 | }
22 |
23 | ReactDOM.render(, document.getElementById('app'));
24 |
--------------------------------------------------------------------------------
/src/reducer.js:
--------------------------------------------------------------------------------
1 | import {RNS_SHOW_NOTIFICATION, RNS_HIDE_NOTIFICATION, RNS_REMOVE_ALL_NOTIFICATIONS} from './const';
2 |
3 | export default function Notifications(state = [], action = {}) {
4 | switch(action.type) {
5 | case RNS_SHOW_NOTIFICATION:
6 | const { type, ...rest } = action;
7 | return [
8 | ...state,
9 | { ...rest, uid: action.uid}
10 | ];
11 | case RNS_HIDE_NOTIFICATION:
12 | return state.filter(notification => {
13 | return notification.uid !== action.uid;
14 | });
15 | case RNS_REMOVE_ALL_NOTIFICATIONS:
16 | return [];
17 | }
18 | return state;
19 | }
20 |
--------------------------------------------------------------------------------
/example/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | React Notification System Redux
4 |
5 |
6 |
7 |
8 |
react-notification-system-redux
9 |
10 |
11 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-notification-system-redux",
3 | "version": "0.0.0",
4 | "description": "Redux wrapper for react-notification-system",
5 | "main": "dist/react-notification-system-redux.min.js",
6 | "homepage": "https://github.com/gor181/react-notification-system-redux",
7 | "authors": [
8 | "Goran Udosic"
9 | ],
10 | "moduleType": [
11 | "amd",
12 | "globals",
13 | "node"
14 | ],
15 | "keywords": [
16 | "react-notification-system",
17 | "redux",
18 | "notifications",
19 | "react",
20 | "react-component"
21 | ],
22 | "license": "MIT",
23 | "ignore": [
24 | ".editorconfig",
25 | ".gitignore",
26 | "package.json",
27 | "src",
28 | "node_modules",
29 | "example",
30 | "test"
31 | ]
32 | }
33 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "env": {
4 | "browser": true,
5 | "node": true
6 | },
7 | "plugins": [
8 | "react"
9 | ],
10 | "rules": {
11 | "curly": [2, "multi-line"],
12 | "quotes": [2, "single", "avoid-escape"],
13 | "react/display-name": 0,
14 | "react/jsx-boolean-value": 1,
15 | "react/jsx-quotes": 1,
16 | "react/jsx-no-undef": 1,
17 | "react/jsx-sort-props": 0,
18 | "react/jsx-sort-prop-types": 1,
19 | "react/jsx-uses-react": 1,
20 | "react/jsx-uses-vars": 1,
21 | "react/no-did-mount-set-state": 1,
22 | "react/no-did-update-set-state": 1,
23 | "react/no-unknown-property": 1,
24 | "react/prop-types": 1,
25 | "react/react-in-jsx-scope": 1,
26 | "react/self-closing-comp": 1,
27 | "react/wrap-multilines": 1,
28 | "semi": 2,
29 | "strict": 0
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/test/__tests__/actions.js:
--------------------------------------------------------------------------------
1 | import { expect } from 'chai';
2 | import * as Actions from '../../src/actions';
3 |
4 | describe('actions', () => {
5 | it('sets the correct notification level', () => {
6 | expect(Actions.success().level).to.equal('success');
7 | expect(Actions.warning().level).to.equal('warning');
8 | expect(Actions.info().level).to.equal('info');
9 | expect(Actions.error().level).to.equal('error');
10 | });
11 |
12 | it('accepts custom opts', () => {
13 | expect(Actions.success({ custom: true }).custom).to.be.ok;
14 | });
15 |
16 | it('generates random uid when not provided', () => {
17 | expect(Actions.success().uid).to.be.defined;
18 | });
19 |
20 | it('sets the custom uid when provided', () => {
21 | expect(Actions.success({ uid: 1 }).uid).to.equal(1);
22 | });
23 | });
24 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | var gulp = require('gulp');
2 | var initGulpTasks = require('react-component-gulp-tasks');
3 |
4 | /**
5 | * Tasks are added by the react-component-gulp-tasks package
6 | *
7 | * See https://github.com/JedWatson/react-component-gulp-tasks
8 | * for documentation.
9 | *
10 | * You can also add your own additional gulp tasks if you like.
11 | */
12 |
13 | var taskConfig = {
14 |
15 | component: {
16 | name: 'notifications',
17 | dependencies: [
18 | 'react',
19 | 'react-dom',
20 | 'react-notification-system'
21 | ],
22 | lib: 'lib'
23 | },
24 |
25 | example: {
26 | src: 'example/src',
27 | dist: 'example/dist',
28 | files: [
29 | 'index.html',
30 | '.gitignore'
31 | ],
32 | scripts: [
33 | 'example.js'
34 | ],
35 | less: [
36 | 'example.less'
37 | ]
38 | }
39 |
40 | };
41 |
42 | initGulpTasks(gulp, taskConfig);
43 |
--------------------------------------------------------------------------------
/example/src/example.less:
--------------------------------------------------------------------------------
1 | /*
2 | // Examples Stylesheet
3 | // -------------------
4 | */
5 |
6 | body {
7 | font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
8 | font-size: 14px;
9 | color: #333;
10 | margin: 0;
11 | padding: 0;
12 | }
13 |
14 | a {
15 | color: #08c;
16 | text-decoration: none;
17 | }
18 |
19 | a:hover {
20 | text-decoration: underline;
21 | }
22 |
23 | .container {
24 | margin-left: auto;
25 | margin-right: auto;
26 | max-width: 720px;
27 | padding: 1em;
28 | }
29 |
30 | .footer {
31 | margin-top: 50px;
32 | border-top: 1px solid #eee;
33 | padding: 20px 0;
34 | font-size: 12px;
35 | color: #999;
36 | }
37 |
38 | h1, h2, h3, h4, h5, h6 {
39 | color: #222;
40 | font-weight: 100;
41 | margin: 0.5em 0;
42 | }
43 |
44 | label {
45 | color: #999;
46 | display: inline-block;
47 | font-size: 0.85em;
48 | font-weight: bold;
49 | margin: 1em 0;
50 | text-transform: uppercase;
51 | }
52 |
53 | .hint {
54 | margin: 15px 0;
55 | font-style: italic;
56 | color: #999;
57 | }
58 |
--------------------------------------------------------------------------------
/test/utils/dom.js:
--------------------------------------------------------------------------------
1 | const jsdom = require('jsdom');
2 |
3 | // setup the simplest document possible
4 | const doc = jsdom.jsdom('');
5 |
6 | // get the window object out of the document
7 | const win = doc.defaultView;
8 |
9 | // set globals for mocha that make access to document and window feel
10 | // natural in the test environment
11 | global.document = doc;
12 | global.window = win;
13 |
14 | //JSDOM doesn't support localStrage by default, so lets just fake it..
15 | if (!global.window.localStorage) {
16 | global.window.localStorage = {
17 | getItem() { return '{}'; },
18 | setItem() {}
19 | };
20 | }
21 |
22 | // take all properties of the window object and also attach it to the
23 | // mocha global object
24 | propagateToGlobal(win);
25 |
26 | // from mocha-jsdom https://github.com/rstacruz/mocha-jsdom/blob/master/index.js#L80
27 | function propagateToGlobal (window) {
28 | for (let key in window) {
29 | if (!window.hasOwnProperty(key)) continue;
30 | if (key in global) continue;
31 |
32 | global[key] = window[key];
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Goran Udosic
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/test/__tests__/reducer.js:
--------------------------------------------------------------------------------
1 | import { expect } from 'chai';
2 |
3 | import Reducer from '../../src/reducer';
4 | import * as Actions from '../../src/actions';
5 |
6 | describe('reducer', () => {
7 | it('initializes state with an array', () => {
8 | expect(Reducer()).to.deep.equal([]);
9 | });
10 |
11 | it('stores the notification to state', () => {
12 | const action = Actions.success();
13 | const state = Reducer([], action);
14 |
15 | expect(state.length).to.equal(1);
16 | });
17 |
18 | it('stores and removes notification', () => {
19 | const uid = 1;
20 |
21 | const state = Reducer([], Actions.success({ uid }));
22 | expect(state.length).to.equal(1);
23 |
24 | const newState = Reducer(state, Actions.hide(uid));
25 | expect(newState.length).to.equal(0);
26 | });
27 |
28 | it('removes all notifications', () => {
29 | const state = Reducer([], Actions.success({ uid: 1 }));
30 | const newState = Reducer(state, Actions.success({ uid: 2 }));
31 | const emptyState = Reducer(newState, Actions.removeAll());
32 |
33 | expect(newState.length).to.equal(2);
34 | expect(emptyState.length).to.equal(0);
35 | });
36 | });
37 |
--------------------------------------------------------------------------------
/src/actions.js:
--------------------------------------------------------------------------------
1 | import {RNS_SHOW_NOTIFICATION, RNS_HIDE_NOTIFICATION, RNS_REMOVE_ALL_NOTIFICATIONS} from './const';
2 |
3 | //Example opts
4 | // {
5 | // title: 'Hey, it\'s good to see you!',
6 | // message: 'Now you can see how easy it is to use notifications in React!',
7 | // position: 'tr',
8 | // autoDismiss: 0,
9 | // action: {
10 | // label: 'Awesome!',
11 | // callback: function() {
12 | // console.log('Clicked');
13 | // }
14 | // }
15 | // }
16 |
17 | export function show(opts = {}, level = 'success') {
18 | return {
19 | type: RNS_SHOW_NOTIFICATION,
20 | ...opts,
21 | uid: opts.uid || Date.now(),
22 | level
23 | };
24 | }
25 |
26 | export function success(opts) {
27 | return show(opts, 'success');
28 | }
29 |
30 | export function error(opts) {
31 | return show(opts, 'error');
32 | }
33 |
34 | export function warning(opts) {
35 | return show(opts, 'warning');
36 | }
37 |
38 | export function info(opts) {
39 | return show(opts, 'info');
40 | }
41 |
42 | export function hide(uid) {
43 | return {
44 | type: RNS_HIDE_NOTIFICATION,
45 | uid
46 | };
47 | }
48 |
49 | export function removeAll() {
50 | return { type: RNS_REMOVE_ALL_NOTIFICATIONS };
51 | }
52 |
--------------------------------------------------------------------------------
/lib/reducer.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | 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; };
8 |
9 | exports['default'] = Notifications;
10 |
11 | var _const = require('./const');
12 |
13 | 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); } }
14 |
15 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
16 |
17 | function Notifications() {
18 | var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
19 | var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
20 |
21 | switch (action.type) {
22 | case _const.RNS_SHOW_NOTIFICATION:
23 | var type = action.type,
24 | rest = _objectWithoutProperties(action, ['type']);
25 |
26 | return [].concat(_toConsumableArray(state), [_extends({}, rest, { uid: action.uid })]);
27 | case _const.RNS_HIDE_NOTIFICATION:
28 | return state.filter(function (notification) {
29 | return notification.uid !== action.uid;
30 | });
31 | case _const.RNS_REMOVE_ALL_NOTIFICATIONS:
32 | return [];
33 | }
34 | return state;
35 | }
--------------------------------------------------------------------------------
/lib/actions.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | Object.defineProperty(exports, "__esModule", {
4 | value: true
5 | });
6 |
7 | 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; };
8 |
9 | exports.show = show;
10 | exports.success = success;
11 | exports.error = error;
12 | exports.warning = warning;
13 | exports.info = info;
14 | exports.hide = hide;
15 | exports.removeAll = removeAll;
16 |
17 | var _const = require('./const');
18 |
19 | //Example opts
20 | // {
21 | // title: 'Hey, it\'s good to see you!',
22 | // message: 'Now you can see how easy it is to use notifications in React!',
23 | // position: 'tr',
24 | // autoDismiss: 0,
25 | // action: {
26 | // label: 'Awesome!',
27 | // callback: function() {
28 | // console.log('Clicked');
29 | // }
30 | // }
31 | // }
32 |
33 | function show() {
34 | var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35 | var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'success';
36 |
37 | return _extends({
38 | type: _const.RNS_SHOW_NOTIFICATION
39 | }, opts, {
40 | uid: opts.uid || Date.now(),
41 | level: level
42 | });
43 | }
44 |
45 | function success(opts) {
46 | return show(opts, 'success');
47 | }
48 |
49 | function error(opts) {
50 | return show(opts, 'error');
51 | }
52 |
53 | function warning(opts) {
54 | return show(opts, 'warning');
55 | }
56 |
57 | function info(opts) {
58 | return show(opts, 'info');
59 | }
60 |
61 | function hide(uid) {
62 | return {
63 | type: _const.RNS_HIDE_NOTIFICATION,
64 | uid: uid
65 | };
66 | }
67 |
68 | function removeAll() {
69 | return { type: _const.RNS_REMOVE_ALL_NOTIFICATIONS };
70 | }
--------------------------------------------------------------------------------
/example/src/components/container.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 | import {connect} from 'react-redux';
4 |
5 | import Notifications, { success, error, warning, info, removeAll } from '../../../src/notifications';
6 |
7 | const notificationOpts = {
8 | // uid: 'once-please', // you can specify your own uid if required
9 | title: 'Hey, it\'s good to see you!',
10 | message: 'Now you can see how easy it is to use notifications in React!',
11 | position: 'tr',
12 | autoDismiss: 0,
13 | action: {
14 | label: 'Click me!!',
15 | callback: () => alert('clicked!')
16 | }
17 | };
18 |
19 | class Container extends React.Component {
20 |
21 | constructor(props) {
22 | super(props);
23 |
24 | this.handleClick = this.handleClick.bind(this);
25 | this.handleRemoveAll = this.handleRemoveAll.bind(this);
26 | }
27 |
28 | dispatchNotification(fn, timeout) {
29 | setTimeout(() => {
30 | fn(notificationOpts);
31 | }, timeout);
32 | }
33 |
34 | handleClick() {
35 | const { success, error, warning, info, removeAll } = this.props;
36 | this.dispatchNotification(success, 250);
37 | this.dispatchNotification(error, 500);
38 | this.dispatchNotification(warning, 750);
39 | this.dispatchNotification(info, 1000);
40 | }
41 |
42 | handleRemoveAll() {
43 | this.props.removeAll();
44 | }
45 |
46 | render() {
47 | const {notifications} = this.props;
48 |
49 | return (
50 |
51 |
52 |
53 |
54 |
55 | );
56 | }
57 | }
58 |
59 | Container.propTypes = {
60 | error: PropTypes.func.isRequired,
61 | info: PropTypes.func.isRequired,
62 | notifications: PropTypes.array,
63 | removeAll: PropTypes.func.isRequired,
64 | success: PropTypes.func.isRequired,
65 | warning: PropTypes.func.isRequired
66 | };
67 |
68 | export default connect(
69 | state => ({ notifications: state.notifications }),
70 | {
71 | success, error, warning, info, removeAll
72 | }
73 | )(Container);
74 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-notification-system-redux",
3 | "version": "2.0.1",
4 | "description": "react-notification-system-redux",
5 | "main": "lib/notifications.js",
6 | "author": "Goran Udosic",
7 | "homepage": "https://github.com/gor181/react-notification-system-redux",
8 | "repository": {
9 | "type": "git",
10 | "url": "https://github.com/gor181/react-notification-system-redux.git"
11 | },
12 | "bugs": {
13 | "url": "https://github.com/gor181/react-notification-system-redux/issues"
14 | },
15 | "devDependencies": {
16 | "babel-core": "^6.14.0",
17 | "babel-eslint": "^4.1.3",
18 | "babel-jest": "^14.1.0",
19 | "babel-polyfill": "^6.13.0",
20 | "babel-preset-airbnb": "^2.0.0",
21 | "babel-preset-es2015": "^6.14.0",
22 | "babel-preset-react": "^6.11.1",
23 | "babel-preset-stage-1": "^6.13.0",
24 | "babel-preset-stage-2": "^6.13.0",
25 | "babel-register": "^6.18.0",
26 | "babelify": "^7.3.0",
27 | "brfs": "^1.4.3",
28 | "chai": "^3.5.0",
29 | "cross-env": "^5.2.0",
30 | "enzyme": "^3.1.0",
31 | "enzyme-adapter-react-16": "^1.0.2",
32 | "eslint": "^6.6.0",
33 | "eslint-plugin-react": "^3.5.1",
34 | "gulp": "^3.9.0",
35 | "jest-cli": "^14.1.0",
36 | "jsdom": "^9.8.3",
37 | "lodash": "^4.14.2",
38 | "mocha": "^3.2.0",
39 | "react": "^16.7.0",
40 | "react-component-gulp-tasks": "git+https://github.com/gor181/react-component-gulp-tasks.git",
41 | "react-dom": "^16.7.0",
42 | "react-redux": "^6.0.0",
43 | "redux": "^4.0.1",
44 | "redux-mock-store": "^1.5.3",
45 | "sinon": "^1.17.6"
46 | },
47 | "dependencies": {
48 | "prop-types": "^15.6.0",
49 | "react-notification-system": "^0.2.x"
50 | },
51 | "peerDependencies": {
52 | "react": ">=16.4.0-0 || 17.0.2",
53 | "react-dom": ">=16.4.0-0 || 17.0.2",
54 | "react-redux": "^6.0.0 || ^7.0.0",
55 | "redux": "^3.6.0 || ^4.0.0"
56 | },
57 | "browserify-shim": {
58 | "react": "global:React"
59 | },
60 | "scripts": {
61 | "build": "gulp clean && cross-env NODE_ENV=production gulp build",
62 | "examples": "gulp dev:server",
63 | "lint": "eslint ./; true",
64 | "publish:site": "cross-env NODE_ENV=production gulp publish:examples",
65 | "release": "cross-env NODE_ENV=production gulp release",
66 | "start": "gulp dev",
67 | "test": "mocha test/__tests__/**/*",
68 | "test-dev": "mocha test/__tests__/**/* --watch",
69 | "watch": "gulp watch:lib"
70 | },
71 | "keywords": [
72 | "react-notification-system",
73 | "redux"
74 | ]
75 | }
76 |
--------------------------------------------------------------------------------
/src/notifications.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import PropTypes from 'prop-types';
3 | import { ReactReduxContext } from 'react-redux';
4 |
5 | import * as actions from './actions';
6 | import reducer from './reducer';
7 |
8 | import NotifySystem from 'react-notification-system';
9 |
10 | class Notifications extends React.Component {
11 |
12 | constructor (props) {
13 | super(props);
14 |
15 | this.notifyRef = React.createRef();
16 | }
17 |
18 | system() {
19 | return this.notifyRef.current;
20 | }
21 |
22 | componentDidUpdate(prevProps) {
23 | const {notifications, store} = this.props;
24 | const notificationIds = notifications.map(notification => notification.uid);
25 | const systemNotifications = this.system().state.notifications || [];
26 |
27 | if (notifications.length > 0) {
28 | // Get all active notifications from react-notification-system
29 | /// and remove all where uid is not found in the reducer
30 | (systemNotifications).forEach(notification => {
31 | if (notificationIds.indexOf(notification.uid) < 0) {
32 | this.system().removeNotification(notification.uid);
33 | }
34 | });
35 |
36 | notifications.forEach(notification => {
37 | this.system().addNotification({
38 | ...notification,
39 | onRemove: () => {
40 | store.dispatch(actions.hide(notification.uid));
41 | notification.onRemove && notification.onRemove();
42 | }
43 | });
44 | });
45 | }
46 |
47 | if ((prevProps.notifications !== notifications) && notifications.length === 0) {
48 | this.system().clearNotifications();
49 | }
50 | }
51 |
52 | shouldComponentUpdate(nextProps) {
53 | return this.props !== nextProps;
54 | }
55 |
56 | render() {
57 | const {notifications, store, ...rest} = this.props;
58 |
59 | return (
60 |
61 | );
62 | }
63 | }
64 |
65 | Notifications.propTypes = {
66 | notifications: PropTypes.array,
67 | store: PropTypes.shape({
68 | dispatch: PropTypes.func.isRequired
69 | }).isRequired
70 | };
71 |
72 | const NotificationsWithContext = props => {
73 | const Context = props.context || ReactReduxContext;
74 |
75 | if (Context == null) {
76 | throw 'Please upgrade to react-redux v6';
77 | }
78 |
79 | return (
80 |
81 | {(otherProps) => {
82 | const { store } = otherProps;
83 | return ;
84 | }}
85 |
86 | );
87 | };
88 |
89 | NotificationsWithContext.propTypes = {
90 | context: PropTypes.object,
91 | };
92 |
93 | // Tie actions to Notifications component instance
94 | Object.keys(actions).forEach(key => {
95 | NotificationsWithContext[key] = actions[key];
96 | });
97 |
98 | NotificationsWithContext.reducer = reducer;
99 |
100 | module.exports = NotificationsWithContext;
101 |
--------------------------------------------------------------------------------
/test/__tests__/notifications.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import configureStore from 'redux-mock-store';
3 | import { mount } from 'enzyme';
4 | import { expect } from 'chai';
5 | import { jsdom } from 'jsdom';
6 | import sinon from 'sinon';
7 | import Component, {
8 | show,
9 | success,
10 | error,
11 | warning,
12 | info,
13 | hide,
14 | removeAll,
15 | reducer
16 | } from '../../src/notifications';
17 | import NotifySystem from 'react-notification-system';
18 |
19 | const createDOM = () =>
20 | jsdom('');
21 |
22 | describe('NotificationsComponent', () => {
23 | let DOM;
24 | let store;
25 |
26 | const notification = {
27 | title: "Hey, it's good to see you!",
28 | message: 'Now you can see how easy it is to use notifications in React!',
29 | dismissible: false,
30 | level: 'info',
31 | uid: 'demo-uid',
32 | autoDismiss: 5
33 | };
34 |
35 | beforeEach(() => {
36 | const mockStore = configureStore();
37 | store = mockStore({
38 | notifications: []
39 | });
40 |
41 | DOM = createDOM();
42 | });
43 |
44 | const mountComponent = props =>
45 | mount(
46 | ,
51 | {
52 | attachTo: DOM.body.firstChild,
53 | context: {
54 | store: {
55 | dispatch: () => {}
56 | }
57 | }
58 | }
59 | );
60 |
61 | it('exports all actions', () => {
62 | expect(show).to.be.a('function');
63 | expect(success).to.be.a('function');
64 | expect(error).to.be.a('function');
65 | expect(warning).to.be.a('function');
66 | expect(info).to.be.a('function');
67 | expect(hide).to.be.a('function');
68 | expect(removeAll).to.be.a('function');
69 | });
70 |
71 | it('exports the reducer', () => {
72 | expect(reducer).to.be.a('function');
73 | });
74 |
75 | it('should render one component', () => {
76 | const wrapper = mountComponent();
77 | expect(wrapper.find(NotifySystem).length).to.equal(1);
78 | });
79 |
80 | it('should warn if prop:notifications is not array', () => {
81 | const c = sinon.stub(console, 'error');
82 |
83 | const wrapper = mountComponent({ notifications: 1 });
84 | const warning = c.args[0][0];
85 |
86 | c.restore();
87 |
88 | expect(warning).to.match(
89 | /Invalid prop `notifications` of type `number` supplied to `Notifications`, expected `array`./
90 | );
91 | });
92 |
93 | it('should render a single notification', () => {
94 | const wrapper = mountComponent();
95 |
96 | wrapper.setProps({
97 | notifications: [notification]
98 | });
99 | wrapper.update();
100 |
101 | expect(wrapper.html()).to.have.string(notification.title);
102 | expect(wrapper.html()).to.have.string(notification.message);
103 | });
104 |
105 | it('should not add notification if it already exists based on the uid', () => {
106 | const wrapper = mountComponent();
107 |
108 | wrapper.setProps({
109 | notifications: [
110 | { ...notification, uid: 1, title: '1st' },
111 | { ...notification, uid: 2, title: '2nd' },
112 | { ...notification, uid: 3, title: '3rd' },
113 | { ...notification, uid: 1, title: '4th' },
114 | { ...notification, uid: 2, title: '5th' },
115 | { ...notification, uid: 3, title: '6th' }
116 | ]
117 | });
118 | wrapper.update();
119 |
120 | const html = wrapper.html();
121 |
122 | expect(html).to.have.string('1st');
123 | expect(html).to.have.string('2nd');
124 | expect(html).to.have.string('3rd');
125 |
126 | expect(html).not.to.have.string('4th');
127 | expect(html).not.to.have.string('5th');
128 | expect(html).not.to.have.string('6th');
129 | });
130 |
131 | it('calls onRemove once the notification is auto dismissed', done => {
132 | const wrapper = mountComponent();
133 | const onRemove = sinon.spy();
134 |
135 | wrapper.setProps({
136 | notifications: [
137 | {
138 | ...notification,
139 | autoDismiss: 1,
140 | onRemove
141 | }
142 | ]
143 | });
144 | wrapper.update();
145 |
146 | setTimeout(() => {
147 | expect(onRemove.called).to.be.true;
148 | done();
149 | }, 1100);
150 | });
151 |
152 | it('calls onRemove once the notification is manually dismissed', done => {
153 | const wrapper = mountComponent();
154 | const onRemove = sinon.spy();
155 | const onCallback = sinon.spy();
156 |
157 | wrapper.setProps({
158 | notifications: [
159 | {
160 | ...notification,
161 | autoDismiss: 0,
162 | action: {
163 | label: 'Dismiss',
164 | callback: onCallback
165 | },
166 | onRemove
167 | }
168 | ]
169 | });
170 | wrapper.update();
171 |
172 | wrapper.find('button').simulate('click');
173 |
174 | setTimeout(() => {
175 | expect(onCallback.called).to.be.true;
176 | expect(onRemove.called).to.be.true;
177 | done();
178 | }, 50);
179 | });
180 |
181 | it('calls onRemove once the notification is auto dismissed while style is false', done => {
182 | const wrapper = mountComponent({ style: false });
183 | const onRemove = sinon.spy();
184 |
185 | wrapper.setProps({
186 | notifications: [
187 | {
188 | ...notification,
189 | autoDismiss: 1,
190 | onRemove
191 | }
192 | ]
193 | });
194 | wrapper.update();
195 |
196 | setTimeout(() => {
197 | expect(onRemove.called).to.be.true;
198 | done();
199 | }, 1100);
200 | });
201 |
202 | it('calls onRemove once the notification is manually dismissed while style is false', done => {
203 | const wrapper = mountComponent({ style: false });
204 | const onRemove = sinon.spy();
205 | const onCallback = sinon.spy();
206 |
207 | wrapper.setProps({
208 | notifications: [
209 | {
210 | ...notification,
211 | autoDismiss: 0,
212 | action: {
213 | label: 'Dismiss',
214 | callback: onCallback
215 | },
216 | onRemove
217 | }
218 | ]
219 | });
220 | wrapper.update();
221 |
222 | wrapper.find('button').simulate('click');
223 |
224 | setTimeout(() => {
225 | expect(onCallback.called).to.be.true;
226 | expect(onRemove.called).to.be.true;
227 | done();
228 | }, 50);
229 | });
230 | });
231 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://travis-ci.org/gor181/react-notification-system-redux)
2 | [](https://www.npmjs.com/package/react-notification-system-redux)
3 | [](https://npm-stat.com/charts.html?package=react-notification-system-redux&from=2016-01-01)
4 | [](http://opensource.org/licenses/MIT)
5 |
6 | # react-notification-system-redux
7 |
8 | Wraps [react-notification-system](https://github.com/igorprado/react-notification-system) into a component and exposes actions and reducer.
9 |
10 | Open for PR's and contributions!
11 |
12 | Use versions below v2.0.0 for react versions lower than 16.
13 |
14 | ## Demo & Examples
15 |
16 | Live demo: [gor181.github.io/react-notification-system-redux](http://gor181.github.io/react-notification-system-redux/)
17 |
18 | To build the examples locally, run:
19 |
20 | ```
21 | npm install
22 | npm start
23 | ```
24 |
25 | Then open [`localhost:8000`](http://localhost:8000) in a browser.
26 |
27 |
28 | ## Installation via NPM
29 |
30 | ```
31 | npm install react-notification-system-redux react-notification-system --save
32 | ```
33 |
34 | ## Usage
35 |
36 | Import the reducer and pass it to your store:
37 |
38 | ``` javascript
39 | import {createStore, combineReducers} from 'redux';
40 |
41 | import {reducer as notifications} from 'react-notification-system-redux';
42 |
43 | export function configureStore(initialState = {}) {
44 | return createStore(
45 | combineReducers({
46 | notifications
47 | }),
48 | initialState
49 | );
50 | }
51 | ```
52 |
53 | Include the Notifications component and pass the data from the reducer by using `connect`:
54 |
55 | ``` javascript
56 | import React, {PropTypes} from 'react';
57 | import {connect} from 'react-redux';
58 | import ReactDOM from 'react-dom';
59 |
60 | import Notifications from 'react-notification-system-redux';
61 |
62 | class DemoComponent extends React.Component {
63 |
64 | render() {
65 | const {notifications} = this.props;
66 |
67 | //Optional styling
68 | const style = {
69 | NotificationItem: { // Override the notification item
70 | DefaultStyle: { // Applied to every notification, regardless of the notification level
71 | margin: '10px 5px 2px 1px'
72 | },
73 |
74 | success: { // Applied only to the success notification item
75 | color: 'red'
76 | }
77 | }
78 | };
79 |
80 | return (
81 |
85 | );
86 | }
87 | }
88 |
89 | DemoComponent.contextTypes = {
90 | store: PropTypes.object
91 | };
92 |
93 | DemoComponent.propTypes = {
94 | notifications: PropTypes.array
95 | };
96 |
97 | export default connect(
98 | state => ({ notifications: state.notifications })
99 | )(DemoComponent);
100 | ```
101 |
102 | Dispatch notification actions from any other component:
103 |
104 | ``` javascript
105 | import React, {PropTypes} from 'react';
106 | import ReactDOM from 'react-dom';
107 |
108 | import Notifications, { success } from 'react-notification-system-redux';
109 |
110 | const notificationOpts = {
111 | // uid: 'once-please', // you can specify your own uid if required
112 | title: 'Hey, it\'s good to see you!',
113 | message: 'Now you can see how easy it is to use notifications in React!',
114 | position: 'tr',
115 | autoDismiss: 0,
116 | action: {
117 | label: 'Click me!!',
118 | callback: () => alert('clicked!')
119 | }
120 | };
121 |
122 | class OtherComponent extends React.Component {
123 |
124 | constructor() {
125 | super();
126 |
127 | this.handleClick = this.handleClick.bind(this);
128 | }
129 |
130 | handleClick() {
131 | this.context.store.dispatch(
132 | success(notificationOpts)
133 | );
134 | }
135 |
136 | render() {
137 | return (
138 |
139 |
142 |
143 | );
144 | }
145 | }
146 |
147 | OtherComponent.contextTypes = {
148 | store: PropTypes.object
149 | };
150 |
151 | export default OtherComponent;
152 | ```
153 |
154 | There is a working example in example/src/**
155 |
156 | ### Properties
157 | It accepts all properties as react-notification-system does, actually it pipes them in the react-notification-system.
158 |
159 | ### Actions
160 | ``` javascript
161 | import Notifications from 'react-notification-system-redux';
162 |
163 | dispatch(Notifications.show(notification, level));
164 | dispatch(Notifications.success(notification));
165 | dispatch(Notifications.error(notification));
166 | dispatch(Notifications.warning(notification));
167 | dispatch(Notifications.info(notification));
168 | dispatch(Notifications.hide(uid)); // Hides notification based on uid
169 | dispatch(Notifications.removeAll()); // Removes all notifications
170 |
171 | // OR //
172 |
173 | import { show, success, error, warning, info, hide, removeAll } from 'react-notification-system-redux';
174 |
175 | dispatch(show(notification, level));
176 | dispatch(success(notification));
177 | dispatch(error(notification));
178 | dispatch(warning(notification));
179 | dispatch(info(notification));
180 | dispatch(hide(uid)); // Hides notification based on uid
181 | dispatch(removeAll()); // Removes all notifications
182 | ```
183 |
184 |
185 | ## Development (`src`, `lib` and the build process)
186 |
187 | **NOTE:** The source code for the component is in `src`. A transpiled CommonJS version (generated with Babel) is available in `lib` for use with node.js, browserify and webpack. A UMD bundle is also built to `dist`, which can be included without the need for any build system.
188 |
189 | To build, watch and serve the examples (which will also watch the component source), run `npm start`. If you just want to watch changes to `src` and rebuild `lib`, run `npm run watch` (this is useful if you are working with `npm link`).
190 |
191 | ## Thanks
192 |
193 | Jed Watson for making react-component yo builder!
194 |
195 | ## License
196 |
197 | MIT Licensed
198 | Copyright (c) 2016 Goran Udosic
199 |
--------------------------------------------------------------------------------
/lib/notifications.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | 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; };
4 |
5 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
6 |
7 | var _react = require('react');
8 |
9 | var _react2 = _interopRequireDefault(_react);
10 |
11 | var _propTypes = require('prop-types');
12 |
13 | var _propTypes2 = _interopRequireDefault(_propTypes);
14 |
15 | var _reactRedux = require('react-redux');
16 |
17 | var _actions = require('./actions');
18 |
19 | var actions = _interopRequireWildcard(_actions);
20 |
21 | var _reducer = require('./reducer');
22 |
23 | var _reducer2 = _interopRequireDefault(_reducer);
24 |
25 | var _reactNotificationSystem = require('react-notification-system');
26 |
27 | var _reactNotificationSystem2 = _interopRequireDefault(_reactNotificationSystem);
28 |
29 | 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; } }
30 |
31 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
32 |
33 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
34 |
35 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
36 |
37 | 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; }
38 |
39 | 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; }
40 |
41 | var Notifications = function (_React$Component) {
42 | _inherits(Notifications, _React$Component);
43 |
44 | function Notifications(props) {
45 | _classCallCheck(this, Notifications);
46 |
47 | var _this = _possibleConstructorReturn(this, (Notifications.__proto__ || Object.getPrototypeOf(Notifications)).call(this, props));
48 |
49 | _this.notifyRef = _react2['default'].createRef();
50 | return _this;
51 | }
52 |
53 | _createClass(Notifications, [{
54 | key: 'system',
55 | value: function () {
56 | function system() {
57 | return this.notifyRef.current;
58 | }
59 |
60 | return system;
61 | }()
62 | }, {
63 | key: 'componentDidUpdate',
64 | value: function () {
65 | function componentDidUpdate(prevProps) {
66 | var _this2 = this;
67 |
68 | var _props = this.props,
69 | notifications = _props.notifications,
70 | store = _props.store;
71 |
72 | var notificationIds = notifications.map(function (notification) {
73 | return notification.uid;
74 | });
75 | var systemNotifications = this.system().state.notifications || [];
76 |
77 | if (notifications.length > 0) {
78 | // Get all active notifications from react-notification-system
79 | /// and remove all where uid is not found in the reducer
80 | systemNotifications.forEach(function (notification) {
81 | if (notificationIds.indexOf(notification.uid) < 0) {
82 | _this2.system().removeNotification(notification.uid);
83 | }
84 | });
85 |
86 | notifications.forEach(function (notification) {
87 | _this2.system().addNotification(_extends({}, notification, {
88 | onRemove: function () {
89 | function onRemove() {
90 | store.dispatch(actions.hide(notification.uid));
91 | notification.onRemove && notification.onRemove();
92 | }
93 |
94 | return onRemove;
95 | }()
96 | }));
97 | });
98 | }
99 |
100 | if (prevProps.notifications !== notifications && notifications.length === 0) {
101 | this.system().clearNotifications();
102 | }
103 | }
104 |
105 | return componentDidUpdate;
106 | }()
107 | }, {
108 | key: 'shouldComponentUpdate',
109 | value: function () {
110 | function shouldComponentUpdate(nextProps) {
111 | return this.props !== nextProps;
112 | }
113 |
114 | return shouldComponentUpdate;
115 | }()
116 | }, {
117 | key: 'render',
118 | value: function () {
119 | function render() {
120 | var _props2 = this.props,
121 | notifications = _props2.notifications,
122 | store = _props2.store,
123 | rest = _objectWithoutProperties(_props2, ['notifications', 'store']);
124 |
125 | return _react2['default'].createElement(_reactNotificationSystem2['default'], _extends({ ref: this.notifyRef }, rest));
126 | }
127 |
128 | return render;
129 | }()
130 | }]);
131 |
132 | return Notifications;
133 | }(_react2['default'].Component);
134 |
135 | Notifications.propTypes = {
136 | notifications: _propTypes2['default'].array,
137 | store: _propTypes2['default'].shape({
138 | dispatch: _propTypes2['default'].func.isRequired
139 | }).isRequired
140 | };
141 |
142 | var NotificationsWithContext = function NotificationsWithContext(props) {
143 | var Context = props.context || _reactRedux.ReactReduxContext;
144 |
145 | if (Context == null) {
146 | throw 'Please upgrade to react-redux v6';
147 | }
148 |
149 | return _react2['default'].createElement(
150 | Context.Consumer,
151 | null,
152 | function (otherProps) {
153 | var store = otherProps.store;
154 |
155 | return _react2['default'].createElement(Notifications, _extends({ store: store }, props));
156 | }
157 | );
158 | };
159 |
160 | NotificationsWithContext.propTypes = {
161 | context: _propTypes2['default'].object
162 | };
163 |
164 | // Tie actions to Notifications component instance
165 | Object.keys(actions).forEach(function (key) {
166 | NotificationsWithContext[key] = actions[key];
167 | });
168 |
169 | NotificationsWithContext.reducer = _reducer2['default'];
170 |
171 | module.exports = NotificationsWithContext;
--------------------------------------------------------------------------------
/dist/react-notification-system-redux.js:
--------------------------------------------------------------------------------
1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.notifications = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 0) continue;
113 | target[key] = source[key];
114 | }
115 |
116 | return target;
117 | }
118 |
119 | module.exports = _objectWithoutPropertiesLoose;
120 | },{}],7:[function(require,module,exports){
121 | function _typeof(obj) {
122 | "@babel/helpers - typeof";
123 |
124 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
125 | module.exports = _typeof = function _typeof(obj) {
126 | return typeof obj;
127 | };
128 | } else {
129 | module.exports = _typeof = function _typeof(obj) {
130 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
131 | };
132 | }
133 |
134 | return _typeof(obj);
135 | }
136 |
137 | module.exports = _typeof;
138 | },{}],8:[function(require,module,exports){
139 | 'use strict';
140 |
141 | var reactIs = require('react-is');
142 |
143 | /**
144 | * Copyright 2015, Yahoo! Inc.
145 | * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
146 | */
147 | var REACT_STATICS = {
148 | childContextTypes: true,
149 | contextType: true,
150 | contextTypes: true,
151 | defaultProps: true,
152 | displayName: true,
153 | getDefaultProps: true,
154 | getDerivedStateFromError: true,
155 | getDerivedStateFromProps: true,
156 | mixins: true,
157 | propTypes: true,
158 | type: true
159 | };
160 | var KNOWN_STATICS = {
161 | name: true,
162 | length: true,
163 | prototype: true,
164 | caller: true,
165 | callee: true,
166 | arguments: true,
167 | arity: true
168 | };
169 | var FORWARD_REF_STATICS = {
170 | '$$typeof': true,
171 | render: true,
172 | defaultProps: true,
173 | displayName: true,
174 | propTypes: true
175 | };
176 | var MEMO_STATICS = {
177 | '$$typeof': true,
178 | compare: true,
179 | defaultProps: true,
180 | displayName: true,
181 | propTypes: true,
182 | type: true
183 | };
184 | var TYPE_STATICS = {};
185 | TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
186 | TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
187 |
188 | function getStatics(component) {
189 | // React v16.11 and below
190 | if (reactIs.isMemo(component)) {
191 | return MEMO_STATICS;
192 | } // React v16.12 and above
193 |
194 |
195 | return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
196 | }
197 |
198 | var defineProperty = Object.defineProperty;
199 | var getOwnPropertyNames = Object.getOwnPropertyNames;
200 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
201 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
202 | var getPrototypeOf = Object.getPrototypeOf;
203 | var objectPrototype = Object.prototype;
204 | function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
205 | if (typeof sourceComponent !== 'string') {
206 | // don't hoist over string (html) components
207 | if (objectPrototype) {
208 | var inheritedComponent = getPrototypeOf(sourceComponent);
209 |
210 | if (inheritedComponent && inheritedComponent !== objectPrototype) {
211 | hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
212 | }
213 | }
214 |
215 | var keys = getOwnPropertyNames(sourceComponent);
216 |
217 | if (getOwnPropertySymbols) {
218 | keys = keys.concat(getOwnPropertySymbols(sourceComponent));
219 | }
220 |
221 | var targetStatics = getStatics(targetComponent);
222 | var sourceStatics = getStatics(sourceComponent);
223 |
224 | for (var i = 0; i < keys.length; ++i) {
225 | var key = keys[i];
226 |
227 | if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
228 | var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
229 |
230 | try {
231 | // Avoid failures from read-only properties
232 | defineProperty(targetComponent, key, descriptor);
233 | } catch (e) {}
234 | }
235 | }
236 | }
237 |
238 | return targetComponent;
239 | }
240 |
241 | module.exports = hoistNonReactStatics;
242 |
243 | },{"react-is":19}],9:[function(require,module,exports){
244 | /**
245 | * Copyright (c) 2013-present, Facebook, Inc.
246 | *
247 | * This source code is licensed under the MIT license found in the
248 | * LICENSE file in the root directory of this source tree.
249 | */
250 |
251 | 'use strict';
252 |
253 | /**
254 | * Use invariant() to assert state which your program assumes to be true.
255 | *
256 | * Provide sprintf-style format (only %s is supported) and arguments
257 | * to provide information about what broke and what you were
258 | * expecting.
259 | *
260 | * The invariant message will be stripped in production, but the invariant
261 | * will remain to ensure logic does not differ in production.
262 | */
263 |
264 | var invariant = function(condition, format, a, b, c, d, e, f) {
265 | if ("production" !== 'production') {
266 | if (format === undefined) {
267 | throw new Error('invariant requires an error message argument');
268 | }
269 | }
270 |
271 | if (!condition) {
272 | var error;
273 | if (format === undefined) {
274 | error = new Error(
275 | 'Minified exception occurred; use the non-minified dev environment ' +
276 | 'for the full error message and additional helpful warnings.'
277 | );
278 | } else {
279 | var args = [a, b, c, d, e, f];
280 | var argIndex = 0;
281 | error = new Error(
282 | format.replace(/%s/g, function() { return args[argIndex++]; })
283 | );
284 | error.name = 'Invariant Violation';
285 | }
286 |
287 | error.framesToPop = 1; // we don't care about invariant's own frame
288 | throw error;
289 | }
290 | };
291 |
292 | module.exports = invariant;
293 |
294 | },{}],10:[function(require,module,exports){
295 | /*
296 | object-assign
297 | (c) Sindre Sorhus
298 | @license MIT
299 | */
300 |
301 | 'use strict';
302 | /* eslint-disable no-unused-vars */
303 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
304 | var hasOwnProperty = Object.prototype.hasOwnProperty;
305 | var propIsEnumerable = Object.prototype.propertyIsEnumerable;
306 |
307 | function toObject(val) {
308 | if (val === null || val === undefined) {
309 | throw new TypeError('Object.assign cannot be called with null or undefined');
310 | }
311 |
312 | return Object(val);
313 | }
314 |
315 | function shouldUseNative() {
316 | try {
317 | if (!Object.assign) {
318 | return false;
319 | }
320 |
321 | // Detect buggy property enumeration order in older V8 versions.
322 |
323 | // https://bugs.chromium.org/p/v8/issues/detail?id=4118
324 | var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
325 | test1[5] = 'de';
326 | if (Object.getOwnPropertyNames(test1)[0] === '5') {
327 | return false;
328 | }
329 |
330 | // https://bugs.chromium.org/p/v8/issues/detail?id=3056
331 | var test2 = {};
332 | for (var i = 0; i < 10; i++) {
333 | test2['_' + String.fromCharCode(i)] = i;
334 | }
335 | var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
336 | return test2[n];
337 | });
338 | if (order2.join('') !== '0123456789') {
339 | return false;
340 | }
341 |
342 | // https://bugs.chromium.org/p/v8/issues/detail?id=3056
343 | var test3 = {};
344 | 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
345 | test3[letter] = letter;
346 | });
347 | if (Object.keys(Object.assign({}, test3)).join('') !==
348 | 'abcdefghijklmnopqrst') {
349 | return false;
350 | }
351 |
352 | return true;
353 | } catch (err) {
354 | // We don't expect any of the above to throw, but better to be safe.
355 | return false;
356 | }
357 | }
358 |
359 | module.exports = shouldUseNative() ? Object.assign : function (target, source) {
360 | var from;
361 | var to = toObject(target);
362 | var symbols;
363 |
364 | for (var s = 1; s < arguments.length; s++) {
365 | from = Object(arguments[s]);
366 |
367 | for (var key in from) {
368 | if (hasOwnProperty.call(from, key)) {
369 | to[key] = from[key];
370 | }
371 | }
372 |
373 | if (getOwnPropertySymbols) {
374 | symbols = getOwnPropertySymbols(from);
375 | for (var i = 0; i < symbols.length; i++) {
376 | if (propIsEnumerable.call(from, symbols[i])) {
377 | to[symbols[i]] = from[symbols[i]];
378 | }
379 | }
380 | }
381 | }
382 |
383 | return to;
384 | };
385 |
386 | },{}],11:[function(require,module,exports){
387 | // shim for using process in browser
388 | var process = module.exports = {};
389 |
390 | // cached from whatever global is present so that test runners that stub it
391 | // don't break things. But we need to wrap it in a try catch in case it is
392 | // wrapped in strict mode code which doesn't define any globals. It's inside a
393 | // function because try/catches deoptimize in certain engines.
394 |
395 | var cachedSetTimeout;
396 | var cachedClearTimeout;
397 |
398 | function defaultSetTimout() {
399 | throw new Error('setTimeout has not been defined');
400 | }
401 | function defaultClearTimeout () {
402 | throw new Error('clearTimeout has not been defined');
403 | }
404 | (function () {
405 | try {
406 | if (typeof setTimeout === 'function') {
407 | cachedSetTimeout = setTimeout;
408 | } else {
409 | cachedSetTimeout = defaultSetTimout;
410 | }
411 | } catch (e) {
412 | cachedSetTimeout = defaultSetTimout;
413 | }
414 | try {
415 | if (typeof clearTimeout === 'function') {
416 | cachedClearTimeout = clearTimeout;
417 | } else {
418 | cachedClearTimeout = defaultClearTimeout;
419 | }
420 | } catch (e) {
421 | cachedClearTimeout = defaultClearTimeout;
422 | }
423 | } ())
424 | function runTimeout(fun) {
425 | if (cachedSetTimeout === setTimeout) {
426 | //normal enviroments in sane situations
427 | return setTimeout(fun, 0);
428 | }
429 | // if setTimeout wasn't available but was latter defined
430 | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
431 | cachedSetTimeout = setTimeout;
432 | return setTimeout(fun, 0);
433 | }
434 | try {
435 | // when when somebody has screwed with setTimeout but no I.E. maddness
436 | return cachedSetTimeout(fun, 0);
437 | } catch(e){
438 | try {
439 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
440 | return cachedSetTimeout.call(null, fun, 0);
441 | } catch(e){
442 | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
443 | return cachedSetTimeout.call(this, fun, 0);
444 | }
445 | }
446 |
447 |
448 | }
449 | function runClearTimeout(marker) {
450 | if (cachedClearTimeout === clearTimeout) {
451 | //normal enviroments in sane situations
452 | return clearTimeout(marker);
453 | }
454 | // if clearTimeout wasn't available but was latter defined
455 | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
456 | cachedClearTimeout = clearTimeout;
457 | return clearTimeout(marker);
458 | }
459 | try {
460 | // when when somebody has screwed with setTimeout but no I.E. maddness
461 | return cachedClearTimeout(marker);
462 | } catch (e){
463 | try {
464 | // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
465 | return cachedClearTimeout.call(null, marker);
466 | } catch (e){
467 | // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
468 | // Some versions of I.E. have different rules for clearTimeout vs setTimeout
469 | return cachedClearTimeout.call(this, marker);
470 | }
471 | }
472 |
473 |
474 |
475 | }
476 | var queue = [];
477 | var draining = false;
478 | var currentQueue;
479 | var queueIndex = -1;
480 |
481 | function cleanUpNextTick() {
482 | if (!draining || !currentQueue) {
483 | return;
484 | }
485 | draining = false;
486 | if (currentQueue.length) {
487 | queue = currentQueue.concat(queue);
488 | } else {
489 | queueIndex = -1;
490 | }
491 | if (queue.length) {
492 | drainQueue();
493 | }
494 | }
495 |
496 | function drainQueue() {
497 | if (draining) {
498 | return;
499 | }
500 | var timeout = runTimeout(cleanUpNextTick);
501 | draining = true;
502 |
503 | var len = queue.length;
504 | while(len) {
505 | currentQueue = queue;
506 | queue = [];
507 | while (++queueIndex < len) {
508 | if (currentQueue) {
509 | currentQueue[queueIndex].run();
510 | }
511 | }
512 | queueIndex = -1;
513 | len = queue.length;
514 | }
515 | currentQueue = null;
516 | draining = false;
517 | runClearTimeout(timeout);
518 | }
519 |
520 | process.nextTick = function (fun) {
521 | var args = new Array(arguments.length - 1);
522 | if (arguments.length > 1) {
523 | for (var i = 1; i < arguments.length; i++) {
524 | args[i - 1] = arguments[i];
525 | }
526 | }
527 | queue.push(new Item(fun, args));
528 | if (queue.length === 1 && !draining) {
529 | runTimeout(drainQueue);
530 | }
531 | };
532 |
533 | // v8 likes predictible objects
534 | function Item(fun, array) {
535 | this.fun = fun;
536 | this.array = array;
537 | }
538 | Item.prototype.run = function () {
539 | this.fun.apply(null, this.array);
540 | };
541 | process.title = 'browser';
542 | process.browser = true;
543 | process.env = {};
544 | process.argv = [];
545 | process.version = ''; // empty string to avoid regexp issues
546 | process.versions = {};
547 |
548 | function noop() {}
549 |
550 | process.on = noop;
551 | process.addListener = noop;
552 | process.once = noop;
553 | process.off = noop;
554 | process.removeListener = noop;
555 | process.removeAllListeners = noop;
556 | process.emit = noop;
557 | process.prependListener = noop;
558 | process.prependOnceListener = noop;
559 |
560 | process.listeners = function (name) { return [] }
561 |
562 | process.binding = function (name) {
563 | throw new Error('process.binding is not supported');
564 | };
565 |
566 | process.cwd = function () { return '/' };
567 | process.chdir = function (dir) {
568 | throw new Error('process.chdir is not supported');
569 | };
570 | process.umask = function() { return 0; };
571 |
572 | },{}],12:[function(require,module,exports){
573 | /**
574 | * Copyright (c) 2013-present, Facebook, Inc.
575 | *
576 | * This source code is licensed under the MIT license found in the
577 | * LICENSE file in the root directory of this source tree.
578 | */
579 |
580 | 'use strict';
581 |
582 | var printWarning = function() {};
583 |
584 | if ("production" !== 'production') {
585 | var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
586 | var loggedTypeFailures = {};
587 | var has = Function.call.bind(Object.prototype.hasOwnProperty);
588 |
589 | printWarning = function(text) {
590 | var message = 'Warning: ' + text;
591 | if (typeof console !== 'undefined') {
592 | console.error(message);
593 | }
594 | try {
595 | // --- Welcome to debugging React ---
596 | // This error was thrown as a convenience so that you can use this stack
597 | // to find the callsite that caused this warning to fire.
598 | throw new Error(message);
599 | } catch (x) {}
600 | };
601 | }
602 |
603 | /**
604 | * Assert that the values match with the type specs.
605 | * Error messages are memorized and will only be shown once.
606 | *
607 | * @param {object} typeSpecs Map of name to a ReactPropType
608 | * @param {object} values Runtime values that need to be type-checked
609 | * @param {string} location e.g. "prop", "context", "child context"
610 | * @param {string} componentName Name of the component for error messages.
611 | * @param {?Function} getStack Returns the component stack.
612 | * @private
613 | */
614 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
615 | if ("production" !== 'production') {
616 | for (var typeSpecName in typeSpecs) {
617 | if (has(typeSpecs, typeSpecName)) {
618 | var error;
619 | // Prop type validation may throw. In case they do, we don't want to
620 | // fail the render phase where it didn't fail before. So we log it.
621 | // After these have been cleaned up, we'll let them throw.
622 | try {
623 | // This is intentionally an invariant that gets caught. It's the same
624 | // behavior as without this statement except with a better message.
625 | if (typeof typeSpecs[typeSpecName] !== 'function') {
626 | var err = Error(
627 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
628 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
629 | );
630 | err.name = 'Invariant Violation';
631 | throw err;
632 | }
633 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
634 | } catch (ex) {
635 | error = ex;
636 | }
637 | if (error && !(error instanceof Error)) {
638 | printWarning(
639 | (componentName || 'React class') + ': type specification of ' +
640 | location + ' `' + typeSpecName + '` is invalid; the type checker ' +
641 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
642 | 'You may have forgotten to pass an argument to the type checker ' +
643 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
644 | 'shape all require an argument).'
645 | );
646 | }
647 | if (error instanceof Error && !(error.message in loggedTypeFailures)) {
648 | // Only monitor this failure once because there tends to be a lot of the
649 | // same error.
650 | loggedTypeFailures[error.message] = true;
651 |
652 | var stack = getStack ? getStack() : '';
653 |
654 | printWarning(
655 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
656 | );
657 | }
658 | }
659 | }
660 | }
661 | }
662 |
663 | /**
664 | * Resets warning cache when testing.
665 | *
666 | * @private
667 | */
668 | checkPropTypes.resetWarningCache = function() {
669 | if ("production" !== 'production') {
670 | loggedTypeFailures = {};
671 | }
672 | }
673 |
674 | module.exports = checkPropTypes;
675 |
676 | },{"./lib/ReactPropTypesSecret":16}],13:[function(require,module,exports){
677 | /**
678 | * Copyright (c) 2013-present, Facebook, Inc.
679 | *
680 | * This source code is licensed under the MIT license found in the
681 | * LICENSE file in the root directory of this source tree.
682 | */
683 |
684 | 'use strict';
685 |
686 | var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
687 |
688 | function emptyFunction() {}
689 | function emptyFunctionWithReset() {}
690 | emptyFunctionWithReset.resetWarningCache = emptyFunction;
691 |
692 | module.exports = function() {
693 | function shim(props, propName, componentName, location, propFullName, secret) {
694 | if (secret === ReactPropTypesSecret) {
695 | // It is still safe when called from React.
696 | return;
697 | }
698 | var err = new Error(
699 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
700 | 'Use PropTypes.checkPropTypes() to call them. ' +
701 | 'Read more at http://fb.me/use-check-prop-types'
702 | );
703 | err.name = 'Invariant Violation';
704 | throw err;
705 | };
706 | shim.isRequired = shim;
707 | function getShim() {
708 | return shim;
709 | };
710 | // Important!
711 | // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
712 | var ReactPropTypes = {
713 | array: shim,
714 | bool: shim,
715 | func: shim,
716 | number: shim,
717 | object: shim,
718 | string: shim,
719 | symbol: shim,
720 |
721 | any: shim,
722 | arrayOf: getShim,
723 | element: shim,
724 | elementType: shim,
725 | instanceOf: getShim,
726 | node: shim,
727 | objectOf: getShim,
728 | oneOf: getShim,
729 | oneOfType: getShim,
730 | shape: getShim,
731 | exact: getShim,
732 |
733 | checkPropTypes: emptyFunctionWithReset,
734 | resetWarningCache: emptyFunction
735 | };
736 |
737 | ReactPropTypes.PropTypes = ReactPropTypes;
738 |
739 | return ReactPropTypes;
740 | };
741 |
742 | },{"./lib/ReactPropTypesSecret":16}],14:[function(require,module,exports){
743 | /**
744 | * Copyright (c) 2013-present, Facebook, Inc.
745 | *
746 | * This source code is licensed under the MIT license found in the
747 | * LICENSE file in the root directory of this source tree.
748 | */
749 |
750 | 'use strict';
751 |
752 | var ReactIs = require('react-is');
753 | var assign = require('object-assign');
754 |
755 | var ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');
756 | var checkPropTypes = require('./checkPropTypes');
757 |
758 | var has = Function.call.bind(Object.prototype.hasOwnProperty);
759 | var printWarning = function() {};
760 |
761 | if ("production" !== 'production') {
762 | printWarning = function(text) {
763 | var message = 'Warning: ' + text;
764 | if (typeof console !== 'undefined') {
765 | console.error(message);
766 | }
767 | try {
768 | // --- Welcome to debugging React ---
769 | // This error was thrown as a convenience so that you can use this stack
770 | // to find the callsite that caused this warning to fire.
771 | throw new Error(message);
772 | } catch (x) {}
773 | };
774 | }
775 |
776 | function emptyFunctionThatReturnsNull() {
777 | return null;
778 | }
779 |
780 | module.exports = function(isValidElement, throwOnDirectAccess) {
781 | /* global Symbol */
782 | var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
783 | var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
784 |
785 | /**
786 | * Returns the iterator method function contained on the iterable object.
787 | *
788 | * Be sure to invoke the function with the iterable as context:
789 | *
790 | * var iteratorFn = getIteratorFn(myIterable);
791 | * if (iteratorFn) {
792 | * var iterator = iteratorFn.call(myIterable);
793 | * ...
794 | * }
795 | *
796 | * @param {?object} maybeIterable
797 | * @return {?function}
798 | */
799 | function getIteratorFn(maybeIterable) {
800 | var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
801 | if (typeof iteratorFn === 'function') {
802 | return iteratorFn;
803 | }
804 | }
805 |
806 | /**
807 | * Collection of methods that allow declaration and validation of props that are
808 | * supplied to React components. Example usage:
809 | *
810 | * var Props = require('ReactPropTypes');
811 | * var MyArticle = React.createClass({
812 | * propTypes: {
813 | * // An optional string prop named "description".
814 | * description: Props.string,
815 | *
816 | * // A required enum prop named "category".
817 | * category: Props.oneOf(['News','Photos']).isRequired,
818 | *
819 | * // A prop named "dialog" that requires an instance of Dialog.
820 | * dialog: Props.instanceOf(Dialog).isRequired
821 | * },
822 | * render: function() { ... }
823 | * });
824 | *
825 | * A more formal specification of how these methods are used:
826 | *
827 | * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
828 | * decl := ReactPropTypes.{type}(.isRequired)?
829 | *
830 | * Each and every declaration produces a function with the same signature. This
831 | * allows the creation of custom validation functions. For example:
832 | *
833 | * var MyLink = React.createClass({
834 | * propTypes: {
835 | * // An optional string or URI prop named "href".
836 | * href: function(props, propName, componentName) {
837 | * var propValue = props[propName];
838 | * if (propValue != null && typeof propValue !== 'string' &&
839 | * !(propValue instanceof URI)) {
840 | * return new Error(
841 | * 'Expected a string or an URI for ' + propName + ' in ' +
842 | * componentName
843 | * );
844 | * }
845 | * }
846 | * },
847 | * render: function() {...}
848 | * });
849 | *
850 | * @internal
851 | */
852 |
853 | var ANONYMOUS = '<>';
854 |
855 | // Important!
856 | // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
857 | var ReactPropTypes = {
858 | array: createPrimitiveTypeChecker('array'),
859 | bool: createPrimitiveTypeChecker('boolean'),
860 | func: createPrimitiveTypeChecker('function'),
861 | number: createPrimitiveTypeChecker('number'),
862 | object: createPrimitiveTypeChecker('object'),
863 | string: createPrimitiveTypeChecker('string'),
864 | symbol: createPrimitiveTypeChecker('symbol'),
865 |
866 | any: createAnyTypeChecker(),
867 | arrayOf: createArrayOfTypeChecker,
868 | element: createElementTypeChecker(),
869 | elementType: createElementTypeTypeChecker(),
870 | instanceOf: createInstanceTypeChecker,
871 | node: createNodeChecker(),
872 | objectOf: createObjectOfTypeChecker,
873 | oneOf: createEnumTypeChecker,
874 | oneOfType: createUnionTypeChecker,
875 | shape: createShapeTypeChecker,
876 | exact: createStrictShapeTypeChecker,
877 | };
878 |
879 | /**
880 | * inlined Object.is polyfill to avoid requiring consumers ship their own
881 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
882 | */
883 | /*eslint-disable no-self-compare*/
884 | function is(x, y) {
885 | // SameValue algorithm
886 | if (x === y) {
887 | // Steps 1-5, 7-10
888 | // Steps 6.b-6.e: +0 != -0
889 | return x !== 0 || 1 / x === 1 / y;
890 | } else {
891 | // Step 6.a: NaN == NaN
892 | return x !== x && y !== y;
893 | }
894 | }
895 | /*eslint-enable no-self-compare*/
896 |
897 | /**
898 | * We use an Error-like object for backward compatibility as people may call
899 | * PropTypes directly and inspect their output. However, we don't use real
900 | * Errors anymore. We don't inspect their stack anyway, and creating them
901 | * is prohibitively expensive if they are created too often, such as what
902 | * happens in oneOfType() for any type before the one that matched.
903 | */
904 | function PropTypeError(message) {
905 | this.message = message;
906 | this.stack = '';
907 | }
908 | // Make `instanceof Error` still work for returned errors.
909 | PropTypeError.prototype = Error.prototype;
910 |
911 | function createChainableTypeChecker(validate) {
912 | if ("production" !== 'production') {
913 | var manualPropTypeCallCache = {};
914 | var manualPropTypeWarningCount = 0;
915 | }
916 | function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
917 | componentName = componentName || ANONYMOUS;
918 | propFullName = propFullName || propName;
919 |
920 | if (secret !== ReactPropTypesSecret) {
921 | if (throwOnDirectAccess) {
922 | // New behavior only for users of `prop-types` package
923 | var err = new Error(
924 | 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
925 | 'Use `PropTypes.checkPropTypes()` to call them. ' +
926 | 'Read more at http://fb.me/use-check-prop-types'
927 | );
928 | err.name = 'Invariant Violation';
929 | throw err;
930 | } else if ("production" !== 'production' && typeof console !== 'undefined') {
931 | // Old behavior for people using React.PropTypes
932 | var cacheKey = componentName + ':' + propName;
933 | if (
934 | !manualPropTypeCallCache[cacheKey] &&
935 | // Avoid spamming the console because they are often not actionable except for lib authors
936 | manualPropTypeWarningCount < 3
937 | ) {
938 | printWarning(
939 | 'You are manually calling a React.PropTypes validation ' +
940 | 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
941 | 'and will throw in the standalone `prop-types` package. ' +
942 | 'You may be seeing this warning due to a third-party PropTypes ' +
943 | 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
944 | );
945 | manualPropTypeCallCache[cacheKey] = true;
946 | manualPropTypeWarningCount++;
947 | }
948 | }
949 | }
950 | if (props[propName] == null) {
951 | if (isRequired) {
952 | if (props[propName] === null) {
953 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
954 | }
955 | return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
956 | }
957 | return null;
958 | } else {
959 | return validate(props, propName, componentName, location, propFullName);
960 | }
961 | }
962 |
963 | var chainedCheckType = checkType.bind(null, false);
964 | chainedCheckType.isRequired = checkType.bind(null, true);
965 |
966 | return chainedCheckType;
967 | }
968 |
969 | function createPrimitiveTypeChecker(expectedType) {
970 | function validate(props, propName, componentName, location, propFullName, secret) {
971 | var propValue = props[propName];
972 | var propType = getPropType(propValue);
973 | if (propType !== expectedType) {
974 | // `propValue` being instance of, say, date/regexp, pass the 'object'
975 | // check, but we can offer a more precise error message here rather than
976 | // 'of type `object`'.
977 | var preciseType = getPreciseType(propValue);
978 |
979 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
980 | }
981 | return null;
982 | }
983 | return createChainableTypeChecker(validate);
984 | }
985 |
986 | function createAnyTypeChecker() {
987 | return createChainableTypeChecker(emptyFunctionThatReturnsNull);
988 | }
989 |
990 | function createArrayOfTypeChecker(typeChecker) {
991 | function validate(props, propName, componentName, location, propFullName) {
992 | if (typeof typeChecker !== 'function') {
993 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
994 | }
995 | var propValue = props[propName];
996 | if (!Array.isArray(propValue)) {
997 | var propType = getPropType(propValue);
998 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
999 | }
1000 | for (var i = 0; i < propValue.length; i++) {
1001 | var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
1002 | if (error instanceof Error) {
1003 | return error;
1004 | }
1005 | }
1006 | return null;
1007 | }
1008 | return createChainableTypeChecker(validate);
1009 | }
1010 |
1011 | function createElementTypeChecker() {
1012 | function validate(props, propName, componentName, location, propFullName) {
1013 | var propValue = props[propName];
1014 | if (!isValidElement(propValue)) {
1015 | var propType = getPropType(propValue);
1016 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
1017 | }
1018 | return null;
1019 | }
1020 | return createChainableTypeChecker(validate);
1021 | }
1022 |
1023 | function createElementTypeTypeChecker() {
1024 | function validate(props, propName, componentName, location, propFullName) {
1025 | var propValue = props[propName];
1026 | if (!ReactIs.isValidElementType(propValue)) {
1027 | var propType = getPropType(propValue);
1028 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
1029 | }
1030 | return null;
1031 | }
1032 | return createChainableTypeChecker(validate);
1033 | }
1034 |
1035 | function createInstanceTypeChecker(expectedClass) {
1036 | function validate(props, propName, componentName, location, propFullName) {
1037 | if (!(props[propName] instanceof expectedClass)) {
1038 | var expectedClassName = expectedClass.name || ANONYMOUS;
1039 | var actualClassName = getClassName(props[propName]);
1040 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
1041 | }
1042 | return null;
1043 | }
1044 | return createChainableTypeChecker(validate);
1045 | }
1046 |
1047 | function createEnumTypeChecker(expectedValues) {
1048 | if (!Array.isArray(expectedValues)) {
1049 | if ("production" !== 'production') {
1050 | if (arguments.length > 1) {
1051 | printWarning(
1052 | 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
1053 | 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
1054 | );
1055 | } else {
1056 | printWarning('Invalid argument supplied to oneOf, expected an array.');
1057 | }
1058 | }
1059 | return emptyFunctionThatReturnsNull;
1060 | }
1061 |
1062 | function validate(props, propName, componentName, location, propFullName) {
1063 | var propValue = props[propName];
1064 | for (var i = 0; i < expectedValues.length; i++) {
1065 | if (is(propValue, expectedValues[i])) {
1066 | return null;
1067 | }
1068 | }
1069 |
1070 | var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
1071 | var type = getPreciseType(value);
1072 | if (type === 'symbol') {
1073 | return String(value);
1074 | }
1075 | return value;
1076 | });
1077 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
1078 | }
1079 | return createChainableTypeChecker(validate);
1080 | }
1081 |
1082 | function createObjectOfTypeChecker(typeChecker) {
1083 | function validate(props, propName, componentName, location, propFullName) {
1084 | if (typeof typeChecker !== 'function') {
1085 | return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
1086 | }
1087 | var propValue = props[propName];
1088 | var propType = getPropType(propValue);
1089 | if (propType !== 'object') {
1090 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
1091 | }
1092 | for (var key in propValue) {
1093 | if (has(propValue, key)) {
1094 | var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1095 | if (error instanceof Error) {
1096 | return error;
1097 | }
1098 | }
1099 | }
1100 | return null;
1101 | }
1102 | return createChainableTypeChecker(validate);
1103 | }
1104 |
1105 | function createUnionTypeChecker(arrayOfTypeCheckers) {
1106 | if (!Array.isArray(arrayOfTypeCheckers)) {
1107 | "production" !== 'production' ? printWarning('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
1108 | return emptyFunctionThatReturnsNull;
1109 | }
1110 |
1111 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1112 | var checker = arrayOfTypeCheckers[i];
1113 | if (typeof checker !== 'function') {
1114 | printWarning(
1115 | 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
1116 | 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
1117 | );
1118 | return emptyFunctionThatReturnsNull;
1119 | }
1120 | }
1121 |
1122 | function validate(props, propName, componentName, location, propFullName) {
1123 | for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
1124 | var checker = arrayOfTypeCheckers[i];
1125 | if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
1126 | return null;
1127 | }
1128 | }
1129 |
1130 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
1131 | }
1132 | return createChainableTypeChecker(validate);
1133 | }
1134 |
1135 | function createNodeChecker() {
1136 | function validate(props, propName, componentName, location, propFullName) {
1137 | if (!isNode(props[propName])) {
1138 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
1139 | }
1140 | return null;
1141 | }
1142 | return createChainableTypeChecker(validate);
1143 | }
1144 |
1145 | function createShapeTypeChecker(shapeTypes) {
1146 | function validate(props, propName, componentName, location, propFullName) {
1147 | var propValue = props[propName];
1148 | var propType = getPropType(propValue);
1149 | if (propType !== 'object') {
1150 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1151 | }
1152 | for (var key in shapeTypes) {
1153 | var checker = shapeTypes[key];
1154 | if (!checker) {
1155 | continue;
1156 | }
1157 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1158 | if (error) {
1159 | return error;
1160 | }
1161 | }
1162 | return null;
1163 | }
1164 | return createChainableTypeChecker(validate);
1165 | }
1166 |
1167 | function createStrictShapeTypeChecker(shapeTypes) {
1168 | function validate(props, propName, componentName, location, propFullName) {
1169 | var propValue = props[propName];
1170 | var propType = getPropType(propValue);
1171 | if (propType !== 'object') {
1172 | return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
1173 | }
1174 | // We need to check all keys in case some are required but missing from
1175 | // props.
1176 | var allKeys = assign({}, props[propName], shapeTypes);
1177 | for (var key in allKeys) {
1178 | var checker = shapeTypes[key];
1179 | if (!checker) {
1180 | return new PropTypeError(
1181 | 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
1182 | '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
1183 | '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
1184 | );
1185 | }
1186 | var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
1187 | if (error) {
1188 | return error;
1189 | }
1190 | }
1191 | return null;
1192 | }
1193 |
1194 | return createChainableTypeChecker(validate);
1195 | }
1196 |
1197 | function isNode(propValue) {
1198 | switch (typeof propValue) {
1199 | case 'number':
1200 | case 'string':
1201 | case 'undefined':
1202 | return true;
1203 | case 'boolean':
1204 | return !propValue;
1205 | case 'object':
1206 | if (Array.isArray(propValue)) {
1207 | return propValue.every(isNode);
1208 | }
1209 | if (propValue === null || isValidElement(propValue)) {
1210 | return true;
1211 | }
1212 |
1213 | var iteratorFn = getIteratorFn(propValue);
1214 | if (iteratorFn) {
1215 | var iterator = iteratorFn.call(propValue);
1216 | var step;
1217 | if (iteratorFn !== propValue.entries) {
1218 | while (!(step = iterator.next()).done) {
1219 | if (!isNode(step.value)) {
1220 | return false;
1221 | }
1222 | }
1223 | } else {
1224 | // Iterator will provide entry [k,v] tuples rather than values.
1225 | while (!(step = iterator.next()).done) {
1226 | var entry = step.value;
1227 | if (entry) {
1228 | if (!isNode(entry[1])) {
1229 | return false;
1230 | }
1231 | }
1232 | }
1233 | }
1234 | } else {
1235 | return false;
1236 | }
1237 |
1238 | return true;
1239 | default:
1240 | return false;
1241 | }
1242 | }
1243 |
1244 | function isSymbol(propType, propValue) {
1245 | // Native Symbol.
1246 | if (propType === 'symbol') {
1247 | return true;
1248 | }
1249 |
1250 | // falsy value can't be a Symbol
1251 | if (!propValue) {
1252 | return false;
1253 | }
1254 |
1255 | // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
1256 | if (propValue['@@toStringTag'] === 'Symbol') {
1257 | return true;
1258 | }
1259 |
1260 | // Fallback for non-spec compliant Symbols which are polyfilled.
1261 | if (typeof Symbol === 'function' && propValue instanceof Symbol) {
1262 | return true;
1263 | }
1264 |
1265 | return false;
1266 | }
1267 |
1268 | // Equivalent of `typeof` but with special handling for array and regexp.
1269 | function getPropType(propValue) {
1270 | var propType = typeof propValue;
1271 | if (Array.isArray(propValue)) {
1272 | return 'array';
1273 | }
1274 | if (propValue instanceof RegExp) {
1275 | // Old webkits (at least until Android 4.0) return 'function' rather than
1276 | // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
1277 | // passes PropTypes.object.
1278 | return 'object';
1279 | }
1280 | if (isSymbol(propType, propValue)) {
1281 | return 'symbol';
1282 | }
1283 | return propType;
1284 | }
1285 |
1286 | // This handles more types than `getPropType`. Only used for error messages.
1287 | // See `createPrimitiveTypeChecker`.
1288 | function getPreciseType(propValue) {
1289 | if (typeof propValue === 'undefined' || propValue === null) {
1290 | return '' + propValue;
1291 | }
1292 | var propType = getPropType(propValue);
1293 | if (propType === 'object') {
1294 | if (propValue instanceof Date) {
1295 | return 'date';
1296 | } else if (propValue instanceof RegExp) {
1297 | return 'regexp';
1298 | }
1299 | }
1300 | return propType;
1301 | }
1302 |
1303 | // Returns a string that is postfixed to a warning about an invalid type.
1304 | // For example, "undefined" or "of type array"
1305 | function getPostfixForTypeWarning(value) {
1306 | var type = getPreciseType(value);
1307 | switch (type) {
1308 | case 'array':
1309 | case 'object':
1310 | return 'an ' + type;
1311 | case 'boolean':
1312 | case 'date':
1313 | case 'regexp':
1314 | return 'a ' + type;
1315 | default:
1316 | return type;
1317 | }
1318 | }
1319 |
1320 | // Returns class name of the object, if any.
1321 | function getClassName(propValue) {
1322 | if (!propValue.constructor || !propValue.constructor.name) {
1323 | return ANONYMOUS;
1324 | }
1325 | return propValue.constructor.name;
1326 | }
1327 |
1328 | ReactPropTypes.checkPropTypes = checkPropTypes;
1329 | ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
1330 | ReactPropTypes.PropTypes = ReactPropTypes;
1331 |
1332 | return ReactPropTypes;
1333 | };
1334 |
1335 | },{"./checkPropTypes":12,"./lib/ReactPropTypesSecret":16,"object-assign":10,"react-is":19}],15:[function(require,module,exports){
1336 | /**
1337 | * Copyright (c) 2013-present, Facebook, Inc.
1338 | *
1339 | * This source code is licensed under the MIT license found in the
1340 | * LICENSE file in the root directory of this source tree.
1341 | */
1342 |
1343 | if ("production" !== 'production') {
1344 | var ReactIs = require('react-is');
1345 |
1346 | // By explicitly using `prop-types` you are opting into new development behavior.
1347 | // http://fb.me/prop-types-in-prod
1348 | var throwOnDirectAccess = true;
1349 | module.exports = require('./factoryWithTypeCheckers')(ReactIs.isElement, throwOnDirectAccess);
1350 | } else {
1351 | // By explicitly using `prop-types` you are opting into new production behavior.
1352 | // http://fb.me/prop-types-in-prod
1353 | module.exports = require('./factoryWithThrowingShims')();
1354 | }
1355 |
1356 | },{"./factoryWithThrowingShims":13,"./factoryWithTypeCheckers":14,"react-is":19}],16:[function(require,module,exports){
1357 | /**
1358 | * Copyright (c) 2013-present, Facebook, Inc.
1359 | *
1360 | * This source code is licensed under the MIT license found in the
1361 | * LICENSE file in the root directory of this source tree.
1362 | */
1363 |
1364 | 'use strict';
1365 |
1366 | var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
1367 |
1368 | module.exports = ReactPropTypesSecret;
1369 |
1370 | },{}],17:[function(require,module,exports){
1371 | (function (process){
1372 | /** @license React v16.13.1
1373 | * react-is.development.js
1374 | *
1375 | * Copyright (c) Facebook, Inc. and its affiliates.
1376 | *
1377 | * This source code is licensed under the MIT license found in the
1378 | * LICENSE file in the root directory of this source tree.
1379 | */
1380 |
1381 | 'use strict';
1382 |
1383 |
1384 |
1385 | if (process.env.NODE_ENV !== "production") {
1386 | (function() {
1387 | 'use strict';
1388 |
1389 | // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
1390 | // nor polyfill, then a plain number is used for performance.
1391 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
1392 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
1393 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
1394 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
1395 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
1396 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
1397 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
1398 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
1399 | // (unstable) APIs that have been removed. Can we remove the symbols?
1400 |
1401 | var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
1402 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
1403 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
1404 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
1405 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
1406 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
1407 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
1408 | var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
1409 | var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
1410 | var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
1411 | var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
1412 |
1413 | function isValidElementType(type) {
1414 | return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
1415 | type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
1416 | }
1417 |
1418 | function typeOf(object) {
1419 | if (typeof object === 'object' && object !== null) {
1420 | var $$typeof = object.$$typeof;
1421 |
1422 | switch ($$typeof) {
1423 | case REACT_ELEMENT_TYPE:
1424 | var type = object.type;
1425 |
1426 | switch (type) {
1427 | case REACT_ASYNC_MODE_TYPE:
1428 | case REACT_CONCURRENT_MODE_TYPE:
1429 | case REACT_FRAGMENT_TYPE:
1430 | case REACT_PROFILER_TYPE:
1431 | case REACT_STRICT_MODE_TYPE:
1432 | case REACT_SUSPENSE_TYPE:
1433 | return type;
1434 |
1435 | default:
1436 | var $$typeofType = type && type.$$typeof;
1437 |
1438 | switch ($$typeofType) {
1439 | case REACT_CONTEXT_TYPE:
1440 | case REACT_FORWARD_REF_TYPE:
1441 | case REACT_LAZY_TYPE:
1442 | case REACT_MEMO_TYPE:
1443 | case REACT_PROVIDER_TYPE:
1444 | return $$typeofType;
1445 |
1446 | default:
1447 | return $$typeof;
1448 | }
1449 |
1450 | }
1451 |
1452 | case REACT_PORTAL_TYPE:
1453 | return $$typeof;
1454 | }
1455 | }
1456 |
1457 | return undefined;
1458 | } // AsyncMode is deprecated along with isAsyncMode
1459 |
1460 | var AsyncMode = REACT_ASYNC_MODE_TYPE;
1461 | var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
1462 | var ContextConsumer = REACT_CONTEXT_TYPE;
1463 | var ContextProvider = REACT_PROVIDER_TYPE;
1464 | var Element = REACT_ELEMENT_TYPE;
1465 | var ForwardRef = REACT_FORWARD_REF_TYPE;
1466 | var Fragment = REACT_FRAGMENT_TYPE;
1467 | var Lazy = REACT_LAZY_TYPE;
1468 | var Memo = REACT_MEMO_TYPE;
1469 | var Portal = REACT_PORTAL_TYPE;
1470 | var Profiler = REACT_PROFILER_TYPE;
1471 | var StrictMode = REACT_STRICT_MODE_TYPE;
1472 | var Suspense = REACT_SUSPENSE_TYPE;
1473 | var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
1474 |
1475 | function isAsyncMode(object) {
1476 | {
1477 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
1478 | hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
1479 |
1480 | console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
1481 | }
1482 | }
1483 |
1484 | return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
1485 | }
1486 | function isConcurrentMode(object) {
1487 | return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
1488 | }
1489 | function isContextConsumer(object) {
1490 | return typeOf(object) === REACT_CONTEXT_TYPE;
1491 | }
1492 | function isContextProvider(object) {
1493 | return typeOf(object) === REACT_PROVIDER_TYPE;
1494 | }
1495 | function isElement(object) {
1496 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1497 | }
1498 | function isForwardRef(object) {
1499 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
1500 | }
1501 | function isFragment(object) {
1502 | return typeOf(object) === REACT_FRAGMENT_TYPE;
1503 | }
1504 | function isLazy(object) {
1505 | return typeOf(object) === REACT_LAZY_TYPE;
1506 | }
1507 | function isMemo(object) {
1508 | return typeOf(object) === REACT_MEMO_TYPE;
1509 | }
1510 | function isPortal(object) {
1511 | return typeOf(object) === REACT_PORTAL_TYPE;
1512 | }
1513 | function isProfiler(object) {
1514 | return typeOf(object) === REACT_PROFILER_TYPE;
1515 | }
1516 | function isStrictMode(object) {
1517 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
1518 | }
1519 | function isSuspense(object) {
1520 | return typeOf(object) === REACT_SUSPENSE_TYPE;
1521 | }
1522 |
1523 | exports.AsyncMode = AsyncMode;
1524 | exports.ConcurrentMode = ConcurrentMode;
1525 | exports.ContextConsumer = ContextConsumer;
1526 | exports.ContextProvider = ContextProvider;
1527 | exports.Element = Element;
1528 | exports.ForwardRef = ForwardRef;
1529 | exports.Fragment = Fragment;
1530 | exports.Lazy = Lazy;
1531 | exports.Memo = Memo;
1532 | exports.Portal = Portal;
1533 | exports.Profiler = Profiler;
1534 | exports.StrictMode = StrictMode;
1535 | exports.Suspense = Suspense;
1536 | exports.isAsyncMode = isAsyncMode;
1537 | exports.isConcurrentMode = isConcurrentMode;
1538 | exports.isContextConsumer = isContextConsumer;
1539 | exports.isContextProvider = isContextProvider;
1540 | exports.isElement = isElement;
1541 | exports.isForwardRef = isForwardRef;
1542 | exports.isFragment = isFragment;
1543 | exports.isLazy = isLazy;
1544 | exports.isMemo = isMemo;
1545 | exports.isPortal = isPortal;
1546 | exports.isProfiler = isProfiler;
1547 | exports.isStrictMode = isStrictMode;
1548 | exports.isSuspense = isSuspense;
1549 | exports.isValidElementType = isValidElementType;
1550 | exports.typeOf = typeOf;
1551 | })();
1552 | }
1553 |
1554 | }).call(this,require('_process'))
1555 | },{"_process":11}],18:[function(require,module,exports){
1556 | /** @license React v16.13.1
1557 | * react-is.production.min.js
1558 | *
1559 | * Copyright (c) Facebook, Inc. and its affiliates.
1560 | *
1561 | * This source code is licensed under the MIT license found in the
1562 | * LICENSE file in the root directory of this source tree.
1563 | */
1564 |
1565 | 'use strict';var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
1566 | Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
1567 | function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;exports.Lazy=t;exports.Memo=r;exports.Portal=d;
1568 | exports.Profiler=g;exports.StrictMode=f;exports.Suspense=p;exports.isAsyncMode=function(a){return A(a)||z(a)===l};exports.isConcurrentMode=A;exports.isContextConsumer=function(a){return z(a)===k};exports.isContextProvider=function(a){return z(a)===h};exports.isElement=function(a){return"object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return z(a)===n};exports.isFragment=function(a){return z(a)===e};exports.isLazy=function(a){return z(a)===t};
1569 | exports.isMemo=function(a){return z(a)===r};exports.isPortal=function(a){return z(a)===d};exports.isProfiler=function(a){return z(a)===g};exports.isStrictMode=function(a){return z(a)===f};exports.isSuspense=function(a){return z(a)===p};
1570 | exports.isValidElementType=function(a){return"string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};exports.typeOf=z;
1571 |
1572 | },{}],19:[function(require,module,exports){
1573 | (function (process){
1574 | 'use strict';
1575 |
1576 | if (process.env.NODE_ENV === 'production') {
1577 | module.exports = require('./cjs/react-is.production.min.js');
1578 | } else {
1579 | module.exports = require('./cjs/react-is.development.js');
1580 | }
1581 |
1582 | }).call(this,require('_process'))
1583 | },{"./cjs/react-is.development.js":17,"./cjs/react-is.production.min.js":18,"_process":11}],20:[function(require,module,exports){
1584 | "use strict";
1585 |
1586 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
1587 |
1588 | exports.__esModule = true;
1589 | exports.default = exports.ReactReduxContext = void 0;
1590 |
1591 | var _react = _interopRequireDefault(require("react"));
1592 |
1593 | var ReactReduxContext = _react.default.createContext(null);
1594 |
1595 | exports.ReactReduxContext = ReactReduxContext;
1596 | var _default = ReactReduxContext;
1597 | exports.default = _default;
1598 | },{"@babel/runtime/helpers/interopRequireDefault":4,"react":undefined}],21:[function(require,module,exports){
1599 | "use strict";
1600 |
1601 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
1602 |
1603 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
1604 |
1605 | exports.__esModule = true;
1606 | exports.default = void 0;
1607 |
1608 | var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
1609 |
1610 | var _react = _interopRequireWildcard(require("react"));
1611 |
1612 | var _propTypes = _interopRequireDefault(require("prop-types"));
1613 |
1614 | var _Context = require("./Context");
1615 |
1616 | var Provider =
1617 | /*#__PURE__*/
1618 | function (_Component) {
1619 | (0, _inheritsLoose2.default)(Provider, _Component);
1620 |
1621 | function Provider(props) {
1622 | var _this;
1623 |
1624 | _this = _Component.call(this, props) || this;
1625 | var store = props.store;
1626 | _this.state = {
1627 | storeState: store.getState(),
1628 | store: store
1629 | };
1630 | return _this;
1631 | }
1632 |
1633 | var _proto = Provider.prototype;
1634 |
1635 | _proto.componentDidMount = function componentDidMount() {
1636 | this._isMounted = true;
1637 | this.subscribe();
1638 | };
1639 |
1640 | _proto.componentWillUnmount = function componentWillUnmount() {
1641 | if (this.unsubscribe) this.unsubscribe();
1642 | this._isMounted = false;
1643 | };
1644 |
1645 | _proto.componentDidUpdate = function componentDidUpdate(prevProps) {
1646 | if (this.props.store !== prevProps.store) {
1647 | if (this.unsubscribe) this.unsubscribe();
1648 | this.subscribe();
1649 | }
1650 | };
1651 |
1652 | _proto.subscribe = function subscribe() {
1653 | var _this2 = this;
1654 |
1655 | var store = this.props.store;
1656 | this.unsubscribe = store.subscribe(function () {
1657 | var newStoreState = store.getState();
1658 |
1659 | if (!_this2._isMounted) {
1660 | return;
1661 | }
1662 |
1663 | _this2.setState(function (providerState) {
1664 | // If the value is the same, skip the unnecessary state update.
1665 | if (providerState.storeState === newStoreState) {
1666 | return null;
1667 | }
1668 |
1669 | return {
1670 | storeState: newStoreState
1671 | };
1672 | });
1673 | }); // Actions might have been dispatched between render and mount - handle those
1674 |
1675 | var postMountStoreState = store.getState();
1676 |
1677 | if (postMountStoreState !== this.state.storeState) {
1678 | this.setState({
1679 | storeState: postMountStoreState
1680 | });
1681 | }
1682 | };
1683 |
1684 | _proto.render = function render() {
1685 | var Context = this.props.context || _Context.ReactReduxContext;
1686 | return _react.default.createElement(Context.Provider, {
1687 | value: this.state
1688 | }, this.props.children);
1689 | };
1690 |
1691 | return Provider;
1692 | }(_react.Component);
1693 |
1694 | Provider.propTypes = {
1695 | store: _propTypes.default.shape({
1696 | subscribe: _propTypes.default.func.isRequired,
1697 | dispatch: _propTypes.default.func.isRequired,
1698 | getState: _propTypes.default.func.isRequired
1699 | }),
1700 | context: _propTypes.default.object,
1701 | children: _propTypes.default.any
1702 | };
1703 | var _default = Provider;
1704 | exports.default = _default;
1705 | },{"./Context":20,"@babel/runtime/helpers/inheritsLoose":3,"@babel/runtime/helpers/interopRequireDefault":4,"@babel/runtime/helpers/interopRequireWildcard":5,"prop-types":15,"react":undefined}],22:[function(require,module,exports){
1706 | "use strict";
1707 |
1708 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
1709 |
1710 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
1711 |
1712 | exports.__esModule = true;
1713 | exports.default = connectAdvanced;
1714 |
1715 | var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
1716 |
1717 | var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
1718 |
1719 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
1720 |
1721 | var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
1722 |
1723 | var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
1724 |
1725 | var _invariant = _interopRequireDefault(require("invariant"));
1726 |
1727 | var _react = _interopRequireWildcard(require("react"));
1728 |
1729 | var _reactIs = require("react-is");
1730 |
1731 | var _Context = require("./Context");
1732 |
1733 | var stringifyComponent = function stringifyComponent(Comp) {
1734 | try {
1735 | return JSON.stringify(Comp);
1736 | } catch (err) {
1737 | return String(Comp);
1738 | }
1739 | };
1740 |
1741 | function connectAdvanced(
1742 | /*
1743 | selectorFactory is a func that is responsible for returning the selector function used to
1744 | compute new props from state, props, and dispatch. For example:
1745 | export default connectAdvanced((dispatch, options) => (state, props) => ({
1746 | thing: state.things[props.thingId],
1747 | saveThing: fields => dispatch(actionCreators.saveThing(props.thingId, fields)),
1748 | }))(YourComponent)
1749 | Access to dispatch is provided to the factory so selectorFactories can bind actionCreators
1750 | outside of their selector as an optimization. Options passed to connectAdvanced are passed to
1751 | the selectorFactory, along with displayName and WrappedComponent, as the second argument.
1752 | Note that selectorFactory is responsible for all caching/memoization of inbound and outbound
1753 | props. Do not use connectAdvanced directly without memoizing results between calls to your
1754 | selector, otherwise the Connect component will re-render on every state or props change.
1755 | */
1756 | selectorFactory, // options object:
1757 | _ref) {
1758 | if (_ref === void 0) {
1759 | _ref = {};
1760 | }
1761 |
1762 | var _ref2 = _ref,
1763 | _ref2$getDisplayName = _ref2.getDisplayName,
1764 | getDisplayName = _ref2$getDisplayName === void 0 ? function (name) {
1765 | return "ConnectAdvanced(" + name + ")";
1766 | } : _ref2$getDisplayName,
1767 | _ref2$methodName = _ref2.methodName,
1768 | methodName = _ref2$methodName === void 0 ? 'connectAdvanced' : _ref2$methodName,
1769 | _ref2$renderCountProp = _ref2.renderCountProp,
1770 | renderCountProp = _ref2$renderCountProp === void 0 ? undefined : _ref2$renderCountProp,
1771 | _ref2$shouldHandleSta = _ref2.shouldHandleStateChanges,
1772 | shouldHandleStateChanges = _ref2$shouldHandleSta === void 0 ? true : _ref2$shouldHandleSta,
1773 | _ref2$storeKey = _ref2.storeKey,
1774 | storeKey = _ref2$storeKey === void 0 ? 'store' : _ref2$storeKey,
1775 | _ref2$withRef = _ref2.withRef,
1776 | withRef = _ref2$withRef === void 0 ? false : _ref2$withRef,
1777 | _ref2$forwardRef = _ref2.forwardRef,
1778 | forwardRef = _ref2$forwardRef === void 0 ? false : _ref2$forwardRef,
1779 | _ref2$context = _ref2.context,
1780 | context = _ref2$context === void 0 ? _Context.ReactReduxContext : _ref2$context,
1781 | connectOptions = (0, _objectWithoutPropertiesLoose2.default)(_ref2, ["getDisplayName", "methodName", "renderCountProp", "shouldHandleStateChanges", "storeKey", "withRef", "forwardRef", "context"]);
1782 | (0, _invariant.default)(renderCountProp === undefined, "renderCountProp is removed. render counting is built into the latest React dev tools profiling extension");
1783 | (0, _invariant.default)(!withRef, 'withRef is removed. To access the wrapped instance, use a ref on the connected component');
1784 | var customStoreWarningMessage = 'To use a custom Redux store for specific components, create a custom React context with ' + "React.createContext(), and pass the context object to React Redux's Provider and specific components" + ' like: . ' + 'You may also pass a {context : MyContext} option to connect';
1785 | (0, _invariant.default)(storeKey === 'store', 'storeKey has been removed and does not do anything. ' + customStoreWarningMessage);
1786 | var Context = context;
1787 | return function wrapWithConnect(WrappedComponent) {
1788 | if ("production" !== 'production') {
1789 | (0, _invariant.default)((0, _reactIs.isValidElementType)(WrappedComponent), "You must pass a component to the function returned by " + (methodName + ". Instead received " + stringifyComponent(WrappedComponent)));
1790 | }
1791 |
1792 | var wrappedComponentName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
1793 | var displayName = getDisplayName(wrappedComponentName);
1794 | var selectorFactoryOptions = (0, _extends2.default)({}, connectOptions, {
1795 | getDisplayName: getDisplayName,
1796 | methodName: methodName,
1797 | renderCountProp: renderCountProp,
1798 | shouldHandleStateChanges: shouldHandleStateChanges,
1799 | storeKey: storeKey,
1800 | displayName: displayName,
1801 | wrappedComponentName: wrappedComponentName,
1802 | WrappedComponent: WrappedComponent
1803 | });
1804 | var pure = connectOptions.pure;
1805 | var OuterBaseComponent = _react.Component;
1806 |
1807 | if (pure) {
1808 | OuterBaseComponent = _react.PureComponent;
1809 | }
1810 |
1811 | function makeDerivedPropsSelector() {
1812 | var lastProps;
1813 | var lastState;
1814 | var lastDerivedProps;
1815 | var lastStore;
1816 | var lastSelectorFactoryOptions;
1817 | var sourceSelector;
1818 | return function selectDerivedProps(state, props, store, selectorFactoryOptions) {
1819 | if (pure && lastProps === props && lastState === state) {
1820 | return lastDerivedProps;
1821 | }
1822 |
1823 | if (store !== lastStore || lastSelectorFactoryOptions !== selectorFactoryOptions) {
1824 | lastStore = store;
1825 | lastSelectorFactoryOptions = selectorFactoryOptions;
1826 | sourceSelector = selectorFactory(store.dispatch, selectorFactoryOptions);
1827 | }
1828 |
1829 | lastProps = props;
1830 | lastState = state;
1831 | var nextProps = sourceSelector(state, props);
1832 | lastDerivedProps = nextProps;
1833 | return lastDerivedProps;
1834 | };
1835 | }
1836 |
1837 | function makeChildElementSelector() {
1838 | var lastChildProps, lastForwardRef, lastChildElement, lastComponent;
1839 | return function selectChildElement(WrappedComponent, childProps, forwardRef) {
1840 | if (childProps !== lastChildProps || forwardRef !== lastForwardRef || lastComponent !== WrappedComponent) {
1841 | lastChildProps = childProps;
1842 | lastForwardRef = forwardRef;
1843 | lastComponent = WrappedComponent;
1844 | lastChildElement = _react.default.createElement(WrappedComponent, (0, _extends2.default)({}, childProps, {
1845 | ref: forwardRef
1846 | }));
1847 | }
1848 |
1849 | return lastChildElement;
1850 | };
1851 | }
1852 |
1853 | var Connect =
1854 | /*#__PURE__*/
1855 | function (_OuterBaseComponent) {
1856 | (0, _inheritsLoose2.default)(Connect, _OuterBaseComponent);
1857 |
1858 | function Connect(props) {
1859 | var _this;
1860 |
1861 | _this = _OuterBaseComponent.call(this, props) || this;
1862 | (0, _invariant.default)(forwardRef ? !props.wrapperProps[storeKey] : !props[storeKey], 'Passing redux store in props has been removed and does not do anything. ' + customStoreWarningMessage);
1863 | _this.selectDerivedProps = makeDerivedPropsSelector();
1864 | _this.selectChildElement = makeChildElementSelector();
1865 | _this.indirectRenderWrappedComponent = _this.indirectRenderWrappedComponent.bind((0, _assertThisInitialized2.default)(_this));
1866 | return _this;
1867 | }
1868 |
1869 | var _proto = Connect.prototype;
1870 |
1871 | _proto.indirectRenderWrappedComponent = function indirectRenderWrappedComponent(value) {
1872 | // calling renderWrappedComponent on prototype from indirectRenderWrappedComponent bound to `this`
1873 | return this.renderWrappedComponent(value);
1874 | };
1875 |
1876 | _proto.renderWrappedComponent = function renderWrappedComponent(value) {
1877 | (0, _invariant.default)(value, "Could not find \"store\" in the context of " + ("\"" + displayName + "\". Either wrap the root component in a , ") + "or pass a custom React context provider to and the corresponding " + ("React context consumer to " + displayName + " in connect options."));
1878 | var storeState = value.storeState,
1879 | store = value.store;
1880 | var wrapperProps = this.props;
1881 | var forwardedRef;
1882 |
1883 | if (forwardRef) {
1884 | wrapperProps = this.props.wrapperProps;
1885 | forwardedRef = this.props.forwardedRef;
1886 | }
1887 |
1888 | var derivedProps = this.selectDerivedProps(storeState, wrapperProps, store, selectorFactoryOptions);
1889 | return this.selectChildElement(WrappedComponent, derivedProps, forwardedRef);
1890 | };
1891 |
1892 | _proto.render = function render() {
1893 | var ContextToUse = this.props.context && this.props.context.Consumer && (0, _reactIs.isContextConsumer)(_react.default.createElement(this.props.context.Consumer, null)) ? this.props.context : Context;
1894 | return _react.default.createElement(ContextToUse.Consumer, null, this.indirectRenderWrappedComponent);
1895 | };
1896 |
1897 | return Connect;
1898 | }(OuterBaseComponent);
1899 |
1900 | Connect.WrappedComponent = WrappedComponent;
1901 | Connect.displayName = displayName;
1902 |
1903 | if (forwardRef) {
1904 | var forwarded = _react.default.forwardRef(function forwardConnectRef(props, ref) {
1905 | return _react.default.createElement(Connect, {
1906 | wrapperProps: props,
1907 | forwardedRef: ref
1908 | });
1909 | });
1910 |
1911 | forwarded.displayName = displayName;
1912 | forwarded.WrappedComponent = WrappedComponent;
1913 | return (0, _hoistNonReactStatics.default)(forwarded, WrappedComponent);
1914 | }
1915 |
1916 | return (0, _hoistNonReactStatics.default)(Connect, WrappedComponent);
1917 | };
1918 | }
1919 | },{"./Context":20,"@babel/runtime/helpers/assertThisInitialized":1,"@babel/runtime/helpers/extends":2,"@babel/runtime/helpers/inheritsLoose":3,"@babel/runtime/helpers/interopRequireDefault":4,"@babel/runtime/helpers/interopRequireWildcard":5,"@babel/runtime/helpers/objectWithoutPropertiesLoose":6,"hoist-non-react-statics":8,"invariant":9,"react":undefined,"react-is":19}],23:[function(require,module,exports){
1920 | "use strict";
1921 |
1922 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
1923 |
1924 | exports.__esModule = true;
1925 | exports.createConnect = createConnect;
1926 | exports.default = void 0;
1927 |
1928 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
1929 |
1930 | var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
1931 |
1932 | var _connectAdvanced = _interopRequireDefault(require("../components/connectAdvanced"));
1933 |
1934 | var _shallowEqual = _interopRequireDefault(require("../utils/shallowEqual"));
1935 |
1936 | var _mapDispatchToProps = _interopRequireDefault(require("./mapDispatchToProps"));
1937 |
1938 | var _mapStateToProps = _interopRequireDefault(require("./mapStateToProps"));
1939 |
1940 | var _mergeProps = _interopRequireDefault(require("./mergeProps"));
1941 |
1942 | var _selectorFactory = _interopRequireDefault(require("./selectorFactory"));
1943 |
1944 | /*
1945 | connect is a facade over connectAdvanced. It turns its args into a compatible
1946 | selectorFactory, which has the signature:
1947 |
1948 | (dispatch, options) => (nextState, nextOwnProps) => nextFinalProps
1949 |
1950 | connect passes its args to connectAdvanced as options, which will in turn pass them to
1951 | selectorFactory each time a Connect component instance is instantiated or hot reloaded.
1952 |
1953 | selectorFactory returns a final props selector from its mapStateToProps,
1954 | mapStateToPropsFactories, mapDispatchToProps, mapDispatchToPropsFactories, mergeProps,
1955 | mergePropsFactories, and pure args.
1956 |
1957 | The resulting final props selector is called by the Connect component instance whenever
1958 | it receives new props or store state.
1959 | */
1960 | function match(arg, factories, name) {
1961 | for (var i = factories.length - 1; i >= 0; i--) {
1962 | var result = factories[i](arg);
1963 | if (result) return result;
1964 | }
1965 |
1966 | return function (dispatch, options) {
1967 | throw new Error("Invalid value of type " + typeof arg + " for " + name + " argument when connecting component " + options.wrappedComponentName + ".");
1968 | };
1969 | }
1970 |
1971 | function strictEqual(a, b) {
1972 | return a === b;
1973 | } // createConnect with default args builds the 'official' connect behavior. Calling it with
1974 | // different options opens up some testing and extensibility scenarios
1975 |
1976 |
1977 | function createConnect(_temp) {
1978 | var _ref = _temp === void 0 ? {} : _temp,
1979 | _ref$connectHOC = _ref.connectHOC,
1980 | connectHOC = _ref$connectHOC === void 0 ? _connectAdvanced.default : _ref$connectHOC,
1981 | _ref$mapStateToPropsF = _ref.mapStateToPropsFactories,
1982 | mapStateToPropsFactories = _ref$mapStateToPropsF === void 0 ? _mapStateToProps.default : _ref$mapStateToPropsF,
1983 | _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories,
1984 | mapDispatchToPropsFactories = _ref$mapDispatchToPro === void 0 ? _mapDispatchToProps.default : _ref$mapDispatchToPro,
1985 | _ref$mergePropsFactor = _ref.mergePropsFactories,
1986 | mergePropsFactories = _ref$mergePropsFactor === void 0 ? _mergeProps.default : _ref$mergePropsFactor,
1987 | _ref$selectorFactory = _ref.selectorFactory,
1988 | selectorFactory = _ref$selectorFactory === void 0 ? _selectorFactory.default : _ref$selectorFactory;
1989 |
1990 | return function connect(mapStateToProps, mapDispatchToProps, mergeProps, _ref2) {
1991 | if (_ref2 === void 0) {
1992 | _ref2 = {};
1993 | }
1994 |
1995 | var _ref3 = _ref2,
1996 | _ref3$pure = _ref3.pure,
1997 | pure = _ref3$pure === void 0 ? true : _ref3$pure,
1998 | _ref3$areStatesEqual = _ref3.areStatesEqual,
1999 | areStatesEqual = _ref3$areStatesEqual === void 0 ? strictEqual : _ref3$areStatesEqual,
2000 | _ref3$areOwnPropsEqua = _ref3.areOwnPropsEqual,
2001 | areOwnPropsEqual = _ref3$areOwnPropsEqua === void 0 ? _shallowEqual.default : _ref3$areOwnPropsEqua,
2002 | _ref3$areStatePropsEq = _ref3.areStatePropsEqual,
2003 | areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? _shallowEqual.default : _ref3$areStatePropsEq,
2004 | _ref3$areMergedPropsE = _ref3.areMergedPropsEqual,
2005 | areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? _shallowEqual.default : _ref3$areMergedPropsE,
2006 | extraOptions = (0, _objectWithoutPropertiesLoose2.default)(_ref3, ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]);
2007 | var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps');
2008 | var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps');
2009 | var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps');
2010 | return connectHOC(selectorFactory, (0, _extends2.default)({
2011 | // used in error messages
2012 | methodName: 'connect',
2013 | // used to compute Connect's displayName from the wrapped component's displayName.
2014 | getDisplayName: function getDisplayName(name) {
2015 | return "Connect(" + name + ")";
2016 | },
2017 | // if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes
2018 | shouldHandleStateChanges: Boolean(mapStateToProps),
2019 | // passed through to selectorFactory
2020 | initMapStateToProps: initMapStateToProps,
2021 | initMapDispatchToProps: initMapDispatchToProps,
2022 | initMergeProps: initMergeProps,
2023 | pure: pure,
2024 | areStatesEqual: areStatesEqual,
2025 | areOwnPropsEqual: areOwnPropsEqual,
2026 | areStatePropsEqual: areStatePropsEqual,
2027 | areMergedPropsEqual: areMergedPropsEqual
2028 | }, extraOptions));
2029 | };
2030 | }
2031 |
2032 | var _default = createConnect();
2033 |
2034 | exports.default = _default;
2035 | },{"../components/connectAdvanced":22,"../utils/shallowEqual":32,"./mapDispatchToProps":24,"./mapStateToProps":25,"./mergeProps":26,"./selectorFactory":27,"@babel/runtime/helpers/extends":2,"@babel/runtime/helpers/interopRequireDefault":4,"@babel/runtime/helpers/objectWithoutPropertiesLoose":6}],24:[function(require,module,exports){
2036 | "use strict";
2037 |
2038 | exports.__esModule = true;
2039 | exports.whenMapDispatchToPropsIsFunction = whenMapDispatchToPropsIsFunction;
2040 | exports.whenMapDispatchToPropsIsMissing = whenMapDispatchToPropsIsMissing;
2041 | exports.whenMapDispatchToPropsIsObject = whenMapDispatchToPropsIsObject;
2042 | exports.default = void 0;
2043 |
2044 | var _redux = require("redux");
2045 |
2046 | var _wrapMapToProps = require("./wrapMapToProps");
2047 |
2048 | function whenMapDispatchToPropsIsFunction(mapDispatchToProps) {
2049 | return typeof mapDispatchToProps === 'function' ? (0, _wrapMapToProps.wrapMapToPropsFunc)(mapDispatchToProps, 'mapDispatchToProps') : undefined;
2050 | }
2051 |
2052 | function whenMapDispatchToPropsIsMissing(mapDispatchToProps) {
2053 | return !mapDispatchToProps ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function (dispatch) {
2054 | return {
2055 | dispatch: dispatch
2056 | };
2057 | }) : undefined;
2058 | }
2059 |
2060 | function whenMapDispatchToPropsIsObject(mapDispatchToProps) {
2061 | return mapDispatchToProps && typeof mapDispatchToProps === 'object' ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function (dispatch) {
2062 | return (0, _redux.bindActionCreators)(mapDispatchToProps, dispatch);
2063 | }) : undefined;
2064 | }
2065 |
2066 | var _default = [whenMapDispatchToPropsIsFunction, whenMapDispatchToPropsIsMissing, whenMapDispatchToPropsIsObject];
2067 | exports.default = _default;
2068 | },{"./wrapMapToProps":29,"redux":35}],25:[function(require,module,exports){
2069 | "use strict";
2070 |
2071 | exports.__esModule = true;
2072 | exports.whenMapStateToPropsIsFunction = whenMapStateToPropsIsFunction;
2073 | exports.whenMapStateToPropsIsMissing = whenMapStateToPropsIsMissing;
2074 | exports.default = void 0;
2075 |
2076 | var _wrapMapToProps = require("./wrapMapToProps");
2077 |
2078 | function whenMapStateToPropsIsFunction(mapStateToProps) {
2079 | return typeof mapStateToProps === 'function' ? (0, _wrapMapToProps.wrapMapToPropsFunc)(mapStateToProps, 'mapStateToProps') : undefined;
2080 | }
2081 |
2082 | function whenMapStateToPropsIsMissing(mapStateToProps) {
2083 | return !mapStateToProps ? (0, _wrapMapToProps.wrapMapToPropsConstant)(function () {
2084 | return {};
2085 | }) : undefined;
2086 | }
2087 |
2088 | var _default = [whenMapStateToPropsIsFunction, whenMapStateToPropsIsMissing];
2089 | exports.default = _default;
2090 | },{"./wrapMapToProps":29}],26:[function(require,module,exports){
2091 | "use strict";
2092 |
2093 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2094 |
2095 | exports.__esModule = true;
2096 | exports.defaultMergeProps = defaultMergeProps;
2097 | exports.wrapMergePropsFunc = wrapMergePropsFunc;
2098 | exports.whenMergePropsIsFunction = whenMergePropsIsFunction;
2099 | exports.whenMergePropsIsOmitted = whenMergePropsIsOmitted;
2100 | exports.default = void 0;
2101 |
2102 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
2103 |
2104 | var _verifyPlainObject = _interopRequireDefault(require("../utils/verifyPlainObject"));
2105 |
2106 | function defaultMergeProps(stateProps, dispatchProps, ownProps) {
2107 | return (0, _extends2.default)({}, ownProps, stateProps, dispatchProps);
2108 | }
2109 |
2110 | function wrapMergePropsFunc(mergeProps) {
2111 | return function initMergePropsProxy(dispatch, _ref) {
2112 | var displayName = _ref.displayName,
2113 | pure = _ref.pure,
2114 | areMergedPropsEqual = _ref.areMergedPropsEqual;
2115 | var hasRunOnce = false;
2116 | var mergedProps;
2117 | return function mergePropsProxy(stateProps, dispatchProps, ownProps) {
2118 | var nextMergedProps = mergeProps(stateProps, dispatchProps, ownProps);
2119 |
2120 | if (hasRunOnce) {
2121 | if (!pure || !areMergedPropsEqual(nextMergedProps, mergedProps)) mergedProps = nextMergedProps;
2122 | } else {
2123 | hasRunOnce = true;
2124 | mergedProps = nextMergedProps;
2125 | if ("production" !== 'production') (0, _verifyPlainObject.default)(mergedProps, displayName, 'mergeProps');
2126 | }
2127 |
2128 | return mergedProps;
2129 | };
2130 | };
2131 | }
2132 |
2133 | function whenMergePropsIsFunction(mergeProps) {
2134 | return typeof mergeProps === 'function' ? wrapMergePropsFunc(mergeProps) : undefined;
2135 | }
2136 |
2137 | function whenMergePropsIsOmitted(mergeProps) {
2138 | return !mergeProps ? function () {
2139 | return defaultMergeProps;
2140 | } : undefined;
2141 | }
2142 |
2143 | var _default = [whenMergePropsIsFunction, whenMergePropsIsOmitted];
2144 | exports.default = _default;
2145 | },{"../utils/verifyPlainObject":33,"@babel/runtime/helpers/extends":2,"@babel/runtime/helpers/interopRequireDefault":4}],27:[function(require,module,exports){
2146 | "use strict";
2147 |
2148 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2149 |
2150 | exports.__esModule = true;
2151 | exports.impureFinalPropsSelectorFactory = impureFinalPropsSelectorFactory;
2152 | exports.pureFinalPropsSelectorFactory = pureFinalPropsSelectorFactory;
2153 | exports.default = finalPropsSelectorFactory;
2154 |
2155 | var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
2156 |
2157 | var _verifySubselectors = _interopRequireDefault(require("./verifySubselectors"));
2158 |
2159 | function impureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch) {
2160 | return function impureFinalPropsSelector(state, ownProps) {
2161 | return mergeProps(mapStateToProps(state, ownProps), mapDispatchToProps(dispatch, ownProps), ownProps);
2162 | };
2163 | }
2164 |
2165 | function pureFinalPropsSelectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, _ref) {
2166 | var areStatesEqual = _ref.areStatesEqual,
2167 | areOwnPropsEqual = _ref.areOwnPropsEqual,
2168 | areStatePropsEqual = _ref.areStatePropsEqual;
2169 | var hasRunAtLeastOnce = false;
2170 | var state;
2171 | var ownProps;
2172 | var stateProps;
2173 | var dispatchProps;
2174 | var mergedProps;
2175 |
2176 | function handleFirstCall(firstState, firstOwnProps) {
2177 | state = firstState;
2178 | ownProps = firstOwnProps;
2179 | stateProps = mapStateToProps(state, ownProps);
2180 | dispatchProps = mapDispatchToProps(dispatch, ownProps);
2181 | mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
2182 | hasRunAtLeastOnce = true;
2183 | return mergedProps;
2184 | }
2185 |
2186 | function handleNewPropsAndNewState() {
2187 | stateProps = mapStateToProps(state, ownProps);
2188 | if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
2189 | mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
2190 | return mergedProps;
2191 | }
2192 |
2193 | function handleNewProps() {
2194 | if (mapStateToProps.dependsOnOwnProps) stateProps = mapStateToProps(state, ownProps);
2195 | if (mapDispatchToProps.dependsOnOwnProps) dispatchProps = mapDispatchToProps(dispatch, ownProps);
2196 | mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
2197 | return mergedProps;
2198 | }
2199 |
2200 | function handleNewState() {
2201 | var nextStateProps = mapStateToProps(state, ownProps);
2202 | var statePropsChanged = !areStatePropsEqual(nextStateProps, stateProps);
2203 | stateProps = nextStateProps;
2204 | if (statePropsChanged) mergedProps = mergeProps(stateProps, dispatchProps, ownProps);
2205 | return mergedProps;
2206 | }
2207 |
2208 | function handleSubsequentCalls(nextState, nextOwnProps) {
2209 | var propsChanged = !areOwnPropsEqual(nextOwnProps, ownProps);
2210 | var stateChanged = !areStatesEqual(nextState, state);
2211 | state = nextState;
2212 | ownProps = nextOwnProps;
2213 | if (propsChanged && stateChanged) return handleNewPropsAndNewState();
2214 | if (propsChanged) return handleNewProps();
2215 | if (stateChanged) return handleNewState();
2216 | return mergedProps;
2217 | }
2218 |
2219 | return function pureFinalPropsSelector(nextState, nextOwnProps) {
2220 | return hasRunAtLeastOnce ? handleSubsequentCalls(nextState, nextOwnProps) : handleFirstCall(nextState, nextOwnProps);
2221 | };
2222 | } // TODO: Add more comments
2223 | // If pure is true, the selector returned by selectorFactory will memoize its results,
2224 | // allowing connectAdvanced's shouldComponentUpdate to return false if final
2225 | // props have not changed. If false, the selector will always return a new
2226 | // object and shouldComponentUpdate will always return true.
2227 |
2228 |
2229 | function finalPropsSelectorFactory(dispatch, _ref2) {
2230 | var initMapStateToProps = _ref2.initMapStateToProps,
2231 | initMapDispatchToProps = _ref2.initMapDispatchToProps,
2232 | initMergeProps = _ref2.initMergeProps,
2233 | options = (0, _objectWithoutPropertiesLoose2.default)(_ref2, ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]);
2234 | var mapStateToProps = initMapStateToProps(dispatch, options);
2235 | var mapDispatchToProps = initMapDispatchToProps(dispatch, options);
2236 | var mergeProps = initMergeProps(dispatch, options);
2237 |
2238 | if ("production" !== 'production') {
2239 | (0, _verifySubselectors.default)(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName);
2240 | }
2241 |
2242 | var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory;
2243 | return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options);
2244 | }
2245 | },{"./verifySubselectors":28,"@babel/runtime/helpers/interopRequireDefault":4,"@babel/runtime/helpers/objectWithoutPropertiesLoose":6}],28:[function(require,module,exports){
2246 | "use strict";
2247 |
2248 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2249 |
2250 | exports.__esModule = true;
2251 | exports.default = verifySubselectors;
2252 |
2253 | var _warning = _interopRequireDefault(require("../utils/warning"));
2254 |
2255 | function verify(selector, methodName, displayName) {
2256 | if (!selector) {
2257 | throw new Error("Unexpected value for " + methodName + " in " + displayName + ".");
2258 | } else if (methodName === 'mapStateToProps' || methodName === 'mapDispatchToProps') {
2259 | if (!selector.hasOwnProperty('dependsOnOwnProps')) {
2260 | (0, _warning.default)("The selector for " + methodName + " of " + displayName + " did not specify a value for dependsOnOwnProps.");
2261 | }
2262 | }
2263 | }
2264 |
2265 | function verifySubselectors(mapStateToProps, mapDispatchToProps, mergeProps, displayName) {
2266 | verify(mapStateToProps, 'mapStateToProps', displayName);
2267 | verify(mapDispatchToProps, 'mapDispatchToProps', displayName);
2268 | verify(mergeProps, 'mergeProps', displayName);
2269 | }
2270 | },{"../utils/warning":34,"@babel/runtime/helpers/interopRequireDefault":4}],29:[function(require,module,exports){
2271 | "use strict";
2272 |
2273 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2274 |
2275 | exports.__esModule = true;
2276 | exports.wrapMapToPropsConstant = wrapMapToPropsConstant;
2277 | exports.getDependsOnOwnProps = getDependsOnOwnProps;
2278 | exports.wrapMapToPropsFunc = wrapMapToPropsFunc;
2279 |
2280 | var _verifyPlainObject = _interopRequireDefault(require("../utils/verifyPlainObject"));
2281 |
2282 | function wrapMapToPropsConstant(getConstant) {
2283 | return function initConstantSelector(dispatch, options) {
2284 | var constant = getConstant(dispatch, options);
2285 |
2286 | function constantSelector() {
2287 | return constant;
2288 | }
2289 |
2290 | constantSelector.dependsOnOwnProps = false;
2291 | return constantSelector;
2292 | };
2293 | } // dependsOnOwnProps is used by createMapToPropsProxy to determine whether to pass props as args
2294 | // to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine
2295 | // whether mapToProps needs to be invoked when props have changed.
2296 | //
2297 | // A length of one signals that mapToProps does not depend on props from the parent component.
2298 | // A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and
2299 | // therefore not reporting its length accurately..
2300 |
2301 |
2302 | function getDependsOnOwnProps(mapToProps) {
2303 | return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1;
2304 | } // Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction,
2305 | // this function wraps mapToProps in a proxy function which does several things:
2306 | //
2307 | // * Detects whether the mapToProps function being called depends on props, which
2308 | // is used by selectorFactory to decide if it should reinvoke on props changes.
2309 | //
2310 | // * On first call, handles mapToProps if returns another function, and treats that
2311 | // new function as the true mapToProps for subsequent calls.
2312 | //
2313 | // * On first call, verifies the first result is a plain object, in order to warn
2314 | // the developer that their mapToProps function is not returning a valid result.
2315 | //
2316 |
2317 |
2318 | function wrapMapToPropsFunc(mapToProps, methodName) {
2319 | return function initProxySelector(dispatch, _ref) {
2320 | var displayName = _ref.displayName;
2321 |
2322 | var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {
2323 | return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch);
2324 | }; // allow detectFactoryAndVerify to get ownProps
2325 |
2326 |
2327 | proxy.dependsOnOwnProps = true;
2328 |
2329 | proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) {
2330 | proxy.mapToProps = mapToProps;
2331 | proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps);
2332 | var props = proxy(stateOrDispatch, ownProps);
2333 |
2334 | if (typeof props === 'function') {
2335 | proxy.mapToProps = props;
2336 | proxy.dependsOnOwnProps = getDependsOnOwnProps(props);
2337 | props = proxy(stateOrDispatch, ownProps);
2338 | }
2339 |
2340 | if ("production" !== 'production') (0, _verifyPlainObject.default)(props, displayName, methodName);
2341 | return props;
2342 | };
2343 |
2344 | return proxy;
2345 | };
2346 | }
2347 | },{"../utils/verifyPlainObject":33,"@babel/runtime/helpers/interopRequireDefault":4}],30:[function(require,module,exports){
2348 | "use strict";
2349 |
2350 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2351 |
2352 | exports.__esModule = true;
2353 |
2354 | var _Provider = _interopRequireDefault(require("./components/Provider"));
2355 |
2356 | exports.Provider = _Provider.default;
2357 |
2358 | var _connectAdvanced = _interopRequireDefault(require("./components/connectAdvanced"));
2359 |
2360 | exports.connectAdvanced = _connectAdvanced.default;
2361 |
2362 | var _Context = require("./components/Context");
2363 |
2364 | exports.ReactReduxContext = _Context.ReactReduxContext;
2365 |
2366 | var _connect = _interopRequireDefault(require("./connect/connect"));
2367 |
2368 | exports.connect = _connect.default;
2369 | },{"./components/Context":20,"./components/Provider":21,"./components/connectAdvanced":22,"./connect/connect":23,"@babel/runtime/helpers/interopRequireDefault":4}],31:[function(require,module,exports){
2370 | "use strict";
2371 |
2372 | exports.__esModule = true;
2373 | exports.default = isPlainObject;
2374 |
2375 | /**
2376 | * @param {any} obj The object to inspect.
2377 | * @returns {boolean} True if the argument appears to be a plain object.
2378 | */
2379 | function isPlainObject(obj) {
2380 | if (typeof obj !== 'object' || obj === null) return false;
2381 | var proto = Object.getPrototypeOf(obj);
2382 | if (proto === null) return true;
2383 | var baseProto = proto;
2384 |
2385 | while (Object.getPrototypeOf(baseProto) !== null) {
2386 | baseProto = Object.getPrototypeOf(baseProto);
2387 | }
2388 |
2389 | return proto === baseProto;
2390 | }
2391 | },{}],32:[function(require,module,exports){
2392 | "use strict";
2393 |
2394 | exports.__esModule = true;
2395 | exports.default = shallowEqual;
2396 | var hasOwn = Object.prototype.hasOwnProperty;
2397 |
2398 | function is(x, y) {
2399 | if (x === y) {
2400 | return x !== 0 || y !== 0 || 1 / x === 1 / y;
2401 | } else {
2402 | return x !== x && y !== y;
2403 | }
2404 | }
2405 |
2406 | function shallowEqual(objA, objB) {
2407 | if (is(objA, objB)) return true;
2408 |
2409 | if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
2410 | return false;
2411 | }
2412 |
2413 | var keysA = Object.keys(objA);
2414 | var keysB = Object.keys(objB);
2415 | if (keysA.length !== keysB.length) return false;
2416 |
2417 | for (var i = 0; i < keysA.length; i++) {
2418 | if (!hasOwn.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
2419 | return false;
2420 | }
2421 | }
2422 |
2423 | return true;
2424 | }
2425 | },{}],33:[function(require,module,exports){
2426 | "use strict";
2427 |
2428 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
2429 |
2430 | exports.__esModule = true;
2431 | exports.default = verifyPlainObject;
2432 |
2433 | var _isPlainObject = _interopRequireDefault(require("./isPlainObject"));
2434 |
2435 | var _warning = _interopRequireDefault(require("./warning"));
2436 |
2437 | function verifyPlainObject(value, displayName, methodName) {
2438 | if (!(0, _isPlainObject.default)(value)) {
2439 | (0, _warning.default)(methodName + "() in " + displayName + " must return a plain object. Instead received " + value + ".");
2440 | }
2441 | }
2442 | },{"./isPlainObject":31,"./warning":34,"@babel/runtime/helpers/interopRequireDefault":4}],34:[function(require,module,exports){
2443 | "use strict";
2444 |
2445 | exports.__esModule = true;
2446 | exports.default = warning;
2447 |
2448 | /**
2449 | * Prints a warning in the console if it exists.
2450 | *
2451 | * @param {String} message The warning message.
2452 | * @returns {void}
2453 | */
2454 | function warning(message) {
2455 | /* eslint-disable no-console */
2456 | if (typeof console !== 'undefined' && typeof console.error === 'function') {
2457 | console.error(message);
2458 | }
2459 | /* eslint-enable no-console */
2460 |
2461 |
2462 | try {
2463 | // This error was thrown as a convenience so that if you enable
2464 | // "break on all exceptions" in your console,
2465 | // it would pause the execution at this line.
2466 | throw new Error(message);
2467 | /* eslint-disable no-empty */
2468 | } catch (e) {}
2469 | /* eslint-enable no-empty */
2470 |
2471 | }
2472 | },{}],35:[function(require,module,exports){
2473 | 'use strict';
2474 |
2475 | Object.defineProperty(exports, '__esModule', { value: true });
2476 |
2477 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
2478 |
2479 | var $$observable = _interopDefault(require('symbol-observable'));
2480 |
2481 | /**
2482 | * These are private action types reserved by Redux.
2483 | * For any unknown actions, you must return the current state.
2484 | * If the current state is undefined, you must return the initial state.
2485 | * Do not reference these action types directly in your code.
2486 | */
2487 | var randomString = function randomString() {
2488 | return Math.random().toString(36).substring(7).split('').join('.');
2489 | };
2490 |
2491 | var ActionTypes = {
2492 | INIT: "@@redux/INIT" + randomString(),
2493 | REPLACE: "@@redux/REPLACE" + randomString(),
2494 | PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
2495 | return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
2496 | }
2497 | };
2498 |
2499 | /**
2500 | * @param {any} obj The object to inspect.
2501 | * @returns {boolean} True if the argument appears to be a plain object.
2502 | */
2503 | function isPlainObject(obj) {
2504 | if (typeof obj !== 'object' || obj === null) return false;
2505 | var proto = obj;
2506 |
2507 | while (Object.getPrototypeOf(proto) !== null) {
2508 | proto = Object.getPrototypeOf(proto);
2509 | }
2510 |
2511 | return Object.getPrototypeOf(obj) === proto;
2512 | }
2513 |
2514 | /**
2515 | * Creates a Redux store that holds the state tree.
2516 | * The only way to change the data in the store is to call `dispatch()` on it.
2517 | *
2518 | * There should only be a single store in your app. To specify how different
2519 | * parts of the state tree respond to actions, you may combine several reducers
2520 | * into a single reducer function by using `combineReducers`.
2521 | *
2522 | * @param {Function} reducer A function that returns the next state tree, given
2523 | * the current state tree and the action to handle.
2524 | *
2525 | * @param {any} [preloadedState] The initial state. You may optionally specify it
2526 | * to hydrate the state from the server in universal apps, or to restore a
2527 | * previously serialized user session.
2528 | * If you use `combineReducers` to produce the root reducer function, this must be
2529 | * an object with the same shape as `combineReducers` keys.
2530 | *
2531 | * @param {Function} [enhancer] The store enhancer. You may optionally specify it
2532 | * to enhance the store with third-party capabilities such as middleware,
2533 | * time travel, persistence, etc. The only store enhancer that ships with Redux
2534 | * is `applyMiddleware()`.
2535 | *
2536 | * @returns {Store} A Redux store that lets you read the state, dispatch actions
2537 | * and subscribe to changes.
2538 | */
2539 |
2540 | function createStore(reducer, preloadedState, enhancer) {
2541 | var _ref2;
2542 |
2543 | if (typeof preloadedState === 'function' && typeof enhancer === 'function' || typeof enhancer === 'function' && typeof arguments[3] === 'function') {
2544 | throw new Error('It looks like you are passing several store enhancers to ' + 'createStore(). This is not supported. Instead, compose them ' + 'together to a single function.');
2545 | }
2546 |
2547 | if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
2548 | enhancer = preloadedState;
2549 | preloadedState = undefined;
2550 | }
2551 |
2552 | if (typeof enhancer !== 'undefined') {
2553 | if (typeof enhancer !== 'function') {
2554 | throw new Error('Expected the enhancer to be a function.');
2555 | }
2556 |
2557 | return enhancer(createStore)(reducer, preloadedState);
2558 | }
2559 |
2560 | if (typeof reducer !== 'function') {
2561 | throw new Error('Expected the reducer to be a function.');
2562 | }
2563 |
2564 | var currentReducer = reducer;
2565 | var currentState = preloadedState;
2566 | var currentListeners = [];
2567 | var nextListeners = currentListeners;
2568 | var isDispatching = false;
2569 | /**
2570 | * This makes a shallow copy of currentListeners so we can use
2571 | * nextListeners as a temporary list while dispatching.
2572 | *
2573 | * This prevents any bugs around consumers calling
2574 | * subscribe/unsubscribe in the middle of a dispatch.
2575 | */
2576 |
2577 | function ensureCanMutateNextListeners() {
2578 | if (nextListeners === currentListeners) {
2579 | nextListeners = currentListeners.slice();
2580 | }
2581 | }
2582 | /**
2583 | * Reads the state tree managed by the store.
2584 | *
2585 | * @returns {any} The current state tree of your application.
2586 | */
2587 |
2588 |
2589 | function getState() {
2590 | if (isDispatching) {
2591 | throw new Error('You may not call store.getState() while the reducer is executing. ' + 'The reducer has already received the state as an argument. ' + 'Pass it down from the top reducer instead of reading it from the store.');
2592 | }
2593 |
2594 | return currentState;
2595 | }
2596 | /**
2597 | * Adds a change listener. It will be called any time an action is dispatched,
2598 | * and some part of the state tree may potentially have changed. You may then
2599 | * call `getState()` to read the current state tree inside the callback.
2600 | *
2601 | * You may call `dispatch()` from a change listener, with the following
2602 | * caveats:
2603 | *
2604 | * 1. The subscriptions are snapshotted just before every `dispatch()` call.
2605 | * If you subscribe or unsubscribe while the listeners are being invoked, this
2606 | * will not have any effect on the `dispatch()` that is currently in progress.
2607 | * However, the next `dispatch()` call, whether nested or not, will use a more
2608 | * recent snapshot of the subscription list.
2609 | *
2610 | * 2. The listener should not expect to see all state changes, as the state
2611 | * might have been updated multiple times during a nested `dispatch()` before
2612 | * the listener is called. It is, however, guaranteed that all subscribers
2613 | * registered before the `dispatch()` started will be called with the latest
2614 | * state by the time it exits.
2615 | *
2616 | * @param {Function} listener A callback to be invoked on every dispatch.
2617 | * @returns {Function} A function to remove this change listener.
2618 | */
2619 |
2620 |
2621 | function subscribe(listener) {
2622 | if (typeof listener !== 'function') {
2623 | throw new Error('Expected the listener to be a function.');
2624 | }
2625 |
2626 | if (isDispatching) {
2627 | throw new Error('You may not call store.subscribe() while the reducer is executing. ' + 'If you would like to be notified after the store has been updated, subscribe from a ' + 'component and invoke store.getState() in the callback to access the latest state. ' + 'See https://redux.js.org/api-reference/store#subscribelistener for more details.');
2628 | }
2629 |
2630 | var isSubscribed = true;
2631 | ensureCanMutateNextListeners();
2632 | nextListeners.push(listener);
2633 | return function unsubscribe() {
2634 | if (!isSubscribed) {
2635 | return;
2636 | }
2637 |
2638 | if (isDispatching) {
2639 | throw new Error('You may not unsubscribe from a store listener while the reducer is executing. ' + 'See https://redux.js.org/api-reference/store#subscribelistener for more details.');
2640 | }
2641 |
2642 | isSubscribed = false;
2643 | ensureCanMutateNextListeners();
2644 | var index = nextListeners.indexOf(listener);
2645 | nextListeners.splice(index, 1);
2646 | currentListeners = null;
2647 | };
2648 | }
2649 | /**
2650 | * Dispatches an action. It is the only way to trigger a state change.
2651 | *
2652 | * The `reducer` function, used to create the store, will be called with the
2653 | * current state tree and the given `action`. Its return value will
2654 | * be considered the **next** state of the tree, and the change listeners
2655 | * will be notified.
2656 | *
2657 | * The base implementation only supports plain object actions. If you want to
2658 | * dispatch a Promise, an Observable, a thunk, or something else, you need to
2659 | * wrap your store creating function into the corresponding middleware. For
2660 | * example, see the documentation for the `redux-thunk` package. Even the
2661 | * middleware will eventually dispatch plain object actions using this method.
2662 | *
2663 | * @param {Object} action A plain object representing “what changed”. It is
2664 | * a good idea to keep actions serializable so you can record and replay user
2665 | * sessions, or use the time travelling `redux-devtools`. An action must have
2666 | * a `type` property which may not be `undefined`. It is a good idea to use
2667 | * string constants for action types.
2668 | *
2669 | * @returns {Object} For convenience, the same action object you dispatched.
2670 | *
2671 | * Note that, if you use a custom middleware, it may wrap `dispatch()` to
2672 | * return something else (for example, a Promise you can await).
2673 | */
2674 |
2675 |
2676 | function dispatch(action) {
2677 | if (!isPlainObject(action)) {
2678 | throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.');
2679 | }
2680 |
2681 | if (typeof action.type === 'undefined') {
2682 | throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?');
2683 | }
2684 |
2685 | if (isDispatching) {
2686 | throw new Error('Reducers may not dispatch actions.');
2687 | }
2688 |
2689 | try {
2690 | isDispatching = true;
2691 | currentState = currentReducer(currentState, action);
2692 | } finally {
2693 | isDispatching = false;
2694 | }
2695 |
2696 | var listeners = currentListeners = nextListeners;
2697 |
2698 | for (var i = 0; i < listeners.length; i++) {
2699 | var listener = listeners[i];
2700 | listener();
2701 | }
2702 |
2703 | return action;
2704 | }
2705 | /**
2706 | * Replaces the reducer currently used by the store to calculate the state.
2707 | *
2708 | * You might need this if your app implements code splitting and you want to
2709 | * load some of the reducers dynamically. You might also need this if you
2710 | * implement a hot reloading mechanism for Redux.
2711 | *
2712 | * @param {Function} nextReducer The reducer for the store to use instead.
2713 | * @returns {void}
2714 | */
2715 |
2716 |
2717 | function replaceReducer(nextReducer) {
2718 | if (typeof nextReducer !== 'function') {
2719 | throw new Error('Expected the nextReducer to be a function.');
2720 | }
2721 |
2722 | currentReducer = nextReducer; // This action has a similiar effect to ActionTypes.INIT.
2723 | // Any reducers that existed in both the new and old rootReducer
2724 | // will receive the previous state. This effectively populates
2725 | // the new state tree with any relevant data from the old one.
2726 |
2727 | dispatch({
2728 | type: ActionTypes.REPLACE
2729 | });
2730 | }
2731 | /**
2732 | * Interoperability point for observable/reactive libraries.
2733 | * @returns {observable} A minimal observable of state changes.
2734 | * For more information, see the observable proposal:
2735 | * https://github.com/tc39/proposal-observable
2736 | */
2737 |
2738 |
2739 | function observable() {
2740 | var _ref;
2741 |
2742 | var outerSubscribe = subscribe;
2743 | return _ref = {
2744 | /**
2745 | * The minimal observable subscription method.
2746 | * @param {Object} observer Any object that can be used as an observer.
2747 | * The observer object should have a `next` method.
2748 | * @returns {subscription} An object with an `unsubscribe` method that can
2749 | * be used to unsubscribe the observable from the store, and prevent further
2750 | * emission of values from the observable.
2751 | */
2752 | subscribe: function subscribe(observer) {
2753 | if (typeof observer !== 'object' || observer === null) {
2754 | throw new TypeError('Expected the observer to be an object.');
2755 | }
2756 |
2757 | function observeState() {
2758 | if (observer.next) {
2759 | observer.next(getState());
2760 | }
2761 | }
2762 |
2763 | observeState();
2764 | var unsubscribe = outerSubscribe(observeState);
2765 | return {
2766 | unsubscribe: unsubscribe
2767 | };
2768 | }
2769 | }, _ref[$$observable] = function () {
2770 | return this;
2771 | }, _ref;
2772 | } // When a store is created, an "INIT" action is dispatched so that every
2773 | // reducer returns their initial state. This effectively populates
2774 | // the initial state tree.
2775 |
2776 |
2777 | dispatch({
2778 | type: ActionTypes.INIT
2779 | });
2780 | return _ref2 = {
2781 | dispatch: dispatch,
2782 | subscribe: subscribe,
2783 | getState: getState,
2784 | replaceReducer: replaceReducer
2785 | }, _ref2[$$observable] = observable, _ref2;
2786 | }
2787 |
2788 | /**
2789 | * Prints a warning in the console if it exists.
2790 | *
2791 | * @param {String} message The warning message.
2792 | * @returns {void}
2793 | */
2794 | function warning(message) {
2795 | /* eslint-disable no-console */
2796 | if (typeof console !== 'undefined' && typeof console.error === 'function') {
2797 | console.error(message);
2798 | }
2799 | /* eslint-enable no-console */
2800 |
2801 |
2802 | try {
2803 | // This error was thrown as a convenience so that if you enable
2804 | // "break on all exceptions" in your console,
2805 | // it would pause the execution at this line.
2806 | throw new Error(message);
2807 | } catch (e) {} // eslint-disable-line no-empty
2808 |
2809 | }
2810 |
2811 | function getUndefinedStateErrorMessage(key, action) {
2812 | var actionType = action && action.type;
2813 | var actionDescription = actionType && "action \"" + String(actionType) + "\"" || 'an action';
2814 | return "Given " + actionDescription + ", 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.";
2815 | }
2816 |
2817 | function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
2818 | var reducerKeys = Object.keys(reducers);
2819 | var argumentName = action && action.type === ActionTypes.INIT ? 'preloadedState argument passed to createStore' : 'previous state received by the reducer';
2820 |
2821 | if (reducerKeys.length === 0) {
2822 | return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.';
2823 | }
2824 |
2825 | if (!isPlainObject(inputState)) {
2826 | 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('", "') + "\"");
2827 | }
2828 |
2829 | var unexpectedKeys = Object.keys(inputState).filter(function (key) {
2830 | return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
2831 | });
2832 | unexpectedKeys.forEach(function (key) {
2833 | unexpectedKeyCache[key] = true;
2834 | });
2835 | if (action && action.type === ActionTypes.REPLACE) return;
2836 |
2837 | if (unexpectedKeys.length > 0) {
2838 | 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.");
2839 | }
2840 | }
2841 |
2842 | function assertReducerShape(reducers) {
2843 | Object.keys(reducers).forEach(function (key) {
2844 | var reducer = reducers[key];
2845 | var initialState = reducer(undefined, {
2846 | type: ActionTypes.INIT
2847 | });
2848 |
2849 | if (typeof initialState === 'undefined') {
2850 | 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.");
2851 | }
2852 |
2853 | if (typeof reducer(undefined, {
2854 | type: ActionTypes.PROBE_UNKNOWN_ACTION()
2855 | }) === 'undefined') {
2856 | 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.");
2857 | }
2858 | });
2859 | }
2860 | /**
2861 | * Turns an object whose values are different reducer functions, into a single
2862 | * reducer function. It will call every child reducer, and gather their results
2863 | * into a single state object, whose keys correspond to the keys of the passed
2864 | * reducer functions.
2865 | *
2866 | * @param {Object} reducers An object whose values correspond to different
2867 | * reducer functions that need to be combined into one. One handy way to obtain
2868 | * it is to use ES6 `import * as reducers` syntax. The reducers may never return
2869 | * undefined for any action. Instead, they should return their initial state
2870 | * if the state passed to them was undefined, and the current state for any
2871 | * unrecognized action.
2872 | *
2873 | * @returns {Function} A reducer function that invokes every reducer inside the
2874 | * passed object, and builds a state object with the same shape.
2875 | */
2876 |
2877 |
2878 | function combineReducers(reducers) {
2879 | var reducerKeys = Object.keys(reducers);
2880 | var finalReducers = {};
2881 |
2882 | for (var i = 0; i < reducerKeys.length; i++) {
2883 | var key = reducerKeys[i];
2884 |
2885 | if ("production" !== 'production') {
2886 | if (typeof reducers[key] === 'undefined') {
2887 | warning("No reducer provided for key \"" + key + "\"");
2888 | }
2889 | }
2890 |
2891 | if (typeof reducers[key] === 'function') {
2892 | finalReducers[key] = reducers[key];
2893 | }
2894 | }
2895 |
2896 | var finalReducerKeys = Object.keys(finalReducers); // This is used to make sure we don't warn about the same
2897 | // keys multiple times.
2898 |
2899 | var unexpectedKeyCache;
2900 |
2901 | if ("production" !== 'production') {
2902 | unexpectedKeyCache = {};
2903 | }
2904 |
2905 | var shapeAssertionError;
2906 |
2907 | try {
2908 | assertReducerShape(finalReducers);
2909 | } catch (e) {
2910 | shapeAssertionError = e;
2911 | }
2912 |
2913 | return function combination(state, action) {
2914 | if (state === void 0) {
2915 | state = {};
2916 | }
2917 |
2918 | if (shapeAssertionError) {
2919 | throw shapeAssertionError;
2920 | }
2921 |
2922 | if ("production" !== 'production') {
2923 | var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
2924 |
2925 | if (warningMessage) {
2926 | warning(warningMessage);
2927 | }
2928 | }
2929 |
2930 | var hasChanged = false;
2931 | var nextState = {};
2932 |
2933 | for (var _i = 0; _i < finalReducerKeys.length; _i++) {
2934 | var _key = finalReducerKeys[_i];
2935 | var reducer = finalReducers[_key];
2936 | var previousStateForKey = state[_key];
2937 | var nextStateForKey = reducer(previousStateForKey, action);
2938 |
2939 | if (typeof nextStateForKey === 'undefined') {
2940 | var errorMessage = getUndefinedStateErrorMessage(_key, action);
2941 | throw new Error(errorMessage);
2942 | }
2943 |
2944 | nextState[_key] = nextStateForKey;
2945 | hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
2946 | }
2947 |
2948 | hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
2949 | return hasChanged ? nextState : state;
2950 | };
2951 | }
2952 |
2953 | function bindActionCreator(actionCreator, dispatch) {
2954 | return function () {
2955 | return dispatch(actionCreator.apply(this, arguments));
2956 | };
2957 | }
2958 | /**
2959 | * Turns an object whose values are action creators, into an object with the
2960 | * same keys, but with every function wrapped into a `dispatch` call so they
2961 | * may be invoked directly. This is just a convenience method, as you can call
2962 | * `store.dispatch(MyActionCreators.doSomething())` yourself just fine.
2963 | *
2964 | * For convenience, you can also pass an action creator as the first argument,
2965 | * and get a dispatch wrapped function in return.
2966 | *
2967 | * @param {Function|Object} actionCreators An object whose values are action
2968 | * creator functions. One handy way to obtain it is to use ES6 `import * as`
2969 | * syntax. You may also pass a single function.
2970 | *
2971 | * @param {Function} dispatch The `dispatch` function available on your Redux
2972 | * store.
2973 | *
2974 | * @returns {Function|Object} The object mimicking the original object, but with
2975 | * every action creator wrapped into the `dispatch` call. If you passed a
2976 | * function as `actionCreators`, the return value will also be a single
2977 | * function.
2978 | */
2979 |
2980 |
2981 | function bindActionCreators(actionCreators, dispatch) {
2982 | if (typeof actionCreators === 'function') {
2983 | return bindActionCreator(actionCreators, dispatch);
2984 | }
2985 |
2986 | if (typeof actionCreators !== 'object' || actionCreators === null) {
2987 | 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\"?");
2988 | }
2989 |
2990 | var boundActionCreators = {};
2991 |
2992 | for (var key in actionCreators) {
2993 | var actionCreator = actionCreators[key];
2994 |
2995 | if (typeof actionCreator === 'function') {
2996 | boundActionCreators[key] = bindActionCreator(actionCreator, dispatch);
2997 | }
2998 | }
2999 |
3000 | return boundActionCreators;
3001 | }
3002 |
3003 | function _defineProperty(obj, key, value) {
3004 | if (key in obj) {
3005 | Object.defineProperty(obj, key, {
3006 | value: value,
3007 | enumerable: true,
3008 | configurable: true,
3009 | writable: true
3010 | });
3011 | } else {
3012 | obj[key] = value;
3013 | }
3014 |
3015 | return obj;
3016 | }
3017 |
3018 | function ownKeys(object, enumerableOnly) {
3019 | var keys = Object.keys(object);
3020 |
3021 | if (Object.getOwnPropertySymbols) {
3022 | keys.push.apply(keys, Object.getOwnPropertySymbols(object));
3023 | }
3024 |
3025 | if (enumerableOnly) keys = keys.filter(function (sym) {
3026 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
3027 | });
3028 | return keys;
3029 | }
3030 |
3031 | function _objectSpread2(target) {
3032 | for (var i = 1; i < arguments.length; i++) {
3033 | var source = arguments[i] != null ? arguments[i] : {};
3034 |
3035 | if (i % 2) {
3036 | ownKeys(source, true).forEach(function (key) {
3037 | _defineProperty(target, key, source[key]);
3038 | });
3039 | } else if (Object.getOwnPropertyDescriptors) {
3040 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
3041 | } else {
3042 | ownKeys(source).forEach(function (key) {
3043 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
3044 | });
3045 | }
3046 | }
3047 |
3048 | return target;
3049 | }
3050 |
3051 | /**
3052 | * Composes single-argument functions from right to left. The rightmost
3053 | * function can take multiple arguments as it provides the signature for
3054 | * the resulting composite function.
3055 | *
3056 | * @param {...Function} funcs The functions to compose.
3057 | * @returns {Function} A function obtained by composing the argument functions
3058 | * from right to left. For example, compose(f, g, h) is identical to doing
3059 | * (...args) => f(g(h(...args))).
3060 | */
3061 | function compose() {
3062 | for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
3063 | funcs[_key] = arguments[_key];
3064 | }
3065 |
3066 | if (funcs.length === 0) {
3067 | return function (arg) {
3068 | return arg;
3069 | };
3070 | }
3071 |
3072 | if (funcs.length === 1) {
3073 | return funcs[0];
3074 | }
3075 |
3076 | return funcs.reduce(function (a, b) {
3077 | return function () {
3078 | return a(b.apply(void 0, arguments));
3079 | };
3080 | });
3081 | }
3082 |
3083 | /**
3084 | * Creates a store enhancer that applies middleware to the dispatch method
3085 | * of the Redux store. This is handy for a variety of tasks, such as expressing
3086 | * asynchronous actions in a concise manner, or logging every action payload.
3087 | *
3088 | * See `redux-thunk` package as an example of the Redux middleware.
3089 | *
3090 | * Because middleware is potentially asynchronous, this should be the first
3091 | * store enhancer in the composition chain.
3092 | *
3093 | * Note that each middleware will be given the `dispatch` and `getState` functions
3094 | * as named arguments.
3095 | *
3096 | * @param {...Function} middlewares The middleware chain to be applied.
3097 | * @returns {Function} A store enhancer applying the middleware.
3098 | */
3099 |
3100 | function applyMiddleware() {
3101 | for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
3102 | middlewares[_key] = arguments[_key];
3103 | }
3104 |
3105 | return function (createStore) {
3106 | return function () {
3107 | var store = createStore.apply(void 0, arguments);
3108 |
3109 | var _dispatch = function dispatch() {
3110 | throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.');
3111 | };
3112 |
3113 | var middlewareAPI = {
3114 | getState: store.getState,
3115 | dispatch: function dispatch() {
3116 | return _dispatch.apply(void 0, arguments);
3117 | }
3118 | };
3119 | var chain = middlewares.map(function (middleware) {
3120 | return middleware(middlewareAPI);
3121 | });
3122 | _dispatch = compose.apply(void 0, chain)(store.dispatch);
3123 | return _objectSpread2({}, store, {
3124 | dispatch: _dispatch
3125 | });
3126 | };
3127 | };
3128 | }
3129 |
3130 | /*
3131 | * This is a dummy function to check if the function name has been altered by minification.
3132 | * If the function has been minified and NODE_ENV !== 'production', warn the user.
3133 | */
3134 |
3135 | function isCrushed() {}
3136 |
3137 | if ("production" !== 'production' && typeof isCrushed.name === 'string' && isCrushed.name !== 'isCrushed') {
3138 | 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 setting mode to production in webpack (https://webpack.js.org/concepts/mode/) ' + 'to ensure you have the correct code for your production build.');
3139 | }
3140 |
3141 | exports.__DO_NOT_USE__ActionTypes = ActionTypes;
3142 | exports.applyMiddleware = applyMiddleware;
3143 | exports.bindActionCreators = bindActionCreators;
3144 | exports.combineReducers = combineReducers;
3145 | exports.compose = compose;
3146 | exports.createStore = createStore;
3147 |
3148 | },{"symbol-observable":36}],36:[function(require,module,exports){
3149 | (function (global){
3150 | 'use strict';
3151 |
3152 | Object.defineProperty(exports, "__esModule", {
3153 | value: true
3154 | });
3155 |
3156 | var _ponyfill = require('./ponyfill.js');
3157 |
3158 | var _ponyfill2 = _interopRequireDefault(_ponyfill);
3159 |
3160 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
3161 |
3162 | var root; /* global window */
3163 |
3164 |
3165 | if (typeof self !== 'undefined') {
3166 | root = self;
3167 | } else if (typeof window !== 'undefined') {
3168 | root = window;
3169 | } else if (typeof global !== 'undefined') {
3170 | root = global;
3171 | } else if (typeof module !== 'undefined') {
3172 | root = module;
3173 | } else {
3174 | root = Function('return this')();
3175 | }
3176 |
3177 | var result = (0, _ponyfill2['default'])(root);
3178 | exports['default'] = result;
3179 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3180 | },{"./ponyfill.js":37}],37:[function(require,module,exports){
3181 | 'use strict';
3182 |
3183 | Object.defineProperty(exports, "__esModule", {
3184 | value: true
3185 | });
3186 | exports['default'] = symbolObservablePonyfill;
3187 | function symbolObservablePonyfill(root) {
3188 | var result;
3189 | var _Symbol = root.Symbol;
3190 |
3191 | if (typeof _Symbol === 'function') {
3192 | if (_Symbol.observable) {
3193 | result = _Symbol.observable;
3194 | } else {
3195 | result = _Symbol('observable');
3196 | _Symbol.observable = result;
3197 | }
3198 | } else {
3199 | result = '@@observable';
3200 | }
3201 |
3202 | return result;
3203 | };
3204 | },{}],38:[function(require,module,exports){
3205 | 'use strict';
3206 |
3207 | Object.defineProperty(exports, "__esModule", {
3208 | value: true
3209 | });
3210 |
3211 | 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; };
3212 |
3213 | exports.show = show;
3214 | exports.success = success;
3215 | exports.error = error;
3216 | exports.warning = warning;
3217 | exports.info = info;
3218 | exports.hide = hide;
3219 | exports.removeAll = removeAll;
3220 |
3221 | var _const = require('./const');
3222 |
3223 | //Example opts
3224 | // {
3225 | // title: 'Hey, it\'s good to see you!',
3226 | // message: 'Now you can see how easy it is to use notifications in React!',
3227 | // position: 'tr',
3228 | // autoDismiss: 0,
3229 | // action: {
3230 | // label: 'Awesome!',
3231 | // callback: function() {
3232 | // console.log('Clicked');
3233 | // }
3234 | // }
3235 | // }
3236 |
3237 | function show() {
3238 | var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3239 | var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'success';
3240 |
3241 | return _extends({
3242 | type: _const.RNS_SHOW_NOTIFICATION
3243 | }, opts, {
3244 | uid: opts.uid || Date.now(),
3245 | level: level
3246 | });
3247 | }
3248 |
3249 | function success(opts) {
3250 | return show(opts, 'success');
3251 | }
3252 |
3253 | function error(opts) {
3254 | return show(opts, 'error');
3255 | }
3256 |
3257 | function warning(opts) {
3258 | return show(opts, 'warning');
3259 | }
3260 |
3261 | function info(opts) {
3262 | return show(opts, 'info');
3263 | }
3264 |
3265 | function hide(uid) {
3266 | return {
3267 | type: _const.RNS_HIDE_NOTIFICATION,
3268 | uid: uid
3269 | };
3270 | }
3271 |
3272 | function removeAll() {
3273 | return { type: _const.RNS_REMOVE_ALL_NOTIFICATIONS };
3274 | }
3275 |
3276 | },{"./const":39}],39:[function(require,module,exports){
3277 | 'use strict';
3278 |
3279 | Object.defineProperty(exports, "__esModule", {
3280 | value: true
3281 | });
3282 | var RNS_SHOW_NOTIFICATION = exports.RNS_SHOW_NOTIFICATION = 'RNS_SHOW_NOTIFICATION';
3283 | var RNS_HIDE_NOTIFICATION = exports.RNS_HIDE_NOTIFICATION = 'RNS_HIDE_NOTIFICATION';
3284 | var RNS_REMOVE_ALL_NOTIFICATIONS = exports.RNS_REMOVE_ALL_NOTIFICATIONS = 'RNS_REMOVE_ALL_NOTIFICATIONS';
3285 |
3286 | },{}],40:[function(require,module,exports){
3287 | (function (global){
3288 | 'use strict';
3289 |
3290 | 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; };
3291 |
3292 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
3293 |
3294 | var _react = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null);
3295 |
3296 | var _react2 = _interopRequireDefault(_react);
3297 |
3298 | var _propTypes = require('prop-types');
3299 |
3300 | var _propTypes2 = _interopRequireDefault(_propTypes);
3301 |
3302 | var _reactRedux = require('react-redux');
3303 |
3304 | var _actions = require('./actions');
3305 |
3306 | var actions = _interopRequireWildcard(_actions);
3307 |
3308 | var _reducer = require('./reducer');
3309 |
3310 | var _reducer2 = _interopRequireDefault(_reducer);
3311 |
3312 | var _reactNotificationSystem = require('react-notification-system');
3313 |
3314 | var _reactNotificationSystem2 = _interopRequireDefault(_reactNotificationSystem);
3315 |
3316 | 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; } }
3317 |
3318 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
3319 |
3320 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
3321 |
3322 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3323 |
3324 | 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; }
3325 |
3326 | 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; }
3327 |
3328 | var Notifications = function (_React$Component) {
3329 | _inherits(Notifications, _React$Component);
3330 |
3331 | function Notifications(props) {
3332 | _classCallCheck(this, Notifications);
3333 |
3334 | var _this = _possibleConstructorReturn(this, (Notifications.__proto__ || Object.getPrototypeOf(Notifications)).call(this, props));
3335 |
3336 | _this.notifyRef = _react2['default'].createRef();
3337 | return _this;
3338 | }
3339 |
3340 | _createClass(Notifications, [{
3341 | key: 'system',
3342 | value: function () {
3343 | function system() {
3344 | return this.notifyRef.current;
3345 | }
3346 |
3347 | return system;
3348 | }()
3349 | }, {
3350 | key: 'componentDidUpdate',
3351 | value: function () {
3352 | function componentDidUpdate(prevProps) {
3353 | var _this2 = this;
3354 |
3355 | var _props = this.props,
3356 | notifications = _props.notifications,
3357 | store = _props.store;
3358 |
3359 | var notificationIds = notifications.map(function (notification) {
3360 | return notification.uid;
3361 | });
3362 | var systemNotifications = this.system().state.notifications || [];
3363 |
3364 | if (notifications.length > 0) {
3365 | // Get all active notifications from react-notification-system
3366 | /// and remove all where uid is not found in the reducer
3367 | systemNotifications.forEach(function (notification) {
3368 | if (notificationIds.indexOf(notification.uid) < 0) {
3369 | _this2.system().removeNotification(notification.uid);
3370 | }
3371 | });
3372 |
3373 | notifications.forEach(function (notification) {
3374 | _this2.system().addNotification(_extends({}, notification, {
3375 | onRemove: function () {
3376 | function onRemove() {
3377 | store.dispatch(actions.hide(notification.uid));
3378 | notification.onRemove && notification.onRemove();
3379 | }
3380 |
3381 | return onRemove;
3382 | }()
3383 | }));
3384 | });
3385 | }
3386 |
3387 | if (prevProps.notifications !== notifications && notifications.length === 0) {
3388 | this.system().clearNotifications();
3389 | }
3390 | }
3391 |
3392 | return componentDidUpdate;
3393 | }()
3394 | }, {
3395 | key: 'shouldComponentUpdate',
3396 | value: function () {
3397 | function shouldComponentUpdate(nextProps) {
3398 | return this.props !== nextProps;
3399 | }
3400 |
3401 | return shouldComponentUpdate;
3402 | }()
3403 | }, {
3404 | key: 'render',
3405 | value: function () {
3406 | function render() {
3407 | var _props2 = this.props,
3408 | notifications = _props2.notifications,
3409 | store = _props2.store,
3410 | rest = _objectWithoutProperties(_props2, ['notifications', 'store']);
3411 |
3412 | return _react2['default'].createElement(_reactNotificationSystem2['default'], _extends({ ref: this.notifyRef }, rest));
3413 | }
3414 |
3415 | return render;
3416 | }()
3417 | }]);
3418 |
3419 | return Notifications;
3420 | }(_react2['default'].Component);
3421 |
3422 | Notifications.propTypes = {
3423 | notifications: _propTypes2['default'].array,
3424 | store: _propTypes2['default'].shape({
3425 | dispatch: _propTypes2['default'].func.isRequired
3426 | }).isRequired
3427 | };
3428 |
3429 | var NotificationsWithContext = function NotificationsWithContext(props) {
3430 | var Context = props.context || _reactRedux.ReactReduxContext;
3431 |
3432 | if (Context == null) {
3433 | throw 'Please upgrade to react-redux v6';
3434 | }
3435 |
3436 | return _react2['default'].createElement(
3437 | Context.Consumer,
3438 | null,
3439 | function (otherProps) {
3440 | var store = otherProps.store;
3441 |
3442 | return _react2['default'].createElement(Notifications, _extends({ store: store }, props));
3443 | }
3444 | );
3445 | };
3446 |
3447 | NotificationsWithContext.propTypes = {
3448 | context: _propTypes2['default'].object
3449 | };
3450 |
3451 | // Tie actions to Notifications component instance
3452 | Object.keys(actions).forEach(function (key) {
3453 | NotificationsWithContext[key] = actions[key];
3454 | });
3455 |
3456 | NotificationsWithContext.reducer = _reducer2['default'];
3457 |
3458 | module.exports = NotificationsWithContext;
3459 |
3460 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
3461 | },{"./actions":38,"./reducer":41,"prop-types":15,"react-notification-system":undefined,"react-redux":30}],41:[function(require,module,exports){
3462 | 'use strict';
3463 |
3464 | Object.defineProperty(exports, "__esModule", {
3465 | value: true
3466 | });
3467 |
3468 | 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; };
3469 |
3470 | exports['default'] = Notifications;
3471 |
3472 | var _const = require('./const');
3473 |
3474 | 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); } }
3475 |
3476 | function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
3477 |
3478 | function Notifications() {
3479 | var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
3480 | var action = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3481 |
3482 | switch (action.type) {
3483 | case _const.RNS_SHOW_NOTIFICATION:
3484 | var type = action.type,
3485 | rest = _objectWithoutProperties(action, ['type']);
3486 |
3487 | return [].concat(_toConsumableArray(state), [_extends({}, rest, { uid: action.uid })]);
3488 | case _const.RNS_HIDE_NOTIFICATION:
3489 | return state.filter(function (notification) {
3490 | return notification.uid !== action.uid;
3491 | });
3492 | case _const.RNS_REMOVE_ALL_NOTIFICATIONS:
3493 | return [];
3494 | }
3495 | return state;
3496 | }
3497 |
3498 | },{"./const":39}]},{},[40])(40)
3499 | });
3500 |
--------------------------------------------------------------------------------