@bigbinary/neeto-commons-frontend 2.1.32 → 2.1.34

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.d.ts CHANGED
@@ -52,8 +52,15 @@ type GlobalPropsType = {
52
52
  endUserUploadedFileSizeLimitInMb: number;
53
53
  [key: string]: any;
54
54
  };
55
+ type TaxonomiesType = {
56
+ [key: string]: {
57
+ singular: string;
58
+ plural: string;
59
+ };
60
+ };
55
61
  export default function initializeApplication(configurations: Configurations): void;
56
62
  export const globalProps: GlobalPropsType;
63
+ export const taxonomies: TaxonomiesType;
57
64
 
58
65
  /** @deprecated use useDisplayErrorPage from react-utils bundle */
59
66
  /**
package/initializers.js CHANGED
@@ -2278,6 +2278,101 @@ var Browser = /*#__PURE__*/function () {
2278
2278
  }();
2279
2279
  Browser.type = 'languageDetector';
2280
2280
 
2281
+ function _arrayWithHoles(arr) {
2282
+ if (Array.isArray(arr)) return arr;
2283
+ }
2284
+
2285
+ function _iterableToArrayLimit(arr, i) {
2286
+ var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
2287
+ if (null != _i) {
2288
+ var _s,
2289
+ _e,
2290
+ _x,
2291
+ _r,
2292
+ _arr = [],
2293
+ _n = !0,
2294
+ _d = !1;
2295
+ try {
2296
+ if (_x = (_i = _i.call(arr)).next, 0 === i) {
2297
+ if (Object(_i) !== _i) return;
2298
+ _n = !1;
2299
+ } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
2300
+ } catch (err) {
2301
+ _d = !0, _e = err;
2302
+ } finally {
2303
+ try {
2304
+ if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
2305
+ } finally {
2306
+ if (_d) throw _e;
2307
+ }
2308
+ }
2309
+ return _arr;
2310
+ }
2311
+ }
2312
+
2313
+ function _arrayLikeToArray(arr, len) {
2314
+ if (len == null || len > arr.length) len = arr.length;
2315
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
2316
+ return arr2;
2317
+ }
2318
+
2319
+ function _unsupportedIterableToArray(o, minLen) {
2320
+ if (!o) return;
2321
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
2322
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2323
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2324
+ if (n === "Map" || n === "Set") return Array.from(o);
2325
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
2326
+ }
2327
+
2328
+ function _nonIterableRest() {
2329
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2330
+ }
2331
+
2332
+ function _slicedToArray(arr, i) {
2333
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
2334
+ }
2335
+
2336
+ var getter = function getter(key) {
2337
+ return function () {
2338
+ return i18n.t("taxonomyDefaultLabels.".concat(key));
2339
+ };
2340
+ };
2341
+ var replaceNullValuesWithGetter = function replaceNullValuesWithGetter(inputObject) {
2342
+ var parentKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
2343
+ var result = {};
2344
+ for (var _i = 0, _Object$entries = Object.entries(inputObject); _i < _Object$entries.length; _i++) {
2345
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
2346
+ key = _Object$entries$_i[0],
2347
+ value = _Object$entries$_i[1];
2348
+ var transKey = parentKey ? "".concat(parentKey, ".").concat(key) : key;
2349
+ if (value === null) {
2350
+ Object.defineProperty(result, key, {
2351
+ get: getter(transKey)
2352
+ });
2353
+ } else if (_typeof$1(value) === "object") {
2354
+ result[key] = replaceNullValuesWithGetter(value, transKey);
2355
+ } else {
2356
+ result[key] = value;
2357
+ }
2358
+ }
2359
+ return result;
2360
+ };
2361
+ var getSentenceCaseProcessor = function getSentenceCaseProcessor() {
2362
+ return {
2363
+ type: "postProcessor",
2364
+ name: "sentenceCasePlaceholderAndTypography",
2365
+ process: function process(value, keys) {
2366
+ if (keys.some(function (str) {
2367
+ return (str.startsWith("placeholder.") || str.startsWith("typography.")) && !str.includes("anyCase.");
2368
+ })) {
2369
+ return value.charAt(0).toLocaleUpperCase() + value.slice(1).toLocaleLowerCase();
2370
+ }
2371
+ return value;
2372
+ }
2373
+ };
2374
+ };
2375
+
2281
2376
  var generic = {
2282
2377
  error: "Something went wrong. Please try again later."
2283
2378
  };
@@ -2393,31 +2488,27 @@ var commonsEn = {
2393
2488
  neetoCommons: neetoCommons
2394
2489
  };
2395
2490
 
2396
- var sentenceCasePlaceholderAndTypographyProcessor = {
2397
- type: "postProcessor",
2398
- name: "sentenceCasePlaceholderAndTypography",
2399
- process: function process(value, keys) {
2400
- if (keys.some(function (str) {
2401
- return (str.startsWith("placeholder.") || str.startsWith("typography.")) && !str.includes("anyCase.");
2402
- })) {
2403
- return value.charAt(0).toLocaleUpperCase() + value.slice(1).toLocaleLowerCase();
2404
- }
2405
- return value;
2406
- }
2407
- };
2408
- var commonsTranslations = {
2409
- en: {
2410
- translation: commonsEn
2411
- }
2412
- };
2491
+ // eslint-disable-next-line import/no-mutable-exports
2492
+ var taxonomies = {};
2413
2493
  var initializeI18n = function initializeI18n(hostTranslations) {
2414
- var _i18n$services$format;
2494
+ var _window$globalProps, _i18n$services$format;
2415
2495
  var packageTranslations = preval.require("./configs/scripts/getPkgTranslations.js");
2496
+ var commonsTranslations = {
2497
+ en: {
2498
+ translation: commonsEn
2499
+ }
2500
+ };
2416
2501
  var resources = [hostTranslations, commonsTranslations, packageTranslations].reduce(mergeDeepLeft);
2417
- i18n.use(Browser).use(initReactI18next).use(sentenceCasePlaceholderAndTypographyProcessor).init({
2502
+ if ((_window$globalProps = window.globalProps) !== null && _window$globalProps !== void 0 && _window$globalProps.taxonomies) {
2503
+ taxonomies = replaceNullValuesWithGetter(window.globalProps.taxonomies);
2504
+ }
2505
+ i18n.use(Browser).use(initReactI18next).use(getSentenceCaseProcessor()).init({
2418
2506
  resources: resources,
2419
2507
  fallbackLng: "en",
2420
2508
  interpolation: {
2509
+ defaultVariables: {
2510
+ taxonomies: taxonomies
2511
+ },
2421
2512
  escapeValue: false,
2422
2513
  skipOnVariables: false
2423
2514
  },
@@ -2493,5 +2584,5 @@ function initializeApplication(_ref) {
2493
2584
  if (process.env.NODE_ENV === "production") disableReactDevTools();
2494
2585
  }
2495
2586
 
2496
- export { initializeApplication as default, globalProps };
2587
+ export { initializeApplication as default, globalProps, taxonomies };
2497
2588
  //# sourceMappingURL=initializers.js.map