@oanda/labs-currency-power-balance-widget 1.0.110 → 1.0.112

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 (28) hide show
  1. package/CHANGELOG.md +900 -0
  2. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +3 -4
  3. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
  4. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +12 -17
  5. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
  6. package/dist/main/CurrencyPowerBalanceWidget/Main.js +1 -1
  7. package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  8. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +1 -1
  9. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  10. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +3 -4
  11. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
  12. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +3 -3
  13. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
  14. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +14 -19
  15. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
  16. package/dist/module/CurrencyPowerBalanceWidget/Main.js +3 -3
  17. package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  18. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +3 -3
  19. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  20. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +3 -3
  21. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
  22. package/package.json +3 -3
  23. package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +3 -3
  24. package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +16 -20
  25. package/src/CurrencyPowerBalanceWidget/Main.tsx +3 -3
  26. package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +3 -3
  27. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +3 -3
  28. package/test/Main.test.tsx +11 -11
@@ -1,9 +1,6 @@
1
1
  import React from 'react';
2
- import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
3
- import {
4
- ChartError, ThemeProvider, getLocale, renderComponent,
5
- } from '@oanda/labs-widget-common';
6
- import { LocaleProvider } from '@oanda/mono-i18n';
2
+ import { ApolloClient, InMemoryCache } from '@apollo/client';
3
+ import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
7
4
  import { Main } from './Main';
8
5
  import { CurrencyPowerBalanceConfig } from './types';
9
6
  import { translations } from '../translations';
@@ -17,21 +14,20 @@ const CurrencyPowerBalance = ({
17
14
  });
18
15
 
19
16
  return (
20
- <ThemeProvider theme={theme}>
21
- <LocaleProvider locale={getLocale(locale)} translations={translations}>
22
- <ApolloProvider client={client}>
23
- {isParamError ? (
24
- <div className="lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
25
- <ChartError />
26
- </div>
27
- ) : renderComponent({
28
- Component: <Main timeUnit={timeUnit} currencies={currencies} />,
29
- logoLink,
30
- linkArea: 'logo',
31
- })}
32
- </ApolloProvider>
33
- </LocaleProvider>
34
- </ThemeProvider>
17
+ <WidgetProvider
18
+ locale={locale}
19
+ translations={translations}
20
+ client={client}
21
+ theme={theme}
22
+ >
23
+ <WidgetWrapper
24
+ logoLink={logoLink}
25
+ linkArea="logo"
26
+ isParamError={isParamError}
27
+ >
28
+ <Main timeUnit={timeUnit} currencies={currencies} />
29
+ </WidgetWrapper>
30
+ </WidgetProvider>
35
31
  );
36
32
  };
37
33
 
@@ -1,5 +1,5 @@
1
- import React, { useContext, useState } from 'react';
2
- import { ThemeContext } from '@oanda/labs-widget-common';
1
+ import React, { useState } from 'react';
2
+ import { useLayoutProvider } from '@oanda/labs-widget-common';
3
3
  import { useLocale } from '@oanda/mono-i18n';
4
4
  import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
5
5
  import { TimeUnitSwitch } from './components/TimeUnitSwitch';
@@ -8,7 +8,7 @@ import { ChartWithData } from './ChartWithData';
8
8
  import { MainProps } from './types';
9
9
 
10
10
  const Main = ({ timeUnit, currencies }: MainProps) => {
11
- const { size } = useContext(ThemeContext);
11
+ const { size } = useLayoutProvider();
12
12
  const { lang } = useLocale();
13
13
  const [selectedTimeUnit, setSelectedTimeUnit] = useState(
14
14
  timeUnit || CurrencyPowerBalanceTimeUnit.CurrentDay,
@@ -1,4 +1,4 @@
1
- import React, { useRef, useEffect, useContext } from 'react';
1
+ import React, { useRef, useEffect } from 'react';
2
2
  import ReactEChartsCore from 'echarts-for-react/lib/core';
3
3
  import * as echarts from 'echarts/core';
4
4
  import { LineChart } from 'echarts/charts';
@@ -7,7 +7,7 @@ import {
7
7
  GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent, MarkLineComponent,
8
8
  } from 'echarts/components';
9
9
  import {
10
- Theme, ThemeContext, getChartTheme, Size,
10
+ Theme, useLayoutProvider, getChartTheme, Size,
11
11
  } from '@oanda/labs-widget-common';
12
12
  import { useLocale } from '@oanda/mono-i18n';
13
13
  import {
@@ -31,7 +31,7 @@ echarts.registerTheme('light_theme', getChartTheme(Theme.Light));
31
31
 
32
32
  const Chart = ({ values, timeUnit, currencies }: ChartProps) => {
33
33
  const { lang } = useLocale();
34
- const { isDark, size } = useContext(ThemeContext);
34
+ const { isDark, size } = useLayoutProvider();
35
35
  const isDesktop = size === Size.DESKTOP;
36
36
  const isMobile = size === Size.MOBILE;
37
37
 
@@ -1,6 +1,6 @@
1
- import React, { useContext } from 'react';
1
+ import React from 'react';
2
2
  import {
3
- Button, ButtonSize, ButtonVariant, ThemeContext, Size,
3
+ Button, ButtonSize, ButtonVariant, useLayoutProvider, Size,
4
4
  } from '@oanda/labs-widget-common';
5
5
  import { useLocale } from '@oanda/mono-i18n';
6
6
  import { TimeUnitSwitchProps } from './types';
@@ -12,7 +12,7 @@ const TimeUnitSwitch = ({
12
12
  selected, options, callback,
13
13
  }: TimeUnitSwitchProps) => {
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
  const handleButtonClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {
@@ -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, Size } from '@oanda/labs-widget-common';
8
8
  import { Main } from '../src/CurrencyPowerBalanceWidget/Main';
9
9
  import { mockResponse } from './responsesMocks';
10
10
  import { CurrencyPowerBalanceTimeUnit } from '../src/gql/types/graphql';
@@ -13,9 +13,9 @@ describe('Main component', () => {
13
13
  it('should render tool desktop view', async () => {
14
14
  const { findByTestId, getByTestId, queryByTestId } = render(
15
15
  <MockedProvider mocks={mockResponse}>
16
- <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
16
+ <MockLayoutProvider>
17
17
  <Main />
18
- </ThemeContext.Provider>
18
+ </MockLayoutProvider>
19
19
  </MockedProvider>,
20
20
  );
21
21
 
@@ -26,9 +26,9 @@ describe('Main component', () => {
26
26
  it('should render widget desktop view', async () => {
27
27
  const { findByTestId, getByTestId, queryByTestId } = render(
28
28
  <MockedProvider mocks={mockResponse}>
29
- <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
29
+ <MockLayoutProvider>
30
30
  <Main timeUnit={CurrencyPowerBalanceTimeUnit.CurrentDay} currencies={['USD', 'EUR']} />
31
- </ThemeContext.Provider>
31
+ </MockLayoutProvider>
32
32
  </MockedProvider>,
33
33
  );
34
34
 
@@ -39,9 +39,9 @@ describe('Main component', () => {
39
39
  it('should render tool desktop view when timeUnit missing for widget', async () => {
40
40
  const { findByTestId, getByTestId, queryByTestId } = render(
41
41
  <MockedProvider mocks={mockResponse}>
42
- <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
42
+ <MockLayoutProvider>
43
43
  <Main currencies={['USD', 'EUR']} />
44
- </ThemeContext.Provider>
44
+ </MockLayoutProvider>
45
45
  </MockedProvider>,
46
46
  );
47
47
 
@@ -52,9 +52,9 @@ describe('Main component', () => {
52
52
  it('should render tool desktop view when currencies missing for widget', async () => {
53
53
  const { findByTestId, getByTestId, queryByTestId } = render(
54
54
  <MockedProvider mocks={mockResponse}>
55
- <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
55
+ <MockLayoutProvider>
56
56
  <Main timeUnit={CurrencyPowerBalanceTimeUnit.CurrentDay} />
57
- </ThemeContext.Provider>
57
+ </MockLayoutProvider>
58
58
  </MockedProvider>,
59
59
  );
60
60
 
@@ -65,9 +65,9 @@ describe('Main component', () => {
65
65
  it('should render tool mobile view', async () => {
66
66
  const { findByTestId, getByTestId, queryByTestId } = render(
67
67
  <MockedProvider mocks={mockResponse}>
68
- <ThemeContext.Provider value={{ size: Size.MOBILE, isDark: true }}>
68
+ <MockLayoutProvider size={Size.MOBILE}>
69
69
  <Main />
70
- </ThemeContext.Provider>
70
+ </MockLayoutProvider>
71
71
  </MockedProvider>,
72
72
  );
73
73