@qrvey/utils 1.2.9-21 → 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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.2.9-21*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.2.9-22*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -688,12 +688,12 @@ Output:
688
688
 
689
689
 
690
690
 
691
- ### dist/filters/adapters/FDToFlatUI.js
691
+ ### dist/filters/adapters/FDToLogic.js
692
692
 
693
693
 
694
- #### FDToFlatUI(filterData, datasetsInfo)
694
+ #### FDToLogic(filterData)
695
695
 
696
- Generates a Flattened UI filter structure from Filter Data structure.
696
+ Generates a Filter Logic structure from Filter Data structure.
697
697
 
698
698
 
699
699
 
@@ -703,7 +703,6 @@ Generates a Flattened UI filter structure from Filter Data structure.
703
703
  | Name | Type | Description | |
704
704
  | ---- | ---- | ----------- | -------- |
705
705
  | filterData | | The filter data object. |   |
706
- | datasetsInfo | | Collection of datasets information |   |
707
706
 
708
707
 
709
708
 
@@ -711,13 +710,13 @@ Generates a Flattened UI filter structure from Filter Data structure.
711
710
  ##### Returns
712
711
 
713
712
 
714
- - a flattened UI filters array
713
+ - a filter logic array
715
714
 
716
715
 
717
716
 
718
- #### FD21ToFlatUI(scopes, datasetsInfo)
717
+ #### getLogicBodyFromFD21(filterData)
719
718
 
720
- Generates a Filter Builder Structure from the Filter Data structure v2.1
719
+ Gets the logic body
721
720
 
722
721
 
723
722
 
@@ -726,8 +725,7 @@ Generates a Filter Builder Structure from the Filter Data structure v2.1
726
725
 
727
726
  | Name | Type | Description | |
728
727
  | ---- | ---- | ----------- | -------- |
729
- | scopes | | The filter scope section |   |
730
- | datasetsInfo | | Collection of datasets information |   |
728
+ | filterData | | The filter data object |   |
731
729
 
732
730
 
733
731
 
@@ -735,17 +733,17 @@ Generates a Filter Builder Structure from the Filter Data structure v2.1
735
733
  ##### Returns
736
734
 
737
735
 
738
- - a flattened UI filters array
736
+ - a filter logic array
739
737
 
740
738
 
741
739
 
742
740
 
743
- ### dist/filters/adapters/FDToLogic.js
741
+ ### dist/filters/adapters/FDToFlatUI.js
744
742
 
745
743
 
746
- #### FDToLogic(filterData)
744
+ #### FDToFlatUI(filterData, datasetsInfo)
747
745
 
748
- Generates a Filter Logic structure from Filter Data structure.
746
+ Generates a Flattened UI filter structure from Filter Data structure.
749
747
 
750
748
 
751
749
 
@@ -755,6 +753,7 @@ Generates a Filter Logic structure from Filter Data structure.
755
753
  | Name | Type | Description | |
756
754
  | ---- | ---- | ----------- | -------- |
757
755
  | filterData | | The filter data object. |   |
756
+ | datasetsInfo | | Collection of datasets information |   |
758
757
 
759
758
 
760
759
 
@@ -762,13 +761,13 @@ Generates a Filter Logic structure from Filter Data structure.
762
761
  ##### Returns
763
762
 
764
763
 
765
- - a filter logic array
764
+ - a flattened UI filters array
766
765
 
767
766
 
768
767
 
769
- #### getLogicBodyFromFD21(filterData)
768
+ #### FD21ToFlatUI(scopes, datasetsInfo)
770
769
 
771
- Gets the logic body
770
+ Generates a Filter Builder Structure from the Filter Data structure v2.1
772
771
 
773
772
 
774
773
 
@@ -777,7 +776,8 @@ Gets the logic body
777
776
 
778
777
  | Name | Type | Description | |
779
778
  | ---- | ---- | ----------- | -------- |
780
- | filterData | | The filter data object |   |
779
+ | scopes | | The filter scope section |   |
780
+ | datasetsInfo | | Collection of datasets information |   |
781
781
 
782
782
 
783
783
 
@@ -785,7 +785,7 @@ Gets the logic body
785
785
  ##### Returns
786
786
 
787
787
 
788
- - a filter logic array
788
+ - a flattened UI filters array
789
789
 
790
790
 
791
791
 
@@ -2889,6 +2889,33 @@ try to find this string as a variable on Windows object
2889
2889
 
2890
2890
 
2891
2891
 
2892
+ ### dist/typescript/decorators/Throttled.js
2893
+
2894
+
2895
+ #### Throttled(time)
2896
+
2897
+ (Method Decorator) Throttled Class Method
2898
+
2899
+
2900
+
2901
+
2902
+ ##### Parameters
2903
+
2904
+ | Name | Type | Description | |
2905
+ | ---- | ---- | ----------- | -------- |
2906
+ | time | | (optional) deafult 500 |   |
2907
+
2908
+
2909
+
2910
+
2911
+ ##### Returns
2912
+
2913
+
2914
+ - `Void`
2915
+
2916
+
2917
+
2918
+
2892
2919
  ### dist/typescript/decorators/Debounce.js
2893
2920
 
2894
2921
 
@@ -2916,12 +2943,12 @@ try to find this string as a variable on Windows object
2916
2943
 
2917
2944
 
2918
2945
 
2919
- ### dist/typescript/decorators/Throttled.js
2946
+ ### dist/dates/relative/helpers/getStatementCase.js
2920
2947
 
2921
2948
 
2922
- #### Throttled(time)
2949
+ #### getStatementCase(includeCurrent, isCalendarDate)
2923
2950
 
2924
- (Method Decorator) Throttled Class Method
2951
+ Returns a number/constant that identifies a relative date case
2925
2952
 
2926
2953
 
2927
2954
 
@@ -2930,7 +2957,8 @@ try to find this string as a variable on Windows object
2930
2957
 
2931
2958
  | Name | Type | Description | |
2932
2959
  | ---- | ---- | ----------- | -------- |
2933
- | time | | (optional) deafult 500 |   |
2960
+ | includeCurrent | `boolean` | |   |
2961
+ | isCalendarDate | `boolean` | |   |
2934
2962
 
2935
2963
 
2936
2964
 
@@ -2938,7 +2966,7 @@ try to find this string as a variable on Windows object
2938
2966
  ##### Returns
2939
2967
 
2940
2968
 
2941
- - `Void`
2969
+ - `number`
2942
2970
 
2943
2971
 
2944
2972
 
@@ -2970,12 +2998,12 @@ Build a proper relative date statement type
2970
2998
 
2971
2999
 
2972
3000
 
2973
- ### dist/dates/relative/helpers/getStatementCase.js
3001
+ ### dist/dates/relative/helpers/parseDate.js
2974
3002
 
2975
3003
 
2976
- #### getStatementCase(includeCurrent, isCalendarDate)
3004
+ #### parseDate(date)
2977
3005
 
2978
- Returns a number/constant that identifies a relative date case
3006
+ Parses a string date and returns a dayjs date
2979
3007
 
2980
3008
 
2981
3009
 
@@ -2984,8 +3012,7 @@ Returns a number/constant that identifies a relative date case
2984
3012
 
2985
3013
  | Name | Type | Description | |
2986
3014
  | ---- | ---- | ----------- | -------- |
2987
- | includeCurrent | `boolean` | |   |
2988
- | isCalendarDate | `boolean` | |   |
3015
+ | date | `string` `Dayjs` `Date` | |   |
2989
3016
 
2990
3017
 
2991
3018
 
@@ -2993,17 +3020,17 @@ Returns a number/constant that identifies a relative date case
2993
3020
  ##### Returns
2994
3021
 
2995
3022
 
2996
- - `number`
3023
+ - `Dayjs` A dayjs date
2997
3024
 
2998
3025
 
2999
3026
 
3000
3027
 
3001
- ### dist/dates/relative/helpers/parseDate.js
3028
+ ### dist/filters/helpers/builder/getFilterBuilderGeneralConfig.js
3002
3029
 
3003
3030
 
3004
- #### parseDate(date)
3031
+ #### getFilterBuilderGeneralConfig(config)
3005
3032
 
3006
- Parses a string date and returns a dayjs date
3033
+ Returns a filter builder config object by a any given config
3007
3034
 
3008
3035
 
3009
3036
 
@@ -3012,7 +3039,7 @@ Parses a string date and returns a dayjs date
3012
3039
 
3013
3040
  | Name | Type | Description | |
3014
3041
  | ---- | ---- | ----------- | -------- |
3015
- | date | `string` `Dayjs` `Date` | |   |
3042
+ | config | | any config object |   |
3016
3043
 
3017
3044
 
3018
3045
 
@@ -3020,7 +3047,7 @@ Parses a string date and returns a dayjs date
3020
3047
  ##### Returns
3021
3048
 
3022
3049
 
3023
- - `Dayjs` A dayjs date
3050
+ - The filter builder config object
3024
3051
 
3025
3052
 
3026
3053
 
@@ -3321,12 +3348,12 @@ Gets filters from the logic by the scopes hierarchy.
3321
3348
 
3322
3349
 
3323
3350
 
3324
- ### dist/filters/helpers/builder/getFilterBuilderGeneralConfig.js
3351
+ ### dist/filters/helpers/common/areFiltersEquals.js
3325
3352
 
3326
3353
 
3327
- #### getFilterBuilderGeneralConfig(config)
3354
+ #### areFiltersEquals(filter1, filter2)
3328
3355
 
3329
- Returns a filter builder config object by a any given config
3356
+ Validates if both filters are the same
3330
3357
 
3331
3358
 
3332
3359
 
@@ -3335,7 +3362,8 @@ Returns a filter builder config object by a any given config
3335
3362
 
3336
3363
  | Name | Type | Description | |
3337
3364
  | ---- | ---- | ----------- | -------- |
3338
- | config | | any config object |   |
3365
+ | filter1 | | filter 1 |   |
3366
+ | filter2 | | filter 2 |   |
3339
3367
 
3340
3368
 
3341
3369
 
@@ -3343,17 +3371,17 @@ Returns a filter builder config object by a any given config
3343
3371
  ##### Returns
3344
3372
 
3345
3373
 
3346
- - The filter builder config object
3374
+ - true: the filters are equal; false: the filters are NOT equal
3347
3375
 
3348
3376
 
3349
3377
 
3350
3378
 
3351
- ### dist/filters/helpers/common/areFiltersEquals.js
3379
+ ### dist/filters/helpers/common/excludeFiltersByAggregateColumn.js
3352
3380
 
3353
3381
 
3354
- #### areFiltersEquals(filter1, filter2)
3382
+ #### excludeFiltersByAggregateColumn(filterData)
3355
3383
 
3356
- Validates if both filters are the same
3384
+ Excludes Aggregate Filters in the Filter Data. Excluding filters when the column.aggregate is included.
3357
3385
 
3358
3386
 
3359
3387
 
@@ -3362,8 +3390,7 @@ Validates if both filters are the same
3362
3390
 
3363
3391
  | Name | Type | Description | |
3364
3392
  | ---- | ---- | ----------- | -------- |
3365
- | filter1 | | filter 1 |   |
3366
- | filter2 | | filter 2 |   |
3393
+ | filterData | | The filter data object |   |
3367
3394
 
3368
3395
 
3369
3396
 
@@ -3371,17 +3398,17 @@ Validates if both filters are the same
3371
3398
  ##### Returns
3372
3399
 
3373
3400
 
3374
- - true: the filters are equal; false: the filters are NOT equal
3401
+ - The new filter data object that were excluded the aggregate filters
3375
3402
 
3376
3403
 
3377
3404
 
3378
3405
 
3379
- ### dist/filters/helpers/common/excludeFiltersByAggregateColumn.js
3406
+ ### dist/filters/helpers/common/excludeFiltersByScopes.js
3380
3407
 
3381
3408
 
3382
- #### excludeFiltersByAggregateColumn(filterData)
3409
+ #### excludeFiltersByScopes(filterData, scopes)
3383
3410
 
3384
- Excludes Aggregate Filters in the Filter Data. Excluding filters when the column.aggregate is included.
3411
+ Excludes and returns a filter data without filters by the given scopes
3385
3412
 
3386
3413
 
3387
3414
 
@@ -3390,7 +3417,8 @@ Excludes Aggregate Filters in the Filter Data. Excluding filters when the column
3390
3417
 
3391
3418
  | Name | Type | Description | |
3392
3419
  | ---- | ---- | ----------- | -------- |
3393
- | filterData | | The filter data object |   |
3420
+ | filterData | | The Filter Data |   |
3421
+ | scopes | | collection of scopes to be as filtering parameters |   |
3394
3422
 
3395
3423
 
3396
3424
 
@@ -3398,7 +3426,7 @@ Excludes Aggregate Filters in the Filter Data. Excluding filters when the column
3398
3426
  ##### Returns
3399
3427
 
3400
3428
 
3401
- - The new filter data object that were excluded the aggregate filters
3429
+ - The new Filter Data without filters by the given scopes.
3402
3430
 
3403
3431
 
3404
3432
 
@@ -3440,34 +3468,6 @@ The validation to filter the stored filter is depending on:
3440
3468
 
3441
3469
 
3442
3470
 
3443
- ### dist/filters/helpers/common/excludeFiltersByScopes.js
3444
-
3445
-
3446
- #### excludeFiltersByScopes(filterData, scopes)
3447
-
3448
- Excludes and returns a filter data without filters by the given scopes
3449
-
3450
-
3451
-
3452
-
3453
- ##### Parameters
3454
-
3455
- | Name | Type | Description | |
3456
- | ---- | ---- | ----------- | -------- |
3457
- | filterData | | The Filter Data |   |
3458
- | scopes | | collection of scopes to be as filtering parameters |   |
3459
-
3460
-
3461
-
3462
-
3463
- ##### Returns
3464
-
3465
-
3466
- - The new Filter Data without filters by the given scopes.
3467
-
3468
-
3469
-
3470
-
3471
3471
  ### dist/filters/helpers/common/getFilterColumnLabel.js
3472
3472
 
3473
3473
 
@@ -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
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LANG_DEFAULT = exports.currencyISO = exports.isTextColumn = exports.supportNumericFormatting = exports.isNumericalColumn = exports.isComplexColumn = exports.hasfileSizeProperty = exports.appliesFormatting = exports.DATEGROUP_FORMATTING_UNSUPPORT = exports.QUESTION_FORMAT_SUPPORT = exports.numericalFields = exports.complexFields = exports.textFields = void 0;
3
+ exports.CURRENCY_DEFAULT = exports.LANG_DEFAULT = exports.currencyISO = exports.isTextColumn = exports.supportNumericFormatting = exports.isNumericalColumn = exports.isComplexColumn = exports.hasfileSizeProperty = exports.appliesFormatting = exports.DATEGROUP_FORMATTING_UNSUPPORT = exports.QUESTION_FORMAT_SUPPORT = exports.numericalFields = exports.complexFields = exports.textFields = void 0;
4
4
  const COLUMN_1 = require("../columns/constants/COLUMN");
5
5
  const Charts_Const_1 = require("../constants/Charts.Const");
6
6
  exports.textFields = [COLUMN_1.COLUMN.TEXTFIELD, COLUMN_1.COLUMN.TEXT_CATEGORY, COLUMN_1.COLUMN.TEXT_LABEL, COLUMN_1.COLUMN.TEXT_CATEGORY];
@@ -82,3 +82,4 @@ exports.currencyISO = [
82
82
  { text: 'RM (MYR)', label: 'MYR' }
83
83
  ];
84
84
  exports.LANG_DEFAULT = 'en-US';
85
+ exports.CURRENCY_DEFAULT = { text: '$ (USD)', label: 'USD' };
@@ -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)
@@ -52,12 +53,13 @@ function getLocaleOptions(outputFormat) {
52
53
  const { format, decimals, currency } = outputFormat;
53
54
  switch (format) {
54
55
  case "Currency" /* CURRENCY */: {
55
- const iso = definition_1.currencyISO.find(item => (item.text === currency.text) || (item.text.includes(currency.label)));
56
- 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' };
57
58
  }
58
59
  case "Scientific" /* SCIENTIFIC */: return { style: "decimal" /* DECIMAL */,
59
60
  notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals };
60
61
  case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals };
62
+ case "Abbreviated" /* ABBREVIATED */: return { notation: "compact" /* COMPACT */, maximumFractionDigits: decimals };
61
63
  default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals };
62
64
  }
63
65
  }
@@ -43,5 +43,5 @@ function getOutputFormat(settings) {
43
43
  */
44
44
  function getFormatConfig(settings) {
45
45
  var _a;
46
- return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.lang };
46
+ return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.locale };
47
47
  }
@@ -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;
@@ -46,12 +47,13 @@ function getLocaleOptions(outputFormat) {
46
47
  const { format, decimals, currency } = outputFormat;
47
48
  switch (format) {
48
49
  case "Currency" /* CURRENCY */: {
49
- const iso = currencyISO.find(item => (item.text === currency.text) || (item.text.includes(currency.label)));
50
- 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' };
51
52
  }
52
53
  case "Scientific" /* SCIENTIFIC */: return { style: "decimal" /* DECIMAL */,
53
54
  notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals };
54
55
  case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals };
56
+ case "Abbreviated" /* ABBREVIATED */: return { notation: "compact" /* COMPACT */, maximumFractionDigits: decimals };
55
57
  default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals };
56
58
  }
57
59
  }
@@ -39,5 +39,5 @@ function getOutputFormat(settings) {
39
39
  */
40
40
  function getFormatConfig(settings) {
41
41
  var _a;
42
- return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.lang };
42
+ return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.locale };
43
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.2.9-21",
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",
@@ -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' };
@@ -92,7 +92,7 @@ export const addFormat = (value: any, outputFormat: any = 'None', config?: IForm
92
92
  return config?.lang && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat.format);
93
93
  case 'NUMERIC': {
94
94
  const parse = parseFloat(value);
95
- const withLocale = outputFormat.format !== 'Abbreviated' && outputFormat !== 'None' && config?.lang;
95
+ const withLocale = outputFormat !== 'None' && config?.lang;
96
96
  return isNaN(parse) ? value : withLocale ? formatWithLocale(value, outputFormat, config)
97
97
  : formatNumber(parse, outputFormat, config);
98
98
  }
@@ -1,5 +1,6 @@
1
+ import { isEmpty } from '../general/mix/isEmpty';
1
2
  import { IFormatConfig, IFormatOutputFormat } from '../interfaces';
2
- import { currencyISO, LOCALE_FORMATS, LOCALE_STYLES, LANG_DEFAULT } from './definition';
3
+ import { currencyISO, LOCALE_FORMATS, LOCALE_STYLES, LANG_DEFAULT, CURRENCY_DEFAULT } from './definition';
3
4
 
4
5
  export const getLang = (locale: string | Record<string, any>) => {
5
6
  if (!locale) return;
@@ -49,12 +50,13 @@ function getLocaleOptions(outputFormat: IFormatOutputFormat) {
49
50
  const { format, decimals, currency } = outputFormat;
50
51
  switch(format) {
51
52
  case LOCALE_FORMATS.CURRENCY: {
52
- const iso = currencyISO.find(item => (item.text === currency.text) || (item.text.includes(currency.label)));
53
- return { style: LOCALE_STYLES.CURRENCY, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: 0 };
53
+ const iso = isEmpty(currency) ? CURRENCY_DEFAULT : currencyISO.find(item => (item.text === currency.text) || item.text.includes(currency.label));
54
+ return { style: LOCALE_STYLES.CURRENCY, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: 0, currencyDisplay: 'narrowSymbol' };
54
55
  }
55
56
  case LOCALE_FORMATS.SCIENTIFIC: return { style: LOCALE_STYLES.DECIMAL,
56
57
  notation: LOCALE_STYLES.SCIENTIFIC, maximumFractionDigits: decimals };
57
58
  case LOCALE_FORMATS.PERCENTAGE: return { style: LOCALE_STYLES.PERCENT, maximumFractionDigits: decimals };
59
+ case LOCALE_FORMATS.ABBREVIATED: return { notation: LOCALE_STYLES.COMPACT, maximumFractionDigits: decimals };
58
60
  default: return { style: LOCALE_STYLES.DECIMAL, maximumFractionDigits: decimals };
59
61
  }
60
62
  }
@@ -43,5 +43,5 @@ function getOutputFormat(settings: ITransformValueSettings) {
43
43
  * @returns the format config
44
44
  */
45
45
  function getFormatConfig(settings: ITransformValueSettings) {
46
- return { lang: settings.i18n?.lang };
46
+ return { lang: settings.i18n?.locale };
47
47
  }