@qrvey/utils 1.2.9-19 → 1.2.9-22

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 (79) hide show
  1. package/README.md +125 -125
  2. package/dist/cjs/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
  3. package/dist/cjs/filters/helpers/ui/getUIValues.js +1 -1
  4. package/dist/cjs/filters/interfaces/builder/IFilterBuilderConfig.d.ts +0 -2
  5. package/dist/cjs/filters/interfaces/builder/IFilterBuilderGeneralConfig.d.ts +2 -1
  6. package/dist/cjs/filters/interfaces/panel/IFilterPanelConfig.d.ts +2 -3
  7. package/dist/cjs/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +2 -1
  8. package/dist/cjs/format/definition.d.ts +8 -2
  9. package/dist/cjs/format/definition.js +2 -1
  10. package/dist/cjs/format/format.js +1 -1
  11. package/dist/cjs/format/localization.js +7 -7
  12. package/dist/cjs/globalization/interfaces/II18nConfig.d.ts +6 -0
  13. package/dist/cjs/globalization/interfaces/{IResourceI18n.js → II18nConfig.js} +0 -0
  14. package/dist/cjs/globalization/interfaces/{IResourceI18n.d.ts → II18nResource.d.ts} +1 -1
  15. package/dist/cjs/globalization/interfaces/II18nResource.js +2 -0
  16. package/dist/cjs/globalization/interfaces/bucket_builder/II18nBucketBuilderModalBucket.d.ts +2 -0
  17. package/dist/cjs/globalization/interfaces/formula_builder/II18nFormulaBuilderListModal.d.ts +2 -0
  18. package/dist/cjs/globalization/interfaces/index.d.ts +2 -1
  19. package/dist/cjs/globalization/interfaces/index.js +2 -1
  20. package/dist/cjs/globalization/interfaces/style_themes/II18nStyleThemesTooltips.d.ts +1 -0
  21. package/dist/cjs/globalization/labels/I18N_DEFAULT.d.ts +2 -2
  22. package/dist/cjs/globalization/labels/bucket_builder/I18N_BUCKET_BUILDER.js +2 -0
  23. package/dist/cjs/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.js +3 -1
  24. package/dist/cjs/globalization/labels/style_themes/I18N_STYLE_THEMES.js +1 -0
  25. package/dist/cjs/globalization/service/i18nextBuilder.d.ts +3 -3
  26. package/dist/cjs/globalization/service/initI18n.d.ts +2 -2
  27. package/dist/cjs/qrvey/helpers/transformValue.js +2 -1
  28. package/dist/cjs/qrvey/interfaces/ITransformValueSettings.d.ts +2 -1
  29. package/dist/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
  30. package/dist/filters/helpers/ui/getUIValues.js +1 -1
  31. package/dist/filters/interfaces/builder/IFilterBuilderConfig.d.ts +0 -2
  32. package/dist/filters/interfaces/builder/IFilterBuilderGeneralConfig.d.ts +2 -1
  33. package/dist/filters/interfaces/panel/IFilterPanelConfig.d.ts +2 -3
  34. package/dist/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +2 -1
  35. package/dist/format/definition.d.ts +8 -2
  36. package/dist/format/definition.js +1 -0
  37. package/dist/format/format.js +1 -1
  38. package/dist/format/localization.js +8 -8
  39. package/dist/globalization/interfaces/II18nConfig.d.ts +6 -0
  40. package/dist/globalization/interfaces/{IResourceI18n.js → II18nConfig.js} +0 -0
  41. package/dist/globalization/interfaces/{IResourceI18n.d.ts → II18nResource.d.ts} +1 -1
  42. package/dist/globalization/interfaces/II18nResource.js +1 -0
  43. package/dist/globalization/interfaces/bucket_builder/II18nBucketBuilderModalBucket.d.ts +2 -0
  44. package/dist/globalization/interfaces/formula_builder/II18nFormulaBuilderListModal.d.ts +2 -0
  45. package/dist/globalization/interfaces/index.d.ts +2 -1
  46. package/dist/globalization/interfaces/index.js +2 -1
  47. package/dist/globalization/interfaces/style_themes/II18nStyleThemesTooltips.d.ts +1 -0
  48. package/dist/globalization/labels/I18N_DEFAULT.d.ts +2 -2
  49. package/dist/globalization/labels/bucket_builder/I18N_BUCKET_BUILDER.js +2 -0
  50. package/dist/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.js +3 -1
  51. package/dist/globalization/labels/style_themes/I18N_STYLE_THEMES.js +1 -0
  52. package/dist/globalization/service/i18nextBuilder.d.ts +3 -3
  53. package/dist/globalization/service/initI18n.d.ts +2 -2
  54. package/dist/qrvey/helpers/transformValue.js +2 -1
  55. package/dist/qrvey/interfaces/ITransformValueSettings.d.ts +2 -1
  56. package/package.json +1 -1
  57. package/src/filters/helpers/builder/getFilterBuilderGeneralConfig.ts +1 -1
  58. package/src/filters/helpers/ui/getUIValues.ts +1 -1
  59. package/src/filters/interfaces/builder/IFilterBuilderConfig.ts +0 -2
  60. package/src/filters/interfaces/builder/IFilterBuilderGeneralConfig.ts +3 -1
  61. package/src/filters/interfaces/panel/IFilterPanelConfig.ts +2 -3
  62. package/src/filters/interfaces/ui/IFUTransformFilterValuesSettings.ts +2 -1
  63. package/src/format/definition.ts +4 -1
  64. package/src/format/format.ts +1 -1
  65. package/src/format/localization.ts +6 -6
  66. package/src/globalization/interfaces/II18nConfig.ts +7 -0
  67. package/src/globalization/interfaces/{IResourceI18n.ts → II18nResource.ts} +1 -1
  68. package/src/globalization/interfaces/bucket_builder/II18nBucketBuilderModalBucket.ts +2 -0
  69. package/src/globalization/interfaces/formula_builder/II18nFormulaBuilderListModal.ts +3 -1
  70. package/src/globalization/interfaces/index.ts +2 -1
  71. package/src/globalization/interfaces/style_themes/II18nStyleThemesTooltips.ts +1 -0
  72. package/src/globalization/labels/I18N_DEFAULT.ts +2 -2
  73. package/src/globalization/labels/bucket_builder/I18N_BUCKET_BUILDER.ts +2 -0
  74. package/src/globalization/labels/formula_builder/I18N_FORMULA_BUILDER.ts +3 -1
  75. package/src/globalization/labels/style_themes/I18N_STYLE_THEMES.ts +1 -0
  76. package/src/globalization/service/i18nextBuilder.ts +4 -4
  77. package/src/globalization/service/initI18n.ts +3 -3
  78. package/src/qrvey/helpers/transformValue.ts +1 -1
  79. package/src/qrvey/interfaces/ITransformValueSettings.ts +2 -1
@@ -93,7 +93,7 @@ const addFormat = (value, outputFormat = 'None', config) => {
93
93
  return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? (0, localization_1.formatWithLocale)(value, outputFormat, config) : formatDate(value, outputFormat.format);
94
94
  case 'NUMERIC': {
95
95
  const parse = parseFloat(value);
96
- const withLocale = outputFormat.format !== 'Abbreviated' && outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
96
+ const withLocale = outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
97
97
  return isNaN(parse) ? value : withLocale ? (0, localization_1.formatWithLocale)(value, outputFormat, config)
98
98
  : formatNumber(parse, outputFormat, config);
99
99
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatWithLocale = exports.chooseLang = exports.getLang = void 0;
4
+ const isEmpty_1 = require("../general/mix/isEmpty");
4
5
  const definition_1 = require("./definition");
5
6
  const getLang = (locale) => {
6
7
  if (!locale)
@@ -12,12 +13,10 @@ const getLang = (locale) => {
12
13
  };
13
14
  exports.getLang = getLang;
14
15
  const chooseLang = (config) => {
15
- var _a, _b, _c, _d, _e;
16
+ var _a, _b;
16
17
  const lang = (((_a = config === null || config === void 0 ? void 0 : config.i18n) === null || _a === void 0 ? void 0 : _a.lang) ||
17
- ((_c = (_b = config === null || config === void 0 ? void 0 : config.i18n) === null || _b === void 0 ? void 0 : _b.locale) === null || _c === void 0 ? void 0 : _c.lang) ||
18
- ((_d = config === null || config === void 0 ? void 0 : config.locale) === null || _d === void 0 ? void 0 : _d.lang) ||
19
18
  config.lang);
20
- return ((_e = lang) === null || _e === void 0 ? void 0 : _e.lang) || lang || definition_1.LANG_DEFAULT;
19
+ return ((_b = lang) === null || _b === void 0 ? void 0 : _b.lang) || lang || definition_1.LANG_DEFAULT;
21
20
  };
22
21
  exports.chooseLang = chooseLang;
23
22
  const formatWithLocale = (value, outputFormat, config = {}) => {
@@ -51,15 +50,16 @@ function formatLocaleNumber(value, outputFormat, config) {
51
50
  }
52
51
  }
53
52
  function getLocaleOptions(outputFormat) {
54
- const { format, decimals, currency, backup_currency } = outputFormat;
53
+ const { format, decimals, currency } = outputFormat;
55
54
  switch (format) {
56
55
  case "Currency" /* CURRENCY */: {
57
- const iso = definition_1.currencyISO.find(item => item.text === (currency.text || backup_currency.text));
58
- return { style: "currency" /* CURRENCY */, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: 0 };
56
+ const iso = (0, isEmpty_1.isEmpty)(currency) ? definition_1.CURRENCY_DEFAULT : definition_1.currencyISO.find(item => (item.text === currency.text) || item.text.includes(currency.label));
57
+ return { style: "currency" /* CURRENCY */, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: 0, currencyDisplay: 'narrowSymbol' };
59
58
  }
60
59
  case "Scientific" /* SCIENTIFIC */: return { style: "decimal" /* DECIMAL */,
61
60
  notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals };
62
61
  case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals };
62
+ case "Abbreviated" /* ABBREVIATED */: return { notation: "compact" /* COMPACT */, maximumFractionDigits: decimals };
63
63
  default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals };
64
64
  }
65
65
  }
@@ -0,0 +1,6 @@
1
+ import { II18nResource } from "./II18nResource";
2
+ export interface II18nConfig {
3
+ lang?: string;
4
+ locale?: string;
5
+ lang_object?: II18nResource;
6
+ }
@@ -11,7 +11,7 @@ import { II18nBucketBuilder } from './bucket_builder/II18nBucketBuilder';
11
11
  import { II18nCrossTabs } from './cross_tabs';
12
12
  import { II18nChartBuilder } from '.';
13
13
  import { II18nStyleThemes } from './style_themes/II18nStyleThemes';
14
- export interface IResourceI18n {
14
+ export interface II18nResource {
15
15
  bucket_builder?: II18nBucketBuilder;
16
16
  chart_builder?: II18nChartBuilder;
17
17
  common?: II18nCommon;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,4 +2,6 @@ export interface II18nBucketBuilderModalBucket {
2
2
  add_bucketed_column: string;
3
3
  loading: string;
4
4
  title: string;
5
+ information_text_link: string;
6
+ information_text_text: string;
5
7
  }
@@ -2,4 +2,6 @@ export interface II18nFormulaBuilderListModal {
2
2
  title_header: string;
3
3
  create_button: string;
4
4
  empty_message: string;
5
+ information_text_link: string;
6
+ information_text_text: string;
5
7
  }
@@ -10,6 +10,7 @@ export * from './formula_builder/index';
10
10
  export * from './panel/index';
11
11
  export * from './style_themes/index';
12
12
  export * from './table_charts/index';
13
+ export * from './II18nConfig';
14
+ export * from './II18nResource';
13
15
  export * from './II18nServiceTranslate';
14
16
  export * from './II18nServiceTranslateOption';
15
- export * from './IResourceI18n';
@@ -22,6 +22,7 @@ __exportStar(require("./formula_builder/index"), exports);
22
22
  __exportStar(require("./panel/index"), exports);
23
23
  __exportStar(require("./style_themes/index"), exports);
24
24
  __exportStar(require("./table_charts/index"), exports);
25
+ __exportStar(require("./II18nConfig"), exports);
26
+ __exportStar(require("./II18nResource"), exports);
25
27
  __exportStar(require("./II18nServiceTranslate"), exports);
26
28
  __exportStar(require("./II18nServiceTranslateOption"), exports);
27
- __exportStar(require("./IResourceI18n"), exports);
@@ -1,3 +1,4 @@
1
1
  export interface II18nStyleThemesTooltips {
2
2
  theme_used_in_all_applications: string;
3
+ theme_will_be_used_in_all_applications: string;
3
4
  }
@@ -1,2 +1,2 @@
1
- import { IResourceI18n } from "../interfaces/IResourceI18n";
2
- export declare const I18N_DEFAULT: IResourceI18n;
1
+ import { II18nResource } from "../interfaces/II18nResource";
2
+ export declare const I18N_DEFAULT: II18nResource;
@@ -97,6 +97,8 @@ exports.I18N_BUCKET_BUILDER = {
97
97
  loading: 'Loading dependencies...',
98
98
  title: 'Buckets',
99
99
  add_bucketed_column: 'Add Bucketed Column',
100
+ information_text_link: 'Learn how to',
101
+ information_text_text: 'create and work with buckets',
100
102
  },
101
103
  operator: {
102
104
  greater_than: 'Greater than',
@@ -5,7 +5,9 @@ exports.I18N_FORMULA_BUILDER = {
5
5
  list_modal: {
6
6
  title_header: 'Formulas',
7
7
  create_button: 'Create Formula',
8
- empty_message: 'No Formulas Yet'
8
+ empty_message: 'No Formulas Yet',
9
+ information_text_link: 'Learn how to',
10
+ information_text_text: 'create and work with formulas',
9
11
  },
10
12
  list_table: {
11
13
  name: 'Formula Name',
@@ -53,5 +53,6 @@ exports.I18N_STYLE_THEMES = {
53
53
  title: 'Style Themes',
54
54
  tooltips: {
55
55
  theme_used_in_all_applications: 'This theme is being used in all applications',
56
+ theme_will_be_used_in_all_applications: 'This theme will be used in all applications'
56
57
  }
57
58
  };
@@ -1,9 +1,9 @@
1
- import { IResourceI18n } from "../interfaces";
1
+ import { II18nResource } from '../interfaces/II18nResource';
2
2
  import { II18nServiceTranslateOption } from "../interfaces/II18nServiceTranslateOption";
3
3
  export declare class I18nServiceBuilder {
4
- static buildI18n(i18nDefault: IResourceI18n, i18nResource: IResourceI18n): Promise<I18nService>;
4
+ static buildI18n(i18nDefault: II18nResource, i18nResource: II18nResource): Promise<I18nService>;
5
5
  private static _initI18n;
6
- static setTranslations(i18nDefault: any, i18nResource: IResourceI18n): IResourceI18n;
6
+ static setTranslations(i18nDefault: any, i18nResource: II18nResource): II18nResource;
7
7
  }
8
8
  export declare abstract class I18nService {
9
9
  abstract translate(key: string, options?: II18nServiceTranslateOption): string;
@@ -1,3 +1,3 @@
1
- import { IResourceI18n } from "../interfaces";
1
+ import { II18nResource } from "../interfaces/II18nResource";
2
2
  import { I18nService } from "../service/i18nextBuilder";
3
- export declare function initI18n(i18nConfig?: IResourceI18n, i18nDefault?: IResourceI18n): Promise<I18nService>;
3
+ export declare function initI18n(i18nConfig?: II18nResource, i18nDefault?: II18nResource): Promise<I18nService>;
@@ -42,5 +42,6 @@ function getOutputFormat(settings) {
42
42
  * @returns the format config
43
43
  */
44
44
  function getFormatConfig(settings) {
45
- return { lang: settings.locale };
45
+ var _a;
46
+ return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.locale };
46
47
  }
@@ -1,10 +1,11 @@
1
1
  import { IColumn } from "../../columns/interfaces/IColumn";
2
2
  import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
3
+ import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
3
4
  import { II18nServiceTranslate } from "../../globalization/interfaces/II18nServiceTranslate";
4
5
  export interface ITransformValueSettings {
5
6
  column: IColumn;
6
7
  property: IColumnPropertyType;
7
8
  translate: II18nServiceTranslate;
8
- locale: string;
9
+ i18n: II18nConfig;
9
10
  suffixTranslateLabel?: string;
10
11
  }
@@ -9,7 +9,7 @@ export function getFilterBuilderGeneralConfig(config = {}) {
9
9
  apiKey: getAttribute(config, 'api_key') || config.apiKey,
10
10
  appid: getAttribute(config, 'app_id') || config.appid,
11
11
  domain: config.domain,
12
- locale: config.locale,
12
+ i18n: config.i18n,
13
13
  qv_token: config.qv_token,
14
14
  timezoneControl: getAttribute(config, 'timezone_control') || config.timezoneControl,
15
15
  userid: getAttribute(config, 'user_id') || config.userid,
@@ -42,7 +42,7 @@ export function getUIValues(filter, settings) {
42
42
  case FILTER_VALIDATOR.IS_NULL:
43
43
  case FILTER_VALIDATOR.IS_NOT_NULL:
44
44
  return [{
45
- value: FILTER_VALIDATOR_INFO[filter.validator].label,
45
+ value: (settings === null || settings === void 0 ? void 0 : settings.translate) ? settings.translate('filter.validators.' + filter.validator.toLowerCase() + '_label') : FILTER_VALIDATOR_INFO[filter.validator].label,
46
46
  enabled: settings.addEnableds ? (_a = filter.values[0]) === null || _a === void 0 ? void 0 : _a.enabled : undefined,
47
47
  }];
48
48
  case FILTER_VALIDATOR.IN:
@@ -1,4 +1,3 @@
1
- import { IResourceI18n } from "../../../globalization/interfaces/IResourceI18n";
2
1
  import { IFBLogic } from "../backend/IFBLogic";
3
2
  import { IFBUserFilters } from "../backend/IFBUserFilters";
4
3
  import { IFSColumn } from "../common/IFSColumn";
@@ -15,7 +14,6 @@ import { IFilterBuilderSettings } from "./IFilterBuilderSettings";
15
14
  * Structure for the configuration of the Filter Builder
16
15
  */
17
16
  export interface IFilterBuilderConfig {
18
- i18n?: IResourceI18n;
19
17
  datasets?: string[];
20
18
  filterData?: IFSData;
21
19
  filterLabel?: string;
@@ -1,3 +1,4 @@
1
+ import { II18nConfig } from "../../../globalization/interfaces/II18nConfig";
1
2
  /**
2
3
  * Structure for the Fiter Builder General config
3
4
  */
@@ -7,6 +8,6 @@ export interface IFilterBuilderGeneralConfig {
7
8
  domain: string;
8
9
  qv_token?: string;
9
10
  timezoneControl?: string;
10
- locale?: string;
11
+ i18n?: II18nConfig;
11
12
  userid: string;
12
13
  }
@@ -1,4 +1,4 @@
1
- import { IResourceI18n } from "../../../globalization";
1
+ import { II18nConfig } from "../../../globalization/interfaces/II18nConfig";
2
2
  import { IFilterBuilderConfig } from "../builder/IFilterBuilderConfig";
3
3
  import { IFUDataStore } from "../ui/IFUDataStore";
4
4
  /**
@@ -6,6 +6,5 @@ import { IFUDataStore } from "../ui/IFUDataStore";
6
6
  */
7
7
  export interface IFilterPanelConfig extends IFUDataStore {
8
8
  filterBuilderConfig?: IFilterBuilderConfig;
9
- i18n?: IResourceI18n;
10
- locale?: string;
9
+ i18n?: II18nConfig;
11
10
  }
@@ -1,6 +1,7 @@
1
+ import { II18nConfig } from "../../../globalization/interfaces/II18nConfig";
1
2
  import { II18nServiceTranslate } from "../../../globalization/interfaces/II18nServiceTranslate";
2
3
  export interface IFUTransformFilterValuesSettings {
3
4
  translate: II18nServiceTranslate;
4
- locale: string;
5
+ i18n: II18nConfig;
5
6
  suffixTranslateLabel?: string;
6
7
  }
@@ -19,12 +19,18 @@ export declare const enum LOCALE_FORMATS {
19
19
  DECIMAL = "Decimal",
20
20
  CURRENCY = "Currency",
21
21
  PERCENTAGE = "Percentage",
22
- SCIENTIFIC = "Scientific"
22
+ SCIENTIFIC = "Scientific",
23
+ ABBREVIATED = "Abbreviated"
23
24
  }
24
25
  export declare const enum LOCALE_STYLES {
25
26
  DECIMAL = "decimal",
26
27
  PERCENT = "percent",
27
28
  CURRENCY = "currency",
28
- SCIENTIFIC = "scientific"
29
+ SCIENTIFIC = "scientific",
30
+ COMPACT = "compact"
29
31
  }
30
32
  export declare const LANG_DEFAULT = "en-US";
33
+ export declare const CURRENCY_DEFAULT: {
34
+ text: string;
35
+ label: string;
36
+ };
@@ -73,3 +73,4 @@ export const currencyISO = [
73
73
  { text: 'RM (MYR)', label: 'MYR' }
74
74
  ];
75
75
  export const LANG_DEFAULT = 'en-US';
76
+ export const CURRENCY_DEFAULT = { text: '$ (USD)', label: 'USD' };
@@ -84,7 +84,7 @@ export const addFormat = (value, outputFormat = 'None', config) => {
84
84
  return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat.format);
85
85
  case 'NUMERIC': {
86
86
  const parse = parseFloat(value);
87
- const withLocale = outputFormat.format !== 'Abbreviated' && outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
87
+ const withLocale = outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
88
88
  return isNaN(parse) ? value : withLocale ? formatWithLocale(value, outputFormat, config)
89
89
  : formatNumber(parse, outputFormat, config);
90
90
  }
@@ -1,4 +1,5 @@
1
- import { currencyISO, LANG_DEFAULT } from './definition';
1
+ import { isEmpty } from '../general/mix/isEmpty';
2
+ import { currencyISO, LANG_DEFAULT, CURRENCY_DEFAULT } from './definition';
2
3
  export const getLang = (locale) => {
3
4
  if (!locale)
4
5
  return;
@@ -8,12 +9,10 @@ export const getLang = (locale) => {
8
9
  return { lang: locale === "browser" ? window.navigator.language : locale };
9
10
  };
10
11
  export const chooseLang = (config) => {
11
- var _a, _b, _c, _d, _e;
12
+ var _a, _b;
12
13
  const lang = (((_a = config === null || config === void 0 ? void 0 : config.i18n) === null || _a === void 0 ? void 0 : _a.lang) ||
13
- ((_c = (_b = config === null || config === void 0 ? void 0 : config.i18n) === null || _b === void 0 ? void 0 : _b.locale) === null || _c === void 0 ? void 0 : _c.lang) ||
14
- ((_d = config === null || config === void 0 ? void 0 : config.locale) === null || _d === void 0 ? void 0 : _d.lang) ||
15
14
  config.lang);
16
- return ((_e = lang) === null || _e === void 0 ? void 0 : _e.lang) || lang || LANG_DEFAULT;
15
+ return ((_b = lang) === null || _b === void 0 ? void 0 : _b.lang) || lang || LANG_DEFAULT;
17
16
  };
18
17
  export const formatWithLocale = (value, outputFormat, config = {}) => {
19
18
  switch (outputFormat.type) {
@@ -45,15 +44,16 @@ function formatLocaleNumber(value, outputFormat, config) {
45
44
  }
46
45
  }
47
46
  function getLocaleOptions(outputFormat) {
48
- const { format, decimals, currency, backup_currency } = outputFormat;
47
+ const { format, decimals, currency } = outputFormat;
49
48
  switch (format) {
50
49
  case "Currency" /* CURRENCY */: {
51
- const iso = currencyISO.find(item => item.text === (currency.text || backup_currency.text));
52
- return { style: "currency" /* CURRENCY */, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: 0 };
50
+ const iso = isEmpty(currency) ? CURRENCY_DEFAULT : currencyISO.find(item => (item.text === currency.text) || item.text.includes(currency.label));
51
+ return { style: "currency" /* CURRENCY */, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: 0, currencyDisplay: 'narrowSymbol' };
53
52
  }
54
53
  case "Scientific" /* SCIENTIFIC */: return { style: "decimal" /* DECIMAL */,
55
54
  notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals };
56
55
  case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals };
56
+ case "Abbreviated" /* ABBREVIATED */: return { notation: "compact" /* COMPACT */, maximumFractionDigits: decimals };
57
57
  default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals };
58
58
  }
59
59
  }
@@ -0,0 +1,6 @@
1
+ import { II18nResource } from "./II18nResource";
2
+ export interface II18nConfig {
3
+ lang?: string;
4
+ locale?: string;
5
+ lang_object?: II18nResource;
6
+ }
@@ -11,7 +11,7 @@ import { II18nBucketBuilder } from './bucket_builder/II18nBucketBuilder';
11
11
  import { II18nCrossTabs } from './cross_tabs';
12
12
  import { II18nChartBuilder } from '.';
13
13
  import { II18nStyleThemes } from './style_themes/II18nStyleThemes';
14
- export interface IResourceI18n {
14
+ export interface II18nResource {
15
15
  bucket_builder?: II18nBucketBuilder;
16
16
  chart_builder?: II18nChartBuilder;
17
17
  common?: II18nCommon;
@@ -0,0 +1 @@
1
+ export {};
@@ -2,4 +2,6 @@ export interface II18nBucketBuilderModalBucket {
2
2
  add_bucketed_column: string;
3
3
  loading: string;
4
4
  title: string;
5
+ information_text_link: string;
6
+ information_text_text: string;
5
7
  }
@@ -2,4 +2,6 @@ export interface II18nFormulaBuilderListModal {
2
2
  title_header: string;
3
3
  create_button: string;
4
4
  empty_message: string;
5
+ information_text_link: string;
6
+ information_text_text: string;
5
7
  }
@@ -10,6 +10,7 @@ export * from './formula_builder/index';
10
10
  export * from './panel/index';
11
11
  export * from './style_themes/index';
12
12
  export * from './table_charts/index';
13
+ export * from './II18nConfig';
14
+ export * from './II18nResource';
13
15
  export * from './II18nServiceTranslate';
14
16
  export * from './II18nServiceTranslateOption';
15
- export * from './IResourceI18n';
@@ -10,6 +10,7 @@ export * from './formula_builder/index';
10
10
  export * from './panel/index';
11
11
  export * from './style_themes/index';
12
12
  export * from './table_charts/index';
13
+ export * from './II18nConfig';
14
+ export * from './II18nResource';
13
15
  export * from './II18nServiceTranslate';
14
16
  export * from './II18nServiceTranslateOption';
15
- export * from './IResourceI18n';
@@ -1,3 +1,4 @@
1
1
  export interface II18nStyleThemesTooltips {
2
2
  theme_used_in_all_applications: string;
3
+ theme_will_be_used_in_all_applications: string;
3
4
  }
@@ -1,2 +1,2 @@
1
- import { IResourceI18n } from "../interfaces/IResourceI18n";
2
- export declare const I18N_DEFAULT: IResourceI18n;
1
+ import { II18nResource } from "../interfaces/II18nResource";
2
+ export declare const I18N_DEFAULT: II18nResource;
@@ -94,6 +94,8 @@ export const I18N_BUCKET_BUILDER = {
94
94
  loading: 'Loading dependencies...',
95
95
  title: 'Buckets',
96
96
  add_bucketed_column: 'Add Bucketed Column',
97
+ information_text_link: 'Learn how to',
98
+ information_text_text: 'create and work with buckets',
97
99
  },
98
100
  operator: {
99
101
  greater_than: 'Greater than',
@@ -2,7 +2,9 @@ export const I18N_FORMULA_BUILDER = {
2
2
  list_modal: {
3
3
  title_header: 'Formulas',
4
4
  create_button: 'Create Formula',
5
- empty_message: 'No Formulas Yet'
5
+ empty_message: 'No Formulas Yet',
6
+ information_text_link: 'Learn how to',
7
+ information_text_text: 'create and work with formulas',
6
8
  },
7
9
  list_table: {
8
10
  name: 'Formula Name',
@@ -50,5 +50,6 @@ export const I18N_STYLE_THEMES = {
50
50
  title: 'Style Themes',
51
51
  tooltips: {
52
52
  theme_used_in_all_applications: 'This theme is being used in all applications',
53
+ theme_will_be_used_in_all_applications: 'This theme will be used in all applications'
53
54
  }
54
55
  };
@@ -1,9 +1,9 @@
1
- import { IResourceI18n } from "../interfaces";
1
+ import { II18nResource } from '../interfaces/II18nResource';
2
2
  import { II18nServiceTranslateOption } from "../interfaces/II18nServiceTranslateOption";
3
3
  export declare class I18nServiceBuilder {
4
- static buildI18n(i18nDefault: IResourceI18n, i18nResource: IResourceI18n): Promise<I18nService>;
4
+ static buildI18n(i18nDefault: II18nResource, i18nResource: II18nResource): Promise<I18nService>;
5
5
  private static _initI18n;
6
- static setTranslations(i18nDefault: any, i18nResource: IResourceI18n): IResourceI18n;
6
+ static setTranslations(i18nDefault: any, i18nResource: II18nResource): II18nResource;
7
7
  }
8
8
  export declare abstract class I18nService {
9
9
  abstract translate(key: string, options?: II18nServiceTranslateOption): string;
@@ -1,3 +1,3 @@
1
- import { IResourceI18n } from "../interfaces";
1
+ import { II18nResource } from "../interfaces/II18nResource";
2
2
  import { I18nService } from "../service/i18nextBuilder";
3
- export declare function initI18n(i18nConfig?: IResourceI18n, i18nDefault?: IResourceI18n): Promise<I18nService>;
3
+ export declare function initI18n(i18nConfig?: II18nResource, i18nDefault?: II18nResource): Promise<I18nService>;
@@ -38,5 +38,6 @@ function getOutputFormat(settings) {
38
38
  * @returns the format config
39
39
  */
40
40
  function getFormatConfig(settings) {
41
- return { lang: settings.locale };
41
+ var _a;
42
+ return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.locale };
42
43
  }
@@ -1,10 +1,11 @@
1
1
  import { IColumn } from "../../columns/interfaces/IColumn";
2
2
  import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
3
+ import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
3
4
  import { II18nServiceTranslate } from "../../globalization/interfaces/II18nServiceTranslate";
4
5
  export interface ITransformValueSettings {
5
6
  column: IColumn;
6
7
  property: IColumnPropertyType;
7
8
  translate: II18nServiceTranslate;
8
- locale: string;
9
+ i18n: II18nConfig;
9
10
  suffixTranslateLabel?: string;
10
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.2.9-19",
3
+ "version": "1.2.9-22",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",
@@ -11,7 +11,7 @@ export function getFilterBuilderGeneralConfig(config: any = {}): IFilterBuilderG
11
11
  apiKey: getAttribute(config, 'api_key') || config.apiKey,
12
12
  appid: getAttribute(config, 'app_id') || config.appid,
13
13
  domain: config.domain,
14
- locale: config.locale,
14
+ i18n: config.i18n,
15
15
  qv_token: config.qv_token,
16
16
  timezoneControl: getAttribute(config, 'timezone_control') || config.timezoneControl,
17
17
  userid: getAttribute(config, 'user_id') || config.userid,
@@ -49,7 +49,7 @@ export function getUIValues(filter: IFSFilter, settings?: IFUUIValueSettings): I
49
49
  case FILTER_VALIDATOR.IS_NULL:
50
50
  case FILTER_VALIDATOR.IS_NOT_NULL:
51
51
  return [{
52
- value: FILTER_VALIDATOR_INFO[filter.validator].label,
52
+ value: settings?.translate ? settings.translate('filter.validators.' + filter.validator.toLowerCase() + '_label') : FILTER_VALIDATOR_INFO[filter.validator].label,
53
53
  enabled: settings.addEnableds ? (filter.values as IFSValue[])[0]?.enabled : undefined,
54
54
  }];
55
55
  case FILTER_VALIDATOR.IN:
@@ -1,4 +1,3 @@
1
- import { IResourceI18n } from "../../../globalization/interfaces/IResourceI18n";
2
1
  import { IFBLogic } from "../backend/IFBLogic";
3
2
  import { IFBUserFilters } from "../backend/IFBUserFilters";
4
3
  import { IFSColumn } from "../common/IFSColumn";
@@ -16,7 +15,6 @@ import { IFilterBuilderSettings } from "./IFilterBuilderSettings";
16
15
  * Structure for the configuration of the Filter Builder
17
16
  */
18
17
  export interface IFilterBuilderConfig {
19
- i18n?: IResourceI18n; // Globalization object
20
18
  datasets?: string[]; // Qrvey IDs for displaying their columns in the colum selector. No qrveyids, the column list is not render
21
19
  filterData?: IFSData; // The Filter Data structure
22
20
  filterLabel?: string; // A label for the filter. If filterLabel is provided the old filterLabel is replaced by the new one
@@ -1,3 +1,5 @@
1
+ import { II18nConfig } from "../../../globalization/interfaces/II18nConfig";
2
+
1
3
  /**
2
4
  * Structure for the Fiter Builder General config
3
5
  */
@@ -7,6 +9,6 @@ export interface IFilterBuilderGeneralConfig {
7
9
  domain: string; // The domain of the environment
8
10
  qv_token?: string; // Qrvey Token for RLS
9
11
  timezoneControl?: string; // Offset number for Timezone
10
- locale?: string; // Localization setting
12
+ i18n?: II18nConfig; // The i18n configuration;
11
13
  userid: string; // User ID
12
14
  }
@@ -1,4 +1,4 @@
1
- import { IResourceI18n } from "../../../globalization";
1
+ import { II18nConfig } from "../../../globalization/interfaces/II18nConfig";
2
2
  import { IFilterBuilderConfig } from "../builder/IFilterBuilderConfig";
3
3
  import { IFUDataStore } from "../ui/IFUDataStore";
4
4
 
@@ -7,6 +7,5 @@ import { IFUDataStore } from "../ui/IFUDataStore";
7
7
  */
8
8
  export interface IFilterPanelConfig extends IFUDataStore {
9
9
  filterBuilderConfig?: IFilterBuilderConfig; // Filter Builder config object
10
- i18n?: IResourceI18n;
11
- locale?: string; // Localization setting
10
+ i18n?: II18nConfig; // The i18n configuration;
12
11
  }
@@ -1,7 +1,8 @@
1
+ import { II18nConfig } from "../../../globalization/interfaces/II18nConfig";
1
2
  import { II18nServiceTranslate } from "../../../globalization/interfaces/II18nServiceTranslate";
2
3
 
3
4
  export interface IFUTransformFilterValuesSettings {
4
5
  translate: II18nServiceTranslate; // Function for getting translations
5
- locale: string; // The locale string
6
+ i18n: II18nConfig; // I18n configuration
6
7
  suffixTranslateLabel?: string // The i18n label for the suffix values.
7
8
  }
@@ -91,12 +91,15 @@ export const enum LOCALE_FORMATS {
91
91
  CURRENCY = 'Currency',
92
92
  PERCENTAGE = 'Percentage',
93
93
  SCIENTIFIC = 'Scientific',
94
+ ABBREVIATED = 'Abbreviated'
94
95
  }
95
96
  export const enum LOCALE_STYLES {
96
97
  DECIMAL = 'decimal',
97
98
  PERCENT = 'percent',
98
99
  CURRENCY = 'currency',
99
100
  SCIENTIFIC = 'scientific',
101
+ COMPACT = 'compact'
100
102
  }
101
103
 
102
- export const LANG_DEFAULT = 'en-US';
104
+ export const LANG_DEFAULT = 'en-US';
105
+ export const CURRENCY_DEFAULT = { text: '$ (USD)', label: 'USD' };