@qrvey/utils 1.3.0-3 → 1.3.0-6
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/bitbucket-pipelines.yml +1 -1
- package/dist/cjs/column_format/constants/CHART_GROUP.d.ts +4 -0
- package/dist/cjs/column_format/constants/CHART_GROUP.js +8 -0
- package/dist/cjs/column_format/constants/DATEGROUP_UNSUPPORT_FORMAT.d.ts +2 -0
- package/dist/cjs/column_format/constants/DATEGROUP_UNSUPPORT_FORMAT.js +16 -0
- package/dist/cjs/column_format/constants/DATEGROUP_WITHOUT_FORMAT.d.ts +12 -0
- package/dist/cjs/column_format/constants/DATEGROUP_WITHOUT_FORMAT.js +16 -0
- package/dist/cjs/column_format/constants/SHELF_TYPE.d.ts +7 -0
- package/dist/cjs/column_format/constants/SHELF_TYPE.js +11 -0
- package/dist/cjs/column_format/constants/STRING_FORMAT.d.ts +3 -0
- package/dist/cjs/column_format/constants/STRING_FORMAT.js +7 -0
- package/dist/cjs/column_format/constants/TABLE_TYPE.d.ts +5 -0
- package/dist/cjs/column_format/constants/TABLE_TYPE.js +9 -0
- package/dist/cjs/column_format/constants/index.d.ts +6 -0
- package/dist/cjs/column_format/constants/index.js +22 -0
- package/dist/cjs/column_format/helpers/columnTypeByChart.d.ts +16 -0
- package/dist/cjs/column_format/helpers/columnTypeByChart.js +28 -0
- package/dist/cjs/column_format/helpers/defineFormatV2.d.ts +11 -0
- package/dist/cjs/column_format/helpers/defineFormatV2.js +17 -0
- package/dist/cjs/column_format/helpers/defineTableChartFormat.d.ts +9 -0
- package/dist/cjs/column_format/helpers/defineTableChartFormat.js +71 -0
- package/dist/cjs/column_format/helpers/defineXYChartFormat.d.ts +11 -0
- package/dist/cjs/column_format/helpers/defineXYChartFormat.js +76 -0
- package/dist/cjs/column_format/helpers/index.d.ts +5 -0
- package/dist/cjs/column_format/helpers/index.js +21 -0
- package/dist/cjs/column_format/helpers/parseFormulaTypeByCharts.d.ts +7 -0
- package/dist/cjs/column_format/helpers/parseFormulaTypeByCharts.js +20 -0
- package/dist/cjs/column_format/index.d.ts +3 -0
- package/dist/cjs/column_format/index.js +19 -0
- package/dist/cjs/column_format/interfaces/IChartColumn.d.ts +23 -0
- package/dist/cjs/column_format/interfaces/IChartColumn.js +2 -0
- package/dist/cjs/column_format/interfaces/IChartGroupType.d.ts +2 -0
- package/dist/cjs/column_format/interfaces/IChartGroupType.js +2 -0
- package/dist/cjs/column_format/interfaces/IChartShelfType.d.ts +2 -0
- package/dist/cjs/column_format/interfaces/IChartShelfType.js +2 -0
- package/dist/cjs/column_format/interfaces/IChartTableType.d.ts +2 -0
- package/dist/cjs/column_format/interfaces/IChartTableType.js +2 -0
- package/dist/cjs/column_format/interfaces/IColumnFormatReturnType.d.ts +3 -0
- package/dist/cjs/column_format/interfaces/IColumnFormatReturnType.js +2 -0
- package/dist/cjs/column_format/interfaces/IColumnFormatSettings.d.ts +9 -0
- package/dist/cjs/column_format/interfaces/IColumnFormatSettings.js +2 -0
- package/dist/cjs/column_format/interfaces/IFormatStringType.d.ts +2 -0
- package/dist/cjs/column_format/interfaces/IFormatStringType.js +2 -0
- package/dist/cjs/column_format/interfaces/index.d.ts +7 -0
- package/dist/cjs/column_format/interfaces/index.js +23 -0
- package/dist/cjs/columns/interfaces/IColumnAggregate.d.ts +7 -0
- package/dist/cjs/columns/interfaces/IColumnAggregate.js +2 -0
- package/dist/cjs/columns/interfaces/IColumnDateGroupSettings.d.ts +7 -0
- package/dist/cjs/columns/interfaces/IColumnDateGroupSettings.js +2 -0
- package/dist/cjs/columns/interfaces/IColumnScale.d.ts +5 -0
- package/dist/cjs/columns/interfaces/IColumnScale.js +2 -0
- package/dist/cjs/dates/helpers/getDatePickerPickLevel.d.ts +7 -0
- package/dist/cjs/dates/helpers/getDatePickerPickLevel.js +14 -0
- package/dist/cjs/dates/helpers/index.d.ts +1 -0
- package/dist/cjs/dates/helpers/index.js +1 -0
- package/dist/cjs/filters/helpers/common/resolveFilterConditions.js +5 -5
- package/dist/cjs/filters/interfaces/common/IFSParamsToGetFilter.d.ts +1 -1
- package/dist/cjs/general/array/addPropertyToArrayOfObjects.d.ts +22 -0
- package/dist/cjs/general/array/addPropertyToArrayOfObjects.js +32 -0
- package/dist/cjs/general/array/index.d.ts +1 -0
- package/dist/cjs/general/array/index.js +1 -0
- package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +3 -3
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/interfaces/format/IFormatDefaultFormat.d.ts +5 -0
- package/dist/cjs/interfaces/format/IFormatDefaultFormat.js +2 -0
- package/dist/cjs/interfaces/format/IFormatOutputFormat.Interface.d.ts +3 -5
- package/dist/column_format/constants/CHART_GROUP.d.ts +4 -0
- package/dist/column_format/constants/CHART_GROUP.js +5 -0
- package/dist/column_format/constants/DATEGROUP_UNSUPPORT_FORMAT.d.ts +2 -0
- package/dist/column_format/constants/DATEGROUP_UNSUPPORT_FORMAT.js +13 -0
- package/dist/column_format/constants/DATEGROUP_WITHOUT_FORMAT.d.ts +12 -0
- package/dist/column_format/constants/DATEGROUP_WITHOUT_FORMAT.js +13 -0
- package/dist/column_format/constants/SHELF_TYPE.d.ts +7 -0
- package/dist/column_format/constants/SHELF_TYPE.js +8 -0
- package/dist/column_format/constants/STRING_FORMAT.d.ts +3 -0
- package/dist/column_format/constants/STRING_FORMAT.js +4 -0
- package/dist/column_format/constants/TABLE_TYPE.d.ts +5 -0
- package/dist/column_format/constants/TABLE_TYPE.js +6 -0
- package/dist/column_format/constants/index.d.ts +6 -0
- package/dist/column_format/constants/index.js +6 -0
- package/dist/column_format/helpers/columnTypeByChart.d.ts +16 -0
- package/dist/column_format/helpers/columnTypeByChart.js +24 -0
- package/dist/column_format/helpers/defineFormatV2.d.ts +11 -0
- package/dist/column_format/helpers/defineFormatV2.js +13 -0
- package/dist/column_format/helpers/defineTableChartFormat.d.ts +9 -0
- package/dist/column_format/helpers/defineTableChartFormat.js +67 -0
- package/dist/column_format/helpers/defineXYChartFormat.d.ts +11 -0
- package/dist/column_format/helpers/defineXYChartFormat.js +72 -0
- package/dist/column_format/helpers/index.d.ts +5 -0
- package/dist/column_format/helpers/index.js +5 -0
- package/dist/column_format/helpers/parseFormulaTypeByCharts.d.ts +7 -0
- package/dist/column_format/helpers/parseFormulaTypeByCharts.js +16 -0
- package/dist/column_format/index.d.ts +3 -0
- package/dist/column_format/index.js +3 -0
- package/dist/column_format/interfaces/IChartColumn.d.ts +23 -0
- package/dist/column_format/interfaces/IChartColumn.js +1 -0
- package/dist/column_format/interfaces/IChartGroupType.d.ts +2 -0
- package/dist/column_format/interfaces/IChartGroupType.js +1 -0
- package/dist/column_format/interfaces/IChartShelfType.d.ts +2 -0
- package/dist/column_format/interfaces/IChartShelfType.js +1 -0
- package/dist/column_format/interfaces/IChartTableType.d.ts +2 -0
- package/dist/column_format/interfaces/IChartTableType.js +1 -0
- package/dist/column_format/interfaces/IColumnFormatReturnType.d.ts +3 -0
- package/dist/column_format/interfaces/IColumnFormatReturnType.js +1 -0
- package/dist/column_format/interfaces/IColumnFormatSettings.d.ts +9 -0
- package/dist/column_format/interfaces/IColumnFormatSettings.js +1 -0
- package/dist/column_format/interfaces/IFormatStringType.d.ts +2 -0
- package/dist/column_format/interfaces/IFormatStringType.js +1 -0
- package/dist/column_format/interfaces/index.d.ts +7 -0
- package/dist/column_format/interfaces/index.js +7 -0
- package/dist/columns/interfaces/IColumnAggregate.d.ts +7 -0
- package/dist/columns/interfaces/IColumnAggregate.js +1 -0
- package/dist/columns/interfaces/IColumnDateGroupSettings.d.ts +7 -0
- package/dist/columns/interfaces/IColumnDateGroupSettings.js +1 -0
- package/dist/columns/interfaces/IColumnScale.d.ts +5 -0
- package/dist/columns/interfaces/IColumnScale.js +1 -0
- package/dist/dates/helpers/getDatePickerPickLevel.d.ts +7 -0
- package/dist/dates/helpers/getDatePickerPickLevel.js +10 -0
- package/dist/dates/helpers/index.d.ts +1 -0
- package/dist/dates/helpers/index.js +1 -0
- package/dist/filters/helpers/common/resolveFilterConditions.js +5 -5
- package/dist/filters/interfaces/common/IFSParamsToGetFilter.d.ts +1 -1
- package/dist/general/array/addPropertyToArrayOfObjects.d.ts +22 -0
- package/dist/general/array/addPropertyToArrayOfObjects.js +28 -0
- package/dist/general/array/index.d.ts +1 -0
- package/dist/general/array/index.js +1 -0
- package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/format/IFormatDefaultFormat.d.ts +5 -0
- package/dist/interfaces/format/IFormatDefaultFormat.js +1 -0
- package/dist/interfaces/format/IFormatOutputFormat.Interface.d.ts +3 -5
- package/jest.config.js +1 -0
- package/package.json +7 -6
- package/src/column_format/constants/CHART_GROUP.ts +4 -0
- package/src/column_format/constants/DATEGROUP_UNSUPPORT_FORMAT.ts +14 -0
- package/src/column_format/constants/DATEGROUP_WITHOUT_FORMAT.ts +12 -0
- package/src/column_format/constants/SHELF_TYPE.ts +7 -0
- package/src/column_format/constants/STRING_FORMAT.ts +3 -0
- package/src/column_format/constants/TABLE_TYPE.ts +5 -0
- package/src/column_format/constants/index.ts +6 -0
- package/src/column_format/helpers/columnTypeByChart.ts +27 -0
- package/src/column_format/helpers/defineFormatV2.ts +17 -0
- package/src/column_format/helpers/defineTableChartFormat.ts +70 -0
- package/src/column_format/helpers/defineXYChartFormat.ts +81 -0
- package/src/column_format/helpers/index.ts +5 -0
- package/src/column_format/helpers/parseFormulaTypeByCharts.ts +17 -0
- package/src/column_format/index.ts +3 -0
- package/src/column_format/interfaces/IChartColumn.ts +24 -0
- package/src/column_format/interfaces/IChartGroupType.ts +3 -0
- package/src/column_format/interfaces/IChartShelfType.ts +3 -0
- package/src/column_format/interfaces/IChartTableType.ts +3 -0
- package/src/column_format/interfaces/IColumnFormatReturnType.ts +4 -0
- package/src/column_format/interfaces/IColumnFormatSettings.ts +11 -0
- package/src/column_format/interfaces/IFormatStringType.ts +3 -0
- package/src/column_format/interfaces/index.ts +7 -0
- package/src/columns/interfaces/IColumnAggregate.ts +7 -0
- package/src/columns/interfaces/IColumnDateGroupSettings.ts +7 -0
- package/src/columns/interfaces/IColumnScale.ts +5 -0
- package/src/dates/helpers/getDatePickerPickLevel.ts +12 -0
- package/src/dates/helpers/index.ts +1 -0
- package/src/filters/helpers/common/resolveFilterConditions.ts +4 -4
- package/src/filters/interfaces/common/IFSParamsToGetFilter.ts +2 -2
- package/src/general/array/addPropertyToArrayOfObjects.ts +32 -0
- package/src/general/array/index.ts +1 -0
- package/src/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.ts +3 -3
- package/src/index.ts +1 -0
- package/src/interfaces/format/IFormatDefaultFormat.ts +5 -0
- package/src/interfaces/format/IFormatOutputFormat.Interface.ts +3 -5
- package/test/general/array/addPropertyToArrayOfObjects.test.js +96 -0
- package/test/tokens/{isTokenLabel.test.js → isTokenLabel.test.ts} +38 -38
- package/tsconfig.json +3 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IColumnSortingSettings, IColumnType, IFormatOutputFormat, IFormulaType } from "../..";
|
|
2
|
+
import { IColumnAggregate } from "../../columns/interfaces/IColumnAggregate";
|
|
3
|
+
import { IColumnDateGroupSettings } from "../../columns/interfaces/IColumnDateGroupSettings";
|
|
4
|
+
import { IColumnScale } from "../../columns/interfaces/IColumnScale";
|
|
5
|
+
import { IFormatDefaultFormat } from "../../interfaces/format/IFormatDefaultFormat";
|
|
6
|
+
export interface IChartColumn {
|
|
7
|
+
aggregate: IColumnAggregate;
|
|
8
|
+
colIndex: number;
|
|
9
|
+
dateGroup?: IColumnDateGroupSettings;
|
|
10
|
+
defaultFormat: IFormatDefaultFormat;
|
|
11
|
+
format?: string;
|
|
12
|
+
formulaType?: IFormulaType;
|
|
13
|
+
groupAgg: string;
|
|
14
|
+
id: string;
|
|
15
|
+
isGroup: string;
|
|
16
|
+
outputFormat: IFormatOutputFormat;
|
|
17
|
+
property: string;
|
|
18
|
+
scaleType?: IColumnScale;
|
|
19
|
+
selectedFormat?: IFormatDefaultFormat;
|
|
20
|
+
sorting?: IColumnSortingSettings;
|
|
21
|
+
text: string;
|
|
22
|
+
type: IColumnType;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IChartShelfType } from "./IChartShelfType";
|
|
2
|
+
import { IChartTableType } from "./IChartTableType";
|
|
3
|
+
export interface IColumnFormatSettings {
|
|
4
|
+
tableType?: IChartTableType;
|
|
5
|
+
isTableChart?: boolean;
|
|
6
|
+
isXYChart?: boolean;
|
|
7
|
+
shelfType: IChartShelfType;
|
|
8
|
+
withoutFormat: boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './IChartColumn';
|
|
2
|
+
export * from './IChartGroupType';
|
|
3
|
+
export * from './IChartShelfType';
|
|
4
|
+
export * from './IChartTableType';
|
|
5
|
+
export * from './IColumnFormatReturnType';
|
|
6
|
+
export * from './IColumnFormatSettings';
|
|
7
|
+
export * from './IFormatStringType';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './IChartColumn';
|
|
2
|
+
export * from './IChartGroupType';
|
|
3
|
+
export * from './IChartShelfType';
|
|
4
|
+
export * from './IChartTableType';
|
|
5
|
+
export * from './IColumnFormatReturnType';
|
|
6
|
+
export * from './IColumnFormatSettings';
|
|
7
|
+
export * from './IFormatStringType';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDateFormat } from "../interfaces/IDateFormat";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the pick level number related to the Date picker element
|
|
4
|
+
* @param {IDateFormat} format The date format
|
|
5
|
+
* @returns {number} A number of the pick level setting
|
|
6
|
+
*/
|
|
7
|
+
export declare function getDatePickerPickLevel(format: IDateFormat): 0 | 1 | 2;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
2
|
+
/**
|
|
3
|
+
* Gets the pick level number related to the Date picker element
|
|
4
|
+
* @param {IDateFormat} format The date format
|
|
5
|
+
* @returns {number} A number of the pick level setting
|
|
6
|
+
*/
|
|
7
|
+
export function getDatePickerPickLevel(format) {
|
|
8
|
+
return format === DATE_FORMAT.YEAR ? 2 :
|
|
9
|
+
format === DATE_FORMAT.MONTH ? 1 : 0;
|
|
10
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './getDateByDateFormat';
|
|
2
2
|
export * from './getDateFormatByProperty';
|
|
3
3
|
export * from './getDateFormatRegularExpressionInArray';
|
|
4
|
+
export * from './getDatePickerPickLevel';
|
|
4
5
|
export * from './getFormattedDateByFormat';
|
|
5
6
|
export * from './getSeparatorByDateFormat';
|
|
6
7
|
export * from './includeDateTokens';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './getDateByDateFormat';
|
|
2
2
|
export * from './getDateFormatByProperty';
|
|
3
3
|
export * from './getDateFormatRegularExpressionInArray';
|
|
4
|
+
export * from './getDatePickerPickLevel';
|
|
4
5
|
export * from './getFormattedDateByFormat';
|
|
5
6
|
export * from './getSeparatorByDateFormat';
|
|
6
7
|
export * from './includeDateTokens';
|
|
@@ -9,14 +9,14 @@ import { _hasProperty } from "../../../general/object/hasProperty";
|
|
|
9
9
|
* @returns true: the condition is satisfied
|
|
10
10
|
*/
|
|
11
11
|
export function resolveFilterConditions(filter, params, letPassUndefinedProperties = false, letPassUndefinedParams = true) {
|
|
12
|
-
var _a, _b, _c, _d;
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13
13
|
return (!_hasProperty(params, 'enableds') || !_hasProperty(params.enableds, 'filters') || (letPassUndefinedProperties && filter.enabled == null) || (letPassUndefinedParams && params.enableds.filters == null) || params.enableds.filters === filter.enabled) &&
|
|
14
14
|
(!_hasProperty(params, 'dateSection') || (letPassUndefinedProperties && filter.dateSection == null) || (letPassUndefinedParams && isEmpty(params.dateSection)) || params.dateSection === filter.dateSection) &&
|
|
15
15
|
(!_hasProperty(params, 'panelid') || (letPassUndefinedProperties && filter.extras.panelid == null) || (letPassUndefinedParams && isEmpty(params.panelid)) || params.panelid === filter.extras.panelid) &&
|
|
16
16
|
(!_hasProperty(params, 'property') || (letPassUndefinedProperties && filter.property == null) || (letPassUndefinedParams && isEmpty(params.property)) || params.property === filter.property) &&
|
|
17
17
|
(!_hasProperty(params, 'validator') || (letPassUndefinedProperties && filter.validator == null) || (letPassUndefinedParams && isEmpty(params.validator)) || params.validator === filter.validator) &&
|
|
18
|
-
(!_hasProperty(params, 'column') || (letPassUndefinedProperties && filter.column == null) || (letPassUndefinedParams && isEmpty(params.column)) || (((_a = params.column) === null || _a === void 0 ? void 0 : _a.id) === filter.column.id &&
|
|
19
|
-
((
|
|
20
|
-
((
|
|
21
|
-
((
|
|
18
|
+
(!_hasProperty(params, 'column') || (letPassUndefinedProperties && filter.column == null) || (letPassUndefinedParams && isEmpty(params.column)) || ((letPassUndefinedParams && isEmpty((_a = params.column) === null || _a === void 0 ? void 0 : _a.id) || ((_b = params.column) === null || _b === void 0 ? void 0 : _b.id) === filter.column.id) &&
|
|
19
|
+
(letPassUndefinedParams && isEmpty((_c = params.column) === null || _c === void 0 ? void 0 : _c.qrveyid) || ((_d = params.column) === null || _d === void 0 ? void 0 : _d.qrveyid) === filter.column.qrveyid) &&
|
|
20
|
+
(letPassUndefinedParams && isEmpty((_e = params.column) === null || _e === void 0 ? void 0 : _e.linkid) || ((_f = params.column) === null || _f === void 0 ? void 0 : _f.linkid) === filter.column.linkid) &&
|
|
21
|
+
(letPassUndefinedParams && isEmpty((_g = params.column) === null || _g === void 0 ? void 0 : _g.aggregate) || ((_h = params.column) === null || _h === void 0 ? void 0 : _h.aggregate) === filter.column.aggregate)));
|
|
22
22
|
}
|
|
@@ -8,7 +8,7 @@ import { IFSParamsToGetFilterEnableds } from "./IFSParamsToGetFilterEnableds";
|
|
|
8
8
|
* Structure for filter properties
|
|
9
9
|
*/
|
|
10
10
|
export interface IFSParamsToGetFilter {
|
|
11
|
-
column?: IFSColumn
|
|
11
|
+
column?: Partial<IFSColumn>;
|
|
12
12
|
dateSection?: IFDateSection;
|
|
13
13
|
enableds?: IFSParamsToGetFilterEnableds;
|
|
14
14
|
linkid?: string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* It takes an array of objects, adds a property to each object, and returns the new array.
|
|
3
|
+
* @param {Object} info - Information needed to add property to the array of objects.
|
|
4
|
+
* @param {Array} info.array - The array of objects you want to add a property to.
|
|
5
|
+
* @param {string} info.property - The property you want to add to the object.
|
|
6
|
+
* @param {any} info.value - - The value to be added to the array of objects.
|
|
7
|
+
* ----------------------------------------------------------------------------------------------
|
|
8
|
+
* @example <caption>Example usage of addPropertyToArrayOfObjects.</caption>
|
|
9
|
+
* addPropertyToArrayOfObjects({
|
|
10
|
+
* array: [{ name: "John", lastName: "Doe" }, { name: "Chris", lastName: "Musk" }],
|
|
11
|
+
* property: "lastName",
|
|
12
|
+
* value: 'Peck'
|
|
13
|
+
* });
|
|
14
|
+
* @returns the new array created.
|
|
15
|
+
*/
|
|
16
|
+
export declare function addPropertyToArrayOfObjects(obj: AddPropertyToArrayOfObjectsParams): any[];
|
|
17
|
+
declare type AddPropertyToArrayOfObjectsParams = {
|
|
18
|
+
array: any[];
|
|
19
|
+
property: string;
|
|
20
|
+
value: any;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isEmpty } from '../mix/isEmpty';
|
|
2
|
+
import { isObject } from '../object/isObject';
|
|
3
|
+
/**
|
|
4
|
+
* It takes an array of objects, adds a property to each object, and returns the new array.
|
|
5
|
+
* @param {Object} info - Information needed to add property to the array of objects.
|
|
6
|
+
* @param {Array} info.array - The array of objects you want to add a property to.
|
|
7
|
+
* @param {string} info.property - The property you want to add to the object.
|
|
8
|
+
* @param {any} info.value - - The value to be added to the array of objects.
|
|
9
|
+
* ----------------------------------------------------------------------------------------------
|
|
10
|
+
* @example <caption>Example usage of addPropertyToArrayOfObjects.</caption>
|
|
11
|
+
* addPropertyToArrayOfObjects({
|
|
12
|
+
* array: [{ name: "John", lastName: "Doe" }, { name: "Chris", lastName: "Musk" }],
|
|
13
|
+
* property: "lastName",
|
|
14
|
+
* value: 'Peck'
|
|
15
|
+
* });
|
|
16
|
+
* @returns the new array created.
|
|
17
|
+
*/
|
|
18
|
+
export function addPropertyToArrayOfObjects(obj) {
|
|
19
|
+
if (isEmpty(obj) || !isObject(obj))
|
|
20
|
+
return [];
|
|
21
|
+
const { array, property, value } = obj;
|
|
22
|
+
if (Array.isArray(array)) {
|
|
23
|
+
if (isEmpty(array) || isEmpty(property))
|
|
24
|
+
return array;
|
|
25
|
+
return array.map((element) => (Object.assign(Object.assign({}, element), { [property]: value })));
|
|
26
|
+
}
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
@@ -184,9 +184,9 @@ export const I18N_CHART_BUILDER_STYLE_OPTIONS = {
|
|
|
184
184
|
align: 'Align',
|
|
185
185
|
align_all_columns: 'All Columns',
|
|
186
186
|
align_default: 'Default',
|
|
187
|
-
align_left: '
|
|
188
|
-
align_right: '
|
|
189
|
-
align_center: '
|
|
187
|
+
align_left: 'Left',
|
|
188
|
+
align_right: 'Right',
|
|
189
|
+
align_center: 'Center',
|
|
190
190
|
typeface: 'Typeface',
|
|
191
191
|
weight: 'Weight',
|
|
192
192
|
weight_bold: 'Bold',
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { IFormatCurrency } from "./IFormatCurrency.Interface";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type: string;
|
|
5
|
-
decimals?: number;
|
|
2
|
+
import { IFormatDefaultFormat } from "./IFormatDefaultFormat";
|
|
3
|
+
export interface IFormatOutputFormat extends IFormatDefaultFormat {
|
|
6
4
|
currency?: IFormatCurrency;
|
|
7
5
|
backup_currency?: IFormatCurrency;
|
|
8
|
-
originalFormat?:
|
|
6
|
+
originalFormat?: IFormatOutputFormat;
|
|
9
7
|
}
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qrvey/utils",
|
|
3
|
-
"version": "1.3.0-
|
|
3
|
+
"version": "1.3.0-6",
|
|
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",
|
|
@@ -21,15 +21,16 @@
|
|
|
21
21
|
"author": "Qrvey Inc",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
+
"@compodoc/compodoc": "1.1.19",
|
|
25
|
+
"@types/jest": "27.5.0",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "5.22.0",
|
|
27
|
+
"@typescript-eslint/parser": "5.22.0",
|
|
24
28
|
"eslint": "8.14.0",
|
|
25
29
|
"jest": "27.5.1",
|
|
26
30
|
"np": "7.6.1",
|
|
31
|
+
"ts-jest": "27.1.4",
|
|
27
32
|
"typedoc": "0.22.15",
|
|
28
|
-
"typescript": "4.6.4"
|
|
29
|
-
"@compodoc/compodoc": "1.1.19",
|
|
30
|
-
"@types/jest": "27.4.1",
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "5.22.0",
|
|
32
|
-
"@typescript-eslint/parser": "5.22.0"
|
|
33
|
+
"typescript": "4.6.4"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"d3": "6.3.1",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DATEGROUP_WITHOUT_FORMAT } from "./DATEGROUP_WITHOUT_FORMAT";
|
|
2
|
+
|
|
3
|
+
export const DATEGROUP_UNSUPPORT_FORMAT = [
|
|
4
|
+
DATEGROUP_WITHOUT_FORMAT.YEAR,
|
|
5
|
+
DATEGROUP_WITHOUT_FORMAT.QUARTER,
|
|
6
|
+
DATEGROUP_WITHOUT_FORMAT.MONTH,
|
|
7
|
+
DATEGROUP_WITHOUT_FORMAT.WEEK,
|
|
8
|
+
DATEGROUP_WITHOUT_FORMAT.QUARTER_ONLY,
|
|
9
|
+
DATEGROUP_WITHOUT_FORMAT.MONTH_ONLY,
|
|
10
|
+
DATEGROUP_WITHOUT_FORMAT.DAY_ONLY,
|
|
11
|
+
DATEGROUP_WITHOUT_FORMAT.HOUR_ONLY,
|
|
12
|
+
DATEGROUP_WITHOUT_FORMAT.MINUTE_ONLY,
|
|
13
|
+
DATEGROUP_WITHOUT_FORMAT.SECOND_ONLY
|
|
14
|
+
];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export enum DATEGROUP_WITHOUT_FORMAT {
|
|
2
|
+
YEAR = 'YEAR',
|
|
3
|
+
QUARTER = 'QUARTER',
|
|
4
|
+
MONTH = 'MONTH',
|
|
5
|
+
WEEK = 'WEEK',
|
|
6
|
+
QUARTER_ONLY = 'QUARTER_ONLY',
|
|
7
|
+
MONTH_ONLY = 'MONTH_ONLY',
|
|
8
|
+
DAY_ONLY = 'DAY_ONLY',
|
|
9
|
+
HOUR_ONLY = 'HOUR_ONLY',
|
|
10
|
+
MINUTE_ONLY = 'MINUTE_ONLY',
|
|
11
|
+
SECOND_ONLY = 'SECOND_ONLY'
|
|
12
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { NUMERICAL_COLUMN, NUMERICAL_COLUMNS } from "../..";
|
|
2
|
+
import { COLUMN } from "../../columns";
|
|
3
|
+
import { CHART_GROUPS } from "../constants/CHART_GROUP";
|
|
4
|
+
import { SHELF_TYPE } from "../constants/SHELF_TYPE";
|
|
5
|
+
import { IChartColumn } from "../interfaces/IChartColumn";
|
|
6
|
+
import { IChartGroupType } from "../interfaces/IChartGroupType";
|
|
7
|
+
import { IChartShelfType } from "../interfaces/IChartShelfType";
|
|
8
|
+
import { parseFormulaTypeByCharts } from "./parseFormulaTypeByCharts";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* It returns the column type for a given column, shelf type, chart group, and whether the table is
|
|
12
|
+
* grouped or not
|
|
13
|
+
* @param {IChartColumn} column - IChartColumn
|
|
14
|
+
* @param {IChartShelfType} shelfType - IChartShelfType
|
|
15
|
+
* @param {IChartGroupType} chartGroup - IChartGroupType
|
|
16
|
+
* @param {boolean} [isGroupedTable] - boolean - this is a boolean that is true if the table is
|
|
17
|
+
* grouped.
|
|
18
|
+
* @returns The column type of the column.
|
|
19
|
+
*/
|
|
20
|
+
export const columnTypeByChart = (column: IChartColumn, shelfType: IChartShelfType, chartGroup: IChartGroupType, isGroupedTable?: boolean) => {
|
|
21
|
+
if (!column) return;
|
|
22
|
+
const currentType = column.type === COLUMN.FORMULA ? parseFormulaTypeByCharts(column.formulaType) : column.type;
|
|
23
|
+
const isNumericalColumn = NUMERICAL_COLUMNS.some(colType => colType === currentType)
|
|
24
|
+
|| ((chartGroup === CHART_GROUPS.TABLES) && (isGroupedTable === true) && (shelfType === SHELF_TYPE.COLUMNS))
|
|
25
|
+
|| ((chartGroup === CHART_GROUPS.XY) && (shelfType === SHELF_TYPE.VALUE || shelfType === SHELF_TYPE.SERIES));
|
|
26
|
+
return isNumericalColumn === true ? NUMERICAL_COLUMN.NUMERIC : currentType;
|
|
27
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IChartColumn } from "../interfaces/IChartColumn";
|
|
2
|
+
import { IColumnFormatReturnType } from "../interfaces/IColumnFormatReturnType";
|
|
3
|
+
import { IColumnFormatSettings } from "../interfaces/IColumnFormatSettings";
|
|
4
|
+
import { defineTableChartFormat } from "./defineTableChartFormat";
|
|
5
|
+
import { defineXYChartFormat } from "./defineXYChartFormat";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* > If the chart is a table chart, then define the format for a table chart, otherwise define the
|
|
9
|
+
* format for an XY chart
|
|
10
|
+
* @param {IChartColumn} column - IChartColumn - this is the column object that is passed to the chart.
|
|
11
|
+
* @param {IColumnFormatSettings} settings - IColumnFormatSettings
|
|
12
|
+
* @returns IColumnFormatReturnType
|
|
13
|
+
*/
|
|
14
|
+
export const defineFormatV2 = (column: IChartColumn, settings: IColumnFormatSettings) : IColumnFormatReturnType => {
|
|
15
|
+
const { isTableChart, isXYChart } = settings;
|
|
16
|
+
return isTableChart && !isXYChart ? defineTableChartFormat(column, settings) : defineXYChartFormat(column, settings);
|
|
17
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AGGREGATE, COLUMN, isEmpty } from "../..";
|
|
2
|
+
import { CHART_GROUPS } from "../constants/CHART_GROUP";
|
|
3
|
+
import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
|
|
4
|
+
import { STRING_FORMAT } from "../constants/STRING_FORMAT";
|
|
5
|
+
import { TABLE_TYPE } from "../constants/TABLE_TYPE";
|
|
6
|
+
import { IChartColumn } from "../interfaces/IChartColumn";
|
|
7
|
+
import { IColumnFormatReturnType } from "../interfaces/IColumnFormatReturnType";
|
|
8
|
+
import { IColumnFormatSettings } from "../interfaces/IColumnFormatSettings";
|
|
9
|
+
import { columnTypeByChart } from "./columnTypeByChart";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* It returns the format of a column based on the column type, the chart type, and the chart settings
|
|
13
|
+
* @param {IChartColumn} column - IChartColumn
|
|
14
|
+
* @param {IColumnFormatSettings} settings - IColumnFormatSettings
|
|
15
|
+
*/
|
|
16
|
+
export const defineTableChartFormat = (column: IChartColumn, settings: IColumnFormatSettings) : IColumnFormatReturnType => {
|
|
17
|
+
const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup } = column;
|
|
18
|
+
const { tableType, shelfType } = settings;
|
|
19
|
+
//Defaults
|
|
20
|
+
const defaultText = 'Default';
|
|
21
|
+
const defaultNumeric = { type: 'NUMERIC', format: 'Numeric' };
|
|
22
|
+
const defaultAbb = { type: 'NUMERIC', format: 'Abbreviated' };
|
|
23
|
+
|
|
24
|
+
const isGroupedTable = tableType === TABLE_TYPE.GROUPED;
|
|
25
|
+
const columnType = columnTypeByChart(column, shelfType, CHART_GROUPS.TABLES, isGroupedTable);
|
|
26
|
+
|
|
27
|
+
const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some(gp => gp === dateGroup?.label);
|
|
28
|
+
const hasDefaultFormat = isEmpty(selectedFormat) && outputFormat?.format === defaultText;
|
|
29
|
+
const isUsedAsNumericColumn = type !== columnType;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
switch(columnType) {
|
|
33
|
+
case COLUMN.YES_NO:
|
|
34
|
+
case COLUMN.PHONE:
|
|
35
|
+
case COLUMN.SINGLE_CHOICE:
|
|
36
|
+
case COLUMN.LONGTEXT:
|
|
37
|
+
case COLUMN.DROPDOWN:
|
|
38
|
+
case COLUMN.EXPRESSION:
|
|
39
|
+
case COLUMN.NAME:
|
|
40
|
+
case COLUMN.EMAIL_FORM:
|
|
41
|
+
case COLUMN.IMAGE:
|
|
42
|
+
case COLUMN.TEXT_LABEL:
|
|
43
|
+
return STRING_FORMAT.NONE;
|
|
44
|
+
case COLUMN.DATE: {
|
|
45
|
+
if(noFormatSupported) {
|
|
46
|
+
return STRING_FORMAT.NONE;
|
|
47
|
+
}
|
|
48
|
+
else if(hasDefaultFormat) {
|
|
49
|
+
return { ...defaultFormat, format: defaultText, originalFormat: { ...column.outputFormat } };
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return selectedFormat;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
case COLUMN.NUMERIC:
|
|
56
|
+
case COLUMN.RATING:
|
|
57
|
+
case COLUMN.SLIDEBAR: {
|
|
58
|
+
if(isUsedAsNumericColumn) {
|
|
59
|
+
if(aggregate?.label === AGGREGATE.COUNT && hasDefaultFormat) return defaultNumeric;
|
|
60
|
+
else if(hasDefaultFormat) return defaultAbb;
|
|
61
|
+
else return outputFormat;
|
|
62
|
+
} else {
|
|
63
|
+
if(hasDefaultFormat) {
|
|
64
|
+
return { ...defaultFormat, format: defaultText, originalFormat: { ...column.outputFormat } };
|
|
65
|
+
}
|
|
66
|
+
else return selectedFormat;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AGGREGATE, COLUMN, isEmpty } from "../..";
|
|
2
|
+
import { CHART_GROUPS } from "../constants/CHART_GROUP";
|
|
3
|
+
import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
|
|
4
|
+
import { STRING_FORMAT } from "../constants/STRING_FORMAT";
|
|
5
|
+
import { IChartColumn } from "../interfaces/IChartColumn";
|
|
6
|
+
import { IColumnFormatReturnType } from "../interfaces/IColumnFormatReturnType";
|
|
7
|
+
import { IColumnFormatSettings } from "../interfaces/IColumnFormatSettings";
|
|
8
|
+
import { columnTypeByChart } from "./columnTypeByChart";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* > It returns the format of a column based on the column's type, the chart's type, and the column's
|
|
12
|
+
* aggregate
|
|
13
|
+
* > Also, if the settings contains the prop withoutFormat as true, returns the default format
|
|
14
|
+
* @param {IChartColumn} column - IChartColumn
|
|
15
|
+
* @param {IColumnFormatSettings} settings - IColumnFormatSettings
|
|
16
|
+
*/
|
|
17
|
+
export const defineXYChartFormat = (column: IChartColumn, settings: IColumnFormatSettings) : IColumnFormatReturnType => {
|
|
18
|
+
const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup } = column;
|
|
19
|
+
const { shelfType, withoutFormat } = settings;
|
|
20
|
+
|
|
21
|
+
//Defaults
|
|
22
|
+
const defaultText = 'Default';
|
|
23
|
+
//const defaultNumeric = { type: 'NUMERIC', format: 'Numeric' };
|
|
24
|
+
const defaultAbb = { type: 'NUMERIC', format: 'Abbreviated' };
|
|
25
|
+
|
|
26
|
+
const columnType = columnTypeByChart(column, shelfType, CHART_GROUPS.XY);
|
|
27
|
+
|
|
28
|
+
const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some(gp => gp === dateGroup?.label);
|
|
29
|
+
const isUsedAsNumericColumn = type !== columnType;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const hasDefaultFormat = (isEmpty(selectedFormat) && outputFormat?.format === defaultText) || (selectedFormat?.format === defaultText);
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
switch(columnType) {
|
|
36
|
+
case COLUMN.YES_NO:
|
|
37
|
+
case COLUMN.PHONE:
|
|
38
|
+
case COLUMN.SINGLE_CHOICE:
|
|
39
|
+
case COLUMN.LONGTEXT:
|
|
40
|
+
case COLUMN.DROPDOWN:
|
|
41
|
+
case COLUMN.EXPRESSION:
|
|
42
|
+
case COLUMN.NAME:
|
|
43
|
+
case COLUMN.EMAIL_FORM:
|
|
44
|
+
case COLUMN.IMAGE:
|
|
45
|
+
case COLUMN.TEXT_LABEL:
|
|
46
|
+
return STRING_FORMAT.NONE;
|
|
47
|
+
case COLUMN.DATE: {
|
|
48
|
+
if(noFormatSupported) {
|
|
49
|
+
return STRING_FORMAT.NONE;
|
|
50
|
+
}
|
|
51
|
+
else if(hasDefaultFormat) {
|
|
52
|
+
return { ...defaultFormat, format: defaultText, originalFormat: { ...outputFormat } };
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return selectedFormat;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
case COLUMN.NUMERIC:
|
|
59
|
+
case COLUMN.RATING:
|
|
60
|
+
case COLUMN.SLIDEBAR: {
|
|
61
|
+
if(isUsedAsNumericColumn) {
|
|
62
|
+
if(
|
|
63
|
+
(aggregate?.label === AGGREGATE.COUNT && hasDefaultFormat)
|
|
64
|
+
||
|
|
65
|
+
(isUsedAsNumericColumn && outputFormat?.type !== COLUMN.NUMERIC)
|
|
66
|
+
||
|
|
67
|
+
withoutFormat
|
|
68
|
+
) return defaultAbb;
|
|
69
|
+
else return outputFormat;
|
|
70
|
+
} else {
|
|
71
|
+
if(withoutFormat === true) {
|
|
72
|
+
return defaultFormat;
|
|
73
|
+
}
|
|
74
|
+
else if(hasDefaultFormat) {
|
|
75
|
+
return { ...outputFormat };
|
|
76
|
+
}
|
|
77
|
+
else return selectedFormat;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|