@qrvey/utils 1.10.0-0 → 1.10.0-2
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/dist/charts/adapters/endpointData.js +0 -3
- package/dist/cjs/charts/adapters/endpointData.js +0 -3
- package/dist/cjs/dates/adapters/ISOToNumericOffset.d.ts +6 -0
- package/dist/cjs/dates/adapters/ISOToNumericOffset.js +21 -0
- package/dist/cjs/dates/adapters/index.d.ts +2 -0
- package/dist/cjs/dates/adapters/index.js +2 -0
- package/dist/cjs/dates/adapters/numericOffsetToISO.d.ts +6 -0
- package/dist/cjs/dates/adapters/numericOffsetToISO.js +29 -0
- package/dist/cjs/dates/constants/ISO_8601_REGEX.d.ts +1 -0
- package/dist/cjs/dates/constants/ISO_8601_REGEX.js +4 -0
- package/dist/cjs/dates/constants/TIMEZONE_TYPE.d.ts +5 -0
- package/dist/cjs/dates/constants/TIMEZONE_TYPE.js +9 -0
- package/dist/cjs/dates/constants/index.d.ts +1 -0
- package/dist/cjs/dates/constants/index.js +1 -0
- package/dist/cjs/dates/helpers/getDateByTimezone.d.ts +8 -0
- package/dist/cjs/dates/helpers/getDateByTimezone.js +41 -0
- package/dist/cjs/dates/helpers/getDateByTimezoneOffset.d.ts +7 -0
- package/dist/cjs/dates/helpers/getDateByTimezoneOffset.js +22 -0
- package/dist/cjs/dates/helpers/getTimezoneObject.d.ts +10 -0
- package/dist/cjs/dates/helpers/getTimezoneObject.js +21 -0
- package/dist/cjs/dates/helpers/getTimezoneOffsetByType.d.ts +13 -0
- package/dist/cjs/dates/helpers/getTimezoneOffsetByType.js +27 -0
- package/dist/cjs/dates/helpers/index.d.ts +4 -1
- package/dist/cjs/dates/helpers/index.js +4 -1
- package/dist/cjs/dates/helpers/isValidISOOffset.d.ts +7 -0
- package/dist/cjs/dates/helpers/isValidISOOffset.js +17 -0
- package/dist/cjs/dates/interfaces/IBTimezone.d.ts +7 -0
- package/dist/cjs/dates/interfaces/IBTimezone.js +2 -0
- package/dist/cjs/dates/interfaces/IBTimezoneType.d.ts +2 -0
- package/dist/cjs/dates/interfaces/IBTimezoneType.js +2 -0
- package/dist/cjs/dates/interfaces/IDTimezone.d.ts +6 -0
- package/dist/cjs/dates/interfaces/IDTimezone.js +2 -0
- package/dist/cjs/dates/interfaces/IDTimezoneOffset.d.ts +1 -0
- package/dist/cjs/dates/interfaces/IDTimezoneOffset.js +2 -0
- package/dist/cjs/dates/interfaces/IDTimezoneType.d.ts +2 -0
- package/dist/cjs/dates/interfaces/IDTimezoneType.js +2 -0
- package/dist/cjs/dates/interfaces/IGetDateByTimezoneSettings.d.ts +6 -0
- package/dist/cjs/dates/interfaces/IGetDateByTimezoneSettings.js +2 -0
- package/dist/cjs/dates/interfaces/index.d.ts +6 -0
- package/dist/cjs/dates/interfaces/index.js +6 -0
- package/dist/cjs/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
- package/dist/cjs/filters/helpers/common/getFiltersByTimezone.d.ts +10 -0
- package/dist/cjs/filters/helpers/common/getFiltersByTimezone.js +26 -0
- package/dist/cjs/filters/helpers/common/index.d.ts +1 -0
- package/dist/cjs/filters/helpers/common/index.js +1 -0
- package/dist/cjs/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +6 -0
- package/dist/cjs/format/format.d.ts +1 -1
- package/dist/cjs/format/format.js +10 -4
- package/dist/cjs/general/index.d.ts +1 -0
- package/dist/cjs/general/index.js +1 -0
- package/dist/cjs/general/numeric/getSign.d.ts +6 -0
- package/dist/cjs/general/numeric/getSign.js +12 -0
- package/dist/cjs/general/numeric/index.d.ts +1 -0
- package/dist/cjs/general/numeric/index.js +17 -0
- package/dist/cjs/general/object/applyTimezoneDeep.d.ts +8 -0
- package/dist/cjs/general/object/applyTimezoneDeep.js +48 -0
- package/dist/cjs/general/object/index.d.ts +1 -0
- package/dist/cjs/general/object/index.js +1 -0
- package/dist/cjs/interfaces/format/IFormatConfig.Interface.d.ts +1 -0
- package/dist/cjs/interfaces/general/IWidgetConfig.d.ts +2 -1
- package/dist/cjs/qrvey/helpers/transformValue.js +34 -6
- package/dist/cjs/qrvey/interfaces/IBDataset.d.ts +2 -0
- package/dist/cjs/qrvey/interfaces/IBModel.d.ts +5 -0
- package/dist/cjs/qrvey/interfaces/IDataset.d.ts +3 -1
- package/dist/cjs/qrvey/interfaces/IModel.d.ts +3 -1
- package/dist/cjs/qrvey/interfaces/ITransformValueSettings.d.ts +6 -0
- package/dist/cjs/services/adapters/BDatasetsToUIDatasets.adapter.js +2 -0
- package/dist/cjs/services/adapters/BModelToUIModel.adapter.js +2 -0
- package/dist/cjs/services/adapters/BTimezoneToUITimezone.d.ts +8 -0
- package/dist/cjs/services/adapters/BTimezoneToUITimezone.js +18 -0
- package/dist/cjs/services/helpers/Request.d.ts +1 -1
- package/dist/cjs/services/helpers/Request.js +11 -5
- package/dist/dates/adapters/ISOToNumericOffset.d.ts +6 -0
- package/dist/dates/adapters/ISOToNumericOffset.js +17 -0
- package/dist/dates/adapters/index.d.ts +2 -0
- package/dist/dates/adapters/index.js +2 -0
- package/dist/dates/adapters/numericOffsetToISO.d.ts +6 -0
- package/dist/dates/adapters/numericOffsetToISO.js +25 -0
- package/dist/dates/constants/ISO_8601_REGEX.d.ts +1 -0
- package/dist/dates/constants/ISO_8601_REGEX.js +1 -0
- package/dist/dates/constants/TIMEZONE_TYPE.d.ts +5 -0
- package/dist/dates/constants/TIMEZONE_TYPE.js +6 -0
- package/dist/dates/constants/index.d.ts +1 -0
- package/dist/dates/constants/index.js +1 -0
- package/dist/dates/helpers/getDateByTimezone.d.ts +8 -0
- package/dist/dates/helpers/getDateByTimezone.js +37 -0
- package/dist/dates/helpers/getDateByTimezoneOffset.d.ts +7 -0
- package/dist/dates/helpers/getDateByTimezoneOffset.js +18 -0
- package/dist/dates/helpers/getTimezoneObject.d.ts +10 -0
- package/dist/dates/helpers/getTimezoneObject.js +17 -0
- package/dist/dates/helpers/getTimezoneOffsetByType.d.ts +13 -0
- package/dist/dates/helpers/getTimezoneOffsetByType.js +23 -0
- package/dist/dates/helpers/index.d.ts +4 -1
- package/dist/dates/helpers/index.js +4 -1
- package/dist/dates/helpers/isValidISOOffset.d.ts +7 -0
- package/dist/dates/helpers/isValidISOOffset.js +13 -0
- package/dist/dates/interfaces/IBTimezone.d.ts +7 -0
- package/dist/dates/interfaces/IBTimezone.js +1 -0
- package/dist/dates/interfaces/IBTimezoneType.d.ts +2 -0
- package/dist/dates/interfaces/IBTimezoneType.js +1 -0
- package/dist/dates/interfaces/IDTimezone.d.ts +6 -0
- package/dist/dates/interfaces/IDTimezone.js +1 -0
- package/dist/dates/interfaces/IDTimezoneOffset.d.ts +1 -0
- package/dist/dates/interfaces/IDTimezoneOffset.js +1 -0
- package/dist/dates/interfaces/IDTimezoneType.d.ts +2 -0
- package/dist/dates/interfaces/IDTimezoneType.js +1 -0
- package/dist/dates/interfaces/IGetDateByTimezoneSettings.d.ts +6 -0
- package/dist/dates/interfaces/IGetDateByTimezoneSettings.js +1 -0
- package/dist/dates/interfaces/index.d.ts +6 -0
- package/dist/dates/interfaces/index.js +6 -0
- package/dist/filters/helpers/builder/getFilterBuilderGeneralConfig.js +1 -1
- package/dist/filters/helpers/common/getFiltersByTimezone.d.ts +10 -0
- package/dist/filters/helpers/common/getFiltersByTimezone.js +22 -0
- package/dist/filters/helpers/common/index.d.ts +1 -0
- package/dist/filters/helpers/common/index.js +1 -0
- package/dist/filters/interfaces/ui/IFUTransformFilterValuesSettings.d.ts +6 -0
- package/dist/format/format.d.ts +1 -1
- package/dist/format/format.js +10 -4
- package/dist/general/index.d.ts +1 -0
- package/dist/general/index.js +1 -0
- package/dist/general/numeric/getSign.d.ts +6 -0
- package/dist/general/numeric/getSign.js +8 -0
- package/dist/general/numeric/index.d.ts +1 -0
- package/dist/general/numeric/index.js +1 -0
- package/dist/general/object/applyTimezoneDeep.d.ts +8 -0
- package/dist/general/object/applyTimezoneDeep.js +44 -0
- package/dist/general/object/index.d.ts +1 -0
- package/dist/general/object/index.js +1 -0
- package/dist/interfaces/format/IFormatConfig.Interface.d.ts +1 -0
- package/dist/interfaces/general/IWidgetConfig.d.ts +2 -1
- package/dist/qrvey/helpers/transformValue.js +34 -6
- package/dist/qrvey/interfaces/IBDataset.d.ts +2 -0
- package/dist/qrvey/interfaces/IBModel.d.ts +5 -0
- package/dist/qrvey/interfaces/IDataset.d.ts +3 -1
- package/dist/qrvey/interfaces/IModel.d.ts +3 -1
- package/dist/qrvey/interfaces/ITransformValueSettings.d.ts +6 -0
- package/dist/services/adapters/BDatasetsToUIDatasets.adapter.js +2 -0
- package/dist/services/adapters/BModelToUIModel.adapter.js +2 -0
- package/dist/services/adapters/BTimezoneToUITimezone.d.ts +8 -0
- package/dist/services/adapters/BTimezoneToUITimezone.js +14 -0
- package/dist/services/helpers/Request.d.ts +1 -1
- package/dist/services/helpers/Request.js +11 -5
- package/package.json +5 -5
- package/dist/cjs/dates/helpers/adjustTimezone.d.ts +0 -6
- package/dist/cjs/dates/helpers/adjustTimezone.js +0 -19
- package/dist/dates/helpers/adjustTimezone.d.ts +0 -6
- package/dist/dates/helpers/adjustTimezone.js +0 -15
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ISOToNumericOffset } from "../adapters/ISOToNumericOffset";
|
|
2
|
+
import { DATE_FORMAT } from "../constants/DATE_FORMAT";
|
|
3
|
+
import { isValidPotentialDate } from "./isValidPotentialDate";
|
|
4
|
+
import { validateDate } from "./validateDate";
|
|
5
|
+
/**
|
|
6
|
+
* Gets a Date with the given offset of the Timezone.
|
|
7
|
+
* No given an offset the default is going to be set by the browser
|
|
8
|
+
* @param date String, object or millisencond number of the date
|
|
9
|
+
* @returns updated Date object
|
|
10
|
+
*/
|
|
11
|
+
export function getDateByTimezoneOffset(date, offset) {
|
|
12
|
+
if (!isValidPotentialDate(date) ||
|
|
13
|
+
(typeof date === "string" && !validateDate(date, DATE_FORMAT.DAY)))
|
|
14
|
+
return date;
|
|
15
|
+
const dt = new Date(date.valueOf());
|
|
16
|
+
const newOffset = ISOToNumericOffset(offset);
|
|
17
|
+
return new Date(+dt + newOffset * 1000 * 60);
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IDataset } from "../../qrvey/interfaces/IDataset";
|
|
2
|
+
import { IModel } from "../../qrvey/interfaces/IModel";
|
|
3
|
+
import { IDTimezone } from "../interfaces/IDTimezone";
|
|
4
|
+
/**
|
|
5
|
+
* Gets the timezone object by the given argument or the model object
|
|
6
|
+
* @param {IDTimezone} timezone the timezone object
|
|
7
|
+
* @param {IModel | IDataset} model the info of the dataset (model)
|
|
8
|
+
* @returns a new timezone object
|
|
9
|
+
*/
|
|
10
|
+
export declare function getTimezoneObject(timezone: IDTimezone, model: IModel | IDataset): IDTimezone;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TIMEZONE_TYPE } from "../constants/TIMEZONE_TYPE";
|
|
2
|
+
import { getTimezoneOffsetByType } from "./getTimezoneOffsetByType";
|
|
3
|
+
/**
|
|
4
|
+
* Gets the timezone object by the given argument or the model object
|
|
5
|
+
* @param {IDTimezone} timezone the timezone object
|
|
6
|
+
* @param {IModel | IDataset} model the info of the dataset (model)
|
|
7
|
+
* @returns a new timezone object
|
|
8
|
+
*/
|
|
9
|
+
export function getTimezoneObject(timezone, model) {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const offset = (timezone === null || timezone === void 0 ? void 0 : timezone.offset) || ((_a = model === null || model === void 0 ? void 0 : model.timezone) === null || _a === void 0 ? void 0 : _a.offset) || "+00:00";
|
|
12
|
+
const type = (timezone === null || timezone === void 0 ? void 0 : timezone.type) || ((_b = model === null || model === void 0 ? void 0 : model.timezone) === null || _b === void 0 ? void 0 : _b.type) || TIMEZONE_TYPE.DEFAULT;
|
|
13
|
+
return {
|
|
14
|
+
offset: getTimezoneOffsetByType({ offset, type }),
|
|
15
|
+
type,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IBTimezone } from "../interfaces/IBTimezone";
|
|
2
|
+
import { IDTimezone } from "../interfaces/IDTimezone";
|
|
3
|
+
import { IDTimezoneOffset } from "../interfaces/IDTimezoneOffset";
|
|
4
|
+
/**
|
|
5
|
+
* Gets the timezone offset by the timezone type.
|
|
6
|
+
* For browser types, it is calculated by a Date instance
|
|
7
|
+
* Default types is UTC-0
|
|
8
|
+
* Undefined or Fixed types is gotten by the offset property
|
|
9
|
+
* @param {IDTimezoneType} type the timezone type
|
|
10
|
+
* @param {IDTimezone | IBTimezone} timezone the timezone object
|
|
11
|
+
* @returns {IDTimezoneOffset} the offset of the timezone
|
|
12
|
+
*/
|
|
13
|
+
export declare function getTimezoneOffsetByType(timezone: IDTimezone | IBTimezone): IDTimezoneOffset;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isEmpty } from "../../general/mix/isEmpty";
|
|
2
|
+
import { numericOffsetToISO } from "../adapters/numericOffsetToISO";
|
|
3
|
+
import { TIMEZONE_TYPE } from "../constants/TIMEZONE_TYPE";
|
|
4
|
+
/**
|
|
5
|
+
* Gets the timezone offset by the timezone type.
|
|
6
|
+
* For browser types, it is calculated by a Date instance
|
|
7
|
+
* Default types is UTC-0
|
|
8
|
+
* Undefined or Fixed types is gotten by the offset property
|
|
9
|
+
* @param {IDTimezoneType} type the timezone type
|
|
10
|
+
* @param {IDTimezone | IBTimezone} timezone the timezone object
|
|
11
|
+
* @returns {IDTimezoneOffset} the offset of the timezone
|
|
12
|
+
*/
|
|
13
|
+
export function getTimezoneOffsetByType(timezone) {
|
|
14
|
+
if (isEmpty(timezone))
|
|
15
|
+
return "+00:00";
|
|
16
|
+
if (timezone.type === TIMEZONE_TYPE.BROWSER) {
|
|
17
|
+
return numericOffsetToISO("browser");
|
|
18
|
+
}
|
|
19
|
+
else if (timezone.type === TIMEZONE_TYPE.DEFAULT) {
|
|
20
|
+
return "+00:00";
|
|
21
|
+
}
|
|
22
|
+
return timezone.offset || timezone.numericOffset || "+00:00";
|
|
23
|
+
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
export * from "./adjustTimezone";
|
|
2
1
|
export * from "./areIncludedDateTokens";
|
|
3
2
|
export * from "./getDateByDateFormat";
|
|
3
|
+
export * from "./getDateByTimezone";
|
|
4
|
+
export * from "./getDateByTimezoneOffset";
|
|
4
5
|
export * from "./getDateFormatByProperty";
|
|
5
6
|
export * from "./getDateFormatRegularExpressionInArray";
|
|
6
7
|
export * from "./getDatePickerPickLevel";
|
|
7
8
|
export * from "./getDateRange";
|
|
8
9
|
export * from "./getFormattedDateByFormat";
|
|
9
10
|
export * from "./getSeparatorByDateFormat";
|
|
11
|
+
export * from "./getTimezoneObject";
|
|
12
|
+
export * from "./getTimezoneOffsetByType";
|
|
10
13
|
export * from "./getWeek";
|
|
11
14
|
export * from "./isValidDateObject";
|
|
12
15
|
export * from "./isValidPotentialDate";
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
export * from "./adjustTimezone";
|
|
2
1
|
export * from "./areIncludedDateTokens";
|
|
3
2
|
export * from "./getDateByDateFormat";
|
|
3
|
+
export * from "./getDateByTimezone";
|
|
4
|
+
export * from "./getDateByTimezoneOffset";
|
|
4
5
|
export * from "./getDateFormatByProperty";
|
|
5
6
|
export * from "./getDateFormatRegularExpressionInArray";
|
|
6
7
|
export * from "./getDatePickerPickLevel";
|
|
7
8
|
export * from "./getDateRange";
|
|
8
9
|
export * from "./getFormattedDateByFormat";
|
|
9
10
|
export * from "./getSeparatorByDateFormat";
|
|
11
|
+
export * from "./getTimezoneObject";
|
|
12
|
+
export * from "./getTimezoneOffsetByType";
|
|
10
13
|
export * from "./getWeek";
|
|
11
14
|
export * from "./isValidDateObject";
|
|
12
15
|
export * from "./isValidPotentialDate";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate if offset uses a valid ISO 8601 offset specification
|
|
3
|
+
* - If the given offset is a numeric, returns an invalid flag.
|
|
4
|
+
* @param {string} offset the timezone offset
|
|
5
|
+
* @returns {boolean} true if the given offset is valid
|
|
6
|
+
*/
|
|
7
|
+
export declare function isValidISOOffset(offset: number | string): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ISO_8601_REGEX } from "../constants/ISO_8601_REGEX";
|
|
2
|
+
/**
|
|
3
|
+
* Validate if offset uses a valid ISO 8601 offset specification
|
|
4
|
+
* - If the given offset is a numeric, returns an invalid flag.
|
|
5
|
+
* @param {string} offset the timezone offset
|
|
6
|
+
* @returns {boolean} true if the given offset is valid
|
|
7
|
+
*/
|
|
8
|
+
export function isValidISOOffset(offset) {
|
|
9
|
+
if (typeof offset !== "string")
|
|
10
|
+
return false;
|
|
11
|
+
const newOffset = (offset || "").trim();
|
|
12
|
+
return ISO_8601_REGEX.test(newOffset);
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type IDTimezoneOffset = number | string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export * from "./IBTimezone";
|
|
2
|
+
export * from "./IBTimezoneType";
|
|
1
3
|
export * from "./IDateFormat";
|
|
2
4
|
export * from "./IDateGroupingProperty";
|
|
3
5
|
export * from "./IDFDateToHmsSettings";
|
|
6
|
+
export * from "./IDTimezone";
|
|
7
|
+
export * from "./IDTimezoneOffset";
|
|
8
|
+
export * from "./IDTimezoneType";
|
|
9
|
+
export * from "./IGetDateByTimezoneSettings";
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export * from "./IBTimezone";
|
|
2
|
+
export * from "./IBTimezoneType";
|
|
1
3
|
export * from "./IDateFormat";
|
|
2
4
|
export * from "./IDateGroupingProperty";
|
|
3
5
|
export * from "./IDFDateToHmsSettings";
|
|
6
|
+
export * from "./IDTimezone";
|
|
7
|
+
export * from "./IDTimezoneOffset";
|
|
8
|
+
export * from "./IDTimezoneType";
|
|
9
|
+
export * from "./IGetDateByTimezoneSettings";
|
|
@@ -11,7 +11,7 @@ export function getFilterBuilderGeneralConfig(config = {}) {
|
|
|
11
11
|
domain: config.domain,
|
|
12
12
|
i18n: config.i18n,
|
|
13
13
|
qv_token: config.qv_token,
|
|
14
|
-
|
|
14
|
+
timezone: config.timezone,
|
|
15
15
|
userid: getAttribute(config, "user_id") || config.userid,
|
|
16
16
|
};
|
|
17
17
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IDTimezone } from "../../../dates/interfaces/IDTimezone";
|
|
2
|
+
import { IFSData } from "../../interfaces/common/IFSData";
|
|
3
|
+
import { IFUData } from "../../interfaces/ui/IFUData";
|
|
4
|
+
/**
|
|
5
|
+
* Gets and transforms the Filter Data by the Timezone object
|
|
6
|
+
* @param {IFSData | IFUData} filterData the filter data
|
|
7
|
+
* @param {IDTimezone} timezone the timezone object
|
|
8
|
+
* @returns {IFSData | IFUData} the new filter data with the transformed datetime values
|
|
9
|
+
*/
|
|
10
|
+
export declare function getFiltersByTimezone(filterData: IFSData | IFUData, timezone: IDTimezone): IFUData | IFSData;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isEmpty } from "../../../general/mix/isEmpty";
|
|
2
|
+
import { transformFilterValues } from "../ui/transformFilterValues";
|
|
3
|
+
/**
|
|
4
|
+
* Gets and transforms the Filter Data by the Timezone object
|
|
5
|
+
* @param {IFSData | IFUData} filterData the filter data
|
|
6
|
+
* @param {IDTimezone} timezone the timezone object
|
|
7
|
+
* @returns {IFSData | IFUData} the new filter data with the transformed datetime values
|
|
8
|
+
*/
|
|
9
|
+
export function getFiltersByTimezone(filterData, timezone) {
|
|
10
|
+
if (isEmpty(filterData) ||
|
|
11
|
+
isEmpty(filterData.scopes) ||
|
|
12
|
+
!Array.isArray(filterData.scopes))
|
|
13
|
+
return filterData;
|
|
14
|
+
return Object.assign(Object.assign({}, filterData), { scopes: filterData.scopes.map((scope) => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map((dataset) => (Object.assign(Object.assign({}, dataset), { filters: dataset.filters.map((filter) => (Object.assign(Object.assign({}, filter), { values: transformFilterValues(filter, {
|
|
15
|
+
timezone,
|
|
16
|
+
translate: undefined,
|
|
17
|
+
i18n: undefined,
|
|
18
|
+
noLocale: true,
|
|
19
|
+
noSuffix: true,
|
|
20
|
+
noTranslate: true,
|
|
21
|
+
}) }))) }))) }))) });
|
|
22
|
+
}
|
|
@@ -10,6 +10,7 @@ export * from "./getFiltersByDatasetsColumns";
|
|
|
10
10
|
export * from "./getFiltersByParams";
|
|
11
11
|
export * from "./getFiltersByScopes";
|
|
12
12
|
export * from "./getFiltersByScopesIds";
|
|
13
|
+
export * from "./getFiltersByTimezone";
|
|
13
14
|
export * from "./getFiltersByVisibility";
|
|
14
15
|
export * from "./getMergeFiltersSettings";
|
|
15
16
|
export * from "./getParamsToGetFilterSettings";
|
|
@@ -10,6 +10,7 @@ export * from "./getFiltersByDatasetsColumns";
|
|
|
10
10
|
export * from "./getFiltersByParams";
|
|
11
11
|
export * from "./getFiltersByScopes";
|
|
12
12
|
export * from "./getFiltersByScopesIds";
|
|
13
|
+
export * from "./getFiltersByTimezone";
|
|
13
14
|
export * from "./getFiltersByVisibility";
|
|
14
15
|
export * from "./getMergeFiltersSettings";
|
|
15
16
|
export * from "./getParamsToGetFilterSettings";
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
import { IDTimezone } from "../../../dates/interfaces/IDTimezone";
|
|
1
2
|
import { II18nConfig } from "../../../globalization/interfaces/II18nConfig";
|
|
2
3
|
import { II18nServiceTranslate } from "../../../globalization/interfaces/II18nServiceTranslate";
|
|
3
4
|
export interface IFUTransformFilterValuesSettings {
|
|
5
|
+
timezone?: IDTimezone;
|
|
4
6
|
translate: II18nServiceTranslate;
|
|
5
7
|
i18n: II18nConfig;
|
|
6
8
|
suffixTranslateLabel?: string;
|
|
9
|
+
noLocale?: boolean;
|
|
10
|
+
noTranslate?: boolean;
|
|
11
|
+
noSuffix?: boolean;
|
|
12
|
+
noTimezone?: boolean;
|
|
7
13
|
}
|
package/dist/format/format.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IFormatConfig } from "../interfaces/format/IFormatConfig.Interface";
|
|
2
|
-
export declare function formatDate(dateString: any, format: any): any;
|
|
2
|
+
export declare function formatDate(dateString: any, format: any, offset: any): any;
|
|
3
3
|
export declare function formatAbbreviated(num: any, decimals: any): any;
|
|
4
4
|
/**
|
|
5
5
|
* Set convert Bytes into MB
|
package/dist/format/format.js
CHANGED
|
@@ -3,6 +3,7 @@ import dayjs from "dayjs";
|
|
|
3
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
|
+
import utc from "dayjs/plugin/utc";
|
|
6
7
|
import { isEmpty } from "../general/mix/isEmpty";
|
|
7
8
|
import { _get } from "../general/object/get";
|
|
8
9
|
import { COLUMN } from "../columns/constants/COLUMN";
|
|
@@ -13,6 +14,7 @@ import { DURATION_PARTS_LIST } from "../column_format/constants/DURATION_PARTS_L
|
|
|
13
14
|
import { cloneDeep } from "../general/object/cloneDeep";
|
|
14
15
|
dayjs.extend(isoWeek); // Add support for iso week format https://github.com/iamkun/dayjs/issues/1328
|
|
15
16
|
dayjs.extend(advancedFormat); // Add support to advanced formats https://day.js.org/docs/en/plugin/advanced-format
|
|
17
|
+
dayjs.extend(utc);
|
|
16
18
|
/**
|
|
17
19
|
* Apply to the given date format to a date value
|
|
18
20
|
* @param bytes type number
|
|
@@ -21,7 +23,7 @@ function isValidDateString(dateString = "") {
|
|
|
21
23
|
return (/^\d{2}\/\d{2}\/\d{4}/.test(dateString) || // MM/DD/YYY OR DD/MM/YYYY
|
|
22
24
|
/^\d{4}-\d{2}-\d{2}/.test(dateString)); // YYYY-MM-DD
|
|
23
25
|
}
|
|
24
|
-
export function formatDate(dateString, format) {
|
|
26
|
+
export function formatDate(dateString, format, offset) {
|
|
25
27
|
let _format = cloneDeep(format);
|
|
26
28
|
if (isObject(format))
|
|
27
29
|
_format = _format.format || "";
|
|
@@ -29,8 +31,12 @@ export function formatDate(dateString, format) {
|
|
|
29
31
|
return dateString;
|
|
30
32
|
if (!isValidDateString(dateString))
|
|
31
33
|
return dateString;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
+
const dateStringCleaned = dateString === null || dateString === void 0 ? void 0 : dateString.replace(/Z$/i, "");
|
|
35
|
+
const firstPartOfDateString = dayjs(dateStringCleaned.split(".")[0]);
|
|
36
|
+
const newDateValue = !isEmpty(offset)
|
|
37
|
+
? firstPartOfDateString.utcOffset(offset)
|
|
38
|
+
: firstPartOfDateString;
|
|
39
|
+
return newDateValue.format(_format
|
|
34
40
|
.replace("HH24:", "HH:")
|
|
35
41
|
.replace("MI:SS", "mm:ss")
|
|
36
42
|
.replace("MM:SS", "mm:ss"));
|
|
@@ -135,7 +141,7 @@ export const addFormat = (value, outputFormat = "None", config) => {
|
|
|
135
141
|
: formatDate(value, (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format) === "Default" &&
|
|
136
142
|
((_c = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _c === void 0 ? void 0 : _c.format)
|
|
137
143
|
? (_d = outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) === null || _d === void 0 ? void 0 : _d.format
|
|
138
|
-
: outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format);
|
|
144
|
+
: outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.format, config === null || config === void 0 ? void 0 : config.offset);
|
|
139
145
|
case "NUMERIC": {
|
|
140
146
|
const parse = parseFloat(value);
|
|
141
147
|
const withLocale = (outputFormat !== "None" && (config === null || config === void 0 ? void 0 : config.lang)) ||
|
package/dist/general/index.d.ts
CHANGED
package/dist/general/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./getSign";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./getSign";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IDTimezone } from "../../dates/interfaces/IDTimezone";
|
|
2
|
+
/**
|
|
3
|
+
* Transforms the date+times propertiesof the given object by the Timezone object
|
|
4
|
+
* @param {any} obj the object
|
|
5
|
+
* @param {IDTimezone} timezone the timezone object
|
|
6
|
+
* @returns {IFSData | IFUData} the new filter data with the transformed datetime values
|
|
7
|
+
*/
|
|
8
|
+
export declare function applyTimezoneDeep(obj: any, timezone: IDTimezone): any;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DATE_FORMAT } from "../../dates/constants/DATE_FORMAT";
|
|
2
|
+
import { DATE_GROUPING_TIME_PROPERTY } from "../../dates/constants/DATE_GROUPING_TIME_PROPERTY";
|
|
3
|
+
import { getDateByTimezone } from "../../dates/helpers/getDateByTimezone";
|
|
4
|
+
import { validateDate } from "../../dates/helpers/validateDate";
|
|
5
|
+
import { isEmpty } from "../mix/isEmpty";
|
|
6
|
+
import { isObject } from "./isObject";
|
|
7
|
+
/**
|
|
8
|
+
* Transforms the date+times propertiesof the given object by the Timezone object
|
|
9
|
+
* @param {any} obj the object
|
|
10
|
+
* @param {IDTimezone} timezone the timezone object
|
|
11
|
+
* @returns {IFSData | IFUData} the new filter data with the transformed datetime values
|
|
12
|
+
*/
|
|
13
|
+
export function applyTimezoneDeep(obj, timezone) {
|
|
14
|
+
if (isEmpty(obj))
|
|
15
|
+
return obj;
|
|
16
|
+
let result;
|
|
17
|
+
if (isObject(obj)) {
|
|
18
|
+
result = {};
|
|
19
|
+
}
|
|
20
|
+
else if (Array.isArray(obj)) {
|
|
21
|
+
result = [];
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
for (const i in obj) {
|
|
25
|
+
if (isObject(obj[i]) || Array.isArray(obj[i])) {
|
|
26
|
+
result[i] = applyTimezoneDeep(obj[i], timezone);
|
|
27
|
+
}
|
|
28
|
+
else if (obj[i] instanceof Date ||
|
|
29
|
+
validateDate(obj[i], DATE_FORMAT.HOUR)) {
|
|
30
|
+
result[i] = getDateByTimezone(obj[i], {
|
|
31
|
+
property: DATE_GROUPING_TIME_PROPERTY.HOUR,
|
|
32
|
+
timezone,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
result[i] = obj[i];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
catch (_a) {
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IDTimezone } from "../../dates/interfaces/IDTimezone";
|
|
1
2
|
import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
|
|
2
3
|
export interface IWidgetConfig {
|
|
3
4
|
appid?: string;
|
|
@@ -5,6 +6,6 @@ export interface IWidgetConfig {
|
|
|
5
6
|
domain: string;
|
|
6
7
|
i18n?: II18nConfig;
|
|
7
8
|
qv_token?: string;
|
|
8
|
-
|
|
9
|
+
timezone?: IDTimezone;
|
|
9
10
|
userid?: string;
|
|
10
11
|
}
|
|
@@ -7,6 +7,7 @@ import { addFormat } from "../../format/format";
|
|
|
7
7
|
import { isEmpty } from "../../general/mix/isEmpty";
|
|
8
8
|
import { getI18nDateGroupLabel } from "../../globalization/helpers/getI18nDateGroupLabel";
|
|
9
9
|
import { getValueWithSuffixes } from "./getValueWithSuffixes";
|
|
10
|
+
import { getDateByTimezone } from "../../dates/helpers/getDateByTimezone";
|
|
10
11
|
/**
|
|
11
12
|
* Transforms a value depending of localization/globalization and extras settings.
|
|
12
13
|
* @param value A value to transform
|
|
@@ -16,12 +17,39 @@ import { getValueWithSuffixes } from "./getValueWithSuffixes";
|
|
|
16
17
|
export function transformValue(value, settings) {
|
|
17
18
|
if (isEmpty(value))
|
|
18
19
|
return value;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const defaultSettings = getDefaultSettings(settings);
|
|
21
|
+
let timezonedValue = value;
|
|
22
|
+
if (!defaultSettings.noTimezone) {
|
|
23
|
+
timezonedValue = getDateByTimezone(value, {
|
|
24
|
+
property: defaultSettings.property,
|
|
25
|
+
timezone: defaultSettings.timezone,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
let valueWithI18n = timezonedValue;
|
|
29
|
+
if (!defaultSettings.noTranslate) {
|
|
30
|
+
valueWithI18n = getI18nDateGroupLabel(timezonedValue, defaultSettings.property, defaultSettings.translate);
|
|
31
|
+
}
|
|
32
|
+
let valueWithLocalization = valueWithI18n;
|
|
33
|
+
if (!defaultSettings.noLocale) {
|
|
34
|
+
valueWithLocalization = addFormat(valueWithI18n, getOutputFormat(settings), getFormatConfig(settings));
|
|
35
|
+
}
|
|
36
|
+
let valueWithSuffix = valueWithI18n;
|
|
37
|
+
if (!defaultSettings.noSuffix) {
|
|
38
|
+
valueWithSuffix = getValueWithSuffixes(valueWithLocalization, {
|
|
39
|
+
suffixTranslateLabel: defaultSettings.suffixTranslateLabel,
|
|
40
|
+
translate: defaultSettings.translate,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return valueWithSuffix;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the default settings properties
|
|
47
|
+
* @param {ITransformValueSettings} settings the given settings
|
|
48
|
+
* @returns {ITransformValueSettings} the settings with default properties
|
|
49
|
+
*/
|
|
50
|
+
function getDefaultSettings(settings) {
|
|
51
|
+
var _a, _b, _c, _d;
|
|
52
|
+
return Object.assign(Object.assign({}, settings), { noLocale: (_a = settings === null || settings === void 0 ? void 0 : settings.noLocale) !== null && _a !== void 0 ? _a : false, noSuffix: (_b = settings === null || settings === void 0 ? void 0 : settings.noSuffix) !== null && _b !== void 0 ? _b : false, noTimezone: (_c = settings === null || settings === void 0 ? void 0 : settings.noTimezone) !== null && _c !== void 0 ? _c : false, noTranslate: (_d = settings === null || settings === void 0 ? void 0 : settings.noTranslate) !== null && _d !== void 0 ? _d : false });
|
|
25
53
|
}
|
|
26
54
|
/**
|
|
27
55
|
* Gets the outputformat settings
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IBColumn } from "../../columns/interfaces/IBColumn";
|
|
2
|
+
import { IBTimezone } from "../../dates/interfaces/IBTimezone";
|
|
2
3
|
/**
|
|
3
4
|
* Structure for Dataset in the frontend side of Qrvey App
|
|
4
5
|
*/
|
|
@@ -7,4 +8,5 @@ export interface IBDataset {
|
|
|
7
8
|
name?: string;
|
|
8
9
|
options?: IBColumn[];
|
|
9
10
|
qrveyid: string;
|
|
11
|
+
timezone?: IBTimezone;
|
|
10
12
|
}
|
|
@@ -2,11 +2,15 @@ import { IAppStatus } from "./IAppStatus";
|
|
|
2
2
|
import { IBModelBranchesMap } from "./IBModelBranchesMap";
|
|
3
3
|
import { IBModelData } from "./IBModelData";
|
|
4
4
|
import { IAppType } from "./IAppType";
|
|
5
|
+
import { IBTimezone } from "../../dates/interfaces/IBTimezone";
|
|
5
6
|
export interface IBModel {
|
|
6
7
|
appType: IAppType;
|
|
7
8
|
appid: string;
|
|
8
9
|
branchesMap?: IBModelBranchesMap[];
|
|
9
10
|
createDate: string;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Data Link feature is not longer supported
|
|
13
|
+
*/
|
|
10
14
|
datalinkInfo?: any[];
|
|
11
15
|
geoGroups?: any[];
|
|
12
16
|
modifyDate: string;
|
|
@@ -16,5 +20,6 @@ export interface IBModel {
|
|
|
16
20
|
questionOrder: string[];
|
|
17
21
|
questions: IBModelData;
|
|
18
22
|
status: IAppStatus;
|
|
23
|
+
timezone: IBTimezone;
|
|
19
24
|
userid: string;
|
|
20
25
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
2
|
+
import { IDTimezone } from "../../dates/interfaces/IDTimezone";
|
|
2
3
|
import { IBDataset } from "./IBDataset";
|
|
3
4
|
/**
|
|
4
5
|
* Structure for Dataset in the frontend side of Qrvey App
|
|
5
6
|
*/
|
|
6
|
-
export interface IDataset extends Omit<IBDataset, "name" | "options"> {
|
|
7
|
+
export interface IDataset extends Omit<IBDataset, "name" | "options" | "timezone"> {
|
|
7
8
|
label?: string;
|
|
8
9
|
options?: IColumn[];
|
|
10
|
+
timezone?: IDTimezone;
|
|
9
11
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
2
|
+
import { IDTimezone } from "../../dates/interfaces/IDTimezone";
|
|
2
3
|
import { IBModel } from "./IBModel";
|
|
3
4
|
import { IModelBranchesMap } from "./IModelBranchesMap";
|
|
4
|
-
export interface IModel extends Omit<IBModel, "questions" | "branchesMap" | "name" | "numResponses" | "questionOrder"> {
|
|
5
|
+
export interface IModel extends Omit<IBModel, "questions" | "branchesMap" | "name" | "numResponses" | "questionOrder" | "timezone"> {
|
|
5
6
|
columns: IColumn[];
|
|
6
7
|
columnOrder: string[];
|
|
7
8
|
branchesMap: IModelBranchesMap[];
|
|
8
9
|
label: string;
|
|
10
|
+
timezone: IDTimezone;
|
|
9
11
|
totalRecords: number;
|
|
10
12
|
}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { IColumn } from "../../columns/interfaces/IColumn";
|
|
2
2
|
import { IColumnPropertyType } from "../../columns/interfaces/IColumnPropertyType";
|
|
3
|
+
import { IDTimezone } from "../../dates/interfaces/IDTimezone";
|
|
3
4
|
import { II18nConfig } from "../../globalization/interfaces/II18nConfig";
|
|
4
5
|
import { II18nServiceTranslate } from "../../globalization/interfaces/II18nServiceTranslate";
|
|
5
6
|
export interface ITransformValueSettings {
|
|
6
7
|
column: IColumn;
|
|
7
8
|
property: IColumnPropertyType;
|
|
9
|
+
timezone?: IDTimezone;
|
|
8
10
|
translate: II18nServiceTranslate;
|
|
9
11
|
i18n: II18nConfig;
|
|
10
12
|
suffixTranslateLabel?: string;
|
|
13
|
+
noLocale?: boolean;
|
|
14
|
+
noTranslate?: boolean;
|
|
15
|
+
noSuffix?: boolean;
|
|
16
|
+
noTimezone?: boolean;
|
|
11
17
|
}
|