@qrvey/utils 1.5.0 → 1.6.0-0-to-0

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 (83) hide show
  1. package/dist/cjs/column_format/helpers/columnTypeByChart.d.ts +1 -1
  2. package/dist/cjs/column_format/helpers/defineTableChartFormat.js +2 -2
  3. package/dist/cjs/column_format/helpers/defineXYChartFormat.js +9 -2
  4. package/dist/cjs/column_format/interfaces/IChartColumn.d.ts +2 -0
  5. package/dist/cjs/columns/constants/COLUMN.d.ts +1 -0
  6. package/dist/cjs/columns/constants/COLUMN.js +1 -0
  7. package/dist/cjs/columns/constants/COLUMNS.js +1 -0
  8. package/dist/cjs/columns/constants/COLUMN_INFO.js +7 -0
  9. package/dist/cjs/columns/constants/COLUMN_INFO_LIST.js +1 -0
  10. package/dist/cjs/columns/constants/COLUMN_LABEL.d.ts +1 -0
  11. package/dist/cjs/columns/constants/COLUMN_LABEL.js +1 -1
  12. package/dist/cjs/columns/constants/COLUMN_PROPERTY_INFO.js +1 -1
  13. package/dist/cjs/columns/constants/COLUMN_PROPERTY_LABEL.d.ts +4 -0
  14. package/dist/cjs/columns/constants/COLUMN_PROPERTY_LABEL.js +2 -1
  15. package/dist/cjs/columns/interfaces/IColumnTimeGroupSettings.d.ts +7 -0
  16. package/dist/cjs/columns/interfaces/IColumnTimeGroupSettings.js +2 -0
  17. package/dist/cjs/dates/adapters/hmsToDate.d.ts +7 -0
  18. package/dist/cjs/dates/adapters/hmsToDate.js +24 -0
  19. package/dist/cjs/dates/adapters/index.d.ts +1 -0
  20. package/dist/cjs/dates/adapters/index.js +1 -0
  21. package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_INFO.d.ts +5 -0
  22. package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_INFO.js +31 -0
  23. package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_INFO_LIST.d.ts +2 -0
  24. package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_INFO_LIST.js +10 -0
  25. package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_LABEL.d.ts +5 -0
  26. package/dist/cjs/dates/constants/TIME_GROUPING_PROPERTY_LABEL.js +9 -0
  27. package/dist/cjs/dates/constants/index.d.ts +3 -0
  28. package/dist/cjs/dates/constants/index.js +3 -0
  29. package/dist/cjs/filters/helpers/backend/getBackendGroupValue.js +3 -1
  30. package/dist/cjs/filters/helpers/backend/getBackendProperty.js +2 -1
  31. package/dist/cjs/filters/services/UChartApi.js +6 -2
  32. package/dist/cjs/filters/services/UChartPaginationApi.js +6 -2
  33. package/dist/cjs/format/definition.d.ts +1 -0
  34. package/dist/cjs/format/definition.js +2 -1
  35. package/dist/cjs/format/format.d.ts +12 -0
  36. package/dist/cjs/format/format.js +32 -4
  37. package/dist/cjs/globalization/interfaces/common/II18nColumnProperties.d.ts +3 -0
  38. package/dist/cjs/globalization/labels/common/I18N_COLUMN_LABEL.d.ts +1 -0
  39. package/dist/cjs/globalization/labels/common/I18N_COLUMN_LABEL.js +1 -0
  40. package/dist/cjs/globalization/labels/common/I18N_COLUMN_PROPERTY_LABEL.js +3 -0
  41. package/dist/cjs/qrvey/helpers/transformValue.js +5 -0
  42. package/dist/column_format/helpers/columnTypeByChart.d.ts +1 -1
  43. package/dist/column_format/helpers/defineTableChartFormat.js +2 -2
  44. package/dist/column_format/helpers/defineXYChartFormat.js +9 -2
  45. package/dist/column_format/interfaces/IChartColumn.d.ts +2 -0
  46. package/dist/columns/constants/COLUMN.d.ts +1 -0
  47. package/dist/columns/constants/COLUMN.js +1 -0
  48. package/dist/columns/constants/COLUMNS.js +1 -0
  49. package/dist/columns/constants/COLUMN_INFO.js +7 -0
  50. package/dist/columns/constants/COLUMN_INFO_LIST.js +1 -0
  51. package/dist/columns/constants/COLUMN_LABEL.d.ts +1 -0
  52. package/dist/columns/constants/COLUMN_LABEL.js +1 -1
  53. package/dist/columns/constants/COLUMN_PROPERTY_INFO.js +1 -1
  54. package/dist/columns/constants/COLUMN_PROPERTY_LABEL.d.ts +4 -0
  55. package/dist/columns/constants/COLUMN_PROPERTY_LABEL.js +2 -1
  56. package/dist/columns/interfaces/IColumnTimeGroupSettings.d.ts +7 -0
  57. package/dist/columns/interfaces/IColumnTimeGroupSettings.js +1 -0
  58. package/dist/dates/adapters/hmsToDate.d.ts +7 -0
  59. package/dist/dates/adapters/hmsToDate.js +20 -0
  60. package/dist/dates/adapters/index.d.ts +1 -0
  61. package/dist/dates/adapters/index.js +1 -0
  62. package/dist/dates/constants/TIME_GROUPING_PROPERTY_INFO.d.ts +5 -0
  63. package/dist/dates/constants/TIME_GROUPING_PROPERTY_INFO.js +28 -0
  64. package/dist/dates/constants/TIME_GROUPING_PROPERTY_INFO_LIST.d.ts +2 -0
  65. package/dist/dates/constants/TIME_GROUPING_PROPERTY_INFO_LIST.js +7 -0
  66. package/dist/dates/constants/TIME_GROUPING_PROPERTY_LABEL.d.ts +5 -0
  67. package/dist/dates/constants/TIME_GROUPING_PROPERTY_LABEL.js +6 -0
  68. package/dist/dates/constants/index.d.ts +3 -0
  69. package/dist/dates/constants/index.js +3 -0
  70. package/dist/filters/helpers/backend/getBackendGroupValue.js +3 -1
  71. package/dist/filters/helpers/backend/getBackendProperty.js +2 -1
  72. package/dist/filters/services/UChartApi.js +6 -2
  73. package/dist/filters/services/UChartPaginationApi.js +6 -2
  74. package/dist/format/definition.d.ts +1 -0
  75. package/dist/format/definition.js +1 -0
  76. package/dist/format/format.d.ts +12 -0
  77. package/dist/format/format.js +30 -4
  78. package/dist/globalization/interfaces/common/II18nColumnProperties.d.ts +3 -0
  79. package/dist/globalization/labels/common/I18N_COLUMN_LABEL.d.ts +1 -0
  80. package/dist/globalization/labels/common/I18N_COLUMN_LABEL.js +1 -0
  81. package/dist/globalization/labels/common/I18N_COLUMN_PROPERTY_LABEL.js +3 -0
  82. package/dist/qrvey/helpers/transformValue.js +5 -0
  83. package/package.json +1 -1
@@ -46,13 +46,13 @@ export const defineTableChartFormat = (column, settings) => {
46
46
  if (noFormatSupported) {
47
47
  return STRING_FORMAT.NONE;
48
48
  }
49
+ if (selectedFormat)
50
+ return selectedFormat;
49
51
  if (hasDefaultFormat) {
50
52
  const columnDefaultFormat = defaultFormat ||
51
53
  outputFormat || { type: "DATE", format: "MM/DD/YYYY" };
52
54
  return Object.assign(Object.assign({}, defaultFormat), { format: defaultText, originalFormat: Object.assign({}, columnDefaultFormat), type: "DATE" });
53
55
  }
54
- if (selectedFormat)
55
- return selectedFormat;
56
56
  return;
57
57
  }
58
58
  case COLUMN.NUMERIC:
@@ -3,6 +3,7 @@ import { COLUMN } from "../../columns/constants/COLUMN";
3
3
  import { STANDARD_NUMERIC_FORMATS, } from "../../format/definition";
4
4
  import { isEmpty } from "../../general/mix/isEmpty";
5
5
  import { CALCULATION_LABEL } from "../../qrvey/constants/CALCULATION_LABEL";
6
+ import { SHELF_TYPE } from "../constants";
6
7
  import { CHART_GROUPS } from "../constants/CHART_GROUP";
7
8
  import { DATEGROUP_UNSUPPORT_FORMAT } from "../constants/DATEGROUP_UNSUPPORT_FORMAT";
8
9
  import { STRING_FORMAT } from "../constants/STRING_FORMAT";
@@ -15,7 +16,7 @@ import { columnTypeByChart } from "./columnTypeByChart";
15
16
  * @param {IColumnFormatSettings} settings - IColumnFormatSettings
16
17
  */
17
18
  export const defineXYChartFormat = (column, settings) => {
18
- const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup, calculation, } = column;
19
+ const { aggregate, type, defaultFormat, outputFormat, selectedFormat, dateGroup, timeGroup, calculation, } = column;
19
20
  const { shelfType, withoutFormat } = settings;
20
21
  const columnDefaultFormat = defaultFormat || outputFormat;
21
22
  //Defaults
@@ -27,7 +28,7 @@ export const defineXYChartFormat = (column, settings) => {
27
28
  format: "Percentage" /* LOCALE_FORMATS.PERCENTAGE */,
28
29
  };
29
30
  const columnType = columnTypeByChart(column, shelfType, CHART_GROUPS.XY);
30
- const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label));
31
+ const noFormatSupported = DATEGROUP_UNSUPPORT_FORMAT.some((gp) => gp === (dateGroup === null || dateGroup === void 0 ? void 0 : dateGroup.label) || gp === (timeGroup === null || timeGroup === void 0 ? void 0 : timeGroup.label));
31
32
  const isUsedAsNumericColumn = type !== columnType;
32
33
  const columnCurrentFormat = isUsedAsNumericColumn
33
34
  ? selectedFormat
@@ -47,6 +48,7 @@ export const defineXYChartFormat = (column, settings) => {
47
48
  case COLUMN.IMAGE:
48
49
  case COLUMN.TEXT_LABEL:
49
50
  return STRING_FORMAT.NONE;
51
+ case COLUMN.TIME:
50
52
  case COLUMN.DATE: {
51
53
  if (noFormatSupported) {
52
54
  return STRING_FORMAT.NONE;
@@ -54,6 +56,11 @@ export const defineXYChartFormat = (column, settings) => {
54
56
  else if (hasDefaultFormat) {
55
57
  return Object.assign(Object.assign({}, columnDefaultFormat), { format: defaultText, originalFormat: Object.assign({}, outputFormat) });
56
58
  }
59
+ else if (columnType === COLUMN.TIME &&
60
+ shelfType === SHELF_TYPE.SERIES &&
61
+ (selectedFormat === null || selectedFormat === void 0 ? void 0 : selectedFormat.type) !== COLUMN.TIME) {
62
+ return outputFormat;
63
+ }
57
64
  return selectedFormat;
58
65
  }
59
66
  case COLUMN.NUMERIC:
@@ -2,12 +2,14 @@ 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 { IColumnTimeGroupSettings } from "../../columns/interfaces/IColumnTimeGroupSettings";
5
6
  import { IColumnCalculation } from "../../columns/interfaces/IColunmCalculation";
6
7
  import { IFormatDefaultFormat } from "../../interfaces/format/IFormatDefaultFormat";
7
8
  export interface IChartColumn {
8
9
  aggregate: IColumnAggregate;
9
10
  colIndex: number;
10
11
  dateGroup?: IColumnDateGroupSettings;
12
+ timeGroup?: IColumnTimeGroupSettings;
11
13
  defaultFormat: IFormatDefaultFormat;
12
14
  format?: string;
13
15
  formulaType?: IFormulaType;
@@ -4,6 +4,7 @@ export declare enum COLUMN {
4
4
  YES_NO = "YES_NO",
5
5
  RANKING = "RANKING",
6
6
  DATE = "DATE",
7
+ TIME = "TIME",
7
8
  SIGNATURE = "SIGNATURE",
8
9
  DROPDOWN = "DROPDOWN",
9
10
  IMAGE = "IMAGE",
@@ -6,6 +6,7 @@ export var COLUMN;
6
6
  COLUMN["YES_NO"] = "YES_NO";
7
7
  COLUMN["RANKING"] = "RANKING";
8
8
  COLUMN["DATE"] = "DATE";
9
+ COLUMN["TIME"] = "TIME";
9
10
  COLUMN["SIGNATURE"] = "SIGNATURE";
10
11
  COLUMN["DROPDOWN"] = "DROPDOWN";
11
12
  COLUMN["IMAGE"] = "IMAGE";
@@ -11,6 +11,7 @@ export const COLUMNS = [
11
11
  COLUMN.YES_NO,
12
12
  COLUMN.RANKING,
13
13
  COLUMN.DATE,
14
+ COLUMN.TIME,
14
15
  COLUMN.SLIDEBAR,
15
16
  COLUMN.SIGNATURE,
16
17
  COLUMN.DROPDOWN,
@@ -41,6 +41,13 @@ export const COLUMN_INFO = Object.assign(Object.assign(Object.assign({ [COLUMN.S
41
41
  value: COLUMN.DATE,
42
42
  displayed: true,
43
43
  i18nLabelPath: "common.column_types.date_label",
44
+ }, [COLUMN.TIME]: {
45
+ label: COLUMN_LABEL.TIME,
46
+ shortLabel: "Time",
47
+ abbrLabel: "TI",
48
+ value: COLUMN.TIME,
49
+ displayed: true,
50
+ i18nLabelPath: "common.column_types.time_label",
44
51
  }, [COLUMN.SIGNATURE]: {
45
52
  label: COLUMN_LABEL.SIGNATURE,
46
53
  shortLabel: "Signature",
@@ -9,6 +9,7 @@ export const COLUMN_INFO_LIST = [
9
9
  COLUMN_INFO[COLUMN.YES_NO],
10
10
  COLUMN_INFO[COLUMN.RANKING],
11
11
  COLUMN_INFO[COLUMN.DATE],
12
+ COLUMN_INFO[COLUMN.TIME],
12
13
  COLUMN_INFO[COLUMN.SIGNATURE],
13
14
  COLUMN_INFO[COLUMN.DROPDOWN],
14
15
  COLUMN_INFO[COLUMN.IMAGE],
@@ -21,6 +21,7 @@ export declare const COLUMN_LABEL: {
21
21
  YES_NO: string;
22
22
  RANKING: string;
23
23
  DATE: string;
24
+ TIME: string;
24
25
  SIGNATURE: string;
25
26
  DROPDOWN: string;
26
27
  IMAGE: string;
@@ -1,4 +1,4 @@
1
1
  import { COMPLEX_COLUMN_LABEL } from "./COMPLEX_COLUMN_LABEL";
2
2
  import { COMPOUND_COLUMN_LABEL } from "./COMPOUND_COLUMN_LABEL";
3
3
  import { NUMERICAL_COLUMN_LABEL } from "./NUMERICAL_COLUMN_LABEL";
4
- export const COLUMN_LABEL = Object.assign(Object.assign(Object.assign({ SINGLE_CHOICE: "Single Choice", MULTIPLE_CHOICE: "Multiple Choice", YES_NO: "Yes No", RANKING: "Ranking", DATE: "Date", SIGNATURE: "Signature", DROPDOWN: "Dropdown", IMAGE: "Image", EMAIL_FORM: "Email Form", PHONE: "Phone", PASSWORD: "Password", CHECKLIST: "Check List", NPS_SCORE: "NPS Score", NPS_FEEDBACK: "NPS Feedback", TEXT: "Text", TEXT_LABEL: "Text Label", TEXT_CATEGORY: "Text Category", LOOKUP: "Lookup", HEADLINE: "Headline", SECTION: "Section", FORMULA: "Formula", AGGREGATED_FORMULA: "Aggregated Formula", BUCKET: "Bucket", STRING: "String" }, NUMERICAL_COLUMN_LABEL), COMPOUND_COLUMN_LABEL), COMPLEX_COLUMN_LABEL);
4
+ export const COLUMN_LABEL = Object.assign(Object.assign(Object.assign({ SINGLE_CHOICE: "Single Choice", MULTIPLE_CHOICE: "Multiple Choice", YES_NO: "Yes No", RANKING: "Ranking", DATE: "Date", TIME: "Time", SIGNATURE: "Signature", DROPDOWN: "Dropdown", IMAGE: "Image", EMAIL_FORM: "Email Form", PHONE: "Phone", PASSWORD: "Password", CHECKLIST: "Check List", NPS_SCORE: "NPS Score", NPS_FEEDBACK: "NPS Feedback", TEXT: "Text", TEXT_LABEL: "Text Label", TEXT_CATEGORY: "Text Category", LOOKUP: "Lookup", HEADLINE: "Headline", SECTION: "Section", FORMULA: "Formula", AGGREGATED_FORMULA: "Aggregated Formula", BUCKET: "Bucket", STRING: "String" }, NUMERICAL_COLUMN_LABEL), COMPOUND_COLUMN_LABEL), COMPLEX_COLUMN_LABEL);
@@ -28,4 +28,4 @@ export const COLUMN_PROPERTY_INFO = Object.assign(Object.assign({ [COLUMN.LOOKUP
28
28
  ...DATE_GROUPING_TIME_PROPERTY_INFO_LIST,
29
29
  ...DATE_DISTINCT_PROPERTY_INFO_LIST,
30
30
  ...DATE_DISTINCT_TIME_PROPERTY_INFO_LIST,
31
- ] }, COMPOUND_COLUMN_PROPERTY_INFO), COMPLEX_COLUMN_PROPERTY_INFO);
31
+ ], [COLUMN.TIME]: [...DATE_GROUPING_TIME_PROPERTY_INFO_LIST] }, COMPOUND_COLUMN_PROPERTY_INFO), COMPLEX_COLUMN_PROPERTY_INFO);
@@ -4,6 +4,7 @@ import { DATE_DISTINCT_PROPERTY_LABEL } from "../../dates/constants/DATE_DISTINC
4
4
  import { DATE_DISTINCT_TIME_PROPERTY_LABEL } from "../../dates/constants/DATE_DISTINCT_TIME_PROPERTY_LABEL";
5
5
  import { COMPLEX_COLUMN_PROPERTY_LABEL } from "./COMPLEX_COLUMN_PROPERTY_LABEL";
6
6
  import { COMPOUND_COLUMN_PROPERTY_LABEL } from "./COMPOUND_COLUMN_PROPERTY_LABEL";
7
+ import { TIME_GROUPING_PROPERTY_LABEL } from "../../dates/constants/TIME_GROUPING_PROPERTY_LABEL";
7
8
  export declare const COLUMN_PROPERTY_LABEL: {
8
9
  NAME_FIRST: COMPOUND_COLUMN_PROPERTY_LABEL.NAME_FIRST;
9
10
  NAME_LAST: COMPOUND_COLUMN_PROPERTY_LABEL.NAME_LAST;
@@ -39,6 +40,9 @@ export declare const COLUMN_PROPERTY_LABEL: {
39
40
  YEAR_QUARTER: DATE_DISTINCT_PROPERTY_LABEL.YEAR_QUARTER;
40
41
  YEAR_MONTH: DATE_DISTINCT_PROPERTY_LABEL.YEAR_MONTH;
41
42
  MONTH_DAY: DATE_DISTINCT_PROPERTY_LABEL.MONTH_DAY;
43
+ TIME_HOUR: TIME_GROUPING_PROPERTY_LABEL.TIME_HOUR;
44
+ TIME_MINUTE: TIME_GROUPING_PROPERTY_LABEL.TIME_MINUTE;
45
+ TIME_SECOND: TIME_GROUPING_PROPERTY_LABEL.TIME_SECOND;
42
46
  HOUR: DATE_GROUPING_TIME_PROPERTY_LABEL.HOUR;
43
47
  MINUTE: DATE_GROUPING_TIME_PROPERTY_LABEL.MINUTE;
44
48
  SECOND: DATE_GROUPING_TIME_PROPERTY_LABEL.SECOND;
@@ -4,4 +4,5 @@ import { DATE_DISTINCT_PROPERTY_LABEL } from "../../dates/constants/DATE_DISTINC
4
4
  import { DATE_DISTINCT_TIME_PROPERTY_LABEL } from "../../dates/constants/DATE_DISTINCT_TIME_PROPERTY_LABEL";
5
5
  import { COMPLEX_COLUMN_PROPERTY_LABEL } from "./COMPLEX_COLUMN_PROPERTY_LABEL";
6
6
  import { COMPOUND_COLUMN_PROPERTY_LABEL } from "./COMPOUND_COLUMN_PROPERTY_LABEL";
7
- export const COLUMN_PROPERTY_LABEL = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ IMAGE_ANSWER_ID: "answer_id", LOOKUP_DISPLAY: "display", LOOKUP_VALUE: "value" }, DATE_GROUPING_PROPERTY_LABEL), DATE_GROUPING_TIME_PROPERTY_LABEL), DATE_DISTINCT_PROPERTY_LABEL), DATE_DISTINCT_TIME_PROPERTY_LABEL), COMPLEX_COLUMN_PROPERTY_LABEL), COMPOUND_COLUMN_PROPERTY_LABEL);
7
+ import { TIME_GROUPING_PROPERTY_LABEL } from "../../dates/constants/TIME_GROUPING_PROPERTY_LABEL";
8
+ export const COLUMN_PROPERTY_LABEL = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ IMAGE_ANSWER_ID: "answer_id", LOOKUP_DISPLAY: "display", LOOKUP_VALUE: "value" }, DATE_GROUPING_PROPERTY_LABEL), DATE_GROUPING_TIME_PROPERTY_LABEL), TIME_GROUPING_PROPERTY_LABEL), DATE_DISTINCT_PROPERTY_LABEL), DATE_DISTINCT_TIME_PROPERTY_LABEL), COMPLEX_COLUMN_PROPERTY_LABEL), COMPOUND_COLUMN_PROPERTY_LABEL);
@@ -0,0 +1,7 @@
1
+ export interface IColumnTimeGroupSettings {
2
+ default: boolean;
3
+ format: string;
4
+ label: string;
5
+ secondatyText: string;
6
+ text: string;
7
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Transforms String time from a [H:m:s] format to Date object.
3
+ * @param monthYearDate String of [H:m:s] time
4
+ * @param time Flag to parse the object date to milliseconds.
5
+ * @returns The date object or the date in milliseconds. If the argument is an unexpected time, the function will return the same value
6
+ */
7
+ export declare function hmsToDate(hmsDate: string, time?: boolean): string | Date | number;
@@ -0,0 +1,20 @@
1
+ import { isEmpty } from "../../general/mix/isEmpty";
2
+ import { isTokenLabel } from "../../tokens/isTokenLabel";
3
+ import { DATE_FORMAT } from "../constants/DATE_FORMAT";
4
+ import { validateDate } from "../helpers/validateDate";
5
+ /**
6
+ * Transforms String time from a [H:m:s] format to Date object.
7
+ * @param monthYearDate String of [H:m:s] time
8
+ * @param time Flag to parse the object date to milliseconds.
9
+ * @returns The date object or the date in milliseconds. If the argument is an unexpected time, the function will return the same value
10
+ */
11
+ export function hmsToDate(hmsDate, time = false) {
12
+ if (isEmpty(hmsDate) ||
13
+ isTokenLabel(hmsDate) ||
14
+ typeof hmsDate !== "string" ||
15
+ !validateDate(hmsDate, DATE_FORMAT.DAY_TIME))
16
+ return hmsDate;
17
+ const [hour, minute, second] = hmsDate.split(":");
18
+ const start = new Date(0, 0, 0, +hour, +minute, +second);
19
+ return time ? +start : start;
20
+ }
@@ -4,6 +4,7 @@ export * from "./dateToMonthYear";
4
4
  export * from "./dateToQuarterYear";
5
5
  export * from "./dateToWeekYear";
6
6
  export * from "./dateToYear";
7
+ export * from "./hmsToDate";
7
8
  export * from "./mdyDateToDate";
8
9
  export * from "./monthYearToDate";
9
10
  export * from "./quarterYearToDate";
@@ -4,6 +4,7 @@ export * from "./dateToMonthYear";
4
4
  export * from "./dateToQuarterYear";
5
5
  export * from "./dateToWeekYear";
6
6
  export * from "./dateToYear";
7
+ export * from "./hmsToDate";
7
8
  export * from "./mdyDateToDate";
8
9
  export * from "./monthYearToDate";
9
10
  export * from "./quarterYearToDate";
@@ -0,0 +1,5 @@
1
+ import { IColumnPropertyInfo } from "../../columns/interfaces/IColumnPropertyInfo";
2
+ import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
3
+ export declare const TIME_GROUPING_PROPERTY_INFO: {
4
+ [key in IColumnPropertyType]?: IColumnPropertyInfo;
5
+ };
@@ -0,0 +1,28 @@
1
+ import { DATE_GROUPING_TIME_PROPERTY } from "./DATE_GROUPING_TIME_PROPERTY";
2
+ import { TIME_GROUPING_PROPERTY_LABEL } from "./TIME_GROUPING_PROPERTY_LABEL";
3
+ export const TIME_GROUPING_PROPERTY_INFO = {
4
+ [DATE_GROUPING_TIME_PROPERTY.HOUR]: {
5
+ label: TIME_GROUPING_PROPERTY_LABEL.TIME_HOUR,
6
+ shortLabel: "Full Hour",
7
+ abbrLabel: "F-H",
8
+ value: DATE_GROUPING_TIME_PROPERTY.HOUR,
9
+ displayed: true,
10
+ i18nLabelPath: "common.properties.time_hour_label",
11
+ },
12
+ [DATE_GROUPING_TIME_PROPERTY.MINUTE]: {
13
+ label: TIME_GROUPING_PROPERTY_LABEL.TIME_MINUTE,
14
+ shortLabel: "Full Minute",
15
+ abbrLabel: "F-M",
16
+ value: DATE_GROUPING_TIME_PROPERTY.MINUTE,
17
+ displayed: true,
18
+ i18nLabelPath: "common.properties.time_minute_label",
19
+ },
20
+ [DATE_GROUPING_TIME_PROPERTY.SECOND]: {
21
+ label: TIME_GROUPING_PROPERTY_LABEL.TIME_SECOND,
22
+ shortLabel: "Full Second",
23
+ abbrLabel: "F-S",
24
+ value: DATE_GROUPING_TIME_PROPERTY.SECOND,
25
+ displayed: true,
26
+ i18nLabelPath: "common.properties.time_second_label",
27
+ },
28
+ };
@@ -0,0 +1,2 @@
1
+ import { IColumnPropertyInfo } from "../../columns/interfaces/IColumnPropertyInfo";
2
+ export declare const TIME_GROUPING_PROPERTY_INFO_LIST: IColumnPropertyInfo[];
@@ -0,0 +1,7 @@
1
+ import { TIME_GROUPING_PROPERTY_INFO } from "./TIME_GROUPING_PROPERTY_INFO";
2
+ import { DATE_GROUPING_TIME_PROPERTY } from "./DATE_GROUPING_TIME_PROPERTY";
3
+ export const TIME_GROUPING_PROPERTY_INFO_LIST = [
4
+ TIME_GROUPING_PROPERTY_INFO[DATE_GROUPING_TIME_PROPERTY.HOUR],
5
+ TIME_GROUPING_PROPERTY_INFO[DATE_GROUPING_TIME_PROPERTY.MINUTE],
6
+ TIME_GROUPING_PROPERTY_INFO[DATE_GROUPING_TIME_PROPERTY.SECOND],
7
+ ];
@@ -0,0 +1,5 @@
1
+ export declare enum TIME_GROUPING_PROPERTY_LABEL {
2
+ TIME_HOUR = "Full Hour",
3
+ TIME_MINUTE = "Full Minute",
4
+ TIME_SECOND = "Full Second"
5
+ }
@@ -0,0 +1,6 @@
1
+ export var TIME_GROUPING_PROPERTY_LABEL;
2
+ (function (TIME_GROUPING_PROPERTY_LABEL) {
3
+ TIME_GROUPING_PROPERTY_LABEL["TIME_HOUR"] = "Full Hour";
4
+ TIME_GROUPING_PROPERTY_LABEL["TIME_MINUTE"] = "Full Minute";
5
+ TIME_GROUPING_PROPERTY_LABEL["TIME_SECOND"] = "Full Second";
6
+ })(TIME_GROUPING_PROPERTY_LABEL || (TIME_GROUPING_PROPERTY_LABEL = {}));
@@ -38,3 +38,6 @@ export * from "./DATE_YEAR_MONTHS_MMMM";
38
38
  export * from "./DATE_YEAR_QUARTERS";
39
39
  export * from "./DATE_YEAR_QUARTERS_RANGE";
40
40
  export * from "./DATETIME_COLUMN_FORMAT";
41
+ export * from "./TIME_GROUPING_PROPERTY_INFO_LIST";
42
+ export * from "./TIME_GROUPING_PROPERTY_INFO";
43
+ export * from "./TIME_GROUPING_PROPERTY_LABEL";
@@ -38,3 +38,6 @@ export * from "./DATE_YEAR_MONTHS_MMMM";
38
38
  export * from "./DATE_YEAR_QUARTERS";
39
39
  export * from "./DATE_YEAR_QUARTERS_RANGE";
40
40
  export * from "./DATETIME_COLUMN_FORMAT";
41
+ export * from "./TIME_GROUPING_PROPERTY_INFO_LIST";
42
+ export * from "./TIME_GROUPING_PROPERTY_INFO";
43
+ export * from "./TIME_GROUPING_PROPERTY_LABEL";
@@ -1,6 +1,7 @@
1
1
  import { adaptDateGroupingProperty } from "../../adapters/adaptDateGroupingProperty";
2
2
  import { isDateColumn } from "../../../columns/helpers/isDateColumn";
3
3
  import { isEmpty } from "../../../general/mix/isEmpty";
4
+ import { COLUMN } from "../../../columns/constants/COLUMN";
4
5
  /**
5
6
  * Gets a group value for the backend logic structure
6
7
  * @param filter The filter
@@ -8,7 +9,8 @@ import { isEmpty } from "../../../general/mix/isEmpty";
8
9
  */
9
10
  export function getBackendGroupValue(filter) {
10
11
  if (isEmpty(filter.column.aggregate) &&
11
- isDateColumn(filter.column) &&
12
+ (isDateColumn(filter.column) ||
13
+ filter.column.type === COLUMN.TIME) &&
12
14
  filter.property != null) {
13
15
  return adaptDateGroupingProperty(filter.property);
14
16
  }
@@ -11,7 +11,8 @@ import { isNullValidator } from "../common/isNullValidator";
11
11
  export function getBackendProperty(filter) {
12
12
  if (isEmpty(filter.column.aggregate)) {
13
13
  if (isNullValidator(filter.validator) ||
14
- isDateColumn(filter.column)) {
14
+ isDateColumn(filter.column) ||
15
+ filter.column.type === COLUMN.TIME) {
15
16
  return undefined;
16
17
  }
17
18
  else if (filter.column.type === COLUMN.EXPRESSION &&
@@ -213,7 +213,9 @@ UChartApi._getSummariesBody = (uFilter) => {
213
213
  const summary = {
214
214
  aggregate: _get(column, "aggregate.label", AGGREGATE.COUNT),
215
215
  questionid: column.id,
216
- property: !isDateColumn(uFilter.column) ? uFilter.property : undefined,
216
+ property: !isDateColumn(uFilter.column) && uFilter.column.type !== COLUMN.TIME
217
+ ? uFilter.property
218
+ : undefined,
217
219
  type: column.type,
218
220
  };
219
221
  let summaries = [summary];
@@ -235,7 +237,8 @@ UChartApi._refineBodies = (bodies, uFilter) => {
235
237
  const _bodies = cloneDeep(bodies);
236
238
  if (uFilter.property != null) {
237
239
  _bodies.forEach((body) => {
238
- if (isDateColumn(uFilter.column)) {
240
+ if (isDateColumn(uFilter.column) ||
241
+ uFilter.column.type === COLUMN.TIME) {
239
242
  body.groupType = "DATE";
240
243
  body.groupValue = uFilter.property.toUpperCase();
241
244
  }
@@ -255,6 +258,7 @@ UChartApi._refineBodies = (bodies, uFilter) => {
255
258
  UChartApi._getValidationType = (column, validator) => {
256
259
  if (isDateColumn(column) ||
257
260
  column.type === COLUMN.BUCKET ||
261
+ column.type === COLUMN.TIME ||
258
262
  isNumericalColumn(column)) {
259
263
  return FILTER_VALIDATOR.EQUALS;
260
264
  }
@@ -227,7 +227,9 @@ UChartPaginationApi._getSummariesBody = (uFilter) => {
227
227
  const summary = {
228
228
  aggregate: _get(column, "aggregate.label", AGGREGATE.COUNT),
229
229
  questionid: column.id,
230
- property: !isDateColumn(uFilter.column) ? uFilter.property : undefined,
230
+ property: !isDateColumn(uFilter.column) && uFilter.column.type !== COLUMN.TIME
231
+ ? uFilter.property
232
+ : undefined,
231
233
  type: column.type,
232
234
  };
233
235
  let summaries = [summary];
@@ -249,7 +251,8 @@ UChartPaginationApi._refineBodies = (bodies, uFilter) => {
249
251
  const _bodies = cloneDeep(bodies);
250
252
  if (uFilter.property != null) {
251
253
  _bodies.forEach((body) => {
252
- if (isDateColumn(uFilter.column)) {
254
+ if (isDateColumn(uFilter.column) ||
255
+ uFilter.column.type === COLUMN.TIME) {
253
256
  body.groupType = "DATE";
254
257
  body.groupValue = uFilter.property.toUpperCase();
255
258
  }
@@ -269,6 +272,7 @@ UChartPaginationApi._refineBodies = (bodies, uFilter) => {
269
272
  UChartPaginationApi._getValidationType = (column, validator) => {
270
273
  if (isDateColumn(column) ||
271
274
  column.type === COLUMN.BUCKET ||
275
+ column.type === COLUMN.TIME ||
272
276
  isNumericalColumn(column)) {
273
277
  return FILTER_VALIDATOR.EQUALS;
274
278
  }
@@ -105,3 +105,4 @@ export declare const DEFAULT_OPTIONS: {
105
105
  locale: string;
106
106
  fractionDigits: number;
107
107
  };
108
+ export declare const DEFAULT_DATE = "1/1/1970";
@@ -133,3 +133,4 @@ export const DEFAULT_OPTIONS = {
133
133
  locale: "en-EN",
134
134
  fractionDigits: 0,
135
135
  };
136
+ export const DEFAULT_DATE = "1/1/1970";
@@ -6,6 +6,18 @@ export declare function formatAbbreviated(num: any, decimals: any): any;
6
6
  * @param bytes type number
7
7
  */
8
8
  export declare function formatFileSize(bytes: number): string;
9
+ /**
10
+ * It returns true if the given string is a valid time string, and false otherwise
11
+ * @param {string} [timeString] - The time string to validate.
12
+ * @returns A boolean value.
13
+ */
14
+ export declare function isValidTimeString(timeString?: string): boolean;
15
+ /**
16
+ * It takes a time string and a format string and returns a formatted time string
17
+ * @param {any} timeString - The time string to be formatted.
18
+ * @param {string} format - The format of the time string.
19
+ */
20
+ export declare function formatTime(timeString: any, format: string): any;
9
21
  export declare const addFormat: (value: any, outputFormat?: any, config?: IFormatConfig) => any;
10
22
  export declare const parseFormulaType: (type: string) => "DATE" | "NUMERIC" | "TEXT_LABEL";
11
23
  export declare const validateColumnType: (column: any) => any;
@@ -1,6 +1,6 @@
1
1
  import { format as d3Format } from "d3";
2
2
  import dayjs from "dayjs";
3
- import { DATEGROUP_FORMATTING_UNSUPPORT, appliesFormatting, hasfileSizeProperty, isTextColumn, } from "./definition";
3
+ import { DATEGROUP_FORMATTING_UNSUPPORT, appliesFormatting, hasfileSizeProperty, isTextColumn, DEFAULT_DATE, } from "./definition";
4
4
  import isoWeek from "dayjs/plugin/isoWeek";
5
5
  import advancedFormat from "dayjs/plugin/advancedFormat";
6
6
  import { isEmpty } from "../general/mix/isEmpty";
@@ -96,18 +96,44 @@ export function formatFileSize(bytes) {
96
96
  ? `${fixDecimals(megaBytes)} MB`
97
97
  : `${Math.round(megaBytes)} MB`;
98
98
  }
99
+ /**
100
+ * It returns true if the given string is a valid time string, and false otherwise
101
+ * @param {string} [timeString] - The time string to validate.
102
+ * @returns A boolean value.
103
+ */
104
+ export function isValidTimeString(timeString = "") {
105
+ const regex = new RegExp("^(?:[01]\\d|2[0-3]):(?:[0-5]\\d):(?:[0-5]\\d)$", "g");
106
+ return regex.test(timeString);
107
+ }
108
+ /**
109
+ * It takes a time string and a format string and returns a formatted time string
110
+ * @param {any} timeString - The time string to be formatted.
111
+ * @param {string} format - The format of the time string.
112
+ */
113
+ export function formatTime(timeString, format) {
114
+ if (!format || isEmpty(timeString) || !isNaN(timeString))
115
+ return timeString;
116
+ if (!isValidTimeString(timeString))
117
+ return timeString;
118
+ return dayjs(`${DEFAULT_DATE} ${timeString}`).format(format.replace("HH24", "HH").replace("MI", "mm").replace("SS", "ss"));
119
+ }
99
120
  export const addFormat = (value, outputFormat = "None", config) => {
100
- var _a, _b;
121
+ var _a, _b, _c, _d;
101
122
  if (isEmpty(value) || (typeof value === "object" && isEmpty(value[0])))
102
123
  return value;
103
124
  switch (outputFormat.type) {
125
+ case "TIME":
126
+ return formatTime(value, (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Default" &&
127
+ ((_a = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _a === void 0 ? void 0 : _a.format)
128
+ ? (_b = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _b === void 0 ? void 0 : _b.format
129
+ : outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
104
130
  case "DATE":
105
131
  case "DATETIME":
106
132
  return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === "Default"
107
133
  ? formatWithLocale(value, outputFormat, config)
108
134
  : formatDate(value, (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Default" &&
109
- ((_a = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _a === void 0 ? void 0 : _a.format)
110
- ? (_b = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _b === void 0 ? void 0 : _b.format
135
+ ((_c = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _c === void 0 ? void 0 : _c.format)
136
+ ? (_d = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _d === void 0 ? void 0 : _d.format
111
137
  : outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
112
138
  case "NUMERIC": {
113
139
  const parse = parseFloat(value);
@@ -10,6 +10,9 @@ export interface II18nColumnProperties {
10
10
  date_hour_label: string;
11
11
  date_minute_label: string;
12
12
  date_second_label: string;
13
+ time_hour_label: string;
14
+ time_minute_label: string;
15
+ time_second_label: string;
13
16
  date_quarter_only_label: string;
14
17
  date_month_only_label: string;
15
18
  date_day_only_label: string;
@@ -5,6 +5,7 @@ export declare const I18N_COLUMN_LABEL: {
5
5
  yes_no_label: string;
6
6
  ranking_label: string;
7
7
  date_label: string;
8
+ time_label: string;
8
9
  slidebar_label: import("../../..").NUMERICAL_COLUMN_LABEL;
9
10
  signature_label: string;
10
11
  dropdown_label: string;
@@ -6,6 +6,7 @@ export const I18N_COLUMN_LABEL = {
6
6
  yes_no_label: COLUMN_LABEL.YES_NO,
7
7
  ranking_label: COLUMN_LABEL.RANKING,
8
8
  date_label: COLUMN_LABEL.DATE,
9
+ time_label: COLUMN_LABEL.TIME,
9
10
  slidebar_label: COLUMN_LABEL.SLIDEBAR,
10
11
  signature_label: COLUMN_LABEL.SIGNATURE,
11
12
  dropdown_label: COLUMN_LABEL.DROPDOWN,
@@ -11,6 +11,9 @@ export const I18N_COLUMN_PROPERTY_LABEL = {
11
11
  date_hour_label: COLUMN_PROPERTY_LABEL.HOUR,
12
12
  date_minute_label: COLUMN_PROPERTY_LABEL.MINUTE,
13
13
  date_second_label: COLUMN_PROPERTY_LABEL.SECOND,
14
+ time_hour_label: COLUMN_PROPERTY_LABEL.TIME_HOUR,
15
+ time_minute_label: COLUMN_PROPERTY_LABEL.TIME_MINUTE,
16
+ time_second_label: COLUMN_PROPERTY_LABEL.TIME_SECOND,
14
17
  date_quarter_only_label: COLUMN_PROPERTY_LABEL.YEAR_QUARTER,
15
18
  date_month_only_label: COLUMN_PROPERTY_LABEL.YEAR_MONTH,
16
19
  date_day_only_label: COLUMN_PROPERTY_LABEL.MONTH_DAY,
@@ -1,3 +1,4 @@
1
+ import { COLUMN } from "../../columns/constants/COLUMN";
1
2
  import { isDateColumn } from "../../columns/helpers/isDateColumn";
2
3
  import { isNumericalColumn } from "../../columns/helpers/isNumericalColumn";
3
4
  import { DATE_GROUPING_PROPERTY } from "../../dates/constants/DATE_GROUPING_PROPERTY";
@@ -39,6 +40,10 @@ function getOutputFormat(settings) {
39
40
  type = "DATE";
40
41
  format = "Default";
41
42
  }
43
+ else if (settings.column.type === COLUMN.TIME) {
44
+ type = "TIME";
45
+ format = "Default";
46
+ }
42
47
  else if (isNumericalColumn(settings.column)) {
43
48
  type = "NUMERIC";
44
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.5.0",
3
+ "version": "1.6.0-0-to-0",
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",