@qrvey/utils 1.2.9-23 → 1.2.9-24

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 (29) hide show
  1. package/README.md +347 -347
  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 +11 -4
  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/dates/constants/DATETIME_COLUMN_FORMAT.d.ts +1 -0
  13. package/dist/dates/constants/DATETIME_COLUMN_FORMAT.js +8 -0
  14. package/dist/dates/constants/index.d.ts +1 -0
  15. package/dist/dates/constants/index.js +1 -0
  16. package/dist/format/definition.d.ts +8 -0
  17. package/dist/format/definition.js +1 -0
  18. package/dist/format/localization.js +12 -5
  19. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.d.ts +1 -0
  20. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +1 -0
  21. package/dist/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
  22. package/package.json +1 -1
  23. package/src/dates/constants/DATETIME_COLUMN_FORMAT.ts +8 -0
  24. package/src/dates/constants/index.ts +1 -0
  25. package/src/format/definition.ts +2 -0
  26. package/src/format/localization.ts +11 -5
  27. package/src/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.ts +1 -0
  28. package/src/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.ts +1 -0
  29. package/src/interfaces/format/IFormatOutputFormat.Interface.ts +2 -1
@@ -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,20 +24,26 @@ 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 new Intl.DateTimeFormat(definition_1.LANG_DEFAULT, langOpts).format(dateParam);
40
47
  }
41
48
  }
42
49
  function formatLocaleNumber(value, outputFormat, config) {
@@ -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
  }
@@ -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,19 +19,25 @@ 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 new Intl.DateTimeFormat(LANG_DEFAULT, langOpts).format(dateParam);
34
41
  }
35
42
  }
36
43
  function formatLocaleNumber(value, outputFormat, config) {
@@ -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
  }
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-24",
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,19 +21,24 @@ 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 new Intl.DateTimeFormat(LANG_DEFAULT, langOpts).format(dateParam);
36
42
  }
37
43
  }
38
44
 
@@ -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
+ }