@oanda/labs-live-rates-table-widget 1.0.38 → 1.0.40

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 (122) hide show
  1. package/CHANGELOG.md +324 -0
  2. package/dist/main/LiveRatesTableWidget/LiveRatesTableWidget.js +25 -27
  3. package/dist/main/LiveRatesTableWidget/LiveRatesTableWidget.js.map +1 -1
  4. package/dist/main/LiveRatesTableWidget/Main.js +16 -16
  5. package/dist/main/LiveRatesTableWidget/Main.js.map +1 -1
  6. package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js +17 -17
  7. package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +1 -1
  8. package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js +6 -6
  9. package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js.map +1 -1
  10. package/dist/main/LiveRatesTableWidget/components/Cards/types.js.map +1 -1
  11. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +4 -4
  12. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
  13. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js.map +1 -1
  14. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +1 -1
  15. package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js +25 -27
  16. package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +1 -1
  17. package/dist/main/LiveRatesTableWidget/components/index.js +12 -12
  18. package/dist/main/LiveRatesTableWidget/components/index.js.map +1 -1
  19. package/dist/main/LiveRatesTableWidget/config.js.map +1 -1
  20. package/dist/main/LiveRatesTableWidget/constant.js.map +1 -1
  21. package/dist/main/LiveRatesTableWidget/render.js +6 -6
  22. package/dist/main/LiveRatesTableWidget/render.js.map +1 -1
  23. package/dist/main/LiveRatesTableWidget/types.js +1 -1
  24. package/dist/main/LiveRatesTableWidget/types.js.map +1 -1
  25. package/dist/main/LiveRatesTableWidget/utils.js +2 -2
  26. package/dist/main/LiveRatesTableWidget/utils.js.map +1 -1
  27. package/dist/main/gql/types/fragment-masking.js.map +1 -1
  28. package/dist/main/gql/types/gql.js +2 -2
  29. package/dist/main/gql/types/gql.js.map +1 -1
  30. package/dist/main/gql/types/graphql.js +142 -142
  31. package/dist/main/gql/types/graphql.js.map +1 -1
  32. package/dist/main/gql/types/index.js.map +1 -1
  33. package/dist/main/index.js +8 -8
  34. package/dist/main/index.js.map +1 -1
  35. package/dist/main/translations/index.js +1 -1
  36. package/dist/main/translations/index.js.map +1 -1
  37. package/dist/main/translations/translations.js.map +1 -1
  38. package/dist/module/LiveRatesTableWidget/LiveRatesTableWidget.js +26 -28
  39. package/dist/module/LiveRatesTableWidget/LiveRatesTableWidget.js.map +1 -1
  40. package/dist/module/LiveRatesTableWidget/Main.js +18 -18
  41. package/dist/module/LiveRatesTableWidget/Main.js.map +1 -1
  42. package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js +18 -18
  43. package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +1 -1
  44. package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js +6 -6
  45. package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js.map +1 -1
  46. package/dist/module/LiveRatesTableWidget/components/Cards/types.js.map +1 -1
  47. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +4 -4
  48. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
  49. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js.map +1 -1
  50. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js +1 -1
  51. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +1 -1
  52. package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js +25 -25
  53. package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +1 -1
  54. package/dist/module/LiveRatesTableWidget/components/index.js +2 -2
  55. package/dist/module/LiveRatesTableWidget/components/index.js.map +1 -1
  56. package/dist/module/LiveRatesTableWidget/config.js.map +1 -1
  57. package/dist/module/LiveRatesTableWidget/constant.js +1 -1
  58. package/dist/module/LiveRatesTableWidget/constant.js.map +1 -1
  59. package/dist/module/LiveRatesTableWidget/render.js +6 -6
  60. package/dist/module/LiveRatesTableWidget/render.js.map +1 -1
  61. package/dist/module/LiveRatesTableWidget/types.js +1 -1
  62. package/dist/module/LiveRatesTableWidget/types.js.map +1 -1
  63. package/dist/module/LiveRatesTableWidget/utils.js +3 -3
  64. package/dist/module/LiveRatesTableWidget/utils.js.map +1 -1
  65. package/dist/module/gql/types/fragment-masking.js.map +1 -1
  66. package/dist/module/gql/types/gql.js +2 -2
  67. package/dist/module/gql/types/gql.js.map +1 -1
  68. package/dist/module/gql/types/graphql.js +142 -142
  69. package/dist/module/gql/types/graphql.js.map +1 -1
  70. package/dist/module/gql/types/index.js +2 -2
  71. package/dist/module/gql/types/index.js.map +1 -1
  72. package/dist/module/index.js +1 -1
  73. package/dist/module/index.js.map +1 -1
  74. package/dist/module/translations/index.js +1 -1
  75. package/dist/module/translations/index.js.map +1 -1
  76. package/dist/module/translations/translations.js.map +1 -1
  77. package/dist/types/LiveRatesTableWidget/LiveRatesTableWidget.d.ts +1 -1
  78. package/dist/types/LiveRatesTableWidget/Main.d.ts +1 -1
  79. package/dist/types/LiveRatesTableWidget/components/CardWithData/CardWithData.d.ts +1 -1
  80. package/dist/types/LiveRatesTableWidget/components/Cards/Cards.d.ts +1 -1
  81. package/dist/types/LiveRatesTableWidget/components/Cards/types.d.ts +2 -2
  82. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.d.ts +1 -1
  83. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/types.d.ts +3 -3
  84. package/dist/types/LiveRatesTableWidget/components/RowWithData/RowWithData.d.ts +1 -1
  85. package/dist/types/LiveRatesTableWidget/components/index.d.ts +2 -2
  86. package/dist/types/LiveRatesTableWidget/config.d.ts +1 -1
  87. package/dist/types/LiveRatesTableWidget/constant.d.ts +1 -1
  88. package/dist/types/LiveRatesTableWidget/types.d.ts +4 -4
  89. package/dist/types/LiveRatesTableWidget/utils.d.ts +5 -4
  90. package/dist/types/gql/types/gql.d.ts +4 -4
  91. package/dist/types/gql/types/index.d.ts +2 -2
  92. package/dist/types/index.d.ts +1 -1
  93. package/dist/types/translations/index.d.ts +2 -2
  94. package/package.json +3 -3
  95. package/src/LiveRatesTableWidget/LiveRatesTableWidget.tsx +28 -35
  96. package/src/LiveRatesTableWidget/Main.tsx +50 -44
  97. package/src/LiveRatesTableWidget/components/CardWithData/CardWithData.tsx +43 -28
  98. package/src/LiveRatesTableWidget/components/Cards/Cards.tsx +15 -8
  99. package/src/LiveRatesTableWidget/components/Cards/types.tsx +2 -2
  100. package/src/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.tsx +12 -10
  101. package/src/LiveRatesTableWidget/components/LineChartWithData/types.tsx +4 -3
  102. package/src/LiveRatesTableWidget/components/LineChartWithData/utils.ts +1 -1
  103. package/src/LiveRatesTableWidget/components/RowWithData/RowWithData.tsx +64 -31
  104. package/src/LiveRatesTableWidget/components/index.ts +2 -2
  105. package/src/LiveRatesTableWidget/config.ts +2 -4
  106. package/src/LiveRatesTableWidget/constant.ts +4 -1
  107. package/src/LiveRatesTableWidget/render.tsx +52 -34
  108. package/src/LiveRatesTableWidget/types.tsx +5 -4
  109. package/src/LiveRatesTableWidget/utils.ts +20 -17
  110. package/src/gql/types/fragment-masking.ts +41 -21
  111. package/src/gql/types/gql.ts +12 -5
  112. package/src/gql/types/graphql.ts +214 -49
  113. package/src/gql/types/index.ts +2 -2
  114. package/src/index.ts +1 -1
  115. package/src/translations/index.ts +4 -4
  116. package/src/translations/translations.ts +2 -1
  117. package/test/CardWithData.test.tsx +16 -12
  118. package/test/Cards.test.tsx +48 -40
  119. package/test/LineChartWithData.test.tsx +77 -32
  120. package/test/Main.test.tsx +14 -11
  121. package/test/RowWithData.test.tsx +21 -17
  122. package/test/mocks.ts +1 -3
@@ -1,7 +1,7 @@
1
- import { WidgetConfig } from '@oanda/labs-widget-common';
2
- import { Division } from '../gql/types/graphql';
3
- export { Locale } from '@oanda/mono-i18n';
1
+ import type { WidgetConfig } from '@oanda/labs-widget-common';
2
+ import type { Division } from '../gql/types/graphql';
4
3
  export { Division } from '../gql/types/graphql';
4
+ export { Locale } from '@oanda/mono-i18n';
5
5
  export declare enum View {
6
6
  TABLE = "table",
7
7
  CARDS = "cards"
@@ -31,7 +31,7 @@ export interface Sentiment {
31
31
  shortPercent: number;
32
32
  longPercent: number;
33
33
  }
34
- export type EmptyRecord = Record<any, never>;
34
+ export type EmptyRecord = Record<string, never>;
35
35
  export interface DataRecord {
36
36
  [key: string]: string | number | undefined;
37
37
  instrument: string;
@@ -1,6 +1,7 @@
1
- import { HeaderColumns, LiveRatesErrorMessage } from '@oanda/labs-widget-common';
2
- import { ColumnsNames, DataRecord, EmptyRecord } from './types';
3
- import { ValidateInstrumentsQuery } from '../gql/types/graphql';
1
+ import type { HeaderColumns, LiveRatesErrorMessage } from '@oanda/labs-widget-common';
2
+ import type { ValidateInstrumentsQuery } from '../gql/types/graphql';
3
+ import type { DataRecord, EmptyRecord } from './types';
4
+ import { ColumnsNames } from './types';
4
5
  declare const getRecords: (data: ValidateInstrumentsQuery) => {
5
6
  instrument: string;
6
7
  displayName: string;
@@ -11,4 +12,4 @@ declare const useRecords: (record: DataRecord | EmptyRecord, target: EventTarget
11
12
  error: LiveRatesErrorMessage | null;
12
13
  ref: (node?: Element | null) => void;
13
14
  };
14
- export { getRecords, getHeaderConfig, useRecords, };
15
+ export { getHeaderConfig, getRecords, useRecords };
@@ -11,11 +11,11 @@ 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 GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n": DocumentNode<types.GetInstrumentsChartQuery, types.Exact<{
14
+ '\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n': DocumentNode<types.GetInstrumentsChartQuery, types.Exact<{
15
15
  instruments?: types.InputMaybe<Array<types.Scalars["String"]["input"]> | types.Scalars["String"]["input"]>;
16
16
  division?: types.InputMaybe<types.Division>;
17
17
  }>>;
18
- "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n": DocumentNode<types.ValidateInstrumentsQuery, types.Exact<{
18
+ '\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n': DocumentNode<types.ValidateInstrumentsQuery, types.Exact<{
19
19
  instruments: Array<types.InputMaybe<types.Scalars["String"]["input"]>> | types.InputMaybe<types.Scalars["String"]["input"]>;
20
20
  division?: types.InputMaybe<types.Division>;
21
21
  }>>;
@@ -36,10 +36,10 @@ export declare function graphql(source: string): unknown;
36
36
  /**
37
37
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
38
38
  */
39
- export declare function graphql(source: "\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n"): (typeof documents)["\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n"];
39
+ export declare function graphql(source: '\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n'): (typeof documents)['\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n'];
40
40
  /**
41
41
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
42
42
  */
43
- export declare function graphql(source: "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n"): (typeof documents)["\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n"];
43
+ export declare function graphql(source: '\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n'): (typeof documents)['\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n'];
44
44
  export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
45
45
  export {};
@@ -1,2 +1,2 @@
1
- export * from "./fragment-masking";
2
- export * from "./gql";
1
+ export * from './fragment-masking';
2
+ export * from './gql';
@@ -1,2 +1,2 @@
1
- export * from './LiveRatesTableWidget/types';
2
1
  export * from './LiveRatesTableWidget/LiveRatesTableWidget';
2
+ export * from './LiveRatesTableWidget/types';
@@ -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-live-rates-table-widget",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "description": "Labs Live Rates Table 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.172",
15
+ "@oanda/labs-widget-common": "^1.0.174",
16
16
  "@oanda/mono-i18n": "10.0.1",
17
17
  "graphql": "16.8.1"
18
18
  },
@@ -20,5 +20,5 @@
20
20
  "@graphql-codegen/cli": "5.0.0",
21
21
  "@graphql-codegen/client-preset": "4.1.0"
22
22
  },
23
- "gitHead": "f3c94dbb01bc271f175ba95700c51001c4099a52"
23
+ "gitHead": "4c5d84b00c7fbf3acd7ef27634fbd2a9ef0afd6b"
24
24
  }
@@ -1,14 +1,12 @@
1
+ import { ApolloClient, InMemoryCache } from '@apollo/client';
2
+ import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
1
3
  import React from 'react';
2
- import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
3
- import { LocaleProvider } from '@oanda/mono-i18n';
4
- import {
5
- ChartError, LiveRatesProvider, ThemeProvider, getLocale,
6
- renderComponent,
7
- } from '@oanda/labs-widget-common';
4
+
8
5
  import { translations } from '../translations';
9
- import { Main } from './Main';
10
- import { Division, LiveRatesTableConfig } from './types';
11
6
  import { sizeConfig } from './config';
7
+ import { Main } from './Main';
8
+ import type { LiveRatesTableConfig } from './types';
9
+ import { Division } from './types';
12
10
 
13
11
  const LiveRatesTableWidget = ({
14
12
  graphqlUrl,
@@ -32,33 +30,28 @@ const LiveRatesTableWidget = ({
32
30
  const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';
33
31
 
34
32
  return (
35
- <ThemeProvider removePadding={removePadding} theme={theme} size={view && sizeConfig[view]}>
36
- <LocaleProvider locale={getLocale(locale)} translations={translations}>
37
- <LiveRatesProvider
38
- url={liveRatesUrl}
39
- options={{ divisionCode, dataSource }}
40
- >
41
- <ApolloProvider client={client}>
42
- {isParamError ? (
43
- <div className="lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
44
- <ChartError />
45
- </div>
46
- )
47
- : (
48
- renderComponent({
49
- Component: <Main
50
- instruments={instruments}
51
- division={division}
52
- columns={columns}
53
- />,
54
- logoLink,
55
- linkArea: 'logo',
56
- })
57
- )}
58
- </ApolloProvider>
59
- </LiveRatesProvider>
60
- </LocaleProvider>
61
- </ThemeProvider>
33
+ <WidgetProvider
34
+ client={client}
35
+ liveRates={{
36
+ url: liveRatesUrl,
37
+ options: { divisionCode, dataSource },
38
+ }}
39
+ locale={locale}
40
+ styling={{
41
+ removePadding,
42
+ size: view && sizeConfig[view],
43
+ }}
44
+ theme={theme}
45
+ translations={translations}
46
+ >
47
+ <WidgetWrapper
48
+ isParamError={isParamError}
49
+ linkArea="logo"
50
+ logoLink={logoLink}
51
+ >
52
+ <Main columns={columns} division={division} instruments={instruments} />
53
+ </WidgetWrapper>
54
+ </WidgetProvider>
62
55
  );
63
56
  };
64
57
 
@@ -1,34 +1,38 @@
1
- import React, { useEffect, useState, useContext } from 'react';
2
1
  import { useQuery } from '@apollo/client';
3
2
  import {
4
3
  Size,
5
4
  Table,
6
- ThemeContext,
7
5
  Tooltip,
6
+ useLayoutProvider,
8
7
  useLiveRatesQuery,
9
8
  } from '@oanda/labs-widget-common';
10
- import { getHeaderConfig, getRecords } from './utils';
11
- import { DataRecord, MainProps } from './types';
12
- import { RowWithData, Cards } from './components';
13
- import {
14
- DEFAULT_COLUMNS, INSTRUMENT_TOOLTIP_ID,
15
- } from './constant';
9
+ import React, { useEffect, useState } from 'react';
10
+
11
+ import type {
12
+ ValidateInstrumentsQuery,
13
+ ValidateInstrumentsQueryVariables,
14
+ } from '../gql/types/graphql';
16
15
  import { validateInstruments } from '../gql/validateInstruments';
17
- import { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';
16
+ import { Cards, RowWithData } from './components';
17
+ import { DEFAULT_COLUMNS, INSTRUMENT_TOOLTIP_ID } from './constant';
18
+ import type { DataRecord, MainProps } from './types';
19
+ import { getHeaderConfig, getRecords } from './utils';
18
20
 
19
21
  const Main = ({
20
22
  instruments,
21
23
  division,
22
24
  columns = DEFAULT_COLUMNS,
23
25
  }: MainProps) => {
24
- const { size } = useContext(ThemeContext);
26
+ const { size } = useLayoutProvider();
25
27
  const isDesktop = size === Size.DESKTOP;
26
28
  const { target, setQuery } = useLiveRatesQuery();
27
- const [records, setRecords] = useState<DataRecord[]>(new Array(instruments.length).fill({}));
29
+ const [records, setRecords] = useState<DataRecord[]>(
30
+ new Array(instruments.length).fill({})
31
+ );
28
32
 
29
33
  const { loading, data, error } = useQuery<
30
- ValidateInstrumentsQuery,
31
- ValidateInstrumentsQueryVariables
34
+ ValidateInstrumentsQuery,
35
+ ValidateInstrumentsQueryVariables
32
36
  >(validateInstruments, {
33
37
  variables: {
34
38
  instruments,
@@ -41,7 +45,6 @@ const Main = ({
41
45
  if (!loading && data) {
42
46
  setRecords(getRecords(data)!);
43
47
  }
44
- // eslint-disable-next-line react-hooks/exhaustive-deps
45
48
  }, [loading, data]);
46
49
 
47
50
  const instrumentsNames = records.map(({ instrument }) => instrument);
@@ -58,39 +61,42 @@ const Main = ({
58
61
  return (
59
62
  <>
60
63
  {size && (
61
- <div data-testid="live-rates-table-wrapper" className="lw-relative lw-text-sm lw-tracking-normal lw-text-text-primary">
62
- {isDesktop ? (
63
- <div className="lw-border lw-border-solid lw-border-border-primary">
64
- <Table<DataRecord>
64
+ <div
65
+ className="lw-relative lw-text-sm lw-tracking-normal lw-text-text-primary"
66
+ data-testid="live-rates-table-wrapper"
67
+ >
68
+ {isDesktop ? (
69
+ <div className="lw-border lw-border-solid lw-border-border-primary">
70
+ <Table<DataRecord>
71
+ headerConfig={getHeaderConfig(columns)}
72
+ isError={showError}
73
+ records={records}
74
+ renderRow={(record, index, isScrolled) => (
75
+ <RowWithData
76
+ key={`row_${index}`}
77
+ activeColumns={columns}
78
+ division={division}
79
+ hasBackgroundColor={index % 2 === 0}
80
+ isScrolled={isScrolled}
81
+ loading={loading}
82
+ record={record}
83
+ target={target}
84
+ />
85
+ )}
86
+ />
87
+ </div>
88
+ ) : (
89
+ <Cards
90
+ columns={columns}
91
+ division={division}
65
92
  isError={showError}
93
+ isLoading={loading}
66
94
  records={records}
67
- headerConfig={getHeaderConfig(columns)}
68
- renderRow={(record, index, isScrolled) => (
69
- <RowWithData
70
- isScrolled={isScrolled}
71
- loading={loading}
72
- key={`row_${index}`}
73
- record={record}
74
- target={target}
75
- hasBackgroundColor={index % 2 === 0}
76
- activeColumns={columns}
77
- division={division}
78
- />
79
- )}
95
+ target={target}
80
96
  />
81
- </div>
82
- ) : (
83
- <Cards
84
- records={records}
85
- division={division}
86
- target={target}
87
- columns={columns}
88
- isError={showError}
89
- isLoading={loading}
90
- />
91
- )}
92
- <Tooltip id={INSTRUMENT_TOOLTIP_ID} />
93
- </div>
97
+ )}
98
+ <Tooltip id={INSTRUMENT_TOOLTIP_ID} />
99
+ </div>
94
100
  )}
95
101
  </>
96
102
  );
@@ -1,18 +1,20 @@
1
- import React from 'react';
2
1
  import {
2
+ ArrowPosition,
3
3
  Card,
4
4
  CardHeader,
5
5
  CardRow,
6
- Price,
7
- ArrowPosition,
8
6
  LineChartSize,
7
+ Price,
9
8
  Truncate,
10
9
  } from '@oanda/labs-widget-common';
11
10
  import { useLocale } from '@oanda/mono-i18n';
12
- import { ColumnsNames, CardWithDataProps } from '../../types';
13
- import { LineChartWithData } from '../LineChartWithData';
14
- import { useRecords } from '../../utils';
11
+ import React from 'react';
12
+
15
13
  import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
14
+ import type { CardWithDataProps } from '../../types';
15
+ import { ColumnsNames } from '../../types';
16
+ import { useRecords } from '../../utils';
17
+ import { LineChartWithData } from '../LineChartWithData';
16
18
 
17
19
  const CardWithData = ({
18
20
  isLoading,
@@ -23,26 +25,35 @@ const CardWithData = ({
23
25
  division,
24
26
  isLast,
25
27
  }: CardWithDataProps) => {
26
- const { updatedRecord, error, ref } = useRecords(record, record.instrument ? target : null);
28
+ const { updatedRecord, error, ref } = useRecords(
29
+ record,
30
+ record.instrument ? target : null
31
+ );
27
32
  const { lang } = useLocale();
28
33
 
29
- const checkLoading = (id: string) => isLoading || (!error && updatedRecord?.[id] === undefined);
34
+ const checkLoading = (id: string) =>
35
+ isLoading || (!error && updatedRecord?.[id] === undefined);
30
36
 
31
37
  return (
32
38
  <Card ref={ref} data-testid="card" withoutBottomBorder={!isLast}>
33
39
  <CardHeader
34
40
  isLoading={isLoading}
35
41
  number={index}
36
- title={<Truncate text={record.displayName} tooltipId={INSTRUMENT_TOOLTIP_ID} />}
42
+ title={
43
+ <Truncate
44
+ text={record.displayName}
45
+ tooltipId={INSTRUMENT_TOOLTIP_ID}
46
+ />
47
+ }
37
48
  >
38
49
  {activeColumns.includes(ColumnsNames.CHART) && (
39
- <LineChartWithData
40
- division={division}
41
- isLoading={checkLoading('instrument')}
42
- size={LineChartSize.xs}
43
- padding={4}
44
- record={updatedRecord}
45
- />
50
+ <LineChartWithData
51
+ division={division}
52
+ isLoading={checkLoading('instrument')}
53
+ padding={4}
54
+ record={updatedRecord}
55
+ size={LineChartSize.xs}
56
+ />
46
57
  )}
47
58
  </CardHeader>
48
59
  {activeColumns.map((item) => {
@@ -50,16 +61,18 @@ const CardWithData = ({
50
61
  return (
51
62
  <CardRow
52
63
  key={ColumnsNames.SELL}
53
- label={lang('sell_price')}
54
- isLoading={checkLoading(ColumnsNames.SELL)}
55
64
  isError={!!error}
65
+ isLoading={checkLoading(ColumnsNames.SELL)}
66
+ label={lang('sell_price')}
56
67
  >
57
68
  <Price
58
69
  arrowPosition={ArrowPosition.left}
59
- priceMovement={updatedRecord.sellPriceMovement}
60
70
  movementIndicator="arrow"
71
+ priceMovement={updatedRecord.sellPriceMovement}
61
72
  >
62
- <span>{updatedRecord.sell?.toFixed(updatedRecord.displayPrecision)}</span>
73
+ <span>
74
+ {updatedRecord.sell?.toFixed(updatedRecord.displayPrecision)}
75
+ </span>
63
76
  </Price>
64
77
  </CardRow>
65
78
  );
@@ -69,16 +82,18 @@ const CardWithData = ({
69
82
  return (
70
83
  <CardRow
71
84
  key={ColumnsNames.BUY}
72
- label={lang('buy_price')}
73
- isLoading={checkLoading(ColumnsNames.BUY)}
74
85
  isError={!!error}
86
+ isLoading={checkLoading(ColumnsNames.BUY)}
87
+ label={lang('buy_price')}
75
88
  >
76
89
  <Price
77
90
  arrowPosition={ArrowPosition.left}
78
- priceMovement={updatedRecord.buyPriceMovement}
79
91
  movementIndicator="arrow"
92
+ priceMovement={updatedRecord.buyPriceMovement}
80
93
  >
81
- <span>{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}</span>
94
+ <span>
95
+ {updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}
96
+ </span>
82
97
  </Price>
83
98
  </CardRow>
84
99
  );
@@ -88,9 +103,9 @@ const CardWithData = ({
88
103
  return (
89
104
  <CardRow
90
105
  key={ColumnsNames.DAILY_CHANGE}
91
- label={lang('daily_percent_change')}
92
- isLoading={checkLoading('dailyPercentChange')}
93
106
  isError={!!error}
107
+ isLoading={checkLoading('dailyPercentChange')}
108
+ label={lang('daily_percent_change')}
94
109
  >
95
110
  <span>{updatedRecord.dailyPercentChange}</span>
96
111
  </CardRow>
@@ -101,9 +116,9 @@ const CardWithData = ({
101
116
  return (
102
117
  <CardRow
103
118
  key={ColumnsNames.SPREAD}
104
- label={lang('spread')}
105
- isLoading={checkLoading(ColumnsNames.SPREAD)}
106
119
  isError={!!error}
120
+ isLoading={checkLoading(ColumnsNames.SPREAD)}
121
+ label={lang('spread')}
107
122
  >
108
123
  <span>{updatedRecord.spread}</span>
109
124
  </CardRow>
@@ -1,10 +1,17 @@
1
- import React from 'react';
2
1
  import { Card, ChartError } from '@oanda/labs-widget-common';
2
+ import React from 'react';
3
+
3
4
  import { CardWithData } from '../CardWithData/CardWithData';
4
- import { CardsProps } from './types';
5
+ import type { CardsProps } from './types';
5
6
 
6
7
  const Cards = ({
7
- records, target, columns, isError, isLoading, division, startIndex = 0,
8
+ records,
9
+ target,
10
+ columns,
11
+ isError,
12
+ isLoading,
13
+ division,
14
+ startIndex = 0,
8
15
  }: CardsProps) => (
9
16
  <>
10
17
  {isError ? (
@@ -18,14 +25,14 @@ const Cards = ({
18
25
  {records.map((record, index) => (
19
26
  <div key={`card_${startIndex + index}`}>
20
27
  <CardWithData
21
- index={startIndex + index + 1}
22
- division={division}
23
- record={record}
24
- target={target}
25
28
  activeColumns={columns}
29
+ division={division}
30
+ index={startIndex + index + 1}
26
31
  isError={isError}
27
- isLoading={isLoading}
28
32
  isLast={index + 1 === records.length}
33
+ isLoading={isLoading}
34
+ record={record}
35
+ target={target}
29
36
  />
30
37
  </div>
31
38
  ))}
@@ -1,5 +1,5 @@
1
- import { Division } from '../../../gql/types/graphql';
2
- import { ColumnsNames, DataRecord } from '../../types';
1
+ import type { Division } from '../../../gql/types/graphql';
2
+ import type { ColumnsNames, DataRecord } from '../../types';
3
3
 
4
4
  export interface CardsProps {
5
5
  startIndex?: number;
@@ -1,11 +1,13 @@
1
- import React from 'react';
2
1
  import { useQuery } from '@apollo/client';
3
- import {
4
- LineChart, Loader, LoaderSize,
5
- } from '@oanda/labs-widget-common';
6
- import { LineChartWithDataProps } from './types';
2
+ import { LineChart, Loader, LoaderSize } from '@oanda/labs-widget-common';
3
+ import React from 'react';
4
+
7
5
  import { getInstrumentsChart } from '../../../gql/getInstrumentsChart';
8
- import { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../../../gql/types/graphql';
6
+ import type {
7
+ GetInstrumentsChartQuery,
8
+ GetInstrumentsChartQueryVariables,
9
+ } from '../../../gql/types/graphql';
10
+ import type { LineChartWithDataProps } from './types';
9
11
  import { getChartColor } from './utils';
10
12
 
11
13
  const LineChartWithData = ({
@@ -17,8 +19,8 @@ const LineChartWithData = ({
17
19
  isDarkMode = false,
18
20
  }: LineChartWithDataProps) => {
19
21
  const { loading, data } = useQuery<
20
- GetInstrumentsChartQuery,
21
- GetInstrumentsChartQueryVariables
22
+ GetInstrumentsChartQuery,
23
+ GetInstrumentsChartQueryVariables
22
24
  >(getInstrumentsChart, {
23
25
  variables: {
24
26
  instruments: [record.instrument],
@@ -38,10 +40,10 @@ const LineChartWithData = ({
38
40
  {showLoader && <Loader size={LoaderSize.md} />}
39
41
  {!showLoader && (
40
42
  <LineChart
41
- padding={padding}
42
- size={size}
43
43
  color={chartColor}
44
44
  data={chart}
45
+ padding={padding}
46
+ size={size}
45
47
  />
46
48
  )}
47
49
  </>
@@ -1,6 +1,7 @@
1
- import { LineChartSize } from '@oanda/labs-widget-common';
2
- import { DataRecord } from '../../types';
3
- import { Division } from '../../../gql/types/graphql';
1
+ import type { LineChartSize } from '@oanda/labs-widget-common';
2
+
3
+ import type { Division } from '../../../gql/types/graphql';
4
+ import type { DataRecord } from '../../types';
4
5
 
5
6
  export interface LineChartWithDataProps {
6
7
  padding?: number;
@@ -1,4 +1,4 @@
1
- import { lightTheme, darkTheme } from '@oanda/labs-widget-common';
1
+ import { darkTheme, lightTheme } from '@oanda/labs-widget-common';
2
2
 
3
3
  export const getChartColor = (dailyChange?: string, isDarkMode?: boolean) => {
4
4
  const theme = isDarkMode ? darkTheme : lightTheme;