@thoughtspot/ts-chart-sdk 0.0.1-alpha.9 → 0.0.2-alpha.10

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 (174) hide show
  1. package/dist/ts-chart-sdk.d.ts +449 -31
  2. package/lib/index.d.ts +3 -0
  3. package/lib/index.d.ts.map +1 -1
  4. package/lib/index.js +3 -0
  5. package/lib/index.js.map +1 -1
  6. package/lib/main/custom-chart-context.d.ts +17 -5
  7. package/lib/main/custom-chart-context.d.ts.map +1 -1
  8. package/lib/main/custom-chart-context.js +74 -34
  9. package/lib/main/custom-chart-context.js.map +1 -1
  10. package/lib/main/custom-chart-context.spec.js +256 -257
  11. package/lib/main/custom-chart-context.spec.js.map +1 -1
  12. package/lib/main/post-message-event-bridge.d.ts +3 -3
  13. package/lib/main/post-message-event-bridge.d.ts.map +1 -1
  14. package/lib/main/post-message-event-bridge.js +24 -36
  15. package/lib/main/post-message-event-bridge.js.map +1 -1
  16. package/lib/main/post-message-event-bridge.spec.js +0 -2
  17. package/lib/main/post-message-event-bridge.spec.js.map +1 -1
  18. package/lib/main/util.d.ts +2 -0
  19. package/lib/main/util.d.ts.map +1 -0
  20. package/lib/main/util.js +9 -0
  21. package/lib/main/util.js.map +1 -0
  22. package/lib/react/use-custom-chart-context.spec.js +128 -121
  23. package/lib/react/use-custom-chart-context.spec.js.map +1 -1
  24. package/lib/test/test-conditional-formatting-utils.d.ts +5 -0
  25. package/lib/test/test-conditional-formatting-utils.d.ts.map +1 -0
  26. package/lib/test/test-conditional-formatting-utils.js +43 -0
  27. package/lib/test/test-conditional-formatting-utils.js.map +1 -0
  28. package/lib/types/answer-column.types.d.ts +54 -1
  29. package/lib/types/answer-column.types.d.ts.map +1 -1
  30. package/lib/types/answer-column.types.js +47 -0
  31. package/lib/types/answer-column.types.js.map +1 -1
  32. package/lib/types/common.types.d.ts +51 -4
  33. package/lib/types/common.types.d.ts.map +1 -1
  34. package/lib/types/common.types.js +15 -1
  35. package/lib/types/common.types.js.map +1 -1
  36. package/lib/types/conditional-formatting.types.d.ts +155 -0
  37. package/lib/types/conditional-formatting.types.d.ts.map +1 -0
  38. package/lib/types/conditional-formatting.types.js +60 -0
  39. package/lib/types/conditional-formatting.types.js.map +1 -0
  40. package/lib/types/configurator.types.d.ts +5 -0
  41. package/lib/types/configurator.types.d.ts.map +1 -1
  42. package/lib/types/ts-to-chart-event.types.d.ts +3 -0
  43. package/lib/types/ts-to-chart-event.types.d.ts.map +1 -1
  44. package/lib/types/ts-to-chart-event.types.js.map +1 -1
  45. package/lib/types/visual-prop.types.d.ts +3 -0
  46. package/lib/types/visual-prop.types.d.ts.map +1 -1
  47. package/lib/utils/conditional-formatting/conditional-formatting.d.ts +10 -0
  48. package/lib/utils/conditional-formatting/conditional-formatting.d.ts.map +1 -0
  49. package/lib/utils/conditional-formatting/conditional-formatting.js +103 -0
  50. package/lib/utils/conditional-formatting/conditional-formatting.js.map +1 -0
  51. package/lib/utils/conditional-formatting/conditional-formatting.spec.d.ts +2 -0
  52. package/lib/utils/conditional-formatting/conditional-formatting.spec.d.ts.map +1 -0
  53. package/lib/utils/conditional-formatting/conditional-formatting.spec.js +142 -0
  54. package/lib/utils/conditional-formatting/conditional-formatting.spec.js.map +1 -0
  55. package/lib/utils/date-formatting.d.ts +19 -0
  56. package/lib/utils/date-formatting.d.ts.map +1 -0
  57. package/lib/utils/date-formatting.js +56 -0
  58. package/lib/utils/date-formatting.js.map +1 -0
  59. package/lib/utils/date-formatting.spec.d.ts +2 -0
  60. package/lib/utils/date-formatting.spec.d.ts.map +1 -0
  61. package/lib/utils/date-formatting.spec.js +124 -0
  62. package/lib/utils/date-formatting.spec.js.map +1 -0
  63. package/package.json +10 -7
  64. package/src/index.ts +3 -0
  65. package/src/main/custom-chart-context.spec.ts +291 -266
  66. package/src/main/custom-chart-context.ts +164 -46
  67. package/src/main/post-message-event-bridge.spec.ts +0 -3
  68. package/src/main/post-message-event-bridge.ts +36 -62
  69. package/src/main/util.ts +11 -0
  70. package/src/react/use-custom-chart-context.spec.tsx +149 -122
  71. package/src/test/test-conditional-formatting-utils.ts +95 -0
  72. package/src/types/answer-column.types.ts +98 -0
  73. package/src/types/common.types.ts +82 -10
  74. package/src/types/conditional-formatting.types.ts +172 -0
  75. package/src/types/configurator.types.ts +21 -0
  76. package/src/types/ts-to-chart-event.types.ts +15 -0
  77. package/src/types/visual-prop.types.ts +7 -0
  78. package/src/utils/conditional-formatting/conditional-formatting.spec.ts +469 -0
  79. package/src/utils/conditional-formatting/conditional-formatting.ts +229 -0
  80. package/src/utils/date-formatting.spec.ts +168 -0
  81. package/src/utils/date-formatting.ts +109 -0
  82. package/cjs/index.d.ts +0 -9
  83. package/cjs/index.d.ts.map +0 -1
  84. package/cjs/index.js +0 -25
  85. package/cjs/index.js.map +0 -1
  86. package/cjs/main/custom-chart-context.d.ts +0 -47
  87. package/cjs/main/custom-chart-context.d.ts.map +0 -1
  88. package/cjs/main/custom-chart-context.js +0 -326
  89. package/cjs/main/custom-chart-context.js.map +0 -1
  90. package/cjs/main/custom-chart-context.spec.d.ts +0 -2
  91. package/cjs/main/custom-chart-context.spec.d.ts.map +0 -1
  92. package/cjs/main/custom-chart-context.spec.js +0 -699
  93. package/cjs/main/custom-chart-context.spec.js.map +0 -1
  94. package/cjs/main/post-message-event-bridge.d.ts +0 -6
  95. package/cjs/main/post-message-event-bridge.d.ts.map +0 -1
  96. package/cjs/main/post-message-event-bridge.js +0 -46
  97. package/cjs/main/post-message-event-bridge.js.map +0 -1
  98. package/cjs/main/post-message-event-bridge.spec.d.ts +0 -2
  99. package/cjs/main/post-message-event-bridge.spec.d.ts.map +0 -1
  100. package/cjs/main/post-message-event-bridge.spec.js +0 -124
  101. package/cjs/main/post-message-event-bridge.spec.js.map +0 -1
  102. package/cjs/react/custom-chart-context-service.d.ts +0 -33
  103. package/cjs/react/custom-chart-context-service.d.ts.map +0 -1
  104. package/cjs/react/custom-chart-context-service.js +0 -118
  105. package/cjs/react/custom-chart-context-service.js.map +0 -1
  106. package/cjs/react/custom-chart.context.d.ts +0 -26
  107. package/cjs/react/custom-chart.context.d.ts.map +0 -1
  108. package/cjs/react/custom-chart.context.js +0 -105
  109. package/cjs/react/custom-chart.context.js.map +0 -1
  110. package/cjs/react/custom-chart.spec.d.ts +0 -2
  111. package/cjs/react/custom-chart.spec.d.ts.map +0 -1
  112. package/cjs/react/custom-chart.spec.js +0 -72
  113. package/cjs/react/custom-chart.spec.js.map +0 -1
  114. package/cjs/react/mocks/custom-chart-context-mock.d.ts +0 -3
  115. package/cjs/react/mocks/custom-chart-context-mock.d.ts.map +0 -1
  116. package/cjs/react/mocks/custom-chart-context-mock.js +0 -100
  117. package/cjs/react/mocks/custom-chart-context-mock.js.map +0 -1
  118. package/cjs/react/use-custom-chart-context.d.ts +0 -4
  119. package/cjs/react/use-custom-chart-context.d.ts.map +0 -1
  120. package/cjs/react/use-custom-chart-context.js +0 -95
  121. package/cjs/react/use-custom-chart-context.js.map +0 -1
  122. package/cjs/react/use-custom-chart-context.spec.d.ts +0 -2
  123. package/cjs/react/use-custom-chart-context.spec.d.ts.map +0 -1
  124. package/cjs/react/use-custom-chart-context.spec.js +0 -391
  125. package/cjs/react/use-custom-chart-context.spec.js.map +0 -1
  126. package/cjs/react/use-custom-chart-context.util.d.ts +0 -6
  127. package/cjs/react/use-custom-chart-context.util.d.ts.map +0 -1
  128. package/cjs/react/use-custom-chart-context.util.js +0 -60
  129. package/cjs/react/use-custom-chart-context.util.js.map +0 -1
  130. package/cjs/react/use-custom-chart-types.d.ts +0 -23
  131. package/cjs/react/use-custom-chart-types.d.ts.map +0 -1
  132. package/cjs/react/use-custom-chart-types.js +0 -3
  133. package/cjs/react/use-custom-chart-types.js.map +0 -1
  134. package/cjs/test/test-utils.d.ts +0 -7
  135. package/cjs/test/test-utils.d.ts.map +0 -1
  136. package/cjs/test/test-utils.js +0 -14
  137. package/cjs/test/test-utils.js.map +0 -1
  138. package/cjs/types/answer-column.types.d.ts +0 -69
  139. package/cjs/types/answer-column.types.d.ts.map +0 -1
  140. package/cjs/types/answer-column.types.js +0 -59
  141. package/cjs/types/answer-column.types.js.map +0 -1
  142. package/cjs/types/chart-to-ts-event.types.d.ts +0 -98
  143. package/cjs/types/chart-to-ts-event.types.d.ts.map +0 -1
  144. package/cjs/types/chart-to-ts-event.types.js +0 -32
  145. package/cjs/types/chart-to-ts-event.types.js.map +0 -1
  146. package/cjs/types/common.types.d.ts +0 -51
  147. package/cjs/types/common.types.d.ts.map +0 -1
  148. package/cjs/types/common.types.js +0 -3
  149. package/cjs/types/common.types.js.map +0 -1
  150. package/cjs/types/configurator.types.d.ts +0 -15
  151. package/cjs/types/configurator.types.d.ts.map +0 -1
  152. package/cjs/types/configurator.types.js +0 -3
  153. package/cjs/types/configurator.types.js.map +0 -1
  154. package/cjs/types/ts-to-chart-event.types.d.ts +0 -91
  155. package/cjs/types/ts-to-chart-event.types.d.ts.map +0 -1
  156. package/cjs/types/ts-to-chart-event.types.js +0 -18
  157. package/cjs/types/ts-to-chart-event.types.js.map +0 -1
  158. package/cjs/types/visual-prop.types.d.ts +0 -73
  159. package/cjs/types/visual-prop.types.d.ts.map +0 -1
  160. package/cjs/types/visual-prop.types.js +0 -3
  161. package/cjs/types/visual-prop.types.js.map +0 -1
  162. package/lib/dist/ts-chart-sdk.d.ts +0 -312
  163. package/lib/react/custom-chart-context-service.d.ts +0 -33
  164. package/lib/react/custom-chart-context-service.d.ts.map +0 -1
  165. package/lib/react/custom-chart-context-service.js +0 -91
  166. package/lib/react/custom-chart-context-service.js.map +0 -1
  167. package/lib/react/custom-chart.context.d.ts +0 -26
  168. package/lib/react/custom-chart.context.d.ts.map +0 -1
  169. package/lib/react/custom-chart.context.js +0 -78
  170. package/lib/react/custom-chart.context.js.map +0 -1
  171. package/lib/react/custom-chart.spec.d.ts +0 -2
  172. package/lib/react/custom-chart.spec.d.ts.map +0 -1
  173. package/lib/react/custom-chart.spec.js +0 -67
  174. package/lib/react/custom-chart.spec.js.map +0 -1
@@ -0,0 +1,168 @@
1
+ /**
2
+ * @file: Date Formatting Spec
3
+ *
4
+ * @author Yashvardhan Nehra <yashvardhan.nehra@thoughtspot.com>
5
+ *
6
+ * Copyright: ThoughtSpot Inc. 2023
7
+ */
8
+
9
+ import {
10
+ ChartColumn,
11
+ ChartSpecificColumnType,
12
+ ColumnTimeBucket,
13
+ ColumnType,
14
+ DataType,
15
+ } from '../types/answer-column.types';
16
+ import {
17
+ CustomCalendarDate,
18
+ dateFormatter,
19
+ getCustomCalendarGuidFromColumn,
20
+ getDisplayString,
21
+ getStartEpoch,
22
+ hasCustomCalendar,
23
+ isAttribute,
24
+ isDateColumn,
25
+ isDateFamilyColumn,
26
+ isDateNumColumn,
27
+ isTimeColumn,
28
+ } from './date-formatting';
29
+
30
+ describe('date-formatting', () => {
31
+ let col: ChartColumn;
32
+ beforeEach(() => {
33
+ col = {
34
+ id: 'testId',
35
+ name: 'test',
36
+ type: ColumnType.MEASURE,
37
+ chartSpecificColumnType: ChartSpecificColumnType.UNKNOWN,
38
+ timeBucket: ColumnTimeBucket.AUTO,
39
+ dataType: DataType.UNKNOWN,
40
+ calenderGuid: '12345',
41
+ };
42
+ });
43
+ test('isDateColumn should return true for DATE data type', () => {
44
+ col.dataType = DataType.DATE;
45
+ expect(isDateColumn(col)).toBe(true);
46
+ });
47
+
48
+ test('isDateColumn should return true for DATE_TIME data type', () => {
49
+ col.dataType = DataType.DATE_TIME;
50
+ expect(isDateColumn(col)).toBe(true);
51
+ });
52
+
53
+ test('isAttribute should return true for ATTRIBUTE column type', () => {
54
+ col.type = ColumnType.ATTRIBUTE;
55
+ expect(isAttribute(col)).toBe(true);
56
+ });
57
+
58
+ test('isAttribute should return false for non-ATTRIBUTE column type', () => {
59
+ col.type = ColumnType.MEASURE;
60
+ expect(isAttribute(col)).toBe(false);
61
+ });
62
+
63
+ test('getCustomCalendarGuidFromColumn should return the calendarGuid', () => {
64
+ col.calenderGuid = '12345';
65
+ expect(getCustomCalendarGuidFromColumn(col)).toBe('12345');
66
+ });
67
+
68
+ test('isDateNumColumn should return true for ATTRIBUTE type with specific time buckets', () => {
69
+ col.type = ColumnType.ATTRIBUTE;
70
+ col.timeBucket = ColumnTimeBucket.HOUR_OF_DAY;
71
+ expect(isDateNumColumn(col)).toBe(true);
72
+ });
73
+
74
+ test('isDateNumColumn should return false for non-ATTRIBUTE type', () => {
75
+ col.type = ColumnType.MEASURE;
76
+ col.timeBucket = ColumnTimeBucket.DAY_OF_WEEK;
77
+ expect(isDateNumColumn(col)).toBe(false);
78
+ });
79
+
80
+ test('isDateFamilyColumn should return true for DATE data type', () => {
81
+ col.dataType = DataType.DATE;
82
+ expect(isDateFamilyColumn(col)).toBe(true);
83
+ });
84
+
85
+ test('isDateFamilyColumn should return true for DATE_NUM column', () => {
86
+ col.type = ColumnType.ATTRIBUTE;
87
+ col.timeBucket = ColumnTimeBucket.DAY_OF_WEEK;
88
+ expect(isDateFamilyColumn(col)).toBe(true);
89
+ });
90
+
91
+ test('isTimeColumn should return true for TIME data type', () => {
92
+ col.dataType = DataType.TIME;
93
+ expect(isTimeColumn(col)).toBe(true);
94
+ });
95
+
96
+ test('hasCustomCalendar should return true for date family columns with custom calendar', () => {
97
+ col.dataType = DataType.DATE;
98
+ col.calenderGuid = '12345';
99
+ expect(hasCustomCalendar(col)).toBe(true);
100
+ });
101
+
102
+ test('getStartEpoch should return the start epoch from CustomCalendarDate', () => {
103
+ const date = {
104
+ v: { s: 12345, e: 12346 },
105
+ d: 'Custom_Date',
106
+ } as CustomCalendarDate;
107
+ expect(getStartEpoch(date)).toBe(date.v.s);
108
+ });
109
+
110
+ test('getStartEpoch should return null if start epoch is not present', () => {
111
+ const date = { v: {}, d: '01-07-2021' } as CustomCalendarDate;
112
+ expect(getStartEpoch(date)).toBe(null);
113
+ });
114
+
115
+ test('getDisplayString should return display string if present', () => {
116
+ const date = { v: { s: 1625097600, e: 1625184000 }, d: '01-07-2021' };
117
+ expect(getDisplayString(date)).toBe('01-07-2021');
118
+ });
119
+
120
+ test('getDisplayString should return null if display string is not present', () => {
121
+ const date = {
122
+ v: { s: 1625097600, e: 1625184000 },
123
+ } as CustomCalendarDate;
124
+ expect(getDisplayString(date)).toBe(null);
125
+ });
126
+
127
+ test('dateFormatter should return custom calendar display string if present', () => {
128
+ const dataValue = {
129
+ v: { s: 1625097600, e: 1625184000 },
130
+ d: '01-07-2021',
131
+ } as CustomCalendarDate;
132
+ col.dataType = DataType.DATE;
133
+ col.calenderGuid = '12345';
134
+ expect(dateFormatter(dataValue, col)).toBe('01-07-2021');
135
+ });
136
+
137
+ test('dateFormatter should return formatted date from start epoch if custom calendar display string is not present', () => {
138
+ const dataValue = {
139
+ v: { s: 1625097600, e: 1625184000 },
140
+ } as CustomCalendarDate;
141
+ col.dataType = DataType.DATE;
142
+ col.calenderGuid = '12345';
143
+ expect(dateFormatter(dataValue, col)).toBe('01-07-2021');
144
+ });
145
+
146
+ test('dateFormatter should return null if start epoch is not present', () => {
147
+ const dataValue = { v: { e: 1625184000 } } as CustomCalendarDate;
148
+ col.dataType = DataType.DATE;
149
+ col.calenderGuid = '12345';
150
+ expect(dateFormatter(dataValue, col)).toBe(null);
151
+ });
152
+
153
+ test('dateFormatter should return formatted date for non-custom calendar column', () => {
154
+ const dataValue = 1625097600;
155
+ col.dataType = DataType.DATE;
156
+ col.calenderGuid = undefined;
157
+ expect(dateFormatter(dataValue, col)).toBe('01-07-2021');
158
+ });
159
+ test('dateFormatter should format the date based on custom calendar', () => {
160
+ col.dataType = DataType.DATE;
161
+ col.calenderGuid = '12345';
162
+ const date = {
163
+ v: { s: 12345, e: 12346 },
164
+ d: 'Custom_Date',
165
+ } as CustomCalendarDate;
166
+ expect(dateFormatter(date, col)).toBe(date.d);
167
+ });
168
+ });
@@ -0,0 +1,109 @@
1
+ /**
2
+ * @file: Date Formatting Utils
3
+ *
4
+ * @author Yashvardhan Nehra <yashvardhan.nehra@thoughtspot.com>
5
+ *
6
+ * Copyright: ThoughtSpot Inc. 2023
7
+ */
8
+
9
+ import _ from 'lodash';
10
+ import { DateTime } from 'luxon';
11
+ import {
12
+ ChartColumn,
13
+ ColumnTimeBucket,
14
+ ColumnType,
15
+ DataType,
16
+ } from '../types/answer-column.types';
17
+
18
+ export interface CustomCalendarDate {
19
+ v: {
20
+ s: number;
21
+ e: number;
22
+ };
23
+ d: string;
24
+ }
25
+
26
+ export const isDateColumn = (col: ChartColumn) =>
27
+ DataType[col.dataType] === 'DATE' || DataType[col.dataType] === 'DATE_TIME';
28
+
29
+ export const isAttribute = (col: ChartColumn) =>
30
+ col.type === ColumnType.ATTRIBUTE;
31
+
32
+ export const getCustomCalendarGuidFromColumn = (col: ChartColumn) =>
33
+ col.calenderGuid;
34
+
35
+ const isDateNumTimeBucket = (col: ChartColumn): boolean => {
36
+ return [
37
+ ColumnTimeBucket.HOUR_OF_DAY,
38
+ ColumnTimeBucket.DAY_OF_WEEK,
39
+ ColumnTimeBucket.DAY_OF_MONTH,
40
+ ColumnTimeBucket.DAY_OF_QUARTER,
41
+ ColumnTimeBucket.DAY_OF_YEAR,
42
+ ColumnTimeBucket.WEEK_OF_MONTH,
43
+ ColumnTimeBucket.WEEK_OF_QUARTER,
44
+ ColumnTimeBucket.WEEK_OF_YEAR,
45
+ ColumnTimeBucket.MONTH_OF_QUARTER,
46
+ ColumnTimeBucket.MONTH_OF_YEAR,
47
+ ColumnTimeBucket.QUARTER_OF_YEAR,
48
+ ].includes(col.timeBucket);
49
+ };
50
+ export const isDateNumColumn = (col: ChartColumn): boolean => {
51
+ return isAttribute(col) && isDateNumTimeBucket(col);
52
+ };
53
+
54
+ export const isDateFamilyColumn = (col: ChartColumn): boolean => {
55
+ return isDateColumn(col) || isDateNumColumn(col);
56
+ };
57
+
58
+ export const isTimeColumn = (col: ChartColumn) => {
59
+ return DataType[col.dataType] === 'TIME';
60
+ };
61
+
62
+ /**
63
+ * Determines if the given column has a custom calendar.
64
+ *
65
+ * @param col - The chart column to check.
66
+ * @returns True if the column is a date family column and has a custom calendar GUID, false otherwise.
67
+ */
68
+ export const hasCustomCalendar = (col: ChartColumn): boolean =>
69
+ isDateFamilyColumn(col) && !!getCustomCalendarGuidFromColumn(col);
70
+
71
+ /**
72
+ * Retrieves the start epoch from a custom calendar date.
73
+ *
74
+ * @param date - The custom calendar date object.
75
+ * @returns The start epoch time if present, null otherwise.
76
+ */
77
+ export function getStartEpoch(date: CustomCalendarDate): number | null {
78
+ if (_.has(date, 'v') && _.has(date.v, 's')) {
79
+ return date.v.s;
80
+ }
81
+ return null;
82
+ }
83
+
84
+ export function getDisplayString(date: CustomCalendarDate): string | null {
85
+ if (_.has(date, 'd')) {
86
+ return date.d;
87
+ }
88
+ return null;
89
+ }
90
+
91
+ /**
92
+ * Formats the date value based on the column's properties and custom calendar settings.
93
+ *
94
+ * @param dataValue - The date value to format.
95
+ * @param col - The chart column.
96
+ * @returns The formatted date string.
97
+ */
98
+ export function dateFormatter(dataValue: any, col: ChartColumn) {
99
+ if (hasCustomCalendar(col)) {
100
+ if (getDisplayString(dataValue)) {
101
+ return getDisplayString(dataValue);
102
+ }
103
+ const startEpoch = getStartEpoch(dataValue);
104
+ return startEpoch !== null
105
+ ? DateTime.fromMillis(startEpoch * 1000).toFormat('dd-MM-yyyy')
106
+ : null;
107
+ }
108
+ return DateTime.fromMillis(dataValue * 1000).toFormat('dd-MM-yyyy');
109
+ }
package/cjs/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export * from './types/common.types';
2
- export * from './types/configurator.types';
3
- export * from './types/visual-prop.types';
4
- export * from './types/answer-column.types';
5
- export * from './types/chart-to-ts-event.types';
6
- export * from './types/ts-to-chart-event.types';
7
- export * from './main/custom-chart-context';
8
- export * from './react/use-custom-chart-context';
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC"}
package/cjs/index.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types/common.types"), exports);
18
- __exportStar(require("./types/configurator.types"), exports);
19
- __exportStar(require("./types/visual-prop.types"), exports);
20
- __exportStar(require("./types/answer-column.types"), exports);
21
- __exportStar(require("./types/chart-to-ts-event.types"), exports);
22
- __exportStar(require("./types/ts-to-chart-event.types"), exports);
23
- __exportStar(require("./main/custom-chart-context"), exports);
24
- __exportStar(require("./react/use-custom-chart-context"), exports);
25
- //# sourceMappingURL=index.js.map
package/cjs/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,6DAA2C;AAC3C,4DAA0C;AAC1C,8DAA4C;AAC5C,kEAAgD;AAChD,kEAAgD;AAChD,8DAA4C;AAC5C,mEAAiD"}
@@ -1,47 +0,0 @@
1
- import { ChartToTSEventsPayloadMap, OpenAxisMenuEventPayload, OpenContextMenuEventPayload } from '../types/chart-to-ts-event.types';
2
- import { AppConfig, ChartConfig, ChartModel, ValidationResponse, VisualProps } from '../types/common.types';
3
- import { ChartConfigEditorDefinition } from '../types/configurator.types';
4
- import { Query, TSToChartEventsPayloadMap } from '../types/ts-to-chart-event.types';
5
- import { VisualPropEditorDefinition } from '../types/visual-prop.types';
6
- export type CustomChartContextProps = {
7
- getDefaultChartConfig: (chartModel: ChartModel) => ChartConfig[];
8
- getQueriesFromChartConfig: (chartConfig: ChartConfig[]) => Query[];
9
- renderChart: (ctx: CustomChartContext) => Promise<void>;
10
- validateConfig?: (updatedConfig: ChartConfig[], chartModel: ChartModel) => ValidationResponse;
11
- validateVisualProps?: (updatedVisualProps: VisualProps, chartModel: ChartModel) => ValidationResponse;
12
- chartConfigEditorDefinition?: ChartConfigEditorDefinition[];
13
- visualPropEditorDefinition?: VisualPropEditorDefinition;
14
- };
15
- export declare class CustomChartContext {
16
- private componentId;
17
- private hostUrl;
18
- private chartModel;
19
- private appConfig;
20
- private chartContextProps;
21
- private eventListeners;
22
- private hasInitializedPromise;
23
- private triggerInitResolve;
24
- private contextMenuActionHandler;
25
- private axisMenuActionHandler;
26
- constructor(chartContextProps: CustomChartContextProps);
27
- initialize: () => Promise<void>;
28
- on<T extends keyof TSToChartEventsPayloadMap>(eventType: T, callbackFn: TSToChartEventsPayloadMap[T]): void;
29
- off<T extends keyof TSToChartEventsPayloadMap>(eventType: T): void;
30
- private onInternal;
31
- destroy(): void;
32
- getChartModel: () => ChartModel;
33
- getAppConfig: () => AppConfig;
34
- contextMenuCustomActionPreProcessor(eventPayload: [OpenContextMenuEventPayload]): [OpenContextMenuEventPayload];
35
- axisMenuCustomActionPreProcessor(eventPayload: [OpenAxisMenuEventPayload]): [OpenAxisMenuEventPayload];
36
- private eventPayloadPreProcessor;
37
- emitEvent<T extends keyof ChartToTSEventsPayloadMap>(eventType: T, ...eventPayload: ChartToTSEventsPayloadMap[T]): Promise<any>;
38
- private registerEventProcessor;
39
- private eventProcessor;
40
- private registerEvents;
41
- private initializeContext;
42
- private initializationComplete;
43
- private publishChartContextPropsToHost;
44
- private executeEventListenerCBs;
45
- }
46
- export declare const getChartContext: (customChartConfig: CustomChartContextProps) => Promise<CustomChartContext>;
47
- //# sourceMappingURL=custom-chart-context.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"custom-chart-context.d.ts","sourceRoot":"","sources":["../../src/main/custom-chart-context.ts"],"names":[],"mappings":"AASA,OAAO,EAGH,yBAAyB,EAIzB,wBAAwB,EACxB,2BAA2B,EAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACH,SAAS,EACT,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,WAAW,EACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAUH,KAAK,EAEL,yBAAyB,EAI5B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAKxE,MAAM,MAAM,uBAAuB,GAAG;IAQlC,qBAAqB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,WAAW,EAAE,CAAC;IAQjE,yBAAyB,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,CAAC;IAQnE,WAAW,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAUxD,cAAc,CAAC,EAAE,CACb,aAAa,EAAE,WAAW,EAAE,EAC5B,UAAU,EAAE,UAAU,KACrB,kBAAkB,CAAC;IAWxB,mBAAmB,CAAC,EAAE,CAClB,kBAAkB,EAAE,WAAW,EAC/B,UAAU,EAAE,UAAU,KACrB,kBAAkB,CAAC;IAQxB,2BAA2B,CAAC,EAAE,2BAA2B,EAAE,CAAC;IAW5D,0BAA0B,CAAC,EAAE,0BAA0B,CAAC;CAC3D,CAAC;AAWF,qBAAa,kBAAkB;IAU3B,OAAO,CAAC,WAAW,CAAM;IASzB,OAAO,CAAC,OAAO,CAAM;IAQrB,OAAO,CAAC,UAAU,CAAyB;IAO3C,OAAO,CAAC,SAAS,CAAiB;IAOlC,OAAO,CAAC,iBAAiB,CACkC;IAQ3D,OAAO,CAAC,cAAc,CAAoD;IAW1E,OAAO,CAAC,qBAAqB,CAAgB;IAS7C,OAAO,CAAC,kBAAkB,CAAsB;IAQhD,OAAO,CAAC,wBAAwB,CAAgC;IAQhE,OAAO,CAAC,qBAAqB,CAA6B;gBAO9C,iBAAiB,EAAE,uBAAuB;IAkB/C,UAAU,QAAO,QAAQ,IAAI,CAAC,CAGnC;IAUK,EAAE,CAAC,CAAC,SAAS,MAAM,yBAAyB,EAC/C,SAAS,EAAE,CAAC,EACZ,UAAU,EAAE,yBAAyB,CAAC,CAAC,CAAC,GACzC,IAAI;IAeA,GAAG,CAAC,CAAC,SAAS,MAAM,yBAAyB,EAAE,SAAS,EAAE,CAAC,GAAG,IAAI;IAiBzE,OAAO,CAAC,UAAU;IAgBX,OAAO;IAUP,aAAa,QAAO,UAAU,CAAoB;IAOlD,YAAY,QAAO,SAAS,CAAmB;IAQ/C,mCAAmC,CACtC,YAAY,EAAE,CAAC,2BAA2B,CAAC,GAC5C,CAAC,2BAA2B,CAAC;IAiCzB,gCAAgC,CACnC,YAAY,EAAE,CAAC,wBAAwB,CAAC,GACzC,CAAC,wBAAwB,CAAC;IAiC7B,OAAO,CAAC,wBAAwB;IA0BzB,SAAS,CAAC,CAAC,SAAS,MAAM,yBAAyB,EACtD,SAAS,EAAE,CAAC,EACZ,GAAG,YAAY,EAAE,yBAAyB,CAAC,CAAC,CAAC,GAC9C,OAAO,CAAC,GAAG,CAAC;IAuBf,OAAO,CAAC,sBAAsB,CAU5B;IAOF,OAAO,CAAC,cAAc,CAuBpB;IAOF,OAAO,CAAC,cAAc,CAqOpB;IASF,OAAO,CAAC,iBAAiB,CASvB;IAEF,OAAO,CAAC,sBAAsB,CAM5B;IAEF,OAAO,CAAC,8BAA8B,CA6BhC;IAQN,OAAO,CAAC,uBAAuB,CAyB7B;CACL;AAQD,eAAO,MAAM,eAAe,sBACL,uBAAuB,KAC3C,QAAQ,kBAAkB,CAO5B,CAAC"}