@thoughtspot/ts-chart-sdk 2.7.6 → 2.7.7
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/ts-chart-sdk.d.ts +1 -0
- package/lib/react/use-custom-chart-context.d.ts.map +1 -1
- package/lib/react/use-custom-chart-context.js +6 -1
- package/lib/react/use-custom-chart-context.js.map +1 -1
- package/lib/react/use-custom-chart-context.spec.js +1 -1
- package/lib/react/use-custom-chart-types.d.ts +2 -1
- package/lib/react/use-custom-chart-types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/react/use-custom-chart-context.spec.tsx +1 -1
- package/src/react/use-custom-chart-context.tsx +11 -2
- package/src/react/use-custom-chart-types.ts +6 -1
package/dist/ts-chart-sdk.d.ts
CHANGED
|
@@ -1447,6 +1447,7 @@ export interface TSChartContextProps {
|
|
|
1447
1447
|
export interface ChartContextProps extends ChartToTSEventEmitters, TSToChartEventListener, TSToChartEventOffListener {
|
|
1448
1448
|
hasInitialized: boolean;
|
|
1449
1449
|
chartModel: ChartModel | undefined;
|
|
1450
|
+
appConfig: AppConfig | undefined;
|
|
1450
1451
|
destroy: () => void;
|
|
1451
1452
|
TSChartContext: ({ children }: TSChartContextProps) => React.JSX.Element;
|
|
1452
1453
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-custom-chart-context.d.ts","sourceRoot":"","sources":["../../src/react/use-custom-chart-context.tsx"],"names":[],"mappings":"AAWA,OAAO,EAEH,uBAAuB,EAC1B,MAAM,8BAA8B,CAAC;AActC,OAAO,EACH,iBAAiB,EAEpB,MAAM,0BAA0B,CAAC;AAYlC,eAAO,MAAM,eAAe,UACjB,KAAK,uBAAuB,EAAE,aAAa,CAAC,KACpD,
|
|
1
|
+
{"version":3,"file":"use-custom-chart-context.d.ts","sourceRoot":"","sources":["../../src/react/use-custom-chart-context.tsx"],"names":[],"mappings":"AAWA,OAAO,EAEH,uBAAuB,EAC1B,MAAM,8BAA8B,CAAC;AActC,OAAO,EACH,iBAAiB,EAEpB,MAAM,0BAA0B,CAAC;AAYlC,eAAO,MAAM,eAAe,UACjB,KAAK,uBAAuB,EAAE,aAAa,CAAC,KACpD,iBAiKF,CAAC"}
|
|
@@ -8,10 +8,12 @@ export const useChartContext = (props) => {
|
|
|
8
8
|
const [key, setKey] = useState(0);
|
|
9
9
|
const [ctx, setContextState] = useState({});
|
|
10
10
|
const [chartModel, setChartModel] = useState();
|
|
11
|
+
const [appConfig, setAppConfig] = useState();
|
|
11
12
|
const getChartContextValues = useCallback((ctx) => {
|
|
12
13
|
return {
|
|
13
14
|
hasInitialized,
|
|
14
15
|
chartModel,
|
|
16
|
+
appConfig,
|
|
15
17
|
destroy: () => ctx === null || ctx === void 0 ? void 0 : ctx.destroy(),
|
|
16
18
|
...emitter(ctx),
|
|
17
19
|
...eventListener(ctx),
|
|
@@ -20,16 +22,18 @@ export const useChartContext = (props) => {
|
|
|
20
22
|
return (React.createElement(React.Fragment, { key: key }, children));
|
|
21
23
|
},
|
|
22
24
|
};
|
|
23
|
-
}, [chartModel, key, hasInitialized, ctx]);
|
|
25
|
+
}, [chartModel, appConfig, key, hasInitialized, ctx]);
|
|
24
26
|
const setupEventListeners = useCallback((context) => {
|
|
25
27
|
const commonUpdateHandler = (payload) => {
|
|
26
28
|
setChartModel(context.getChartModel());
|
|
29
|
+
setAppConfig(context.getAppConfig());
|
|
27
30
|
return {
|
|
28
31
|
triggerRenderChart: true,
|
|
29
32
|
};
|
|
30
33
|
};
|
|
31
34
|
const defaultDownloadUpdateHandler = (payload) => {
|
|
32
35
|
setChartModel(context.getChartModel());
|
|
36
|
+
setAppConfig(context.getAppConfig());
|
|
33
37
|
return Promise.resolve({
|
|
34
38
|
isDownloadHandled: true,
|
|
35
39
|
fileName: '',
|
|
@@ -54,6 +58,7 @@ export const useChartContext = (props) => {
|
|
|
54
58
|
setHasInitialized(true);
|
|
55
59
|
setContextState(context);
|
|
56
60
|
setChartModel(context.getChartModel());
|
|
61
|
+
setAppConfig(context.getAppConfig());
|
|
57
62
|
return true;
|
|
58
63
|
})
|
|
59
64
|
.catch((e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-custom-chart-context.js","sourceRoot":"","sources":["../../src/react/use-custom-chart-context.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EACH,kBAAkB,GAErB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQxC,OAAO,EACH,OAAO,EACP,aAAa,EACb,gBAAgB,GACnB,MAAM,iCAAiC,CAAC;AAMzC,MAAM,MAAM,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAUnD,MAAM,CAAC,MAAM,eAAe,GAAG,CAC3B,KAAmD,EAClC,EAAE;IAKnB,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAK5D,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAKlC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,GAAG,QAAQ,CACnC,EAAwB,CAC3B,CAAC;IAKF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,EAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"use-custom-chart-context.js","sourceRoot":"","sources":["../../src/react/use-custom-chart-context.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EACH,kBAAkB,GAErB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAQxC,OAAO,EACH,OAAO,EACP,aAAa,EACb,gB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EAAE;YACP,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACxB,eAAe,CAAC,OAAO,CAAC,CAAC;YACzB,aAAa,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;YACvC,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;YACrC,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,MAAM,CAAC,GAAG,CAAC,iCAAiC,EAAE,CAAC,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACX,CAAC,CAAC;IAQF,MAAM,WAAW,GAAG,WAAW,CAC3B,CAAC,GAAuB,EAAE,EAAE;QACxB,MAAM,CAAC,CAAC,OAAe,EAAE,EAAE,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;QACzC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC,EACD,CAAC,GAAG,CAAC,CACR,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QAGX,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC;YACnC,GAAG,KAAK;YACR,WAAW;SACd,CAAC,CAAC;QAEH,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC3B,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC7B,OAAO,GAAG,EAAE;YACR,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,qBAAqB,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC,CAAC"}
|
|
@@ -389,7 +389,7 @@ describe('useChartContext on React Wrapper component', () => {
|
|
|
389
389
|
});
|
|
390
390
|
const updatedChildElement = getByTestId('child-element');
|
|
391
391
|
await waitFor(() => {
|
|
392
|
-
expect(updatedChildElement.textContent).toBe('Child Element counter:
|
|
392
|
+
expect(updatedChildElement.textContent).toBe('Child Element counter: 2red');
|
|
393
393
|
});
|
|
394
394
|
});
|
|
395
395
|
test('TSChartContext renders children should increase counter for useEffect on chartModel.visualProps if visualProps is updated', async () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartToTSEventsPayloadMap } from '../types/chart-to-ts-event.types';
|
|
3
|
-
import { ChartModel } from '../types/common.types';
|
|
3
|
+
import { AppConfig, ChartModel } from '../types/common.types';
|
|
4
4
|
import { TSToChartEventsPayloadMap } from '../types/ts-to-chart-event.types';
|
|
5
5
|
export type ChartToTSEventEmitters = {
|
|
6
6
|
[key in keyof ChartToTSEventsPayloadMap as `emit${Capitalize<key>}`]: (...args: ChartToTSEventsPayloadMap[key]) => Promise<void>;
|
|
@@ -17,6 +17,7 @@ export interface TSChartContextProps {
|
|
|
17
17
|
export interface ChartContextProps extends ChartToTSEventEmitters, TSToChartEventListener, TSToChartEventOffListener {
|
|
18
18
|
hasInitialized: boolean;
|
|
19
19
|
chartModel: ChartModel | undefined;
|
|
20
|
+
appConfig: AppConfig | undefined;
|
|
20
21
|
destroy: () => void;
|
|
21
22
|
TSChartContext: ({ children }: TSChartContextProps) => React.JSX.Element;
|
|
22
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-custom-chart-types.d.ts","sourceRoot":"","sources":["../../src/react/use-custom-chart-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-custom-chart-types.d.ts","sourceRoot":"","sources":["../../src/react/use-custom-chart-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAO7E,MAAM,MAAM,sBAAsB,GAAG;KAChC,GAAG,IAAI,MAAM,yBAAyB,IAAI,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,CAClE,GAAG,IAAI,EAAE,yBAAyB,CAAC,GAAG,CAAC,KACtC,OAAO,CAAC,IAAI,CAAC;CACrB,CAAC;AAOF,MAAM,MAAM,sBAAsB,GAAG;KAChC,GAAG,IAAI,MAAM,yBAAyB,IAAI,QAAQ,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,CACnE,IAAI,EAAE,yBAAyB,CAAC,GAAG,CAAC,KACnC,OAAO,CAAC,IAAI,CAAC;CACrB,CAAC;AAOF,MAAM,MAAM,yBAAyB,GAAG;KACnC,GAAG,IAAI,MAAM,yBAAyB,IAAI,SAAS,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;CAC9F,CAAC;AAEF,MAAM,WAAW,mBAAmB;IAKhC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,MAAM,WAAW,iBACb,SAAQ,sBAAsB,EAC1B,sBAAsB,EACtB,yBAAyB;IAI7B,cAAc,EAAE,OAAO,CAAC;IAKxB,UAAU,EAAE,UAAU,GAAG,SAAS,CAAC;IAKnC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IAKjC,OAAO,EAAE,MAAM,IAAI,CAAC;IAOpB,cAAc,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,mBAAmB,KAAK,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;CAC5E"}
|
package/package.json
CHANGED
|
@@ -509,7 +509,7 @@ describe('useChartContext on React Wrapper component', () => {
|
|
|
509
509
|
const updatedChildElement = getByTestId('child-element');
|
|
510
510
|
await waitFor(() => {
|
|
511
511
|
expect(updatedChildElement.textContent).toBe(
|
|
512
|
-
'Child Element counter:
|
|
512
|
+
'Child Element counter: 2red',
|
|
513
513
|
);
|
|
514
514
|
});
|
|
515
515
|
});
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
CustomChartContextProps,
|
|
15
15
|
} from '../main/custom-chart-context';
|
|
16
16
|
import { create } from '../main/logger';
|
|
17
|
-
import { ChartModel } from '../types/common.types';
|
|
17
|
+
import { AppConfig, ChartModel } from '../types/common.types';
|
|
18
18
|
import {
|
|
19
19
|
ChartModelUpdateEventPayload,
|
|
20
20
|
DataUpdateEventPayload,
|
|
@@ -66,6 +66,11 @@ export const useChartContext = (
|
|
|
66
66
|
* @type {ChartModel}
|
|
67
67
|
*/
|
|
68
68
|
const [chartModel, setChartModel] = useState<ChartModel>();
|
|
69
|
+
/**
|
|
70
|
+
* State to manage the app config.
|
|
71
|
+
* @type {AppConfig}
|
|
72
|
+
*/
|
|
73
|
+
const [appConfig, setAppConfig] = useState<AppConfig>();
|
|
69
74
|
|
|
70
75
|
/**
|
|
71
76
|
* Retrieves the chart context values.
|
|
@@ -79,6 +84,7 @@ export const useChartContext = (
|
|
|
79
84
|
return {
|
|
80
85
|
hasInitialized,
|
|
81
86
|
chartModel,
|
|
87
|
+
appConfig,
|
|
82
88
|
destroy: () => ctx?.destroy(),
|
|
83
89
|
...emitter(ctx),
|
|
84
90
|
...eventListener(ctx),
|
|
@@ -90,7 +96,7 @@ export const useChartContext = (
|
|
|
90
96
|
},
|
|
91
97
|
};
|
|
92
98
|
},
|
|
93
|
-
[chartModel, key, hasInitialized, ctx],
|
|
99
|
+
[chartModel, appConfig, key, hasInitialized, ctx],
|
|
94
100
|
);
|
|
95
101
|
|
|
96
102
|
/**
|
|
@@ -104,6 +110,7 @@ export const useChartContext = (
|
|
|
104
110
|
| DataUpdateEventPayload,
|
|
105
111
|
) => {
|
|
106
112
|
setChartModel(context.getChartModel());
|
|
113
|
+
setAppConfig(context.getAppConfig());
|
|
107
114
|
return {
|
|
108
115
|
triggerRenderChart: true,
|
|
109
116
|
};
|
|
@@ -112,6 +119,7 @@ export const useChartContext = (
|
|
|
112
119
|
payload: DownloadExcelTriggerPayload,
|
|
113
120
|
) => {
|
|
114
121
|
setChartModel(context.getChartModel());
|
|
122
|
+
setAppConfig(context.getAppConfig());
|
|
115
123
|
return Promise.resolve({
|
|
116
124
|
isDownloadHandled: true,
|
|
117
125
|
fileName: '',
|
|
@@ -158,6 +166,7 @@ export const useChartContext = (
|
|
|
158
166
|
setHasInitialized(true);
|
|
159
167
|
setContextState(context);
|
|
160
168
|
setChartModel(context.getChartModel());
|
|
169
|
+
setAppConfig(context.getAppConfig());
|
|
161
170
|
return true;
|
|
162
171
|
})
|
|
163
172
|
.catch((e) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ChartToTSEventsPayloadMap } from '../types/chart-to-ts-event.types';
|
|
3
|
-
import { ChartModel } from '../types/common.types';
|
|
3
|
+
import { AppConfig, ChartModel } from '../types/common.types';
|
|
4
4
|
import { TSToChartEventsPayloadMap } from '../types/ts-to-chart-event.types';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -55,6 +55,11 @@ export interface ChartContextProps
|
|
|
55
55
|
* config, data and visual props
|
|
56
56
|
*/
|
|
57
57
|
chartModel: ChartModel | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* app config to be used by client having
|
|
60
|
+
* app state like locale and timezones
|
|
61
|
+
*/
|
|
62
|
+
appConfig: AppConfig | undefined;
|
|
58
63
|
/**
|
|
59
64
|
* For destroying current chart context
|
|
60
65
|
* @returns void
|