1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.NProgress = {}, global.React));
|
5 | })(this, (function (exports, React) { 'use strict';
|
6 |
|
7 | function _interopNamespaceDefault(e) {
|
8 | var n = Object.create(null);
|
9 | if (e) {
|
10 | Object.keys(e).forEach(function (k) {
|
11 | if (k !== 'default') {
|
12 | var d = Object.getOwnPropertyDescriptor(e, k);
|
13 | Object.defineProperty(n, k, d.get ? d : {
|
14 | enumerable: true,
|
15 | get: function () { return e[k]; }
|
16 | });
|
17 | }
|
18 | });
|
19 | }
|
20 | n.default = e;
|
21 | return Object.freeze(n);
|
22 | }
|
23 |
|
24 | var React__namespace = _interopNamespaceDefault(React);
|
25 |
|
26 | function _objectWithoutPropertiesLoose(source, excluded) {
|
27 | if (source == null) return {};
|
28 | var target = {};
|
29 | var sourceKeys = Object.keys(source);
|
30 | var key, i;
|
31 | for (i = 0; i < sourceKeys.length; i++) {
|
32 | key = sourceKeys[i];
|
33 | if (excluded.indexOf(key) >= 0) continue;
|
34 | target[key] = source[key];
|
35 | }
|
36 | return target;
|
37 | }
|
38 |
|
39 | function _extends() {
|
40 | _extends = Object.assign ? Object.assign.bind() : function (target) {
|
41 | for (var i = 1; i < arguments.length; i++) {
|
42 | var source = arguments[i];
|
43 | for (var key in source) {
|
44 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
45 | target[key] = source[key];
|
46 | }
|
47 | }
|
48 | }
|
49 | return target;
|
50 | };
|
51 | return _extends.apply(this, arguments);
|
52 | }
|
53 |
|
54 | var clamp = function clamp(num, lower, upper) {
|
55 | num = num <= upper ? num : upper;
|
56 | num = num >= lower ? num : lower;
|
57 | return num;
|
58 | };
|
59 |
|
60 | var createQueue = function createQueue() {
|
61 | var isRunning = false;
|
62 | var pending = [];
|
63 | var next = function next() {
|
64 | isRunning = true;
|
65 | var cb = pending.shift();
|
66 | if (cb) {
|
67 | return cb(next);
|
68 | }
|
69 | isRunning = false;
|
70 | };
|
71 | var clear = function clear() {
|
72 | isRunning = false;
|
73 | pending = [];
|
74 | };
|
75 | var enqueue = function enqueue(cb) {
|
76 | pending.push(cb);
|
77 | if (!isRunning && pending.length === 1) {
|
78 | next();
|
79 | }
|
80 | };
|
81 | return {
|
82 | clear: clear,
|
83 | enqueue: enqueue
|
84 | };
|
85 | };
|
86 |
|
87 | var createTimeout = function createTimeout() {
|
88 | var handle;
|
89 | var cancel = function cancel() {
|
90 | if (handle) {
|
91 | window.cancelAnimationFrame(handle);
|
92 | }
|
93 | };
|
94 | var schedule = function schedule(callback, delay) {
|
95 | var deltaTime;
|
96 | var start;
|
97 | var frame = function frame(time) {
|
98 | start = start || time;
|
99 | deltaTime = time - start;
|
100 | if (deltaTime > delay) {
|
101 | callback();
|
102 | return;
|
103 | }
|
104 | handle = window.requestAnimationFrame(frame);
|
105 | };
|
106 | handle = window.requestAnimationFrame(frame);
|
107 | };
|
108 | return {
|
109 | cancel: cancel,
|
110 | schedule: schedule
|
111 | };
|
112 | };
|
113 |
|
114 | var increment = function increment(progress) {
|
115 | var amount = 0;
|
116 | if (progress >= 0 && progress < 0.2) {
|
117 | amount = 0.1;
|
118 | } else if (progress >= 0.2 && progress < 0.5) {
|
119 | amount = 0.04;
|
120 | } else if (progress >= 0.5 && progress < 0.8) {
|
121 | amount = 0.02;
|
122 | } else if (progress >= 0.8 && progress < 0.99) {
|
123 | amount = 0.005;
|
124 | }
|
125 | return clamp(progress + amount, 0, 0.994);
|
126 | };
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 | var useEffectOnce = function useEffectOnce(effect) {
|
134 |
|
135 | React.useEffect(effect, []);
|
136 | };
|
137 |
|
138 | var incrementParameter = function incrementParameter(num) {
|
139 | return ++num % 1000000;
|
140 | };
|
141 | var useUpdate = function useUpdate() {
|
142 | var _useState = React.useState(0),
|
143 | setState = _useState[1];
|
144 | return React.useCallback(function () {
|
145 | return setState(incrementParameter);
|
146 | }, []);
|
147 | };
|
148 | var useGetSetState = function useGetSetState( /* istanbul ignore next */
|
149 | initialState) {
|
150 | if (initialState === void 0) {
|
151 | initialState = {};
|
152 | }
|
153 | var update = useUpdate();
|
154 | var state = React.useRef(_extends({}, initialState));
|
155 | var get = React.useCallback(function () {
|
156 | return state.current;
|
157 | }, []);
|
158 | var set = React.useCallback(function (patch) {
|
159 | if (!patch) {
|
160 | return;
|
161 | }
|
162 | Object.assign(state.current, patch);
|
163 | update();
|
164 |
|
165 | }, []);
|
166 | return [get, set];
|
167 | };
|
168 |
|
169 | // Hat-tip:
|
170 | // https://github.com/streamich/react-use/blob/master/src/useUpdateEffect.ts.
|
171 | //
|
172 | // `react-use` appears to be unmaintained, so moving the required code into
|
173 | // this project for now.
|
174 | var useFirstMountState = function useFirstMountState() {
|
175 | var isFirst = React.useRef(true);
|
176 | if (isFirst.current) {
|
177 | isFirst.current = false;
|
178 | return true;
|
179 | }
|
180 | return isFirst.current;
|
181 | };
|
182 | var useUpdateEffect = function useUpdateEffect(effect, deps) {
|
183 | var isFirstMount = useFirstMountState();
|
184 | React.useEffect(function () {
|
185 | if (!isFirstMount) {
|
186 | return effect();
|
187 | }
|
188 |
|
189 | }, deps);
|
190 | };
|
191 |
|
192 |
|
193 | var noop = function noop() {
|
194 | return undefined;
|
195 | };
|
196 | var initialState = {
|
197 | isFinished: true,
|
198 | progress: 0,
|
199 | sideEffect: noop
|
200 | };
|
201 | var useNProgress = function useNProgress(_temp) {
|
202 | var _ref = _temp === void 0 ? {} : _temp,
|
203 | _ref$animationDuratio = _ref.animationDuration,
|
204 | animationDuration = _ref$animationDuratio === void 0 ? 200 : _ref$animationDuratio,
|
205 | _ref$incrementDuratio = _ref.incrementDuration,
|
206 | incrementDuration = _ref$incrementDuratio === void 0 ? 800 : _ref$incrementDuratio,
|
207 | _ref$isAnimating = _ref.isAnimating,
|
208 | isAnimating = _ref$isAnimating === void 0 ? false : _ref$isAnimating,
|
209 | _ref$minimum = _ref.minimum,
|
210 | minimum = _ref$minimum === void 0 ? 0.08 : _ref$minimum;
|
211 | var _useGetSetState = useGetSetState(initialState),
|
212 | get = _useGetSetState[0],
|
213 | setState = _useGetSetState[1];
|
214 | var queue = React.useRef(null);
|
215 | var timeout = React.useRef(null);
|
216 | useEffectOnce(function () {
|
217 | queue.current = createQueue();
|
218 | timeout.current = createTimeout();
|
219 | });
|
220 | var cleanup = React.useCallback(function () {
|
221 | var _timeout$current, _queue$current;
|
222 | (_timeout$current = timeout.current) == null || _timeout$current.cancel();
|
223 | (_queue$current = queue.current) == null || _queue$current.clear();
|
224 | }, []);
|
225 | var set = React.useCallback(function (n) {
|
226 | var _queue$current4;
|
227 | n = clamp(n, minimum, 1);
|
228 | if (n === 1) {
|
229 | var _queue$current2, _queue$current3;
|
230 | cleanup();
|
231 | (_queue$current2 = queue.current) == null || _queue$current2.enqueue(function (next) {
|
232 | setState({
|
233 | progress: n,
|
234 | sideEffect: function sideEffect() {
|
235 | var _timeout$current2;
|
236 | return (_timeout$current2 = timeout.current) == null ? void 0 : _timeout$current2.schedule(next, animationDuration);
|
237 | }
|
238 | });
|
239 | });
|
240 | (_queue$current3 = queue.current) == null || _queue$current3.enqueue(function () {
|
241 | setState({
|
242 | isFinished: true,
|
243 | sideEffect: cleanup
|
244 | });
|
245 | });
|
246 | return;
|
247 | }
|
248 | (_queue$current4 = queue.current) == null || _queue$current4.enqueue(function (next) {
|
249 | setState({
|
250 | isFinished: false,
|
251 | progress: n,
|
252 | sideEffect: function sideEffect() {
|
253 | var _timeout$current3;
|
254 | return (_timeout$current3 = timeout.current) == null ? void 0 : _timeout$current3.schedule(next, animationDuration);
|
255 | }
|
256 | });
|
257 | });
|
258 | }, [animationDuration, cleanup, minimum, queue, setState, timeout]);
|
259 | var trickle = React.useCallback(function () {
|
260 | set(increment(get().progress));
|
261 | }, [get, set]);
|
262 | var start = React.useCallback(function () {
|
263 | var work = function work() {
|
264 | var _queue$current5;
|
265 | trickle();
|
266 | (_queue$current5 = queue.current) == null || _queue$current5.enqueue(function (next) {
|
267 | var _timeout$current4;
|
268 | (_timeout$current4 = timeout.current) == null || _timeout$current4.schedule(function () {
|
269 | work();
|
270 | next();
|
271 | }, incrementDuration);
|
272 | });
|
273 | };
|
274 | work();
|
275 | }, [incrementDuration, queue, timeout, trickle]);
|
276 | var savedTrickle = React.useRef(noop);
|
277 | var sideEffect = get().sideEffect;
|
278 | React.useEffect(function () {
|
279 | savedTrickle.current = trickle;
|
280 | });
|
281 | useEffectOnce(function () {
|
282 | if (isAnimating) {
|
283 | start();
|
284 | }
|
285 | return cleanup;
|
286 | });
|
287 | useUpdateEffect(function () {
|
288 | get().sideEffect();
|
289 | }, [get, sideEffect]);
|
290 | useUpdateEffect(function () {
|
291 | if (!isAnimating) {
|
292 | set(1);
|
293 | } else {
|
294 | setState(_extends({}, initialState, {
|
295 | sideEffect: start
|
296 | }));
|
297 | }
|
298 | }, [isAnimating, set, setState, start]);
|
299 | return {
|
300 | animationDuration: animationDuration,
|
301 | isFinished: get().isFinished,
|
302 | progress: get().progress
|
303 | };
|
304 | };
|
305 |
|
306 | var _excluded = ["children"];
|
307 | var NProgress = function NProgress(_ref) {
|
308 | var children = _ref.children,
|
309 | restProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
310 | var renderProps = useNProgress(restProps);
|
311 | return children(renderProps);
|
312 | };
|
313 |
|
314 | function getDefaultExportFromCjs (x) {
|
315 | return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
316 | }
|
317 |
|
318 | var reactIs$1 = {exports: {}};
|
319 |
|
320 | var reactIs_development = {};
|
321 |
|
322 | |
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 | var hasRequiredReactIs_development;
|
332 |
|
333 | function requireReactIs_development () {
|
334 | if (hasRequiredReactIs_development) return reactIs_development;
|
335 | hasRequiredReactIs_development = 1;
|
336 |
|
337 |
|
338 |
|
339 | {
|
340 | (function() {
|
341 |
|
342 |
|
343 |
|
344 | var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
345 | var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
346 | var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
347 | var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
348 | var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
349 | var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
350 | var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
351 | var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
352 |
|
353 |
|
354 | var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
355 | var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
356 | var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
357 | var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
358 | var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
|
359 | var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
360 | var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
361 | var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
|
362 | var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
363 | var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
364 | var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
365 |
|
366 | function isValidElementType(type) {
|
367 | return typeof type === 'string' || typeof type === 'function' ||
|
368 | 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);
|
369 | }
|
370 |
|
371 | function typeOf(object) {
|
372 | if (typeof object === 'object' && object !== null) {
|
373 | var $$typeof = object.$$typeof;
|
374 |
|
375 | switch ($$typeof) {
|
376 | case REACT_ELEMENT_TYPE:
|
377 | var type = object.type;
|
378 |
|
379 | switch (type) {
|
380 | case REACT_ASYNC_MODE_TYPE:
|
381 | case REACT_CONCURRENT_MODE_TYPE:
|
382 | case REACT_FRAGMENT_TYPE:
|
383 | case REACT_PROFILER_TYPE:
|
384 | case REACT_STRICT_MODE_TYPE:
|
385 | case REACT_SUSPENSE_TYPE:
|
386 | return type;
|
387 |
|
388 | default:
|
389 | var $$typeofType = type && type.$$typeof;
|
390 |
|
391 | switch ($$typeofType) {
|
392 | case REACT_CONTEXT_TYPE:
|
393 | case REACT_FORWARD_REF_TYPE:
|
394 | case REACT_LAZY_TYPE:
|
395 | case REACT_MEMO_TYPE:
|
396 | case REACT_PROVIDER_TYPE:
|
397 | return $$typeofType;
|
398 |
|
399 | default:
|
400 | return $$typeof;
|
401 | }
|
402 |
|
403 | }
|
404 |
|
405 | case REACT_PORTAL_TYPE:
|
406 | return $$typeof;
|
407 | }
|
408 | }
|
409 |
|
410 | return undefined;
|
411 | }
|
412 |
|
413 | var AsyncMode = REACT_ASYNC_MODE_TYPE;
|
414 | var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
|
415 | var ContextConsumer = REACT_CONTEXT_TYPE;
|
416 | var ContextProvider = REACT_PROVIDER_TYPE;
|
417 | var Element = REACT_ELEMENT_TYPE;
|
418 | var ForwardRef = REACT_FORWARD_REF_TYPE;
|
419 | var Fragment = REACT_FRAGMENT_TYPE;
|
420 | var Lazy = REACT_LAZY_TYPE;
|
421 | var Memo = REACT_MEMO_TYPE;
|
422 | var Portal = REACT_PORTAL_TYPE;
|
423 | var Profiler = REACT_PROFILER_TYPE;
|
424 | var StrictMode = REACT_STRICT_MODE_TYPE;
|
425 | var Suspense = REACT_SUSPENSE_TYPE;
|
426 | var hasWarnedAboutDeprecatedIsAsyncMode = false;
|
427 |
|
428 | function isAsyncMode(object) {
|
429 | {
|
430 | if (!hasWarnedAboutDeprecatedIsAsyncMode) {
|
431 | hasWarnedAboutDeprecatedIsAsyncMode = true;
|
432 |
|
433 | 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.');
|
434 | }
|
435 | }
|
436 |
|
437 | return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
|
438 | }
|
439 | function isConcurrentMode(object) {
|
440 | return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
|
441 | }
|
442 | function isContextConsumer(object) {
|
443 | return typeOf(object) === REACT_CONTEXT_TYPE;
|
444 | }
|
445 | function isContextProvider(object) {
|
446 | return typeOf(object) === REACT_PROVIDER_TYPE;
|
447 | }
|
448 | function isElement(object) {
|
449 | return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
450 | }
|
451 | function isForwardRef(object) {
|
452 | return typeOf(object) === REACT_FORWARD_REF_TYPE;
|
453 | }
|
454 | function isFragment(object) {
|
455 | return typeOf(object) === REACT_FRAGMENT_TYPE;
|
456 | }
|
457 | function isLazy(object) {
|
458 | return typeOf(object) === REACT_LAZY_TYPE;
|
459 | }
|
460 | function isMemo(object) {
|
461 | return typeOf(object) === REACT_MEMO_TYPE;
|
462 | }
|
463 | function isPortal(object) {
|
464 | return typeOf(object) === REACT_PORTAL_TYPE;
|
465 | }
|
466 | function isProfiler(object) {
|
467 | return typeOf(object) === REACT_PROFILER_TYPE;
|
468 | }
|
469 | function isStrictMode(object) {
|
470 | return typeOf(object) === REACT_STRICT_MODE_TYPE;
|
471 | }
|
472 | function isSuspense(object) {
|
473 | return typeOf(object) === REACT_SUSPENSE_TYPE;
|
474 | }
|
475 |
|
476 | reactIs_development.AsyncMode = AsyncMode;
|
477 | reactIs_development.ConcurrentMode = ConcurrentMode;
|
478 | reactIs_development.ContextConsumer = ContextConsumer;
|
479 | reactIs_development.ContextProvider = ContextProvider;
|
480 | reactIs_development.Element = Element;
|
481 | reactIs_development.ForwardRef = ForwardRef;
|
482 | reactIs_development.Fragment = Fragment;
|
483 | reactIs_development.Lazy = Lazy;
|
484 | reactIs_development.Memo = Memo;
|
485 | reactIs_development.Portal = Portal;
|
486 | reactIs_development.Profiler = Profiler;
|
487 | reactIs_development.StrictMode = StrictMode;
|
488 | reactIs_development.Suspense = Suspense;
|
489 | reactIs_development.isAsyncMode = isAsyncMode;
|
490 | reactIs_development.isConcurrentMode = isConcurrentMode;
|
491 | reactIs_development.isContextConsumer = isContextConsumer;
|
492 | reactIs_development.isContextProvider = isContextProvider;
|
493 | reactIs_development.isElement = isElement;
|
494 | reactIs_development.isForwardRef = isForwardRef;
|
495 | reactIs_development.isFragment = isFragment;
|
496 | reactIs_development.isLazy = isLazy;
|
497 | reactIs_development.isMemo = isMemo;
|
498 | reactIs_development.isPortal = isPortal;
|
499 | reactIs_development.isProfiler = isProfiler;
|
500 | reactIs_development.isStrictMode = isStrictMode;
|
501 | reactIs_development.isSuspense = isSuspense;
|
502 | reactIs_development.isValidElementType = isValidElementType;
|
503 | reactIs_development.typeOf = typeOf;
|
504 | })();
|
505 | }
|
506 | return reactIs_development;
|
507 | }
|
508 |
|
509 | {
|
510 | reactIs$1.exports = requireReactIs_development();
|
511 | }
|
512 |
|
513 | var reactIsExports = reactIs$1.exports;
|
514 |
|
515 | var reactIs = reactIsExports;
|
516 |
|
517 | |
518 |
|
519 |
|
520 |
|
521 | var REACT_STATICS = {
|
522 | childContextTypes: true,
|
523 | contextType: true,
|
524 | contextTypes: true,
|
525 | defaultProps: true,
|
526 | displayName: true,
|
527 | getDefaultProps: true,
|
528 | getDerivedStateFromError: true,
|
529 | getDerivedStateFromProps: true,
|
530 | mixins: true,
|
531 | propTypes: true,
|
532 | type: true
|
533 | };
|
534 | var KNOWN_STATICS = {
|
535 | name: true,
|
536 | length: true,
|
537 | prototype: true,
|
538 | caller: true,
|
539 | callee: true,
|
540 | arguments: true,
|
541 | arity: true
|
542 | };
|
543 | var FORWARD_REF_STATICS = {
|
544 | '$$typeof': true,
|
545 | render: true,
|
546 | defaultProps: true,
|
547 | displayName: true,
|
548 | propTypes: true
|
549 | };
|
550 | var MEMO_STATICS = {
|
551 | '$$typeof': true,
|
552 | compare: true,
|
553 | defaultProps: true,
|
554 | displayName: true,
|
555 | propTypes: true,
|
556 | type: true
|
557 | };
|
558 | var TYPE_STATICS = {};
|
559 | TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
|
560 | TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
|
561 |
|
562 | function getStatics(component) {
|
563 |
|
564 | if (reactIs.isMemo(component)) {
|
565 | return MEMO_STATICS;
|
566 | }
|
567 |
|
568 |
|
569 | return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
|
570 | }
|
571 |
|
572 | var defineProperty = Object.defineProperty;
|
573 | var getOwnPropertyNames = Object.getOwnPropertyNames;
|
574 | var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
575 | var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
576 | var getPrototypeOf = Object.getPrototypeOf;
|
577 | var objectPrototype = Object.prototype;
|
578 | function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
579 | if (typeof sourceComponent !== 'string') {
|
580 |
|
581 | if (objectPrototype) {
|
582 | var inheritedComponent = getPrototypeOf(sourceComponent);
|
583 |
|
584 | if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
585 | hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
586 | }
|
587 | }
|
588 |
|
589 | var keys = getOwnPropertyNames(sourceComponent);
|
590 |
|
591 | if (getOwnPropertySymbols) {
|
592 | keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
593 | }
|
594 |
|
595 | var targetStatics = getStatics(targetComponent);
|
596 | var sourceStatics = getStatics(sourceComponent);
|
597 |
|
598 | for (var i = 0; i < keys.length; ++i) {
|
599 | var key = keys[i];
|
600 |
|
601 | if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
602 | var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
603 |
|
604 | try {
|
605 |
|
606 | defineProperty(targetComponent, key, descriptor);
|
607 | } catch (e) {}
|
608 | }
|
609 | }
|
610 | }
|
611 |
|
612 | return targetComponent;
|
613 | }
|
614 |
|
615 | var hoistNonReactStatics_cjs = hoistNonReactStatics;
|
616 |
|
617 | var hoistNonReactStatics$1 = getDefaultExportFromCjs(hoistNonReactStatics_cjs);
|
618 |
|
619 | function withNProgress(BaseComponent) {
|
620 | var WithNProgress = function WithNProgress(props) {
|
621 | var hookProps = useNProgress(props);
|
622 | return React__namespace.createElement(BaseComponent, _extends({}, props, hookProps));
|
623 | };
|
624 | hoistNonReactStatics$1(WithNProgress, BaseComponent);
|
625 | return WithNProgress;
|
626 | }
|
627 |
|
628 | exports.NProgress = NProgress;
|
629 | exports.useNProgress = useNProgress;
|
630 | exports.withNProgress = withNProgress;
|
631 |
|
632 | }));
|
633 |
|