@qrvey/utils 1.2.9-21 → 1.2.9-24

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 (53) hide show
  1. package/README.md +295 -295
  2. package/dist/cjs/columns/interfaces/IColumn.d.ts +0 -2
  3. package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.d.ts +1 -0
  4. package/dist/cjs/dates/constants/DATETIME_COLUMN_FORMAT.js +11 -0
  5. package/dist/cjs/dates/constants/index.d.ts +1 -0
  6. package/dist/cjs/dates/constants/index.js +1 -0
  7. package/dist/cjs/filters/adapters/FDToFlatUI.js +1 -1
  8. package/dist/cjs/filters/adapters/FDToUI.js +1 -2
  9. package/dist/cjs/filters/adapters/logicToFlatUI.js +3 -3
  10. package/dist/cjs/filters/helpers/ui/getUpdatedUIFilters.js +1 -1
  11. package/dist/cjs/filters/interfaces/OLD_IFilterDetail.d.ts +4 -1
  12. package/dist/cjs/format/definition.d.ts +16 -2
  13. package/dist/cjs/format/definition.js +3 -1
  14. package/dist/cjs/format/format.js +1 -1
  15. package/dist/cjs/format/localization.js +24 -9
  16. package/dist/cjs/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.d.ts +1 -0
  17. package/dist/cjs/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +1 -0
  18. package/dist/cjs/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
  19. package/dist/cjs/qrvey/helpers/transformValue.js +1 -1
  20. package/dist/columns/interfaces/IColumn.d.ts +0 -2
  21. package/dist/dates/constants/DATETIME_COLUMN_FORMAT.d.ts +1 -0
  22. package/dist/dates/constants/DATETIME_COLUMN_FORMAT.js +8 -0
  23. package/dist/dates/constants/index.d.ts +1 -0
  24. package/dist/dates/constants/index.js +1 -0
  25. package/dist/filters/adapters/FDToFlatUI.js +1 -1
  26. package/dist/filters/adapters/FDToUI.js +1 -2
  27. package/dist/filters/adapters/logicToFlatUI.js +3 -3
  28. package/dist/filters/helpers/ui/getUpdatedUIFilters.js +1 -1
  29. package/dist/filters/interfaces/OLD_IFilterDetail.d.ts +4 -1
  30. package/dist/format/definition.d.ts +16 -2
  31. package/dist/format/definition.js +2 -0
  32. package/dist/format/format.js +1 -1
  33. package/dist/format/localization.js +25 -10
  34. package/dist/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.d.ts +1 -0
  35. package/dist/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.js +1 -0
  36. package/dist/interfaces/format/IFormatOutputFormat.Interface.d.ts +1 -0
  37. package/dist/qrvey/helpers/transformValue.js +1 -1
  38. package/package.json +1 -1
  39. package/src/columns/interfaces/IColumn.ts +0 -2
  40. package/src/dates/constants/DATETIME_COLUMN_FORMAT.ts +8 -0
  41. package/src/dates/constants/index.ts +1 -0
  42. package/src/filters/adapters/FDToFlatUI.ts +1 -1
  43. package/src/filters/adapters/FDToUI.ts +1 -1
  44. package/src/filters/adapters/logicToFlatUI.ts +1 -1
  45. package/src/filters/helpers/ui/getUpdatedUIFilters.ts +1 -1
  46. package/src/filters/interfaces/OLD_IFilterDetail.ts +2 -1
  47. package/src/format/definition.ts +6 -1
  48. package/src/format/format.ts +1 -1
  49. package/src/format/localization.ts +24 -10
  50. package/src/globalization/interfaces/chart_builder/II18nChartBuilderDimensions.ts +1 -0
  51. package/src/globalization/labels/chart_builder/I18N_CHART_BUILDER_GENERAL.ts +1 -0
  52. package/src/interfaces/format/IFormatOutputFormat.Interface.ts +2 -1
  53. package/src/qrvey/helpers/transformValue.ts +1 -1
@@ -1,5 +1,4 @@
1
1
  import { IColumnCalculationType } from "../../qrvey/interfaces/ICalculationType";
2
- import { IDataset } from "../../qrvey/interfaces/IDataset";
3
2
  import { IColumnPropertyType } from "./IColumnPropertyType";
4
3
  import { IColumnSortingSettings } from "./IColumnSortingSettings";
5
4
  import { IBColumn } from "./IBColumn";
@@ -11,7 +10,6 @@ export interface IColumn extends Omit<IBColumn, "text" | "bucketId" | "formulaId
11
10
  bucketid?: string;
12
11
  aggregate?: IAggregateType;
13
12
  calculation?: IColumnCalculationType;
14
- dataset?: IDataset;
15
13
  formulaid?: string;
16
14
  label?: string;
17
15
  linkid?: string;
@@ -0,0 +1 @@
1
+ export declare const DATETIME_COLUMN_FORMAT: string[];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DATETIME_COLUMN_FORMAT = void 0;
4
+ exports.DATETIME_COLUMN_FORMAT = [
5
+ 'MM/DD/YYYY HH24:MM:SS',
6
+ 'DD/MM/YYYY HH24:MM:SS',
7
+ 'YYYY-MM-DD HH24:MM:SS',
8
+ 'MM/DD/YYYY HH24:MI:SS',
9
+ 'DD/MM/YYYY HH24:MI:SS',
10
+ 'YYYY-MM-DD HH24:MI:SS'
11
+ ];
@@ -32,3 +32,4 @@ export * from './DATE_YEAR_MONTHS';
32
32
  export * from './DATE_YEAR_MONTHS_MMMM';
33
33
  export * from './DATE_YEAR_QUARTERS';
34
34
  export * from './DATE_YEAR_QUARTERS_RANGE';
35
+ export * from './DATETIME_COLUMN_FORMAT';
@@ -44,3 +44,4 @@ __exportStar(require("./DATE_YEAR_MONTHS"), exports);
44
44
  __exportStar(require("./DATE_YEAR_MONTHS_MMMM"), exports);
45
45
  __exportStar(require("./DATE_YEAR_QUARTERS"), exports);
46
46
  __exportStar(require("./DATE_YEAR_QUARTERS_RANGE"), exports);
47
+ __exportStar(require("./DATETIME_COLUMN_FORMAT"), exports);
@@ -44,7 +44,7 @@ function FD21ToFlatUI(scopes = [], datasetsInfo = []) {
44
44
  const datasetInfo = datasetsInfo.find(dInfo => dInfo.qrveyid === dataset.qrveyid && dInfo.linkid === dataset.linkid);
45
45
  let columnInfo;
46
46
  if (!(0, isEmpty_1.isEmpty)(datasetInfo))
47
- columnInfo = datasetInfo.options.find(cInfo => { var _a, _b; return cInfo.id === filter.column.id && ((_a = cInfo.dataset) === null || _a === void 0 ? void 0 : _a.qrveyid) === filter.column.qrveyid && ((_b = cInfo.dataset) === null || _b === void 0 ? void 0 : _b.linkid) === filter.column.linkid; });
47
+ columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
48
48
  const info = !(0, isEmpty_1.isEmpty)(filter.extras.info) ? { icon: filter.extras.info.icon, label: filter.extras.info.label } : undefined;
49
49
  const property = (0, adaptDateGroupingProperty_1.adaptDateGroupingProperty)(filter.property);
50
50
  const uFilter = {
@@ -48,7 +48,6 @@ function FD21ToUI(scopes = [], section = FILTER_SECTION_1.FILTER_SECTION.ANYWHER
48
48
  ufData.scopes = scopes.map(scope => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map(dataset => {
49
49
  const datasetInfo = datasetsInfo.find(dInfo => dInfo.qrveyid === dataset.qrveyid && dInfo.linkid === dataset.linkid);
50
50
  return Object.assign(Object.assign({}, dataset), { label: datasetInfo === null || datasetInfo === void 0 ? void 0 : datasetInfo.label, filters: dataset.filters.map(filter => {
51
- var _a;
52
51
  let columnInfo;
53
52
  if (!(0, isEmpty_1.isEmpty)(datasetInfo))
54
53
  columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
@@ -60,7 +59,7 @@ function FD21ToUI(scopes = [], section = FILTER_SECTION_1.FILTER_SECTION.ANYWHER
60
59
  id: filter.column.id,
61
60
  label: columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.label,
62
61
  linked: columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.linked,
63
- linkid: ((_a = columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.dataset) === null || _a === void 0 ? void 0 : _a.linkid) || (datasetInfo === null || datasetInfo === void 0 ? void 0 : datasetInfo.linkid),
62
+ linkid: (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.linkid) || (datasetInfo === null || datasetInfo === void 0 ? void 0 : datasetInfo.linkid),
64
63
  outputFormat: (0, get_1._get)(datasetInfo, 'outputFormat'),
65
64
  qrveyid: filter.column.qrveyid,
66
65
  type: (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.type) || filter.column.type,
@@ -56,7 +56,7 @@ function buildFilterByExpression(expression, scopeItem, uFilters) {
56
56
  }
57
57
  }
58
58
  function getFilterByExpression(expression, scopeItem) {
59
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
59
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
60
60
  const uiExtras = expression.uiExtras;
61
61
  const scopeid = scopeItem.scope !== FILTER_SCOPE_1.FILTER_SCOPE.GLOBAL ? (0, get_1._get)(scopeItem, 'uiExtras.scopeid') : undefined;
62
62
  const info = !(0, isEmpty_1.isEmpty)(uiExtras.info) ? { icon: uiExtras.info.icon, label: uiExtras.info.label } : undefined;
@@ -92,8 +92,8 @@ function getFilterByExpression(expression, scopeItem) {
92
92
  enabled: true,
93
93
  displayed: true,
94
94
  qrveyid: (_r = uiExtras.column) === null || _r === void 0 ? void 0 : _r.qrveyid,
95
- label: (0, get_1._get)((_s = uiExtras.column) === null || _s === void 0 ? void 0 : _s.dataset, 'name') || ((_u = (_t = uiExtras.column) === null || _t === void 0 ? void 0 : _t.dataset) === null || _u === void 0 ? void 0 : _u.label),
96
- linkid: (_v = uiExtras.column) === null || _v === void 0 ? void 0 : _v.linkid,
95
+ label: (0, get_1._get)(uiExtras.column, 'dataset.name') || ((_s = uiExtras.column) === null || _s === void 0 ? void 0 : _s.label),
96
+ linkid: (_t = uiExtras.column) === null || _t === void 0 ? void 0 : _t.linkid,
97
97
  } }),
98
98
  filterid: undefined,
99
99
  lookupDisplayIndex: uiExtras.lookupDisplayIndex,
@@ -19,7 +19,7 @@ function getUpdatedUIFilters(data, datasets = []) {
19
19
  dataset.filters = dataset.filters.map(filter => {
20
20
  let columnInfo;
21
21
  if (!(0, isEmpty_1.isEmpty)(datasetInfo))
22
- columnInfo = datasetInfo.options.find(cInfo => { var _a, _b; return cInfo.id === filter.column.id && ((_a = cInfo.dataset) === null || _a === void 0 ? void 0 : _a.qrveyid) === filter.column.qrveyid && ((_b = cInfo.dataset) === null || _b === void 0 ? void 0 : _b.linkid) === filter.column.linkid; });
22
+ columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
23
23
  if (!(0, isEmpty_1.isEmpty)(columnInfo)) {
24
24
  filter.column.formulaType = columnInfo.formulaType;
25
25
  filter.column.label = columnInfo.label;
@@ -1,4 +1,5 @@
1
1
  import { IColumn } from "../../columns/interfaces/IColumn";
2
+ import { IDataset } from "../../qrvey/interfaces/IDataset";
2
3
  import { IFSFilterExtrasInfo } from "./common/IFSFilterExtrasInfo";
3
4
  import { IFDateSection } from "./IFDateSection";
4
5
  import { IFOperator } from "./IFOperator";
@@ -10,7 +11,9 @@ import { IFValue } from "./IFValue";
10
11
  import { IFUChartSettings } from "./ui/IFUChartSettings";
11
12
  import { IFUValue } from "./ui/IFUValue";
12
13
  export interface OLD_IFilterDetail {
13
- column?: IColumn;
14
+ column?: IColumn & {
15
+ dataset: IDataset;
16
+ };
14
17
  dateSection?: IFDateSection;
15
18
  enabled?: boolean;
16
19
  lookupDisplayIndex?: number;
@@ -19,12 +19,26 @@ export declare const enum LOCALE_FORMATS {
19
19
  DECIMAL = "Decimal",
20
20
  CURRENCY = "Currency",
21
21
  PERCENTAGE = "Percentage",
22
- SCIENTIFIC = "Scientific"
22
+ SCIENTIFIC = "Scientific",
23
+ ABBREVIATED = "Abbreviated"
23
24
  }
24
25
  export declare const enum LOCALE_STYLES {
25
26
  DECIMAL = "decimal",
26
27
  PERCENT = "percent",
27
28
  CURRENCY = "currency",
28
- SCIENTIFIC = "scientific"
29
+ SCIENTIFIC = "scientific",
30
+ COMPACT = "compact"
29
31
  }
30
32
  export declare const LANG_DEFAULT = "en-US";
33
+ export declare const CURRENCY_DEFAULT: {
34
+ text: string;
35
+ label: string;
36
+ };
37
+ export declare const DATETIME_OPTIONS: {
38
+ year: string;
39
+ month: string;
40
+ day: string;
41
+ hour: string;
42
+ minute: string;
43
+ second: string;
44
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LANG_DEFAULT = exports.currencyISO = exports.isTextColumn = exports.supportNumericFormatting = exports.isNumericalColumn = exports.isComplexColumn = exports.hasfileSizeProperty = exports.appliesFormatting = exports.DATEGROUP_FORMATTING_UNSUPPORT = exports.QUESTION_FORMAT_SUPPORT = exports.numericalFields = exports.complexFields = exports.textFields = void 0;
3
+ exports.DATETIME_OPTIONS = exports.CURRENCY_DEFAULT = exports.LANG_DEFAULT = exports.currencyISO = exports.isTextColumn = exports.supportNumericFormatting = exports.isNumericalColumn = exports.isComplexColumn = exports.hasfileSizeProperty = exports.appliesFormatting = exports.DATEGROUP_FORMATTING_UNSUPPORT = exports.QUESTION_FORMAT_SUPPORT = exports.numericalFields = exports.complexFields = exports.textFields = void 0;
4
4
  const COLUMN_1 = require("../columns/constants/COLUMN");
5
5
  const Charts_Const_1 = require("../constants/Charts.Const");
6
6
  exports.textFields = [COLUMN_1.COLUMN.TEXTFIELD, COLUMN_1.COLUMN.TEXT_CATEGORY, COLUMN_1.COLUMN.TEXT_LABEL, COLUMN_1.COLUMN.TEXT_CATEGORY];
@@ -82,3 +82,5 @@ exports.currencyISO = [
82
82
  { text: 'RM (MYR)', label: 'MYR' }
83
83
  ];
84
84
  exports.LANG_DEFAULT = 'en-US';
85
+ exports.CURRENCY_DEFAULT = { text: '$ (USD)', label: 'USD' };
86
+ exports.DATETIME_OPTIONS = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
@@ -93,7 +93,7 @@ const addFormat = (value, outputFormat = 'None', config) => {
93
93
  return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? (0, localization_1.formatWithLocale)(value, outputFormat, config) : formatDate(value, outputFormat.format);
94
94
  case 'NUMERIC': {
95
95
  const parse = parseFloat(value);
96
- const withLocale = outputFormat.format !== 'Abbreviated' && outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
96
+ const withLocale = outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
97
97
  return isNaN(parse) ? value : withLocale ? (0, localization_1.formatWithLocale)(value, outputFormat, config)
98
98
  : formatNumber(parse, outputFormat, config);
99
99
  }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatWithLocale = exports.chooseLang = exports.getLang = void 0;
4
+ const __1 = require("..");
5
+ const isEmpty_1 = require("../general/mix/isEmpty");
4
6
  const definition_1 = require("./definition");
5
7
  const getLang = (locale) => {
6
8
  if (!locale)
@@ -22,20 +24,26 @@ const formatWithLocale = (value, outputFormat, config = {}) => {
22
24
  switch (outputFormat.type) {
23
25
  case 'DATE':
24
26
  case 'DATETIME':
25
- return formatLocaleDate(value, config);
27
+ return formatLocaleDate(value, outputFormat, config);
26
28
  case 'NUMERIC':
27
29
  return formatLocaleNumber(value, outputFormat, config);
28
30
  }
29
31
  };
30
32
  exports.formatWithLocale = formatWithLocale;
31
- function formatLocaleDate(value, config) {
33
+ function formatLocaleDate(value, outputFormat, config) {
32
34
  const { lang = definition_1.LANG_DEFAULT, options } = config;
33
35
  const dateParam = new Date(value);
36
+ let langOpts = options;
37
+ if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
38
+ const { format } = outputFormat.originalFormat;
39
+ if (__1.DATETIME_COLUMN_FORMAT.includes(format))
40
+ langOpts = definition_1.DATETIME_OPTIONS;
41
+ }
34
42
  try {
35
- return new Intl.DateTimeFormat([lang, definition_1.LANG_DEFAULT], options).format(dateParam);
43
+ return new Intl.DateTimeFormat([lang, definition_1.LANG_DEFAULT], langOpts).format(dateParam);
36
44
  }
37
45
  catch (error) {
38
- return new Intl.DateTimeFormat(definition_1.LANG_DEFAULT, options).format(dateParam);
46
+ return new Intl.DateTimeFormat(definition_1.LANG_DEFAULT, langOpts).format(dateParam);
39
47
  }
40
48
  }
41
49
  function formatLocaleNumber(value, outputFormat, config) {
@@ -52,12 +60,19 @@ function getLocaleOptions(outputFormat) {
52
60
  const { format, decimals, currency } = outputFormat;
53
61
  switch (format) {
54
62
  case "Currency" /* CURRENCY */: {
55
- const iso = definition_1.currencyISO.find(item => (item.text === currency.text) || (item.text.includes(currency.label)));
56
- return { style: "currency" /* CURRENCY */, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: 0 };
63
+ let iso = (0, isEmpty_1.isEmpty)(currency) ? definition_1.CURRENCY_DEFAULT : definition_1.currencyISO.find(item => item.text === currency.text);
64
+ if ((0, isEmpty_1.isEmpty)(iso)) {
65
+ iso = definition_1.currencyISO.find(item => {
66
+ const symbol = item.text.split(' ')[0];
67
+ return symbol === currency.label;
68
+ });
69
+ }
70
+ return { style: "currency" /* CURRENCY */, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: decimals, currencyDisplay: 'narrowSymbol' };
57
71
  }
58
72
  case "Scientific" /* SCIENTIFIC */: return { style: "decimal" /* DECIMAL */,
59
- notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals };
60
- case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals };
61
- default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals };
73
+ notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
74
+ case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
75
+ case "Abbreviated" /* ABBREVIATED */: return { notation: "compact" /* COMPACT */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
76
+ default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
62
77
  }
63
78
  }
@@ -8,6 +8,7 @@ export interface II18nChartBuilderDimensions {
8
8
  geolocation: string;
9
9
  group: string;
10
10
  groups: string;
11
+ other_value: string;
11
12
  other_values: string;
12
13
  pivot: string;
13
14
  row: string;
@@ -79,6 +79,7 @@ exports.I18N_CHART_BUILDER_GENERAL = {
79
79
  geolocation: 'Geolocation',
80
80
  group: 'Group',
81
81
  groups: 'Groups',
82
+ other_value: 'Other Value',
82
83
  other_values: 'Other Values',
83
84
  pivot: 'Pivot',
84
85
  row: 'Row',
@@ -5,4 +5,5 @@ export interface IFormatOutputFormat {
5
5
  decimals?: number;
6
6
  currency?: IFormatCurrency;
7
7
  backup_currency?: IFormatCurrency;
8
+ originalFormat?: any;
8
9
  }
@@ -43,5 +43,5 @@ function getOutputFormat(settings) {
43
43
  */
44
44
  function getFormatConfig(settings) {
45
45
  var _a;
46
- return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.lang };
46
+ return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.locale };
47
47
  }
@@ -1,5 +1,4 @@
1
1
  import { IColumnCalculationType } from "../../qrvey/interfaces/ICalculationType";
2
- import { IDataset } from "../../qrvey/interfaces/IDataset";
3
2
  import { IColumnPropertyType } from "./IColumnPropertyType";
4
3
  import { IColumnSortingSettings } from "./IColumnSortingSettings";
5
4
  import { IBColumn } from "./IBColumn";
@@ -11,7 +10,6 @@ export interface IColumn extends Omit<IBColumn, "text" | "bucketId" | "formulaId
11
10
  bucketid?: string;
12
11
  aggregate?: IAggregateType;
13
12
  calculation?: IColumnCalculationType;
14
- dataset?: IDataset;
15
13
  formulaid?: string;
16
14
  label?: string;
17
15
  linkid?: string;
@@ -0,0 +1 @@
1
+ export declare const DATETIME_COLUMN_FORMAT: string[];
@@ -0,0 +1,8 @@
1
+ export const DATETIME_COLUMN_FORMAT = [
2
+ 'MM/DD/YYYY HH24:MM:SS',
3
+ 'DD/MM/YYYY HH24:MM:SS',
4
+ 'YYYY-MM-DD HH24:MM:SS',
5
+ 'MM/DD/YYYY HH24:MI:SS',
6
+ 'DD/MM/YYYY HH24:MI:SS',
7
+ 'YYYY-MM-DD HH24:MI:SS'
8
+ ];
@@ -32,3 +32,4 @@ export * from './DATE_YEAR_MONTHS';
32
32
  export * from './DATE_YEAR_MONTHS_MMMM';
33
33
  export * from './DATE_YEAR_QUARTERS';
34
34
  export * from './DATE_YEAR_QUARTERS_RANGE';
35
+ export * from './DATETIME_COLUMN_FORMAT';
@@ -32,3 +32,4 @@ export * from './DATE_YEAR_MONTHS';
32
32
  export * from './DATE_YEAR_MONTHS_MMMM';
33
33
  export * from './DATE_YEAR_QUARTERS';
34
34
  export * from './DATE_YEAR_QUARTERS_RANGE';
35
+ export * from './DATETIME_COLUMN_FORMAT';
@@ -40,7 +40,7 @@ function FD21ToFlatUI(scopes = [], datasetsInfo = []) {
40
40
  const datasetInfo = datasetsInfo.find(dInfo => dInfo.qrveyid === dataset.qrveyid && dInfo.linkid === dataset.linkid);
41
41
  let columnInfo;
42
42
  if (!isEmpty(datasetInfo))
43
- columnInfo = datasetInfo.options.find(cInfo => { var _a, _b; return cInfo.id === filter.column.id && ((_a = cInfo.dataset) === null || _a === void 0 ? void 0 : _a.qrveyid) === filter.column.qrveyid && ((_b = cInfo.dataset) === null || _b === void 0 ? void 0 : _b.linkid) === filter.column.linkid; });
43
+ columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
44
44
  const info = !isEmpty(filter.extras.info) ? { icon: filter.extras.info.icon, label: filter.extras.info.label } : undefined;
45
45
  const property = adaptDateGroupingProperty(filter.property);
46
46
  const uFilter = {
@@ -44,7 +44,6 @@ function FD21ToUI(scopes = [], section = FILTER_SECTION.ANYWHERE, enabled = true
44
44
  ufData.scopes = scopes.map(scope => (Object.assign(Object.assign({}, scope), { datasets: scope.datasets.map(dataset => {
45
45
  const datasetInfo = datasetsInfo.find(dInfo => dInfo.qrveyid === dataset.qrveyid && dInfo.linkid === dataset.linkid);
46
46
  return Object.assign(Object.assign({}, dataset), { label: datasetInfo === null || datasetInfo === void 0 ? void 0 : datasetInfo.label, filters: dataset.filters.map(filter => {
47
- var _a;
48
47
  let columnInfo;
49
48
  if (!isEmpty(datasetInfo))
50
49
  columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
@@ -56,7 +55,7 @@ function FD21ToUI(scopes = [], section = FILTER_SECTION.ANYWHERE, enabled = true
56
55
  id: filter.column.id,
57
56
  label: columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.label,
58
57
  linked: columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.linked,
59
- linkid: ((_a = columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.dataset) === null || _a === void 0 ? void 0 : _a.linkid) || (datasetInfo === null || datasetInfo === void 0 ? void 0 : datasetInfo.linkid),
58
+ linkid: (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.linkid) || (datasetInfo === null || datasetInfo === void 0 ? void 0 : datasetInfo.linkid),
60
59
  outputFormat: _get(datasetInfo, 'outputFormat'),
61
60
  qrveyid: filter.column.qrveyid,
62
61
  type: (columnInfo === null || columnInfo === void 0 ? void 0 : columnInfo.type) || filter.column.type,
@@ -52,7 +52,7 @@ function buildFilterByExpression(expression, scopeItem, uFilters) {
52
52
  }
53
53
  }
54
54
  function getFilterByExpression(expression, scopeItem) {
55
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
55
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
56
56
  const uiExtras = expression.uiExtras;
57
57
  const scopeid = scopeItem.scope !== FILTER_SCOPE.GLOBAL ? _get(scopeItem, 'uiExtras.scopeid') : undefined;
58
58
  const info = !isEmpty(uiExtras.info) ? { icon: uiExtras.info.icon, label: uiExtras.info.label } : undefined;
@@ -88,8 +88,8 @@ function getFilterByExpression(expression, scopeItem) {
88
88
  enabled: true,
89
89
  displayed: true,
90
90
  qrveyid: (_r = uiExtras.column) === null || _r === void 0 ? void 0 : _r.qrveyid,
91
- label: _get((_s = uiExtras.column) === null || _s === void 0 ? void 0 : _s.dataset, 'name') || ((_u = (_t = uiExtras.column) === null || _t === void 0 ? void 0 : _t.dataset) === null || _u === void 0 ? void 0 : _u.label),
92
- linkid: (_v = uiExtras.column) === null || _v === void 0 ? void 0 : _v.linkid,
91
+ label: _get(uiExtras.column, 'dataset.name') || ((_s = uiExtras.column) === null || _s === void 0 ? void 0 : _s.label),
92
+ linkid: (_t = uiExtras.column) === null || _t === void 0 ? void 0 : _t.linkid,
93
93
  } }),
94
94
  filterid: undefined,
95
95
  lookupDisplayIndex: uiExtras.lookupDisplayIndex,
@@ -16,7 +16,7 @@ export function getUpdatedUIFilters(data, datasets = []) {
16
16
  dataset.filters = dataset.filters.map(filter => {
17
17
  let columnInfo;
18
18
  if (!isEmpty(datasetInfo))
19
- columnInfo = datasetInfo.options.find(cInfo => { var _a, _b; return cInfo.id === filter.column.id && ((_a = cInfo.dataset) === null || _a === void 0 ? void 0 : _a.qrveyid) === filter.column.qrveyid && ((_b = cInfo.dataset) === null || _b === void 0 ? void 0 : _b.linkid) === filter.column.linkid; });
19
+ columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
20
20
  if (!isEmpty(columnInfo)) {
21
21
  filter.column.formulaType = columnInfo.formulaType;
22
22
  filter.column.label = columnInfo.label;
@@ -1,4 +1,5 @@
1
1
  import { IColumn } from "../../columns/interfaces/IColumn";
2
+ import { IDataset } from "../../qrvey/interfaces/IDataset";
2
3
  import { IFSFilterExtrasInfo } from "./common/IFSFilterExtrasInfo";
3
4
  import { IFDateSection } from "./IFDateSection";
4
5
  import { IFOperator } from "./IFOperator";
@@ -10,7 +11,9 @@ import { IFValue } from "./IFValue";
10
11
  import { IFUChartSettings } from "./ui/IFUChartSettings";
11
12
  import { IFUValue } from "./ui/IFUValue";
12
13
  export interface OLD_IFilterDetail {
13
- column?: IColumn;
14
+ column?: IColumn & {
15
+ dataset: IDataset;
16
+ };
14
17
  dateSection?: IFDateSection;
15
18
  enabled?: boolean;
16
19
  lookupDisplayIndex?: number;
@@ -19,12 +19,26 @@ export declare const enum LOCALE_FORMATS {
19
19
  DECIMAL = "Decimal",
20
20
  CURRENCY = "Currency",
21
21
  PERCENTAGE = "Percentage",
22
- SCIENTIFIC = "Scientific"
22
+ SCIENTIFIC = "Scientific",
23
+ ABBREVIATED = "Abbreviated"
23
24
  }
24
25
  export declare const enum LOCALE_STYLES {
25
26
  DECIMAL = "decimal",
26
27
  PERCENT = "percent",
27
28
  CURRENCY = "currency",
28
- SCIENTIFIC = "scientific"
29
+ SCIENTIFIC = "scientific",
30
+ COMPACT = "compact"
29
31
  }
30
32
  export declare const LANG_DEFAULT = "en-US";
33
+ export declare const CURRENCY_DEFAULT: {
34
+ text: string;
35
+ label: string;
36
+ };
37
+ export declare const DATETIME_OPTIONS: {
38
+ year: string;
39
+ month: string;
40
+ day: string;
41
+ hour: string;
42
+ minute: string;
43
+ second: string;
44
+ };
@@ -73,3 +73,5 @@ export const currencyISO = [
73
73
  { text: 'RM (MYR)', label: 'MYR' }
74
74
  ];
75
75
  export const LANG_DEFAULT = 'en-US';
76
+ export const CURRENCY_DEFAULT = { text: '$ (USD)', label: 'USD' };
77
+ export const DATETIME_OPTIONS = { year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' };
@@ -84,7 +84,7 @@ export const addFormat = (value, outputFormat = 'None', config) => {
84
84
  return (config === null || config === void 0 ? void 0 : config.lang) && outputFormat.format === 'Default' ? formatWithLocale(value, outputFormat, config) : formatDate(value, outputFormat.format);
85
85
  case 'NUMERIC': {
86
86
  const parse = parseFloat(value);
87
- const withLocale = outputFormat.format !== 'Abbreviated' && outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
87
+ const withLocale = outputFormat !== 'None' && (config === null || config === void 0 ? void 0 : config.lang);
88
88
  return isNaN(parse) ? value : withLocale ? formatWithLocale(value, outputFormat, config)
89
89
  : formatNumber(parse, outputFormat, config);
90
90
  }
@@ -1,4 +1,6 @@
1
- import { currencyISO, LANG_DEFAULT } from './definition';
1
+ import { DATETIME_COLUMN_FORMAT } from '..';
2
+ import { isEmpty } from '../general/mix/isEmpty';
3
+ import { currencyISO, LANG_DEFAULT, CURRENCY_DEFAULT, DATETIME_OPTIONS } from './definition';
2
4
  export const getLang = (locale) => {
3
5
  if (!locale)
4
6
  return;
@@ -17,19 +19,25 @@ export const formatWithLocale = (value, outputFormat, config = {}) => {
17
19
  switch (outputFormat.type) {
18
20
  case 'DATE':
19
21
  case 'DATETIME':
20
- return formatLocaleDate(value, config);
22
+ return formatLocaleDate(value, outputFormat, config);
21
23
  case 'NUMERIC':
22
24
  return formatLocaleNumber(value, outputFormat, config);
23
25
  }
24
26
  };
25
- function formatLocaleDate(value, config) {
27
+ function formatLocaleDate(value, outputFormat, config) {
26
28
  const { lang = LANG_DEFAULT, options } = config;
27
29
  const dateParam = new Date(value);
30
+ let langOpts = options;
31
+ if (outputFormat === null || outputFormat === void 0 ? void 0 : outputFormat.originalFormat) {
32
+ const { format } = outputFormat.originalFormat;
33
+ if (DATETIME_COLUMN_FORMAT.includes(format))
34
+ langOpts = DATETIME_OPTIONS;
35
+ }
28
36
  try {
29
- return new Intl.DateTimeFormat([lang, LANG_DEFAULT], options).format(dateParam);
37
+ return new Intl.DateTimeFormat([lang, LANG_DEFAULT], langOpts).format(dateParam);
30
38
  }
31
39
  catch (error) {
32
- return new Intl.DateTimeFormat(LANG_DEFAULT, options).format(dateParam);
40
+ return new Intl.DateTimeFormat(LANG_DEFAULT, langOpts).format(dateParam);
33
41
  }
34
42
  }
35
43
  function formatLocaleNumber(value, outputFormat, config) {
@@ -46,12 +54,19 @@ function getLocaleOptions(outputFormat) {
46
54
  const { format, decimals, currency } = outputFormat;
47
55
  switch (format) {
48
56
  case "Currency" /* CURRENCY */: {
49
- const iso = currencyISO.find(item => (item.text === currency.text) || (item.text.includes(currency.label)));
50
- return { style: "currency" /* CURRENCY */, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: 0 };
57
+ let iso = isEmpty(currency) ? CURRENCY_DEFAULT : currencyISO.find(item => item.text === currency.text);
58
+ if (isEmpty(iso)) {
59
+ iso = currencyISO.find(item => {
60
+ const symbol = item.text.split(' ')[0];
61
+ return symbol === currency.label;
62
+ });
63
+ }
64
+ return { style: "currency" /* CURRENCY */, currency: iso.label, maximumFractionDigits: decimals, minimumFractionDigits: decimals, currencyDisplay: 'narrowSymbol' };
51
65
  }
52
66
  case "Scientific" /* SCIENTIFIC */: return { style: "decimal" /* DECIMAL */,
53
- notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals };
54
- case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals };
55
- default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals };
67
+ notation: "scientific" /* SCIENTIFIC */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
68
+ case "Percentage" /* PERCENTAGE */: return { style: "percent" /* PERCENT */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
69
+ case "Abbreviated" /* ABBREVIATED */: return { notation: "compact" /* COMPACT */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
70
+ default: return { style: "decimal" /* DECIMAL */, maximumFractionDigits: decimals, minimumFractionDigits: decimals };
56
71
  }
57
72
  }
@@ -8,6 +8,7 @@ export interface II18nChartBuilderDimensions {
8
8
  geolocation: string;
9
9
  group: string;
10
10
  groups: string;
11
+ other_value: string;
11
12
  other_values: string;
12
13
  pivot: string;
13
14
  row: string;
@@ -76,6 +76,7 @@ export const I18N_CHART_BUILDER_GENERAL = {
76
76
  geolocation: 'Geolocation',
77
77
  group: 'Group',
78
78
  groups: 'Groups',
79
+ other_value: 'Other Value',
79
80
  other_values: 'Other Values',
80
81
  pivot: 'Pivot',
81
82
  row: 'Row',
@@ -5,4 +5,5 @@ export interface IFormatOutputFormat {
5
5
  decimals?: number;
6
6
  currency?: IFormatCurrency;
7
7
  backup_currency?: IFormatCurrency;
8
+ originalFormat?: any;
8
9
  }
@@ -39,5 +39,5 @@ function getOutputFormat(settings) {
39
39
  */
40
40
  function getFormatConfig(settings) {
41
41
  var _a;
42
- return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.lang };
42
+ return { lang: (_a = settings.i18n) === null || _a === void 0 ? void 0 : _a.locale };
43
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.2.9-21",
3
+ "version": "1.2.9-24",
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",
@@ -1,5 +1,4 @@
1
1
  import { IColumnCalculationType } from "../../qrvey/interfaces/ICalculationType";
2
- import { IDataset } from "../../qrvey/interfaces/IDataset";
3
2
  import { IColumnPropertyType } from "./IColumnPropertyType";
4
3
  import { IColumnSortingSettings } from "./IColumnSortingSettings";
5
4
  import { IBColumn } from "./IBColumn";
@@ -12,7 +11,6 @@ export interface IColumn extends Omit<IBColumn, "text" | "bucketId" | "formulaId
12
11
  bucketid?: string;
13
12
  aggregate?: IAggregateType;
14
13
  calculation?: IColumnCalculationType;
15
- dataset?: IDataset;
16
14
  formulaid?: string;
17
15
  label?: string;
18
16
  linkid?: string;
@@ -0,0 +1,8 @@
1
+ export const DATETIME_COLUMN_FORMAT = [
2
+ 'MM/DD/YYYY HH24:MM:SS',
3
+ 'DD/MM/YYYY HH24:MM:SS',
4
+ 'YYYY-MM-DD HH24:MM:SS',
5
+ 'MM/DD/YYYY HH24:MI:SS',
6
+ 'DD/MM/YYYY HH24:MI:SS',
7
+ 'YYYY-MM-DD HH24:MI:SS'
8
+ ];
@@ -40,3 +40,4 @@ export * from './DATE_YEAR_MONTHS';
40
40
  export * from './DATE_YEAR_MONTHS_MMMM';
41
41
  export * from './DATE_YEAR_QUARTERS';
42
42
  export * from './DATE_YEAR_QUARTERS_RANGE';
43
+ export * from './DATETIME_COLUMN_FORMAT';
@@ -47,7 +47,7 @@ function FD21ToFlatUI(scopes: IFSScope[] = [], datasetsInfo: IDataset[] = []): I
47
47
  dataset.filters.forEach(filter => {
48
48
  const datasetInfo: IDataset = datasetsInfo.find(dInfo => dInfo.qrveyid === dataset.qrveyid && dInfo.linkid === dataset.linkid);
49
49
  let columnInfo: IColumn;
50
- if (!isEmpty(datasetInfo)) columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.dataset?.qrveyid === filter.column.qrveyid && cInfo.dataset?.linkid === filter.column.linkid);
50
+ if (!isEmpty(datasetInfo)) columnInfo = datasetInfo.options.find(cInfo => cInfo.id === filter.column.id && cInfo.qrveyid === filter.column.qrveyid && cInfo.linkid === filter.column.linkid);
51
51
  const info = !isEmpty(filter.extras.info) ? { icon: filter.extras.info.icon, label: filter.extras.info.label } : undefined;
52
52
  const property = adaptDateGroupingProperty(filter.property);
53
53
 
@@ -71,7 +71,7 @@ export function FDToUI(filterData: IFSData, datasetsInfo: IDataset[] = []): IFUD
71
71
  id: filter.column.id,
72
72
  label: columnInfo?.label,
73
73
  linked: columnInfo?.linked,
74
- linkid: columnInfo?.dataset?.linkid || datasetInfo?.linkid,
74
+ linkid: columnInfo?.linkid || datasetInfo?.linkid,
75
75
  outputFormat: _get(datasetInfo, 'outputFormat'),
76
76
  qrveyid: filter.column.qrveyid,
77
77
  type: columnInfo?.type || filter.column.type,
@@ -103,7 +103,7 @@ function getFilterByExpression(expression: OLD_IFilterExpression, scopeItem: OLD
103
103
  enabled: true,
104
104
  displayed: true,
105
105
  qrveyid: uiExtras.column?.qrveyid,
106
- label: _get( uiExtras.column?.dataset, 'name') || uiExtras.column?.dataset?.label,
106
+ label: _get(uiExtras.column, 'dataset.name') || uiExtras.column?.label,
107
107
  linkid: uiExtras.column?.linkid,
108
108
  },
109
109
  },