@bigbinary/neeto-commons-frontend 2.0.106 → 2.0.108

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/initializers.js CHANGED
@@ -10,34 +10,34 @@ import { initReactI18next } from 'react-i18next';
10
10
  import Logger from 'js-logger';
11
11
  import mixpanel from 'mixpanel-browser';
12
12
 
13
- function _typeof(obj) {
13
+ function _typeof$1(obj) {
14
14
  "@babel/helpers - typeof";
15
15
 
16
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
16
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
17
17
  return typeof obj;
18
18
  } : function (obj) {
19
19
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
20
- }, _typeof(obj);
20
+ }, _typeof$1(obj);
21
21
  }
22
22
 
23
- function _toPrimitive(input, hint) {
24
- if (_typeof(input) !== "object" || input === null) return input;
23
+ function _toPrimitive$1(input, hint) {
24
+ if (_typeof$1(input) !== "object" || input === null) return input;
25
25
  var prim = input[Symbol.toPrimitive];
26
26
  if (prim !== undefined) {
27
27
  var res = prim.call(input, hint || "default");
28
- if (_typeof(res) !== "object") return res;
28
+ if (_typeof$1(res) !== "object") return res;
29
29
  throw new TypeError("@@toPrimitive must return a primitive value.");
30
30
  }
31
31
  return (hint === "string" ? String : Number)(input);
32
32
  }
33
33
 
34
- function _toPropertyKey(arg) {
35
- var key = _toPrimitive(arg, "string");
36
- return _typeof(key) === "symbol" ? key : String(key);
34
+ function _toPropertyKey$1(arg) {
35
+ var key = _toPrimitive$1(arg, "string");
36
+ return _typeof$1(key) === "symbol" ? key : String(key);
37
37
  }
38
38
 
39
39
  function _defineProperty(obj, key, value) {
40
- key = _toPropertyKey(key);
40
+ key = _toPropertyKey$1(key);
41
41
  if (key in obj) {
42
42
  Object.defineProperty(obj, key, {
43
43
  value: value,
@@ -60,10 +60,10 @@ var HEADERS_KEYS = {
60
60
  };
61
61
 
62
62
  var shouldNot = function shouldNot(skip) {
63
- return _typeof(skip) === "object" || !skip;
63
+ return _typeof$1(skip) === "object" || !skip;
64
64
  };
65
65
  var shouldShowToastr = function shouldShowToastr(response) {
66
- return typeof response === "string" || _typeof(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
66
+ return typeof response === "string" || _typeof$1(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
67
67
  };
68
68
  var setAuthHeaders = function setAuthHeaders() {
69
69
  var _document$querySelect, _axios$defaults$heade, _globalProps$user, _globalProps$user2;
@@ -1863,6 +1863,419 @@ function createDOMPurify() {
1863
1863
 
1864
1864
  var purify = createDOMPurify();
1865
1865
 
1866
+ function _classCallCheck(instance, Constructor) {
1867
+ if (!(instance instanceof Constructor)) {
1868
+ throw new TypeError("Cannot call a class as a function");
1869
+ }
1870
+ }
1871
+
1872
+ function _typeof(obj) {
1873
+ "@babel/helpers - typeof";
1874
+
1875
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
1876
+ return typeof obj;
1877
+ } : function (obj) {
1878
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1879
+ }, _typeof(obj);
1880
+ }
1881
+
1882
+ function _toPrimitive(input, hint) {
1883
+ if (_typeof(input) !== "object" || input === null) return input;
1884
+ var prim = input[Symbol.toPrimitive];
1885
+ if (prim !== undefined) {
1886
+ var res = prim.call(input, hint || "default");
1887
+ if (_typeof(res) !== "object") return res;
1888
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1889
+ }
1890
+ return (hint === "string" ? String : Number)(input);
1891
+ }
1892
+
1893
+ function _toPropertyKey(arg) {
1894
+ var key = _toPrimitive(arg, "string");
1895
+ return _typeof(key) === "symbol" ? key : String(key);
1896
+ }
1897
+
1898
+ function _defineProperties(target, props) {
1899
+ for (var i = 0; i < props.length; i++) {
1900
+ var descriptor = props[i];
1901
+ descriptor.enumerable = descriptor.enumerable || false;
1902
+ descriptor.configurable = true;
1903
+ if ("value" in descriptor) descriptor.writable = true;
1904
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
1905
+ }
1906
+ }
1907
+ function _createClass(Constructor, protoProps, staticProps) {
1908
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
1909
+ if (staticProps) _defineProperties(Constructor, staticProps);
1910
+ Object.defineProperty(Constructor, "prototype", {
1911
+ writable: false
1912
+ });
1913
+ return Constructor;
1914
+ }
1915
+
1916
+ var arr = [];
1917
+ var each = arr.forEach;
1918
+ var slice = arr.slice;
1919
+ function defaults(obj) {
1920
+ each.call(slice.call(arguments, 1), function (source) {
1921
+ if (source) {
1922
+ for (var prop in source) {
1923
+ if (obj[prop] === undefined) obj[prop] = source[prop];
1924
+ }
1925
+ }
1926
+ });
1927
+ return obj;
1928
+ }
1929
+
1930
+ // eslint-disable-next-line no-control-regex
1931
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
1932
+ var serializeCookie = function serializeCookie(name, val, options) {
1933
+ var opt = options || {};
1934
+ opt.path = opt.path || '/';
1935
+ var value = encodeURIComponent(val);
1936
+ var str = "".concat(name, "=").concat(value);
1937
+ if (opt.maxAge > 0) {
1938
+ var maxAge = opt.maxAge - 0;
1939
+ if (Number.isNaN(maxAge)) throw new Error('maxAge should be a Number');
1940
+ str += "; Max-Age=".concat(Math.floor(maxAge));
1941
+ }
1942
+ if (opt.domain) {
1943
+ if (!fieldContentRegExp.test(opt.domain)) {
1944
+ throw new TypeError('option domain is invalid');
1945
+ }
1946
+ str += "; Domain=".concat(opt.domain);
1947
+ }
1948
+ if (opt.path) {
1949
+ if (!fieldContentRegExp.test(opt.path)) {
1950
+ throw new TypeError('option path is invalid');
1951
+ }
1952
+ str += "; Path=".concat(opt.path);
1953
+ }
1954
+ if (opt.expires) {
1955
+ if (typeof opt.expires.toUTCString !== 'function') {
1956
+ throw new TypeError('option expires is invalid');
1957
+ }
1958
+ str += "; Expires=".concat(opt.expires.toUTCString());
1959
+ }
1960
+ if (opt.httpOnly) str += '; HttpOnly';
1961
+ if (opt.secure) str += '; Secure';
1962
+ if (opt.sameSite) {
1963
+ var sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;
1964
+ switch (sameSite) {
1965
+ case true:
1966
+ str += '; SameSite=Strict';
1967
+ break;
1968
+ case 'lax':
1969
+ str += '; SameSite=Lax';
1970
+ break;
1971
+ case 'strict':
1972
+ str += '; SameSite=Strict';
1973
+ break;
1974
+ case 'none':
1975
+ str += '; SameSite=None';
1976
+ break;
1977
+ default:
1978
+ throw new TypeError('option sameSite is invalid');
1979
+ }
1980
+ }
1981
+ return str;
1982
+ };
1983
+ var cookie = {
1984
+ create: function create(name, value, minutes, domain) {
1985
+ var cookieOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
1986
+ path: '/',
1987
+ sameSite: 'strict'
1988
+ };
1989
+ if (minutes) {
1990
+ cookieOptions.expires = new Date();
1991
+ cookieOptions.expires.setTime(cookieOptions.expires.getTime() + minutes * 60 * 1000);
1992
+ }
1993
+ if (domain) cookieOptions.domain = domain;
1994
+ document.cookie = serializeCookie(name, encodeURIComponent(value), cookieOptions);
1995
+ },
1996
+ read: function read(name) {
1997
+ var nameEQ = "".concat(name, "=");
1998
+ var ca = document.cookie.split(';');
1999
+ for (var i = 0; i < ca.length; i++) {
2000
+ var c = ca[i];
2001
+ while (c.charAt(0) === ' ') {
2002
+ c = c.substring(1, c.length);
2003
+ }
2004
+ if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
2005
+ }
2006
+ return null;
2007
+ },
2008
+ remove: function remove(name) {
2009
+ this.create(name, '', -1);
2010
+ }
2011
+ };
2012
+ var cookie$1 = {
2013
+ name: 'cookie',
2014
+ lookup: function lookup(options) {
2015
+ var found;
2016
+ if (options.lookupCookie && typeof document !== 'undefined') {
2017
+ var c = cookie.read(options.lookupCookie);
2018
+ if (c) found = c;
2019
+ }
2020
+ return found;
2021
+ },
2022
+ cacheUserLanguage: function cacheUserLanguage(lng, options) {
2023
+ if (options.lookupCookie && typeof document !== 'undefined') {
2024
+ cookie.create(options.lookupCookie, lng, options.cookieMinutes, options.cookieDomain, options.cookieOptions);
2025
+ }
2026
+ }
2027
+ };
2028
+
2029
+ var querystring = {
2030
+ name: 'querystring',
2031
+ lookup: function lookup(options) {
2032
+ var found;
2033
+ if (typeof window !== 'undefined') {
2034
+ var search = window.location.search;
2035
+ if (!window.location.search && window.location.hash && window.location.hash.indexOf('?') > -1) {
2036
+ search = window.location.hash.substring(window.location.hash.indexOf('?'));
2037
+ }
2038
+ var query = search.substring(1);
2039
+ var params = query.split('&');
2040
+ for (var i = 0; i < params.length; i++) {
2041
+ var pos = params[i].indexOf('=');
2042
+ if (pos > 0) {
2043
+ var key = params[i].substring(0, pos);
2044
+ if (key === options.lookupQuerystring) {
2045
+ found = params[i].substring(pos + 1);
2046
+ }
2047
+ }
2048
+ }
2049
+ }
2050
+ return found;
2051
+ }
2052
+ };
2053
+
2054
+ var hasLocalStorageSupport = null;
2055
+ var localStorageAvailable = function localStorageAvailable() {
2056
+ if (hasLocalStorageSupport !== null) return hasLocalStorageSupport;
2057
+ try {
2058
+ hasLocalStorageSupport = window !== 'undefined' && window.localStorage !== null;
2059
+ var testKey = 'i18next.translate.boo';
2060
+ window.localStorage.setItem(testKey, 'foo');
2061
+ window.localStorage.removeItem(testKey);
2062
+ } catch (e) {
2063
+ hasLocalStorageSupport = false;
2064
+ }
2065
+ return hasLocalStorageSupport;
2066
+ };
2067
+ var localStorage = {
2068
+ name: 'localStorage',
2069
+ lookup: function lookup(options) {
2070
+ var found;
2071
+ if (options.lookupLocalStorage && localStorageAvailable()) {
2072
+ var lng = window.localStorage.getItem(options.lookupLocalStorage);
2073
+ if (lng) found = lng;
2074
+ }
2075
+ return found;
2076
+ },
2077
+ cacheUserLanguage: function cacheUserLanguage(lng, options) {
2078
+ if (options.lookupLocalStorage && localStorageAvailable()) {
2079
+ window.localStorage.setItem(options.lookupLocalStorage, lng);
2080
+ }
2081
+ }
2082
+ };
2083
+
2084
+ var hasSessionStorageSupport = null;
2085
+ var sessionStorageAvailable = function sessionStorageAvailable() {
2086
+ if (hasSessionStorageSupport !== null) return hasSessionStorageSupport;
2087
+ try {
2088
+ hasSessionStorageSupport = window !== 'undefined' && window.sessionStorage !== null;
2089
+ var testKey = 'i18next.translate.boo';
2090
+ window.sessionStorage.setItem(testKey, 'foo');
2091
+ window.sessionStorage.removeItem(testKey);
2092
+ } catch (e) {
2093
+ hasSessionStorageSupport = false;
2094
+ }
2095
+ return hasSessionStorageSupport;
2096
+ };
2097
+ var sessionStorage = {
2098
+ name: 'sessionStorage',
2099
+ lookup: function lookup(options) {
2100
+ var found;
2101
+ if (options.lookupSessionStorage && sessionStorageAvailable()) {
2102
+ var lng = window.sessionStorage.getItem(options.lookupSessionStorage);
2103
+ if (lng) found = lng;
2104
+ }
2105
+ return found;
2106
+ },
2107
+ cacheUserLanguage: function cacheUserLanguage(lng, options) {
2108
+ if (options.lookupSessionStorage && sessionStorageAvailable()) {
2109
+ window.sessionStorage.setItem(options.lookupSessionStorage, lng);
2110
+ }
2111
+ }
2112
+ };
2113
+
2114
+ var navigator$1 = {
2115
+ name: 'navigator',
2116
+ lookup: function lookup(options) {
2117
+ var found = [];
2118
+ if (typeof navigator !== 'undefined') {
2119
+ if (navigator.languages) {
2120
+ // chrome only; not an array, so can't use .push.apply instead of iterating
2121
+ for (var i = 0; i < navigator.languages.length; i++) {
2122
+ found.push(navigator.languages[i]);
2123
+ }
2124
+ }
2125
+ if (navigator.userLanguage) {
2126
+ found.push(navigator.userLanguage);
2127
+ }
2128
+ if (navigator.language) {
2129
+ found.push(navigator.language);
2130
+ }
2131
+ }
2132
+ return found.length > 0 ? found : undefined;
2133
+ }
2134
+ };
2135
+
2136
+ var htmlTag = {
2137
+ name: 'htmlTag',
2138
+ lookup: function lookup(options) {
2139
+ var found;
2140
+ var htmlTag = options.htmlTag || (typeof document !== 'undefined' ? document.documentElement : null);
2141
+ if (htmlTag && typeof htmlTag.getAttribute === 'function') {
2142
+ found = htmlTag.getAttribute('lang');
2143
+ }
2144
+ return found;
2145
+ }
2146
+ };
2147
+
2148
+ var path = {
2149
+ name: 'path',
2150
+ lookup: function lookup(options) {
2151
+ var found;
2152
+ if (typeof window !== 'undefined') {
2153
+ var language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
2154
+ if (language instanceof Array) {
2155
+ if (typeof options.lookupFromPathIndex === 'number') {
2156
+ if (typeof language[options.lookupFromPathIndex] !== 'string') {
2157
+ return undefined;
2158
+ }
2159
+ found = language[options.lookupFromPathIndex].replace('/', '');
2160
+ } else {
2161
+ found = language[0].replace('/', '');
2162
+ }
2163
+ }
2164
+ }
2165
+ return found;
2166
+ }
2167
+ };
2168
+
2169
+ var subdomain = {
2170
+ name: 'subdomain',
2171
+ lookup: function lookup(options) {
2172
+ // If given get the subdomain index else 1
2173
+ var lookupFromSubdomainIndex = typeof options.lookupFromSubdomainIndex === 'number' ? options.lookupFromSubdomainIndex + 1 : 1;
2174
+ // get all matches if window.location. is existing
2175
+ // first item of match is the match itself and the second is the first group macht which sould be the first subdomain match
2176
+ // is the hostname no public domain get the or option of localhost
2177
+ var language = typeof window !== 'undefined' && window.location && window.location.hostname && window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);
2178
+
2179
+ // if there is no match (null) return undefined
2180
+ if (!language) return undefined;
2181
+ // return the given group match
2182
+ return language[lookupFromSubdomainIndex];
2183
+ }
2184
+ };
2185
+
2186
+ function getDefaults() {
2187
+ return {
2188
+ order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag'],
2189
+ lookupQuerystring: 'lng',
2190
+ lookupCookie: 'i18next',
2191
+ lookupLocalStorage: 'i18nextLng',
2192
+ lookupSessionStorage: 'i18nextLng',
2193
+ // cache user language
2194
+ caches: ['localStorage'],
2195
+ excludeCacheFor: ['cimode'],
2196
+ // cookieMinutes: 10,
2197
+ // cookieDomain: 'myDomain'
2198
+
2199
+ convertDetectedLanguage: function convertDetectedLanguage(l) {
2200
+ return l;
2201
+ }
2202
+ };
2203
+ }
2204
+ var Browser = /*#__PURE__*/function () {
2205
+ function Browser(services) {
2206
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2207
+ _classCallCheck(this, Browser);
2208
+ this.type = 'languageDetector';
2209
+ this.detectors = {};
2210
+ this.init(services, options);
2211
+ }
2212
+ _createClass(Browser, [{
2213
+ key: "init",
2214
+ value: function init(services) {
2215
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2216
+ var i18nOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2217
+ this.services = services || {
2218
+ languageUtils: {}
2219
+ }; // this way the language detector can be used without i18next
2220
+ this.options = defaults(options, this.options || {}, getDefaults());
2221
+ if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) {
2222
+ this.options.convertDetectedLanguage = function (l) {
2223
+ return l.replace('-', '_');
2224
+ };
2225
+ }
2226
+
2227
+ // backwards compatibility
2228
+ if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
2229
+ this.i18nOptions = i18nOptions;
2230
+ this.addDetector(cookie$1);
2231
+ this.addDetector(querystring);
2232
+ this.addDetector(localStorage);
2233
+ this.addDetector(sessionStorage);
2234
+ this.addDetector(navigator$1);
2235
+ this.addDetector(htmlTag);
2236
+ this.addDetector(path);
2237
+ this.addDetector(subdomain);
2238
+ }
2239
+ }, {
2240
+ key: "addDetector",
2241
+ value: function addDetector(detector) {
2242
+ this.detectors[detector.name] = detector;
2243
+ }
2244
+ }, {
2245
+ key: "detect",
2246
+ value: function detect(detectionOrder) {
2247
+ var _this = this;
2248
+ if (!detectionOrder) detectionOrder = this.options.order;
2249
+ var detected = [];
2250
+ detectionOrder.forEach(function (detectorName) {
2251
+ if (_this.detectors[detectorName]) {
2252
+ var lookup = _this.detectors[detectorName].lookup(_this.options);
2253
+ if (lookup && typeof lookup === 'string') lookup = [lookup];
2254
+ if (lookup) detected = detected.concat(lookup);
2255
+ }
2256
+ });
2257
+ detected = detected.map(function (d) {
2258
+ return _this.options.convertDetectedLanguage(d);
2259
+ });
2260
+ if (this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
2261
+ return detected.length > 0 ? detected[0] : null; // a little backward compatibility
2262
+ }
2263
+ }, {
2264
+ key: "cacheUserLanguage",
2265
+ value: function cacheUserLanguage(lng, caches) {
2266
+ var _this2 = this;
2267
+ if (!caches) caches = this.options.caches;
2268
+ if (!caches) return;
2269
+ if (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(lng) > -1) return;
2270
+ caches.forEach(function (cacheName) {
2271
+ if (_this2.detectors[cacheName]) _this2.detectors[cacheName].cacheUserLanguage(lng, _this2.options);
2272
+ });
2273
+ }
2274
+ }]);
2275
+ return Browser;
2276
+ }();
2277
+ Browser.type = 'languageDetector';
2278
+
1866
2279
  var generic = {
1867
2280
  error: "Something went wrong. Please try again later."
1868
2281
  };
@@ -1996,17 +2409,23 @@ var packageEnTranslations = getPackageTranslations("en", packageNames);
1996
2409
  var en = mergeDeepLeft(commonsEn, packageEnTranslations);
1997
2410
  var initializeI18n = function initializeI18n(resources) {
1998
2411
  var _i18n$services$format;
1999
- i18n.use(initReactI18next).init({
2412
+ i18n.use(Browser).use(initReactI18next).init({
2000
2413
  resources: mergeDeepLeft(resources, {
2001
2414
  en: {
2002
2415
  translation: en
2003
2416
  }
2004
2417
  }),
2005
- lng: "en",
2418
+ supportedLngs: ["en", "de"],
2006
2419
  fallbackLng: "en",
2007
2420
  interpolation: {
2008
2421
  escapeValue: false,
2009
2422
  skipOnVariables: false
2423
+ },
2424
+ detection: {
2425
+ order: ["querystring", "cookie", "navigator", "path"],
2426
+ caches: ["cookie"],
2427
+ lookupQuerystring: "lang",
2428
+ lookupCookie: "lang"
2010
2429
  }
2011
2430
  });
2012
2431
  (_i18n$services$format = i18n.services.formatter) === null || _i18n$services$format === void 0 ? void 0 : _i18n$services$format.addCached("boldList", function (language, options) {
@@ -2050,7 +2469,7 @@ function initializeMixPanel() {
2050
2469
  }
2051
2470
 
2052
2471
  var isObjectOrFunction = function isObjectOrFunction(object) {
2053
- var type = _typeof(object);
2472
+ var type = _typeof$1(object);
2054
2473
  return type === "function" || type === "object" && !!object;
2055
2474
  };
2056
2475
  function disableReactDevTools() {
@@ -2078,7 +2497,7 @@ function initializeApplication(_ref) {
2078
2497
  globalProps$1 = window.globalProps;
2079
2498
  }
2080
2499
  if (!(skip !== null && skip !== void 0 && skip.mixpanel)) initializeMixPanel();
2081
- if (_typeof(skip === null || skip === void 0 ? void 0 : skip.axios) === "object" || !(skip !== null && skip !== void 0 && skip.axios)) {
2500
+ if (_typeof$1(skip === null || skip === void 0 ? void 0 : skip.axios) === "object" || !(skip !== null && skip !== void 0 && skip.axios)) {
2082
2501
  initializeAxios(skip === null || skip === void 0 ? void 0 : skip.axios);
2083
2502
  }
2084
2503
  if (!(skip !== null && skip !== void 0 && skip.i18n)) initializeI18n(translationResources);