@qrvey/utils 1.2.9-23 → 1.2.9-26

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 (32) hide show
  1. package/README.md +81 -81
  2. package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.d.ts +1 -0
  3. package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.js +11 -0
  4. package/dist/cjs/dates/constants/index.d.ts +1 -0
  5. package/dist/cjs/dates/constants/index.js +1 -0
  6. package/dist/cjs/format/definition.d.ts +8 -0
  7. package/dist/cjs/format/definition.js +2 -1
  8. package/dist/cjs/format/localization.js +14 -6
  9. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.d.ts +1 -0
  10. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +1 -0
  11. package/dist/cjs/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
  12. package/dist/cjs/qrvey/helpers/transformValue.js +3 -2
  13. package/dist/dates/constants/DATETIME_COLUMN_FORMAT.d.ts +1 -0
  14. package/dist/dates/constants/DATETIME_COLUMN_FORMAT.js +8 -0
  15. package/dist/dates/constants/index.d.ts +1 -0
  16. package/dist/dates/constants/index.js +1 -0
  17. package/dist/format/definition.d.ts +8 -0
  18. package/dist/format/definition.js +1 -0
  19. package/dist/format/localization.js +15 -7
  20. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.d.ts +1 -0
  21. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +1 -0
  22. package/dist/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
  23. package/dist/qrvey/helpers/transformValue.js +3 -2
  24. package/package.json +1 -1
  25. package/src/dates/constants/DATETIME_COLUMN_FORMAT.ts +8 -0
  26. package/src/dates/constants/index.ts +1 -0
  27. package/src/format/definition.ts +2 -0
  28. package/src/format/localization.ts +14 -7
  29. package/src/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.ts +1 -0
  30. package/src/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.ts +1 -0
  31. package/src/interfaces/format/IFormatOutputFormat.Interface.ts +2 -1
  32. package/src/qrvey/helpers/transformValue.ts +3 -2
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.2.9-23*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.2.9-26*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -2722,69 +2722,68 @@ Gets the format config
2722
2722
 
2723
2723
 
2724
2724
 
2725
- ### dist/stencil/decorators/Config.js
2725
+ ### dist/services/api/getAllDatasets.api.js
2726
2726
 
2727
2727
 
2728
- #### Config()
2729
-
2730
- Stencil.js - Prop Decorator
2731
- Get and Parse the Widget Configuration Object and also provide the ability to get properties in different case styles such as: lower, upper, camel and pascal
2732
- But for this, is required ask for a property in `snake_case` style
2728
+ #### getAllDatasets(config, pickDatasets)
2733
2729
 
2730
+ Get a dataset list from a collection of Qrvey IDs
2734
2731
 
2735
2732
 
2736
2733
 
2737
2734
 
2735
+ ##### Parameters
2738
2736
 
2739
- ##### Examples
2737
+ | Name | Type | Description | |
2738
+ | ---- | ---- | ----------- | -------- |
2739
+ | config | | the widget config. Includes the appid and others configuration properties |   |
2740
+ | pickDatasets | | Collection of Qrvey IDs for filtering the request |   |
2740
2741
 
2741
- ```javascript
2742
- \ @Config() @Prop() settings;
2743
2742
 
2744
- someMethod() {
2745
- this.settings.snake_case //it search for: obj.snake_case || obj.snakeCase || obj.SnakeCase || obj.snakecase || obj.SNAKECASE
2746
- }
2747
- ```
2748
2743
 
2749
2744
 
2750
2745
  ##### Returns
2751
2746
 
2752
2747
 
2753
- - `Void`
2748
+ - a promise
2754
2749
 
2755
2750
 
2756
2751
 
2757
2752
 
2758
- ### dist/stencil/util/createRef.js
2753
+ ### dist/services/api/getAllQrveys.api.js
2759
2754
 
2760
2755
 
2761
- #### createRef()
2756
+ #### getAllQrveys(config, params)
2757
+
2758
+ POST Request for getting Qrveys such as Web Forms and Datasets. Use params for getting precise data
2762
2759
 
2763
- lit implementation of React createRef (https://reactjs.org/docs/refs-and-the-dom.html)
2764
2760
 
2765
2761
 
2766
2762
 
2763
+ ##### Parameters
2764
+
2765
+ | Name | Type | Description | |
2766
+ | ---- | ---- | ----------- | -------- |
2767
+ | config | | Configuration |   |
2768
+ | params | | Object for getting precise data |   |
2769
+
2767
2770
 
2768
2771
 
2769
2772
 
2770
2773
  ##### Returns
2771
2774
 
2772
2775
 
2773
- - function - Function to use in ref prop in html elements
2776
+ - `Void`
2774
2777
 
2775
2778
 
2776
2779
 
2777
2780
 
2778
- ### dist/stencil/util/getConfig.js
2781
+ ### dist/services/api/getDatasetColumns.api.js
2779
2782
 
2780
2783
 
2781
- #### getConfig(cfg)
2784
+ #### getDatasetColumns(qrveyid)
2782
2785
 
2783
- verify the Config object type and try to return a parsed Object
2784
- - In case _cfg_ is a string, first try to make a JSON parse in other case
2785
- try to find this string as a variable on Windows object
2786
- - If _cfg_ is a fuction, tis is invoked and parsed
2787
- - Finally, if is an object, _cfg_ is inmediatly returned
2786
+ Get a dataset by Qrvey ID
2788
2787
 
2789
2788
 
2790
2789
 
@@ -2793,7 +2792,7 @@ try to find this string as a variable on Windows object
2793
2792
 
2794
2793
  | Name | Type | Description | |
2795
2794
  | ---- | ---- | ----------- | -------- |
2796
- | cfg | | |   |
2795
+ | qrveyid | | The Qrvey ID |   |
2797
2796
 
2798
2797
 
2799
2798
 
@@ -2801,55 +2800,52 @@ try to find this string as a variable on Windows object
2801
2800
  ##### Returns
2802
2801
 
2803
2802
 
2804
- - `Void`
2805
-
2806
-
2803
+ - a promise
2807
2804
 
2808
2805
 
2809
- ### dist/services/api/getAllDatasets.api.js
2810
2806
 
2811
2807
 
2812
- #### getAllDatasets(config, pickDatasets)
2808
+ ### dist/stencil/decorators/Config.js
2813
2809
 
2814
- Get a dataset list from a collection of Qrvey IDs
2815
2810
 
2811
+ #### Config()
2816
2812
 
2813
+ Stencil.js - Prop Decorator
2814
+ Get and Parse the Widget Configuration Object and also provide the ability to get properties in different case styles such as: lower, upper, camel and pascal
2815
+ But for this, is required ask for a property in `snake_case` style
2817
2816
 
2818
2817
 
2819
- ##### Parameters
2820
2818
 
2821
- | Name | Type | Description | |
2822
- | ---- | ---- | ----------- | -------- |
2823
- | config | | the widget config. Includes the appid and others configuration properties |   |
2824
- | pickDatasets | | Collection of Qrvey IDs for filtering the request |   |
2825
2819
 
2826
2820
 
2827
2821
 
2822
+ ##### Examples
2828
2823
 
2829
- ##### Returns
2824
+ ```javascript
2825
+ \ @Config() @Prop() settings;
2830
2826
 
2827
+ someMethod() {
2828
+ this.settings.snake_case //it search for: obj.snake_case || obj.snakeCase || obj.SnakeCase || obj.snakecase || obj.SNAKECASE
2829
+ }
2830
+ ```
2831
2831
 
2832
- - a promise
2833
2832
 
2833
+ ##### Returns
2834
2834
 
2835
2835
 
2836
+ - `Void`
2836
2837
 
2837
- ### dist/services/api/getAllQrveys.api.js
2838
2838
 
2839
2839
 
2840
- #### getAllQrveys(config, params)
2841
2840
 
2842
- POST Request for getting Qrveys such as Web Forms and Datasets. Use params for getting precise data
2841
+ ### dist/stencil/util/createRef.js
2843
2842
 
2844
2843
 
2844
+ #### createRef()
2845
2845
 
2846
+ lit implementation of React createRef (https://reactjs.org/docs/refs-and-the-dom.html)
2846
2847
 
2847
- ##### Parameters
2848
2848
 
2849
- | Name | Type | Description | |
2850
- | ---- | ---- | ----------- | -------- |
2851
- | config | | Configuration |   |
2852
- | params | | Object for getting precise data |   |
2853
2849
 
2854
2850
 
2855
2851
 
@@ -2857,17 +2853,21 @@ POST Request for getting Qrveys such as Web Forms and Datasets. Use params for g
2857
2853
  ##### Returns
2858
2854
 
2859
2855
 
2860
- - `Void`
2856
+ - function - Function to use in ref prop in html elements
2861
2857
 
2862
2858
 
2863
2859
 
2864
2860
 
2865
- ### dist/services/api/getDatasetColumns.api.js
2861
+ ### dist/stencil/util/getConfig.js
2866
2862
 
2867
2863
 
2868
- #### getDatasetColumns(qrveyid)
2864
+ #### getConfig(cfg)
2869
2865
 
2870
- Get a dataset by Qrvey ID
2866
+ verify the Config object type and try to return a parsed Object
2867
+ - In case _cfg_ is a string, first try to make a JSON parse in other case
2868
+ try to find this string as a variable on Windows object
2869
+ - If _cfg_ is a fuction, tis is invoked and parsed
2870
+ - Finally, if is an object, _cfg_ is inmediatly returned
2871
2871
 
2872
2872
 
2873
2873
 
@@ -2876,7 +2876,7 @@ Get a dataset by Qrvey ID
2876
2876
 
2877
2877
  | Name | Type | Description | |
2878
2878
  | ---- | ---- | ----------- | -------- |
2879
- | qrveyid | | The Qrvey ID |   |
2879
+ | cfg | | |   |
2880
2880
 
2881
2881
 
2882
2882
 
@@ -2884,7 +2884,7 @@ Get a dataset by Qrvey ID
2884
2884
  ##### Returns
2885
2885
 
2886
2886
 
2887
- - a promise
2887
+ - `Void`
2888
2888
 
2889
2889
 
2890
2890
 
@@ -3468,6 +3468,33 @@ Excludes and returns a filter data without filters by the given scopes
3468
3468
 
3469
3469
 
3470
3470
 
3471
+ ### dist/filters/helpers/common/getFilterColumnLabel.js
3472
+
3473
+
3474
+ #### getFilterColumnLabel(column)
3475
+
3476
+ Get an string of the properties of the given filter column.
3477
+
3478
+
3479
+
3480
+
3481
+ ##### Parameters
3482
+
3483
+ | Name | Type | Description | |
3484
+ | ---- | ---- | ----------- | -------- |
3485
+ | column | | The filter column |   |
3486
+
3487
+
3488
+
3489
+
3490
+ ##### Returns
3491
+
3492
+
3493
+ - an string with the property, aggregate or calculation label.
3494
+
3495
+
3496
+
3497
+
3471
3498
  ### dist/filters/helpers/common/getFilterLabel.js
3472
3499
 
3473
3500
 
@@ -4453,31 +4480,4 @@ Resolves conditions between UI flattened filter and given parameters
4453
4480
 
4454
4481
 
4455
4482
 
4456
- ### dist/filters/helpers/common/getFilterColumnLabel.js
4457
-
4458
-
4459
- #### getFilterColumnLabel(column)
4460
-
4461
- Get an string of the properties of the given filter column.
4462
-
4463
-
4464
-
4465
-
4466
- ##### Parameters
4467
-
4468
- | Name | Type | Description | |
4469
- | ---- | ---- | ----------- | -------- |
4470
- | column | | The filter column |   |
4471
-
4472
-
4473
-
4474
-
4475
- ##### Returns
4476
-
4477
-
4478
- - an string with the property, aggregate or calculation label.
4479
-
4480
-
4481
-
4482
-
4483
4483
  *Documentation generated with [doxdox](https://github.com/neogeek/doxdox).*
@@ -0,0 +1 @@
1
+ export declare const DATETIME_COLUMN_FORMAT: string[];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DATETIME_COLUMN_FORMAT = void 0;
4
+ exports.DATETIME_COLUMN_FORMAT = [
5
+ 'MM/DD/YYYY HH24:MM:SS',
6
+ 'DD/MM/YYYY HH24:MM:SS',
7
+ 'YYYY-MM-DD HH24:MM:SS',
8
+ 'MM/DD/YYYY HH24:MI:SS',
9
+ 'DD/MM/YYYY HH24:MI:SS',
10
+ 'YYYY-MM-DD HH24:MI:SS'
11
+ ];
@@ -32,3 +32,4 @@ export * from './DATE_YEAR_MONTHS';
32
32
  export * from './DATE_YEAR_MONTHS_MMMM';
33
33
  export * from './DATE_YEAR_QUARTERS';
34
34
  export * from './DATE_YEAR_QUARTERS_RANGE';
35
+ export * from './DATETIME_COLUMN_FORMAT';
@@ -44,3 +44,4 @@ __exportStar(require("./DATE_YEAR_MONTHS"), exports);
44
44
  __exportStar(require("./DATE_YEAR_MONTHS_MMMM"), exports);
45
45
  __exportStar(require("./DATE_YEAR_QUARTERS"), exports);
46
46
  __exportStar(require("./DATE_YEAR_QUARTERS_RANGE"), exports);
47
+ __exportStar(require("./DATETIME_COLUMN_FORMAT"), exports);
@@ -34,3 +34,11 @@ export declare const CURRENCY_DEFAULT: {
34
34
  text: string;
35
35
  label: string;
36
36
  };
37
+ export declare const DATETIME_OPTIONS: {
38
+ year: string;
39
+ month: string;
40
+ day: string;
41
+ hour: string;
42
+ minute: string;
43
+ second: string;
44
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.DATETIME_OPTIONS = 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];
@@ -83,3 +83,4 @@ exports.currencyISO = [
83
83
  ];
84
84
  exports.LANG_DEFAULT = 'en-US';
85
85
  exports.CURRENCY_DEFAULT = { text: '$ (USD)', label: 'USD' };
86
+ exports.DATETIME_OPTIONS = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
@@ -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 __1 = require("..");
4
5
  const isEmpty_1 = require("../general/mix/isEmpty");
5
6
  const definition_1 = require("./definition");
6
7
  const getLang = (locale) => {
@@ -23,30 +24,37 @@ const formatWithLocale = (value, outputFormat, config = {}) => {
23
24
  switch (outputFormat.type) {
24
25
  case 'DATE':
25
26
  case 'DATETIME':
26
- return formatLocaleDate(value, config);
27
+ return formatLocaleDate(value, outputFormat, config);
27
28
  case 'NUMERIC':
28
29
  return formatLocaleNumber(value, outputFormat, config);
29
30
  }
30
31
  };
31
32
  exports.formatWithLocale = formatWithLocale;
32
- function formatLocaleDate(value, config) {
33
+ function formatLocaleDate(value, outputFormat, config) {
33
34
  const { lang = definition_1.LANG_DEFAULT, options } = config;
34
35
  const dateParam = new Date(value);
36
+ let langOpts = options;
37
+ if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
38
+ const { format } = outputFormat.originalFormat;
39
+ if (__1.DATETIME_COLUMN_FORMAT.includes(format))
40
+ langOpts = definition_1.DATETIME_OPTIONS;
41
+ }
35
42
  try {
36
- return new Intl.DateTimeFormat([lang, definition_1.LANG_DEFAULT], options).format(dateParam);
43
+ return new Intl.DateTimeFormat([lang, definition_1.LANG_DEFAULT], langOpts).format(dateParam);
37
44
  }
38
45
  catch (error) {
39
- return new Intl.DateTimeFormat(definition_1.LANG_DEFAULT, options).format(dateParam);
46
+ return (0, isEmpty_1.isEmpty)(dateParam) ? value : new Intl.DateTimeFormat(definition_1.LANG_DEFAULT, langOpts).format(dateParam);
40
47
  }
41
48
  }
42
49
  function formatLocaleNumber(value, outputFormat, config) {
43
50
  const { lang = definition_1.LANG_DEFAULT, options } = config;
44
51
  const langOpts = options || getLocaleOptions(outputFormat);
52
+ const valueToFormat = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Percentage" /* PERCENTAGE */ ? value / 100 : value;
45
53
  try {
46
- return new Intl.NumberFormat([lang, definition_1.LANG_DEFAULT], langOpts).format(value);
54
+ return new Intl.NumberFormat([lang, definition_1.LANG_DEFAULT], langOpts).format(valueToFormat);
47
55
  }
48
56
  catch (e) {
49
- return new Intl.NumberFormat(definition_1.LANG_DEFAULT, langOpts).format(value);
57
+ return new Intl.NumberFormat(definition_1.LANG_DEFAULT, langOpts).format(valueToFormat);
50
58
  }
51
59
  }
52
60
  function getLocaleOptions(outputFormat) {
@@ -8,6 +8,7 @@ export interface II18nChartBuilderDimensions {
8
8
  geolocation: string;
9
9
  group: string;
10
10
  groups: string;
11
+ other_value: string;
11
12
  other_values: string;
12
13
  pivot: string;
13
14
  row: string;
@@ -79,6 +79,7 @@ exports.I18N_CHART_BUILDER_GENERAL = {
79
79
  geolocation: 'Geolocation',
80
80
  group: 'Group',
81
81
  groups: 'Groups',
82
+ other_value: 'Other Value',
82
83
  other_values: 'Other Values',
83
84
  pivot: 'Pivot',
84
85
  row: 'Row',
@@ -5,4 +5,5 @@ export interface IFormatOutputFormat {
5
5
  decimals?: number;
6
6
  currency?: IFormatCurrency;
7
7
  backup_currency?: IFormatCurrency;
8
+ originalFormat?: any;
8
9
  }
@@ -27,14 +27,15 @@ exports.transformValue = transformValue;
27
27
  */
28
28
  function getOutputFormat(settings) {
29
29
  let type, format;
30
- if ((0, isDateColumn_1.isDateColumn)(settings.column) && [DATE_GROUPING_PROPERTY_1.DATE_GROUPING_PROPERTY.DAY, DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.HOUR, DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.MINUTE, DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.SECOND].includes(settings.property)) {
30
+ const isDateTime = [DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.HOUR, DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.MINUTE, DATE_GROUPING_TIME_PROPERTY_1.DATE_GROUPING_TIME_PROPERTY.SECOND].includes(settings.property);
31
+ if ((0, isDateColumn_1.isDateColumn)(settings.column) && [DATE_GROUPING_PROPERTY_1.DATE_GROUPING_PROPERTY.DAY].includes(settings.property) && isDateTime) {
31
32
  type = 'DATE';
32
33
  format = 'Default';
33
34
  }
34
35
  else if ((0, isNumericalColumn_1.isNumericalColumn)(settings.column)) {
35
36
  type = 'NUMERIC';
36
37
  }
37
- return { type, format };
38
+ return { type, format, originalFormat: isDateTime ? settings.column.outputFormat : undefined };
38
39
  }
39
40
  /**
40
41
  * Gets the format config
@@ -0,0 +1 @@
1
+ export declare const DATETIME_COLUMN_FORMAT: string[];
@@ -0,0 +1,8 @@
1
+ export const DATETIME_COLUMN_FORMAT = [
2
+ 'MM/DD/YYYY HH24:MM:SS',
3
+ 'DD/MM/YYYY HH24:MM:SS',
4
+ 'YYYY-MM-DD HH24:MM:SS',
5
+ 'MM/DD/YYYY HH24:MI:SS',
6
+ 'DD/MM/YYYY HH24:MI:SS',
7
+ 'YYYY-MM-DD HH24:MI:SS'
8
+ ];
@@ -32,3 +32,4 @@ export * from './DATE_YEAR_MONTHS';
32
32
  export * from './DATE_YEAR_MONTHS_MMMM';
33
33
  export * from './DATE_YEAR_QUARTERS';
34
34
  export * from './DATE_YEAR_QUARTERS_RANGE';
35
+ export * from './DATETIME_COLUMN_FORMAT';
@@ -32,3 +32,4 @@ export * from './DATE_YEAR_MONTHS';
32
32
  export * from './DATE_YEAR_MONTHS_MMMM';
33
33
  export * from './DATE_YEAR_QUARTERS';
34
34
  export * from './DATE_YEAR_QUARTERS_RANGE';
35
+ export * from './DATETIME_COLUMN_FORMAT';
@@ -34,3 +34,11 @@ export declare const CURRENCY_DEFAULT: {
34
34
  text: string;
35
35
  label: string;
36
36
  };
37
+ export declare const DATETIME_OPTIONS: {
38
+ year: string;
39
+ month: string;
40
+ day: string;
41
+ hour: string;
42
+ minute: string;
43
+ second: string;
44
+ };
@@ -74,3 +74,4 @@ export const currencyISO = [
74
74
  ];
75
75
  export const LANG_DEFAULT = 'en-US';
76
76
  export const CURRENCY_DEFAULT = { text: '$ (USD)', label: 'USD' };
77
+ export const DATETIME_OPTIONS = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
@@ -1,5 +1,6 @@
1
+ import { DATETIME_COLUMN_FORMAT } from '..';
1
2
  import { isEmpty } from '../general/mix/isEmpty';
2
- import { currencyISO, LANG_DEFAULT, CURRENCY_DEFAULT } from './definition';
3
+ import { currencyISO, LANG_DEFAULT, CURRENCY_DEFAULT, DATETIME_OPTIONS } from './definition';
3
4
  export const getLang = (locale) => {
4
5
  if (!locale)
5
6
  return;
@@ -18,29 +19,36 @@ export const formatWithLocale = (value, outputFormat, config = {}) => {
18
19
  switch (outputFormat.type) {
19
20
  case 'DATE':
20
21
  case 'DATETIME':
21
- return formatLocaleDate(value, config);
22
+ return formatLocaleDate(value, outputFormat, config);
22
23
  case 'NUMERIC':
23
24
  return formatLocaleNumber(value, outputFormat, config);
24
25
  }
25
26
  };
26
- function formatLocaleDate(value, config) {
27
+ function formatLocaleDate(value, outputFormat, config) {
27
28
  const { lang = LANG_DEFAULT, options } = config;
28
29
  const dateParam = new Date(value);
30
+ let langOpts = options;
31
+ if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
32
+ const { format } = outputFormat.originalFormat;
33
+ if (DATETIME_COLUMN_FORMAT.includes(format))
34
+ langOpts = DATETIME_OPTIONS;
35
+ }
29
36
  try {
30
- return new Intl.DateTimeFormat([lang, LANG_DEFAULT], options).format(dateParam);
37
+ return new Intl.DateTimeFormat([lang, LANG_DEFAULT], langOpts).format(dateParam);
31
38
  }
32
39
  catch (error) {
33
- return new Intl.DateTimeFormat(LANG_DEFAULT, options).format(dateParam);
40
+ return isEmpty(dateParam) ? value : new Intl.DateTimeFormat(LANG_DEFAULT, langOpts).format(dateParam);
34
41
  }
35
42
  }
36
43
  function formatLocaleNumber(value, outputFormat, config) {
37
44
  const { lang = LANG_DEFAULT, options } = config;
38
45
  const langOpts = options || getLocaleOptions(outputFormat);
46
+ const valueToFormat = (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Percentage" /* PERCENTAGE */ ? value / 100 : value;
39
47
  try {
40
- return new Intl.NumberFormat([lang, LANG_DEFAULT], langOpts).format(value);
48
+ return new Intl.NumberFormat([lang, LANG_DEFAULT], langOpts).format(valueToFormat);
41
49
  }
42
50
  catch (e) {
43
- return new Intl.NumberFormat(LANG_DEFAULT, langOpts).format(value);
51
+ return new Intl.NumberFormat(LANG_DEFAULT, langOpts).format(valueToFormat);
44
52
  }
45
53
  }
46
54
  function getLocaleOptions(outputFormat) {
@@ -8,6 +8,7 @@ export interface II18nChartBuilderDimensions {
8
8
  geolocation: string;
9
9
  group: string;
10
10
  groups: string;
11
+ other_value: string;
11
12
  other_values: string;
12
13
  pivot: string;
13
14
  row: string;
@@ -76,6 +76,7 @@ export const I18N_CHART_BUILDER_GENERAL = {
76
76
  geolocation: 'Geolocation',
77
77
  group: 'Group',
78
78
  groups: 'Groups',
79
+ other_value: 'Other Value',
79
80
  other_values: 'Other Values',
80
81
  pivot: 'Pivot',
81
82
  row: 'Row',
@@ -5,4 +5,5 @@ export interface IFormatOutputFormat {
5
5
  decimals?: number;
6
6
  currency?: IFormatCurrency;
7
7
  backup_currency?: IFormatCurrency;
8
+ originalFormat?: any;
8
9
  }
@@ -23,14 +23,15 @@ export function transformValue(value, settings) {
23
23
  */
24
24
  function getOutputFormat(settings) {
25
25
  let type, format;
26
- if (isDateColumn(settings.column) && [DATE_GROUPING_PROPERTY.DAY, DATE_GROUPING_TIME_PROPERTY.HOUR, DATE_GROUPING_TIME_PROPERTY.MINUTE, DATE_GROUPING_TIME_PROPERTY.SECOND].includes(settings.property)) {
26
+ const isDateTime = [DATE_GROUPING_TIME_PROPERTY.HOUR, DATE_GROUPING_TIME_PROPERTY.MINUTE, DATE_GROUPING_TIME_PROPERTY.SECOND].includes(settings.property);
27
+ if (isDateColumn(settings.column) && [DATE_GROUPING_PROPERTY.DAY].includes(settings.property) && isDateTime) {
27
28
  type = 'DATE';
28
29
  format = 'Default';
29
30
  }
30
31
  else if (isNumericalColumn(settings.column)) {
31
32
  type = 'NUMERIC';
32
33
  }
33
- return { type, format };
34
+ return { type, format, originalFormat: isDateTime ? settings.column.outputFormat : undefined };
34
35
  }
35
36
  /**
36
37
  * Gets the format config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.2.9-23",
3
+ "version": "1.2.9-26",
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",
@@ -0,0 +1,8 @@
1
+ export const DATETIME_COLUMN_FORMAT = [
2
+ 'MM/DD/YYYY HH24:MM:SS',
3
+ 'DD/MM/YYYY HH24:MM:SS',
4
+ 'YYYY-MM-DD HH24:MM:SS',
5
+ 'MM/DD/YYYY HH24:MI:SS',
6
+ 'DD/MM/YYYY HH24:MI:SS',
7
+ 'YYYY-MM-DD HH24:MI:SS'
8
+ ];
@@ -40,3 +40,4 @@ export * from './DATE_YEAR_MONTHS';
40
40
  export * from './DATE_YEAR_MONTHS_MMMM';
41
41
  export * from './DATE_YEAR_QUARTERS';
42
42
  export * from './DATE_YEAR_QUARTERS_RANGE';
43
+ export * from './DATETIME_COLUMN_FORMAT';
@@ -103,3 +103,5 @@ export const enum LOCALE_STYLES {
103
103
 
104
104
  export const LANG_DEFAULT = 'en-US';
105
105
  export const CURRENCY_DEFAULT = { text: '$ (USD)', label: 'USD' };
106
+ export const DATETIME_OPTIONS = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
107
+
@@ -1,6 +1,7 @@
1
+ import { DATETIME_COLUMN_FORMAT } from '..';
1
2
  import { isEmpty } from '../general/mix/isEmpty';
2
3
  import { IFormatConfig, IFormatOutputFormat } from '../interfaces';
3
- import { currencyISO, LOCALE_FORMATS, LOCALE_STYLES, LANG_DEFAULT, CURRENCY_DEFAULT } from './definition';
4
+ import { currencyISO, LOCALE_FORMATS, LOCALE_STYLES, LANG_DEFAULT, CURRENCY_DEFAULT, DATETIME_OPTIONS } from './definition';
4
5
 
5
6
  export const getLang = (locale: string | Record<string, any>) => {
6
7
  if (!locale) return;
@@ -20,29 +21,35 @@ export const formatWithLocale = (value: any, outputFormat: IFormatOutputFormat,
20
21
  switch (outputFormat.type) {
21
22
  case 'DATE':
22
23
  case 'DATETIME':
23
- return formatLocaleDate(value, config);
24
+ return formatLocaleDate(value, outputFormat, config);
24
25
  case 'NUMERIC':
25
26
  return formatLocaleNumber(value, outputFormat, config);
26
27
  }
27
28
  };
28
29
 
29
- function formatLocaleDate(value: any, config: IFormatConfig) {
30
+ function formatLocaleDate(value: any, outputFormat: IFormatOutputFormat, config: IFormatConfig) {
30
31
  const { lang = LANG_DEFAULT, options } = config;
31
32
  const dateParam = new Date(value);
33
+ let langOpts = options;
34
+ if (outputFormat?.originalFormat) {
35
+ const { format } = outputFormat.originalFormat;
36
+ if (DATETIME_COLUMN_FORMAT.includes(format)) langOpts = DATETIME_OPTIONS;
37
+ }
32
38
  try {
33
- return new Intl.DateTimeFormat([lang, LANG_DEFAULT], options).format(dateParam);
39
+ return new Intl.DateTimeFormat([lang, LANG_DEFAULT], langOpts).format(dateParam);
34
40
  } catch (error) {
35
- return new Intl.DateTimeFormat(LANG_DEFAULT, options).format(dateParam);
41
+ return isEmpty(dateParam) ? value : new Intl.DateTimeFormat(LANG_DEFAULT, langOpts).format(dateParam);
36
42
  }
37
43
  }
38
44
 
39
45
  function formatLocaleNumber(value: any, outputFormat: IFormatOutputFormat, config: IFormatConfig,) {
40
46
  const { lang = LANG_DEFAULT, options } = config;
41
47
  const langOpts = options || getLocaleOptions(outputFormat);
48
+ const valueToFormat = outputFormat?.format === LOCALE_FORMATS.PERCENTAGE ? value/100 : value;
42
49
  try {
43
- return new Intl.NumberFormat([lang, LANG_DEFAULT], langOpts).format(value);
50
+ return new Intl.NumberFormat([lang, LANG_DEFAULT], langOpts).format(valueToFormat);
44
51
  } catch (e) {
45
- return new Intl.NumberFormat(LANG_DEFAULT, langOpts).format(value);
52
+ return new Intl.NumberFormat(LANG_DEFAULT, langOpts).format(valueToFormat);
46
53
  }
47
54
  }
48
55
 
@@ -8,6 +8,7 @@ export interface II18nChartBuilderDimensions {
8
8
  geolocation: string;
9
9
  group: string;
10
10
  groups: string;
11
+ other_value: string;
11
12
  other_values: string;
12
13
  pivot: string;
13
14
  row: string;
@@ -85,6 +85,7 @@ export const I18N_CHART_BUILDER_GENERAL: Pick<II18nChartBuilder, General> = {
85
85
  geolocation: 'Geolocation',
86
86
  group: 'Group',
87
87
  groups: 'Groups',
88
+ other_value: 'Other Value',
88
89
  other_values: 'Other Values',
89
90
  pivot: 'Pivot',
90
91
  row: 'Row',
@@ -6,4 +6,5 @@ export interface IFormatOutputFormat {
6
6
  decimals?: number;
7
7
  currency?: IFormatCurrency;
8
8
  backup_currency?: IFormatCurrency;
9
- }
9
+ originalFormat?: any;
10
+ }
@@ -28,13 +28,14 @@ export function transformValue(value: string, settings: ITransformValueSettings)
28
28
  */
29
29
  function getOutputFormat(settings: ITransformValueSettings) {
30
30
  let type, format;
31
- if (isDateColumn(settings.column) && [DATE_GROUPING_PROPERTY.DAY, DATE_GROUPING_TIME_PROPERTY.HOUR, DATE_GROUPING_TIME_PROPERTY.MINUTE, DATE_GROUPING_TIME_PROPERTY.SECOND].includes(settings.property as any)) {
31
+ const isDateTime = [DATE_GROUPING_TIME_PROPERTY.HOUR, DATE_GROUPING_TIME_PROPERTY.MINUTE, DATE_GROUPING_TIME_PROPERTY.SECOND].includes(settings.property as any);
32
+ if (isDateColumn(settings.column) && [DATE_GROUPING_PROPERTY.DAY].includes(settings.property as any) && isDateTime) {
32
33
  type = 'DATE';
33
34
  format = 'Default';
34
35
  } else if (isNumericalColumn(settings.column)) {
35
36
  type = 'NUMERIC';
36
37
  }
37
- return { type, format };
38
+ return { type, format, originalFormat: isDateTime ? settings.column.outputFormat : undefined };
38
39
  }
39
40
 
40
41
  /**