@oanda/labs-ticker-tape-widget 1.0.28 → 1.0.30
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 +244 -0
- package/dist/main/TickerTapeWidget/Main.js +11 -11
- package/dist/main/TickerTapeWidget/Main.js.map +1 -1
- package/dist/main/TickerTapeWidget/TickerTapeWidget.js +29 -29
- package/dist/main/TickerTapeWidget/TickerTapeWidget.js.map +1 -1
- package/dist/main/TickerTapeWidget/ValidationWrapper.js +5 -7
- package/dist/main/TickerTapeWidget/ValidationWrapper.js.map +1 -1
- package/dist/main/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +5 -5
- package/dist/main/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +1 -1
- package/dist/main/TickerTapeWidget/components/InstrumentRateWithData/types.js.map +1 -1
- package/dist/main/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.js +1 -1
- package/dist/main/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.js.map +1 -1
- package/dist/main/TickerTapeWidget/constant.js.map +1 -1
- package/dist/main/TickerTapeWidget/index.js +8 -8
- package/dist/main/TickerTapeWidget/index.js.map +1 -1
- package/dist/main/TickerTapeWidget/render.js +7 -7
- package/dist/main/TickerTapeWidget/render.js.map +1 -1
- package/dist/main/TickerTapeWidget/types.js +1 -1
- package/dist/main/TickerTapeWidget/types.js.map +1 -1
- package/dist/main/TickerTapeWidget/utils.js +1 -1
- package/dist/main/TickerTapeWidget/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/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/TickerTapeWidget/Main.js +10 -10
- package/dist/module/TickerTapeWidget/Main.js.map +1 -1
- package/dist/module/TickerTapeWidget/TickerTapeWidget.js +30 -29
- package/dist/module/TickerTapeWidget/TickerTapeWidget.js.map +1 -1
- package/dist/module/TickerTapeWidget/ValidationWrapper.js +5 -5
- package/dist/module/TickerTapeWidget/ValidationWrapper.js.map +1 -1
- package/dist/module/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +5 -5
- package/dist/module/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +1 -1
- package/dist/module/TickerTapeWidget/components/InstrumentRateWithData/types.js.map +1 -1
- package/dist/module/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.js +1 -1
- package/dist/module/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.js.map +1 -1
- package/dist/module/TickerTapeWidget/constant.js.map +1 -1
- package/dist/module/TickerTapeWidget/index.js +1 -1
- package/dist/module/TickerTapeWidget/index.js.map +1 -1
- package/dist/module/TickerTapeWidget/render.js +7 -7
- package/dist/module/TickerTapeWidget/render.js.map +1 -1
- package/dist/module/TickerTapeWidget/types.js +1 -1
- package/dist/module/TickerTapeWidget/types.js.map +1 -1
- package/dist/module/TickerTapeWidget/utils.js +1 -1
- package/dist/module/TickerTapeWidget/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/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/TickerTapeWidget/Main.d.ts +1 -1
- package/dist/types/TickerTapeWidget/TickerTapeWidget.d.ts +1 -1
- package/dist/types/TickerTapeWidget/ValidationWrapper.d.ts +1 -1
- package/dist/types/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.d.ts +1 -1
- package/dist/types/TickerTapeWidget/components/InstrumentRateWithData/types.d.ts +2 -2
- package/dist/types/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.d.ts +1 -1
- package/dist/types/TickerTapeWidget/constant.d.ts +1 -1
- package/dist/types/TickerTapeWidget/index.d.ts +1 -1
- package/dist/types/TickerTapeWidget/types.d.ts +3 -3
- package/dist/types/TickerTapeWidget/utils.d.ts +3 -3
- package/dist/types/gql/types/gql.d.ts +4 -4
- package/dist/types/gql/types/index.d.ts +2 -2
- package/dist/types/translations/index.d.ts +2 -2
- package/package.json +3 -3
- package/src/TickerTapeWidget/Main.tsx +23 -14
- package/src/TickerTapeWidget/TickerTapeWidget.tsx +34 -30
- package/src/TickerTapeWidget/ValidationWrapper.tsx +24 -16
- package/src/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.tsx +12 -8
- package/src/TickerTapeWidget/components/InstrumentRateWithData/types.ts +4 -3
- package/src/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.tsx +6 -8
- package/src/TickerTapeWidget/constant.ts +1 -3
- package/src/TickerTapeWidget/index.ts +1 -1
- package/src/TickerTapeWidget/render.tsx +47 -32
- package/src/TickerTapeWidget/types.ts +8 -3
- package/src/TickerTapeWidget/utils.ts +16 -16
- package/src/gql/types/fragment-masking.ts +41 -21
- package/src/gql/types/gql.ts +12 -5
- package/src/gql/types/graphql.ts +214 -50
- package/src/gql/types/index.ts +2 -2
- package/src/translations/index.ts +4 -4
- package/src/translations/translations.ts +2 -1
- package/test/Main.test.tsx +22 -14
- package/test/mocks.ts +1 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DataRecord, WidgetConfig, WidgetSize } from '@oanda/labs-widget-common';
|
|
2
|
-
import { Division } from '../gql/types/graphql';
|
|
3
|
-
export { Locale } from '@oanda/mono-i18n';
|
|
1
|
+
import type { DataRecord, WidgetConfig, WidgetSize } 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 interface TickerTapeConfig extends WidgetConfig {
|
|
6
6
|
division: Division;
|
|
7
7
|
liveRatesUrl: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataRecord, LiveRatesErrorMessage } from '@oanda/labs-widget-common';
|
|
2
|
-
import { ValidateInstrumentsQuery } from '../gql/types/graphql';
|
|
1
|
+
import type { DataRecord, LiveRatesErrorMessage } from '@oanda/labs-widget-common';
|
|
2
|
+
import type { ValidateInstrumentsQuery } from '../gql/types/graphql';
|
|
3
3
|
declare const getRecords: (data: ValidateInstrumentsQuery) => {
|
|
4
4
|
instrument: string;
|
|
5
5
|
displayName: string;
|
|
@@ -8,4 +8,4 @@ declare const useRecords: (record: DataRecord, target: EventTarget | null) => {
|
|
|
8
8
|
updatedRecord: DataRecord;
|
|
9
9
|
error: LiveRatesErrorMessage | null;
|
|
10
10
|
};
|
|
11
|
-
export { getRecords, useRecords
|
|
11
|
+
export { 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';
|
|
@@ -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-ticker-tape-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "Labs Ticker Tape 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
|
"react-fast-marquee": "1.6.5"
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"@graphql-codegen/cli": "5.0.0",
|
|
22
22
|
"@graphql-codegen/client-preset": "4.1.0"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "4c5d84b00c7fbf3acd7ef27634fbd2a9ef0afd6b"
|
|
25
25
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
1
|
import { Tooltip, useLiveRatesQuery } from '@oanda/labs-widget-common';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import React, { useEffect } from 'react';
|
|
4
|
+
|
|
6
5
|
import { InstrumentRateWithData } from './components/InstrumentRateWithData';
|
|
7
6
|
import { MarqueeWrapper } from './components/MarqueeWrapper';
|
|
7
|
+
import { INSTRUMENT_TOOLTIP_ID } from './constant';
|
|
8
|
+
import type { MainProps } from './types';
|
|
8
9
|
|
|
9
10
|
const Main = ({
|
|
10
11
|
records,
|
|
@@ -14,7 +15,9 @@ const Main = ({
|
|
|
14
15
|
}: MainProps) => {
|
|
15
16
|
const { target, setQuery } = useLiveRatesQuery();
|
|
16
17
|
|
|
17
|
-
const instrumentsNames = records.map(
|
|
18
|
+
const instrumentsNames = records.map(
|
|
19
|
+
({ instrument: instrumentName }) => instrumentName
|
|
20
|
+
);
|
|
18
21
|
|
|
19
22
|
useEffect(() => {
|
|
20
23
|
if (instrumentsNames[0]) {
|
|
@@ -24,22 +27,28 @@ const Main = ({
|
|
|
24
27
|
}, [records]);
|
|
25
28
|
|
|
26
29
|
return (
|
|
27
|
-
<div data-testid="ticker-tape-wrapper"
|
|
28
|
-
<MarqueeWrapper
|
|
30
|
+
<div className="lw-flex" data-testid="ticker-tape-wrapper">
|
|
31
|
+
<MarqueeWrapper
|
|
32
|
+
isStatic={motion === 'none'}
|
|
33
|
+
shouldPlay={records.length > 0}
|
|
34
|
+
>
|
|
29
35
|
{records.map((record) => (
|
|
30
36
|
<div
|
|
31
37
|
key={record.instrument}
|
|
32
|
-
className={classnames(
|
|
33
|
-
'lw-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
className={classnames(
|
|
39
|
+
'lw-flex lw-border lw-border-r-0 lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary',
|
|
40
|
+
{
|
|
41
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
42
|
+
'lw-h-[54px]': widgetSize === 'compact',
|
|
43
|
+
'lw-w-fit last:lw-border-r': motion === 'none',
|
|
44
|
+
}
|
|
45
|
+
)}
|
|
37
46
|
>
|
|
38
47
|
<InstrumentRateWithData
|
|
39
|
-
record={record}
|
|
40
|
-
target={target}
|
|
41
48
|
division={division}
|
|
49
|
+
record={record}
|
|
42
50
|
size={widgetSize}
|
|
51
|
+
target={target}
|
|
43
52
|
/>
|
|
44
53
|
</div>
|
|
45
54
|
))}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
LiveRatesProvider, ThemeProvider, getLocale, renderComponent,
|
|
6
|
-
} from '@oanda/labs-widget-common';
|
|
1
|
+
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
|
2
|
+
import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
7
5
|
import { translations } from '../translations';
|
|
8
|
-
import {
|
|
6
|
+
import type { TickerTapeConfig } from './types';
|
|
7
|
+
import { Division } from './types';
|
|
9
8
|
import { ValidationWrapper } from './ValidationWrapper';
|
|
10
9
|
|
|
11
10
|
const TickerTapeWidget = ({
|
|
@@ -30,30 +29,35 @@ const TickerTapeWidget = ({
|
|
|
30
29
|
const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';
|
|
31
30
|
|
|
32
31
|
return (
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
<WidgetProvider
|
|
33
|
+
withSuspense
|
|
34
|
+
client={client}
|
|
35
|
+
liveRates={{
|
|
36
|
+
url: liveRatesUrl,
|
|
37
|
+
options: { divisionCode, dataSource },
|
|
38
|
+
}}
|
|
39
|
+
locale={locale}
|
|
40
|
+
styling={{
|
|
41
|
+
removePadding,
|
|
42
|
+
fitContent: motion === 'none',
|
|
43
|
+
}}
|
|
44
|
+
theme={theme}
|
|
45
|
+
translations={translations}
|
|
46
|
+
>
|
|
47
|
+
<WidgetWrapper
|
|
48
|
+
isParamError={isParamError}
|
|
49
|
+
linkArea="full"
|
|
50
|
+
logoLink={logoLink}
|
|
37
51
|
>
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
isParamError={isParamError}
|
|
48
|
-
/>,
|
|
49
|
-
logoLink,
|
|
50
|
-
linkArea: 'full',
|
|
51
|
-
})}
|
|
52
|
-
</ThemeProvider>
|
|
53
|
-
</Suspense>
|
|
54
|
-
</ApolloProvider>
|
|
55
|
-
</LiveRatesProvider>
|
|
56
|
-
</LocaleProvider>
|
|
52
|
+
<ValidationWrapper
|
|
53
|
+
division={division}
|
|
54
|
+
instruments={instruments}
|
|
55
|
+
isParamError={isParamError}
|
|
56
|
+
motion={motion}
|
|
57
|
+
size={size}
|
|
58
|
+
/>
|
|
59
|
+
</WidgetWrapper>
|
|
60
|
+
</WidgetProvider>
|
|
57
61
|
);
|
|
58
62
|
};
|
|
59
63
|
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
1
|
import { useSuspenseQuery } from '@apollo/client';
|
|
2
|
+
import { Error, useLayoutProvider } from '@oanda/labs-widget-common';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
-
import
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
ValidateInstrumentsQuery,
|
|
8
|
+
ValidateInstrumentsQueryVariables,
|
|
9
|
+
} from '../gql/types/graphql';
|
|
5
10
|
import { validateInstruments } from '../gql/validateInstruments';
|
|
6
|
-
import { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';
|
|
7
11
|
import { Main } from './Main';
|
|
12
|
+
import type { ValidationWrapperProps } from './types';
|
|
8
13
|
import { getRecords } from './utils';
|
|
9
|
-
import { ValidationWrapperProps } from './types';
|
|
10
14
|
|
|
11
15
|
const ValidationWrapper = ({
|
|
12
16
|
instruments,
|
|
@@ -15,10 +19,10 @@ const ValidationWrapper = ({
|
|
|
15
19
|
motion,
|
|
16
20
|
isParamError,
|
|
17
21
|
}: ValidationWrapperProps) => {
|
|
18
|
-
const { size } =
|
|
22
|
+
const { size } = useLayoutProvider();
|
|
19
23
|
const { data, error } = useSuspenseQuery<
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
ValidateInstrumentsQuery,
|
|
25
|
+
ValidateInstrumentsQueryVariables
|
|
22
26
|
>(validateInstruments, {
|
|
23
27
|
variables: {
|
|
24
28
|
instruments,
|
|
@@ -34,20 +38,24 @@ const ValidationWrapper = ({
|
|
|
34
38
|
<>
|
|
35
39
|
{!showError && size && (
|
|
36
40
|
<Main
|
|
37
|
-
size={widgetSize}
|
|
38
41
|
division={division}
|
|
39
|
-
records={getRecords(data!)!}
|
|
40
42
|
motion={motion}
|
|
43
|
+
records={getRecords(data!)!}
|
|
44
|
+
size={widgetSize}
|
|
41
45
|
/>
|
|
42
46
|
)}
|
|
43
47
|
{showError && (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
<div
|
|
49
|
+
className={classnames(
|
|
50
|
+
'lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary',
|
|
51
|
+
{
|
|
52
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
53
|
+
'lw-h-[54px]': widgetSize === 'compact',
|
|
54
|
+
}
|
|
55
|
+
)}
|
|
56
|
+
>
|
|
57
|
+
<Error />
|
|
58
|
+
</div>
|
|
51
59
|
)}
|
|
52
60
|
</>
|
|
53
61
|
);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { useBackgroundQuery } from '@apollo/client';
|
|
3
2
|
import { InstrumentRateWithChart } from '@oanda/labs-widget-common';
|
|
4
|
-
import
|
|
5
|
-
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
6
5
|
import { getInstrumentsChart } from '../../../gql/getInstrumentsChart';
|
|
7
|
-
import {
|
|
6
|
+
import type {
|
|
7
|
+
GetInstrumentsChartQuery,
|
|
8
|
+
GetInstrumentsChartQueryVariables,
|
|
9
|
+
} from '../../../gql/types/graphql';
|
|
10
|
+
import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
|
|
11
|
+
import type { InstrumentRateWithDataProps } from './types';
|
|
8
12
|
|
|
9
13
|
const InstrumentRateWithData = ({
|
|
10
14
|
record,
|
|
@@ -15,8 +19,8 @@ const InstrumentRateWithData = ({
|
|
|
15
19
|
const hasInstrument = !!record.instrument;
|
|
16
20
|
|
|
17
21
|
const [queryRef] = useBackgroundQuery<
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
GetInstrumentsChartQuery,
|
|
23
|
+
GetInstrumentsChartQueryVariables
|
|
20
24
|
>(getInstrumentsChart, {
|
|
21
25
|
variables: {
|
|
22
26
|
instruments: [record.instrument],
|
|
@@ -28,11 +32,11 @@ const InstrumentRateWithData = ({
|
|
|
28
32
|
|
|
29
33
|
return (
|
|
30
34
|
<InstrumentRateWithChart<GetInstrumentsChartQuery>
|
|
35
|
+
queryRef={queryRef}
|
|
31
36
|
record={record}
|
|
32
|
-
target={target}
|
|
33
37
|
size={size}
|
|
38
|
+
target={target}
|
|
34
39
|
tooltipId={INSTRUMENT_TOOLTIP_ID}
|
|
35
|
-
queryRef={queryRef}
|
|
36
40
|
/>
|
|
37
41
|
);
|
|
38
42
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { DataRecord, WidgetSize } from '@oanda/labs-widget-common';
|
|
2
|
-
|
|
1
|
+
import type { DataRecord, WidgetSize } from '@oanda/labs-widget-common';
|
|
2
|
+
|
|
3
|
+
import type { Division } from '../../types';
|
|
3
4
|
|
|
4
5
|
export interface InstrumentRateWithDataProps {
|
|
5
6
|
record: DataRecord;
|
|
6
7
|
target: EventTarget | null;
|
|
7
8
|
division: Division;
|
|
8
|
-
size?: WidgetSize
|
|
9
|
+
size?: WidgetSize;
|
|
9
10
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Marquee from 'react-fast-marquee';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import type { MarqueeWrapperProps } from './types';
|
|
4
5
|
|
|
5
6
|
const MarqueeWrapper = ({
|
|
6
7
|
children,
|
|
@@ -9,15 +10,12 @@ const MarqueeWrapper = ({
|
|
|
9
10
|
}: MarqueeWrapperProps) => (
|
|
10
11
|
<>
|
|
11
12
|
{!isStatic ? (
|
|
12
|
-
<Marquee
|
|
13
|
-
play={shouldPlay}
|
|
14
|
-
autoFill
|
|
15
|
-
pauseOnHover
|
|
16
|
-
speed={60}
|
|
17
|
-
>
|
|
13
|
+
<Marquee autoFill pauseOnHover play={shouldPlay} speed={60}>
|
|
18
14
|
{children}
|
|
19
15
|
</Marquee>
|
|
20
|
-
) :
|
|
16
|
+
) : (
|
|
17
|
+
children
|
|
18
|
+
)}
|
|
21
19
|
</>
|
|
22
20
|
);
|
|
23
21
|
|
|
@@ -1,52 +1,67 @@
|
|
|
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 { TickerTapeWidget } from './TickerTapeWidget';
|
|
5
|
+
|
|
5
6
|
import { Division } from '../gql/types/graphql';
|
|
7
|
+
import { TickerTapeWidget } from './TickerTapeWidget';
|
|
6
8
|
|
|
7
|
-
const {
|
|
8
|
-
graphqlUrl,
|
|
9
|
-
liveRatesUrl,
|
|
10
|
-
} = window.widgetsConfig || {};
|
|
9
|
+
const { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};
|
|
11
10
|
|
|
12
|
-
const dataTickerTapeParamsElements = document.querySelectorAll(
|
|
11
|
+
const dataTickerTapeParamsElements = document.querySelectorAll(
|
|
12
|
+
'div[data-ticker-tape-params]'
|
|
13
|
+
);
|
|
13
14
|
|
|
14
15
|
dataTickerTapeParamsElements.forEach((element) => {
|
|
15
16
|
const root = createRoot(element);
|
|
16
17
|
const params = element.getAttribute('data-ticker-tape-params');
|
|
17
18
|
const mode = element.getAttribute('data-mode');
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const { instruments, division, locale, size, motion } = 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
|
-
|
|
23
|
+
const isParamError = validateToolParams(
|
|
24
|
+
{
|
|
25
|
+
division,
|
|
26
|
+
locale,
|
|
27
|
+
graphqlUrl,
|
|
28
|
+
liveRatesUrl,
|
|
29
|
+
instruments,
|
|
30
|
+
},
|
|
31
|
+
[
|
|
32
|
+
{
|
|
33
|
+
name: 'locale',
|
|
34
|
+
valueCheck: (value: string | undefined) => validateLocale(value),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'division',
|
|
38
|
+
valueCheck: (value: Division) =>
|
|
39
|
+
Object.values(Division).includes(value),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'instruments',
|
|
43
|
+
valueCheck: (value) => value.length > 0 && value.length <= 10,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'graphqlUrl',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'liveRatesUrl',
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
);
|
|
38
53
|
|
|
39
54
|
root.render(
|
|
40
55
|
<TickerTapeWidget
|
|
41
|
-
graphqlUrl={graphqlUrl}
|
|
42
|
-
liveRatesUrl={liveRatesUrl}
|
|
43
56
|
division={division}
|
|
57
|
+
graphqlUrl={graphqlUrl}
|
|
44
58
|
instruments={instruments}
|
|
45
|
-
locale={locale}
|
|
46
|
-
theme={mode as Theme}
|
|
47
59
|
isParamError={isParamError}
|
|
48
|
-
|
|
60
|
+
liveRatesUrl={liveRatesUrl}
|
|
61
|
+
locale={locale}
|
|
49
62
|
motion={motion}
|
|
50
|
-
|
|
63
|
+
size={size}
|
|
64
|
+
theme={mode as Theme}
|
|
65
|
+
/>
|
|
51
66
|
);
|
|
52
67
|
});
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type {
|
|
2
|
+
DataRecord,
|
|
3
|
+
WidgetConfig,
|
|
4
|
+
WidgetSize,
|
|
5
|
+
} from '@oanda/labs-widget-common';
|
|
6
|
+
|
|
7
|
+
import type { Division } from '../gql/types/graphql';
|
|
3
8
|
|
|
4
|
-
export { Locale } from '@oanda/mono-i18n';
|
|
5
9
|
export { Division } from '../gql/types/graphql';
|
|
10
|
+
export { Locale } from '@oanda/mono-i18n';
|
|
6
11
|
|
|
7
12
|
export interface TickerTapeConfig extends WidgetConfig {
|
|
8
13
|
division: Division;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type {
|
|
2
|
+
DataRecord,
|
|
3
|
+
LiveRatesErrorMessage,
|
|
4
|
+
} from '@oanda/labs-widget-common';
|
|
5
|
+
import { useLiveRatesMessage } from '@oanda/labs-widget-common';
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
instrument: item?.name || '',
|
|
7
|
-
displayName: item?.displayName || '',
|
|
8
|
-
}));
|
|
8
|
+
import type { ValidateInstrumentsQuery } from '../gql/types/graphql';
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const getRecords = (data: ValidateInstrumentsQuery) =>
|
|
11
|
+
data?.mapInstrumentNames?.map((item) => ({
|
|
12
|
+
instrument: item?.name || '',
|
|
13
|
+
displayName: item?.displayName || '',
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
const useRecords = (record: DataRecord, target: EventTarget | null) => {
|
|
14
17
|
const [updatedRecord, setUpdatedRecord] = useState<DataRecord>({
|
|
15
18
|
displayName: record.displayName,
|
|
16
19
|
instrument: record.instrument,
|
|
@@ -20,7 +23,7 @@ const useRecords = (
|
|
|
20
23
|
|
|
21
24
|
const { update, error: liveRatesError } = useLiveRatesMessage(
|
|
22
25
|
record.instrument,
|
|
23
|
-
target
|
|
26
|
+
target
|
|
24
27
|
);
|
|
25
28
|
|
|
26
29
|
useEffect(() => {
|
|
@@ -42,7 +45,4 @@ const useRecords = (
|
|
|
42
45
|
};
|
|
43
46
|
};
|
|
44
47
|
|
|
45
|
-
export {
|
|
46
|
-
getRecords,
|
|
47
|
-
useRecords,
|
|
48
|
-
};
|
|
48
|
+
export { getRecords, useRecords };
|