@bigbinary/neeto-commons-frontend 4.13.92 → 4.13.94-beta.1

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.
Files changed (94) hide show
  1. package/README.md +1 -0
  2. package/configs/esbuild/index.js +4 -0
  3. package/configs/esbuild/plugins/packageTranslations.js +16 -0
  4. package/configs/esbuild/plugins/preval.js +16 -6
  5. package/configs/esbuild/plugins/reactGiphy.js +1 -0
  6. package/configs/scripts/buildTranslationImports.js +21 -0
  7. package/configs/scripts/getEnglishTranslation.js +11 -0
  8. package/configs/utils/packageTranslations.js +90 -0
  9. package/configs/vite/index.js +5 -0
  10. package/configs/vite/plugins/packageTranslations.js +14 -0
  11. package/configs/vite/plugins/preval.js +17 -11
  12. package/dist/cjs/initializers/i18n.js +120 -183
  13. package/dist/cjs/initializers/i18n.js.map +1 -1
  14. package/dist/cjs/initializers/index.js +43 -19
  15. package/dist/cjs/initializers/index.js.map +1 -1
  16. package/dist/cjs/react-utils/PrivateRoute/PrivateRoute.js +17 -13
  17. package/dist/cjs/react-utils/PrivateRoute/PrivateRoute.js.map +1 -1
  18. package/dist/cjs/react-utils/PrivateRoute/constants.js +8 -0
  19. package/dist/cjs/react-utils/PrivateRoute/constants.js.map +1 -0
  20. package/dist/cjs/react-utils/PrivateRoute/index.js +2 -0
  21. package/dist/cjs/react-utils/PrivateRoute/index.js.map +1 -1
  22. package/dist/cjs/react-utils/PrivateRoute/utils.js +16 -0
  23. package/dist/cjs/react-utils/PrivateRoute/utils.js.map +1 -0
  24. package/dist/cjs/react-utils/index.js +5 -0
  25. package/dist/cjs/react-utils/index.js.map +1 -1
  26. package/dist/cjs/react-utils/mount/mount.js +68 -69
  27. package/dist/cjs/react-utils/mount/mount.js.map +1 -1
  28. package/dist/cjs/react-utils/usePrefersReducedMotion/constants.js +6 -0
  29. package/dist/cjs/react-utils/usePrefersReducedMotion/constants.js.map +1 -0
  30. package/dist/cjs/react-utils/usePrefersReducedMotion/index.js +12 -0
  31. package/dist/cjs/react-utils/usePrefersReducedMotion/index.js.map +1 -0
  32. package/dist/cjs/react-utils/usePrefersReducedMotion/usePrefersReducedMotion.js +46 -0
  33. package/dist/cjs/react-utils/usePrefersReducedMotion/usePrefersReducedMotion.js.map +1 -0
  34. package/dist/initializers/i18n.js +120 -183
  35. package/dist/initializers/i18n.js.map +1 -1
  36. package/dist/initializers/index.js +43 -19
  37. package/dist/initializers/index.js.map +1 -1
  38. package/dist/react-utils/PrivateRoute/PrivateRoute.js +17 -13
  39. package/dist/react-utils/PrivateRoute/PrivateRoute.js.map +1 -1
  40. package/dist/react-utils/PrivateRoute/constants.js +5 -0
  41. package/dist/react-utils/PrivateRoute/constants.js.map +1 -0
  42. package/dist/react-utils/PrivateRoute/index.js +2 -0
  43. package/dist/react-utils/PrivateRoute/index.js.map +1 -1
  44. package/dist/react-utils/PrivateRoute/utils.js +14 -0
  45. package/dist/react-utils/PrivateRoute/utils.js.map +1 -0
  46. package/dist/react-utils/index.js +4 -0
  47. package/dist/react-utils/index.js.map +1 -1
  48. package/dist/react-utils/mount/mount.js +68 -69
  49. package/dist/react-utils/mount/mount.js.map +1 -1
  50. package/dist/react-utils/usePrefersReducedMotion/constants.js +4 -0
  51. package/dist/react-utils/usePrefersReducedMotion/constants.js.map +1 -0
  52. package/dist/react-utils/usePrefersReducedMotion/index.js +6 -0
  53. package/dist/react-utils/usePrefersReducedMotion/index.js.map +1 -0
  54. package/dist/react-utils/usePrefersReducedMotion/usePrefersReducedMotion.js +44 -0
  55. package/dist/react-utils/usePrefersReducedMotion/usePrefersReducedMotion.js.map +1 -0
  56. package/initializers.d.ts +1 -1
  57. package/package.json +13 -7
  58. package/react-utils.d.ts +69 -3
  59. package/src/translations/ar.json +111 -0
  60. package/src/translations/bg.json +111 -0
  61. package/src/translations/ca.json +111 -0
  62. package/src/translations/cs.json +111 -0
  63. package/src/translations/da.json +111 -0
  64. package/src/translations/de.json +111 -0
  65. package/src/translations/en.json +111 -0
  66. package/src/translations/es-MX.json +111 -0
  67. package/src/translations/es.json +111 -0
  68. package/src/translations/et.json +111 -0
  69. package/src/translations/fi.json +111 -0
  70. package/src/translations/fil.json +111 -0
  71. package/src/translations/fr.json +111 -0
  72. package/src/translations/he.json +111 -0
  73. package/src/translations/hi.json +111 -0
  74. package/src/translations/hr.json +111 -0
  75. package/src/translations/id.json +111 -0
  76. package/src/translations/it.json +111 -0
  77. package/src/translations/ja.json +111 -0
  78. package/src/translations/ko.json +111 -0
  79. package/src/translations/nl.json +111 -0
  80. package/src/translations/pl.json +111 -0
  81. package/src/translations/pt-BR.json +111 -0
  82. package/src/translations/pt.json +111 -0
  83. package/src/translations/ro.json +111 -0
  84. package/src/translations/ru.json +111 -0
  85. package/src/translations/sk.json +111 -0
  86. package/src/translations/sl.json +111 -0
  87. package/src/translations/sv.json +111 -0
  88. package/src/translations/th.json +111 -0
  89. package/src/translations/tr.json +111 -0
  90. package/src/translations/uk.json +111 -0
  91. package/src/translations/vi.json +111 -0
  92. package/src/translations/zh-CN.json +111 -0
  93. package/src/translations/zh-TW.json +111 -0
  94. package/configs/scripts/getPkgTranslations.js +0 -45
@@ -1,10 +1,13 @@
1
+ import { _ as _asyncToGenerator, a as _regeneratorRuntime } from '../index-DbuxAQMD.js';
1
2
  import i18next from 'i18next';
2
3
  import { mergeDeepLeft } from 'ramda';
3
4
  import { initReactI18next } from 'react-i18next';
5
+ import _retryImport from '../utils/retryImport.js';
4
6
  import { LIST_FORMATS } from './constants.js';
5
7
  import { listFormatter, lowerCaseDynamicTextFormatter } from './utils/customFormatters.js';
6
8
  import { sentenceCaseProcessor } from './utils/customPostProcessors.js';
7
9
  import { replaceNullValuesWithGetter as _replaceNullValuesWithGetter } from './utils/utils.js';
10
+ import '../_commonjsHelpers-BFTU3MAI.js';
8
11
  import 'dompurify';
9
12
  import '../typeof-D-UKOauR.js';
10
13
  import '../slicedToArray-DmsZvA_9.js';
@@ -423,195 +426,129 @@ var Browser = /*#__PURE__*/function () {
423
426
  }();
424
427
  Browser.type = 'languageDetector';
425
428
 
426
- var generic = {
427
- error: "Something went wrong. Please try again later."
428
- };
429
- var authentication = {
430
- notLoggedIn: "Could not authenticate, please login to continue!",
431
- couldNotAuth: "Could not authenticate with the provided {{parameter}}.",
432
- incorrectPassword: "Current password is incorrect. Please try again.",
433
- incorrectEmailPassword: "Incorrect email or password. Please try again."
434
- };
435
- var authorization = {
436
- unauthorized: "You are not authorized to perform this action."
437
- };
438
- var resource = {
439
- add_one: "{{entity}} has been added successfully.",
440
- add_other: "{{entity}} have been added successfully.",
441
- save: "{{entity}} has been saved successfully.",
442
- save_one: "{{entity}} has been saved successfully.",
443
- save_other: "{{entity}} have been saved successfully.",
444
- update: "{{entity}} has been updated successfully.",
445
- update_one: "{{entity}} has been updated successfully.",
446
- update_other: "{{entity}} have been updated successfully.",
447
- delete_one: "{{entity}} has been deleted successfully.",
448
- delete_other: "{{entity}} have been deleted successfully.",
449
- clone: "{{entity}} has been cloned successfully.",
450
- notFound: "{{entity}} does not exist.",
451
- remove_one: "{{entity}} has been removed successfully.",
452
- remove_other: "{{entity}} have been removed successfully.",
453
- sent: "{{entity}} sent successfully.",
454
- merged: "{{entity}} have been successfully merged.",
455
- disconnected: "{{entity}} has been successfully disconnected."
456
- };
457
- var otp = {
458
- sent: "OTP has been sent successfully.",
459
- invalid: "Invalid OTP",
460
- verified: "OTP has been verified successfully."
461
- };
462
- var upload = {
463
- error: "An error occurred while uploading the file"
464
- };
465
- var image = {
466
- profile: {
467
- removalFailed: "Failed to remove profile picture",
468
- removalSuccess: "Profile picture successfully removed"
469
- },
470
- contentTypeInvalid: "Other than jpg, png, svg are not supported",
471
- sizeOutOfRange: "Should not be more than {{maxSize, number}} MB"
472
- };
473
- var userRole = {
474
- deactivateActiveAdmin: "You cannot deactivate active admin from the workspace!"
475
- };
476
- var activeRecord = {
477
- error: {
478
- blankName: "Name can't be blank",
479
- blankDescription: "Description can't be blank",
480
- blankValue: "Value can't be blank",
481
- prefixType: "Prefix type {{value}} is not valid",
482
- minimumEntryLimit: "Minimum entry limit must be less than or equal to {{maximumEntryLimit, number}}",
483
- maximumEntryLimit: "Maximum entry limit must be greater than or equal to {{minimumEntryLimit, number}}"
484
- }
485
- };
486
- var sessions = {
487
- expiry: "Your session has expired. Please login again."
488
- };
489
- var payment = {
490
- error: {
491
- incomplete: "Your payment could not be completed"
492
- }
493
- };
494
- var invitations = {
495
- deleted_one: "Invitation has been deleted successfully",
496
- deleted_other: "{{count, number}} Invitations have been deleted successfully",
497
- sent_one: "Invitation has been sent successfully",
498
- sent_other: "{{count, number}} Invitations have been sent successfully",
499
- notFound: "{{email}} was not invited to test this website."
500
- };
501
- var github = {
502
- error: {
503
- webhookPermissionDenied: "Permission denied. Ensure you have permission to create webhooks for the repository.",
504
- primaryNonDeletable: "Primary Github account cannot be deleted."
505
- }
506
- };
507
- var neetoCommons = {
508
- fallbackComponent: {
509
- somethingWentWrong: "Sorry, something went wrong.",
510
- description: "Please try <reloading>reloading</reloading> the page.<br> If the problem persists, <contactus>contact us</contactus>."
511
- },
512
- toastr: {
513
- success: {
514
- copiedToClipboard: "Copied to clipboard!"
515
- },
516
- error: {
517
- noInternetConnection: "No Internet Connection.",
518
- networkError: "Network error. Please check your connection and try again."
519
- }
520
- },
521
- notice: {
522
- errorOccurred: "Some error occurred."
523
- },
524
- validators: {
525
- isRequired: "{{what}} is required.",
526
- mustNotContainCapitalLetters: "{{what}} must not contain capital letters.",
527
- mustNotContainSpaces: "{{what}} must not contain spaces.",
528
- mustNotContainSpecialCharactersExceptHyphen: "{{what}} must not contain any special characters, except '-'",
529
- mustNotStartOrEndWithSpecialCharacters: "{{what}} must not start or end with special characters."
530
- },
531
- copyToClipboard: {
532
- failed: "Failed to copy to clipboard"
533
- }
534
- };
535
- var commonsEn = {
536
- generic: generic,
537
- authentication: authentication,
538
- authorization: authorization,
539
- resource: resource,
540
- otp: otp,
541
- upload: upload,
542
- image: image,
543
- userRole: userRole,
544
- activeRecord: activeRecord,
545
- sessions: sessions,
546
- payment: payment,
547
- invitations: invitations,
548
- github: github,
549
- neetoCommons: neetoCommons
429
+ var resourcesToBackend = function resourcesToBackend(res) {
430
+ return {
431
+ type: 'backend',
432
+ init: function init(services, backendOptions, i18nextOptions) {},
433
+ read: function read(language, namespace, callback) {
434
+ if (typeof res === 'function') {
435
+ if (res.length < 3) {
436
+ try {
437
+ var r = res(language, namespace);
438
+ if (r && typeof r.then === 'function') {
439
+ r.then(function (data) {
440
+ return callback(null, data && data.default || data);
441
+ }).catch(callback);
442
+ } else {
443
+ callback(null, r);
444
+ }
445
+ } catch (err) {
446
+ callback(err);
447
+ }
448
+ return;
449
+ }
450
+ res(language, namespace, callback);
451
+ return;
452
+ }
453
+ callback(null, res && res[language] && res[language][namespace]);
454
+ }
455
+ };
550
456
  };
551
457
 
552
458
  // eslint-disable-next-line import/no-mutable-exports
553
459
  var taxonomies = {};
554
- var initializeI18n = function initializeI18n(hostTranslations) {
555
- var _window$globalProps, _window$globalProps2;
556
- var enableDirAttribute = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
557
- document.documentElement.removeAttribute("lang");
558
- var userLanguage = (_window$globalProps = window.globalProps) === null || _window$globalProps === void 0 || (_window$globalProps = _window$globalProps.user) === null || _window$globalProps === void 0 ? void 0 : _window$globalProps.language;
559
- if (userLanguage) document.documentElement.setAttribute("lang", userLanguage);
560
- var packageTranslations = preval.require("../../configs/scripts/getPkgTranslations.js");
561
- var commonsTranslations = {
562
- en: {
563
- translation: commonsEn
564
- }
565
- };
566
- var resources = [hostTranslations, commonsTranslations, packageTranslations].reduce(mergeDeepLeft);
567
- var defaultTaxonomyKeys = Object.keys(resources.en.translation.taxonomyDefaultLabels || {});
568
- var defaultTaxonomies = Object.fromEntries(defaultTaxonomyKeys.map(function (key) {
569
- return [key, {
570
- singular: null,
571
- plural: null
572
- }];
573
- }));
574
- var hostTaxonomies = ((_window$globalProps2 = window.globalProps) === null || _window$globalProps2 === void 0 ? void 0 : _window$globalProps2.taxonomies) || {};
575
- taxonomies = _replaceNullValuesWithGetter(mergeDeepLeft(hostTaxonomies, defaultTaxonomies));
576
- i18next.use(Browser).use(initReactI18next).use(sentenceCaseProcessor).init({
577
- resources: resources,
578
- fallbackLng: "en",
579
- interpolation: {
580
- defaultVariables: {
581
- taxonomies: taxonomies
582
- },
583
- escapeValue: false,
584
- skipOnVariables: false,
585
- alwaysFormat: true,
586
- format: function format(value, _format, lng, options) {
587
- var newValue = value;
588
- if (LIST_FORMATS.includes(_format)) {
589
- newValue = listFormatter({
590
- value: newValue,
591
- format: _format,
592
- lng: lng,
593
- options: options
460
+ var initializeI18n = /*#__PURE__*/function () {
461
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
462
+ var _window$globalProps, _window$globalProps2;
463
+ var hostTranslations,
464
+ enableDirAttribute,
465
+ userLanguage,
466
+ translationImports,
467
+ englishTranslations,
468
+ englishResource,
469
+ resources,
470
+ defaultTaxonomyKeys,
471
+ defaultTaxonomies,
472
+ hostTaxonomies,
473
+ _args = arguments;
474
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
475
+ while (1) switch (_context.prev = _context.next) {
476
+ case 0:
477
+ hostTranslations = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
478
+ enableDirAttribute = _args.length > 1 && _args[1] !== undefined ? _args[1] : true;
479
+ document.documentElement.removeAttribute("lang");
480
+ userLanguage = (_window$globalProps = window.globalProps) === null || _window$globalProps === void 0 || (_window$globalProps = _window$globalProps.user) === null || _window$globalProps === void 0 ? void 0 : _window$globalProps.language;
481
+ if (userLanguage) document.documentElement.setAttribute("lang", userLanguage);
482
+ translationImports = preval.require("../../configs/scripts/buildTranslationImports.js");
483
+ englishTranslations = preval.require("../../configs/scripts/getEnglishTranslation.js");
484
+ englishResource = {
485
+ en: {
486
+ translation: englishTranslations || {}
487
+ }
488
+ };
489
+ resources = mergeDeepLeft(hostTranslations, englishResource);
490
+ defaultTaxonomyKeys = Object.keys(resources.en.translation.taxonomyDefaultLabels || {});
491
+ defaultTaxonomies = Object.fromEntries(defaultTaxonomyKeys.map(function (key) {
492
+ return [key, {
493
+ singular: null,
494
+ plural: null
495
+ }];
496
+ }));
497
+ hostTaxonomies = ((_window$globalProps2 = window.globalProps) === null || _window$globalProps2 === void 0 ? void 0 : _window$globalProps2.taxonomies) || {};
498
+ taxonomies = _replaceNullValuesWithGetter(mergeDeepLeft(hostTaxonomies, defaultTaxonomies));
499
+ _context.next = 15;
500
+ return i18next.use(Browser).use(initReactI18next).use(sentenceCaseProcessor).use(resourcesToBackend(function (language) {
501
+ return _retryImport(translationImports === null || translationImports === void 0 ? void 0 : translationImports[language]);
502
+ })).init({
503
+ resources: resources,
504
+ partialBundledLanguages: true,
505
+ fallbackLng: "en",
506
+ interpolation: {
507
+ defaultVariables: {
508
+ taxonomies: taxonomies
509
+ },
510
+ escapeValue: false,
511
+ skipOnVariables: false,
512
+ alwaysFormat: true,
513
+ format: function format(value, _format, lng, options) {
514
+ var newValue = value;
515
+ if (LIST_FORMATS.includes(_format)) {
516
+ newValue = listFormatter({
517
+ value: newValue,
518
+ format: _format,
519
+ lng: lng,
520
+ options: options
521
+ });
522
+ return newValue;
523
+ }
524
+ return lowerCaseDynamicTextFormatter(newValue, _format);
525
+ }
526
+ },
527
+ postProcess: [sentenceCaseProcessor.name],
528
+ detection: {
529
+ order: ["querystring", "htmlTag", "navigator", "cookie"],
530
+ caches: ["cookie"],
531
+ lookupQuerystring: "lang",
532
+ lookupCookie: "lang"
533
+ }
594
534
  });
595
- return newValue;
596
- }
597
- return lowerCaseDynamicTextFormatter(newValue, _format);
535
+ case 15:
536
+ if (enableDirAttribute) {
537
+ document.documentElement.setAttribute("dir", i18next.dir() || "ltr");
538
+ }
539
+ if (!userLanguage) {
540
+ document.documentElement.setAttribute("lang", i18next.resolvedLanguage || "en");
541
+ }
542
+ case 17:
543
+ case "end":
544
+ return _context.stop();
598
545
  }
599
- },
600
- postProcess: [sentenceCaseProcessor.name],
601
- detection: {
602
- order: ["querystring", "htmlTag", "navigator", "cookie"],
603
- caches: ["cookie"],
604
- lookupQuerystring: "lang",
605
- lookupCookie: "lang"
606
- }
607
- });
608
- if (enableDirAttribute) {
609
- document.documentElement.setAttribute("dir", i18next.dir() || "ltr");
610
- }
611
- if (!userLanguage) {
612
- document.documentElement.setAttribute("lang", i18next.resolvedLanguage || "en");
613
- }
614
- };
546
+ }, _callee);
547
+ }));
548
+ return function initializeI18n() {
549
+ return _ref.apply(this, arguments);
550
+ };
551
+ }();
615
552
 
616
553
  export { initializeI18n as default, taxonomies };
617
554
  //# sourceMappingURL=i18n.js.map