@thoughtspot/ts-chart-sdk 0.0.2-alpha.2 → 0.0.2-alpha.21
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/README.md +126 -50
- package/dist/ts-chart-sdk.d.ts +940 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -1
- package/lib/main/custom-chart-context.d.ts +22 -7
- package/lib/main/custom-chart-context.d.ts.map +1 -1
- package/lib/main/custom-chart-context.js +59 -4
- package/lib/main/custom-chart-context.js.map +1 -1
- package/lib/main/custom-chart-context.spec.js +402 -5
- package/lib/main/custom-chart-context.spec.js.map +1 -1
- package/lib/main/post-message-event-bridge.js +2 -2
- package/lib/main/post-message-event-bridge.js.map +1 -1
- package/lib/main/util.spec.d.ts +2 -0
- package/lib/main/util.spec.d.ts.map +1 -0
- package/lib/main/util.spec.js +31 -0
- package/lib/main/util.spec.js.map +1 -0
- package/lib/react/use-custom-chart-context.spec.js +54 -3
- package/lib/react/use-custom-chart-context.spec.js.map +1 -1
- package/lib/test/test-conditional-formatting-utils.d.ts +5 -0
- package/lib/test/test-conditional-formatting-utils.d.ts.map +1 -0
- package/lib/test/test-conditional-formatting-utils.js +43 -0
- package/lib/test/test-conditional-formatting-utils.js.map +1 -0
- package/lib/types/answer-column.types.d.ts +57 -1
- package/lib/types/answer-column.types.d.ts.map +1 -1
- package/lib/types/answer-column.types.js +47 -0
- package/lib/types/answer-column.types.js.map +1 -1
- package/lib/types/chart-to-ts-event.types.d.ts +2 -0
- package/lib/types/chart-to-ts-event.types.d.ts.map +1 -1
- package/lib/types/chart-to-ts-event.types.js +1 -0
- package/lib/types/chart-to-ts-event.types.js.map +1 -1
- package/lib/types/common.types.d.ts +103 -4
- package/lib/types/common.types.d.ts.map +1 -1
- package/lib/types/common.types.js +15 -1
- package/lib/types/common.types.js.map +1 -1
- package/lib/types/conditional-formatting.types.d.ts +140 -0
- package/lib/types/conditional-formatting.types.d.ts.map +1 -0
- package/lib/types/conditional-formatting.types.js +60 -0
- package/lib/types/conditional-formatting.types.js.map +1 -0
- package/lib/types/configurator.types.d.ts +5 -0
- package/lib/types/configurator.types.d.ts.map +1 -1
- package/lib/types/number-formatting.types.d.ts +55 -0
- package/lib/types/number-formatting.types.d.ts.map +1 -0
- package/lib/types/number-formatting.types.js +23 -0
- package/lib/types/number-formatting.types.js.map +1 -0
- package/lib/types/ts-to-chart-event.types.d.ts +10 -5
- package/lib/types/ts-to-chart-event.types.d.ts.map +1 -1
- package/lib/types/ts-to-chart-event.types.js.map +1 -1
- package/lib/types/visual-prop.types.d.ts +21 -0
- package/lib/types/visual-prop.types.d.ts.map +1 -1
- package/lib/utils/conditional-formatting/conditional-formatting.d.ts +10 -0
- package/lib/utils/conditional-formatting/conditional-formatting.d.ts.map +1 -0
- package/lib/utils/conditional-formatting/conditional-formatting.js +103 -0
- package/lib/utils/conditional-formatting/conditional-formatting.js.map +1 -0
- package/lib/utils/conditional-formatting/conditional-formatting.spec.d.ts +2 -0
- package/lib/utils/conditional-formatting/conditional-formatting.spec.d.ts.map +1 -0
- package/lib/utils/conditional-formatting/conditional-formatting.spec.js +142 -0
- package/lib/utils/conditional-formatting/conditional-formatting.spec.js.map +1 -0
- package/lib/utils/date-formatting.d.ts +103 -0
- package/lib/utils/date-formatting.d.ts.map +1 -0
- package/lib/utils/date-formatting.js +389 -0
- package/lib/utils/date-formatting.js.map +1 -0
- package/lib/utils/date-formatting.spec.d.ts +2 -0
- package/lib/utils/date-formatting.spec.d.ts.map +1 -0
- package/lib/utils/date-formatting.spec.js +394 -0
- package/lib/utils/date-formatting.spec.js.map +1 -0
- package/lib/utils/date-utils.d.ts +6 -0
- package/lib/utils/date-utils.d.ts.map +1 -0
- package/lib/utils/date-utils.js +20 -0
- package/lib/utils/date-utils.js.map +1 -0
- package/lib/utils/date-utils.spec.d.ts +2 -0
- package/lib/utils/date-utils.spec.d.ts.map +1 -0
- package/lib/utils/date-utils.spec.js +63 -0
- package/lib/utils/date-utils.spec.js.map +1 -0
- package/lib/utils/formatting-util.d.ts +10 -0
- package/lib/utils/formatting-util.d.ts.map +1 -0
- package/lib/utils/formatting-util.js +78 -0
- package/lib/utils/formatting-util.js.map +1 -0
- package/lib/utils/formatting-util.spec.d.ts +2 -0
- package/lib/utils/formatting-util.spec.d.ts.map +1 -0
- package/lib/utils/formatting-util.spec.js +247 -0
- package/lib/utils/formatting-util.spec.js.map +1 -0
- package/package.json +6 -4
- package/src/index.ts +4 -0
- package/src/main/custom-chart-context.spec.ts +474 -9
- package/src/main/custom-chart-context.ts +246 -12
- package/src/main/post-message-event-bridge.ts +1 -1
- package/src/main/util.spec.ts +41 -0
- package/src/react/use-custom-chart-context.spec.tsx +65 -3
- package/src/test/test-conditional-formatting-utils.ts +95 -0
- package/src/types/answer-column.types.ts +102 -1
- package/src/types/chart-to-ts-event.types.ts +7 -0
- package/src/types/common.types.ts +165 -10
- package/src/types/conditional-formatting.types.ts +157 -0
- package/src/types/configurator.types.ts +21 -0
- package/src/types/number-formatting.types.ts +80 -0
- package/src/types/ts-to-chart-event.types.ts +38 -6
- package/src/types/visual-prop.types.ts +75 -1
- package/src/utils/conditional-formatting/conditional-formatting.spec.ts +469 -0
- package/src/utils/conditional-formatting/conditional-formatting.ts +229 -0
- package/src/utils/date-formatting.spec.ts +511 -0
- package/src/utils/date-formatting.ts +679 -0
- package/src/utils/date-utils.spec.ts +93 -0
- package/src/utils/date-utils.ts +69 -0
- package/src/utils/formatting-util.spec.ts +312 -0
- package/src/utils/formatting-util.ts +234 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
import { dateFormatPresets, formatDate, formatDateNum, getCustomCalendarGuidFromColumn, getCustomCalendarValueFromEpoch, getDisplayString, getEffectiveDateNumDataType, hasCustomCalendar, isDateColumn, isDateNumColumn, isDateTimeColumn, } from './date-formatting';
|
|
3
|
+
import { getCustomCalendarGuid, getFormatPatternForBucket, showDateFinancialYearFormat, } from './date-utils';
|
|
4
|
+
const getBucketization = (col) => col.timeBucket;
|
|
5
|
+
export const getFormatPattern = (col) => { var _a; return getFormatPatternForBucket(getBucketization(col)) || ((_a = col.format) === null || _a === void 0 ? void 0 : _a.pattern); };
|
|
6
|
+
export function getBaseTypeFormatterInstance(col, options) {
|
|
7
|
+
let formatPattern = getFormatPattern(col);
|
|
8
|
+
if (isDateColumn(col)) {
|
|
9
|
+
const showFinancialFormat = showDateFinancialYearFormat(col);
|
|
10
|
+
const isDateTime = isDateTimeColumn(col);
|
|
11
|
+
if (!formatPattern) {
|
|
12
|
+
if (isDateTime) {
|
|
13
|
+
if (options.isMillisIncluded) {
|
|
14
|
+
formatPattern =
|
|
15
|
+
dateFormatPresets.DATETIME_SHORT_WITH_MILLIS;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
formatPattern =
|
|
19
|
+
dateFormatPresets.DATETIME_SHORT_WITH_SECONDS;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return (dataValue, options) => {
|
|
24
|
+
const customCalendarValueFromEpoch = getCustomCalendarValueFromEpoch(col, dataValue, options === null || options === void 0 ? void 0 : options.displayToCustomCalendarValueMap);
|
|
25
|
+
const customCalendarDisplayStr = getDisplayString(customCalendarValueFromEpoch);
|
|
26
|
+
if (customCalendarDisplayStr) {
|
|
27
|
+
return customCalendarDisplayStr;
|
|
28
|
+
}
|
|
29
|
+
const customCalendarOverridesFiscalOffset = hasCustomCalendar(col) &&
|
|
30
|
+
getCustomCalendarGuidFromColumn(col) !==
|
|
31
|
+
getCustomCalendarGuid('fiscal', options.defaultDataSourceId, options.tsDefinedCustomCalenders);
|
|
32
|
+
const optionsWithFiscalOffset = {
|
|
33
|
+
...options,
|
|
34
|
+
customCalendarOverridesFiscalOffset: !!customCalendarOverridesFiscalOffset,
|
|
35
|
+
};
|
|
36
|
+
return formatDate(dataValue, formatPattern, !showFinancialFormat, optionsWithFiscalOffset);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (isDateNumColumn(col)) {
|
|
40
|
+
return (dataValue, options) => {
|
|
41
|
+
const customCalendarValueFromEpoch = getCustomCalendarValueFromEpoch(col, dataValue, options === null || options === void 0 ? void 0 : options.displayToCustomCalendarValueMap);
|
|
42
|
+
const customCalendarDisplayStr = getDisplayString(customCalendarValueFromEpoch);
|
|
43
|
+
if (customCalendarValueFromEpoch && customCalendarDisplayStr) {
|
|
44
|
+
return customCalendarDisplayStr;
|
|
45
|
+
}
|
|
46
|
+
return formatDateNum(getEffectiveDateNumDataType(col), dataValue, formatPattern, options);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return (dataValue) => {
|
|
50
|
+
return dataValue;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export const getDataFormatter = (col, options, aggrTypeOverride) => {
|
|
54
|
+
return getBaseTypeFormatterInstance(col, options);
|
|
55
|
+
};
|
|
56
|
+
export const generateMapOptions = (appConfig, col, data) => {
|
|
57
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
58
|
+
let customCalenderMap = {};
|
|
59
|
+
if (!_.isEmpty(getCustomCalendarGuidFromColumn(col))) {
|
|
60
|
+
customCalenderMap = data.reduce((customCalenderMapAcc, dataValue) => {
|
|
61
|
+
return {
|
|
62
|
+
...customCalenderMapAcc,
|
|
63
|
+
[dataValue.v.s]: dataValue,
|
|
64
|
+
};
|
|
65
|
+
}, {});
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
locale: (_a = appConfig === null || appConfig === void 0 ? void 0 : appConfig.localeOptions) === null || _a === void 0 ? void 0 : _a.locale,
|
|
69
|
+
quarterStartMonth: (_b = appConfig === null || appConfig === void 0 ? void 0 : appConfig.localeOptions) === null || _b === void 0 ? void 0 : _b.quarterStartMonth,
|
|
70
|
+
tsLocaleBasedDateFormats: (_c = appConfig === null || appConfig === void 0 ? void 0 : appConfig.dateFormatsConfig) === null || _c === void 0 ? void 0 : _c.tsLocaleBasedDateFormats,
|
|
71
|
+
tsLocaleBasedStringsFormats: (_d = appConfig === null || appConfig === void 0 ? void 0 : appConfig.dateFormatsConfig) === null || _d === void 0 ? void 0 : _d.tsLocaleBasedStringsFormats,
|
|
72
|
+
tsDateConstants: (_e = appConfig === null || appConfig === void 0 ? void 0 : appConfig.dateFormatsConfig) === null || _e === void 0 ? void 0 : _e.tsDateConstants,
|
|
73
|
+
tsDefinedCustomCalenders: (_f = appConfig === null || appConfig === void 0 ? void 0 : appConfig.dateFormatsConfig) === null || _f === void 0 ? void 0 : _f.tsDefinedCustomCalenders,
|
|
74
|
+
defaultDataSourceId: (_g = appConfig === null || appConfig === void 0 ? void 0 : appConfig.dateFormatsConfig) === null || _g === void 0 ? void 0 : _g.defaultDataSourceId,
|
|
75
|
+
displayToCustomCalendarValueMap: customCalenderMap,
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=formatting-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting-util.js","sourceRoot":"","sources":["../../src/utils/formatting-util.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AASvB,OAAO,EAEH,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,+BAA+B,EAC/B,+BAA+B,EAC/B,gBAAgB,EAChB,2BAA2B,EAC3B,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,gBAAgB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EACzB,2BAA2B,GAC9B,MAAM,cAAc,CAAC;AAMtB,MAAM,gBAAgB,GAAG,CAAC,GAAgB,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC;AAW9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAgB,EAAU,EAAE,WACzD,OAAA,yBAAyB,CAAC,gBAAgB,CAAC,G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,aAAT,SAAS,uBAAT,SAAS,CAAE,aAAa,0CAAE,MAAM;QACxC,iBAAiB,EAAE,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,aAAa,0CAAE,iBAAiB;QAC9D,wBAAwB,EACpB,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,iBAAiB,0CAAE,wBAAwB;QAC1D,2BAA2B,EACvB,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,iBAAiB,0CAAE,2BAA2B;QAC7D,eAAe,EAAE,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,iBAAiB,0CAAE,eAAe;QAC9D,wBAAwB,EACpB,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,iBAAiB,0CAAE,wBAAwB;QAC1D,mBAAmB,EAAE,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,iBAAiB,0CAAE,mBAAmB;QACtE,+BAA+B,EAAE,iBAAiB;KACrD,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting-util.spec.d.ts","sourceRoot":"","sources":["../../src/utils/formatting-util.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { ChartSpecificColumnType, ColumnTimeBucket, ColumnType, DataType, } from '../types/answer-column.types';
|
|
2
|
+
import * as DateFormatting from './date-formatting';
|
|
3
|
+
import { getFormatPatternForBucket, showDateFinancialYearFormat, } from './date-utils';
|
|
4
|
+
import { generateMapOptions, getBaseTypeFormatterInstance, getDataFormatter, getFormatPattern, } from './formatting-util';
|
|
5
|
+
jest.mock('./date-utils', () => ({
|
|
6
|
+
getFormatPatternForBucket: jest.fn(),
|
|
7
|
+
showDateFinancialYearFormat: jest.fn(),
|
|
8
|
+
getCustomCalendarGuid: jest
|
|
9
|
+
.fn()
|
|
10
|
+
.mockReturnValue('7573c08b-753b-478b-84fd-6e702d481ff6'),
|
|
11
|
+
}));
|
|
12
|
+
describe('formatting utils', () => {
|
|
13
|
+
const mockOptions = {
|
|
14
|
+
quarterStartMonth: 1,
|
|
15
|
+
tsLocaleBasedStringsFormats: {
|
|
16
|
+
null_value_placeholder_label: '{Null}',
|
|
17
|
+
empty_value_placeholder_label: '{Empty}',
|
|
18
|
+
other_value_placeholder_label: '{Other}',
|
|
19
|
+
unavailabe_column_sample_value: '{Unavailable}',
|
|
20
|
+
weekOfDay: {
|
|
21
|
+
Friday: 'Friday',
|
|
22
|
+
Monday: 'Monday',
|
|
23
|
+
Saturday: 'Saturday',
|
|
24
|
+
Sunday: 'Sunday',
|
|
25
|
+
Thursday: 'Thursday',
|
|
26
|
+
Tuesday: 'Tuesday',
|
|
27
|
+
Wednesday: 'Wednesday',
|
|
28
|
+
},
|
|
29
|
+
monthOfYear: {
|
|
30
|
+
April: 'April',
|
|
31
|
+
August: 'August',
|
|
32
|
+
December: 'December',
|
|
33
|
+
February: 'February',
|
|
34
|
+
January: 'January',
|
|
35
|
+
July: 'July',
|
|
36
|
+
June: 'June',
|
|
37
|
+
March: 'March',
|
|
38
|
+
May: 'May',
|
|
39
|
+
November: 'November',
|
|
40
|
+
October: 'October',
|
|
41
|
+
September: 'September',
|
|
42
|
+
},
|
|
43
|
+
quarter_of_year: 'Q{1}',
|
|
44
|
+
},
|
|
45
|
+
tsDateConstants: {
|
|
46
|
+
day_in_month_format: 'e',
|
|
47
|
+
day_in_quarter_format: 'e',
|
|
48
|
+
day_in_year_format: 'j',
|
|
49
|
+
day_of_week_format: 'e',
|
|
50
|
+
month_in_quarter_format: 'm',
|
|
51
|
+
month_in_year_format: 'm',
|
|
52
|
+
special_value_unavailable: 'N/A',
|
|
53
|
+
week_in_year_format: 'V',
|
|
54
|
+
},
|
|
55
|
+
tsLocaleBasedDateFormats: {
|
|
56
|
+
DATE_SHORT: 'y',
|
|
57
|
+
},
|
|
58
|
+
quarter_of_year: 'Q{1}',
|
|
59
|
+
tsDefinedCustomCalenders: {
|
|
60
|
+
'43121d86-347a-4dbb-bea8-5e5bb899e427': {
|
|
61
|
+
calendar: '7573c08b-753b-478b-84fd-6e702d481ff6',
|
|
62
|
+
fiscal: 'bfa39848-ba4f-46d8-80fd-b695064e61b7',
|
|
63
|
+
french: 'a7316e8d-d4dd-4eaf-9294-396db951b422',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
displayToCustomCalendarValueMap: {
|
|
67
|
+
'1234567891': {
|
|
68
|
+
v: {
|
|
69
|
+
s: 'start',
|
|
70
|
+
e: 'end',
|
|
71
|
+
},
|
|
72
|
+
d: 'custom Date',
|
|
73
|
+
},
|
|
74
|
+
'1234567892': {
|
|
75
|
+
v: {
|
|
76
|
+
s: '1234567890',
|
|
77
|
+
e: 'end',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
test('getFormatPattern should call getFormatPatternForBucket with bucket and return pattern', () => {
|
|
83
|
+
const column = {
|
|
84
|
+
id: 'testId',
|
|
85
|
+
name: 'test',
|
|
86
|
+
type: ColumnType.MEASURE,
|
|
87
|
+
chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
|
|
88
|
+
timeBucket: ColumnTimeBucket.YEARLY,
|
|
89
|
+
dataType: DataType.DATE,
|
|
90
|
+
calenderGuid: '12345',
|
|
91
|
+
};
|
|
92
|
+
expect(getFormatPattern(column)).toBe(undefined);
|
|
93
|
+
expect(getFormatPatternForBucket).toHaveBeenCalledWith(column.timeBucket);
|
|
94
|
+
});
|
|
95
|
+
test('should return date formatter if column is date', () => {
|
|
96
|
+
const column = {
|
|
97
|
+
id: 'testId',
|
|
98
|
+
name: 'test',
|
|
99
|
+
type: ColumnType.MEASURE,
|
|
100
|
+
chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
|
|
101
|
+
timeBucket: ColumnTimeBucket.YEARLY,
|
|
102
|
+
dataType: DataType.DATE,
|
|
103
|
+
calenderGuid: '12345',
|
|
104
|
+
};
|
|
105
|
+
const options = { isMillisIncluded: true };
|
|
106
|
+
const formatter = getBaseTypeFormatterInstance(column, options);
|
|
107
|
+
expect(typeof formatter).toBe('function');
|
|
108
|
+
const formattedDate = formatter(1234567890, mockOptions);
|
|
109
|
+
expect(formattedDate).toBe('2009');
|
|
110
|
+
const customFormattedDate = formatter(1234567891, mockOptions);
|
|
111
|
+
const customFormattedDateWithoutDisplayValue = formatter(1234567892, mockOptions);
|
|
112
|
+
expect(customFormattedDateWithoutDisplayValue).toBe('2009');
|
|
113
|
+
expect(customFormattedDate).toBe('custom Date');
|
|
114
|
+
expect(showDateFinancialYearFormat).toHaveBeenCalledWith(column);
|
|
115
|
+
});
|
|
116
|
+
test('should return dateNum formatter if column is dateNum', () => {
|
|
117
|
+
const column = {
|
|
118
|
+
id: 'testId',
|
|
119
|
+
name: 'test',
|
|
120
|
+
type: ColumnType.ATTRIBUTE,
|
|
121
|
+
chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
|
|
122
|
+
timeBucket: ColumnTimeBucket.HOUR_OF_DAY,
|
|
123
|
+
dataType: DataType.INT64,
|
|
124
|
+
calenderGuid: '12345',
|
|
125
|
+
};
|
|
126
|
+
const options = { isMillisIncluded: true };
|
|
127
|
+
const formatter = getBaseTypeFormatterInstance(column, options);
|
|
128
|
+
expect(typeof formatter).toBe('function');
|
|
129
|
+
const formattedDate = formatter(1234567890, mockOptions);
|
|
130
|
+
expect(formattedDate).toBe(1234567890);
|
|
131
|
+
const customFormattedDate = formatter(1234567891, mockOptions);
|
|
132
|
+
const customFormattedDateWithoutDisplayValue = formatter(1234567892, mockOptions);
|
|
133
|
+
expect(customFormattedDateWithoutDisplayValue).toBe(1234567892);
|
|
134
|
+
expect(customFormattedDate).toBe('custom Date');
|
|
135
|
+
});
|
|
136
|
+
test('should return a default formatter for non-date types', () => {
|
|
137
|
+
const column = {
|
|
138
|
+
id: 'testId',
|
|
139
|
+
name: 'test',
|
|
140
|
+
type: ColumnType.MEASURE,
|
|
141
|
+
chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
|
|
142
|
+
timeBucket: ColumnTimeBucket.HOUR_OF_DAY,
|
|
143
|
+
dataType: DataType.INT64,
|
|
144
|
+
calenderGuid: '12345',
|
|
145
|
+
};
|
|
146
|
+
const options = { isMillisIncluded: true };
|
|
147
|
+
const formatter = getBaseTypeFormatterInstance(column, options);
|
|
148
|
+
expect(formatter('test')).toBe('test');
|
|
149
|
+
});
|
|
150
|
+
test('getDataFormatter should return appropriate formatter based on column type', () => {
|
|
151
|
+
const column = {
|
|
152
|
+
id: 'testId',
|
|
153
|
+
name: 'test',
|
|
154
|
+
type: ColumnType.ATTRIBUTE,
|
|
155
|
+
chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
|
|
156
|
+
timeBucket: ColumnTimeBucket.YEARLY,
|
|
157
|
+
dataType: DataType.DATE,
|
|
158
|
+
calenderGuid: '12345',
|
|
159
|
+
};
|
|
160
|
+
const options = { isMillisIncluded: true };
|
|
161
|
+
const formatter = getDataFormatter(column, options);
|
|
162
|
+
expect(typeof formatter).toBe('function');
|
|
163
|
+
const formattedDate = formatter(1234567890, mockOptions);
|
|
164
|
+
expect(formattedDate).toBe('2009');
|
|
165
|
+
const customFormattedDate = formatter(1234567891, mockOptions);
|
|
166
|
+
const customFormattedDateWithoutDisplayValue = formatter(1234567892, mockOptions);
|
|
167
|
+
expect(customFormattedDateWithoutDisplayValue).toBe('2009');
|
|
168
|
+
expect(customFormattedDate).toBe('custom Date');
|
|
169
|
+
expect(showDateFinancialYearFormat).toHaveBeenCalledWith(column);
|
|
170
|
+
});
|
|
171
|
+
test('generateMapOptions should return map options based on appConfig and column', () => {
|
|
172
|
+
const column = {
|
|
173
|
+
id: 'testId',
|
|
174
|
+
name: 'test',
|
|
175
|
+
type: ColumnType.ATTRIBUTE,
|
|
176
|
+
chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
|
|
177
|
+
timeBucket: ColumnTimeBucket.YEARLY,
|
|
178
|
+
dataType: DataType.DATE,
|
|
179
|
+
calenderGuid: '12345',
|
|
180
|
+
};
|
|
181
|
+
const appConfig = {
|
|
182
|
+
localeOptions: { locale: 'en-US', quarterStartMonth: 1 },
|
|
183
|
+
dateFormatsConfig: {
|
|
184
|
+
tsLocaleBasedDateFormats: 'MM-DD-YYYY',
|
|
185
|
+
tsLocaleBasedStringsFormats: 'YYYY/MM/DD',
|
|
186
|
+
tsDateConstants: {},
|
|
187
|
+
tsDefinedCustomCalenders: {},
|
|
188
|
+
DEFAULT_DATASOURCE_ID: 'source1',
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
const data = [{ v: { s: 'key1' } }, { v: { s: 'key2' } }];
|
|
192
|
+
const mapOptions = generateMapOptions(appConfig, column, data);
|
|
193
|
+
expect(mapOptions.locale).toBe('en-US');
|
|
194
|
+
expect(mapOptions.quarterStartMonth).toBe(1);
|
|
195
|
+
expect(mapOptions.displayToCustomCalendarValueMap).toEqual({
|
|
196
|
+
key1: data[0],
|
|
197
|
+
key2: data[1],
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
test('should have format pattern as DATETIME_SHORT_WITH_MILLIS when format pattern is null', () => {
|
|
201
|
+
const column = {
|
|
202
|
+
id: 'testId',
|
|
203
|
+
name: 'test',
|
|
204
|
+
type: ColumnType.VIRTUAL,
|
|
205
|
+
chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
|
|
206
|
+
timeBucket: ColumnTimeBucket.MONTHLY,
|
|
207
|
+
dataType: DataType.DATE_TIME,
|
|
208
|
+
calenderGuid: '12345',
|
|
209
|
+
};
|
|
210
|
+
const options = { isMillisIncluded: true };
|
|
211
|
+
const formatter = getBaseTypeFormatterInstance(column, options);
|
|
212
|
+
expect(typeof formatter).toBe('function');
|
|
213
|
+
});
|
|
214
|
+
test('should correctly set format pattern for date-time column with and without milliseconds', () => {
|
|
215
|
+
jest.spyOn(DateFormatting, 'formatDate').mockImplementation(jest.fn());
|
|
216
|
+
const column = {
|
|
217
|
+
id: 'testId',
|
|
218
|
+
name: 'test',
|
|
219
|
+
type: ColumnType.MEASURE,
|
|
220
|
+
chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
|
|
221
|
+
timeBucket: ColumnTimeBucket.MONTHLY,
|
|
222
|
+
dataType: DataType.DATE_TIME,
|
|
223
|
+
calenderGuid: '12345',
|
|
224
|
+
};
|
|
225
|
+
const optionsWithMillis = { isMillisIncluded: true };
|
|
226
|
+
const optionsWithoutMillis = { isMillisIncluded: false };
|
|
227
|
+
const formatterWithMillis = getBaseTypeFormatterInstance(column, optionsWithMillis);
|
|
228
|
+
const formatterWithoutMillis = getBaseTypeFormatterInstance(column, optionsWithoutMillis);
|
|
229
|
+
expect(typeof formatterWithMillis).toBe('function');
|
|
230
|
+
expect(typeof formatterWithoutMillis).toBe('function');
|
|
231
|
+
const dateFormatPresetsMock = {
|
|
232
|
+
DATETIME_SHORT_WITH_MILLIS: 'DATETIME_SHORT_WITH_MILLIS',
|
|
233
|
+
DATETIME_SHORT_WITH_SECONDS: 'DATETIME_SHORT_WITH_SECONDS',
|
|
234
|
+
};
|
|
235
|
+
const formattedDateWithMillis = formatterWithMillis(1234567890, mockOptions);
|
|
236
|
+
expect(DateFormatting.formatDate).toHaveBeenCalledWith(1234567890, dateFormatPresetsMock.DATETIME_SHORT_WITH_MILLIS, true, {
|
|
237
|
+
...mockOptions,
|
|
238
|
+
customCalendarOverridesFiscalOffset: true,
|
|
239
|
+
});
|
|
240
|
+
const formattedDateWithoutMillis = formatterWithoutMillis(1234567890, mockOptions);
|
|
241
|
+
expect(DateFormatting.formatDate).toHaveBeenCalledWith(1234567890, dateFormatPresetsMock.DATETIME_SHORT_WITH_SECONDS, true, {
|
|
242
|
+
...mockOptions,
|
|
243
|
+
customCalendarOverridesFiscalOffset: true,
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
//# sourceMappingURL=formatting-util.spec.js.map
|
|
@@ -0,0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AAC;QACpD,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAGvD,MAAM,qBAAqB,GAAG;YAC1B,0BAA0B,EAAE,4BAA4B;YACxD,2BAA2B,EAAE,6BAA6B;SAC7D,CAAC;QAGF,MAAM,uBAAuB,GAAG,mBAAmB,CAC/C,UAAU,EACV,WAAW,CACd,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAClD,UAAU,EACV,qBAAqB,CAAC,0BAA0B,EAChD,IAAI,EACJ;YACI,GAAG,WAAW;YACd,mCAAmC,EAAE,IAAI;SAC5C,CACJ,CAAC;QACF,MAAM,0BAA0B,GAAG,sBAAsB,CACrD,UAAU,EACV,WAAW,CACd,CAAC;QACF,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAClD,UAAU,EACV,qBAAqB,CAAC,2BAA2B,EACjD,IAAI,EACJ;YACI,GAAG,WAAW;YACd,mCAAmC,EAAE,IAAI;SAC5C,CACJ,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtspot/ts-chart-sdk",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.0.2-alpha.
|
|
4
|
+
"version": "0.0.2-alpha.21",
|
|
5
5
|
"module": "lib/index",
|
|
6
6
|
"main": "lib/index",
|
|
7
7
|
"types": "lib/index",
|
|
@@ -23,26 +23,27 @@
|
|
|
23
23
|
"dev:bar": "vite serve example/custom-bar-chart --port 3000",
|
|
24
24
|
"about:bundle-dts": "echo '===== add ts types bundle in dist ====='",
|
|
25
25
|
"bundle-dts": "npx dts-bundle --name ../dist/ts-chart-sdk --main lib/index.d.ts --outputAsModuleFolder=true",
|
|
26
|
-
"
|
|
26
|
+
"prepublishOnly": "npm run ci; npm run build; npm run bundle-dts;",
|
|
27
27
|
"about:publish-dev": "echo '===== patch dev workflow ====='",
|
|
28
28
|
"patch-dev": "npm version prerelease --no-git-tag-version",
|
|
29
29
|
"publish-dev": "npm publish --tag dev --access public",
|
|
30
30
|
"about:publish-prod": "echo '===== patch prod workflow ====='",
|
|
31
31
|
"patch-prod": "npm version prepatch --no-git-tag-version",
|
|
32
|
-
"publish-prod": "npm publish --access public"
|
|
32
|
+
"publish-prod": "npm publish --tag latest --access public"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@testing-library/react": "12.1.5",
|
|
36
36
|
"@testing-library/react-hooks": "^7.0.2",
|
|
37
37
|
"@types/jest": "^27.0.3",
|
|
38
38
|
"@types/lodash": "4.14.175",
|
|
39
|
+
"@types/luxon": "^3.4.2",
|
|
39
40
|
"@types/node": "18.16.3",
|
|
40
41
|
"@types/react": "^17.0.2",
|
|
41
42
|
"@types/react-dom": "^17.0.11",
|
|
42
43
|
"@typescript-eslint/eslint-plugin": "^5.59.5",
|
|
43
44
|
"@typescript-eslint/parser": "^5.59.5",
|
|
44
45
|
"dts-bundle": "^0.7.3",
|
|
45
|
-
"eslint": "
|
|
46
|
+
"eslint": "^8.56.0",
|
|
46
47
|
"eslint-config-airbnb-base": "15.0.0",
|
|
47
48
|
"eslint-config-prettier": "^6.9.0",
|
|
48
49
|
"eslint-import-resolver-typescript": "^2.0.0",
|
|
@@ -74,6 +75,7 @@
|
|
|
74
75
|
},
|
|
75
76
|
"dependencies": {
|
|
76
77
|
"lodash": "^4.17.21",
|
|
78
|
+
"luxon": "^3.4.4",
|
|
77
79
|
"promise-postmessage": "^3.5.0",
|
|
78
80
|
"react": "^17.0.2",
|
|
79
81
|
"react-dom": "^17.0.2"
|
package/src/index.ts
CHANGED
|
@@ -6,3 +6,7 @@ export * from './types/chart-to-ts-event.types';
|
|
|
6
6
|
export * from './types/ts-to-chart-event.types';
|
|
7
7
|
export * from './main/custom-chart-context';
|
|
8
8
|
export * from './react/use-custom-chart-context';
|
|
9
|
+
export * from './types/conditional-formatting.types';
|
|
10
|
+
export * from './types/number-formatting.types';
|
|
11
|
+
export * from './utils/date-formatting';
|
|
12
|
+
export * from './utils/conditional-formatting/conditional-formatting';
|