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

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 (128) hide show
  1. package/CHANGELOG.md +916 -0
  2. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +9 -8
  3. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
  4. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +9 -9
  5. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
  6. package/dist/main/CurrencyPowerBalanceWidget/Main.js +12 -12
  7. package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  8. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +12 -12
  9. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  10. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  11. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +6 -15
  12. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  13. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +1 -1
  14. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  15. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js +2 -2
  16. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -1
  17. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -1
  18. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -1
  19. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
  20. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +4 -4
  21. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
  22. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +9 -9
  23. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
  24. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -1
  25. package/dist/main/CurrencyPowerBalanceWidget/config.js.map +1 -1
  26. package/dist/main/CurrencyPowerBalanceWidget/constants.js.map +1 -1
  27. package/dist/main/CurrencyPowerBalanceWidget/render.js +8 -8
  28. package/dist/main/CurrencyPowerBalanceWidget/render.js.map +1 -1
  29. package/dist/main/CurrencyPowerBalanceWidget/types.js.map +1 -1
  30. package/dist/main/gql/getCurrencyPowerBalance.js +3 -12
  31. package/dist/main/gql/getCurrencyPowerBalance.js.map +1 -1
  32. package/dist/main/gql/types/fragment-masking.js +3 -2
  33. package/dist/main/gql/types/fragment-masking.js.map +1 -1
  34. package/dist/main/gql/types/gql.js +3 -2
  35. package/dist/main/gql/types/gql.js.map +1 -1
  36. package/dist/main/gql/types/graphql.js +64 -64
  37. package/dist/main/gql/types/graphql.js.map +1 -1
  38. package/dist/main/gql/types/index.js.map +1 -1
  39. package/dist/main/translations/index.js +1 -1
  40. package/dist/main/translations/index.js.map +1 -1
  41. package/dist/main/translations/translations.js.map +1 -1
  42. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +9 -8
  43. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
  44. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +9 -9
  45. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
  46. package/dist/module/CurrencyPowerBalanceWidget/Main.js +12 -12
  47. package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  48. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +11 -11
  49. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  50. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +1 -1
  51. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  52. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +8 -17
  53. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  54. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +2 -2
  55. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  56. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js +2 -2
  57. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -1
  58. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -1
  59. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -1
  60. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
  61. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +4 -4
  62. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
  63. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +10 -10
  64. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
  65. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -1
  66. package/dist/module/CurrencyPowerBalanceWidget/config.js.map +1 -1
  67. package/dist/module/CurrencyPowerBalanceWidget/constants.js.map +1 -1
  68. package/dist/module/CurrencyPowerBalanceWidget/render.js +8 -8
  69. package/dist/module/CurrencyPowerBalanceWidget/render.js.map +1 -1
  70. package/dist/module/CurrencyPowerBalanceWidget/types.js.map +1 -1
  71. package/dist/module/gql/getCurrencyPowerBalance.js +3 -12
  72. package/dist/module/gql/getCurrencyPowerBalance.js.map +1 -1
  73. package/dist/module/gql/types/fragment-masking.js +3 -2
  74. package/dist/module/gql/types/fragment-masking.js.map +1 -1
  75. package/dist/module/gql/types/gql.js +3 -2
  76. package/dist/module/gql/types/gql.js.map +1 -1
  77. package/dist/module/gql/types/graphql.js +64 -64
  78. package/dist/module/gql/types/graphql.js.map +1 -1
  79. package/dist/module/gql/types/index.js +2 -2
  80. package/dist/module/gql/types/index.js.map +1 -1
  81. package/dist/module/translations/index.js +1 -1
  82. package/dist/module/translations/index.js.map +1 -1
  83. package/dist/module/translations/translations.js.map +1 -1
  84. package/dist/types/CurrencyPowerBalanceWidget/ChartWithData.d.ts +1 -1
  85. package/dist/types/CurrencyPowerBalanceWidget/CurrencyPowerBalance.d.ts +1 -1
  86. package/dist/types/CurrencyPowerBalanceWidget/Main.d.ts +1 -1
  87. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/Chart.d.ts +1 -1
  88. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +1 -1
  89. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/formatters.d.ts +4 -3
  90. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +2 -1
  91. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/utils.d.ts +1 -1
  92. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/types.d.ts +1 -1
  93. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.d.ts +1 -1
  94. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.d.ts +1 -1
  95. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.d.ts +3 -3
  96. package/dist/types/CurrencyPowerBalanceWidget/types.d.ts +2 -2
  97. package/dist/types/gql/types/gql.d.ts +2 -2
  98. package/dist/types/gql/types/index.d.ts +2 -2
  99. package/dist/types/translations/index.d.ts +2 -2
  100. package/package.json +3 -3
  101. package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +31 -17
  102. package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +16 -9
  103. package/src/CurrencyPowerBalanceWidget/Main.tsx +18 -9
  104. package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +25 -20
  105. package/src/CurrencyPowerBalanceWidget/components/Chart/options/constants.ts +11 -10
  106. package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +42 -22
  107. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +59 -44
  108. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts +7 -4
  109. package/src/CurrencyPowerBalanceWidget/components/Chart/options/types.ts +1 -1
  110. package/src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts +10 -9
  111. package/src/CurrencyPowerBalanceWidget/components/Chart/types.ts +4 -1
  112. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +21 -15
  113. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +47 -37
  114. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts +3 -3
  115. package/src/CurrencyPowerBalanceWidget/config.ts +8 -2
  116. package/src/CurrencyPowerBalanceWidget/constants.ts +2 -1
  117. package/src/CurrencyPowerBalanceWidget/render.tsx +24 -20
  118. package/src/CurrencyPowerBalanceWidget/types.ts +5 -3
  119. package/src/gql/types/fragment-masking.ts +41 -21
  120. package/src/gql/types/gql.ts +7 -3
  121. package/src/gql/types/graphql.ts +117 -44
  122. package/src/gql/types/index.ts +2 -2
  123. package/src/translations/index.ts +4 -4
  124. package/src/translations/translations.ts +2 -1
  125. package/test/Main.test.tsx +28 -14
  126. package/test/chartFormatters.test.ts +84 -24
  127. package/test/responsesMocks.ts +254 -255
  128. package/test/utils.test.ts +0 -1
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { CurrencyPowerBalanceConfig } from './types';
2
+ import type { CurrencyPowerBalanceConfig } from './types';
3
3
  declare const CurrencyPowerBalance: ({ graphqlUrl, theme, locale, timeUnit, currencies, isParamError, logoLink, }: CurrencyPowerBalanceConfig) => React.JSX.Element;
4
4
  export { CurrencyPowerBalance };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { MainProps } from './types';
2
+ import type { MainProps } from './types';
3
3
  declare const Main: ({ timeUnit, currencies }: MainProps) => React.JSX.Element;
4
4
  export { Main };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { ChartProps } from './types';
2
+ import type { ChartProps } from './types';
3
3
  declare const Chart: ({ values, timeUnit, currencies }: ChartProps) => React.JSX.Element;
4
4
  export { Chart };
@@ -26,4 +26,4 @@ declare const TOOLTIP_LINE_COLOR_CONFIG: {
26
26
  DARK: string;
27
27
  LIGHT: string;
28
28
  };
29
- export { X_LABEL_SIZE, X_LABEL_SIZE_MOBILE, Y_LABEL_SIZE_MOBILE, Y_LABEL_SIZE, CHART_WIDTH, CHART_HEIGHT, LEGEND_HEIGHT, LEGEND_HEIGHT_MOBILE, VERTICAL_LINE_COUNT, COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, CANDLE_NUMBER_HOUR, CANDLE_MINUTE, CURRENCIES_ORDER, WEEKEND_DURATION, };
29
+ export { CANDLE_MINUTE, CANDLE_NUMBER_HOUR, CHART_HEIGHT, CHART_WIDTH, COLOR_CONFIG, CURRENCIES_ORDER, LEGEND_HEIGHT, LEGEND_HEIGHT_MOBILE, TOOLTIP_LINE_COLOR_CONFIG, VERTICAL_LINE_COUNT, WEEKEND_DURATION, X_LABEL_SIZE, X_LABEL_SIZE_MOBILE, Y_LABEL_SIZE, Y_LABEL_SIZE_MOBILE, };
@@ -1,5 +1,6 @@
1
- import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
- import { TooltipFormatterParams } from './types';
1
+ import type { CurrencyPowerBalance } from '../../../../gql/types/graphql';
2
+ import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
3
+ import type { TooltipFormatterParams } from './types';
3
4
  declare const isMonthWeek: (timeUnit: CurrencyPowerBalanceTimeUnit) => timeUnit is CurrencyPowerBalanceTimeUnit.M1 | CurrencyPowerBalanceTimeUnit.M3 | CurrencyPowerBalanceTimeUnit.W1;
4
5
  declare const xAxisLabelFormatter: (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => string;
5
6
  declare const intervalFormatter: (dataLength: number) => number;
@@ -10,4 +11,4 @@ declare const formatLegendData: (values: CurrencyPowerBalance[]) => {
10
11
  color: string;
11
12
  };
12
13
  }[];
13
- export { isMonthWeek, tooltipFormatter, xAxisLabelFormatter, intervalFormatter, formatLegendData, };
14
+ export { formatLegendData, intervalFormatter, isMonthWeek, tooltipFormatter, xAxisLabelFormatter, };
@@ -1,4 +1,5 @@
1
- import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
1
+ import type { CurrencyPowerBalance } from '../../../../gql/types/graphql';
2
+ import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
3
  declare const getOption: (chartData: CurrencyPowerBalance[], timeUnit: CurrencyPowerBalanceTimeUnit, isDark: boolean, lang: (key: string) => string) => {
3
4
  animation: boolean;
4
5
  legend: {
@@ -1,2 +1,2 @@
1
1
  declare const findLastIndexesBeforeWeekend: (timestamps: number[]) => number[];
2
- export { findLastIndexesBeforeWeekend, };
2
+ export { findLastIndexesBeforeWeekend };
@@ -1,4 +1,4 @@
1
- import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
1
+ import type { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
2
2
  export interface ChartProps {
3
3
  values: CurrencyPowerBalance[];
4
4
  timeUnit: CurrencyPowerBalanceTimeUnit;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { TimeUnitSwitchProps } from './types';
2
+ import type { TimeUnitSwitchProps } from './types';
3
3
  declare const TimeUnitSelect: ({ selected, options, callback, }: TimeUnitSwitchProps) => React.JSX.Element;
4
4
  export { TimeUnitSelect };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { TimeUnitSwitchProps } from './types';
2
+ import type { TimeUnitSwitchProps } from './types';
3
3
  declare const TimeUnitSwitch: ({ selected, options, callback, }: TimeUnitSwitchProps) => React.JSX.Element;
4
4
  export { TimeUnitSwitch };
@@ -1,4 +1,4 @@
1
- import { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
1
+ import type { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
2
2
  export interface TimeUnitOption {
3
3
  value: CurrencyPowerBalanceTimeUnit;
4
4
  label: string;
@@ -9,8 +9,8 @@ export interface TimeUnitSwitchProps {
9
9
  options: TimeUnitOption[];
10
10
  callback: (value: CurrencyPowerBalanceTimeUnit) => void;
11
11
  }
12
- type TooltipLabel = {
12
+ interface TooltipLabel {
13
13
  translationKey: string;
14
14
  count: number;
15
- };
15
+ }
16
16
  export {};
@@ -1,5 +1,5 @@
1
- import { WidgetConfig } from '@oanda/labs-widget-common';
2
- import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
1
+ import type { WidgetConfig } from '@oanda/labs-widget-common';
2
+ import type { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
3
3
  export interface CurrencyPowerBalanceConfig extends WidgetConfig {
4
4
  timeUnit?: CurrencyPowerBalanceTimeUnit;
5
5
  currencies?: string[];
@@ -11,7 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
11
11
  * Therefore it is highly recommended to use the babel or swc plugin for production.
12
12
  */
13
13
  declare const documents: {
14
- "\n query GetCurrencyPowerBalance($timeUnit: CurrencyPowerBalanceTimeUnit!) {\n currencyPowerBalance(timeUnit: $timeUnit) {\n currency\n power {\n point\n price\n }\n updatedAt\n }\n }\n": DocumentNode<types.GetCurrencyPowerBalanceQuery, types.Exact<{
14
+ '\n query GetCurrencyPowerBalance($timeUnit: CurrencyPowerBalanceTimeUnit!) {\n currencyPowerBalance(timeUnit: $timeUnit) {\n currency\n power {\n point\n price\n }\n updatedAt\n }\n }\n': DocumentNode<types.GetCurrencyPowerBalanceQuery, types.Exact<{
15
15
  timeUnit: types.CurrencyPowerBalanceTimeUnit;
16
16
  }>>;
17
17
  };
@@ -31,6 +31,6 @@ export declare function graphql(source: string): unknown;
31
31
  /**
32
32
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
33
33
  */
34
- export declare function graphql(source: "\n query GetCurrencyPowerBalance($timeUnit: CurrencyPowerBalanceTimeUnit!) {\n currencyPowerBalance(timeUnit: $timeUnit) {\n currency\n power {\n point\n price\n }\n updatedAt\n }\n }\n"): (typeof documents)["\n query GetCurrencyPowerBalance($timeUnit: CurrencyPowerBalanceTimeUnit!) {\n currencyPowerBalance(timeUnit: $timeUnit) {\n currency\n power {\n point\n price\n }\n updatedAt\n }\n }\n"];
34
+ export declare function graphql(source: '\n query GetCurrencyPowerBalance($timeUnit: CurrencyPowerBalanceTimeUnit!) {\n currencyPowerBalance(timeUnit: $timeUnit) {\n currency\n power {\n point\n price\n }\n updatedAt\n }\n }\n'): (typeof documents)['\n query GetCurrencyPowerBalance($timeUnit: CurrencyPowerBalanceTimeUnit!) {\n currencyPowerBalance(timeUnit: $timeUnit) {\n currency\n power {\n point\n price\n }\n updatedAt\n }\n }\n'];
35
35
  export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
36
36
  export {};
@@ -1,2 +1,2 @@
1
- export * from "./fragment-masking";
2
- export * from "./gql";
1
+ export * from './fragment-masking';
2
+ export * from './gql';
@@ -1,4 +1,4 @@
1
- import { Translations } from '@oanda/mono-i18n';
2
- import { defaultTranslations } from './translations';
1
+ import type { Translations } from '@oanda/mono-i18n';
2
+ import type { defaultTranslations } from './translations';
3
3
  export type TranslationKey = keyof typeof defaultTranslations;
4
4
  export declare const translations: Translations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-currency-power-balance-widget",
3
- "version": "1.0.112",
3
+ "version": "1.0.114",
4
4
  "description": "Labs Currency Power Balance Widget",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
@@ -12,7 +12,7 @@
12
12
  "author": "OANDA",
13
13
  "license": "UNLICENSED",
14
14
  "dependencies": {
15
- "@oanda/labs-widget-common": "^1.0.173",
15
+ "@oanda/labs-widget-common": "^1.0.175",
16
16
  "@oanda/mono-i18n": "10.0.1",
17
17
  "echarts": "5.5.0",
18
18
  "echarts-for-react": "3.0.2",
@@ -22,5 +22,5 @@
22
22
  "@graphql-codegen/cli": "5.0.0",
23
23
  "@graphql-codegen/client-preset": "4.1.0"
24
24
  },
25
- "gitHead": "67a7801f99f0bab94dd6067a102761f51de786c1"
25
+ "gitHead": "ffe302e74b4bdf5fb28f1f7be09cfd2cb7672eb3"
26
26
  }
@@ -1,23 +1,32 @@
1
- import React from 'react';
2
1
  import { useQuery } from '@apollo/client';
3
- import { useLocale } from '@oanda/mono-i18n';
4
2
  import {
5
- ChartError, Spinner, SpinnerSize, useLayoutProvider, Tooltip, Size,
3
+ ChartError,
6
4
  LastUpdated,
5
+ Size,
6
+ Spinner,
7
+ SpinnerSize,
8
+ Tooltip,
9
+ useLayoutProvider,
7
10
  } from '@oanda/labs-widget-common';
11
+ import { useLocale } from '@oanda/mono-i18n';
12
+ import React from 'react';
13
+
14
+ import { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';
15
+ import type {
16
+ GetCurrencyPowerBalanceQuery,
17
+ GetCurrencyPowerBalanceQueryVariables,
18
+ } from '../gql/types/graphql';
8
19
  import { Chart } from './components/Chart';
9
20
  import { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';
10
- import { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';
11
- import { ChartWithDataProps } from './types';
12
- import { GetCurrencyPowerBalanceQuery, GetCurrencyPowerBalanceQueryVariables } from '../gql/types/graphql';
21
+ import type { ChartWithDataProps } from './types';
13
22
 
14
23
  const ChartWithData = ({ timeUnit, currencies }: ChartWithDataProps) => {
15
24
  const { size } = useLayoutProvider();
16
25
  const isDesktop = size === Size.DESKTOP;
17
26
  const { lang } = useLocale();
18
27
  const { loading, data, error } = useQuery<
19
- GetCurrencyPowerBalanceQuery,
20
- GetCurrencyPowerBalanceQueryVariables
28
+ GetCurrencyPowerBalanceQuery,
29
+ GetCurrencyPowerBalanceQueryVariables
21
30
  >(getCurrencyPowerBalance, {
22
31
  variables: {
23
32
  timeUnit,
@@ -25,19 +34,24 @@ const ChartWithData = ({ timeUnit, currencies }: ChartWithDataProps) => {
25
34
  fetchPolicy: 'cache-and-network',
26
35
  });
27
36
 
28
- const showError = data?.currencyPowerBalance?.length === 0 || error
29
- || (currencies && (currencies.length === 0 || currencies.length === 1));
37
+ const showError =
38
+ data?.currencyPowerBalance?.length === 0 ||
39
+ error ||
40
+ (currencies && (currencies.length === 0 || currencies.length === 1));
30
41
 
31
42
  return (
32
43
  <>
33
- {loading
34
- && (
35
- <div className="lw-mb-[50px] lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
36
- <Spinner size={SpinnerSize.lg} />
37
- </div>
44
+ {loading && (
45
+ <div className="lw-mb-[50px] lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
46
+ <Spinner size={SpinnerSize.lg} />
47
+ </div>
38
48
  )}
39
49
  {!loading && !showError && (
40
- <Chart values={data?.currencyPowerBalance!} timeUnit={timeUnit} currencies={currencies} />
50
+ <Chart
51
+ currencies={currencies}
52
+ timeUnit={timeUnit}
53
+ values={data?.currencyPowerBalance!}
54
+ />
41
55
  )}
42
56
  {!loading && showError && (
43
57
  <div className="lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
@@ -48,8 +62,8 @@ const ChartWithData = ({ timeUnit, currencies }: ChartWithDataProps) => {
48
62
  <div className="lw-mt-2 lw-h-8">
49
63
  {!loading && !showError && (
50
64
  <LastUpdated
51
- timestamp={data?.currencyPowerBalance![0]?.updatedAt}
52
65
  labelCallback={lang}
66
+ timestamp={data?.currencyPowerBalance![0]?.updatedAt}
53
67
  />
54
68
  )}
55
69
  </div>
@@ -1,12 +1,19 @@
1
- import React from 'react';
2
1
  import { ApolloClient, InMemoryCache } from '@apollo/client';
3
2
  import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
4
- import { Main } from './Main';
5
- import { CurrencyPowerBalanceConfig } from './types';
3
+ import React from 'react';
4
+
6
5
  import { translations } from '../translations';
6
+ import { Main } from './Main';
7
+ import type { CurrencyPowerBalanceConfig } from './types';
7
8
 
8
9
  const CurrencyPowerBalance = ({
9
- graphqlUrl, theme, locale, timeUnit, currencies, isParamError, logoLink,
10
+ graphqlUrl,
11
+ theme,
12
+ locale,
13
+ timeUnit,
14
+ currencies,
15
+ isParamError,
16
+ logoLink,
10
17
  }: CurrencyPowerBalanceConfig) => {
11
18
  const client = new ApolloClient({
12
19
  uri: graphqlUrl,
@@ -15,17 +22,17 @@ const CurrencyPowerBalance = ({
15
22
 
16
23
  return (
17
24
  <WidgetProvider
18
- locale={locale}
19
- translations={translations}
20
25
  client={client}
26
+ locale={locale}
21
27
  theme={theme}
28
+ translations={translations}
22
29
  >
23
30
  <WidgetWrapper
24
- logoLink={logoLink}
25
- linkArea="logo"
26
31
  isParamError={isParamError}
32
+ linkArea="logo"
33
+ logoLink={logoLink}
27
34
  >
28
- <Main timeUnit={timeUnit} currencies={currencies} />
35
+ <Main currencies={currencies} timeUnit={timeUnit} />
29
36
  </WidgetWrapper>
30
37
  </WidgetProvider>
31
38
  );
@@ -1,45 +1,54 @@
1
- import React, { useState } from 'react';
2
1
  import { useLayoutProvider } from '@oanda/labs-widget-common';
3
2
  import { useLocale } from '@oanda/mono-i18n';
3
+ import React, { useState } from 'react';
4
+
4
5
  import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
6
+ import { ChartWithData } from './ChartWithData';
5
7
  import { TimeUnitSwitch } from './components/TimeUnitSwitch';
6
8
  import { timeUnitConfig } from './config';
7
- import { ChartWithData } from './ChartWithData';
8
- import { MainProps } from './types';
9
+ import type { MainProps } from './types';
9
10
 
10
11
  const Main = ({ timeUnit, currencies }: MainProps) => {
11
12
  const { size } = useLayoutProvider();
12
13
  const { lang } = useLocale();
13
14
  const [selectedTimeUnit, setSelectedTimeUnit] = useState(
14
- timeUnit || CurrencyPowerBalanceTimeUnit.CurrentDay,
15
+ timeUnit || CurrencyPowerBalanceTimeUnit.CurrentDay
15
16
  );
16
17
  return (
17
18
  <>
18
19
  {size && (
19
20
  <div
20
- data-testid="currency-power-balance-wrapper"
21
21
  className="lw-flex lw-flex-col lw-text-sm lw-tracking-normal"
22
+ data-testid="currency-power-balance-wrapper"
22
23
  >
23
24
  {timeUnit && currencies ? (
24
25
  <>
25
26
  {timeUnitConfig
26
27
  .filter(({ value }) => value === selectedTimeUnit)
27
28
  .map(({ tooltipLabel, label }) => (
28
- <div data-testid="time-unit-label" key={label} className="lw-mb-6 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold">
29
- {tooltipLabel ? <span>{`${lang(tooltipLabel!.translationKey, { count: tooltipLabel!.count })}`}</span> : <span>{`${lang(label)}`}</span>}
29
+ <div
30
+ key={label}
31
+ className="lw-mb-6 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold"
32
+ data-testid="time-unit-label"
33
+ >
34
+ {tooltipLabel ? (
35
+ <span>{`${lang(tooltipLabel!.translationKey, { count: tooltipLabel!.count })}`}</span>
36
+ ) : (
37
+ <span>{`${lang(label)}`}</span>
38
+ )}
30
39
  </div>
31
40
  ))}
32
41
  </>
33
42
  ) : (
34
43
  <TimeUnitSwitch
35
- selected={selectedTimeUnit}
36
44
  callback={setSelectedTimeUnit}
37
45
  options={timeUnitConfig}
46
+ selected={selectedTimeUnit}
38
47
  />
39
48
  )}
40
49
  <ChartWithData
41
- timeUnit={selectedTimeUnit}
42
50
  currencies={timeUnit && currencies}
51
+ timeUnit={selectedTimeUnit}
43
52
  />
44
53
  </div>
45
54
  )}
@@ -1,20 +1,26 @@
1
- import React, { useRef, useEffect } from 'react';
2
- import ReactEChartsCore from 'echarts-for-react/lib/core';
3
- import * as echarts from 'echarts/core';
4
- import { LineChart } from 'echarts/charts';
5
- import { CanvasRenderer } from 'echarts/renderers';
6
- import {
7
- GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent, MarkLineComponent,
8
- } from 'echarts/components';
9
1
  import {
10
- Theme, useLayoutProvider, getChartTheme, Size,
2
+ getChartTheme,
3
+ Size,
4
+ Theme,
5
+ useLayoutProvider,
11
6
  } from '@oanda/labs-widget-common';
12
7
  import { useLocale } from '@oanda/mono-i18n';
8
+ import { LineChart } from 'echarts/charts';
13
9
  import {
14
- CHART_HEIGHT,
15
- } from './options/constants';
16
- import { getResponsiveOption, getOption } from './options';
17
- import { ChartProps } from './types';
10
+ GraphicComponent,
11
+ GridSimpleComponent,
12
+ LegendPlainComponent,
13
+ MarkLineComponent,
14
+ TooltipComponent,
15
+ } from 'echarts/components';
16
+ import * as echarts from 'echarts/core';
17
+ import { CanvasRenderer } from 'echarts/renderers';
18
+ import ReactEChartsCore from 'echarts-for-react/lib/core';
19
+ import React, { useEffect, useRef } from 'react';
20
+
21
+ import { getOption, getResponsiveOption } from './options';
22
+ import { CHART_HEIGHT } from './options/constants';
23
+ import type { ChartProps } from './types';
18
24
 
19
25
  echarts.use([
20
26
  GridSimpleComponent,
@@ -35,7 +41,7 @@ const Chart = ({ values, timeUnit, currencies }: ChartProps) => {
35
41
  const isDesktop = size === Size.DESKTOP;
36
42
  const isMobile = size === Size.MOBILE;
37
43
 
38
- const echartRef = useRef(null);
44
+ const echartRef = useRef<ReactEChartsCore | null>(null);
39
45
 
40
46
  const chartData = currencies
41
47
  ? values.filter(({ currency }) => currencies.includes(currency))
@@ -43,25 +49,24 @@ const Chart = ({ values, timeUnit, currencies }: ChartProps) => {
43
49
 
44
50
  useEffect(() => {
45
51
  if (echartRef.current) {
46
- // @ts-ignore
47
- const echartInstance = echartRef.current.getEchartsInstance() as echarts.EChartsType;
52
+ const echartInstance = echartRef.current.getEchartsInstance();
48
53
 
49
54
  echartInstance.setOption(
50
- getResponsiveOption(isDesktop, isMobile, isDark),
55
+ getResponsiveOption(isDesktop, isMobile, isDark)
51
56
  );
52
57
  }
53
58
  }, [echartRef, isDesktop, isMobile, isDark]);
54
59
 
55
60
  return (
56
61
  <ReactEChartsCore
57
- echarts={echarts}
58
62
  ref={echartRef}
59
- theme={isDark ? 'dark_theme' : 'light_theme'}
63
+ echarts={echarts}
64
+ option={getOption(chartData, timeUnit, isDark, lang)}
60
65
  style={{
61
66
  height: `${CHART_HEIGHT}px`,
62
67
  width: '100%',
63
68
  }}
64
- option={getOption(chartData, timeUnit, isDark, lang)}
69
+ theme={isDark ? 'dark_theme' : 'light_theme'}
65
70
  />
66
71
  );
67
72
  };
@@ -1,4 +1,5 @@
1
1
  import { colorPalette } from '@oanda/labs-widget-common';
2
+
2
3
  import { CurrencyName } from '../../../../gql/types/graphql';
3
4
 
4
5
  const WEEKEND_DURATION = 172800000;
@@ -43,19 +44,19 @@ const TOOLTIP_LINE_COLOR_CONFIG = {
43
44
  };
44
45
 
45
46
  export {
46
- X_LABEL_SIZE,
47
- X_LABEL_SIZE_MOBILE,
48
- Y_LABEL_SIZE_MOBILE,
49
- Y_LABEL_SIZE,
50
- CHART_WIDTH,
47
+ CANDLE_MINUTE,
48
+ CANDLE_NUMBER_HOUR,
51
49
  CHART_HEIGHT,
50
+ CHART_WIDTH,
51
+ COLOR_CONFIG,
52
+ CURRENCIES_ORDER,
52
53
  LEGEND_HEIGHT,
53
54
  LEGEND_HEIGHT_MOBILE,
54
- VERTICAL_LINE_COUNT,
55
- COLOR_CONFIG,
56
55
  TOOLTIP_LINE_COLOR_CONFIG,
57
- CANDLE_NUMBER_HOUR,
58
- CANDLE_MINUTE,
59
- CURRENCIES_ORDER,
56
+ VERTICAL_LINE_COUNT,
60
57
  WEEKEND_DURATION,
58
+ X_LABEL_SIZE,
59
+ X_LABEL_SIZE_MOBILE,
60
+ Y_LABEL_SIZE,
61
+ Y_LABEL_SIZE_MOBILE,
61
62
  };
@@ -1,6 +1,11 @@
1
- import { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
2
- import { VERTICAL_LINE_COUNT, CURRENCIES_ORDER, COLOR_CONFIG } from './constants';
3
- import { TooltipFormatterParams } from './types';
1
+ import type { CurrencyPowerBalance } from '../../../../gql/types/graphql';
2
+ import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
3
+ import {
4
+ COLOR_CONFIG,
5
+ CURRENCIES_ORDER,
6
+ VERTICAL_LINE_COUNT,
7
+ } from './constants';
8
+ import type { TooltipFormatterParams } from './types';
4
9
 
5
10
  const getDateAndTime = (param: string) => {
6
11
  const dateAndTime = param.split('T');
@@ -11,39 +16,51 @@ const getDateAndTime = (param: string) => {
11
16
  };
12
17
  };
13
18
 
14
- const dateFormat = (date: string) => `${new Date(date).toLocaleDateString(undefined, { month: 'numeric', day: 'numeric' })}`;
19
+ const dateFormat = (date: string) =>
20
+ `${new Date(date).toLocaleDateString(undefined, { month: 'numeric', day: 'numeric' })}`;
15
21
 
16
- const dateTimeFormat = ({ date, time }: { date: string, time: string }) => `${new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: 'numeric', day: 'numeric' })}, ${time} UTC`;
22
+ const dateTimeFormat = ({ date, time }: { date: string; time: string }) =>
23
+ `${new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: 'numeric', day: 'numeric' })}, ${time} UTC`;
17
24
 
18
- const isMonthWeek = (
19
- timeUnit: CurrencyPowerBalanceTimeUnit,
20
- ) => timeUnit === CurrencyPowerBalanceTimeUnit.M3
21
- || timeUnit === CurrencyPowerBalanceTimeUnit.M1
22
- || timeUnit === CurrencyPowerBalanceTimeUnit.W1;
25
+ const isMonthWeek = (timeUnit: CurrencyPowerBalanceTimeUnit) =>
26
+ timeUnit === CurrencyPowerBalanceTimeUnit.M3 ||
27
+ timeUnit === CurrencyPowerBalanceTimeUnit.M1 ||
28
+ timeUnit === CurrencyPowerBalanceTimeUnit.W1;
23
29
 
24
- const xAxisLabelFormatter = (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => {
30
+ const xAxisLabelFormatter = (
31
+ label: string,
32
+ timeUnit: CurrencyPowerBalanceTimeUnit
33
+ ) => {
25
34
  const { date, time } = getDateAndTime(label);
26
35
  const isDateFormat = isMonthWeek(timeUnit) || time === '00:00';
27
36
 
28
37
  return isDateFormat ? dateFormat(date) : time;
29
38
  };
30
39
 
31
- const intervalFormatter = (
32
- dataLength: number,
33
- ) => Math.round(dataLength / VERTICAL_LINE_COUNT);
40
+ const intervalFormatter = (dataLength: number) =>
41
+ Math.round(dataLength / VERTICAL_LINE_COUNT);
34
42
 
35
43
  const tooltipFormatter = (values: TooltipFormatterParams[]) => {
36
44
  const date = dateTimeFormat(getDateAndTime(values[0].value[0]));
37
45
 
38
46
  const row = values
39
- .sort(({ value: valueA }, { value: valueB }) => Number(valueB[1]) - Number(valueA[1]))
40
- .map(({ marker, seriesName, value }) => `<div style="display:flex;align-items:center;">
47
+ .sort(
48
+ ({ value: valueA }, { value: valueB }) =>
49
+ Number(valueB[1]) - Number(valueA[1])
50
+ )
51
+ .map(
52
+ ({
53
+ marker,
54
+ seriesName,
55
+ value,
56
+ }) => `<div style="display:flex;align-items:center;">
41
57
  <div style="display:flex;align-items:center;width:50px;margin-right:10px;">
42
58
  ${marker}
43
59
  <span>${seriesName}</span>
44
60
  </div>
45
61
  <span>${value[1]}</span>
46
- </div>`);
62
+ </div>`
63
+ );
47
64
 
48
65
  return `<div style="display:flex; flex-direction:column;">
49
66
  <span style="margin-bottom:5px;">${date}</span>
@@ -54,9 +71,12 @@ const tooltipFormatter = (values: TooltipFormatterParams[]) => {
54
71
  const formatLegendData = (values: CurrencyPowerBalance[]) => {
55
72
  const dataCurrencies = values.map(({ currency }) => currency);
56
73
 
57
- const list = dataCurrencies.length === CURRENCIES_ORDER.length
58
- ? CURRENCIES_ORDER
59
- : CURRENCIES_ORDER.filter((currency) => dataCurrencies.includes(currency));
74
+ const list =
75
+ dataCurrencies.length === CURRENCIES_ORDER.length
76
+ ? CURRENCIES_ORDER
77
+ : CURRENCIES_ORDER.filter((currency) =>
78
+ dataCurrencies.includes(currency)
79
+ );
60
80
 
61
81
  return list.map((currency) => ({
62
82
  name: currency,
@@ -67,9 +87,9 @@ const formatLegendData = (values: CurrencyPowerBalance[]) => {
67
87
  };
68
88
 
69
89
  export {
90
+ formatLegendData,
91
+ intervalFormatter,
70
92
  isMonthWeek,
71
93
  tooltipFormatter,
72
94
  xAxisLabelFormatter,
73
- intervalFormatter,
74
- formatLegendData,
75
95
  };