@qrvey/utils 1.4.0-6 → 1.4.0-7
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 +1 -1
- package/dist/cjs/column_format/helpers/defineTableChartFormat.js +32 -27
- package/dist/cjs/column_format/helpers/defineXYChartFormat.js +8 -1
- package/dist/cjs/column_format/interfaces/IChartColumn.d.ts +2 -0
- package/dist/cjs/columns/interfaces/IColunmCalculation.d.ts +5 -0
- package/dist/cjs/columns/interfaces/IColunmCalculation.js +2 -0
- package/dist/cjs/filters/adapters/adaptDateGroupingProperty.js +1 -1
- package/dist/column_format/helpers/defineTableChartFormat.js +15 -10
- package/dist/column_format/helpers/defineXYChartFormat.js +8 -1
- package/dist/column_format/interfaces/IChartColumn.d.ts +2 -0
- package/dist/columns/interfaces/IColunmCalculation.d.ts +5 -0
- package/dist/columns/interfaces/IColunmCalculation.js +1 -0
- package/dist/filters/adapters/adaptDateGroupingProperty.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,59 +1,64 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defineTableChartFormat = void 0;
|
|
4
|
-
const
|
|
4
|
+
const AGGREGATE_1 = require("../../charts/constants/AGGREGATE");
|
|
5
|
+
const COLUMN_1 = require("../../columns/constants/COLUMN");
|
|
6
|
+
const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
5
7
|
const CHART_GROUP_1 = require("../constants/CHART_GROUP");
|
|
6
|
-
const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
|
|
7
8
|
const STRING_FORMAT_1 = require("../constants/STRING_FORMAT");
|
|
8
9
|
const TABLE_TYPE_1 = require("../constants/TABLE_TYPE");
|
|
9
10
|
const columnTypeByChart_1 = require("./columnTypeByChart");
|
|
11
|
+
const CALCULATION_LABEL_1 = require("../../qrvey/constants/CALCULATION_LABEL");
|
|
10
12
|
/**
|
|
11
13
|
* It returns the format of a column based on the column type, the chart type, and the chart settings
|
|
12
14
|
* @param {IChartColumn} column - IChartColumn
|
|
13
15
|
* @param {IColumnFormatSettings} settings - IColumnFormatSettings
|
|
14
16
|
*/
|
|
15
17
|
const defineTableChartFormat = (column, settings) => {
|
|
16
|
-
const { aggregate, defaultFormat, outputFormat, selectedFormat,
|
|
18
|
+
const { aggregate, defaultFormat, outputFormat, selectedFormat, calculation, } = column;
|
|
17
19
|
const { tableType, shelfType } = settings;
|
|
18
20
|
//Defaults
|
|
19
21
|
const defaultText = "Default";
|
|
20
|
-
const defaultNumeric = { type: "NUMERIC", format: "
|
|
22
|
+
const defaultNumeric = { type: "NUMERIC", format: "Decimal" /* LOCALE_FORMATS.DECIMAL */ };
|
|
23
|
+
const defaultPercentage = {
|
|
24
|
+
type: "NUMERIC",
|
|
25
|
+
format: "Percentage" /* LOCALE_FORMATS.PERCENTAGE */,
|
|
26
|
+
};
|
|
21
27
|
const isGroupedTable = tableType === TABLE_TYPE_1.TABLE_TYPE.GROUPED;
|
|
22
28
|
const columnType = (0, columnTypeByChart_1.columnTypeByChart)(column, shelfType, CHART_GROUP_1.CHART_GROUPS.TABLES, isGroupedTable);
|
|
23
|
-
const
|
|
24
|
-
const hasDefaultFormat = (0, __1.isEmpty)(selectedFormat) ||
|
|
29
|
+
const hasDefaultFormat = (0, isEmpty_1.isEmpty)(selectedFormat) ||
|
|
25
30
|
(outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText ||
|
|
26
31
|
(selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText;
|
|
27
32
|
switch (columnType) {
|
|
28
|
-
case
|
|
29
|
-
case
|
|
30
|
-
case
|
|
31
|
-
case
|
|
32
|
-
case
|
|
33
|
-
case
|
|
34
|
-
case
|
|
35
|
-
case
|
|
36
|
-
case
|
|
37
|
-
case
|
|
33
|
+
case COLUMN_1.COLUMN.YES_NO:
|
|
34
|
+
case COLUMN_1.COLUMN.PHONE:
|
|
35
|
+
case COLUMN_1.COLUMN.SINGLE_CHOICE:
|
|
36
|
+
case COLUMN_1.COLUMN.LONGTEXT:
|
|
37
|
+
case COLUMN_1.COLUMN.DROPDOWN:
|
|
38
|
+
case COLUMN_1.COLUMN.EXPRESSION:
|
|
39
|
+
case COLUMN_1.COLUMN.NAME:
|
|
40
|
+
case COLUMN_1.COLUMN.EMAIL_FORM:
|
|
41
|
+
case COLUMN_1.COLUMN.IMAGE:
|
|
42
|
+
case COLUMN_1.COLUMN.TEXT_LABEL:
|
|
38
43
|
return STRING_FORMAT_1.STRING_FORMAT.NONE;
|
|
39
|
-
case
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
else if (hasDefaultFormat) {
|
|
44
|
-
const columnDefaultFormat = defaultFormat || outputFormat || { type: 'DATE', format: 'MM/DD/YYYY' };
|
|
44
|
+
case COLUMN_1.COLUMN.DATE: {
|
|
45
|
+
if (hasDefaultFormat) {
|
|
46
|
+
const columnDefaultFormat = defaultFormat ||
|
|
47
|
+
outputFormat || { type: "DATE", format: "MM/DD/YYYY" };
|
|
45
48
|
return Object.assign(Object.assign({}, defaultFormat), { format: defaultText, originalFormat: Object.assign({}, columnDefaultFormat), type: "DATE" });
|
|
46
49
|
}
|
|
47
50
|
else {
|
|
48
51
|
return selectedFormat;
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
|
-
case
|
|
52
|
-
case
|
|
53
|
-
case
|
|
54
|
+
case COLUMN_1.COLUMN.NUMERIC:
|
|
55
|
+
case COLUMN_1.COLUMN.RATING:
|
|
56
|
+
case COLUMN_1.COLUMN.SLIDEBAR: {
|
|
57
|
+
if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL_1.CALCULATION_LABEL.PDIFF)
|
|
58
|
+
return defaultPercentage;
|
|
54
59
|
if (hasDefaultFormat) {
|
|
55
|
-
if ((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) ===
|
|
56
|
-
(aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) ===
|
|
60
|
+
if ((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.COUNT ||
|
|
61
|
+
(aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT)
|
|
57
62
|
return defaultNumeric;
|
|
58
63
|
return defaultFormat || defaultNumeric;
|
|
59
64
|
}
|
|
@@ -4,6 +4,7 @@ exports.defineXYChartFormat = void 0;
|
|
|
4
4
|
const AGGREGATE_1 = require("../../charts/constants/AGGREGATE");
|
|
5
5
|
const COLUMN_1 = require("../../columns/constants/COLUMN");
|
|
6
6
|
const isEmpty_1 = require("../../general/mix/isEmpty");
|
|
7
|
+
const CALCULATION_LABEL_1 = require("../../qrvey/constants/CALCULATION_LABEL");
|
|
7
8
|
const CHART_GROUP_1 = require("../constants/CHART_GROUP");
|
|
8
9
|
const DATEGROUP_UNSUPPORT_FORMAT_1 = require("../constants/DATEGROUP_UNSUPPORT_FORMAT");
|
|
9
10
|
const STRING_FORMAT_1 = require("../constants/STRING_FORMAT");
|
|
@@ -16,13 +17,17 @@ const columnTypeByChart_1 = require("./columnTypeByChart");
|
|
|
16
17
|
* @param {IColumnFormatSettings} settings - IColumnFormatSettings
|
|
17
18
|
*/
|
|
18
19
|
const defineXYChartFormat = (column, settings) => {
|
|
19
|
-
const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup, } = column;
|
|
20
|
+
const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup, calculation, } = column;
|
|
20
21
|
const { shelfType, withoutFormat } = settings;
|
|
21
22
|
const columnDefaultFormat = defaultFormat || outputFormat;
|
|
22
23
|
//Defaults
|
|
23
24
|
const defaultText = "Default";
|
|
24
25
|
const defaultAbb = { type: "NUMERIC", format: "Abbreviated" /* LOCALE_FORMATS.ABBREVIATED */ };
|
|
25
26
|
const defaultDecimal = { type: "NUMERIC", format: "Decimal" /* LOCALE_FORMATS.DECIMAL */ };
|
|
27
|
+
const defaultPercentage = {
|
|
28
|
+
type: "NUMERIC",
|
|
29
|
+
format: "Percentage" /* LOCALE_FORMATS.PERCENTAGE */,
|
|
30
|
+
};
|
|
26
31
|
const columnType = (0, columnTypeByChart_1.columnTypeByChart)(column, shelfType, CHART_GROUP_1.CHART_GROUPS.XY);
|
|
27
32
|
const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT_1.DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
|
|
28
33
|
const isUsedAsNumericColumn = type !== columnType;
|
|
@@ -58,6 +63,8 @@ const defineXYChartFormat = (column, settings) => {
|
|
|
58
63
|
case COLUMN_1.COLUMN.NUMERIC:
|
|
59
64
|
case COLUMN_1.COLUMN.RATING:
|
|
60
65
|
case COLUMN_1.COLUMN.SLIDEBAR: {
|
|
66
|
+
if ((calculation === null || calculation === void 0 ? void 0 : calculation.aggregate) === CALCULATION_LABEL_1.CALCULATION_LABEL.PDIFF)
|
|
67
|
+
return defaultPercentage;
|
|
61
68
|
if (((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.COUNT ||
|
|
62
69
|
(aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE_1.AGGREGATE.DISTINCTCOUNT) &&
|
|
63
70
|
hasDefaultFormat)
|
|
@@ -2,6 +2,7 @@ import { IColumnSortingSettings, IColumnType, IFormatOutputFormat, IFormulaType
|
|
|
2
2
|
import { IColumnAggregate } from "../../columns/interfaces/IColumnAggregate";
|
|
3
3
|
import { IColumnDateGroupSettings } from "../../columns/interfaces/IColumnDateGroupSettings";
|
|
4
4
|
import { IColumnScale } from "../../columns/interfaces/IColumnScale";
|
|
5
|
+
import { IColumnCalculation } from "../../columns/interfaces/IColunmCalculation";
|
|
5
6
|
import { IFormatDefaultFormat } from "../../interfaces/format/IFormatDefaultFormat";
|
|
6
7
|
export interface IChartColumn {
|
|
7
8
|
aggregate: IColumnAggregate;
|
|
@@ -20,4 +21,5 @@ export interface IChartColumn {
|
|
|
20
21
|
sorting?: IColumnSortingSettings;
|
|
21
22
|
text: string;
|
|
22
23
|
type: IColumnType;
|
|
24
|
+
calculation?: IColumnCalculation;
|
|
23
25
|
}
|
|
@@ -10,7 +10,7 @@ const DATE_DISTINCT_TIME_PROPERTY_1 = require("../../dates/constants/DATE_DISTIN
|
|
|
10
10
|
* @returns a adapted property
|
|
11
11
|
*/
|
|
12
12
|
function adaptDateGroupingProperty(property) {
|
|
13
|
-
return ODD_PROPERTY[property];
|
|
13
|
+
return ODD_PROPERTY[property] || property;
|
|
14
14
|
}
|
|
15
15
|
exports.adaptDateGroupingProperty = adaptDateGroupingProperty;
|
|
16
16
|
const ODD_PROPERTY = {
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import { AGGREGATE
|
|
1
|
+
import { AGGREGATE } from "../../charts/constants/AGGREGATE";
|
|
2
|
+
import { COLUMN } from "../../columns/constants/COLUMN";
|
|
3
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
4
|
import { CHART_GROUPS } from "../constants/CHART_GROUP";
|
|
3
|
-
import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
|
|
4
5
|
import { STRING_FORMAT } from "../constants/STRING_FORMAT";
|
|
5
6
|
import { TABLE_TYPE } from "../constants/TABLE_TYPE";
|
|
6
7
|
import { columnTypeByChart } from "./columnTypeByChart";
|
|
8
|
+
import { CALCULATION_LABEL } from "../../qrvey/constants/CALCULATION_LABEL";
|
|
7
9
|
/**
|
|
8
10
|
* It returns the format of a column based on the column type, the chart type, and the chart settings
|
|
9
11
|
* @param {IChartColumn} column - IChartColumn
|
|
10
12
|
* @param {IColumnFormatSettings} settings - IColumnFormatSettings
|
|
11
13
|
*/
|
|
12
14
|
export const defineTableChartFormat = (column, settings) => {
|
|
13
|
-
const { aggregate, defaultFormat, outputFormat, selectedFormat,
|
|
15
|
+
const { aggregate, defaultFormat, outputFormat, selectedFormat, calculation, } = column;
|
|
14
16
|
const { tableType, shelfType } = settings;
|
|
15
17
|
//Defaults
|
|
16
18
|
const defaultText = "Default";
|
|
17
|
-
const defaultNumeric = { type: "NUMERIC", format: "
|
|
19
|
+
const defaultNumeric = { type: "NUMERIC", format: "Decimal" /* LOCALE_FORMATS.DECIMAL */ };
|
|
20
|
+
const defaultPercentage = {
|
|
21
|
+
type: "NUMERIC",
|
|
22
|
+
format: "Percentage" /* LOCALE_FORMATS.PERCENTAGE */,
|
|
23
|
+
};
|
|
18
24
|
const isGroupedTable = tableType === TABLE_TYPE.GROUPED;
|
|
19
25
|
const columnType = columnTypeByChart(column, shelfType, CHART_GROUPS.TABLES, isGroupedTable);
|
|
20
|
-
const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
|
|
21
26
|
const hasDefaultFormat = isEmpty(selectedFormat) ||
|
|
22
27
|
(outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === defaultText ||
|
|
23
28
|
(selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.format) === defaultText;
|
|
@@ -34,11 +39,9 @@ export const defineTableChartFormat = (column, settings) => {
|
|
|
34
39
|
case COLUMN.TEXT_LABEL:
|
|
35
40
|
return STRING_FORMAT.NONE;
|
|
36
41
|
case COLUMN.DATE: {
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
else if (hasDefaultFormat) {
|
|
41
|
-
const columnDefaultFormat = defaultFormat || outputFormat || { type: 'DATE', format: 'MM/DD/YYYY' };
|
|
42
|
+
if (hasDefaultFormat) {
|
|
43
|
+
const columnDefaultFormat = defaultFormat ||
|
|
44
|
+
outputFormat || { type: "DATE", format: "MM/DD/YYYY" };
|
|
42
45
|
return Object.assign(Object.assign({}, defaultFormat), { format: defaultText, originalFormat: Object.assign({}, columnDefaultFormat), type: "DATE" });
|
|
43
46
|
}
|
|
44
47
|
else {
|
|
@@ -48,6 +51,8 @@ export const defineTableChartFormat = (column, settings) => {
|
|
|
48
51
|
case COLUMN.NUMERIC:
|
|
49
52
|
case COLUMN.RATING:
|
|
50
53
|
case COLUMN.SLIDEBAR: {
|
|
54
|
+
if ((calculation === null || calculation === void 0 ? void 0 : calculation.value) === CALCULATION_LABEL.PDIFF)
|
|
55
|
+
return defaultPercentage;
|
|
51
56
|
if (hasDefaultFormat) {
|
|
52
57
|
if ((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.COUNT ||
|
|
53
58
|
(aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.DISTINCTCOUNT)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AGGREGATE } from "../../charts/constants/AGGREGATE";
|
|
2
2
|
import { COLUMN } from "../../columns/constants/COLUMN";
|
|
3
3
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
4
|
+
import { CALCULATION_LABEL } from "../../qrvey/constants/CALCULATION_LABEL";
|
|
4
5
|
import { CHART_GROUPS } from "../constants/CHART_GROUP";
|
|
5
6
|
import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
|
|
6
7
|
import { STRING_FORMAT } from "../constants/STRING_FORMAT";
|
|
@@ -13,13 +14,17 @@ import { columnTypeByChart } from "./columnTypeByChart";
|
|
|
13
14
|
* @param {IColumnFormatSettings} settings - IColumnFormatSettings
|
|
14
15
|
*/
|
|
15
16
|
export const defineXYChartFormat = (column, settings) => {
|
|
16
|
-
const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup, } = column;
|
|
17
|
+
const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup, calculation, } = column;
|
|
17
18
|
const { shelfType, withoutFormat } = settings;
|
|
18
19
|
const columnDefaultFormat = defaultFormat || outputFormat;
|
|
19
20
|
//Defaults
|
|
20
21
|
const defaultText = "Default";
|
|
21
22
|
const defaultAbb = { type: "NUMERIC", format: "Abbreviated" /* LOCALE_FORMATS.ABBREVIATED */ };
|
|
22
23
|
const defaultDecimal = { type: "NUMERIC", format: "Decimal" /* LOCALE_FORMATS.DECIMAL */ };
|
|
24
|
+
const defaultPercentage = {
|
|
25
|
+
type: "NUMERIC",
|
|
26
|
+
format: "Percentage" /* LOCALE_FORMATS.PERCENTAGE */,
|
|
27
|
+
};
|
|
23
28
|
const columnType = columnTypeByChart(column, shelfType, CHART_GROUPS.XY);
|
|
24
29
|
const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
|
|
25
30
|
const isUsedAsNumericColumn = type !== columnType;
|
|
@@ -55,6 +60,8 @@ export const defineXYChartFormat = (column, settings) => {
|
|
|
55
60
|
case COLUMN.NUMERIC:
|
|
56
61
|
case COLUMN.RATING:
|
|
57
62
|
case COLUMN.SLIDEBAR: {
|
|
63
|
+
if ((calculation === null || calculation === void 0 ? void 0 : calculation.aggregate) === CALCULATION_LABEL.PDIFF)
|
|
64
|
+
return defaultPercentage;
|
|
58
65
|
if (((aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.COUNT ||
|
|
59
66
|
(aggregate === null || aggregate === void 0 ? void 0 : aggregate.label) === AGGREGATE.DISTINCTCOUNT) &&
|
|
60
67
|
hasDefaultFormat)
|
|
@@ -2,6 +2,7 @@ import { IColumnSortingSettings, IColumnType, IFormatOutputFormat, IFormulaType
|
|
|
2
2
|
import { IColumnAggregate } from "../../columns/interfaces/IColumnAggregate";
|
|
3
3
|
import { IColumnDateGroupSettings } from "../../columns/interfaces/IColumnDateGroupSettings";
|
|
4
4
|
import { IColumnScale } from "../../columns/interfaces/IColumnScale";
|
|
5
|
+
import { IColumnCalculation } from "../../columns/interfaces/IColunmCalculation";
|
|
5
6
|
import { IFormatDefaultFormat } from "../../interfaces/format/IFormatDefaultFormat";
|
|
6
7
|
export interface IChartColumn {
|
|
7
8
|
aggregate: IColumnAggregate;
|
|
@@ -20,4 +21,5 @@ export interface IChartColumn {
|
|
|
20
21
|
sorting?: IColumnSortingSettings;
|
|
21
22
|
text: string;
|
|
22
23
|
type: IColumnType;
|
|
24
|
+
calculation?: IColumnCalculation;
|
|
23
25
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,7 +7,7 @@ import { DATE_DISTINCT_TIME_PROPERTY } from "../../dates/constants/DATE_DISTINCT
|
|
|
7
7
|
* @returns a adapted property
|
|
8
8
|
*/
|
|
9
9
|
export function adaptDateGroupingProperty(property) {
|
|
10
|
-
return ODD_PROPERTY[property];
|
|
10
|
+
return ODD_PROPERTY[property] || property;
|
|
11
11
|
}
|
|
12
12
|
const ODD_PROPERTY = {
|
|
13
13
|
"p&quarter": DATE_DISTINCT_PROPERTY.YEAR_QUARTER,
|