@oanda/labs-live-rates-table-widget 1.0.39 → 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 +164 -0
- package/dist/main/LiveRatesTableWidget/LiveRatesTableWidget.js +14 -14
- package/dist/main/LiveRatesTableWidget/LiveRatesTableWidget.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/Main.js +15 -15
- 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 +24 -24
- 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 +14 -14
- package/dist/module/LiveRatesTableWidget/LiveRatesTableWidget.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/Main.js +17 -17
- 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 +24 -24
- 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 +14 -17
- package/src/LiveRatesTableWidget/Main.tsx +49 -43
- 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 +63 -30
- 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 +8 -7
- package/test/Cards.test.tsx +32 -29
- package/test/LineChartWithData.test.tsx +77 -32
- package/test/Main.test.tsx +10 -9
- package/test/RowWithData.test.tsx +9 -8
- package/test/mocks.ts +1 -3
|
@@ -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;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
1
|
import {
|
|
4
|
-
|
|
2
|
+
LoaderSize,
|
|
3
|
+
Price,
|
|
4
|
+
TableCell,
|
|
5
|
+
TableRow,
|
|
6
|
+
Truncate,
|
|
7
|
+
useLayoutProvider,
|
|
5
8
|
} from '@oanda/labs-widget-common';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
+
import classnames from 'classnames';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
|
|
9
12
|
import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
|
|
13
|
+
import type { RowWithDataProps } from '../../types';
|
|
14
|
+
import { ColumnsNames } from '../../types';
|
|
15
|
+
import { useRecords } from '../../utils';
|
|
16
|
+
import { LineChartWithData } from '../LineChartWithData';
|
|
10
17
|
|
|
11
18
|
const RowWithData = ({
|
|
12
19
|
loading,
|
|
@@ -18,37 +25,54 @@ const RowWithData = ({
|
|
|
18
25
|
isScrolled,
|
|
19
26
|
}: RowWithDataProps) => {
|
|
20
27
|
const { isDark } = useLayoutProvider();
|
|
21
|
-
const { updatedRecord, error, ref } = useRecords(
|
|
28
|
+
const { updatedRecord, error, ref } = useRecords(
|
|
29
|
+
record,
|
|
30
|
+
record.instrument ? target : null
|
|
31
|
+
);
|
|
22
32
|
|
|
23
|
-
const checkLoading = (id: string) =>
|
|
33
|
+
const checkLoading = (id: string) =>
|
|
34
|
+
loading || (!error && updatedRecord?.[id] === undefined);
|
|
24
35
|
|
|
25
36
|
return (
|
|
26
|
-
<TableRow
|
|
37
|
+
<TableRow
|
|
38
|
+
ref={ref}
|
|
39
|
+
hasBackgroundColor={hasBackgroundColor}
|
|
40
|
+
isScrolled={isScrolled}
|
|
41
|
+
>
|
|
27
42
|
<>
|
|
28
43
|
<TableCell
|
|
29
|
-
type="text"
|
|
30
|
-
classNames={classnames(
|
|
31
|
-
'lw-font-bold',
|
|
32
|
-
{
|
|
33
|
-
'[&>*:first-child]:lw-border-r [&>*:first-child]:lw-border-border-primary': isDark && isScrolled,
|
|
34
|
-
},
|
|
35
|
-
)}
|
|
36
44
|
key={ColumnsNames.INSTRUMENT}
|
|
45
|
+
classNames={classnames('lw-font-bold', {
|
|
46
|
+
'[&>*:first-child]:lw-border-r [&>*:first-child]:lw-border-border-primary':
|
|
47
|
+
isDark && isScrolled,
|
|
48
|
+
})}
|
|
37
49
|
isLoading={checkLoading(ColumnsNames.INSTRUMENT)}
|
|
50
|
+
type="text"
|
|
38
51
|
>
|
|
39
|
-
<Truncate
|
|
52
|
+
<Truncate
|
|
53
|
+
maxWidth={130}
|
|
54
|
+
text={record.displayName}
|
|
55
|
+
tooltipId={INSTRUMENT_TOOLTIP_ID}
|
|
56
|
+
/>
|
|
40
57
|
</TableCell>
|
|
41
58
|
{activeColumns.map((item) => {
|
|
42
59
|
if (item === ColumnsNames.SELL) {
|
|
43
60
|
return (
|
|
44
61
|
<TableCell
|
|
45
62
|
key={ColumnsNames.SELL}
|
|
46
|
-
isLoading={checkLoading(ColumnsNames.SELL)}
|
|
47
|
-
isError={!!error}
|
|
48
63
|
additionalPaddingRight
|
|
64
|
+
isError={!!error}
|
|
65
|
+
isLoading={checkLoading(ColumnsNames.SELL)}
|
|
49
66
|
>
|
|
50
|
-
<Price
|
|
51
|
-
|
|
67
|
+
<Price
|
|
68
|
+
movementIndicator="arrow"
|
|
69
|
+
priceMovement={updatedRecord.sellPriceMovement}
|
|
70
|
+
>
|
|
71
|
+
<span>
|
|
72
|
+
{updatedRecord.sell?.toFixed(
|
|
73
|
+
updatedRecord.displayPrecision
|
|
74
|
+
)}
|
|
75
|
+
</span>
|
|
52
76
|
</Price>
|
|
53
77
|
</TableCell>
|
|
54
78
|
);
|
|
@@ -58,12 +82,17 @@ const RowWithData = ({
|
|
|
58
82
|
return (
|
|
59
83
|
<TableCell
|
|
60
84
|
key={ColumnsNames.BUY}
|
|
61
|
-
isLoading={checkLoading(ColumnsNames.BUY)}
|
|
62
|
-
isError={!!error}
|
|
63
85
|
additionalPaddingRight
|
|
86
|
+
isError={!!error}
|
|
87
|
+
isLoading={checkLoading(ColumnsNames.BUY)}
|
|
64
88
|
>
|
|
65
|
-
<Price
|
|
66
|
-
|
|
89
|
+
<Price
|
|
90
|
+
movementIndicator="arrow"
|
|
91
|
+
priceMovement={updatedRecord.buyPriceMovement}
|
|
92
|
+
>
|
|
93
|
+
<span>
|
|
94
|
+
{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}
|
|
95
|
+
</span>
|
|
67
96
|
</Price>
|
|
68
97
|
</TableCell>
|
|
69
98
|
);
|
|
@@ -73,8 +102,8 @@ const RowWithData = ({
|
|
|
73
102
|
return (
|
|
74
103
|
<TableCell
|
|
75
104
|
key={ColumnsNames.DAILY_CHANGE}
|
|
76
|
-
isLoading={checkLoading('dailyPercentChange')}
|
|
77
105
|
isError={!!error}
|
|
106
|
+
isLoading={checkLoading('dailyPercentChange')}
|
|
78
107
|
>
|
|
79
108
|
<span>{updatedRecord.dailyPercentChange}</span>
|
|
80
109
|
</TableCell>
|
|
@@ -83,12 +112,16 @@ const RowWithData = ({
|
|
|
83
112
|
|
|
84
113
|
if (item === ColumnsNames.CHART) {
|
|
85
114
|
return (
|
|
86
|
-
<td
|
|
115
|
+
<td
|
|
116
|
+
key={ColumnsNames.CHART}
|
|
117
|
+
className="lw-relative lw-px-3 lw-py-0 lw-text-right"
|
|
118
|
+
data-testid="chart-table-cell"
|
|
119
|
+
>
|
|
87
120
|
<div className="lw-flex lw-justify-center">
|
|
88
121
|
<LineChartWithData
|
|
89
|
-
record={updatedRecord}
|
|
90
|
-
isLoading={checkLoading('instrument')}
|
|
91
122
|
division={division}
|
|
123
|
+
isLoading={checkLoading('instrument')}
|
|
124
|
+
record={updatedRecord}
|
|
92
125
|
/>
|
|
93
126
|
</div>
|
|
94
127
|
</td>
|
|
@@ -99,8 +132,8 @@ const RowWithData = ({
|
|
|
99
132
|
return (
|
|
100
133
|
<TableCell
|
|
101
134
|
key={ColumnsNames.SPREAD}
|
|
102
|
-
isLoading={checkLoading(ColumnsNames.SPREAD)}
|
|
103
135
|
isError={!!error}
|
|
136
|
+
isLoading={checkLoading(ColumnsNames.SPREAD)}
|
|
104
137
|
loaderSize={LoaderSize.sm}
|
|
105
138
|
>
|
|
106
139
|
<span>{updatedRecord.spread}</span>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Size } from '@oanda/labs-widget-common';
|
|
2
|
+
|
|
2
3
|
import { ColumnsNames, View } from './types';
|
|
3
4
|
|
|
4
5
|
const headerConfig = {
|
|
@@ -33,7 +34,4 @@ const sizeConfig = {
|
|
|
33
34
|
[View.TABLE]: Size.DESKTOP,
|
|
34
35
|
};
|
|
35
36
|
|
|
36
|
-
export {
|
|
37
|
-
headerConfig,
|
|
38
|
-
sizeConfig,
|
|
39
|
-
};
|
|
37
|
+
export { headerConfig, sizeConfig };
|
|
@@ -15,5 +15,8 @@ const DEFAULT_COLUMNS = [
|
|
|
15
15
|
const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';
|
|
16
16
|
|
|
17
17
|
export {
|
|
18
|
-
|
|
18
|
+
DEFAULT_COLUMNS,
|
|
19
|
+
DEFAULT_COUNT,
|
|
20
|
+
DEFAULT_TOTAL_COUNT,
|
|
21
|
+
INSTRUMENT_TOOLTIP_ID,
|
|
19
22
|
};
|
|
@@ -1,55 +1,73 @@
|
|
|
1
|
+
import type { Theme } from '@oanda/labs-widget-common';
|
|
2
|
+
import { validateLocale, validateToolParams } from '@oanda/labs-widget-common';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { createRoot } from 'react-dom/client';
|
|
3
|
-
|
|
4
|
-
import { LiveRatesTableWidget } from './LiveRatesTableWidget';
|
|
5
|
+
|
|
5
6
|
import { Division } from '../gql/types/graphql';
|
|
7
|
+
import { LiveRatesTableWidget } from './LiveRatesTableWidget';
|
|
6
8
|
|
|
7
|
-
const {
|
|
8
|
-
graphqlUrl,
|
|
9
|
-
liveRatesUrl,
|
|
10
|
-
} = window.widgetsConfig || {};
|
|
9
|
+
const { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};
|
|
11
10
|
|
|
12
|
-
const liveRatesTableParamsElements = document.querySelectorAll(
|
|
11
|
+
const liveRatesTableParamsElements = document.querySelectorAll(
|
|
12
|
+
'div[data-live-rates-table-params]'
|
|
13
|
+
);
|
|
13
14
|
|
|
14
15
|
liveRatesTableParamsElements.forEach((element) => {
|
|
15
16
|
const root = createRoot(element);
|
|
16
17
|
const params = element.getAttribute('data-live-rates-table-params');
|
|
17
18
|
const mode = element.getAttribute('data-mode');
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const { instruments, columns, division, locale, view } = JSON.parse(
|
|
20
|
+
params as string
|
|
21
|
+
);
|
|
21
22
|
|
|
22
|
-
const isParamError = validateToolParams(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
const isParamError = validateToolParams(
|
|
24
|
+
{
|
|
25
|
+
division,
|
|
26
|
+
locale,
|
|
27
|
+
graphqlUrl,
|
|
28
|
+
liveRatesUrl,
|
|
29
|
+
instruments,
|
|
30
|
+
columns,
|
|
31
|
+
},
|
|
32
|
+
[
|
|
33
|
+
{
|
|
34
|
+
name: 'locale',
|
|
35
|
+
valueCheck: (value: string | undefined) => validateLocale(value),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'division',
|
|
39
|
+
valueCheck: (value: Division) =>
|
|
40
|
+
Object.values(Division).includes(value),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'instruments',
|
|
44
|
+
valueCheck: (value) =>
|
|
45
|
+
(value as string[]).length > 0 && (value as string[]).length <= 10,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'columns',
|
|
49
|
+
valueCheck: (value) => (value as string[]).length > 0,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'graphqlUrl',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'liveRatesUrl',
|
|
56
|
+
},
|
|
57
|
+
]
|
|
58
|
+
);
|
|
41
59
|
|
|
42
60
|
root.render(
|
|
43
61
|
<LiveRatesTableWidget
|
|
44
|
-
|
|
45
|
-
liveRatesUrl={liveRatesUrl}
|
|
62
|
+
columns={columns}
|
|
46
63
|
division={division}
|
|
64
|
+
graphqlUrl={graphqlUrl}
|
|
47
65
|
instruments={instruments}
|
|
48
|
-
|
|
66
|
+
isParamError={isParamError}
|
|
67
|
+
liveRatesUrl={liveRatesUrl}
|
|
49
68
|
locale={locale}
|
|
50
69
|
theme={mode as Theme}
|
|
51
|
-
isParamError={isParamError}
|
|
52
70
|
view={view}
|
|
53
|
-
|
|
71
|
+
/>
|
|
54
72
|
);
|
|
55
73
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { WidgetConfig } from '@oanda/labs-widget-common';
|
|
2
|
-
|
|
1
|
+
import type { WidgetConfig } from '@oanda/labs-widget-common';
|
|
2
|
+
|
|
3
|
+
import type { Division } from '../gql/types/graphql';
|
|
3
4
|
|
|
4
|
-
export { Locale } from '@oanda/mono-i18n';
|
|
5
5
|
export { Division } from '../gql/types/graphql';
|
|
6
|
+
export { Locale } from '@oanda/mono-i18n';
|
|
6
7
|
|
|
7
8
|
export enum View {
|
|
8
9
|
TABLE = 'table',
|
|
@@ -38,7 +39,7 @@ export interface Sentiment {
|
|
|
38
39
|
longPercent: number;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
export type EmptyRecord = Record<
|
|
42
|
+
export type EmptyRecord = Record<string, never>;
|
|
42
43
|
|
|
43
44
|
export interface DataRecord {
|
|
44
45
|
[key: string]: string | number | undefined;
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
HeaderColumns,
|
|
3
|
+
LiveRatesErrorMessage,
|
|
4
|
+
} from '@oanda/labs-widget-common';
|
|
5
|
+
import { useLiveRatesMessage } from '@oanda/labs-widget-common';
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
3
7
|
import { useIntersectionObserver } from 'usehooks-ts';
|
|
4
|
-
|
|
8
|
+
|
|
9
|
+
import type { ValidateInstrumentsQuery } from '../gql/types/graphql';
|
|
5
10
|
import { headerConfig } from './config';
|
|
6
|
-
import {
|
|
11
|
+
import type { DataRecord, EmptyRecord } from './types';
|
|
12
|
+
import { ColumnsNames } from './types';
|
|
7
13
|
|
|
8
|
-
const getRecords = (data: ValidateInstrumentsQuery) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
const getRecords = (data: ValidateInstrumentsQuery) =>
|
|
15
|
+
data?.mapInstrumentNames?.map((item) => ({
|
|
16
|
+
instrument: item?.name || '',
|
|
17
|
+
displayName: item?.displayName || '',
|
|
18
|
+
}));
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
const getHeaderConfig = (activeColumns: ColumnsNames[]): HeaderColumns[] =>
|
|
21
|
+
[ColumnsNames.INSTRUMENT, ...activeColumns].map((item) => headerConfig[item]);
|
|
15
22
|
|
|
16
23
|
const useRecords = (
|
|
17
24
|
record: DataRecord | EmptyRecord,
|
|
18
|
-
target: EventTarget | null
|
|
25
|
+
target: EventTarget | null
|
|
19
26
|
) => {
|
|
20
27
|
const [updatedRecord, setUpdatedRecord] = useState<DataRecord>({
|
|
21
28
|
displayName: record.displayName,
|
|
@@ -28,7 +35,7 @@ const useRecords = (
|
|
|
28
35
|
|
|
29
36
|
const { update, error: liveRatesError } = useLiveRatesMessage(
|
|
30
37
|
record.instrument,
|
|
31
|
-
target
|
|
38
|
+
target
|
|
32
39
|
);
|
|
33
40
|
|
|
34
41
|
useEffect(() => {
|
|
@@ -56,8 +63,4 @@ const useRecords = (
|
|
|
56
63
|
};
|
|
57
64
|
};
|
|
58
65
|
|
|
59
|
-
export {
|
|
60
|
-
getRecords,
|
|
61
|
-
getHeaderConfig,
|
|
62
|
-
useRecords,
|
|
63
|
-
};
|
|
66
|
+
export { getHeaderConfig, getRecords, useRecords };
|