@qrvey/utils 1.2.9-15 → 1.2.9-19
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 +214 -111
- package/dist/cjs/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -0
- package/dist/cjs/filters/helpers/ui/index.d.ts +1 -0
- package/dist/cjs/filters/helpers/ui/index.js +1 -0
- package/dist/cjs/filters/helpers/ui/transformFilterValues.d.ts +4 -0
- package/dist/cjs/filters/helpers/ui/transformFilterValues.js +22 -0
- package/dist/cjs/filters/interfaces/builder/IFilterBuilderGeneralConfig.d.ts +1 -0
- package/dist/cjs/filters/interfaces/panel/IFilterPanelConfig.d.ts +1 -0
- package/dist/cjs/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +6 -0
- package/dist/cjs/filters/interfaces/ui/IFUTransformFilterValuesSettings.js +2 -0
- package/dist/cjs/filters/interfaces/ui/index.d.ts +3 -2
- package/dist/cjs/filters/interfaces/ui/index.js +3 -2
- package/dist/cjs/format/definition.d.ts +17 -0
- package/dist/cjs/format/definition.js +31 -1
- package/dist/cjs/format/format.d.ts +2 -1
- package/dist/cjs/format/format.js +8 -5
- package/dist/cjs/format/index.d.ts +1 -0
- package/dist/cjs/format/index.js +1 -0
- package/dist/cjs/format/localization.d.ts +4 -0
- package/dist/cjs/format/localization.js +65 -0
- package/dist/cjs/globalization/helpers/getI18nCalendar.d.ts +4 -0
- package/dist/cjs/globalization/helpers/getI18nCalendar.js +69 -0
- package/dist/cjs/globalization/helpers/index.d.ts +1 -0
- package/dist/cjs/globalization/helpers/index.js +1 -0
- package/dist/cjs/globalization/interfaces/calendar/II18nCalendar.d.ts +7 -0
- package/dist/cjs/globalization/interfaces/calendar/II18nCalendar.js +2 -0
- package/dist/cjs/globalization/interfaces/calendar/II18nCalendarProperties.d.ts +9 -0
- package/dist/cjs/globalization/interfaces/calendar/II18nCalendarProperties.js +2 -0
- package/dist/cjs/globalization/interfaces/calendar/index.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/calendar/index.js +14 -0
- package/dist/cjs/globalization/interfaces/common/II18nCommon.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/common/II18nDayNames.d.ts +7 -0
- package/dist/cjs/globalization/interfaces/filters/II18nFilter.d.ts +2 -0
- package/dist/cjs/globalization/interfaces/filters/II18nTokenBox.d.ts +6 -0
- package/dist/cjs/globalization/interfaces/filters/II18nTokenBox.js +2 -0
- package/dist/cjs/globalization/interfaces/index.d.ts +1 -0
- package/dist/cjs/globalization/interfaces/index.js +1 -0
- package/dist/cjs/globalization/labels/calendar/I18N_CALENDAR.d.ts +2 -0
- package/dist/cjs/globalization/labels/calendar/I18N_CALENDAR.js +10 -0
- package/dist/cjs/globalization/labels/calendar/index.d.ts +1 -0
- package/dist/cjs/globalization/labels/calendar/index.js +13 -0
- package/dist/cjs/globalization/labels/common/I18N_COMMON.js +2 -0
- package/dist/cjs/globalization/labels/common/I18N_DAY_NAMES.js +7 -0
- package/dist/cjs/globalization/labels/filters/I18N_FILTER.js +6 -0
- package/dist/cjs/globalization/labels/index.d.ts +1 -0
- package/dist/cjs/globalization/labels/index.js +1 -0
- package/dist/cjs/interfaces/format/IFormatConfig.Interface.d.ts +5 -0
- package/dist/cjs/interfaces/format/IFormatConfig.Interface.js +2 -0
- package/dist/cjs/interfaces/format/IFormatCurrency.Interface.d.ts +4 -0
- package/dist/cjs/interfaces/format/IFormatCurrency.Interface.js +2 -0
- package/dist/cjs/interfaces/format/IFormatOutputFormat.Interface.d.ts +8 -0
- package/dist/cjs/interfaces/format/IFormatOutputFormat.Interface.js +2 -0
- package/dist/cjs/interfaces/format/index.d.ts +3 -0
- package/dist/cjs/interfaces/format/index.js +15 -0
- package/dist/cjs/interfaces/general/IGeneralWidgetConfig.d.ts +2 -0
- package/dist/cjs/interfaces/index.d.ts +1 -0
- package/dist/cjs/interfaces/index.js +1 -0
- package/dist/cjs/qrvey/helpers/getValueWithSuffixes.d.ts +9 -0
- package/dist/cjs/qrvey/helpers/getValueWithSuffixes.js +23 -0
- package/dist/cjs/qrvey/helpers/index.d.ts +2 -0
- package/dist/cjs/qrvey/helpers/index.js +2 -0
- package/dist/cjs/qrvey/helpers/transformValue.d.ts +8 -0
- package/dist/cjs/qrvey/helpers/transformValue.js +46 -0
- package/dist/cjs/qrvey/interfaces/IGetValueWithSuffixesSettings.d.ts +11 -0
- package/dist/cjs/qrvey/interfaces/IGetValueWithSuffixesSettings.js +2 -0
- package/dist/cjs/qrvey/interfaces/ITransformValueSettings.d.ts +10 -0
- package/dist/cjs/qrvey/interfaces/ITransformValueSettings.js +2 -0
- package/dist/cjs/qrvey/interfaces/index.d.ts +2 -0
- package/dist/cjs/qrvey/interfaces/index.js +2 -0
- package/dist/cjs/services/api/getDatasetColumns.api.js +3 -1
- package/dist/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -0
- package/dist/filters/helpers/ui/index.d.ts +1 -0
- package/dist/filters/helpers/ui/index.js +1 -0
- package/dist/filters/helpers/ui/transformFilterValues.d.ts +4 -0
- package/dist/filters/helpers/ui/transformFilterValues.js +18 -0
- package/dist/filters/interfaces/builder/IFilterBuilderGeneralConfig.d.ts +1 -0
- package/dist/filters/interfaces/panel/IFilterPanelConfig.d.ts +1 -0
- package/dist/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +6 -0
- package/dist/filters/interfaces/ui/IFUTransformFilterValuesSettings.js +1 -0
- package/dist/filters/interfaces/ui/index.d.ts +3 -2
- package/dist/filters/interfaces/ui/index.js +3 -2
- package/dist/format/definition.d.ts +17 -0
- package/dist/format/definition.js +30 -0
- package/dist/format/format.d.ts +2 -1
- package/dist/format/format.js +6 -3
- package/dist/format/index.d.ts +1 -0
- package/dist/format/index.js +1 -0
- package/dist/format/localization.d.ts +4 -0
- package/dist/format/localization.js +59 -0
- package/dist/globalization/helpers/getI18nCalendar.d.ts +4 -0
- package/dist/globalization/helpers/getI18nCalendar.js +65 -0
- package/dist/globalization/helpers/index.d.ts +1 -0
- package/dist/globalization/helpers/index.js +1 -0
- package/dist/globalization/interfaces/calendar/II18nCalendar.d.ts +7 -0
- package/dist/globalization/interfaces/calendar/II18nCalendar.js +1 -0
- package/dist/globalization/interfaces/calendar/II18nCalendarProperties.d.ts +9 -0
- package/dist/globalization/interfaces/calendar/II18nCalendarProperties.js +1 -0
- package/dist/globalization/interfaces/calendar/index.d.ts +2 -0
- package/dist/globalization/interfaces/calendar/index.js +2 -0
- package/dist/globalization/interfaces/common/II18nCommon.d.ts +2 -0
- package/dist/globalization/interfaces/common/II18nDayNames.d.ts +7 -0
- package/dist/globalization/interfaces/filters/II18nFilter.d.ts +2 -0
- package/dist/globalization/interfaces/filters/II18nTokenBox.d.ts +6 -0
- package/dist/globalization/interfaces/filters/II18nTokenBox.js +1 -0
- package/dist/globalization/interfaces/index.d.ts +1 -0
- package/dist/globalization/interfaces/index.js +1 -0
- package/dist/globalization/labels/calendar/I18N_CALENDAR.d.ts +2 -0
- package/dist/globalization/labels/calendar/I18N_CALENDAR.js +7 -0
- package/dist/globalization/labels/calendar/index.d.ts +1 -0
- package/dist/globalization/labels/calendar/index.js +1 -0
- package/dist/globalization/labels/common/I18N_COMMON.js +2 -0
- package/dist/globalization/labels/common/I18N_DAY_NAMES.js +7 -0
- package/dist/globalization/labels/filters/I18N_FILTER.js +6 -0
- package/dist/globalization/labels/index.d.ts +1 -0
- package/dist/globalization/labels/index.js +1 -0
- package/dist/interfaces/format/IFormatConfig.Interface.d.ts +5 -0
- package/dist/interfaces/format/IFormatConfig.Interface.js +1 -0
- package/dist/interfaces/format/IFormatCurrency.Interface.d.ts +4 -0
- package/dist/interfaces/format/IFormatCurrency.Interface.js +1 -0
- package/dist/interfaces/format/IFormatOutputFormat.Interface.d.ts +8 -0
- package/dist/interfaces/format/IFormatOutputFormat.Interface.js +1 -0
- package/dist/interfaces/format/index.d.ts +3 -0
- package/dist/interfaces/format/index.js +3 -0
- package/dist/interfaces/general/IGeneralWidgetConfig.d.ts +2 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.js +1 -0
- package/dist/qrvey/helpers/getValueWithSuffixes.d.ts +9 -0
- package/dist/qrvey/helpers/getValueWithSuffixes.js +19 -0
- package/dist/qrvey/helpers/index.d.ts +2 -0
- package/dist/qrvey/helpers/index.js +2 -0
- package/dist/qrvey/helpers/transformValue.d.ts +8 -0
- package/dist/qrvey/helpers/transformValue.js +42 -0
- package/dist/qrvey/interfaces/IGetValueWithSuffixesSettings.d.ts +11 -0
- package/dist/qrvey/interfaces/IGetValueWithSuffixesSettings.js +1 -0
- package/dist/qrvey/interfaces/ITransformValueSettings.d.ts +10 -0
- package/dist/qrvey/interfaces/ITransformValueSettings.js +1 -0
- package/dist/qrvey/interfaces/index.d.ts +2 -0
- package/dist/qrvey/interfaces/index.js +2 -0
- package/dist/services/api/getDatasetColumns.api.js +3 -1
- package/package.json +1 -1
- package/src/filters/helpers/builder/getFilterBuilderGeneralConfig.ts +1 -0
- package/src/filters/helpers/ui/index.ts +1 -0
- package/src/filters/helpers/ui/transformFilterValues.ts +29 -0
- package/src/filters/interfaces/builder/IFilterBuilderGeneralConfig.ts +2 -1
- package/src/filters/interfaces/panel/IFilterPanelConfig.ts +1 -0
- package/src/filters/interfaces/ui/IFUTransformFilterValuesSettings.ts +7 -0
- package/src/filters/interfaces/ui/index.ts +3 -2
- package/src/format/definition.ts +45 -0
- package/src/format/format.ts +19 -15
- package/src/format/index.ts +1 -0
- package/src/format/localization.ts +62 -0
- package/src/globalization/helpers/getI18nCalendar.ts +68 -0
- package/src/globalization/helpers/index.ts +1 -0
- package/src/globalization/interfaces/calendar/II18nCalendar.ts +7 -0
- package/src/globalization/interfaces/calendar/II18nCalendarProperties.ts +9 -0
- package/src/globalization/interfaces/calendar/index.ts +2 -0
- package/src/globalization/interfaces/common/II18nCommon.ts +2 -0
- package/src/globalization/interfaces/common/II18nDayNames.ts +8 -0
- package/src/globalization/interfaces/filters/II18nFilter.ts +2 -0
- package/src/globalization/interfaces/filters/II18nTokenBox.ts +6 -0
- package/src/globalization/interfaces/index.ts +1 -0
- package/src/globalization/labels/calendar/I18N_CALENDAR.ts +9 -0
- package/src/globalization/labels/calendar/index.ts +1 -0
- package/src/globalization/labels/common/I18N_COMMON.ts +2 -0
- package/src/globalization/labels/common/I18N_DAY_NAMES.ts +8 -0
- package/src/globalization/labels/filters/I18N_FILTER.ts +6 -0
- package/src/globalization/labels/index.ts +1 -0
- package/src/interfaces/format/IFormatConfig.Interface.ts +5 -0
- package/src/interfaces/format/IFormatCurrency.Interface.ts +4 -0
- package/src/interfaces/format/IFormatOutputFormat.Interface.ts +9 -0
- package/src/interfaces/format/index.ts +3 -0
- package/src/interfaces/general/IGeneralWidgetConfig.ts +2 -0
- package/src/interfaces/index.ts +1 -0
- package/src/qrvey/helpers/getValueWithSuffixes.ts +19 -0
- package/src/qrvey/helpers/index.ts +2 -0
- package/src/qrvey/helpers/transformValue.ts +47 -0
- package/src/qrvey/interfaces/IGetValueWithSuffixesSettings.ts +12 -0
- package/src/qrvey/interfaces/ITransformValueSettings.ts +12 -0
- package/src/qrvey/interfaces/index.ts +2 -0
- package/src/services/api/getDatasetColumns.api.ts +3 -1
- package/test/columns/isNumericalColumn.test.js +154 -0
- package/test/format.test.js +11 -11
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IGetValueWithSuffixesSettings } from "../interfaces/IGetValueWithSuffixesSettings";
|
|
2
|
+
/**
|
|
3
|
+
* Get a string value with suffixes if available.
|
|
4
|
+
* Add suffix into the value string. Prioritized for numeric values.
|
|
5
|
+
* @param value a number or string
|
|
6
|
+
* @param suffixes An object with singular or plural suffix string.
|
|
7
|
+
* @returns a string value with suffix
|
|
8
|
+
*/
|
|
9
|
+
export declare function getValueWithSuffixes(value: string | number, settings: IGetValueWithSuffixesSettings): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getValueWithSuffixes = void 0;
|
|
4
|
+
const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
5
|
+
const isNaNV2_1 = require("../../general/mix/isNaNV2");
|
|
6
|
+
/**
|
|
7
|
+
* Get a string value with suffixes if available.
|
|
8
|
+
* Add suffix into the value string. Prioritized for numeric values.
|
|
9
|
+
* @param value a number or string
|
|
10
|
+
* @param suffixes An object with singular or plural suffix string.
|
|
11
|
+
* @returns a string value with suffix
|
|
12
|
+
*/
|
|
13
|
+
function getValueWithSuffixes(value, settings) {
|
|
14
|
+
let suffix = '';
|
|
15
|
+
if (!(0, isNaNV2_1.isNaNV2)(value)) {
|
|
16
|
+
if (!(0, isEmpty_1.isEmpty)(settings.suffixTranslateLabel) && !(0, isEmpty_1.isEmpty)(settings.translate))
|
|
17
|
+
suffix = settings.translate(settings.suffixTranslateLabel, { count: +value });
|
|
18
|
+
if (!(0, isEmpty_1.isEmpty)(settings.suffixes))
|
|
19
|
+
suffix = (+value > 1 || +value === 0) ? settings.suffixes.plural : settings.suffixes.singular;
|
|
20
|
+
}
|
|
21
|
+
return value + (!(0, isEmpty_1.isEmpty)(suffix) ? ' ' + suffix : '');
|
|
22
|
+
}
|
|
23
|
+
exports.getValueWithSuffixes = getValueWithSuffixes;
|
|
@@ -12,3 +12,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./getColumnsLabel"), exports);
|
|
14
14
|
__exportStar(require("./getPropertyLabel"), exports);
|
|
15
|
+
__exportStar(require("./getValueWithSuffixes"), exports);
|
|
16
|
+
__exportStar(require("./transformValue"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ITransformValueSettings } from "../interfaces/ITransformValueSettings";
|
|
2
|
+
/**
|
|
3
|
+
* Transforms a value depending of localization/globalization and extras settings.
|
|
4
|
+
* @param value A value to transform
|
|
5
|
+
* @param settings The settings of the transformValue function
|
|
6
|
+
* @returns A transformed value
|
|
7
|
+
*/
|
|
8
|
+
export declare function transformValue(value: string, settings: ITransformValueSettings): string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformValue = void 0;
|
|
4
|
+
const isDateColumn_1 = require("../../columns/helpers/isDateColumn");
|
|
5
|
+
const isNumericalColumn_1 = require("../../columns/helpers/isNumericalColumn");
|
|
6
|
+
const DATE_GROUPING_PROPERTY_1 = require("../../dates/constants/DATE_GROUPING_PROPERTY");
|
|
7
|
+
const DATE_GROUPING_TIME_PROPERTY_1 = require("../../dates/constants/DATE_GROUPING_TIME_PROPERTY");
|
|
8
|
+
const format_1 = require("../../format/format");
|
|
9
|
+
const getI18nDateGroupLabel_1 = require("../../globalization/helpers/getI18nDateGroupLabel");
|
|
10
|
+
const getValueWithSuffixes_1 = require("./getValueWithSuffixes");
|
|
11
|
+
/**
|
|
12
|
+
* Transforms a value depending of localization/globalization and extras settings.
|
|
13
|
+
* @param value A value to transform
|
|
14
|
+
* @param settings The settings of the transformValue function
|
|
15
|
+
* @returns A transformed value
|
|
16
|
+
*/
|
|
17
|
+
function transformValue(value, settings) {
|
|
18
|
+
const valueWithI18n = (0, getI18nDateGroupLabel_1.getI18nDateGroupLabel)(value, settings.property, settings.translate);
|
|
19
|
+
const valueWithLocalization = (0, format_1.addFormat)(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
|
|
20
|
+
return (0, getValueWithSuffixes_1.getValueWithSuffixes)(valueWithLocalization, { suffixTranslateLabel: settings.suffixTranslateLabel, translate: settings.translate });
|
|
21
|
+
}
|
|
22
|
+
exports.transformValue = transformValue;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the outputformat settings
|
|
25
|
+
* @param settings The settings of the transformValue function
|
|
26
|
+
* @returns the outputformat settings
|
|
27
|
+
*/
|
|
28
|
+
function getOutputFormat(settings) {
|
|
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)) {
|
|
31
|
+
type = 'DATE';
|
|
32
|
+
format = 'Default';
|
|
33
|
+
}
|
|
34
|
+
else if ((0, isNumericalColumn_1.isNumericalColumn)(settings.column)) {
|
|
35
|
+
type = 'NUMERIC';
|
|
36
|
+
}
|
|
37
|
+
return { type, format };
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Gets the format config
|
|
41
|
+
* @param settings The settings of the transformValue function
|
|
42
|
+
* @returns the format config
|
|
43
|
+
*/
|
|
44
|
+
function getFormatConfig(settings) {
|
|
45
|
+
return { lang: settings.locale };
|
|
46
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { II18nServiceTranslate } from "../../globalization/interfaces/II18nServiceTranslate";
|
|
2
|
+
export interface IGetValueWithSuffixesSettings {
|
|
3
|
+
translate?: II18nServiceTranslate;
|
|
4
|
+
suffixTranslateLabel?: string;
|
|
5
|
+
suffixes?: IGetValueWithSuffixesSettingsSuffixes;
|
|
6
|
+
}
|
|
7
|
+
interface IGetValueWithSuffixesSettingsSuffixes {
|
|
8
|
+
singular: string;
|
|
9
|
+
plural: string;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
2
|
+
import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
|
|
3
|
+
import { II18nServiceTranslate } from "../../globalization/interfaces/II18nServiceTranslate";
|
|
4
|
+
export interface ITransformValueSettings {
|
|
5
|
+
column: IColumn;
|
|
6
|
+
property: IColumnPropertyType;
|
|
7
|
+
translate: II18nServiceTranslate;
|
|
8
|
+
locale: string;
|
|
9
|
+
suffixTranslateLabel?: string;
|
|
10
|
+
}
|
|
@@ -15,3 +15,5 @@ __exportStar(require("./ICalculation"), exports);
|
|
|
15
15
|
__exportStar(require("./ICalculationInfo"), exports);
|
|
16
16
|
__exportStar(require("./ICalculationType"), exports);
|
|
17
17
|
__exportStar(require("./IDataset"), exports);
|
|
18
|
+
__exportStar(require("./IGetValueWithSuffixesSettings"), exports);
|
|
19
|
+
__exportStar(require("./ITransformValueSettings"), exports);
|
|
@@ -7,16 +7,18 @@ exports.getDatasetColumns = void 0;
|
|
|
7
7
|
const CHART_ENDPOINT_1 = require("../constants/CHART_ENDPOINT");
|
|
8
8
|
const Request_1 = __importDefault(require("../helpers/Request"));
|
|
9
9
|
const BDatasetsToUIDatasets_adapter_1 = require("../adapters/BDatasetsToUIDatasets.adapter");
|
|
10
|
+
const __1 = require("../..");
|
|
10
11
|
/**
|
|
11
12
|
* Get a dataset by Qrvey ID
|
|
12
13
|
* @param qrveyid The Qrvey ID
|
|
13
14
|
* @returns a promise
|
|
14
15
|
*/
|
|
15
16
|
function getDatasetColumns(config, qrveyid) {
|
|
17
|
+
const lang = (0, __1.chooseLang)(config);
|
|
16
18
|
return Request_1.default.post(Object.assign(Object.assign({}, config), { qrveyid, endpoint: CHART_ENDPOINT_1.CHART_ENDPOINT }), '/question/list', {
|
|
17
19
|
'optionsAttributes': ['id', 'text', 'type', 'property', 'linked', 'linkid', 'qrveyid', 'bucketId', 'formulaId', 'formulaType', 'geogroup', 'outputFormat'],
|
|
18
20
|
'extend': true
|
|
19
|
-
})
|
|
21
|
+
}, { lang })
|
|
20
22
|
.then(BDatasetsToUIDatasets_adapter_1.BDatasetsToUIDatasets)
|
|
21
23
|
.catch(_e => []);
|
|
22
24
|
}
|
|
@@ -9,6 +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
13
|
qv_token: config.qv_token,
|
|
13
14
|
timezoneControl: getAttribute(config, 'timezone_control') || config.timezoneControl,
|
|
14
15
|
userid: getAttribute(config, 'user_id') || config.userid,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IFSFilter } from "../../interfaces/common/IFSFilter";
|
|
2
|
+
import { IFValue } from "../../interfaces/IFValue";
|
|
3
|
+
import { IFUTransformFilterValuesSettings } from "../../interfaces/ui/IFUTransformFilterValuesSettings";
|
|
4
|
+
export declare function transformFilterValues(filter: IFSFilter, settings: IFUTransformFilterValuesSettings): IFValue[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isEmpty } from "../../../general/mix/isEmpty";
|
|
2
|
+
import { transformValue } from "../../../qrvey/helpers/transformValue";
|
|
3
|
+
import { isRangeValidator } from "../common/isRangeValidator";
|
|
4
|
+
import { isRegularValidator } from "../common/isRegularValidator";
|
|
5
|
+
export function transformFilterValues(filter, settings) {
|
|
6
|
+
const transformValueSettings = Object.assign(Object.assign({}, settings), { column: filter.column, property: filter.property });
|
|
7
|
+
if (isEmpty(filter))
|
|
8
|
+
return [];
|
|
9
|
+
if (isRegularValidator(filter.validator)) {
|
|
10
|
+
return filter.values.map((value) => (Object.assign(Object.assign({}, value), { value: transformValue(value.value, transformValueSettings) })));
|
|
11
|
+
}
|
|
12
|
+
else if (isRangeValidator(filter.validator)) {
|
|
13
|
+
return filter.values.map((value) => (Object.assign(Object.assign({}, value), { min: transformValue(value.min, transformValueSettings), max: transformValue(value.max, transformValueSettings) })));
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
return filter.values;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -18,7 +18,8 @@ export * from './IFUDataset';
|
|
|
18
18
|
export * from './IFUFilter';
|
|
19
19
|
export * from './IFUFilterExtras';
|
|
20
20
|
export * from './IFUFlattenedFilter';
|
|
21
|
-
export * from './IFUScope';
|
|
22
21
|
export * from './IFUParamsToGetFilter';
|
|
23
|
-
export * from './
|
|
22
|
+
export * from './IFUScope';
|
|
23
|
+
export * from './IFUTransformFilterValuesSettings';
|
|
24
24
|
export * from './IFUUIValueSettings';
|
|
25
|
+
export * from './IFUValue';
|
|
@@ -18,7 +18,8 @@ export * from './IFUDataset';
|
|
|
18
18
|
export * from './IFUFilter';
|
|
19
19
|
export * from './IFUFilterExtras';
|
|
20
20
|
export * from './IFUFlattenedFilter';
|
|
21
|
-
export * from './IFUScope';
|
|
22
21
|
export * from './IFUParamsToGetFilter';
|
|
23
|
-
export * from './
|
|
22
|
+
export * from './IFUScope';
|
|
23
|
+
export * from './IFUTransformFilterValuesSettings';
|
|
24
24
|
export * from './IFUUIValueSettings';
|
|
25
|
+
export * from './IFUValue';
|
|
@@ -11,3 +11,20 @@ export declare const isComplexColumn: (column?: any) => boolean;
|
|
|
11
11
|
export declare const isNumericalColumn: (column?: any) => boolean;
|
|
12
12
|
export declare function supportNumericFormatting(chartType: ChartType): boolean;
|
|
13
13
|
export declare const isTextColumn: (column: any) => boolean;
|
|
14
|
+
export declare const currencyISO: {
|
|
15
|
+
text: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}[];
|
|
18
|
+
export declare const enum LOCALE_FORMATS {
|
|
19
|
+
DECIMAL = "Decimal",
|
|
20
|
+
CURRENCY = "Currency",
|
|
21
|
+
PERCENTAGE = "Percentage",
|
|
22
|
+
SCIENTIFIC = "Scientific"
|
|
23
|
+
}
|
|
24
|
+
export declare const enum LOCALE_STYLES {
|
|
25
|
+
DECIMAL = "decimal",
|
|
26
|
+
PERCENT = "percent",
|
|
27
|
+
CURRENCY = "currency",
|
|
28
|
+
SCIENTIFIC = "scientific"
|
|
29
|
+
}
|
|
30
|
+
export declare const LANG_DEFAULT = "en-US";
|
|
@@ -43,3 +43,33 @@ export function supportNumericFormatting(chartType) {
|
|
|
43
43
|
return supportedCharts.includes(chartType);
|
|
44
44
|
}
|
|
45
45
|
export const isTextColumn = (column) => textFields.includes(column.type) || column.formulaType === 'string' || column.formulaType === 'boolean';
|
|
46
|
+
export const currencyISO = [
|
|
47
|
+
{ text: 'Default', label: 'USD' },
|
|
48
|
+
{ text: '$ (USD)', label: 'USD' },
|
|
49
|
+
{ text: '€ (EUR)', label: 'EUR' },
|
|
50
|
+
{ text: '¥ (JPY)', label: 'JPY' },
|
|
51
|
+
{ text: '£ (GBP)', label: 'GBP' },
|
|
52
|
+
{ text: '₩ (WON)', label: 'WON' },
|
|
53
|
+
{ text: '$ (AUD)', label: 'AUD' },
|
|
54
|
+
{ text: '$ (CAD)', label: 'CAD' },
|
|
55
|
+
{ text: 'CHF (CHF)', label: 'CHF' },
|
|
56
|
+
{ text: '¥ (CNY)', label: 'CNY' },
|
|
57
|
+
{ text: 'kr (SEK)', label: 'SEK' },
|
|
58
|
+
{ text: '$ (MXN)', label: 'MXN' },
|
|
59
|
+
{ text: '$ (NZD)', label: 'NZD' },
|
|
60
|
+
{ text: '$ (SGD)', label: 'SGD' },
|
|
61
|
+
{ text: '$ (HKD)', label: 'HKD' },
|
|
62
|
+
{ text: 'kr (NOK)', label: 'NOK' },
|
|
63
|
+
{ text: '₩ (KRW)', label: 'KRW' },
|
|
64
|
+
{ text: '₺ (TRY)', label: 'TRY' },
|
|
65
|
+
{ text: '₹ (INR)', label: 'INR' },
|
|
66
|
+
{ text: '₽ (RUB)', label: 'RUB' },
|
|
67
|
+
{ text: 'R$ (BRL)', label: 'BRL' },
|
|
68
|
+
{ text: 'R (ZAR)', label: 'ZAR' },
|
|
69
|
+
{ text: 'kr (DKK)', label: 'DKK' },
|
|
70
|
+
{ text: 'zł (PLN)', label: 'PLN' },
|
|
71
|
+
{ text: 'NT$ (TWD)', label: 'TWD' },
|
|
72
|
+
{ text: '฿ (THB)', label: 'THB' },
|
|
73
|
+
{ text: 'RM (MYR)', label: 'MYR' }
|
|
74
|
+
];
|
|
75
|
+
export const LANG_DEFAULT = 'en-US';
|
package/dist/format/format.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IFormatConfig } from '..';
|
|
1
2
|
export declare function formatDate(dateString: any, format: any): any;
|
|
2
3
|
export declare function formatAbbreviated(num: any, decimals: any): any;
|
|
3
4
|
/**
|
|
@@ -5,7 +6,7 @@ export declare function formatAbbreviated(num: any, decimals: any): any;
|
|
|
5
6
|
* @param bytes type number
|
|
6
7
|
*/
|
|
7
8
|
export declare function formatFileSize(bytes: number): string;
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const addFormat: (value: any, outputFormat?: any, config?: IFormatConfig) => any;
|
|
9
10
|
export declare const parseFormulaType: (type: string) => "DATE" | "NUMERIC" | "TEXT_LABEL";
|
|
10
11
|
export declare const validateColumnType: (column: any) => any;
|
|
11
12
|
export declare const defineFormat: (column?: any, isSimpleTable?: boolean, isCategoryDimension?: boolean) => any;
|
package/dist/format/format.js
CHANGED
|
@@ -6,6 +6,7 @@ import { isEmpty } from '../general/mix/isEmpty';
|
|
|
6
6
|
import { _get } from '../general/object/get';
|
|
7
7
|
import { COLUMN } from '../columns/constants/COLUMN';
|
|
8
8
|
import { FORMULA } from '../formulas/constants/FORMULA';
|
|
9
|
+
import { formatWithLocale } from './localization';
|
|
9
10
|
dayjs.extend(advancedFormat); // Add support to advanced formats https://day.js.org/docs/en/plugin/advanced-format
|
|
10
11
|
/**
|
|
11
12
|
* Apply to the given date format to a date value
|
|
@@ -74,16 +75,18 @@ export function formatFileSize(bytes) {
|
|
|
74
75
|
const megaBytes = kiloBytes / 1024;
|
|
75
76
|
return megaBytes < 10 ? `${fixDecimals(megaBytes)} MB` : `${Math.round(megaBytes)} MB`;
|
|
76
77
|
}
|
|
77
|
-
export const
|
|
78
|
+
export const addFormat = (value, outputFormat = 'None', config) => {
|
|
78
79
|
if (isEmpty(value) || typeof value === 'object' && isEmpty(value[0]))
|
|
79
80
|
return value;
|
|
80
81
|
switch (outputFormat.type) {
|
|
81
82
|
case 'DATE':
|
|
82
83
|
case 'DATETIME':
|
|
83
|
-
return formatDate(value, outputFormat.format);
|
|
84
|
+
return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat.format);
|
|
84
85
|
case 'NUMERIC': {
|
|
85
86
|
const parse = parseFloat(value);
|
|
86
|
-
|
|
87
|
+
const withLocale = outputFormat.format !== 'Abbreviated' && outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
|
|
88
|
+
return isNaN(parse) ? value : withLocale ? formatWithLocale(value, outputFormat, config)
|
|
89
|
+
: formatNumber(parse, outputFormat, config);
|
|
87
90
|
}
|
|
88
91
|
case 'IMAGEUPLOAD':
|
|
89
92
|
case 'FILEUPLOAD':
|
package/dist/format/index.d.ts
CHANGED
package/dist/format/index.js
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IFormatConfig, IFormatOutputFormat } from '../interfaces';
|
|
2
|
+
export declare const getLang: (locale: string | Record<string, any>) => Record<string, any>;
|
|
3
|
+
export declare const chooseLang: (config: Record<string, any>) => string;
|
|
4
|
+
export declare const formatWithLocale: (value: any, outputFormat: IFormatOutputFormat, config?: IFormatConfig) => any;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { currencyISO, LANG_DEFAULT } from './definition';
|
|
2
|
+
export const getLang = (locale) => {
|
|
3
|
+
if (!locale)
|
|
4
|
+
return;
|
|
5
|
+
else if (typeof locale === 'object')
|
|
6
|
+
return locale;
|
|
7
|
+
else
|
|
8
|
+
return { lang: locale === "browser" ? window.navigator.language : locale };
|
|
9
|
+
};
|
|
10
|
+
export const chooseLang = (config) => {
|
|
11
|
+
var _a, _b, _c, _d, _e;
|
|
12
|
+
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
|
+
config.lang);
|
|
16
|
+
return ((_e = lang) === null || _e === void 0 ? void 0 : _e.lang) || lang || LANG_DEFAULT;
|
|
17
|
+
};
|
|
18
|
+
export const formatWithLocale = (value, outputFormat, config = {}) => {
|
|
19
|
+
switch (outputFormat.type) {
|
|
20
|
+
case 'DATE':
|
|
21
|
+
case 'DATETIME':
|
|
22
|
+
return formatLocaleDate(value, config);
|
|
23
|
+
case 'NUMERIC':
|
|
24
|
+
return formatLocaleNumber(value, outputFormat, config);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
function formatLocaleDate(value, config) {
|
|
28
|
+
const { lang = LANG_DEFAULT, options } = config;
|
|
29
|
+
const dateParam = new Date(value);
|
|
30
|
+
try {
|
|
31
|
+
return new Intl.DateTimeFormat([lang, LANG_DEFAULT], options).format(dateParam);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return new Intl.DateTimeFormat(LANG_DEFAULT, options).format(dateParam);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function formatLocaleNumber(value, outputFormat, config) {
|
|
38
|
+
const { lang = LANG_DEFAULT, options } = config;
|
|
39
|
+
const langOpts = options || getLocaleOptions(outputFormat);
|
|
40
|
+
try {
|
|
41
|
+
return new Intl.NumberFormat([lang, LANG_DEFAULT], langOpts).format(value);
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
return new Intl.NumberFormat(LANG_DEFAULT, langOpts).format(value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function getLocaleOptions(outputFormat) {
|
|
48
|
+
const { format, decimals, currency, backup_currency } = outputFormat;
|
|
49
|
+
switch (format) {
|
|
50
|
+
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 };
|
|
53
|
+
}
|
|
54
|
+
case "Scientific" /* SCIENTIFIC */: return { style: "decimal" /* DECIMAL */,
|
|
55
|
+
notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals };
|
|
56
|
+
case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals };
|
|
57
|
+
default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { II18nCalendarProperties } from "../interfaces/calendar/II18nCalendarProperties";
|
|
2
|
+
import { II18nServiceTranslate } from "../interfaces/II18nServiceTranslate";
|
|
3
|
+
import { I18nService } from "../service/i18nextBuilder";
|
|
4
|
+
export declare function getI18nCalendar(locale: I18nService | II18nServiceTranslate): II18nCalendarProperties;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { I18nService } from "../service/i18nextBuilder";
|
|
2
|
+
export function getI18nCalendar(locale) {
|
|
3
|
+
const localeOverride = locale instanceof I18nService ? locale : typeof locale === 'function' ? { translate: locale } : undefined;
|
|
4
|
+
if (!localeOverride)
|
|
5
|
+
return undefined;
|
|
6
|
+
return {
|
|
7
|
+
clear: localeOverride.translate('common.calendar.clear'),
|
|
8
|
+
days: [
|
|
9
|
+
localeOverride.translate('common.day_names.sunday_dddd'),
|
|
10
|
+
localeOverride.translate('common.day_names.monday_dddd'),
|
|
11
|
+
localeOverride.translate('common.day_names.tuesday_dddd'),
|
|
12
|
+
localeOverride.translate('common.day_names.wednesday_dddd'),
|
|
13
|
+
localeOverride.translate('common.day_names.thursday_dddd'),
|
|
14
|
+
localeOverride.translate('common.day_names.friday_dddd'),
|
|
15
|
+
localeOverride.translate('common.day_names.saturday_dddd')
|
|
16
|
+
],
|
|
17
|
+
daysMin: [
|
|
18
|
+
localeOverride.translate('common.day_names.sunday_dd'),
|
|
19
|
+
localeOverride.translate('common.day_names.monday_dd'),
|
|
20
|
+
localeOverride.translate('common.day_names.tuesday_dd'),
|
|
21
|
+
localeOverride.translate('common.day_names.wednesday_dd'),
|
|
22
|
+
localeOverride.translate('common.day_names.thursday_dd'),
|
|
23
|
+
localeOverride.translate('common.day_names.friday_dd'),
|
|
24
|
+
localeOverride.translate('common.day_names.saturday_dd')
|
|
25
|
+
],
|
|
26
|
+
daysShort: [
|
|
27
|
+
localeOverride.translate('common.day_names.sunday_ddd'),
|
|
28
|
+
localeOverride.translate('common.day_names.monday_ddd'),
|
|
29
|
+
localeOverride.translate('common.day_names.tuesday_ddd'),
|
|
30
|
+
localeOverride.translate('common.day_names.wednesday_ddd'),
|
|
31
|
+
localeOverride.translate('common.day_names.thursday_ddd'),
|
|
32
|
+
localeOverride.translate('common.day_names.friday_ddd'),
|
|
33
|
+
localeOverride.translate('common.day_names.saturday_ddd')
|
|
34
|
+
],
|
|
35
|
+
months: [
|
|
36
|
+
localeOverride.translate('common.date_grouping.january_mmmm'),
|
|
37
|
+
localeOverride.translate('common.date_grouping.february_mmmm'),
|
|
38
|
+
localeOverride.translate('common.date_grouping.march_mmmm'),
|
|
39
|
+
localeOverride.translate('common.date_grouping.april_mmmm'),
|
|
40
|
+
localeOverride.translate('common.date_grouping.may_mmmm'),
|
|
41
|
+
localeOverride.translate('common.date_grouping.june_mmmm'),
|
|
42
|
+
localeOverride.translate('common.date_grouping.july_mmmm'),
|
|
43
|
+
localeOverride.translate('common.date_grouping.august_mmmm'),
|
|
44
|
+
localeOverride.translate('common.date_grouping.september_mmmm'),
|
|
45
|
+
localeOverride.translate('common.date_grouping.october_mmmm'),
|
|
46
|
+
localeOverride.translate('common.date_grouping.november_mmmm'),
|
|
47
|
+
localeOverride.translate('common.date_grouping.december_mmmm')
|
|
48
|
+
],
|
|
49
|
+
monthsShort: [
|
|
50
|
+
localeOverride.translate('common.date_grouping.january_mmm'),
|
|
51
|
+
localeOverride.translate('common.date_grouping.february_mmm'),
|
|
52
|
+
localeOverride.translate('common.date_grouping.march_mmm'),
|
|
53
|
+
localeOverride.translate('common.date_grouping.april_mmm'),
|
|
54
|
+
localeOverride.translate('common.date_grouping.may_mmm'),
|
|
55
|
+
localeOverride.translate('common.date_grouping.june_mmm'),
|
|
56
|
+
localeOverride.translate('common.date_grouping.july_mmm'),
|
|
57
|
+
localeOverride.translate('common.date_grouping.august_mmm'),
|
|
58
|
+
localeOverride.translate('common.date_grouping.september_mmm'),
|
|
59
|
+
localeOverride.translate('common.date_grouping.october_mmm'),
|
|
60
|
+
localeOverride.translate('common.date_grouping.november_mmm'),
|
|
61
|
+
localeOverride.translate('common.date_grouping.december_mmm')
|
|
62
|
+
],
|
|
63
|
+
today: localeOverride.translate('common.calendar.today')
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,8 +5,10 @@ import { II18nColumnTypesSuffixes } from "./II18nColumnTypesSuffixes";
|
|
|
5
5
|
import { II18nDateGrouping } from "./II18nDateGrouping";
|
|
6
6
|
import { II18nDayNames } from "./II18nDayNames";
|
|
7
7
|
import { II18nUnits } from "./II18nUnits";
|
|
8
|
+
import { II18nCalendar } from "../calendar/II18nCalendar";
|
|
8
9
|
export interface II18nCommon {
|
|
9
10
|
aggregate_labels: II18nAgreggateLabels;
|
|
11
|
+
calendar: II18nCalendar;
|
|
10
12
|
column_types: II18nColumnTypes;
|
|
11
13
|
column_types_suffixes: II18nColumnTypesSuffixes;
|
|
12
14
|
date_grouping: II18nDateGrouping;
|
|
@@ -7,6 +7,7 @@ import { II18nFilterOperator } from "./II18nFilterOperator";
|
|
|
7
7
|
import { II18nFilterScopes } from "./II18nFilterScopes";
|
|
8
8
|
import { II18nFilterPanelScopeTitle } from "./II18nFilterPanelScopeTitle";
|
|
9
9
|
import { II18nFilterDateSections } from "./II18nFilterDateSections";
|
|
10
|
+
import { II18nTokenBox } from './II18nTokenBox';
|
|
10
11
|
export interface II18nFilter {
|
|
11
12
|
date_sections: II18nFilterDateSections;
|
|
12
13
|
operators: II18nFilterOperator;
|
|
@@ -15,6 +16,7 @@ export interface II18nFilter {
|
|
|
15
16
|
scope_title: II18nFilterPanelScopeTitle;
|
|
16
17
|
scopes: II18nFilterScopes;
|
|
17
18
|
slidebar: II18nSlidebar;
|
|
19
|
+
token_box?: II18nTokenBox;
|
|
18
20
|
validators: II18nFilterValidator;
|
|
19
21
|
value_container: II18nValueContainer;
|
|
20
22
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|