@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.
- package/README.md +347 -347
- package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.d.ts +1 -0
- package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.js +11 -0
- package/dist/cjs/dates/constants/index.d.ts +1 -0
- package/dist/cjs/dates/constants/index.js +1 -0
- package/dist/cjs/format/definition.d.ts +8 -0
- package/dist/cjs/format/definition.js +2 -1
- package/dist/cjs/format/localization.js +11 -4
- package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.d.ts +1 -0
- package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +1 -0
- package/dist/cjs/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
- package/dist/dates/constants/DATETIME_COLUMN_FORMAT.d.ts +1 -0
- package/dist/dates/constants/DATETIME_COLUMN_FORMAT.js +8 -0
- package/dist/dates/constants/index.d.ts +1 -0
- package/dist/dates/constants/index.js +1 -0
- package/dist/format/definition.d.ts +8 -0
- package/dist/format/definition.js +1 -0
- package/dist/format/localization.js +12 -5
- package/dist/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.d.ts +1 -0
- package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +1 -0
- package/dist/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
- package/package.json +1 -1
- package/src/dates/constants/DATETIME_COLUMN_FORMAT.ts +8 -0
- package/src/dates/constants/index.ts +1 -0
- package/src/format/definition.ts +2 -0
- package/src/format/localization.ts +11 -5
- package/src/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.ts +1 -0
- package/src/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.ts +1 -0
- 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
|
+
];
|
|
@@ -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);
|
|
@@ -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],
|
|
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,
|
|
46
|
+
return new Intl.DateTimeFormat(definition_1.LANG_DEFAULT, langOpts).format(dateParam);
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
49
|
function formatLocaleNumber(value, outputFormat, config) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DATETIME_COLUMN_FORMAT: string[];
|
|
@@ -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],
|
|
37
|
+
return new Intl.DateTimeFormat([lang, LANG_DEFAULT], langOpts).format(dateParam);
|
|
31
38
|
}
|
|
32
39
|
catch (error) {
|
|
33
|
-
return new Intl.DateTimeFormat(LANG_DEFAULT,
|
|
40
|
+
return new Intl.DateTimeFormat(LANG_DEFAULT, langOpts).format(dateParam);
|
|
34
41
|
}
|
|
35
42
|
}
|
|
36
43
|
function formatLocaleNumber(value, outputFormat, config) {
|
package/package.json
CHANGED
package/src/format/definition.ts
CHANGED
|
@@ -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],
|
|
39
|
+
return new Intl.DateTimeFormat([lang, LANG_DEFAULT], langOpts).format(dateParam);
|
|
34
40
|
} catch (error) {
|
|
35
|
-
return new Intl.DateTimeFormat(LANG_DEFAULT,
|
|
41
|
+
return new Intl.DateTimeFormat(LANG_DEFAULT, langOpts).format(dateParam);
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
|