@bigbinary/neeto-commons-frontend 3.0.7 → 3.0.9

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 (48) hide show
  1. package/cjs/configs/babel.js +50 -0
  2. package/cjs/configs/eslint/globals.js +14 -0
  3. package/cjs/configs/eslint/helpers/index.js +74 -0
  4. package/cjs/configs/eslint/imports/enforced.js +29 -0
  5. package/cjs/configs/eslint/imports/order.js +65 -0
  6. package/cjs/configs/eslint/index.js +171 -0
  7. package/cjs/configs/eslint/overrides.js +30 -0
  8. package/cjs/configs/eslint/promise.js +8 -0
  9. package/cjs/configs/eslint/react.js +92 -0
  10. package/cjs/configs/nanos/eslint/imports/order.js +25 -0
  11. package/cjs/configs/nanos/eslint/index.js +28 -0
  12. package/cjs/configs/nanos/tailwind.js +11 -0
  13. package/cjs/configs/nanos/webpack/resolve.js +48 -0
  14. package/cjs/configs/nextjs/eslint/imports/order.js +25 -0
  15. package/cjs/configs/nextjs/eslint/index.js +22 -0
  16. package/cjs/configs/nextjs/webpack/resolve.js +1 -0
  17. package/cjs/configs/prettier.js +16 -0
  18. package/cjs/configs/scripts/dead-code-eliminator/constants.js +12 -0
  19. package/cjs/configs/scripts/dead-code-eliminator/index.js +266 -0
  20. package/cjs/configs/scripts/getPkgTranslations.js +45 -0
  21. package/cjs/configs/scripts/jsdoc-builder/constants.mjs +42 -0
  22. package/cjs/configs/scripts/jsdoc-builder/index.mjs +67 -0
  23. package/cjs/configs/scripts/jsdoc-builder/utils.mjs +219 -0
  24. package/cjs/configs/scripts/remove-unused-translation-keys/constants.js +11 -0
  25. package/cjs/configs/scripts/remove-unused-translation-keys/index.js +186 -0
  26. package/cjs/configs/tailwind.js +13 -0
  27. package/cjs/configs/webpack/helpers/customize-default-rules.js +54 -0
  28. package/cjs/configs/webpack/index.js +58 -0
  29. package/cjs/configs/webpack/resolve.js +53 -0
  30. package/cjs/configs/webpack/rules.js +34 -0
  31. package/cjs/cypress-configs/initializer.js +32 -0
  32. package/cjs/cypress-configs/plugins.js +105 -0
  33. package/cjs/cypress-configs/resolve.js +17 -0
  34. package/cjs/cypress-configs/webpack.config.js +19 -0
  35. package/cjs/initializers/constants.js +9 -3
  36. package/cjs/initializers/constants.js.map +1 -1
  37. package/cjs/initializers/i18n.js +8 -2
  38. package/cjs/initializers/i18n.js.map +1 -1
  39. package/cjs/initializers/utils/customFormatters.js +17 -8
  40. package/cjs/initializers/utils/customFormatters.js.map +1 -1
  41. package/cjs/translations/en.json +100 -0
  42. package/initializers/constants.js +6 -1
  43. package/initializers/constants.js.map +1 -1
  44. package/initializers/i18n.js +9 -3
  45. package/initializers/i18n.js.map +1 -1
  46. package/initializers/utils/customFormatters.js +16 -7
  47. package/initializers/utils/customFormatters.js.map +1 -1
  48. package/package.json +1 -1
@@ -0,0 +1,105 @@
1
+ // @ts-nocheck
2
+ /// <reference types="cypress" />
3
+
4
+ /**
5
+ * @type {Cypress.PluginConfig}
6
+ */
7
+ // eslint-disable-next-line no-unused-vars
8
+ const path = require("path");
9
+
10
+ const webpack = require("@cypress/webpack-preprocessor");
11
+ const {
12
+ cypressBrowserPermissionsPlugin,
13
+ } = require("cypress-browser-permissions");
14
+ const { cloudPlugin } = require("cypress-cloud/plugin");
15
+ const fs = require("fs-extra");
16
+
17
+ const getConfigurationByFile = file => {
18
+ const pathToConfigFile = `cypress/config/cypress.${file}.json`;
19
+
20
+ return file && fs.readJsonSync(path.join(process.cwd(), pathToConfigFile));
21
+ };
22
+
23
+ const globalState = "globalState.txt";
24
+
25
+ const merge = (target, source = {}) => {
26
+ Object.keys(source).forEach(key => {
27
+ if (source[key] && typeof source[key] === "object") {
28
+ merge((target[key] = target[key] || {}), source[key]);
29
+
30
+ return;
31
+ }
32
+ target[key] = source[key];
33
+ });
34
+
35
+ return target;
36
+ };
37
+
38
+ module.exports = (on, config) => {
39
+ const environment = config.env.configFile;
40
+ const configForEnvironment = getConfigurationByFile(environment);
41
+ const options = {
42
+ // send in the options from your webpack.config.js
43
+ webpackOptions: require("./webpack.config"),
44
+ watchOptions: {},
45
+ };
46
+ on("file:preprocessor", webpack(options));
47
+
48
+ config = cypressBrowserPermissionsPlugin(on, config);
49
+
50
+ const newEnvironment = merge(config, configForEnvironment);
51
+ require("@cypress/grep/src/plugin")(newEnvironment);
52
+ require("@cypress/code-coverage/task")(on, newEnvironment);
53
+ cloudPlugin(on, newEnvironment);
54
+
55
+ on("before:browser:launch", (browser, launchOptions) => {
56
+ if (["chrome", "edge"].includes(browser.name) && browser.isHeadless) {
57
+ launchOptions.args.push("--no-sandbox");
58
+ launchOptions.args.push("--disable-gl-drawing-for-tests");
59
+ launchOptions.args.push("--js-flags=--max-old-space-size=3500");
60
+ launchOptions.args.push("--disable-gpu");
61
+ }
62
+
63
+ return launchOptions;
64
+ });
65
+
66
+ const readFileSyncIfExists = filePath => {
67
+ try {
68
+ return JSON.parse(fs.readFileSync(filePath, "utf8"));
69
+ } catch (error) {
70
+ if (error.code === "ENOENT") {
71
+ return {};
72
+ }
73
+ console.log(error); // eslint-disable-line
74
+ }
75
+
76
+ return {};
77
+ };
78
+
79
+ const writeDataToFile = (filePath, data) => {
80
+ try {
81
+ fs.writeFileSync(filePath, data, "utf8");
82
+ } catch (err) {
83
+ console.log(err); // eslint-disable-line
84
+ }
85
+
86
+ return true;
87
+ };
88
+
89
+ on("task", {
90
+ getGlobalState: key =>
91
+ key
92
+ ? readFileSyncIfExists(globalState)?.[key] ?? null
93
+ : readFileSyncIfExists(globalState),
94
+ updateGlobalState: ({ key, value }) => {
95
+ const data = readFileSyncIfExists(globalState);
96
+ data[key] = value;
97
+
98
+ return writeDataToFile(globalState, JSON.stringify(data));
99
+ },
100
+ bulkUpdateGlobalState: newState =>
101
+ writeDataToFile(globalState, JSON.stringify(newState)),
102
+ });
103
+
104
+ return config, newEnvironment;
105
+ };
@@ -0,0 +1,17 @@
1
+ const path = require("path");
2
+
3
+ const basePath = `${process.cwd()}/cypress/`;
4
+
5
+ module.exports = {
6
+ alias: {
7
+ Fixtures: path.resolve(basePath, "fixtures"),
8
+ Plugins: path.resolve(basePath, "plugins"),
9
+ Support: path.resolve(basePath, "support"),
10
+ Texts: path.resolve(basePath, "constants/texts"),
11
+ Selectors: path.resolve(basePath, "constants/selectors"),
12
+ neetocommons: "@bigbinary/neeto-commons-frontend",
13
+ Constants: path.resolve(basePath, "constants"),
14
+ neetocist: "@bigbinary/neeto-cist",
15
+ },
16
+ fallback: { path: require.resolve("path-browserify") },
17
+ };
@@ -0,0 +1,19 @@
1
+ const resolve = require("./resolve");
2
+
3
+ module.exports = {
4
+ resolve,
5
+ module: {
6
+ rules: [
7
+ {
8
+ test: /\.(js|jsx)$/,
9
+ exclude: [/node_modules/],
10
+ use: [
11
+ {
12
+ loader: "babel-loader",
13
+ options: { presets: ["@babel/preset-env"] },
14
+ },
15
+ ],
16
+ },
17
+ ],
18
+ },
19
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.LOWERCASED = exports.HEADERS_KEYS = exports.ANY_CASE = void 0;
6
+ exports.LOWERCASED = exports.LIST_FORMATS = exports.HEADERS_KEYS = exports.FORMATS = void 0;
7
7
  var HEADERS_KEYS = {
8
8
  xCsrfToken: "X-CSRF-TOKEN",
9
9
  contentType: "Content-Type",
@@ -12,6 +12,12 @@ var HEADERS_KEYS = {
12
12
  exports.HEADERS_KEYS = HEADERS_KEYS;
13
13
  var LOWERCASED = "__LOWERCASED__";
14
14
  exports.LOWERCASED = LOWERCASED;
15
- var ANY_CASE = "anyCase";
16
- exports.ANY_CASE = ANY_CASE;
15
+ var FORMATS = {
16
+ boldList: "boldList",
17
+ list: "list",
18
+ anyCase: "anyCase"
19
+ };
20
+ exports.FORMATS = FORMATS;
21
+ var LIST_FORMATS = [FORMATS.boldList, FORMATS.list];
22
+ exports.LIST_FORMATS = LIST_FORMATS;
17
23
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["HEADERS_KEYS","xCsrfToken","contentType","accept","exports","LOWERCASED","ANY_CASE"],"sources":["../../../src/initializers/constants.js"],"sourcesContent":["export const HEADERS_KEYS = {\n xCsrfToken: \"X-CSRF-TOKEN\",\n contentType: \"Content-Type\",\n accept: \"Accept\",\n};\n\nexport const LOWERCASED = \"__LOWERCASED__\";\nexport const ANY_CASE = \"anyCase\";\n"],"mappings":";;;;;;AAAO,IAAMA,YAAY,GAAG;EAC1BC,UAAU,EAAE,cAAc;EAC1BC,WAAW,EAAE,cAAc;EAC3BC,MAAM,EAAE;AACV,CAAC;AAACC,OAAA,CAAAJ,YAAA,GAAAA,YAAA;AAEK,IAAMK,UAAU,GAAG,gBAAgB;AAACD,OAAA,CAAAC,UAAA,GAAAA,UAAA;AACpC,IAAMC,QAAQ,GAAG,SAAS;AAACF,OAAA,CAAAE,QAAA,GAAAA,QAAA"}
1
+ {"version":3,"file":"constants.js","names":["HEADERS_KEYS","xCsrfToken","contentType","accept","exports","LOWERCASED","FORMATS","boldList","list","anyCase","LIST_FORMATS"],"sources":["../../../src/initializers/constants.js"],"sourcesContent":["export const HEADERS_KEYS = {\n xCsrfToken: \"X-CSRF-TOKEN\",\n contentType: \"Content-Type\",\n accept: \"Accept\",\n};\n\nexport const LOWERCASED = \"__LOWERCASED__\";\n\nexport const FORMATS = {\n boldList: \"boldList\",\n list: \"list\",\n anyCase: \"anyCase\",\n};\nexport const LIST_FORMATS = [FORMATS.boldList, FORMATS.list];\n"],"mappings":";;;;;;AAAO,IAAMA,YAAY,GAAG;EAC1BC,UAAU,EAAE,cAAc;EAC1BC,WAAW,EAAE,cAAc;EAC3BC,MAAM,EAAE;AACV,CAAC;AAACC,OAAA,CAAAJ,YAAA,GAAAA,YAAA;AAEK,IAAMK,UAAU,GAAG,gBAAgB;AAACD,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAEpC,IAAMC,OAAO,GAAG;EACrBC,QAAQ,EAAE,UAAU;EACpBC,IAAI,EAAE,MAAM;EACZC,OAAO,EAAE;AACX,CAAC;AAACL,OAAA,CAAAE,OAAA,GAAAA,OAAA;AACK,IAAMI,YAAY,GAAG,CAACJ,OAAO,CAACC,QAAQ,EAAED,OAAO,CAACE,IAAI,CAAC;AAACJ,OAAA,CAAAM,YAAA,GAAAA,YAAA"}
@@ -9,6 +9,7 @@ var _i18next = _interopRequireDefault(require("i18next"));
9
9
  var _i18nextBrowserLanguagedetector = _interopRequireDefault(require("i18next-browser-languagedetector"));
10
10
  var _ramda = require("ramda");
11
11
  var _reactI18next = require("react-i18next");
12
+ var _constants = require("./constants");
12
13
  var _utils = require("./utils");
13
14
  var _customFormatters = require("./utils/customFormatters");
14
15
  var _customPostProcessors = require("./utils/customPostProcessors");
@@ -47,8 +48,13 @@ var initializeI18n = function initializeI18n(hostTranslations) {
47
48
  alwaysFormat: true,
48
49
  format: function format(value, _format, lng, options) {
49
50
  var newValue = value;
50
- if (_format === "boldList") {
51
- newValue = (0, _customFormatters.boldListFormatter)(newValue, lng, options);
51
+ if (_constants.LIST_FORMATS.includes(_format)) {
52
+ newValue = (0, _customFormatters.listFormatter)({
53
+ value: newValue,
54
+ format: _format,
55
+ lng: lng,
56
+ options: options
57
+ });
52
58
  return newValue;
53
59
  }
54
60
  return (0, _customFormatters.lowerCaseDynamicTextFormatter)(newValue, _format);
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","names":["_i18next","_interopRequireDefault","require","_i18nextBrowserLanguagedetector","_ramda","_reactI18next","_utils","_customFormatters","_customPostProcessors","_en","taxonomies","exports","initializeI18n","hostTranslations","_window$globalProps","packageTranslations","preval","commonsTranslations","en","translation","commonsEn","resources","reduce","mergeDeepLeft","defaultTaxonomyKeys","Object","keys","taxonomyDefaultLabels","defaultTaxonomies","fromEntries","map","key","singular","plural","hostTaxonomies","window","globalProps","replaceNullValuesWithGetter","i18n","use","LanguageDetector","initReactI18next","sentenceCaseProcessor","init","fallbackLng","interpolation","defaultVariables","escapeValue","skipOnVariables","alwaysFormat","format","value","lng","options","newValue","boldListFormatter","lowerCaseDynamicTextFormatter","postProcess","name","detection","order","caches","lookupQuerystring","lookupCookie","_default"],"sources":["../../../src/initializers/i18n.js"],"sourcesContent":["import i18n from \"i18next\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\nimport { mergeDeepLeft } from \"ramda\";\nimport { initReactI18next } from \"react-i18next\";\n\nimport { replaceNullValuesWithGetter } from \"./utils\";\nimport {\n boldListFormatter,\n lowerCaseDynamicTextFormatter,\n} from \"./utils/customFormatters\";\nimport { sentenceCaseProcessor } from \"./utils/customPostProcessors\";\n\nimport commonsEn from \"../translations/en.json\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet taxonomies = {};\n\nconst initializeI18n = hostTranslations => {\n // eslint-disable-next-line no-undef\n const packageTranslations = preval.require(\n \"../configs/scripts/getPkgTranslations.js\"\n );\n\n const commonsTranslations = { en: { translation: commonsEn } };\n\n const resources = [\n hostTranslations,\n commonsTranslations,\n packageTranslations,\n ].reduce(mergeDeepLeft);\n\n const defaultTaxonomyKeys = Object.keys(\n resources.en.translation.taxonomyDefaultLabels || {}\n );\n\n const defaultTaxonomies = Object.fromEntries(\n defaultTaxonomyKeys.map(key => [key, { singular: null, plural: null }])\n );\n\n const hostTaxonomies = window.globalProps?.taxonomies || {};\n\n taxonomies = replaceNullValuesWithGetter(\n mergeDeepLeft(hostTaxonomies, defaultTaxonomies)\n );\n\n i18n\n .use(LanguageDetector)\n .use(initReactI18next)\n .use(sentenceCaseProcessor)\n .init({\n resources,\n fallbackLng: \"en\",\n interpolation: {\n defaultVariables: { taxonomies },\n escapeValue: false,\n skipOnVariables: false,\n alwaysFormat: true,\n format: (value, format, lng, options) => {\n let newValue = value;\n if (format === \"boldList\") {\n newValue = boldListFormatter(newValue, lng, options);\n\n return newValue;\n }\n\n return lowerCaseDynamicTextFormatter(newValue, format);\n },\n },\n postProcess: [sentenceCaseProcessor.name],\n detection: {\n order: [\"querystring\", \"cookie\", \"navigator\", \"path\"],\n caches: [\"cookie\"],\n lookupQuerystring: \"lang\",\n lookupCookie: \"lang\",\n },\n });\n};\n\nexport { taxonomies };\n\nexport default initializeI18n;\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,+BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AAIA,IAAAM,qBAAA,GAAAN,OAAA;AAEA,IAAAO,GAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEA;AACA,IAAIQ,UAAU,GAAG,CAAC,CAAC;AAACC,OAAA,CAAAD,UAAA,GAAAA,UAAA;AAEpB,IAAME,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,gBAAgB,EAAI;EAAA,IAAAC,mBAAA;EACzC;EACA,IAAMC,mBAAmB,GAAGC,MAAM,CAACd,OAAO,CACxC,0CAA0C,CAC3C;EAED,IAAMe,mBAAmB,GAAG;IAAEC,EAAE,EAAE;MAAEC,WAAW,EAAEC;IAAU;EAAE,CAAC;EAE9D,IAAMC,SAAS,GAAG,CAChBR,gBAAgB,EAChBI,mBAAmB,EACnBF,mBAAmB,CACpB,CAACO,MAAM,CAACC,oBAAa,CAAC;EAEvB,IAAMC,mBAAmB,GAAGC,MAAM,CAACC,IAAI,CACrCL,SAAS,CAACH,EAAE,CAACC,WAAW,CAACQ,qBAAqB,IAAI,CAAC,CAAC,CACrD;EAED,IAAMC,iBAAiB,GAAGH,MAAM,CAACI,WAAW,CAC1CL,mBAAmB,CAACM,GAAG,CAAC,UAAAC,GAAG;IAAA,OAAI,CAACA,GAAG,EAAE;MAAEC,QAAQ,EAAE,IAAI;MAAEC,MAAM,EAAE;IAAK,CAAC,CAAC;EAAA,EAAC,CACxE;EAED,IAAMC,cAAc,GAAG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}
1
+ {"version":3,"file":"i18n.js","names":["_i18next","_interopRequireDefault","require","_i18nextBrowserLanguagedetector","_ramda","_reactI18next","_constants","_utils","_customFormatters","_customPostProcessors","_en","taxonomies","exports","initializeI18n","hostTranslations","_window$globalProps","packageTranslations","preval","commonsTranslations","en","translation","commonsEn","resources","reduce","mergeDeepLeft","defaultTaxonomyKeys","Object","keys","taxonomyDefaultLabels","defaultTaxonomies","fromEntries","map","key","singular","plural","hostTaxonomies","window","globalProps","replaceNullValuesWithGetter","i18n","use","LanguageDetector","initReactI18next","sentenceCaseProcessor","init","fallbackLng","interpolation","defaultVariables","escapeValue","skipOnVariables","alwaysFormat","format","value","lng","options","newValue","LIST_FORMATS","includes","listFormatter","lowerCaseDynamicTextFormatter","postProcess","name","detection","order","caches","lookupQuerystring","lookupCookie","_default"],"sources":["../../../src/initializers/i18n.js"],"sourcesContent":["import i18n from \"i18next\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\nimport { mergeDeepLeft } from \"ramda\";\nimport { initReactI18next } from \"react-i18next\";\n\nimport { LIST_FORMATS } from \"./constants\";\nimport { replaceNullValuesWithGetter } from \"./utils\";\nimport {\n listFormatter,\n lowerCaseDynamicTextFormatter,\n} from \"./utils/customFormatters\";\nimport { sentenceCaseProcessor } from \"./utils/customPostProcessors\";\n\nimport commonsEn from \"../translations/en.json\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet taxonomies = {};\n\nconst initializeI18n = hostTranslations => {\n // eslint-disable-next-line no-undef\n const packageTranslations = preval.require(\n \"../configs/scripts/getPkgTranslations.js\"\n );\n\n const commonsTranslations = { en: { translation: commonsEn } };\n\n const resources = [\n hostTranslations,\n commonsTranslations,\n packageTranslations,\n ].reduce(mergeDeepLeft);\n\n const defaultTaxonomyKeys = Object.keys(\n resources.en.translation.taxonomyDefaultLabels || {}\n );\n\n const defaultTaxonomies = Object.fromEntries(\n defaultTaxonomyKeys.map(key => [key, { singular: null, plural: null }])\n );\n\n const hostTaxonomies = window.globalProps?.taxonomies || {};\n\n taxonomies = replaceNullValuesWithGetter(\n mergeDeepLeft(hostTaxonomies, defaultTaxonomies)\n );\n\n i18n\n .use(LanguageDetector)\n .use(initReactI18next)\n .use(sentenceCaseProcessor)\n .init({\n resources,\n fallbackLng: \"en\",\n interpolation: {\n defaultVariables: { taxonomies },\n escapeValue: false,\n skipOnVariables: false,\n alwaysFormat: true,\n format: (value, format, lng, options) => {\n let newValue = value;\n\n if (LIST_FORMATS.includes(format)) {\n newValue = listFormatter({ value: newValue, format, lng, options });\n\n return newValue;\n }\n\n return lowerCaseDynamicTextFormatter(newValue, format);\n },\n },\n postProcess: [sentenceCaseProcessor.name],\n detection: {\n order: [\"querystring\", \"cookie\", \"navigator\", \"path\"],\n caches: [\"cookie\"],\n lookupQuerystring: \"lang\",\n lookupCookie: \"lang\",\n },\n });\n};\n\nexport { taxonomies };\n\nexport default initializeI18n;\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,+BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AAIA,IAAAO,qBAAA,GAAAP,OAAA;AAEA,IAAAQ,GAAA,GAAAT,sBAAA,CAAAC,OAAA;AAEA;AACA,IAAIS,UAAU,GAAG,CAAC,CAAC;AAACC,OAAA,CAAAD,UAAA,GAAAA,UAAA;AAEpB,IAAME,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,gBAAgB,EAAI;EAAA,IAAAC,mBAAA;EACzC;EACA,IAAMC,mBAAmB,GAAGC,MAAM,CAACf,OAAO,CACxC,0CAA0C,CAC3C;EAED,IAAMgB,mBAAmB,GAAG;IAAEC,EAAE,EAAE;MAAEC,WAAW,EAAEC;IAAU;EAAE,CA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AAAG,+BAAa,EAAC;YAAEN,KAAK,EAAEG,QAAQ;YAAEJ,MAAM,EAANA,OAAM;YAAEE,GAAG,EAAHA,GAAG;YAAEC,OAAO,EAAPA;UAAQ,CAAC,CAAC;UAEnE,OAAOC,QAAQ;QACjB;QAEA,OAAO,IAAAI,+CAA6B,EAACJ,QAAQ,EAAEJ,OAAM,CAAC;MACxD;IACF,CAAC;IACDS,WAAW,EAAE,CAACjB,2CAAqB,CAACkB,IAAI,CAAC;IACzCC,SAAS,EAAE;MACTC,KAAK,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC;MACrDC,MAAM,EAAE,CAAC,QAAQ,CAAC;MAClBC,iBAAiB,EAAE,MAAM;MACzBC,YAAY,EAAE;IAChB;EACF,CAAC,CAAC;AACN,CAAC;AAAC,IAAAC,QAAA,GAIatD,cAAc;AAAAD,OAAA,cAAAuD,QAAA"}
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.lowerCaseDynamicTextFormatter = exports.boldListFormatter = void 0;
7
+ exports.lowerCaseDynamicTextFormatter = exports.listFormatter = void 0;
8
8
  var _dompurify = _interopRequireDefault(require("dompurify"));
9
9
  var _constants = require("../constants");
10
10
  var sanitizer = function sanitizer(array) {
@@ -25,19 +25,28 @@ var fetchCachedOrInvoke = function fetchCachedOrInvoke(func, lng, options) {
25
25
  return cache;
26
26
  };
27
27
  var lowerCaseDynamicTextFormatter = function lowerCaseDynamicTextFormatter(value, format) {
28
- if (!value || format === _constants.ANY_CASE || typeof value !== "string") return value;
28
+ if (!value || format === _constants.FORMATS.anyCase || typeof value !== "string") {
29
+ return value;
30
+ }
29
31
  return _constants.LOWERCASED + value.toLocaleLowerCase();
30
32
  };
31
33
  exports.lowerCaseDynamicTextFormatter = lowerCaseDynamicTextFormatter;
32
- var boldListFormatter = function boldListFormatter(array, lng, options) {
34
+ var listFormatter = function listFormatter(_ref) {
35
+ var value = _ref.value,
36
+ format = _ref.format,
37
+ lng = _ref.lng,
38
+ options = _ref.options;
33
39
  var formatter = fetchCachedOrInvoke(function (lng, options) {
34
40
  return new Intl.ListFormat(lng, options);
35
41
  }, lng, options);
36
- var boldItems = array.map(function (item) {
37
- return "<strong>".concat(item, "</strong>");
38
- });
39
- var sanitizedItems = sanitizer(boldItems).split(",");
42
+ var newValue = value;
43
+ if (format === _constants.FORMATS.boldList) {
44
+ newValue = value.map(function (item) {
45
+ return "<strong>".concat(item, "</strong>");
46
+ });
47
+ }
48
+ var sanitizedItems = sanitizer(newValue).split(",");
40
49
  return formatter.format(sanitizedItems);
41
50
  };
42
- exports.boldListFormatter = boldListFormatter;
51
+ exports.listFormatter = listFormatter;
43
52
  //# sourceMappingURL=customFormatters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customFormatters.js","names":["_dompurify","_interopRequireDefault","require","_constants","sanitizer","array","DOMPurify","sanitize","USE_PROFILES","html","cacheStore","Map","fetchCachedOrInvoke","func","lng","options","_cacheStore$get","cache","get","lngCache","set","lowerCaseDynamicTextFormatter","value","format","ANY_CASE","LOWERCASED","toLocaleLowerCase","exports","boldListFormatter","formatter","Intl","ListFormat","boldItems","map","item","concat","sanitizedItems","split"],"sources":["../../../../src/initializers/utils/customFormatters.js"],"sourcesContent":["import DOMPurify from \"dompurify\";\n\nimport { LOWERCASED, ANY_CASE } from \"../constants\";\n\nconst sanitizer = array =>\n DOMPurify.sanitize(array, { USE_PROFILES: { html: true } });\n\nconst cacheStore = new Map();\n\nconst fetchCachedOrInvoke = (func, lng, options) => {\n let cache = cacheStore.get(lng)?.get(options);\n if (cache) return cache;\n\n cache = func(lng, options);\n const lngCache = cacheStore.get(lng);\n if (lngCache) lngCache.set(options, cache);\n else cacheStore.set(lng, new Map([[options, cache]]));\n\n return cache;\n};\n\nexport const lowerCaseDynamicTextFormatter = (value, format) => {\n if (!value || format === ANY_CASE || typeof value !== \"string\") return value;\n\n return LOWERCASED + value.toLocaleLowerCase();\n};\n\nexport const boldListFormatter = (array, lng, options) => {\n const formatter = fetchCachedOrInvoke(\n (lng, options) => new Intl.ListFormat(lng, options),\n lng,\n options\n );\n const boldItems = array.map(item => `<strong>${item}</strong>`);\n const sanitizedItems = sanitizer(boldItems).split(\",\");\n\n return formatter.format(sanitizedItems);\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAME,SAAS,GAAG,SAAZA,SAASA,CAAGC,KAAK;EAAA,OACrBC,qBAAS,CAACC,QAAQ,CAACF,KAAK,EAAE;IAAEG,YAAY,EAAE;MAAEC,IAAI,EAAE;IAAK;EAAE,CAAC,CAAC;AAAA;AAE7D,IAAMC,UAAU,GAAG,IAAIC,GAAG,EAAE;AAE5B,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,IAAI,EAAEC,GAAG,EAAEC,OAAO,EAAK;EAAA,IAAAC,eAAA;EAClD,IAAIC,KAAK,IAAAD,eAAA,GAAGN,UAAU,CAACQ,GAAG,CAACJ,GAAG,CAAC,cAAAE,eAAA,uBAAnBA,eAAA,CAAqBE,GAAG,CAACH,OAAO,CAAC;EAC7C,IAAIE,KAAK,EAAE,OAAOA,KAAK;EAEvBA,KAAK,GAAGJ,IAAI,CAACC,GAAG,EAAEC,OAAO,CAAC;EAC1B,IAAMI,QAAQ,GAAGT,UAAU,CAACQ,GAAG,CAACJ,GAAG,CAAC;EACpC,IAAIK,QAAQ,EAAEA,QAAQ,CAACC,GAAG,CAACL,OAAO,EAAEE,KAAK,CAAC,CAAC,KACtCP,UAAU,CAACU,GAAG,CAACN,GAAG,EAAE,IAAIH,GAAG,CAAC,CAAC,CAACI,OAAO,EAAEE,KAAK,CAAC,CAAC,CAAC,CAAC;EAErD,OAAOA,KAAK;AACd,CAAC;AAEM,IAAMI,6BAA6B,GAAG,SAAhCA,6BAA6BA,CAAIC,KAAK,EAAEC,MAAM,EAAK;EAC9D,IAAI,CAACD,KAAK,IAAIC,MAAM,KAAKC,mBAAQ,IAAI,OAAOF,KAAK,KAAK,QAAQ,EAAE,OAAOA,KAAK;EAE5E,OAAOG,qBAAU,GAAGH,KAAK,CAACI,iBAAiB,EAAE;AAC/C,CAAC;AAACC,OAAA,CAAAN,6BAAA,GAAAA,6BAAA;AAEK,IAAMO,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIvB,KAAK,EAAES,GAAG,EAAEC,OAAO,EAAK;EACxD,IAAMc,SAAS,GAAGjB,mBAAmB,CACnC,UAACE,GAAG,EAAEC,OAAO;IAAA,OAAK,IAAIe,IAAI,CAACC,UAAU,CAACjB,GAAG,EAAEC,OAAO,CAAC;EAAA,GACnDD,GAAG,EACHC,OAAO,CACR;EACD,IAAMiB,SAAS,GAAG3B,KAAK,CAAC4B,GAAG,CAAC,UAAAC,IAAI;IAAA,kBAAAC,MAAA,CAAeD,IAAI;EAAA,CAAW,CAAC;EAC/D,IAAME,cAAc,GAAGhC,SAAS,CAAC4B,SAAS,CAAC,CAACK,KAAK,CAAC,GAAG,CAAC;EAEtD,OAAOR,SAAS,CAACN,MAAM,CAACa,cAAc,CAAC;AACzC,CAAC;AAACT,OAAA,CAAAC,iBAAA,GAAAA,iBAAA"}
1
+ {"version":3,"file":"customFormatters.js","names":["_dompurify","_interopRequireDefault","require","_constants","sanitizer","array","DOMPurify","sanitize","USE_PROFILES","html","cacheStore","Map","fetchCachedOrInvoke","func","lng","options","_cacheStore$get","cache","get","lngCache","set","lowerCaseDynamicTextFormatter","value","format","FORMATS","anyCase","LOWERCASED","toLocaleLowerCase","exports","listFormatter","_ref","formatter","Intl","ListFormat","newValue","boldList","map","item","concat","sanitizedItems","split"],"sources":["../../../../src/initializers/utils/customFormatters.js"],"sourcesContent":["import DOMPurify from \"dompurify\";\n\nimport { LOWERCASED, FORMATS } from \"../constants\";\n\nconst sanitizer = array =>\n DOMPurify.sanitize(array, { USE_PROFILES: { html: true } });\n\nconst cacheStore = new Map();\n\nconst fetchCachedOrInvoke = (func, lng, options) => {\n let cache = cacheStore.get(lng)?.get(options);\n if (cache) return cache;\n\n cache = func(lng, options);\n const lngCache = cacheStore.get(lng);\n if (lngCache) lngCache.set(options, cache);\n else cacheStore.set(lng, new Map([[options, cache]]));\n\n return cache;\n};\n\nexport const lowerCaseDynamicTextFormatter = (value, format) => {\n if (!value || format === FORMATS.anyCase || typeof value !== \"string\") {\n return value;\n }\n\n return LOWERCASED + value.toLocaleLowerCase();\n};\n\nexport const listFormatter = ({ value, format, lng, options }) => {\n const formatter = fetchCachedOrInvoke(\n (lng, options) => new Intl.ListFormat(lng, options),\n lng,\n options\n );\n\n let newValue = value;\n if (format === FORMATS.boldList) {\n newValue = value.map(item => `<strong>${item}</strong>`);\n }\n const sanitizedItems = sanitizer(newValue).split(\",\");\n\n return formatter.format(sanitizedItems);\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAME,SAAS,GAAG,SAAZA,SAASA,CAAGC,KAAK;EAAA,OACrBC,qBAAS,CAACC,QAAQ,CAACF,KAAK,EAAE;IAAEG,YAAY,EAAE;MAAEC,IAAI,EAAE;IAAK;EAAE,CAAC,CAAC;AAAA;AAE7D,IAAMC,UAAU,GAAG,IAAIC,GAAG,EAAE;AAE5B,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,IAAI,EAAEC,GAAG,EAAEC,OAAO,EAAK;EAAA,IAAAC,eAAA;EAClD,IAAIC,KAAK,IAAAD,eAAA,GAAGN,UAAU,CAACQ,GAAG,CAACJ,GAAG,CAAC,cAAAE,eAAA,uBAAnBA,eAAA,CAAqBE,GAAG,CAACH,OAAO,CAAC;EAC7C,IAAIE,KAAK,EAAE,OAAOA,KAAK;EAEvBA,KAAK,GAAGJ,IAA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I;IAAA,CAAW,CAAC;EAC1D;EACA,IAAME,cAAc,GAAGnC,SAAS,CAAC8B,QAAQ,CAAC,CAACM,KAAK,CAAC,GAAG,CAAC;EAErD,OAAOT,SAAS,CAACR,MAAM,CAACgB,cAAc,CAAC;AACzC,CAAC;AAACX,OAAA,CAAAC,aAAA,GAAAA,aAAA"}
@@ -0,0 +1,100 @@
1
+ {
2
+ "generic": {
3
+ "error": "Something went wrong. Please try again later."
4
+ },
5
+ "authentication": {
6
+ "notLoggedIn": "Could not authenticate, please login to continue!",
7
+ "couldNotAuth": "Could not authenticate with the provided {{parameter}}.",
8
+ "incorrectPassword": "Current password is incorrect. Please try again.",
9
+ "incorrectEmailPassword": "Incorrect email or password. Please try again."
10
+ },
11
+ "authorization": {
12
+ "unauthorized": "You are not authorized to perform this action."
13
+ },
14
+ "resource": {
15
+ "add_one": "{{entity}} has been added successfully.",
16
+ "add_other": "{{entity}} have been added successfully.",
17
+ "save": "{{entity}} has been saved successfully.",
18
+ "save_one": "{{entity}} has been saved successfully.",
19
+ "save_other": "{{entity}} have been saved successfully.",
20
+ "update": "{{entity}} has been updated successfully.",
21
+ "update_one": "{{entity}} has been updated successfully.",
22
+ "update_other": "{{entity}} have been updated successfully.",
23
+ "delete_one": "{{entity}} has been deleted successfully.",
24
+ "delete_other": "{{entity}} have been deleted successfully.",
25
+ "clone": "{{entity}} has been cloned successfully.",
26
+ "notFound": "{{entity}} does not exist.",
27
+ "remove_one": "{{entity}} has been removed successfully.",
28
+ "remove_other": "{{entity}} have been removed successfully.",
29
+ "sent": "{{entity}} sent successfully.",
30
+ "merged": "{{entity}} have been successfully merged.",
31
+ "disconnected": "{{entity}} has been successfully disconnected."
32
+ },
33
+ "otp": {
34
+ "sent": "OTP has been sent successfully.",
35
+ "invalid": "Invalid OTP",
36
+ "verified": "OTP has been verified successfully."
37
+ },
38
+ "upload": {
39
+ "error": "An error occurred while uploading the file"
40
+ },
41
+ "image": {
42
+ "profile": {
43
+ "removalFailed": "Failed to remove profile picture",
44
+ "removalSuccess": "Profile picture successfully removed"
45
+ },
46
+ "contentTypeInvalid": "Other than jpg, png, svg are not supported",
47
+ "sizeOutOfRange": "Should not be more than {{maxSize, number}} MB"
48
+ },
49
+ "userRole": {
50
+ "deactivateActiveAdmin": "You cannot deactivate active admin from the organization!"
51
+ },
52
+ "activeRecord": {
53
+ "error": {
54
+ "blankName": "Name can't be blank",
55
+ "blankDescription": "Description can't be blank",
56
+ "blankValue": "Value can't be blank",
57
+ "prefixType": "Prefix type {{value}} is not valid",
58
+ "minimumEntryLimit": "Minimum entry limit must be less than or equal to {{maximumEntryLimit, number}}",
59
+ "maximumEntryLimit": "Maximum entry limit must be greater than or equal to {{minimumEntryLimit, number}}"
60
+ }
61
+ },
62
+ "sessions": {
63
+ "expiry": "Your session has expired. Please login again."
64
+ },
65
+ "payment": {
66
+ "error": {
67
+ "incomplete": "Your payment could not be completed"
68
+ }
69
+ },
70
+ "invitations": {
71
+ "deleted_one": "Invitation has been deleted successfully",
72
+ "deleted_other": "{{count, number}} Invitations have been deleted successfully",
73
+ "sent_one": "Invitation has been sent successfully",
74
+ "sent_other": "{{count, number}} Invitations have been sent successfully",
75
+ "notFound": "{{email}} was not invited to test this website."
76
+ },
77
+ "github": {
78
+ "error": {
79
+ "webhookPermissionDenied": "Permission denied. Ensure you have permission to create webhooks for the repository.",
80
+ "primaryNonDeletable": "Primary Github account cannot be deleted."
81
+ }
82
+ },
83
+ "neetoCommons": {
84
+ "fallbackComponent": {
85
+ "somethingWentWrong": "Sorry, something went wrong.",
86
+ "description": "Please try <reloading>reloading</reloading> the page.<br> If the problem persists, <contactus>contact us</contactus>."
87
+ },
88
+ "toastr": {
89
+ "success": {
90
+ "copiedToClipboard": "Copied to clipboard!"
91
+ },
92
+ "error": {
93
+ "networkError": "No Internet Connection"
94
+ }
95
+ },
96
+ "notice": {
97
+ "errorOccurred": "Some error occurred."
98
+ }
99
+ }
100
+ }
@@ -4,5 +4,10 @@ export var HEADERS_KEYS = {
4
4
  accept: "Accept"
5
5
  };
6
6
  export var LOWERCASED = "__LOWERCASED__";
7
- export var ANY_CASE = "anyCase";
7
+ export var FORMATS = {
8
+ boldList: "boldList",
9
+ list: "list",
10
+ anyCase: "anyCase"
11
+ };
12
+ export var LIST_FORMATS = [FORMATS.boldList, FORMATS.list];
8
13
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["HEADERS_KEYS","xCsrfToken","contentType","accept","LOWERCASED","ANY_CASE"],"sources":["../../src/initializers/constants.js"],"sourcesContent":["export const HEADERS_KEYS = {\n xCsrfToken: \"X-CSRF-TOKEN\",\n contentType: \"Content-Type\",\n accept: \"Accept\",\n};\n\nexport const LOWERCASED = \"__LOWERCASED__\";\nexport const ANY_CASE = \"anyCase\";\n"],"mappings":"AAAA,OAAO,IAAMA,YAAY,GAAG;EAC1BC,UAAU,EAAE,cAAc;EAC1BC,WAAW,EAAE,cAAc;EAC3BC,MAAM,EAAE;AACV,CAAC;AAED,OAAO,IAAMC,UAAU,GAAG,gBAAgB;AAC1C,OAAO,IAAMC,QAAQ,GAAG,SAAS"}
1
+ {"version":3,"file":"constants.js","names":["HEADERS_KEYS","xCsrfToken","contentType","accept","LOWERCASED","FORMATS","boldList","list","anyCase","LIST_FORMATS"],"sources":["../../src/initializers/constants.js"],"sourcesContent":["export const HEADERS_KEYS = {\n xCsrfToken: \"X-CSRF-TOKEN\",\n contentType: \"Content-Type\",\n accept: \"Accept\",\n};\n\nexport const LOWERCASED = \"__LOWERCASED__\";\n\nexport const FORMATS = {\n boldList: \"boldList\",\n list: \"list\",\n anyCase: \"anyCase\",\n};\nexport const LIST_FORMATS = [FORMATS.boldList, FORMATS.list];\n"],"mappings":"AAAA,OAAO,IAAMA,YAAY,GAAG;EAC1BC,UAAU,EAAE,cAAc;EAC1BC,WAAW,EAAE,cAAc;EAC3BC,MAAM,EAAE;AACV,CAAC;AAED,OAAO,IAAMC,UAAU,GAAG,gBAAgB;AAE1C,OAAO,IAAMC,OAAO,GAAG;EACrBC,QAAQ,EAAE,UAAU;EACpBC,IAAI,EAAE,MAAM;EACZC,OAAO,EAAE;AACX,CAAC;AACD,OAAO,IAAMC,YAAY,GAAG,CAACJ,OAAO,CAACC,QAAQ,EAAED,OAAO,CAACE,IAAI,CAAC"}
@@ -2,8 +2,9 @@ import i18n from "i18next";
2
2
  import LanguageDetector from "i18next-browser-languagedetector";
3
3
  import { mergeDeepLeft } from "ramda";
4
4
  import { initReactI18next } from "react-i18next";
5
+ import { LIST_FORMATS } from "./constants";
5
6
  import { replaceNullValuesWithGetter } from "./utils";
6
- import { boldListFormatter, lowerCaseDynamicTextFormatter } from "./utils/customFormatters";
7
+ import { listFormatter, lowerCaseDynamicTextFormatter } from "./utils/customFormatters";
7
8
  import { sentenceCaseProcessor } from "./utils/customPostProcessors";
8
9
  import commonsEn from "../translations/en.json";
9
10
 
@@ -40,8 +41,13 @@ var initializeI18n = function initializeI18n(hostTranslations) {
40
41
  alwaysFormat: true,
41
42
  format: function format(value, _format, lng, options) {
42
43
  var newValue = value;
43
- if (_format === "boldList") {
44
- newValue = boldListFormatter(newValue, lng, options);
44
+ if (LIST_FORMATS.includes(_format)) {
45
+ newValue = listFormatter({
46
+ value: newValue,
47
+ format: _format,
48
+ lng: lng,
49
+ options: options
50
+ });
45
51
  return newValue;
46
52
  }
47
53
  return lowerCaseDynamicTextFormatter(newValue, _format);
@@ -1 +1 @@
1
- {"version":3,"file":"i18n.js","names":["i18n","LanguageDetector","mergeDeepLeft","initReactI18next","replaceNullValuesWithGetter","boldListFormatter","lowerCaseDynamicTextFormatter","sentenceCaseProcessor","commonsEn","taxonomies","initializeI18n","hostTranslations","_window$globalProps","packageTranslations","preval","require","commonsTranslations","en","translation","resources","reduce","defaultTaxonomyKeys","Object","keys","taxonomyDefaultLabels","defaultTaxonomies","fromEntries","map","key","singular","plural","hostTaxonomies","window","globalProps","use","init","fallbackLng","interpolation","defaultVariables","escapeValue","skipOnVariables","alwaysFormat","format","value","lng","options","newValue","postProcess","name","detection","order","caches","lookupQuerystring","lookupCookie"],"sources":["../../src/initializers/i18n.js"],"sourcesContent":["import i18n from \"i18next\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\nimport { mergeDeepLeft } from \"ramda\";\nimport { initReactI18next } from \"react-i18next\";\n\nimport { replaceNullValuesWithGetter } from \"./utils\";\nimport {\n boldListFormatter,\n lowerCaseDynamicTextFormatter,\n} from \"./utils/customFormatters\";\nimport { sentenceCaseProcessor } from \"./utils/customPostProcessors\";\n\nimport commonsEn from \"../translations/en.json\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet taxonomies = {};\n\nconst initializeI18n = hostTranslations => {\n // eslint-disable-next-line no-undef\n const packageTranslations = preval.require(\n \"../configs/scripts/getPkgTranslations.js\"\n );\n\n const commonsTranslations = { en: { translation: commonsEn } };\n\n const resources = [\n hostTranslations,\n commonsTranslations,\n packageTranslations,\n ].reduce(mergeDeepLeft);\n\n const defaultTaxonomyKeys = Object.keys(\n resources.en.translation.taxonomyDefaultLabels || {}\n );\n\n const defaultTaxonomies = Object.fromEntries(\n defaultTaxonomyKeys.map(key => [key, { singular: null, plural: null }])\n );\n\n const hostTaxonomies = window.globalProps?.taxonomies || {};\n\n taxonomies = replaceNullValuesWithGetter(\n mergeDeepLeft(hostTaxonomies, defaultTaxonomies)\n );\n\n i18n\n .use(LanguageDetector)\n .use(initReactI18next)\n .use(sentenceCaseProcessor)\n .init({\n resources,\n fallbackLng: \"en\",\n interpolation: {\n defaultVariables: { taxonomies },\n escapeValue: false,\n skipOnVariables: false,\n alwaysFormat: true,\n format: (value, format, lng, options) => {\n let newValue = value;\n if (format === \"boldList\") {\n newValue = boldListFormatter(newValue, lng, options);\n\n return newValue;\n }\n\n return lowerCaseDynamicTextFormatter(newValue, format);\n },\n },\n postProcess: [sentenceCaseProcessor.name],\n detection: {\n order: [\"querystring\", \"cookie\", \"navigator\", \"path\"],\n caches: [\"cookie\"],\n l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6B,cAAc,EAAEN,iBAAiB,CAAC,CACjD;EAEDzB,IAAI,CACDkC,GAAG,CAACjC,gBAAgB,CAAC,CACrBiC,GAAG,CAAC/B,gBAAgB,CAAC,CACrB+B,GAAG,CAAC3B,qBAAqB,CAAC,CAC1B4B,IAAI,CAAC;IACJhB,SAAS,EAATA,SAAS;IACTiB,WAAW,EAAE,IAAI;IACjBC,aAAa,EAAE;MACbC,gBAAgB,EAAE;QAAE7B,UAAU,EAAVA;MAAW,CAAC;MAChC8B,WAAW,EAAE,KAAK;MAClBC,eAAe,EAAE,KAAK;MACtBC,YAAY,EAAE,IAAI;MAClBC,MAAM,EAAE,SAAAA,OAACC,KAAK,EAAED,OAAM,EAAEE,GAAG,EAAEC,OAAO,EAAK;QACvC,IAAIC,QAAQ,GAAGH,KAAK;QACpB,IAAID,OAAM,KAAK,UAAU,EAAE;UACzBI,QAAQ,GAAGzC,iBAAiB,CAACyC,QAAQ,EAAEF,GAAG,EAAEC,OAAO,CAAC;UAEpD,OAAOC,QAAQ;QACjB;QAEA,OAAOxC,6BAA6B,CAACwC,QAAQ,EAAEJ,OAAM,CAAC;MACxD;IACF,CAAC;IACDK,WAAW,EAAE,CAACxC,qBAAqB,CAACyC,IAAI,CAAC;IACzCC,SAAS,EAAE;MACTC,KAAK,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC;MACrDC,MAAM,EAAE,CAAC,QAAQ,CAAC;MAClBC,iBAAiB,EAAE,MAAM;MACzBC,YAAY,EAAE;IAChB;EACF,CAAC,CAAC;AACN,CAAC;AAED,SAAS5C,UAAU;AAEnB,eAAeC,cAAc"}
1
+ {"version":3,"file":"i18n.js","names":["i18n","LanguageDetector","mergeDeepLeft","initReactI18next","LIST_FORMATS","replaceNullValuesWithGetter","listFormatter","lowerCaseDynamicTextFormatter","sentenceCaseProcessor","commonsEn","taxonomies","initializeI18n","hostTranslations","_window$globalProps","packageTranslations","preval","require","commonsTranslations","en","translation","resources","reduce","defaultTaxonomyKeys","Object","keys","taxonomyDefaultLabels","defaultTaxonomies","fromEntries","map","key","singular","plural","hostTaxonomies","window","globalProps","use","init","fallbackLng","interpolation","defaultVariables","escapeValue","skipOnVariables","alwaysFormat","format","value","lng","options","newValue","includes","postProcess","name","detection","order","caches","lookupQuerystring","lookupCookie"],"sources":["../../src/initializers/i18n.js"],"sourcesContent":["import i18n from \"i18next\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\nimport { mergeDeepLeft } from \"ramda\";\nimport { initReactI18next } from \"react-i18next\";\n\nimport { LIST_FORMATS } from \"./constants\";\nimport { replaceNullValuesWithGetter } from \"./utils\";\nimport {\n listFormatter,\n lowerCaseDynamicTextFormatter,\n} from \"./utils/customFormatters\";\nimport { sentenceCaseProcessor } from \"./utils/customPostProcessors\";\n\nimport commonsEn from \"../translations/en.json\";\n\n// eslint-disable-next-line import/no-mutable-exports\nlet taxonomies = {};\n\nconst initializeI18n = hostTranslations => {\n // eslint-disable-next-line no-undef\n const packageTranslations = preval.require(\n \"../configs/scripts/getPkgTranslations.js\"\n );\n\n const commonsTranslations = { en: { translation: commonsEn } };\n\n const resources = [\n hostTranslations,\n commonsTranslations,\n packageTranslations,\n ].reduce(mergeDeepLeft);\n\n const defaultTaxonomyKeys = Object.keys(\n resources.en.translation.taxonomyDefaultLabels || {}\n );\n\n const defaultTaxonomies = Object.fromEntries(\n defaultTaxonomyKeys.map(key => [key, { singular: null, plural: null }])\n );\n\n const hostTaxonomies = window.globalProps?.taxonomies || {};\n\n taxonomies = replaceNullValuesWithGetter(\n mergeDeepLeft(hostTaxonomies, defaultTaxonomies)\n );\n\n i18n\n .use(LanguageDetector)\n .use(initReactI18next)\n .use(sentenceCaseProcessor)\n .init({\n resources,\n fallbackLng: \"en\",\n interpolation: {\n defaultVariables: { taxonomies },\n escapeValue: false,\n skipOnVariables: false,\n alwaysFormat: true,\n format: (value, format, lng, options) => {\n let newValue = value;\n\n if (LIST_FORMATS.includes(format)) {\n newValue = listFormatter({ value: newValue, format, lng, options });\n\n return newValue;\n }\n\n return lowerCaseDynamicTextFormatter(newValue, format);\n },\n },\n postProcess: [sentenceCaseProcessor.name],\n detection: {\n order: [\"querystring\", \"cookie\", \"navigator\", \"path\"],\n caches: [\"cookie\"],\n lookupQuerystring: \"lang\",\n lookupCookie: \"lang\",\n },\n });\n};\n\nexport { taxonomies };\n\nexport default initializeI18n;\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,SAAS;AAC1B,OAAOC,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,aAAa,QAAQ,OAAO;AACrC,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,SAASC,YAAY;AACrB,SAASC,2BAA2B;AACpC,SACEC,aAAa,EACbC,6BAA6B;AAE/B,SAASC,qBAAqB;AAE9B,OAAOC,SAAS;;AAEhB;AACA,IAAIC,UAAU,GAAG,CAAC,CAAC;AAEnB,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAGC,gBAAgB,EAAI;EAAA,IAAAC,mBAAA;EACzC;EACA,IAAMC,mBAAmB,GAAGC,MAAM,CAACC,OAAO,CACxC,0CAA0C,CAC3C;EAED,IAAMC,mBAAmB,GAAG;IAAEC,EAAE,EAAE;MAAEC,WAAW,EAAEV;IAAU;EAAE,CAAC;EAE9D,IAAMW,SAAS,GAAG,CAChBR,gBAAgB,EAChBK,mBAAmB,EACnBH,mBAAmB,CACpB,CAACO,MAAM,CAACnB,aAAa,CAAC;EAEvB,IAAMoB,mBAAmB,GAAGC,MAAM,CAACC,IAAI,CACrCJ,SAAS,CAACF,EAAE,CAACC,WAAW,CAACM,qBAAqB,IAAI,CAAC,CAAC,CACrD;EAED,IAAMC,iBAAiB,GAAGH,MAAM,CAACI,WAAW,CAC1CL,mBAAmB,CAACM,GAAG,CAAC,UAAAC,GAAG;IAAA,OAAI,CAACA,GAAG,EAAE;MAAEC,QAAQ,EAAE,IAAI;MAAEC,MAAM,EAAE;IAAK,CAAC,CAAC;EAAA,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Y,EAAE;IAChB;EACF,CAAC,CAAC;AACN,CAAC;AAED,SAAS7C,UAAU;AAEnB,eAAeC,cAAc"}
@@ -1,5 +1,5 @@
1
1
  import DOMPurify from "dompurify";
2
- import { LOWERCASED, ANY_CASE } from "../constants";
2
+ import { LOWERCASED, FORMATS } from "../constants";
3
3
  var sanitizer = function sanitizer(array) {
4
4
  return DOMPurify.sanitize(array, {
5
5
  USE_PROFILES: {
@@ -18,17 +18,26 @@ var fetchCachedOrInvoke = function fetchCachedOrInvoke(func, lng, options) {
18
18
  return cache;
19
19
  };
20
20
  export var lowerCaseDynamicTextFormatter = function lowerCaseDynamicTextFormatter(value, format) {
21
- if (!value || format === ANY_CASE || typeof value !== "string") return value;
21
+ if (!value || format === FORMATS.anyCase || typeof value !== "string") {
22
+ return value;
23
+ }
22
24
  return LOWERCASED + value.toLocaleLowerCase();
23
25
  };
24
- export var boldListFormatter = function boldListFormatter(array, lng, options) {
26
+ export var listFormatter = function listFormatter(_ref) {
27
+ var value = _ref.value,
28
+ format = _ref.format,
29
+ lng = _ref.lng,
30
+ options = _ref.options;
25
31
  var formatter = fetchCachedOrInvoke(function (lng, options) {
26
32
  return new Intl.ListFormat(lng, options);
27
33
  }, lng, options);
28
- var boldItems = array.map(function (item) {
29
- return "<strong>".concat(item, "</strong>");
30
- });
31
- var sanitizedItems = sanitizer(boldItems).split(",");
34
+ var newValue = value;
35
+ if (format === FORMATS.boldList) {
36
+ newValue = value.map(function (item) {
37
+ return "<strong>".concat(item, "</strong>");
38
+ });
39
+ }
40
+ var sanitizedItems = sanitizer(newValue).split(",");
32
41
  return formatter.format(sanitizedItems);
33
42
  };
34
43
  //# sourceMappingURL=customFormatters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"customFormatters.js","names":["DOMPurify","LOWERCASED","ANY_CASE","sanitizer","array","sanitize","USE_PROFILES","html","cacheStore","Map","fetchCachedOrInvoke","func","lng","options","_cacheStore$get","cache","get","lngCache","set","lowerCaseDynamicTextFormatter","value","format","toLocaleLowerCase","boldListFormatter","formatter","Intl","ListFormat","boldItems","map","item","concat","sanitizedItems","split"],"sources":["../../../src/initializers/utils/customFormatters.js"],"sourcesContent":["import DOMPurify from \"dompurify\";\n\nimport { LOWERCASED, ANY_CASE } from \"../constants\";\n\nconst sanitizer = array =>\n DOMPurify.sanitize(array, { USE_PROFILES: { html: true } });\n\nconst cacheStore = new Map();\n\nconst fetchCachedOrInvoke = (func, lng, options) => {\n let cache = cacheStore.get(lng)?.get(options);\n if (cache) return cache;\n\n cache = func(lng, options);\n const lngCache = cacheStore.get(lng);\n if (lngCache) lngCache.set(options, cache);\n else cacheStore.set(lng, new Map([[options, cache]]));\n\n return cache;\n};\n\nexport const lowerCaseDynamicTextFormatter = (value, format) => {\n if (!value || format === ANY_CASE || typeof value !== \"string\") return value;\n\n return LOWERCASED + value.toLocaleLowerCase();\n};\n\nexport const boldListFormatter = (array, lng, options) => {\n const formatter = fetchCachedOrInvoke(\n (lng, options) => new Intl.ListFormat(lng, options),\n lng,\n options\n );\n const boldItems = array.map(item => `<strong>${item}</strong>`);\n const sanitizedItems = sanitizer(boldItems).split(\",\");\n\n return formatter.format(sanitizedItems);\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,WAAW;AAEjC,SAASC,UAAU,EAAEC,QAAQ;AAE7B,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAGC,KAAK;EAAA,OACrBJ,SAAS,CAACK,QAAQ,CAACD,KAAK,EAAE;IAAEE,YAAY,EAAE;MAAEC,IAAI,EAAE;IAAK;EAAE,CAAC,CAAC;AAAA;AAE7D,IAAMC,UAAU,GAAG,IAAIC,GAAG,EAAE;AAE5B,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAIC,IAAI,EAAEC,GAAG,EAAEC,OAAO,EAAK;EAAA,IAAAC,eAAA;EAClD,IAAIC,KAAK,IAAAD,eAAA,GAAGN,UAAU,CAACQ,GAAG,CAACJ,GAAG,CAAC,cAAAE,eAAA,u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AC"}
1
+ {"version":3,"file":"customFormatters.js","names":["DOMPurify","LOWERCASED","FORMATS","sanitizer","array","sanitize","USE_PROFILES","html","cacheStore","Map","fetchCachedOrInvoke","func","lng","options","_cacheStore$get","cache","get","lngCache","set","lowerCaseDynamicTextFormatter","value","format","anyCase","toLocaleLowerCase","listFormatter","_ref","formatter","Intl","ListFormat","newValue","boldList","map","item","concat","sanitizedItems","split"],"sources":["../../../src/initializers/utils/customFormatters.js"],"sourcesContent":["import DOMPurify from \"dompurify\";\n\nimport { LOWERCASED, FORMATS } from \"../constants\";\n\nconst sanitizer = array =>\n DOMPurify.sanitize(array, { USE_PROFILES: { html: true } });\n\nconst cacheStore = new Map();\n\nconst fetchCachedOrInvoke = (func, lng, options) => {\n let cache = cacheStore.get(lng)?.get(options);\n if (cache) return cache;\n\n cache = func(lng, options);\n const lngCache = cacheStore.get(lng);\n if (lngCache) lngCache.set(options, cache);\n else cacheStore.set(lng, new Map([[options, cache]]));\n\n return cache;\n};\n\nexport const lowerCaseDynamicTextFormatter = (value, format) => {\n if (!value || format === FORMATS.anyCase || typeof value !== \"string\") {\n return value;\n }\n\n return LOWERCASED + value.toLocaleLowerCase();\n};\n\nexport const listFormatter = ({ value, format, lng, options }) => {\n const formatter = fetchCachedOrInvoke(\n (lng, options) => new Intl.ListFormat(lng, options),\n lng,\n options\n );\n\n let newValue = value;\n if (format === FORMATS.boldList) {\n newValue = value.map(item => `<strong>${item}</strong>`);\n }\n const sanitizedItems = sanitizer(newValue).split(\",\");\n\n return formatter.format(sanitizedItems);\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,WAAW;AAEjC,SAASC,UAAU,EAAEC,OAAO;AAE5B,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAGC,KAAK;EAAA,OACrBJ,SAAS,CAACK,QAAQ,CAACD,KAAK,EAAE;IAAEE,YAAY,EAAE;MAAEC,IAAI,EAAE;IAAK;EAAE,CAAC,CAAC;AAAA;AAE7D,IAAMC,UAAU,G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E,GAAG,EAAEC,OAAO;IAAA,OAAK,IAAIc,IAAI,CAACC,UAAU,CAAChB,GAAG,EAAEC,OAAO,CAAC;EAAA,GACnDD,GAAG,EACHC,OAAO,CACR;EAED,IAAIgB,QAAQ,GAAGT,KAAK;EACpB,IAAIC,MAAM,KAAKnB,OAAO,CAAC4B,QAAQ,EAAE;IAC/BD,QAAQ,GAAGT,KAAK,CAACW,GAAG,CAAC,UAAAC,IAAI;MAAA,kBAAAC,MAAA,CAAeD,IAAI;IAAA,CAAW,CAAC;EAC1D;EACA,IAAME,cAAc,GAAG/B,SAAS,CAAC0B,QAAQ,CAAC,CAACM,KAAK,CAAC,GAAG,CAAC;EAErD,OAAOT,SAAS,CAACL,MAAM,CAACa,cAAc,CAAC;AACzC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "3.0.7",
3
+ "version": "3.0.9",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",