@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.
- package/CHANGELOG.md +324 -0
- package/dist/main/LiveRatesTableWidget/LiveRatesTableWidget.js +25 -27
- package/dist/main/LiveRatesTableWidget/LiveRatesTableWidget.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/Main.js +16 -16
- package/dist/main/LiveRatesTableWidget/Main.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js +17 -17
- package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js +6 -6
- package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/Cards/types.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +4 -4
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js +25 -27
- package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/index.js +12 -12
- package/dist/main/LiveRatesTableWidget/components/index.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/config.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/constant.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/render.js +6 -6
- package/dist/main/LiveRatesTableWidget/render.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/types.js +1 -1
- package/dist/main/LiveRatesTableWidget/types.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/utils.js +2 -2
- package/dist/main/LiveRatesTableWidget/utils.js.map +1 -1
- package/dist/main/gql/types/fragment-masking.js.map +1 -1
- package/dist/main/gql/types/gql.js +2 -2
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +142 -142
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/main/gql/types/index.js.map +1 -1
- package/dist/main/index.js +8 -8
- package/dist/main/index.js.map +1 -1
- package/dist/main/translations/index.js +1 -1
- package/dist/main/translations/index.js.map +1 -1
- package/dist/main/translations/translations.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/LiveRatesTableWidget.js +26 -28
- package/dist/module/LiveRatesTableWidget/LiveRatesTableWidget.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/Main.js +18 -18
- package/dist/module/LiveRatesTableWidget/Main.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js +18 -18
- package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js +6 -6
- package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/Cards/types.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +4 -4
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js +1 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js +25 -25
- package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/index.js +2 -2
- package/dist/module/LiveRatesTableWidget/components/index.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/config.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/constant.js +1 -1
- package/dist/module/LiveRatesTableWidget/constant.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/render.js +6 -6
- package/dist/module/LiveRatesTableWidget/render.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/types.js +1 -1
- package/dist/module/LiveRatesTableWidget/types.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/utils.js +3 -3
- package/dist/module/LiveRatesTableWidget/utils.js.map +1 -1
- package/dist/module/gql/types/fragment-masking.js.map +1 -1
- package/dist/module/gql/types/gql.js +2 -2
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +142 -142
- package/dist/module/gql/types/graphql.js.map +1 -1
- package/dist/module/gql/types/index.js +2 -2
- package/dist/module/gql/types/index.js.map +1 -1
- package/dist/module/index.js +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/translations/index.js +1 -1
- package/dist/module/translations/index.js.map +1 -1
- package/dist/module/translations/translations.js.map +1 -1
- package/dist/types/LiveRatesTableWidget/LiveRatesTableWidget.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/Main.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/components/CardWithData/CardWithData.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/components/Cards/Cards.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/components/Cards/types.d.ts +2 -2
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/types.d.ts +3 -3
- package/dist/types/LiveRatesTableWidget/components/RowWithData/RowWithData.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/components/index.d.ts +2 -2
- package/dist/types/LiveRatesTableWidget/config.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/constant.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/types.d.ts +4 -4
- package/dist/types/LiveRatesTableWidget/utils.d.ts +5 -4
- package/dist/types/gql/types/gql.d.ts +4 -4
- package/dist/types/gql/types/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/translations/index.d.ts +2 -2
- package/package.json +3 -3
- package/src/LiveRatesTableWidget/LiveRatesTableWidget.tsx +28 -35
- package/src/LiveRatesTableWidget/Main.tsx +50 -44
- package/src/LiveRatesTableWidget/components/CardWithData/CardWithData.tsx +43 -28
- package/src/LiveRatesTableWidget/components/Cards/Cards.tsx +15 -8
- package/src/LiveRatesTableWidget/components/Cards/types.tsx +2 -2
- package/src/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.tsx +12 -10
- package/src/LiveRatesTableWidget/components/LineChartWithData/types.tsx +4 -3
- package/src/LiveRatesTableWidget/components/LineChartWithData/utils.ts +1 -1
- package/src/LiveRatesTableWidget/components/RowWithData/RowWithData.tsx +64 -31
- package/src/LiveRatesTableWidget/components/index.ts +2 -2
- package/src/LiveRatesTableWidget/config.ts +2 -4
- package/src/LiveRatesTableWidget/constant.ts +4 -1
- package/src/LiveRatesTableWidget/render.tsx +52 -34
- package/src/LiveRatesTableWidget/types.tsx +5 -4
- package/src/LiveRatesTableWidget/utils.ts +20 -17
- package/src/gql/types/fragment-masking.ts +41 -21
- package/src/gql/types/gql.ts +12 -5
- package/src/gql/types/graphql.ts +214 -49
- package/src/gql/types/index.ts +2 -2
- package/src/index.ts +1 -1
- package/src/translations/index.ts +4 -4
- package/src/translations/translations.ts +2 -1
- package/test/CardWithData.test.tsx +16 -12
- package/test/Cards.test.tsx +48 -40
- package/test/LineChartWithData.test.tsx +77 -32
- package/test/Main.test.tsx +14 -11
- package/test/RowWithData.test.tsx +21 -17
- 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<
|
|
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 {
|
|
3
|
-
import {
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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
|
|
2
|
-
export * from
|
|
1
|
+
export * from './fragment-masking';
|
|
2
|
+
export * from './gql';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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": "
|
|
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
|
-
|
|
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
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 {
|
|
11
|
-
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from '
|
|
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 {
|
|
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 } =
|
|
26
|
+
const { size } = useLayoutProvider();
|
|
25
27
|
const isDesktop = size === Size.DESKTOP;
|
|
26
28
|
const { target, setQuery } = useLiveRatesQuery();
|
|
27
|
-
const [records, setRecords] = useState<DataRecord[]>(
|
|
29
|
+
const [records, setRecords] = useState<DataRecord[]>(
|
|
30
|
+
new Array(instruments.length).fill({})
|
|
31
|
+
);
|
|
28
32
|
|
|
29
33
|
const { loading, data, error } = useQuery<
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
|
13
|
-
|
|
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(
|
|
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) =>
|
|
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={
|
|
42
|
+
title={
|
|
43
|
+
<Truncate
|
|
44
|
+
text={record.displayName}
|
|
45
|
+
tooltipId={INSTRUMENT_TOOLTIP_ID}
|
|
46
|
+
/>
|
|
47
|
+
}
|
|
37
48
|
>
|
|
38
49
|
{activeColumns.includes(ColumnsNames.CHART) && (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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>
|
|
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>
|
|
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,
|
|
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
|
-
|
|
5
|
-
|
|
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 {
|
|
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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
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;
|