@oanda/labs-value-at-risk-widget 1.0.64 → 1.0.65
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/CHANGELOG.md +264 -0
- package/dist/main/ValueAtRiskWidget/ChartWithData.js +2 -4
- package/dist/main/ValueAtRiskWidget/ChartWithData.js.map +1 -1
- package/dist/main/ValueAtRiskWidget/Tool.js +1 -1
- package/dist/main/ValueAtRiskWidget/Tool.js.map +1 -1
- package/dist/main/ValueAtRiskWidget/ToolWithData.js +2 -4
- package/dist/main/ValueAtRiskWidget/ToolWithData.js.map +1 -1
- package/dist/main/ValueAtRiskWidget/ValueAtRiskWidget.js +16 -21
- package/dist/main/ValueAtRiskWidget/ValueAtRiskWidget.js.map +1 -1
- package/dist/main/ValueAtRiskWidget/Widget.js +2 -4
- package/dist/main/ValueAtRiskWidget/Widget.js.map +1 -1
- package/dist/main/ValueAtRiskWidget/components/Chart/Chart.js +3 -3
- package/dist/main/ValueAtRiskWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/ValueAtRiskWidget/components/Legend/Legend.js +3 -4
- package/dist/main/ValueAtRiskWidget/components/Legend/Legend.js.map +1 -1
- package/dist/module/ValueAtRiskWidget/ChartWithData.js +3 -3
- package/dist/module/ValueAtRiskWidget/ChartWithData.js.map +1 -1
- package/dist/module/ValueAtRiskWidget/Tool.js +3 -3
- package/dist/module/ValueAtRiskWidget/Tool.js.map +1 -1
- package/dist/module/ValueAtRiskWidget/ToolWithData.js +3 -3
- package/dist/module/ValueAtRiskWidget/ToolWithData.js.map +1 -1
- package/dist/module/ValueAtRiskWidget/ValueAtRiskWidget.js +18 -23
- package/dist/module/ValueAtRiskWidget/ValueAtRiskWidget.js.map +1 -1
- package/dist/module/ValueAtRiskWidget/Widget.js +3 -3
- package/dist/module/ValueAtRiskWidget/Widget.js.map +1 -1
- package/dist/module/ValueAtRiskWidget/components/Chart/Chart.js +3 -3
- package/dist/module/ValueAtRiskWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/ValueAtRiskWidget/components/Legend/Legend.js +3 -3
- package/dist/module/ValueAtRiskWidget/components/Legend/Legend.js.map +1 -1
- package/package.json +3 -3
- package/src/ValueAtRiskWidget/ChartWithData.tsx +3 -3
- package/src/ValueAtRiskWidget/Tool.tsx +3 -3
- package/src/ValueAtRiskWidget/ToolWithData.tsx +3 -3
- package/src/ValueAtRiskWidget/ValueAtRiskWidget.tsx +26 -31
- package/src/ValueAtRiskWidget/Widget.tsx +3 -3
- package/src/ValueAtRiskWidget/components/Chart/Chart.tsx +3 -3
- package/src/ValueAtRiskWidget/components/Legend/Legend.tsx +3 -3
- package/test/ChartWithData.test.tsx +7 -7
- package/test/Tool.test.tsx +5 -5
- package/test/ToolWithData.test.tsx +3 -3
- package/test/Widget.test.tsx +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
import { Size,
|
|
3
|
+
import { Size, useLayoutProvider } from '@oanda/labs-widget-common';
|
|
4
4
|
import { useLocale } from '@oanda/mono-i18n';
|
|
5
5
|
import { WidgetProps } from './types';
|
|
6
6
|
import { ChartWithData } from './ChartWithData';
|
|
@@ -12,7 +12,7 @@ const Widget = ({
|
|
|
12
12
|
bars,
|
|
13
13
|
}: WidgetProps) => {
|
|
14
14
|
const { lang } = useLocale();
|
|
15
|
-
const { size } =
|
|
15
|
+
const { size } = useLayoutProvider();
|
|
16
16
|
const isDesktop = size === Size.DESKTOP;
|
|
17
17
|
|
|
18
18
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import ReactEChartsCore from 'echarts-for-react/lib/core';
|
|
3
3
|
import * as echarts from 'echarts/core';
|
|
4
4
|
import { LineChart, CustomChart } from 'echarts/charts';
|
|
@@ -17,7 +17,7 @@ import { useLocale } from '@oanda/mono-i18n';
|
|
|
17
17
|
import {
|
|
18
18
|
Size,
|
|
19
19
|
Theme,
|
|
20
|
-
|
|
20
|
+
useLayoutProvider,
|
|
21
21
|
getChartTheme,
|
|
22
22
|
} from '@oanda/labs-widget-common';
|
|
23
23
|
import { CHART_HEIGHT } from './constants';
|
|
@@ -43,7 +43,7 @@ echarts.registerTheme('light_theme', getChartTheme(Theme.Light));
|
|
|
43
43
|
|
|
44
44
|
const Chart = ({ values }: ChartProps) => {
|
|
45
45
|
const { lang } = useLocale();
|
|
46
|
-
const { isDark, size } =
|
|
46
|
+
const { isDark, size } = useLayoutProvider();
|
|
47
47
|
const isDesktop = size === Size.DESKTOP;
|
|
48
48
|
|
|
49
49
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Size,
|
|
4
|
-
|
|
4
|
+
useLayoutProvider,
|
|
5
5
|
} from '@oanda/labs-widget-common';
|
|
6
6
|
import { useLocale } from '@oanda/mono-i18n';
|
|
7
7
|
import {
|
|
@@ -11,7 +11,7 @@ import { DesktopLegend } from './DesktopLegend';
|
|
|
11
11
|
import { MobileLegend } from './MobileLegend';
|
|
12
12
|
|
|
13
13
|
const Legend = ({ data }: LegendProps) => {
|
|
14
|
-
const { size, isDark } =
|
|
14
|
+
const { size, isDark } = useLayoutProvider();
|
|
15
15
|
const { lang } = useLocale();
|
|
16
16
|
const isDesktop = size === Size.DESKTOP;
|
|
17
17
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
import { MockedProvider } from '@apollo/client/testing';
|
|
7
|
-
import {
|
|
7
|
+
import { MockLayoutProvider } from '@oanda/labs-widget-common';
|
|
8
8
|
import { Division, ValueAtRiskBars, ValueAtRiskDuration } from '../src/gql/types/graphql';
|
|
9
9
|
import { getValueAtRiskChartErrorMock, getValueAtRiskChartMock } from './mocks/responsesMocks';
|
|
10
10
|
import { ChartWithData } from '../src/ValueAtRiskWidget/ChartWithData';
|
|
@@ -13,14 +13,14 @@ describe('ChartWithData component', () => {
|
|
|
13
13
|
it('should render chart view', async () => {
|
|
14
14
|
const { findByTestId } = render(
|
|
15
15
|
<MockedProvider mocks={getValueAtRiskChartMock('CORN')}>
|
|
16
|
-
<
|
|
16
|
+
<MockLayoutProvider isDark={false}>
|
|
17
17
|
<ChartWithData
|
|
18
18
|
division={Division.Oc}
|
|
19
19
|
instrument="CORN"
|
|
20
20
|
bars={ValueAtRiskBars.C100}
|
|
21
21
|
duration={ValueAtRiskDuration.C1}
|
|
22
22
|
/>
|
|
23
|
-
</
|
|
23
|
+
</MockLayoutProvider>
|
|
24
24
|
</MockedProvider>,
|
|
25
25
|
);
|
|
26
26
|
|
|
@@ -30,14 +30,14 @@ describe('ChartWithData component', () => {
|
|
|
30
30
|
it('should render mobile chart view', async () => {
|
|
31
31
|
const { findByTestId } = render(
|
|
32
32
|
<MockedProvider mocks={getValueAtRiskChartMock('CORN')}>
|
|
33
|
-
<
|
|
33
|
+
<MockLayoutProvider isDark={false}>
|
|
34
34
|
<ChartWithData
|
|
35
35
|
division={Division.Oc}
|
|
36
36
|
instrument="CORN"
|
|
37
37
|
bars={ValueAtRiskBars.C100}
|
|
38
38
|
duration={ValueAtRiskDuration.C1}
|
|
39
39
|
/>
|
|
40
|
-
</
|
|
40
|
+
</MockLayoutProvider>
|
|
41
41
|
</MockedProvider>,
|
|
42
42
|
);
|
|
43
43
|
|
|
@@ -47,14 +47,14 @@ describe('ChartWithData component', () => {
|
|
|
47
47
|
it('should render error view', async () => {
|
|
48
48
|
const { findByTestId } = render(
|
|
49
49
|
<MockedProvider mocks={getValueAtRiskChartErrorMock}>
|
|
50
|
-
<
|
|
50
|
+
<MockLayoutProvider isDark={false}>
|
|
51
51
|
<ChartWithData
|
|
52
52
|
division={Division.Oc}
|
|
53
53
|
instrument="AUD_USD"
|
|
54
54
|
bars={ValueAtRiskBars.C100}
|
|
55
55
|
duration={ValueAtRiskDuration.C1}
|
|
56
56
|
/>
|
|
57
|
-
</
|
|
57
|
+
</MockLayoutProvider>
|
|
58
58
|
</MockedProvider>,
|
|
59
59
|
);
|
|
60
60
|
|
package/test/Tool.test.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { render, fireEvent } from '@testing-library/react';
|
|
6
|
-
import {
|
|
6
|
+
import { MockLayoutProvider } from '@oanda/labs-widget-common';
|
|
7
7
|
import { MockedProvider } from '@apollo/client/testing';
|
|
8
8
|
import { Tool } from '../src/ValueAtRiskWidget/Tool';
|
|
9
9
|
import { assetClassesMock, getValueAtRiskChartMock } from './mocks';
|
|
@@ -17,12 +17,12 @@ describe('Tool component', () => {
|
|
|
17
17
|
it('should render tool view', () => {
|
|
18
18
|
const { getByTestId } = render(
|
|
19
19
|
<MockedProvider mocks={getValueAtRiskChartMock()}>
|
|
20
|
-
<
|
|
20
|
+
<MockLayoutProvider>
|
|
21
21
|
<Tool
|
|
22
22
|
data={data}
|
|
23
23
|
division={Division.Oc}
|
|
24
24
|
/>
|
|
25
|
-
</
|
|
25
|
+
</MockLayoutProvider>
|
|
26
26
|
</MockedProvider>,
|
|
27
27
|
);
|
|
28
28
|
|
|
@@ -31,12 +31,12 @@ describe('Tool component', () => {
|
|
|
31
31
|
it('should change asset class and instruments list on click', () => {
|
|
32
32
|
const { container, getByTestId } = render(
|
|
33
33
|
<MockedProvider mocks={[...getValueAtRiskChartMock('AUD_USD'), ...getValueAtRiskChartMock('AUS200')]}>
|
|
34
|
-
<
|
|
34
|
+
<MockLayoutProvider>
|
|
35
35
|
<Tool
|
|
36
36
|
data={data}
|
|
37
37
|
division={Division.Oc}
|
|
38
38
|
/>
|
|
39
|
-
</
|
|
39
|
+
</MockLayoutProvider>
|
|
40
40
|
</MockedProvider>,
|
|
41
41
|
);
|
|
42
42
|
expect(getByTestId('value-at-risk-tool-wrapper')).toBeInTheDocument();
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
import { MockedProvider } from '@apollo/client/testing';
|
|
7
|
-
import {
|
|
7
|
+
import { MockLayoutProvider } from '@oanda/labs-widget-common';
|
|
8
8
|
import { ToolWithData } from '../src/ValueAtRiskWidget/ToolWithData';
|
|
9
9
|
import { Division } from '../src/gql/types/graphql';
|
|
10
10
|
import { getValueAtRiskAssetClassesMock, getValueAtRiskChartMock } from './mocks/responsesMocks';
|
|
@@ -13,9 +13,9 @@ describe('Main component', () => {
|
|
|
13
13
|
it('should render tool view', async () => {
|
|
14
14
|
const { findByTestId } = render(
|
|
15
15
|
<MockedProvider mocks={[...getValueAtRiskAssetClassesMock, ...getValueAtRiskChartMock()]}>
|
|
16
|
-
<
|
|
16
|
+
<MockLayoutProvider isDark={false}>
|
|
17
17
|
<ToolWithData division={Division.Oc} />
|
|
18
|
-
</
|
|
18
|
+
</MockLayoutProvider>
|
|
19
19
|
</MockedProvider>,
|
|
20
20
|
);
|
|
21
21
|
|
package/test/Widget.test.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
|
-
import {
|
|
6
|
+
import { MockLayoutProvider } from '@oanda/labs-widget-common';
|
|
7
7
|
import { MockedProvider } from '@apollo/client/testing';
|
|
8
8
|
import { getValueAtRiskChartMock } from './mocks';
|
|
9
9
|
import { Division, ValueAtRiskBars, ValueAtRiskDuration } from '../src/gql/types/graphql';
|
|
@@ -13,14 +13,14 @@ describe('Widget component', () => {
|
|
|
13
13
|
it('should render widget view', () => {
|
|
14
14
|
const { getByTestId } = render(
|
|
15
15
|
<MockedProvider mocks={getValueAtRiskChartMock()}>
|
|
16
|
-
<
|
|
16
|
+
<MockLayoutProvider>
|
|
17
17
|
<Widget
|
|
18
18
|
division={Division.Oc}
|
|
19
19
|
instrument="AUD_USD"
|
|
20
20
|
bars={ValueAtRiskBars.C100}
|
|
21
21
|
duration={ValueAtRiskDuration.C1}
|
|
22
22
|
/>
|
|
23
|
-
</
|
|
23
|
+
</MockLayoutProvider>
|
|
24
24
|
</MockedProvider>,
|
|
25
25
|
);
|
|
26
26
|
|