@bigbinary/neeto-commons-frontend 2.0.19 → 2.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/initializers.cjs.js +583 -10
- package/initializers.d.ts +3 -1
- package/initializers.js +583 -12
- package/package.json +1 -1
- package/react-utils.cjs.js +944 -371
- package/react-utils.js +946 -374
package/README.md
CHANGED
package/initializers.cjs.js
CHANGED
|
@@ -6,6 +6,7 @@ var neetoui = require('@bigbinary/neetoui');
|
|
|
6
6
|
var axios = require('axios');
|
|
7
7
|
var i18next = require('i18next');
|
|
8
8
|
var ramda = require('ramda');
|
|
9
|
+
var require$$0 = require('react');
|
|
9
10
|
var reactI18next = require('react-i18next');
|
|
10
11
|
var Logger = require('js-logger');
|
|
11
12
|
var mixpanel = require('mixpanel-browser');
|
|
@@ -14,6 +15,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
14
15
|
|
|
15
16
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
16
17
|
var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
|
|
18
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
17
19
|
var Logger__default = /*#__PURE__*/_interopDefaultLegacy(Logger);
|
|
18
20
|
var mixpanel__default = /*#__PURE__*/_interopDefaultLegacy(mixpanel);
|
|
19
21
|
|
|
@@ -228,6 +230,561 @@ var resetAuthTokens = function resetAuthTokens() {
|
|
|
228
230
|
});
|
|
229
231
|
};
|
|
230
232
|
|
|
233
|
+
const createStoreImpl = (createState) => {
|
|
234
|
+
let state;
|
|
235
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
236
|
+
const setState = (partial, replace) => {
|
|
237
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
238
|
+
if (!Object.is(nextState, state)) {
|
|
239
|
+
const previousState = state;
|
|
240
|
+
state = (replace != null ? replace : typeof nextState !== "object") ? nextState : Object.assign({}, state, nextState);
|
|
241
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
const getState = () => state;
|
|
245
|
+
const subscribe = (listener) => {
|
|
246
|
+
listeners.add(listener);
|
|
247
|
+
return () => listeners.delete(listener);
|
|
248
|
+
};
|
|
249
|
+
const destroy = () => listeners.clear();
|
|
250
|
+
const api = { setState, getState, subscribe, destroy };
|
|
251
|
+
state = createState(
|
|
252
|
+
setState,
|
|
253
|
+
getState,
|
|
254
|
+
api
|
|
255
|
+
);
|
|
256
|
+
return api;
|
|
257
|
+
};
|
|
258
|
+
const createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
259
|
+
|
|
260
|
+
function getDefaultExportFromCjs (x) {
|
|
261
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
var withSelector = {exports: {}};
|
|
265
|
+
|
|
266
|
+
var withSelector_production_min = {};
|
|
267
|
+
|
|
268
|
+
var shim = {exports: {}};
|
|
269
|
+
|
|
270
|
+
var useSyncExternalStoreShim_production_min = {};
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* @license React
|
|
274
|
+
* use-sync-external-store-shim.production.min.js
|
|
275
|
+
*
|
|
276
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
277
|
+
*
|
|
278
|
+
* This source code is licensed under the MIT license found in the
|
|
279
|
+
* LICENSE file in the root directory of this source tree.
|
|
280
|
+
*/
|
|
281
|
+
|
|
282
|
+
var hasRequiredUseSyncExternalStoreShim_production_min;
|
|
283
|
+
|
|
284
|
+
function requireUseSyncExternalStoreShim_production_min () {
|
|
285
|
+
if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
|
|
286
|
+
hasRequiredUseSyncExternalStoreShim_production_min = 1;
|
|
287
|
+
var e=require$$0__default["default"];function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c});},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c});})},[a]);p(d);return d}
|
|
288
|
+
function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f){return !0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;useSyncExternalStoreShim_production_min.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;
|
|
289
|
+
return useSyncExternalStoreShim_production_min;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
var useSyncExternalStoreShim_development = {};
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* @license React
|
|
296
|
+
* use-sync-external-store-shim.development.js
|
|
297
|
+
*
|
|
298
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
299
|
+
*
|
|
300
|
+
* This source code is licensed under the MIT license found in the
|
|
301
|
+
* LICENSE file in the root directory of this source tree.
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
var hasRequiredUseSyncExternalStoreShim_development;
|
|
305
|
+
|
|
306
|
+
function requireUseSyncExternalStoreShim_development () {
|
|
307
|
+
if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
|
|
308
|
+
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
309
|
+
|
|
310
|
+
if (process.env.NODE_ENV !== "production") {
|
|
311
|
+
(function() {
|
|
312
|
+
|
|
313
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
314
|
+
if (
|
|
315
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
316
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
317
|
+
'function'
|
|
318
|
+
) {
|
|
319
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
320
|
+
}
|
|
321
|
+
var React = require$$0__default["default"];
|
|
322
|
+
|
|
323
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
324
|
+
|
|
325
|
+
function error(format) {
|
|
326
|
+
{
|
|
327
|
+
{
|
|
328
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
329
|
+
args[_key2 - 1] = arguments[_key2];
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
printWarning('error', format, args);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function printWarning(level, format, args) {
|
|
338
|
+
// When changing this logic, you might want to also
|
|
339
|
+
// update consoleWithStackDev.www.js as well.
|
|
340
|
+
{
|
|
341
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
342
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
343
|
+
|
|
344
|
+
if (stack !== '') {
|
|
345
|
+
format += '%s';
|
|
346
|
+
args = args.concat([stack]);
|
|
347
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
var argsWithFormat = args.map(function (item) {
|
|
351
|
+
return String(item);
|
|
352
|
+
}); // Careful: RN currently depends on this prefix
|
|
353
|
+
|
|
354
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
355
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
356
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
|
357
|
+
|
|
358
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
364
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
365
|
+
*/
|
|
366
|
+
function is(x, y) {
|
|
367
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
368
|
+
;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
372
|
+
|
|
373
|
+
// dispatch for CommonJS interop named imports.
|
|
374
|
+
|
|
375
|
+
var useState = React.useState,
|
|
376
|
+
useEffect = React.useEffect,
|
|
377
|
+
useLayoutEffect = React.useLayoutEffect,
|
|
378
|
+
useDebugValue = React.useDebugValue;
|
|
379
|
+
var didWarnOld18Alpha = false;
|
|
380
|
+
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
|
|
381
|
+
// because of a very particular set of implementation details and assumptions
|
|
382
|
+
// -- change any one of them and it will break. The most important assumption
|
|
383
|
+
// is that updates are always synchronous, because concurrent rendering is
|
|
384
|
+
// only available in versions of React that also have a built-in
|
|
385
|
+
// useSyncExternalStore API. And we only use this shim when the built-in API
|
|
386
|
+
// does not exist.
|
|
387
|
+
//
|
|
388
|
+
// Do not assume that the clever hacks used by this hook also work in general.
|
|
389
|
+
// The point of this shim is to replace the need for hacks by other libraries.
|
|
390
|
+
|
|
391
|
+
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
392
|
+
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
393
|
+
// will need to track that themselves and return the correct value
|
|
394
|
+
// from `getSnapshot`.
|
|
395
|
+
getServerSnapshot) {
|
|
396
|
+
{
|
|
397
|
+
if (!didWarnOld18Alpha) {
|
|
398
|
+
if (React.startTransition !== undefined) {
|
|
399
|
+
didWarnOld18Alpha = true;
|
|
400
|
+
|
|
401
|
+
error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
} // Read the current snapshot from the store on every render. Again, this
|
|
405
|
+
// breaks the rules of React, and only works here because of specific
|
|
406
|
+
// implementation details, most importantly that updates are
|
|
407
|
+
// always synchronous.
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
var value = getSnapshot();
|
|
411
|
+
|
|
412
|
+
{
|
|
413
|
+
if (!didWarnUncachedGetSnapshot) {
|
|
414
|
+
var cachedValue = getSnapshot();
|
|
415
|
+
|
|
416
|
+
if (!objectIs(value, cachedValue)) {
|
|
417
|
+
error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
418
|
+
|
|
419
|
+
didWarnUncachedGetSnapshot = true;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
} // Because updates are synchronous, we don't queue them. Instead we force a
|
|
423
|
+
// re-render whenever the subscribed state changes by updating an some
|
|
424
|
+
// arbitrary useState hook. Then, during render, we call getSnapshot to read
|
|
425
|
+
// the current value.
|
|
426
|
+
//
|
|
427
|
+
// Because we don't actually use the state returned by the useState hook, we
|
|
428
|
+
// can save a bit of memory by storing other stuff in that slot.
|
|
429
|
+
//
|
|
430
|
+
// To implement the early bailout, we need to track some things on a mutable
|
|
431
|
+
// object. Usually, we would put that in a useRef hook, but we can stash it in
|
|
432
|
+
// our useState hook instead.
|
|
433
|
+
//
|
|
434
|
+
// To force a re-render, we call forceUpdate({inst}). That works because the
|
|
435
|
+
// new object always fails an equality check.
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
var _useState = useState({
|
|
439
|
+
inst: {
|
|
440
|
+
value: value,
|
|
441
|
+
getSnapshot: getSnapshot
|
|
442
|
+
}
|
|
443
|
+
}),
|
|
444
|
+
inst = _useState[0].inst,
|
|
445
|
+
forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
|
|
446
|
+
// in the layout phase so we can access it during the tearing check that
|
|
447
|
+
// happens on subscribe.
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
useLayoutEffect(function () {
|
|
451
|
+
inst.value = value;
|
|
452
|
+
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
|
|
453
|
+
// commit phase if there was an interleaved mutation. In concurrent mode
|
|
454
|
+
// this can happen all the time, but even in synchronous mode, an earlier
|
|
455
|
+
// effect may have mutated the store.
|
|
456
|
+
|
|
457
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
458
|
+
// Force a re-render.
|
|
459
|
+
forceUpdate({
|
|
460
|
+
inst: inst
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}, [subscribe, value, getSnapshot]);
|
|
464
|
+
useEffect(function () {
|
|
465
|
+
// Check for changes right before subscribing. Subsequent changes will be
|
|
466
|
+
// detected in the subscription handler.
|
|
467
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
468
|
+
// Force a re-render.
|
|
469
|
+
forceUpdate({
|
|
470
|
+
inst: inst
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
var handleStoreChange = function () {
|
|
475
|
+
// TODO: Because there is no cross-renderer API for batching updates, it's
|
|
476
|
+
// up to the consumer of this library to wrap their subscription event
|
|
477
|
+
// with unstable_batchedUpdates. Should we try to detect when this isn't
|
|
478
|
+
// the case and print a warning in development?
|
|
479
|
+
// The store changed. Check if the snapshot changed since the last time we
|
|
480
|
+
// read from the store.
|
|
481
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
482
|
+
// Force a re-render.
|
|
483
|
+
forceUpdate({
|
|
484
|
+
inst: inst
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
}; // Subscribe to the store and return a clean-up function.
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
return subscribe(handleStoreChange);
|
|
491
|
+
}, [subscribe]);
|
|
492
|
+
useDebugValue(value);
|
|
493
|
+
return value;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
function checkIfSnapshotChanged(inst) {
|
|
497
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
498
|
+
var prevValue = inst.value;
|
|
499
|
+
|
|
500
|
+
try {
|
|
501
|
+
var nextValue = latestGetSnapshot();
|
|
502
|
+
return !objectIs(prevValue, nextValue);
|
|
503
|
+
} catch (error) {
|
|
504
|
+
return true;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
|
|
509
|
+
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
510
|
+
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
511
|
+
// will need to track that themselves and return the correct value
|
|
512
|
+
// from `getSnapshot`.
|
|
513
|
+
return getSnapshot();
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
|
|
517
|
+
|
|
518
|
+
var isServerEnvironment = !canUseDOM;
|
|
519
|
+
|
|
520
|
+
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
521
|
+
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
|
|
522
|
+
|
|
523
|
+
useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
|
|
524
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
525
|
+
if (
|
|
526
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
527
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
528
|
+
'function'
|
|
529
|
+
) {
|
|
530
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
})();
|
|
534
|
+
}
|
|
535
|
+
return useSyncExternalStoreShim_development;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
var hasRequiredShim;
|
|
539
|
+
|
|
540
|
+
function requireShim () {
|
|
541
|
+
if (hasRequiredShim) return shim.exports;
|
|
542
|
+
hasRequiredShim = 1;
|
|
543
|
+
(function (module) {
|
|
544
|
+
|
|
545
|
+
if (process.env.NODE_ENV === 'production') {
|
|
546
|
+
module.exports = requireUseSyncExternalStoreShim_production_min();
|
|
547
|
+
} else {
|
|
548
|
+
module.exports = requireUseSyncExternalStoreShim_development();
|
|
549
|
+
}
|
|
550
|
+
} (shim));
|
|
551
|
+
return shim.exports;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* @license React
|
|
556
|
+
* use-sync-external-store-shim/with-selector.production.min.js
|
|
557
|
+
*
|
|
558
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
559
|
+
*
|
|
560
|
+
* This source code is licensed under the MIT license found in the
|
|
561
|
+
* LICENSE file in the root directory of this source tree.
|
|
562
|
+
*/
|
|
563
|
+
|
|
564
|
+
var hasRequiredWithSelector_production_min;
|
|
565
|
+
|
|
566
|
+
function requireWithSelector_production_min () {
|
|
567
|
+
if (hasRequiredWithSelector_production_min) return withSelector_production_min;
|
|
568
|
+
hasRequiredWithSelector_production_min = 1;
|
|
569
|
+
var h=require$$0__default["default"],n=requireShim();function p(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var q="function"===typeof Object.is?Object.is:p,r=n.useSyncExternalStore,t=h.useRef,u=h.useEffect,v=h.useMemo,w=h.useDebugValue;
|
|
570
|
+
withSelector_production_min.useSyncExternalStoreWithSelector=function(a,b,e,l,g){var c=t(null);if(null===c.current){var f={hasValue:!1,value:null};c.current=f;}else f=c.current;c=v(function(){function a(a){if(!c){c=!0;d=a;a=l(a);if(void 0!==g&&f.hasValue){var b=f.value;if(g(b,a))return k=b}return k=a}b=k;if(q(d,a))return b;var e=l(a);if(void 0!==g&&g(b,e))return b;d=a;return k=e}var c=!1,d,k,m=void 0===e?null:e;return [function(){return a(b())},null===m?void 0:function(){return a(m())}]},[b,e,l,g]);var d=r(a,c[0],c[1]);
|
|
571
|
+
u(function(){f.hasValue=!0;f.value=d;},[d]);w(d);return d};
|
|
572
|
+
return withSelector_production_min;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
var withSelector_development = {};
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* @license React
|
|
579
|
+
* use-sync-external-store-shim/with-selector.development.js
|
|
580
|
+
*
|
|
581
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
582
|
+
*
|
|
583
|
+
* This source code is licensed under the MIT license found in the
|
|
584
|
+
* LICENSE file in the root directory of this source tree.
|
|
585
|
+
*/
|
|
586
|
+
|
|
587
|
+
var hasRequiredWithSelector_development;
|
|
588
|
+
|
|
589
|
+
function requireWithSelector_development () {
|
|
590
|
+
if (hasRequiredWithSelector_development) return withSelector_development;
|
|
591
|
+
hasRequiredWithSelector_development = 1;
|
|
592
|
+
|
|
593
|
+
if (process.env.NODE_ENV !== "production") {
|
|
594
|
+
(function() {
|
|
595
|
+
|
|
596
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
597
|
+
if (
|
|
598
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
599
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
600
|
+
'function'
|
|
601
|
+
) {
|
|
602
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
603
|
+
}
|
|
604
|
+
var React = require$$0__default["default"];
|
|
605
|
+
var shim = requireShim();
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
609
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
610
|
+
*/
|
|
611
|
+
function is(x, y) {
|
|
612
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
613
|
+
;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
617
|
+
|
|
618
|
+
var useSyncExternalStore = shim.useSyncExternalStore;
|
|
619
|
+
|
|
620
|
+
// for CommonJS interop.
|
|
621
|
+
|
|
622
|
+
var useRef = React.useRef,
|
|
623
|
+
useEffect = React.useEffect,
|
|
624
|
+
useMemo = React.useMemo,
|
|
625
|
+
useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
|
|
626
|
+
|
|
627
|
+
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
628
|
+
// Use this to track the rendered snapshot.
|
|
629
|
+
var instRef = useRef(null);
|
|
630
|
+
var inst;
|
|
631
|
+
|
|
632
|
+
if (instRef.current === null) {
|
|
633
|
+
inst = {
|
|
634
|
+
hasValue: false,
|
|
635
|
+
value: null
|
|
636
|
+
};
|
|
637
|
+
instRef.current = inst;
|
|
638
|
+
} else {
|
|
639
|
+
inst = instRef.current;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
var _useMemo = useMemo(function () {
|
|
643
|
+
// Track the memoized state using closure variables that are local to this
|
|
644
|
+
// memoized instance of a getSnapshot function. Intentionally not using a
|
|
645
|
+
// useRef hook, because that state would be shared across all concurrent
|
|
646
|
+
// copies of the hook/component.
|
|
647
|
+
var hasMemo = false;
|
|
648
|
+
var memoizedSnapshot;
|
|
649
|
+
var memoizedSelection;
|
|
650
|
+
|
|
651
|
+
var memoizedSelector = function (nextSnapshot) {
|
|
652
|
+
if (!hasMemo) {
|
|
653
|
+
// The first time the hook is called, there is no memoized result.
|
|
654
|
+
hasMemo = true;
|
|
655
|
+
memoizedSnapshot = nextSnapshot;
|
|
656
|
+
|
|
657
|
+
var _nextSelection = selector(nextSnapshot);
|
|
658
|
+
|
|
659
|
+
if (isEqual !== undefined) {
|
|
660
|
+
// Even if the selector has changed, the currently rendered selection
|
|
661
|
+
// may be equal to the new selection. We should attempt to reuse the
|
|
662
|
+
// current value if possible, to preserve downstream memoizations.
|
|
663
|
+
if (inst.hasValue) {
|
|
664
|
+
var currentSelection = inst.value;
|
|
665
|
+
|
|
666
|
+
if (isEqual(currentSelection, _nextSelection)) {
|
|
667
|
+
memoizedSelection = currentSelection;
|
|
668
|
+
return currentSelection;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
memoizedSelection = _nextSelection;
|
|
674
|
+
return _nextSelection;
|
|
675
|
+
} // We may be able to reuse the previous invocation's result.
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
// We may be able to reuse the previous invocation's result.
|
|
679
|
+
var prevSnapshot = memoizedSnapshot;
|
|
680
|
+
var prevSelection = memoizedSelection;
|
|
681
|
+
|
|
682
|
+
if (objectIs(prevSnapshot, nextSnapshot)) {
|
|
683
|
+
// The snapshot is the same as last time. Reuse the previous selection.
|
|
684
|
+
return prevSelection;
|
|
685
|
+
} // The snapshot has changed, so we need to compute a new selection.
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
// The snapshot has changed, so we need to compute a new selection.
|
|
689
|
+
var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
|
|
690
|
+
// has changed. If it hasn't, return the previous selection. That signals
|
|
691
|
+
// to React that the selections are conceptually equal, and we can bail
|
|
692
|
+
// out of rendering.
|
|
693
|
+
|
|
694
|
+
// If a custom isEqual function is provided, use that to check if the data
|
|
695
|
+
// has changed. If it hasn't, return the previous selection. That signals
|
|
696
|
+
// to React that the selections are conceptually equal, and we can bail
|
|
697
|
+
// out of rendering.
|
|
698
|
+
if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
|
|
699
|
+
return prevSelection;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
memoizedSnapshot = nextSnapshot;
|
|
703
|
+
memoizedSelection = nextSelection;
|
|
704
|
+
return nextSelection;
|
|
705
|
+
}; // Assigning this to a constant so that Flow knows it can't change.
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
// Assigning this to a constant so that Flow knows it can't change.
|
|
709
|
+
var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
|
|
710
|
+
|
|
711
|
+
var getSnapshotWithSelector = function () {
|
|
712
|
+
return memoizedSelector(getSnapshot());
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
|
|
716
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
717
|
+
};
|
|
718
|
+
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
719
|
+
}, [getSnapshot, getServerSnapshot, selector, isEqual]),
|
|
720
|
+
getSelection = _useMemo[0],
|
|
721
|
+
getServerSelection = _useMemo[1];
|
|
722
|
+
|
|
723
|
+
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
724
|
+
useEffect(function () {
|
|
725
|
+
inst.hasValue = true;
|
|
726
|
+
inst.value = value;
|
|
727
|
+
}, [value]);
|
|
728
|
+
useDebugValue(value);
|
|
729
|
+
return value;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
|
|
733
|
+
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
734
|
+
if (
|
|
735
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
736
|
+
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
737
|
+
'function'
|
|
738
|
+
) {
|
|
739
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
})();
|
|
743
|
+
}
|
|
744
|
+
return withSelector_development;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
(function (module) {
|
|
748
|
+
|
|
749
|
+
if (process.env.NODE_ENV === 'production') {
|
|
750
|
+
module.exports = requireWithSelector_production_min();
|
|
751
|
+
} else {
|
|
752
|
+
module.exports = requireWithSelector_development();
|
|
753
|
+
}
|
|
754
|
+
} (withSelector));
|
|
755
|
+
|
|
756
|
+
var useSyncExternalStoreExports = /*@__PURE__*/getDefaultExportFromCjs(withSelector.exports);
|
|
757
|
+
|
|
758
|
+
const { useSyncExternalStoreWithSelector } = useSyncExternalStoreExports;
|
|
759
|
+
function useStore(api, selector = api.getState, equalityFn) {
|
|
760
|
+
const slice = useSyncExternalStoreWithSelector(
|
|
761
|
+
api.subscribe,
|
|
762
|
+
api.getState,
|
|
763
|
+
api.getServerState || api.getState,
|
|
764
|
+
selector,
|
|
765
|
+
equalityFn
|
|
766
|
+
);
|
|
767
|
+
require$$0.useDebugValue(slice);
|
|
768
|
+
return slice;
|
|
769
|
+
}
|
|
770
|
+
const createImpl = (createState) => {
|
|
771
|
+
const api = typeof createState === "function" ? createStore(createState) : createState;
|
|
772
|
+
const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn);
|
|
773
|
+
Object.assign(useBoundStore, api);
|
|
774
|
+
return useBoundStore;
|
|
775
|
+
};
|
|
776
|
+
const create = (createState) => createState ? createImpl(createState) : createImpl;
|
|
777
|
+
|
|
778
|
+
var useDisplayErrorPage = function useDisplayErrorPage() {
|
|
779
|
+
return useErrorDisplayStore(ramda.prop("show404Page"));
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
var useErrorDisplayStore = create(function () {
|
|
783
|
+
return {
|
|
784
|
+
show404Page: false
|
|
785
|
+
};
|
|
786
|
+
});
|
|
787
|
+
|
|
231
788
|
var shouldNot = function shouldNot(skip) {
|
|
232
789
|
return _typeof(skip) === "object" || !skip;
|
|
233
790
|
};
|
|
@@ -255,7 +812,7 @@ var createPipe = function createPipe(functions) {
|
|
|
255
812
|
};
|
|
256
813
|
};
|
|
257
814
|
|
|
258
|
-
var
|
|
815
|
+
var transformResponseKeysToCamelCase = function transformResponseKeysToCamelCase(response) {
|
|
259
816
|
var _response$config$tran = response.config.transformResponseCase,
|
|
260
817
|
transformResponseCase = _response$config$tran === void 0 ? true : _response$config$tran;
|
|
261
818
|
|
|
@@ -266,6 +823,17 @@ var transformKeysToCamelCase = function transformKeysToCamelCase(response) {
|
|
|
266
823
|
return response;
|
|
267
824
|
};
|
|
268
825
|
|
|
826
|
+
var transformErrorKeysToCamelCase = function transformErrorKeysToCamelCase(error) {
|
|
827
|
+
var _error$config$transfo = error.config.transformResponseCase,
|
|
828
|
+
transformResponseCase = _error$config$transfo === void 0 ? true : _error$config$transfo;
|
|
829
|
+
|
|
830
|
+
if (error.response.data && transformResponseCase) {
|
|
831
|
+
error.response.data = keysToCamelCase(error.response.data);
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
return error;
|
|
835
|
+
};
|
|
836
|
+
|
|
269
837
|
var showSuccessToastr = function showSuccessToastr(response) {
|
|
270
838
|
var _response$config$show = response.config.showToastr,
|
|
271
839
|
showToastr = _response$config$show === void 0 ? true : _response$config$show;
|
|
@@ -285,7 +853,7 @@ var pullDataFromResponse = function pullDataFromResponse(response) {
|
|
|
285
853
|
|
|
286
854
|
var buildSuccessResponseHandler = function buildSuccessResponseHandler(skip) {
|
|
287
855
|
var interceptors = [];
|
|
288
|
-
if (!(skip !== null && skip !== void 0 && skip.transformCase)) interceptors.push(
|
|
856
|
+
if (!(skip !== null && skip !== void 0 && skip.transformCase)) interceptors.push(transformResponseKeysToCamelCase);
|
|
289
857
|
if (!(skip !== null && skip !== void 0 && skip.showToastr)) interceptors.push(showSuccessToastr);
|
|
290
858
|
if (!(skip !== null && skip !== void 0 && skip.pullDataFromResponse)) interceptors.push(pullDataFromResponse);
|
|
291
859
|
return createPipe(interceptors);
|
|
@@ -325,14 +893,17 @@ var showErrorToastr = function showErrorToastr(error) {
|
|
|
325
893
|
return error;
|
|
326
894
|
};
|
|
327
895
|
|
|
328
|
-
var
|
|
896
|
+
var handle404ErrorResponse = function handle404ErrorResponse(error) {
|
|
329
897
|
var _error$response2;
|
|
330
898
|
|
|
331
|
-
|
|
332
|
-
|
|
899
|
+
if (((_error$response2 = error.response) === null || _error$response2 === void 0 ? void 0 : _error$response2.status) !== 404) return error;
|
|
900
|
+
var _error$config$show = error.config.show404ErrorPage,
|
|
901
|
+
show404ErrorPage = _error$config$show === void 0 ? true : _error$config$show;
|
|
333
902
|
|
|
334
|
-
if (
|
|
335
|
-
|
|
903
|
+
if (show404ErrorPage) {
|
|
904
|
+
useErrorDisplayStore.setState({
|
|
905
|
+
show404Page: true
|
|
906
|
+
});
|
|
336
907
|
}
|
|
337
908
|
|
|
338
909
|
return error;
|
|
@@ -340,7 +911,8 @@ var redirect404 = function redirect404(error) {
|
|
|
340
911
|
|
|
341
912
|
var buildErrorResponseHandler = function buildErrorResponseHandler(skip) {
|
|
342
913
|
var interceptors = [];
|
|
343
|
-
if (!(skip !== null && skip !== void 0 && skip.
|
|
914
|
+
if (!(skip !== null && skip !== void 0 && skip.transformCase)) interceptors.push(transformErrorKeysToCamelCase);
|
|
915
|
+
if (!(skip !== null && skip !== void 0 && skip.show404ErrorPage)) interceptors.push(handle404ErrorResponse);
|
|
344
916
|
if (!(skip !== null && skip !== void 0 && skip.logoutOn401)) interceptors.push(handleUnauthorizedErrorResponse);
|
|
345
917
|
if (!(skip !== null && skip !== void 0 && skip.showToastr)) interceptors.push(showErrorToastr);
|
|
346
918
|
interceptors.push(Promise.reject.bind(Promise));
|
|
@@ -405,8 +977,8 @@ var neetoCommons = {
|
|
|
405
977
|
reload: "Reload"
|
|
406
978
|
},
|
|
407
979
|
sidebar: {
|
|
408
|
-
myProfile: "My
|
|
409
|
-
myOrganization: "My
|
|
980
|
+
myProfile: "My profile",
|
|
981
|
+
myOrganization: "My organization",
|
|
410
982
|
logout: "Logout",
|
|
411
983
|
help: "Help"
|
|
412
984
|
},
|
|
@@ -604,3 +1176,4 @@ function initializeApplication(_ref) {
|
|
|
604
1176
|
}
|
|
605
1177
|
|
|
606
1178
|
exports["default"] = initializeApplication;
|
|
1179
|
+
exports.useDisplayErrorPage = useDisplayErrorPage;
|
package/initializers.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ type Configurations = {
|
|
|
19
19
|
transformCase: boolean;
|
|
20
20
|
showToastr: boolean;
|
|
21
21
|
pullDataFromResponse: boolean;
|
|
22
|
-
|
|
22
|
+
show404ErrorPage: boolean;
|
|
23
23
|
logoutOn401: boolean;
|
|
24
24
|
}>;
|
|
25
25
|
}>;
|
|
@@ -58,3 +58,5 @@ export default function initializeApplication(
|
|
|
58
58
|
): void;
|
|
59
59
|
|
|
60
60
|
export const globalProps: GlobalPropsType;
|
|
61
|
+
|
|
62
|
+
export function useDisplayErrorPage(): Boolean;
|