@oanda/labs-instrument-live-rate-widget 1.0.9 → 1.0.10
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 +44 -0
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +8 -12
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/Main.js +21 -56
- package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/ValidationWrapper.js +52 -0
- package/dist/main/InstrumentLiveRateWidget/ValidationWrapper.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/types.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +7 -12
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/Main.js +24 -58
- package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/ValidationWrapper.js +45 -0
- package/dist/module/InstrumentLiveRateWidget/ValidationWrapper.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/types.js.map +1 -1
- package/dist/types/InstrumentLiveRateWidget/Main.d.ts +1 -1
- package/dist/types/InstrumentLiveRateWidget/ValidationWrapper.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/types.d.ts +10 -4
- package/package.json +3 -4
- package/src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx +11 -20
- package/src/InstrumentLiveRateWidget/Main.tsx +27 -66
- package/src/InstrumentLiveRateWidget/ValidationWrapper.tsx +62 -0
- package/src/InstrumentLiveRateWidget/types.tsx +10 -4
- package/test/Main.test.tsx +7 -3
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +0 -46
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js +0 -28
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js +0 -6
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js +0 -25
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +0 -42
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/index.js +0 -17
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/index.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js +0 -6
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/index.js +0 -28
- package/dist/main/InstrumentLiveRateWidget/components/index.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +0 -38
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js +0 -3
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js +0 -2
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js +0 -18
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +0 -35
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/index.js +0 -2
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/index.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js +0 -2
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/index.js +0 -3
- package/dist/module/InstrumentLiveRateWidget/components/index.js.map +0 -1
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.d.ts +0 -4
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.d.ts +0 -2
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.d.ts +0 -9
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.d.ts +0 -3
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.d.ts +0 -4
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/index.d.ts +0 -1
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/types.d.ts +0 -8
- package/dist/types/InstrumentLiveRateWidget/components/index.d.ts +0 -2
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx +0 -43
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.ts +0 -2
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.ts +0 -10
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.ts +0 -25
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx +0 -43
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/index.ts +0 -1
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx +0 -9
- package/src/InstrumentLiveRateWidget/components/index.ts +0 -2
- package/test/LineChartWithData.test.tsx +0 -164
- package/test/components/InstrumentRateWithChart.test.tsx +0 -62
- package/test/components/utils.test.ts +0 -13
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Locale } from '@oanda/mono-i18n';
|
|
2
|
-
import { Theme } from '@oanda/labs-widget-common';
|
|
2
|
+
import { DataRecord, Theme, WidgetSize } from '@oanda/labs-widget-common';
|
|
3
3
|
import { Division } from '../gql/types/graphql';
|
|
4
4
|
export { Locale } from '@oanda/mono-i18n';
|
|
5
5
|
export { Division } from '../gql/types/graphql';
|
|
@@ -12,10 +12,16 @@ export interface InstrumentLiveRateConfig {
|
|
|
12
12
|
theme?: Theme;
|
|
13
13
|
isParamError?: boolean;
|
|
14
14
|
removePadding?: boolean;
|
|
15
|
-
size?:
|
|
15
|
+
size?: WidgetSize;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
17
|
+
export interface ValidationWrapperProps {
|
|
18
18
|
instrument: string;
|
|
19
19
|
division: Division;
|
|
20
|
-
size?:
|
|
20
|
+
size?: WidgetSize;
|
|
21
|
+
isParamError?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface MainProps {
|
|
24
|
+
record: DataRecord;
|
|
25
|
+
division: Division;
|
|
26
|
+
size?: WidgetSize;
|
|
21
27
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oanda/labs-instrument-live-rate-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Labs Instrument Live Rate Widget",
|
|
5
5
|
"main": "dist/main/index.js",
|
|
6
6
|
"module": "dist/module/index.js",
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
"author": "OANDA",
|
|
13
13
|
"license": "UNLICENSED",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@
|
|
16
|
-
"@oanda/labs-widget-common": "^1.0.148",
|
|
15
|
+
"@oanda/labs-widget-common": "^1.0.149",
|
|
17
16
|
"@oanda/mono-i18n": "10.0.1",
|
|
18
17
|
"graphql": "16.8.1"
|
|
19
18
|
},
|
|
@@ -21,5 +20,5 @@
|
|
|
21
20
|
"@graphql-codegen/cli": "5.0.0",
|
|
22
21
|
"@graphql-codegen/client-preset": "4.1.0"
|
|
23
22
|
},
|
|
24
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "5669c16b7b74489de566298ef8830cd6bc99b47b"
|
|
25
24
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
1
|
+
import React, { Suspense } from 'react';
|
|
3
2
|
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
4
3
|
import { LocaleProvider } from '@oanda/mono-i18n';
|
|
5
4
|
import {
|
|
6
|
-
|
|
5
|
+
LiveRatesProvider, ThemeProvider, getLocale,
|
|
7
6
|
} from '@oanda/labs-widget-common';
|
|
8
7
|
import { translations } from '../translations';
|
|
9
|
-
import { Main } from './Main';
|
|
10
8
|
import { Division, InstrumentLiveRateConfig } from './types';
|
|
9
|
+
import { ValidationWrapper } from './ValidationWrapper';
|
|
11
10
|
|
|
12
11
|
const InstrumentLiveRateWidget = ({
|
|
13
12
|
graphqlUrl,
|
|
@@ -36,22 +35,14 @@ const InstrumentLiveRateWidget = ({
|
|
|
36
35
|
options={{ divisionCode, dataSource }}
|
|
37
36
|
>
|
|
38
37
|
<ApolloProvider client={client}>
|
|
39
|
-
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
)
|
|
48
|
-
: (
|
|
49
|
-
<Main
|
|
50
|
-
size={size}
|
|
51
|
-
instrument={instrument}
|
|
52
|
-
division={division}
|
|
53
|
-
/>
|
|
54
|
-
)}
|
|
38
|
+
<Suspense>
|
|
39
|
+
<ValidationWrapper
|
|
40
|
+
size={size}
|
|
41
|
+
instrument={instrument}
|
|
42
|
+
division={division}
|
|
43
|
+
isParamError={isParamError}
|
|
44
|
+
/>
|
|
45
|
+
</Suspense>
|
|
55
46
|
</ApolloProvider>
|
|
56
47
|
</LiveRatesProvider>
|
|
57
48
|
</LocaleProvider>
|
|
@@ -1,93 +1,54 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
3
|
-
import classnames from 'classnames';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useBackgroundQuery } from '@apollo/client';
|
|
4
3
|
import {
|
|
5
|
-
|
|
6
|
-
DataRecord,
|
|
7
|
-
ThemeContext,
|
|
4
|
+
InstrumentRateWithChart,
|
|
8
5
|
Tooltip,
|
|
9
6
|
useLiveRatesQuery,
|
|
10
7
|
} from '@oanda/labs-widget-common';
|
|
11
|
-
import { getRecords } from './utils';
|
|
12
8
|
import { MainProps } from './types';
|
|
13
9
|
import { INSTRUMENT_TOOLTIP_ID } from './constant';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { InstrumentRateWithChart } from './components/InstrumentRateWithChart';
|
|
10
|
+
import { getInstrumentsChart } from '../gql/getInstrumentsChart';
|
|
11
|
+
import { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../gql/types/graphql';
|
|
17
12
|
|
|
18
13
|
const Main = ({
|
|
19
|
-
instrument,
|
|
20
14
|
division,
|
|
21
15
|
size: widgetSize = 'fullWithChart',
|
|
16
|
+
record,
|
|
22
17
|
}: MainProps) => {
|
|
23
|
-
const
|
|
24
|
-
const { target, setQuery } = useLiveRatesQuery();
|
|
25
|
-
const [records, setRecords] = useState<DataRecord[]>([]);
|
|
18
|
+
const hasInstrument = !!record.instrument;
|
|
26
19
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
>(
|
|
20
|
+
const [queryRef] = useBackgroundQuery<
|
|
21
|
+
GetInstrumentsChartQuery,
|
|
22
|
+
GetInstrumentsChartQueryVariables
|
|
23
|
+
>(getInstrumentsChart, {
|
|
31
24
|
variables: {
|
|
32
|
-
instruments: [instrument],
|
|
25
|
+
instruments: [record.instrument],
|
|
33
26
|
division,
|
|
34
27
|
},
|
|
35
28
|
fetchPolicy: 'network-only',
|
|
29
|
+
skip: !hasInstrument,
|
|
36
30
|
});
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
if (!loading && data) {
|
|
40
|
-
setRecords(getRecords(data)!);
|
|
41
|
-
}
|
|
42
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
|
-
}, [loading, data]);
|
|
44
|
-
|
|
45
|
-
const instrumentsNames = records.map(({ instrument: instrumentName }) => instrumentName);
|
|
32
|
+
const { target, setQuery } = useLiveRatesQuery();
|
|
46
33
|
|
|
47
34
|
useEffect(() => {
|
|
48
|
-
if (
|
|
49
|
-
setQuery({ instruments:
|
|
35
|
+
if (hasInstrument) {
|
|
36
|
+
setQuery({ instruments: [record?.instrument] });
|
|
50
37
|
}
|
|
51
38
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
52
|
-
}, [
|
|
53
|
-
|
|
54
|
-
const showError = !!error;
|
|
39
|
+
}, [record]);
|
|
55
40
|
|
|
56
41
|
return (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})}
|
|
68
|
-
>
|
|
69
|
-
<InstrumentRateWithChart
|
|
70
|
-
loading={loading}
|
|
71
|
-
record={records[0] || {}}
|
|
72
|
-
target={target}
|
|
73
|
-
division={division}
|
|
74
|
-
size={widgetSize}
|
|
75
|
-
/>
|
|
76
|
-
<Tooltip id={INSTRUMENT_TOOLTIP_ID} />
|
|
77
|
-
</div>
|
|
78
|
-
)}
|
|
79
|
-
{!loading && showError && (
|
|
80
|
-
<div className={classnames('lw-flex lw-w-full lw-items-center', {
|
|
81
|
-
'lw-h-[82px]': widgetSize !== 'compact',
|
|
82
|
-
'lw-h-[54px]': widgetSize === 'compact',
|
|
83
|
-
})}
|
|
84
|
-
>
|
|
85
|
-
<Error />
|
|
86
|
-
</div>
|
|
87
|
-
)}
|
|
88
|
-
</div>
|
|
89
|
-
)}
|
|
90
|
-
</>
|
|
42
|
+
<div>
|
|
43
|
+
<InstrumentRateWithChart<GetInstrumentsChartQuery>
|
|
44
|
+
record={record}
|
|
45
|
+
target={target}
|
|
46
|
+
size={widgetSize}
|
|
47
|
+
tooltipId={INSTRUMENT_TOOLTIP_ID}
|
|
48
|
+
queryRef={queryRef}
|
|
49
|
+
/>
|
|
50
|
+
<Tooltip id={INSTRUMENT_TOOLTIP_ID} />
|
|
51
|
+
</div>
|
|
91
52
|
);
|
|
92
53
|
};
|
|
93
54
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSuspenseQuery } from '@apollo/client';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { Error } from '@oanda/labs-widget-common';
|
|
5
|
+
import { getRecords } from './utils';
|
|
6
|
+
import { ValidationWrapperProps } from './types';
|
|
7
|
+
import { validateInstruments } from '../gql/validateInstruments';
|
|
8
|
+
import { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';
|
|
9
|
+
import { Main } from './Main';
|
|
10
|
+
|
|
11
|
+
const ValidationWrapper = ({
|
|
12
|
+
instrument,
|
|
13
|
+
division,
|
|
14
|
+
size: widgetSize,
|
|
15
|
+
isParamError,
|
|
16
|
+
}: ValidationWrapperProps) => {
|
|
17
|
+
const { data, error } = useSuspenseQuery<
|
|
18
|
+
ValidateInstrumentsQuery,
|
|
19
|
+
ValidateInstrumentsQueryVariables
|
|
20
|
+
>(validateInstruments, {
|
|
21
|
+
variables: {
|
|
22
|
+
instruments: [instrument],
|
|
23
|
+
division,
|
|
24
|
+
},
|
|
25
|
+
fetchPolicy: 'network-only',
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const showError = !!error || isParamError;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<div
|
|
33
|
+
className="lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary"
|
|
34
|
+
>
|
|
35
|
+
{!showError && (
|
|
36
|
+
<div className={classnames({
|
|
37
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
38
|
+
'lw-h-[54px]': widgetSize === 'compact',
|
|
39
|
+
})}
|
|
40
|
+
>
|
|
41
|
+
<Main
|
|
42
|
+
size={widgetSize}
|
|
43
|
+
division={division}
|
|
44
|
+
record={getRecords(data!)?.[0]!}
|
|
45
|
+
/>
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
48
|
+
{showError && (
|
|
49
|
+
<div className={classnames('lw-flex lw-w-full lw-items-center', {
|
|
50
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
51
|
+
'lw-h-[54px]': widgetSize === 'compact',
|
|
52
|
+
})}
|
|
53
|
+
>
|
|
54
|
+
<Error />
|
|
55
|
+
</div>
|
|
56
|
+
)}
|
|
57
|
+
</div>
|
|
58
|
+
</>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { ValidationWrapper };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Locale } from '@oanda/mono-i18n';
|
|
2
|
-
import { Theme } from '@oanda/labs-widget-common';
|
|
2
|
+
import { DataRecord, Theme, WidgetSize } from '@oanda/labs-widget-common';
|
|
3
3
|
import { Division } from '../gql/types/graphql';
|
|
4
4
|
|
|
5
5
|
export { Locale } from '@oanda/mono-i18n';
|
|
@@ -14,11 +14,17 @@ export interface InstrumentLiveRateConfig {
|
|
|
14
14
|
theme?: Theme;
|
|
15
15
|
isParamError?: boolean;
|
|
16
16
|
removePadding?: boolean;
|
|
17
|
-
size?:
|
|
17
|
+
size?: WidgetSize;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export interface
|
|
20
|
+
export interface ValidationWrapperProps {
|
|
21
21
|
instrument: string;
|
|
22
22
|
division: Division;
|
|
23
|
-
size?:
|
|
23
|
+
size?: WidgetSize;
|
|
24
|
+
isParamError?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface MainProps {
|
|
27
|
+
record: DataRecord;
|
|
28
|
+
division: Division;
|
|
29
|
+
size?: WidgetSize;
|
|
24
30
|
}
|
package/test/Main.test.tsx
CHANGED
|
@@ -10,18 +10,22 @@ import { Division } from '../src/gql/types/graphql';
|
|
|
10
10
|
import { widgetMocks } from './mocks';
|
|
11
11
|
|
|
12
12
|
describe('Main component', () => {
|
|
13
|
-
it('should render
|
|
13
|
+
it('should render instrument live rate component', async () => {
|
|
14
14
|
const { findByTestId } = render(
|
|
15
15
|
<MockedProvider mocks={widgetMocks}>
|
|
16
16
|
<ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
|
|
17
17
|
<Main
|
|
18
18
|
division={Division.Oc}
|
|
19
|
-
|
|
19
|
+
record={{
|
|
20
|
+
instrument: 'EUR_USD',
|
|
21
|
+
displayName: 'EUR/USD',
|
|
22
|
+
}}
|
|
23
|
+
size="compact"
|
|
20
24
|
/>
|
|
21
25
|
</ThemeContext.Provider>
|
|
22
26
|
</MockedProvider>,
|
|
23
27
|
);
|
|
24
28
|
|
|
25
|
-
expect(await findByTestId('instrument-
|
|
29
|
+
expect(await findByTestId('instrument-rate-wrapper')).toBeInTheDocument();
|
|
26
30
|
});
|
|
27
31
|
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.InstrumentRateWithChart = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
9
|
-
var _utils = require("./utils");
|
|
10
|
-
var _constant = require("../../constant");
|
|
11
|
-
var _LineChartWithData = require("../LineChartWithData");
|
|
12
|
-
var _utils2 = require("../../utils");
|
|
13
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
-
const InstrumentRateWithChart = _ref => {
|
|
16
|
-
let {
|
|
17
|
-
loading,
|
|
18
|
-
record,
|
|
19
|
-
target,
|
|
20
|
-
division,
|
|
21
|
-
size
|
|
22
|
-
} = _ref;
|
|
23
|
-
const {
|
|
24
|
-
isDark
|
|
25
|
-
} = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
|
|
26
|
-
const {
|
|
27
|
-
updatedRecord,
|
|
28
|
-
error
|
|
29
|
-
} = (0, _utils2.useRecords)(record, record?.instrument ? target : null);
|
|
30
|
-
const indicator = (0, _utils.getColorIndicator)(updatedRecord.dailyPercentChange);
|
|
31
|
-
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_labsWidgetCommon.InstrumentRate, {
|
|
32
|
-
isLoading: loading,
|
|
33
|
-
isError: !!error,
|
|
34
|
-
record: updatedRecord,
|
|
35
|
-
size: size,
|
|
36
|
-
tooltipId: _constant.INSTRUMENT_TOOLTIP_ID,
|
|
37
|
-
colorIndicator: indicator
|
|
38
|
-
}), size === 'fullWithChart' && _react.default.createElement(_LineChartWithData.LineChartWithData, {
|
|
39
|
-
record: record,
|
|
40
|
-
isLoading: loading,
|
|
41
|
-
division: division,
|
|
42
|
-
color: (0, _utils.getChartColor)(indicator, isDark)
|
|
43
|
-
}));
|
|
44
|
-
};
|
|
45
|
-
exports.InstrumentRateWithChart = InstrumentRateWithChart;
|
|
46
|
-
//# sourceMappingURL=InstrumentRateWithChart.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentRateWithChart.js","names":["_react","_interopRequireWildcard","require","_labsWidgetCommon","_utils","_constant","_LineChartWithData","_utils2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","InstrumentRateWithChart","_ref","loading","record","target","division","size","isDark","useContext","ThemeContext","updatedRecord","error","useRecords","instrument","indicator","getColorIndicator","dailyPercentChange","createElement","Fragment","InstrumentRate","isLoading","isError","tooltipId","INSTRUMENT_TOOLTIP_ID","colorIndicator","LineChartWithData","color","getChartColor","exports"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { InstrumentRate, ThemeContext } from '@oanda/labs-widget-common';\nimport { InstrumentRateWithChartProps } from './types';\nimport { getChartColor, getColorIndicator } from './utils';\nimport { INSTRUMENT_TOOLTIP_ID } from '../../constant';\nimport { LineChartWithData } from '../LineChartWithData';\nimport { useRecords } from '../../utils';\n\nconst InstrumentRateWithChart = ({\n loading,\n record,\n target,\n division,\n size,\n}: InstrumentRateWithChartProps) => {\n const { isDark } = useContext(ThemeContext);\n const { updatedRecord, error } = useRecords(record, record?.instrument ? target : null);\n\n const indicator = getColorIndicator(updatedRecord.dailyPercentChange);\n\n return (\n <>\n <InstrumentRate\n isLoading={loading}\n isError={!!error}\n record={updatedRecord}\n size={size}\n tooltipId={INSTRUMENT_TOOLTIP_ID}\n colorIndicator={indicator}\n />\n {size === 'fullWithChart' && (\n <LineChartWithData\n record={record}\n isLoading={loading}\n division={division}\n color={getChartColor(indicator, isDark)}\n />\n )}\n </>\n );\n};\n\nexport { InstrumentRateWithChart };\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _InstrumentRateWithChart = require("./InstrumentRateWithChart");
|
|
7
|
-
Object.keys(_InstrumentRateWithChart).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _InstrumentRateWithChart[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _InstrumentRateWithChart[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _utils = require("./utils");
|
|
18
|
-
Object.keys(_utils).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _utils[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _utils[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_InstrumentRateWithChart","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_utils"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.ts"],"sourcesContent":["export * from './InstrumentRateWithChart';\nexport * from './utils';\n"],"mappings":";;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,wBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,wBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,wBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.ts"],"sourcesContent":["import { DataRecord } from '@oanda/labs-widget-common';\nimport { Division } from '../../types';\n\nexport interface InstrumentRateWithChartProps {\n loading: boolean;\n record: DataRecord;\n target: EventTarget | null;\n division: Division;\n size?: 'compact' | 'full' | 'fullWithChart'\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getColorIndicator = exports.getChartColor = void 0;
|
|
7
|
-
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
8
|
-
const getColorIndicator = dailyChange => {
|
|
9
|
-
const numberValue = Number(dailyChange?.substring(0, dailyChange.length - 1));
|
|
10
|
-
return Math.sign(numberValue);
|
|
11
|
-
};
|
|
12
|
-
exports.getColorIndicator = getColorIndicator;
|
|
13
|
-
const getChartColor = (indicator, isDarkMode) => {
|
|
14
|
-
const theme = isDarkMode ? _labsWidgetCommon.darkTheme : _labsWidgetCommon.lightTheme;
|
|
15
|
-
switch (indicator) {
|
|
16
|
-
case 1:
|
|
17
|
-
return theme.textOk;
|
|
18
|
-
case -1:
|
|
19
|
-
return theme.textDanger;
|
|
20
|
-
default:
|
|
21
|
-
return theme.textDisabled;
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
exports.getChartColor = getChartColor;
|
|
25
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_labsWidgetCommon","require","getColorIndicator","dailyChange","numberValue","Number","substring","length","Math","sign","exports","getChartColor","indicator","isDarkMode","theme","darkTheme","lightTheme","textOk","textDanger","textDisabled"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.ts"],"sourcesContent":["import { lightTheme, darkTheme } from '@oanda/labs-widget-common';\n\nconst getColorIndicator = (dailyChange?: string) => {\n const numberValue = Number(dailyChange?.substring(0, dailyChange.length - 1));\n\n return Math.sign(numberValue);\n};\n\nconst getChartColor = (indicator?: number, isDarkMode?: boolean) => {\n const theme = isDarkMode ? darkTheme : lightTheme;\n\n switch (indicator) {\n case 1:\n return theme.textOk;\n case -1:\n return theme.textDanger;\n default:\n return theme.textDisabled;\n }\n};\n\nexport {\n getColorIndicator,\n getChartColor,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,MAAMC,iBAAiB,GAAIC,WAAoB,IAAK;EAClD,MAAMC,WAAW,GAAGC,MAAM,CAACF,WAAW,EAAEG,SAAS,CAAC,CAAC,EAAEH,WAAW,CAACI,MAAM,GAAG,CAAC,CAAC,CAAC;EAE7E,OAAOC,IAAI,CAACC,IAAI,CAACL,WAAW,CAAC;AAC/B,CAAC;AAACM,OAAA,CAAAR,iBAAA,GAAAA,iBAAA;AAEF,MAAMS,aAAa,GAAGA,CAACC,SAAkB,EAAEC,UAAoB,KAAK;EAClE,MAAMC,KAAK,GAAGD,UAAU,GAAGE,2BAAS,GAAGC,4BAAU;EAEjD,QAAQJ,SAAS;IACf,KAAK,CAAC;MACJ,OAAOE,KAAK,CAACG,MAAM;IACrB,KAAK,CAAC,CAAC;MACL,OAAOH,KAAK,CAACI,UAAU;IACzB;MACE,OAAOJ,KAAK,CAACK,YAAY;EAC7B;AACF,CAAC;AAACT,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.LineChartWithData = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _client = require("@apollo/client");
|
|
9
|
-
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
10
|
-
var _getInstrumentsChart = require("../../../gql/getInstrumentsChart");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
const LineChartWithData = _ref => {
|
|
13
|
-
let {
|
|
14
|
-
record,
|
|
15
|
-
isLoading,
|
|
16
|
-
division,
|
|
17
|
-
color
|
|
18
|
-
} = _ref;
|
|
19
|
-
const {
|
|
20
|
-
loading,
|
|
21
|
-
data
|
|
22
|
-
} = (0, _client.useQuery)(_getInstrumentsChart.getInstrumentsChart, {
|
|
23
|
-
variables: {
|
|
24
|
-
instruments: [record.instrument],
|
|
25
|
-
division
|
|
26
|
-
},
|
|
27
|
-
fetchPolicy: 'network-only',
|
|
28
|
-
skip: !record.instrument
|
|
29
|
-
});
|
|
30
|
-
const showChart = isLoading || loading;
|
|
31
|
-
const chart = data?.topicalInstrumentsCharts?.[0].chart || [];
|
|
32
|
-
return _react.default.createElement("div", {
|
|
33
|
-
className: "lw-relative"
|
|
34
|
-
}, !showChart ? _react.default.createElement("div", {
|
|
35
|
-
className: "lw-absolute lw-bottom-0 lw-right-0 lw--z-50 lw-flex lw-h-10 lw-w-[100px] lw-items-center lw-justify-center"
|
|
36
|
-
}, _react.default.createElement(_labsWidgetCommon.LineChart, {
|
|
37
|
-
color: color,
|
|
38
|
-
data: chart
|
|
39
|
-
})) : null);
|
|
40
|
-
};
|
|
41
|
-
exports.LineChartWithData = LineChartWithData;
|
|
42
|
-
//# sourceMappingURL=LineChartWithData.js.map
|
package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LineChartWithData.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_getInstrumentsChart","e","__esModule","default","LineChartWithData","_ref","record","isLoading","division","color","loading","data","useQuery","getInstrumentsChart","variables","instruments","instrument","fetchPolicy","skip","showChart","chart","topicalInstrumentsCharts","createElement","className","LineChart","exports"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx"],"sourcesContent":["import React from 'react';\nimport { useQuery } from '@apollo/client';\nimport { LineChart } from '@oanda/labs-widget-common';\nimport { LineChartWithDataProps } from './types';\nimport { getInstrumentsChart } from '../../../gql/getInstrumentsChart';\nimport { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../../../gql/types/graphql';\n\nconst LineChartWithData = ({\n record,\n isLoading,\n division,\n color,\n}: LineChartWithDataProps) => {\n const { loading, data } = useQuery<\n GetInstrumentsChartQuery,\n GetInstrumentsChartQueryVariables\n >(getInstrumentsChart, {\n variables: {\n instruments: [record.instrument],\n division,\n },\n fetchPolicy: 'network-only',\n skip: !record.instrument,\n });\n\n const showChart = isLoading || loading;\n const chart = data?.topicalInstrumentsCharts?.[0].chart || [];\n\n return (\n <div className=\"lw-relative\">\n {!showChart ? (\n <div className=\"lw-absolute lw-bottom-0 lw-right-0 lw--z-50 lw-flex lw-h-10 lw-w-[100px] lw-items-center lw-justify-center\">\n <LineChart\n color={color}\n data={chart}\n />\n </div>\n ) : null}\n </div>\n );\n};\n\nexport { LineChartWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,oBAAA,GAAAH,OAAA;AAAuE,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGvE,MAAMG,iBAAiB,GAAGC,IAAA,IAKI;EAAA,IALH;IACzBC,MAAM;IACNC,SAAS;IACTC,QAAQ;IACRC;EACsB,CAAC,GAAAJ,IAAA;EACvB,MAAM;IAAEK,OAAO;IAAEC;EAAK,CAAC,GAAG,IAAAC,gBAAQ,EAGhCC,wCAAmB,EAAE;IACrBC,SAAS,EAAE;MACTC,WAAW,EAAE,CAACT,MAAM,CAACU,UAAU,CAAC;MAChCR;IACF,CAAC;IACDS,WAAW,EAAE,cAAc;IAC3BC,IAAI,EAAE,CAACZ,MAAM,CAACU;EAChB,CAAC,CAAC;EAEF,MAAMG,SAAS,GAAGZ,SAAS,IAAIG,OAAO;EACtC,MAAMU,KAAK,GAAGT,IAAI,EAAEU,wBAAwB,GAAG,CAAC,CAAC,CAACD,KAAK,IAAI,EAAE;EAE7D,OACEzB,MAAA,CAAAQ,OAAA,CAAAmB,aAAA;IAAKC,SAAS,EAAC;EAAa,GACzB,CAACJ,SAAS,GACTxB,MAAA,CAAAQ,OAAA,CAAAmB,aAAA;IAAKC,SAAS,EAAC;EAA4G,GACzH5B,MAAA,CAAAQ,OAAA,CAAAmB,aAAA,CAACvB,iBAAA,CAAAyB,SAAS;IACRf,KAAK,EAAEA,KAAM;IACbE,IAAI,EAAES;EAAM,CACb,CACE,CAAC,GACJ,IACD,CAAC;AAEV,CAAC;AAACK,OAAA,CAAArB,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _LineChartWithData = require("./LineChartWithData");
|
|
7
|
-
Object.keys(_LineChartWithData).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _LineChartWithData[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _LineChartWithData[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_LineChartWithData","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/index.ts"],"sourcesContent":["export * from './LineChartWithData';\n"],"mappings":";;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,kBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,kBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,kBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { DataRecord } from '@oanda/labs-widget-common';\nimport { Division } from '../../../gql/types/graphql';\n\nexport interface LineChartWithDataProps {\n record: DataRecord;\n isLoading: boolean;\n division: Division;\n color: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _InstrumentRateWithChart = require("./InstrumentRateWithChart");
|
|
7
|
-
Object.keys(_InstrumentRateWithChart).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _InstrumentRateWithChart[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _InstrumentRateWithChart[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _LineChartWithData = require("./LineChartWithData");
|
|
18
|
-
Object.keys(_LineChartWithData).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _LineChartWithData[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _LineChartWithData[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_InstrumentRateWithChart","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_LineChartWithData"],"sources":["../../../../src/InstrumentLiveRateWidget/components/index.ts"],"sourcesContent":["export * from './InstrumentRateWithChart';\nexport * from './LineChartWithData';\n"],"mappings":";;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,wBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,wBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,wBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,kBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,kBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,kBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,kBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import { InstrumentRate, ThemeContext } from '@oanda/labs-widget-common';
|
|
3
|
-
import { getChartColor, getColorIndicator } from './utils';
|
|
4
|
-
import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
|
|
5
|
-
import { LineChartWithData } from '../LineChartWithData';
|
|
6
|
-
import { useRecords } from '../../utils';
|
|
7
|
-
const InstrumentRateWithChart = _ref => {
|
|
8
|
-
let {
|
|
9
|
-
loading,
|
|
10
|
-
record,
|
|
11
|
-
target,
|
|
12
|
-
division,
|
|
13
|
-
size
|
|
14
|
-
} = _ref;
|
|
15
|
-
const {
|
|
16
|
-
isDark
|
|
17
|
-
} = useContext(ThemeContext);
|
|
18
|
-
const {
|
|
19
|
-
updatedRecord,
|
|
20
|
-
error
|
|
21
|
-
} = useRecords(record, record?.instrument ? target : null);
|
|
22
|
-
const indicator = getColorIndicator(updatedRecord.dailyPercentChange);
|
|
23
|
-
return React.createElement(React.Fragment, null, React.createElement(InstrumentRate, {
|
|
24
|
-
isLoading: loading,
|
|
25
|
-
isError: !!error,
|
|
26
|
-
record: updatedRecord,
|
|
27
|
-
size: size,
|
|
28
|
-
tooltipId: INSTRUMENT_TOOLTIP_ID,
|
|
29
|
-
colorIndicator: indicator
|
|
30
|
-
}), size === 'fullWithChart' && React.createElement(LineChartWithData, {
|
|
31
|
-
record: record,
|
|
32
|
-
isLoading: loading,
|
|
33
|
-
division: division,
|
|
34
|
-
color: getChartColor(indicator, isDark)
|
|
35
|
-
}));
|
|
36
|
-
};
|
|
37
|
-
export { InstrumentRateWithChart };
|
|
38
|
-
//# sourceMappingURL=InstrumentRateWithChart.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentRateWithChart.js","names":["React","useContext","InstrumentRate","ThemeContext","getChartColor","getColorIndicator","INSTRUMENT_TOOLTIP_ID","LineChartWithData","useRecords","InstrumentRateWithChart","_ref","loading","record","target","division","size","isDark","updatedRecord","error","instrument","indicator","dailyPercentChange","createElement","Fragment","isLoading","isError","tooltipId","colorIndicator","color"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { InstrumentRate, ThemeContext } from '@oanda/labs-widget-common';\nimport { InstrumentRateWithChartProps } from './types';\nimport { getChartColor, getColorIndicator } from './utils';\nimport { INSTRUMENT_TOOLTIP_ID } from '../../constant';\nimport { LineChartWithData } from '../LineChartWithData';\nimport { useRecords } from '../../utils';\n\nconst InstrumentRateWithChart = ({\n loading,\n record,\n target,\n division,\n size,\n}: InstrumentRateWithChartProps) => {\n const { isDark } = useContext(ThemeContext);\n const { updatedRecord, error } = useRecords(record, record?.instrument ? target : null);\n\n const indicator = getColorIndicator(updatedRecord.dailyPercentChange);\n\n return (\n <>\n <InstrumentRate\n isLoading={loading}\n isError={!!error}\n record={updatedRecord}\n size={size}\n tooltipId={INSTRUMENT_TOOLTIP_ID}\n colorIndicator={indicator}\n />\n {size === 'fullWithChart' && (\n <LineChartWithData\n record={record}\n isLoading={loading}\n division={division}\n color={getChartColor(indicator, isDark)}\n />\n )}\n </>\n );\n};\n\nexport { InstrumentRateWithChart };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,cAAc,EAAEC,YAAY,QAAQ,2BAA2B;AAExE,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,SAAS;AAC1D,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,UAAU,QAAQ,aAAa;AAExC,MAAMC,uBAAuB,GAAGC,IAAA,IAMI;EAAA,IANH;IAC/BC,OAAO;IACPC,MAAM;IACNC,MAAM;IACNC,QAAQ;IACRC;EAC4B,CAAC,GAAAL,IAAA;EAC7B,MAAM;IAAEM;EAAO,CAAC,GAAGf,UAAU,CAACE,YAAY,CAAC;EAC3C,MAAM;IAAEc,aAAa;IAAEC;EAAM,CAAC,GAAGV,UAAU,CAACI,MAAM,EAAEA,MAAM,EAAEO,UAAU,GAAGN,MAAM,GAAG,IAAI,CAAC;EAEvF,MAAMO,SAAS,GAAGf,iBAAiB,CAACY,aAAa,CAACI,kBAAkB,CAAC;EAErE,OACErB,KAAA,CAAAsB,aAAA,CAAAtB,KAAA,CAAAuB,QAAA,QACEvB,KAAA,CAAAsB,aAAA,CAACpB,cAAc;IACbsB,SAAS,EAAEb,OAAQ;IACnBc,OAAO,EAAE,CAAC,CAACP,KAAM;IACjBN,MAAM,EAAEK,aAAc;IACtBF,IAAI,EAAEA,IAAK;IACXW,SAAS,EAAEpB,qBAAsB;IACjCqB,cAAc,EAAEP;EAAU,CAC3B,CAAC,EACDL,IAAI,KAAK,eAAe,IACvBf,KAAA,CAAAsB,aAAA,CAACf,iBAAiB;IAChBK,MAAM,EAAEA,MAAO;IACfY,SAAS,EAAEb,OAAQ;IACnBG,QAAQ,EAAEA,QAAS;IACnBc,KAAK,EAAExB,aAAa,CAACgB,SAAS,EAAEJ,MAAM;EAAE,CACzC,CAEH,CAAC;AAEP,CAAC;AAED,SAASP,uBAAuB","ignoreList":[]}
|