@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.
Files changed (41) hide show
  1. package/CHANGELOG.md +264 -0
  2. package/dist/main/ValueAtRiskWidget/ChartWithData.js +2 -4
  3. package/dist/main/ValueAtRiskWidget/ChartWithData.js.map +1 -1
  4. package/dist/main/ValueAtRiskWidget/Tool.js +1 -1
  5. package/dist/main/ValueAtRiskWidget/Tool.js.map +1 -1
  6. package/dist/main/ValueAtRiskWidget/ToolWithData.js +2 -4
  7. package/dist/main/ValueAtRiskWidget/ToolWithData.js.map +1 -1
  8. package/dist/main/ValueAtRiskWidget/ValueAtRiskWidget.js +16 -21
  9. package/dist/main/ValueAtRiskWidget/ValueAtRiskWidget.js.map +1 -1
  10. package/dist/main/ValueAtRiskWidget/Widget.js +2 -4
  11. package/dist/main/ValueAtRiskWidget/Widget.js.map +1 -1
  12. package/dist/main/ValueAtRiskWidget/components/Chart/Chart.js +3 -3
  13. package/dist/main/ValueAtRiskWidget/components/Chart/Chart.js.map +1 -1
  14. package/dist/main/ValueAtRiskWidget/components/Legend/Legend.js +3 -4
  15. package/dist/main/ValueAtRiskWidget/components/Legend/Legend.js.map +1 -1
  16. package/dist/module/ValueAtRiskWidget/ChartWithData.js +3 -3
  17. package/dist/module/ValueAtRiskWidget/ChartWithData.js.map +1 -1
  18. package/dist/module/ValueAtRiskWidget/Tool.js +3 -3
  19. package/dist/module/ValueAtRiskWidget/Tool.js.map +1 -1
  20. package/dist/module/ValueAtRiskWidget/ToolWithData.js +3 -3
  21. package/dist/module/ValueAtRiskWidget/ToolWithData.js.map +1 -1
  22. package/dist/module/ValueAtRiskWidget/ValueAtRiskWidget.js +18 -23
  23. package/dist/module/ValueAtRiskWidget/ValueAtRiskWidget.js.map +1 -1
  24. package/dist/module/ValueAtRiskWidget/Widget.js +3 -3
  25. package/dist/module/ValueAtRiskWidget/Widget.js.map +1 -1
  26. package/dist/module/ValueAtRiskWidget/components/Chart/Chart.js +3 -3
  27. package/dist/module/ValueAtRiskWidget/components/Chart/Chart.js.map +1 -1
  28. package/dist/module/ValueAtRiskWidget/components/Legend/Legend.js +3 -3
  29. package/dist/module/ValueAtRiskWidget/components/Legend/Legend.js.map +1 -1
  30. package/package.json +3 -3
  31. package/src/ValueAtRiskWidget/ChartWithData.tsx +3 -3
  32. package/src/ValueAtRiskWidget/Tool.tsx +3 -3
  33. package/src/ValueAtRiskWidget/ToolWithData.tsx +3 -3
  34. package/src/ValueAtRiskWidget/ValueAtRiskWidget.tsx +26 -31
  35. package/src/ValueAtRiskWidget/Widget.tsx +3 -3
  36. package/src/ValueAtRiskWidget/components/Chart/Chart.tsx +3 -3
  37. package/src/ValueAtRiskWidget/components/Legend/Legend.tsx +3 -3
  38. package/test/ChartWithData.test.tsx +7 -7
  39. package/test/Tool.test.tsx +5 -5
  40. package/test/ToolWithData.test.tsx +3 -3
  41. package/test/Widget.test.tsx +3 -3
@@ -1,6 +1,6 @@
1
- import React, { useContext } from 'react';
1
+ import React from 'react';
2
2
  import classnames from 'classnames';
3
- import { Size, ThemeContext } from '@oanda/labs-widget-common';
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 } = useContext(ThemeContext);
15
+ const { size } = useLayoutProvider();
16
16
  const isDesktop = size === Size.DESKTOP;
17
17
 
18
18
  return (
@@ -1,4 +1,4 @@
1
- import React, { useContext } from '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
- ThemeContext,
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 } = useContext(ThemeContext);
46
+ const { isDark, size } = useLayoutProvider();
47
47
  const isDesktop = size === Size.DESKTOP;
48
48
 
49
49
  return (
@@ -1,7 +1,7 @@
1
- import React, { useContext } from 'react';
1
+ import React from 'react';
2
2
  import {
3
3
  Size,
4
- ThemeContext,
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 } = useContext(ThemeContext);
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 { Size, ThemeContext } from '@oanda/labs-widget-common';
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
- <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: false }}>
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
- </ThemeContext.Provider>
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
- <ThemeContext.Provider value={{ size: Size.MOBILE, isDark: false }}>
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
- </ThemeContext.Provider>
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
- <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: false }}>
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
- </ThemeContext.Provider>
57
+ </MockLayoutProvider>
58
58
  </MockedProvider>,
59
59
  );
60
60
 
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import React from 'react';
5
5
  import { render, fireEvent } from '@testing-library/react';
6
- import { ThemeContext, Size } from '@oanda/labs-widget-common';
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
- <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
20
+ <MockLayoutProvider>
21
21
  <Tool
22
22
  data={data}
23
23
  division={Division.Oc}
24
24
  />
25
- </ThemeContext.Provider>
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
- <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
34
+ <MockLayoutProvider>
35
35
  <Tool
36
36
  data={data}
37
37
  division={Division.Oc}
38
38
  />
39
- </ThemeContext.Provider>
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 { Size, ThemeContext } from '@oanda/labs-widget-common';
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
- <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: false }}>
16
+ <MockLayoutProvider isDark={false}>
17
17
  <ToolWithData division={Division.Oc} />
18
- </ThemeContext.Provider>
18
+ </MockLayoutProvider>
19
19
  </MockedProvider>,
20
20
  );
21
21
 
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import React from 'react';
5
5
  import { render } from '@testing-library/react';
6
- import { ThemeContext, Size } from '@oanda/labs-widget-common';
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
- <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
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
- </ThemeContext.Provider>
23
+ </MockLayoutProvider>
24
24
  </MockedProvider>,
25
25
  );
26
26