@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.
Files changed (173) hide show
  1. package/bitbucket-pipelines.yml +1 -1
  2. package/dist/cjs/column_format/constants/CHART_GROUP.d.ts +4 -0
  3. package/dist/cjs/column_format/constants/CHART_GROUP.js +8 -0
  4. package/dist/cjs/column_format/constants/DATEGROUP_UNSUPPORT_FORMAT.d.ts +2 -0
  5. package/dist/cjs/column_format/constants/DATEGROUP_UNSUPPORT_FORMAT.js +16 -0
  6. package/dist/cjs/column_format/constants/DATEGROUP_WITHOUT_FORMAT.d.ts +12 -0
  7. package/dist/cjs/column_format/constants/DATEGROUP_WITHOUT_FORMAT.js +16 -0
  8. package/dist/cjs/column_format/constants/SHELF_TYPE.d.ts +7 -0
  9. package/dist/cjs/column_format/constants/SHELF_TYPE.js +11 -0
  10. package/dist/cjs/column_format/constants/STRING_FORMAT.d.ts +3 -0
  11. package/dist/cjs/column_format/constants/STRING_FORMAT.js +7 -0
  12. package/dist/cjs/column_format/constants/TABLE_TYPE.d.ts +5 -0
  13. package/dist/cjs/column_format/constants/TABLE_TYPE.js +9 -0
  14. package/dist/cjs/column_format/constants/index.d.ts +6 -0
  15. package/dist/cjs/column_format/constants/index.js +22 -0
  16. package/dist/cjs/column_format/helpers/columnTypeByChart.d.ts +16 -0
  17. package/dist/cjs/column_format/helpers/columnTypeByChart.js +28 -0
  18. package/dist/cjs/column_format/helpers/defineFormatV2.d.ts +11 -0
  19. package/dist/cjs/column_format/helpers/defineFormatV2.js +17 -0
  20. package/dist/cjs/column_format/helpers/defineTableChartFormat.d.ts +9 -0
  21. package/dist/cjs/column_format/helpers/defineTableChartFormat.js +71 -0
  22. package/dist/cjs/column_format/helpers/defineXYChartFormat.d.ts +11 -0
  23. package/dist/cjs/column_format/helpers/defineXYChartFormat.js +76 -0
  24. package/dist/cjs/column_format/helpers/index.d.ts +5 -0
  25. package/dist/cjs/column_format/helpers/index.js +21 -0
  26. package/dist/cjs/column_format/helpers/parseFormulaTypeByCharts.d.ts +7 -0
  27. package/dist/cjs/column_format/helpers/parseFormulaTypeByCharts.js +20 -0
  28. package/dist/cjs/column_format/index.d.ts +3 -0
  29. package/dist/cjs/column_format/index.js +19 -0
  30. package/dist/cjs/column_format/interfaces/IChartColumn.d.ts +23 -0
  31. package/dist/cjs/column_format/interfaces/IChartColumn.js +2 -0
  32. package/dist/cjs/column_format/interfaces/IChartGroupType.d.ts +2 -0
  33. package/dist/cjs/column_format/interfaces/IChartGroupType.js +2 -0
  34. package/dist/cjs/column_format/interfaces/IChartShelfType.d.ts +2 -0
  35. package/dist/cjs/column_format/interfaces/IChartShelfType.js +2 -0
  36. package/dist/cjs/column_format/interfaces/IChartTableType.d.ts +2 -0
  37. package/dist/cjs/column_format/interfaces/IChartTableType.js +2 -0
  38. package/dist/cjs/column_format/interfaces/IColumnFormatReturnType.d.ts +3 -0
  39. package/dist/cjs/column_format/interfaces/IColumnFormatReturnType.js +2 -0
  40. package/dist/cjs/column_format/interfaces/IColumnFormatSettings.d.ts +9 -0
  41. package/dist/cjs/column_format/interfaces/IColumnFormatSettings.js +2 -0
  42. package/dist/cjs/column_format/interfaces/IFormatStringType.d.ts +2 -0
  43. package/dist/cjs/column_format/interfaces/IFormatStringType.js +2 -0
  44. package/dist/cjs/column_format/interfaces/index.d.ts +7 -0
  45. package/dist/cjs/column_format/interfaces/index.js +23 -0
  46. package/dist/cjs/columns/interfaces/IColumnAggregate.d.ts +7 -0
  47. package/dist/cjs/columns/interfaces/IColumnAggregate.js +2 -0
  48. package/dist/cjs/columns/interfaces/IColumnDateGroupSettings.d.ts +7 -0
  49. package/dist/cjs/columns/interfaces/IColumnDateGroupSettings.js +2 -0
  50. package/dist/cjs/columns/interfaces/IColumnScale.d.ts +5 -0
  51. package/dist/cjs/columns/interfaces/IColumnScale.js +2 -0
  52. package/dist/cjs/dates/helpers/getDatePickerPickLevel.d.ts +7 -0
  53. package/dist/cjs/dates/helpers/getDatePickerPickLevel.js +14 -0
  54. package/dist/cjs/dates/helpers/index.d.ts +1 -0
  55. package/dist/cjs/dates/helpers/index.js +1 -0
  56. package/dist/cjs/filters/helpers/common/resolveFilterConditions.js +5 -5
  57. package/dist/cjs/filters/interfaces/common/IFSParamsToGetFilter.d.ts +1 -1
  58. package/dist/cjs/general/array/addPropertyToArrayOfObjects.d.ts +22 -0
  59. package/dist/cjs/general/array/addPropertyToArrayOfObjects.js +32 -0
  60. package/dist/cjs/general/array/index.d.ts +1 -0
  61. package/dist/cjs/general/array/index.js +1 -0
  62. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +3 -3
  63. package/dist/cjs/index.d.ts +1 -0
  64. package/dist/cjs/index.js +1 -0
  65. package/dist/cjs/interfaces/format/IFormatDefaultFormat.d.ts +5 -0
  66. package/dist/cjs/interfaces/format/IFormatDefaultFormat.js +2 -0
  67. package/dist/cjs/interfaces/format/IFormatOutputFormat.Interface.d.ts +3 -5
  68. package/dist/column_format/constants/CHART_GROUP.d.ts +4 -0
  69. package/dist/column_format/constants/CHART_GROUP.js +5 -0
  70. package/dist/column_format/constants/DATEGROUP_UNSUPPORT_FORMAT.d.ts +2 -0
  71. package/dist/column_format/constants/DATEGROUP_UNSUPPORT_FORMAT.js +13 -0
  72. package/dist/column_format/constants/DATEGROUP_WITHOUT_FORMAT.d.ts +12 -0
  73. package/dist/column_format/constants/DATEGROUP_WITHOUT_FORMAT.js +13 -0
  74. package/dist/column_format/constants/SHELF_TYPE.d.ts +7 -0
  75. package/dist/column_format/constants/SHELF_TYPE.js +8 -0
  76. package/dist/column_format/constants/STRING_FORMAT.d.ts +3 -0
  77. package/dist/column_format/constants/STRING_FORMAT.js +4 -0
  78. package/dist/column_format/constants/TABLE_TYPE.d.ts +5 -0
  79. package/dist/column_format/constants/TABLE_TYPE.js +6 -0
  80. package/dist/column_format/constants/index.d.ts +6 -0
  81. package/dist/column_format/constants/index.js +6 -0
  82. package/dist/column_format/helpers/columnTypeByChart.d.ts +16 -0
  83. package/dist/column_format/helpers/columnTypeByChart.js +24 -0
  84. package/dist/column_format/helpers/defineFormatV2.d.ts +11 -0
  85. package/dist/column_format/helpers/defineFormatV2.js +13 -0
  86. package/dist/column_format/helpers/defineTableChartFormat.d.ts +9 -0
  87. package/dist/column_format/helpers/defineTableChartFormat.js +67 -0
  88. package/dist/column_format/helpers/defineXYChartFormat.d.ts +11 -0
  89. package/dist/column_format/helpers/defineXYChartFormat.js +72 -0
  90. package/dist/column_format/helpers/index.d.ts +5 -0
  91. package/dist/column_format/helpers/index.js +5 -0
  92. package/dist/column_format/helpers/parseFormulaTypeByCharts.d.ts +7 -0
  93. package/dist/column_format/helpers/parseFormulaTypeByCharts.js +16 -0
  94. package/dist/column_format/index.d.ts +3 -0
  95. package/dist/column_format/index.js +3 -0
  96. package/dist/column_format/interfaces/IChartColumn.d.ts +23 -0
  97. package/dist/column_format/interfaces/IChartColumn.js +1 -0
  98. package/dist/column_format/interfaces/IChartGroupType.d.ts +2 -0
  99. package/dist/column_format/interfaces/IChartGroupType.js +1 -0
  100. package/dist/column_format/interfaces/IChartShelfType.d.ts +2 -0
  101. package/dist/column_format/interfaces/IChartShelfType.js +1 -0
  102. package/dist/column_format/interfaces/IChartTableType.d.ts +2 -0
  103. package/dist/column_format/interfaces/IChartTableType.js +1 -0
  104. package/dist/column_format/interfaces/IColumnFormatReturnType.d.ts +3 -0
  105. package/dist/column_format/interfaces/IColumnFormatReturnType.js +1 -0
  106. package/dist/column_format/interfaces/IColumnFormatSettings.d.ts +9 -0
  107. package/dist/column_format/interfaces/IColumnFormatSettings.js +1 -0
  108. package/dist/column_format/interfaces/IFormatStringType.d.ts +2 -0
  109. package/dist/column_format/interfaces/IFormatStringType.js +1 -0
  110. package/dist/column_format/interfaces/index.d.ts +7 -0
  111. package/dist/column_format/interfaces/index.js +7 -0
  112. package/dist/columns/interfaces/IColumnAggregate.d.ts +7 -0
  113. package/dist/columns/interfaces/IColumnAggregate.js +1 -0
  114. package/dist/columns/interfaces/IColumnDateGroupSettings.d.ts +7 -0
  115. package/dist/columns/interfaces/IColumnDateGroupSettings.js +1 -0
  116. package/dist/columns/interfaces/IColumnScale.d.ts +5 -0
  117. package/dist/columns/interfaces/IColumnScale.js +1 -0
  118. package/dist/dates/helpers/getDatePickerPickLevel.d.ts +7 -0
  119. package/dist/dates/helpers/getDatePickerPickLevel.js +10 -0
  120. package/dist/dates/helpers/index.d.ts +1 -0
  121. package/dist/dates/helpers/index.js +1 -0
  122. package/dist/filters/helpers/common/resolveFilterConditions.js +5 -5
  123. package/dist/filters/interfaces/common/IFSParamsToGetFilter.d.ts +1 -1
  124. package/dist/general/array/addPropertyToArrayOfObjects.d.ts +22 -0
  125. package/dist/general/array/addPropertyToArrayOfObjects.js +28 -0
  126. package/dist/general/array/index.d.ts +1 -0
  127. package/dist/general/array/index.js +1 -0
  128. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.js +3 -3
  129. package/dist/index.d.ts +1 -0
  130. package/dist/index.js +1 -0
  131. package/dist/interfaces/format/IFormatDefaultFormat.d.ts +5 -0
  132. package/dist/interfaces/format/IFormatDefaultFormat.js +1 -0
  133. package/dist/interfaces/format/IFormatOutputFormat.Interface.d.ts +3 -5
  134. package/jest.config.js +1 -0
  135. package/package.json +7 -6
  136. package/src/column_format/constants/CHART_GROUP.ts +4 -0
  137. package/src/column_format/constants/DATEGROUP_UNSUPPORT_FORMAT.ts +14 -0
  138. package/src/column_format/constants/DATEGROUP_WITHOUT_FORMAT.ts +12 -0
  139. package/src/column_format/constants/SHELF_TYPE.ts +7 -0
  140. package/src/column_format/constants/STRING_FORMAT.ts +3 -0
  141. package/src/column_format/constants/TABLE_TYPE.ts +5 -0
  142. package/src/column_format/constants/index.ts +6 -0
  143. package/src/column_format/helpers/columnTypeByChart.ts +27 -0
  144. package/src/column_format/helpers/defineFormatV2.ts +17 -0
  145. package/src/column_format/helpers/defineTableChartFormat.ts +70 -0
  146. package/src/column_format/helpers/defineXYChartFormat.ts +81 -0
  147. package/src/column_format/helpers/index.ts +5 -0
  148. package/src/column_format/helpers/parseFormulaTypeByCharts.ts +17 -0
  149. package/src/column_format/index.ts +3 -0
  150. package/src/column_format/interfaces/IChartColumn.ts +24 -0
  151. package/src/column_format/interfaces/IChartGroupType.ts +3 -0
  152. package/src/column_format/interfaces/IChartShelfType.ts +3 -0
  153. package/src/column_format/interfaces/IChartTableType.ts +3 -0
  154. package/src/column_format/interfaces/IColumnFormatReturnType.ts +4 -0
  155. package/src/column_format/interfaces/IColumnFormatSettings.ts +11 -0
  156. package/src/column_format/interfaces/IFormatStringType.ts +3 -0
  157. package/src/column_format/interfaces/index.ts +7 -0
  158. package/src/columns/interfaces/IColumnAggregate.ts +7 -0
  159. package/src/columns/interfaces/IColumnDateGroupSettings.ts +7 -0
  160. package/src/columns/interfaces/IColumnScale.ts +5 -0
  161. package/src/dates/helpers/getDatePickerPickLevel.ts +12 -0
  162. package/src/dates/helpers/index.ts +1 -0
  163. package/src/filters/helpers/common/resolveFilterConditions.ts +4 -4
  164. package/src/filters/interfaces/common/IFSParamsToGetFilter.ts +2 -2
  165. package/src/general/array/addPropertyToArrayOfObjects.ts +32 -0
  166. package/src/general/array/index.ts +1 -0
  167. package/src/globalization/labels/chart_builder/I18N_CHART_BUILDER_STYLE_OPTIONS.ts +3 -3
  168. package/src/index.ts +1 -0
  169. package/src/interfaces/format/IFormatDefaultFormat.ts +5 -0
  170. package/src/interfaces/format/IFormatOutputFormat.Interface.ts +3 -5
  171. package/test/general/array/addPropertyToArrayOfObjects.test.js +96 -0
  172. package/test/tokens/{isTokenLabel.test.js → isTokenLabel.test.ts} +38 -38
  173. package/tsconfig.json +3 -0
@@ -0,0 +1,3 @@
1
+ export * from './constants/index';
2
+ export * from './helpers/index';
3
+ export * from './interfaces/index';
@@ -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,2 @@
1
+ import { CHART_GROUPS } from "../constants/CHART_GROUP";
2
+ export declare type IChartGroupType = CHART_GROUPS;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { SHELF_TYPE } from "../constants/SHELF_TYPE";
2
+ export declare type IChartShelfType = SHELF_TYPE;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { TABLE_TYPE } from "../constants/TABLE_TYPE";
2
+ export declare type IChartTableType = TABLE_TYPE;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import { IFormatOutputFormat } from "../..";
2
+ import { IFormatStringType } from "./IFormatStringType";
3
+ export declare type IColumnFormatReturnType = IFormatStringType | IFormatOutputFormat;
@@ -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,2 @@
1
+ import { STRING_FORMAT } from "../constants/STRING_FORMAT";
2
+ export declare type IFormatStringType = STRING_FORMAT;
@@ -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,7 @@
1
+ export interface IColumnAggregate {
2
+ abbreviation: string;
3
+ id: string;
4
+ key: string;
5
+ label: string;
6
+ text: string;
7
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export interface IColumnDateGroupSettings {
2
+ default: boolean;
3
+ format: string;
4
+ label: string;
5
+ secondatyText: string;
6
+ text: string;
7
+ }
@@ -0,0 +1,5 @@
1
+ export interface IColumnScale {
2
+ key: string;
3
+ text: string;
4
+ value: string;
5
+ }
@@ -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
- ((_b = params.column) === null || _b === void 0 ? void 0 : _b.qrveyid) === filter.column.qrveyid &&
20
- ((_c = params.column) === null || _c === void 0 ? void 0 : _c.linkid) === filter.column.linkid &&
21
- ((_d = params.column) === null || _d === void 0 ? void 0 : _d.aggregate) === filter.column.aggregate));
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
+ }
@@ -1,3 +1,4 @@
1
+ export * from './addPropertyToArrayOfObjects';
1
2
  export * from './delete';
2
3
  export * from './flattenDeep';
3
4
  export * from './filterNestedTree';
@@ -1,3 +1,4 @@
1
+ export * from './addPropertyToArrayOfObjects';
1
2
  export * from './delete';
2
3
  export * from './flattenDeep';
3
4
  export * from './filterNestedTree';
@@ -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: 'Align Left',
188
- align_right: 'Align Right',
189
- align_center: '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
@@ -13,3 +13,4 @@ export * from './stencil/index';
13
13
  export * from './services/index';
14
14
  export * from './typescript/index';
15
15
  export * from './tokens/index';
16
+ export * from './column_format/index';
package/dist/index.js CHANGED
@@ -13,3 +13,4 @@ export * from './stencil/index';
13
13
  export * from './services/index';
14
14
  export * from './typescript/index';
15
15
  export * from './tokens/index';
16
+ export * from './column_format/index';
@@ -0,0 +1,5 @@
1
+ export interface IFormatDefaultFormat {
2
+ format: string;
3
+ type: string;
4
+ decimals?: number;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,9 +1,7 @@
1
1
  import { IFormatCurrency } from "./IFormatCurrency.Interface";
2
- export interface IFormatOutputFormat {
3
- format: string;
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?: any;
6
+ originalFormat?: IFormatOutputFormat;
9
7
  }
package/jest.config.js CHANGED
@@ -1,4 +1,5 @@
1
1
  module.exports = {
2
+ preset: 'ts-jest',
2
3
  testEnvironment: 'node',
3
4
  verbose: true,
4
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.3.0-3",
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,4 @@
1
+ export enum CHART_GROUPS {
2
+ TABLES = 'tables',
3
+ XY = 'xy'
4
+ }
@@ -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,7 @@
1
+ export enum SHELF_TYPE {
2
+ CATEGORY = 'category',
3
+ VALUE = 'value',
4
+ GROUPS = 'groups',
5
+ COLUMNS = 'columns',
6
+ SERIES = 'series'
7
+ }
@@ -0,0 +1,3 @@
1
+ export enum STRING_FORMAT {
2
+ NONE = 'none'
3
+ }
@@ -0,0 +1,5 @@
1
+ export enum TABLE_TYPE {
2
+ SIMPLE = 'simple',
3
+ GROUPED = 'grouped',
4
+ EXPANDABLE = 'expandable'
5
+ }
@@ -0,0 +1,6 @@
1
+ export * from './CHART_GROUP';
2
+ export * from './DATEGROUP_UNSUPPORT_FORMAT';
3
+ export * from './DATEGROUP_WITHOUT_FORMAT';
4
+ export * from './SHELF_TYPE';
5
+ export * from './STRING_FORMAT';
6
+ export * from './TABLE_TYPE';
@@ -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
+ };
@@ -0,0 +1,5 @@
1
+ export * from './columnTypeByChart';
2
+ export * from './defineFormatV2';
3
+ export * from './defineTableChartFormat';
4
+ export * from './defineXYChartFormat';
5
+ export * from './parseFormulaTypeByCharts';