UNPKG

6.25 kBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory(require("lodash/lang"), require("./actions.js"), require("./pageUtils.js"), require("./merge.js"));
4 else if(typeof define === 'function' && define.amd)
5 define(["lodash/lang", "./actions.js", "./pageUtils.js", "./merge.js"], factory);
6 else if(typeof exports === 'object')
7 exports["reducer.js"] = factory(require("lodash/lang"), require("./actions.js"), require("./pageUtils.js"), require("./merge.js"));
8 else
9 root["reducer.js"] = factory(root["lodash/lang"], root["./actions.js"], root["./pageUtils.js"], root["./merge.js"]);
10})(this, function(__WEBPACK_EXTERNAL_MODULE_12__, __WEBPACK_EXTERNAL_MODULE_13__, __WEBPACK_EXTERNAL_MODULE_14__, __WEBPACK_EXTERNAL_MODULE_322__) {
11return /******/ (function(modules) { // webpackBootstrap
12/******/ // The module cache
13/******/ var installedModules = {};
14
15/******/ // The require function
16/******/ function __webpack_require__(moduleId) {
17
18/******/ // Check if module is in cache
19/******/ if(installedModules[moduleId])
20/******/ return installedModules[moduleId].exports;
21
22/******/ // Create a new module (and put it into the cache)
23/******/ var module = installedModules[moduleId] = {
24/******/ exports: {},
25/******/ id: moduleId,
26/******/ loaded: false
27/******/ };
28
29/******/ // Execute the module function
30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
32/******/ // Flag the module as loaded
33/******/ module.loaded = true;
34
35/******/ // Return the exports of the module
36/******/ return module.exports;
37/******/ }
38
39
40/******/ // expose the modules object (__webpack_modules__)
41/******/ __webpack_require__.m = modules;
42
43/******/ // expose the module cache
44/******/ __webpack_require__.c = installedModules;
45
46/******/ // __webpack_public_path__
47/******/ __webpack_require__.p = "";
48
49/******/ // Load entry module and return exports
50/******/ return __webpack_require__(0);
51/******/ })
52/************************************************************************/
53/******/ ({
54
55/***/ 0:
56/***/ function(module, exports, __webpack_require__) {
57
58 'use strict';
59
60 Object.defineProperty(exports, "__esModule", {
61 value: true
62 });
63
64 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; };
65
66 var _lang = __webpack_require__(12);
67
68 var _merge = __webpack_require__(322);
69
70 var _merge2 = _interopRequireDefault(_merge);
71
72 var _pageUtils = __webpack_require__(14);
73
74 var _actions = __webpack_require__(13);
75
76 var actions = _interopRequireWildcard(_actions);
77
78 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; } }
79
80 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
81
82 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); } }
83
84 var DEFAULT = {
85 currentPageIndex: -1,
86 history: [],
87 currentPage: {},
88 shell: false
89 };
90
91 exports.default = function () {
92 var state = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT : arguments[0];
93 var action = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
94
95 switch (action.type) {
96 case actions.SET_STATUS:
97 {
98 var pageData = (0, _merge2.default)(state.currentPage, { status: action.payload.status });
99 var history = [].concat(_toConsumableArray(state.history));
100 history[state.currentPageIndex] = pageData;
101
102 return _extends({}, state, { history: history, currentPage: pageData });
103 }
104
105 case actions.SET_PAGE:
106 {
107 var historyLen = state.history.length;
108 var referrerFromHistory = !(0, _lang.isEmpty)(state.currentPage) && historyLen > 1 ? (0, _pageUtils.urlFromPage)(state.currentPage) : '';
109
110 var _action$payload = action.payload;
111 var url = _action$payload.url;
112 var urlParams = _action$payload.urlParams;
113 var queryParams = _action$payload.queryParams;
114 var hashParams = _action$payload.hashParams;
115 var referrer = _action$payload.referrer;
116 var _action$payload$statu = _action$payload.status;
117 var status = _action$payload$statu === undefined ? 200 : _action$payload$statu;
118
119
120 var routeReferrer = referrer ? referrer : referrerFromHistory;
121
122 var relevantHistory = state.history.slice(0, state.currentPageIndex + 1);
123 var _pageData = {
124 url: url,
125 urlParams: urlParams,
126 queryParams: queryParams,
127 hashParams: hashParams,
128 status: status,
129 referrer: routeReferrer
130 };
131
132 return _extends({}, state, {
133 currentPageIndex: state.currentPageIndex + 1,
134 history: relevantHistory.concat([_pageData]),
135 currentPage: _pageData
136 });
137 }
138
139 case actions.GOTO_PAGE_INDEX:
140 {
141 var pageIndex = action.payload.pageIndex;
142
143
144 return _extends({}, state, {
145 currentPageIndex: pageIndex,
146 currentPage: state.history[pageIndex]
147 });
148 }
149
150 case actions.SET_SHELL:
151 {
152 return (0, _merge2.default)(state, {
153 shell: action.shell
154 });
155 }
156
157 default:
158 return state;
159 }
160 };
161
162/***/ },
163
164/***/ 12:
165/***/ function(module, exports) {
166
167 module.exports = require("lodash/lang");
168
169/***/ },
170
171/***/ 13:
172/***/ function(module, exports) {
173
174 module.exports = __WEBPACK_EXTERNAL_MODULE_13__;
175
176/***/ },
177
178/***/ 14:
179/***/ function(module, exports) {
180
181 module.exports = __WEBPACK_EXTERNAL_MODULE_14__;
182
183/***/ },
184
185/***/ 322:
186/***/ function(module, exports) {
187
188 module.exports = __WEBPACK_EXTERNAL_MODULE_322__;
189
190/***/ }
191
192/******/ })
193});
194;
\No newline at end of file