@oanda/labs-currency-cross-table 1.0.24 → 1.0.25
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 +104 -0
- package/dist/main/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js +11 -11
- package/dist/main/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/Main.js +10 -10
- package/dist/main/CurrencyCrossTableWidget/Main.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/ValidationWrapper.js +6 -6
- package/dist/main/CurrencyCrossTableWidget/ValidationWrapper.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/Cell.js +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/Cell.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/CellWithData.js +7 -7
- package/dist/main/CurrencyCrossTableWidget/components/CellWithData.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/TextCell.js +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/TextCell.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/components/types.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/constant.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/index.js +8 -8
- package/dist/main/CurrencyCrossTableWidget/index.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/render.js +6 -6
- package/dist/main/CurrencyCrossTableWidget/render.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/types.js.map +1 -1
- package/dist/main/CurrencyCrossTableWidget/utils.js.map +1 -1
- package/dist/main/gql/types/fragment-masking.js.map +1 -1
- package/dist/main/gql/types/gql.js +1 -1
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +73 -73
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/main/gql/types/index.js.map +1 -1
- package/dist/main/gql/validateInstruments.js +4 -1
- package/dist/main/gql/validateInstruments.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/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js +11 -11
- package/dist/module/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/Main.js +10 -10
- package/dist/module/CurrencyCrossTableWidget/Main.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/ValidationWrapper.js +6 -6
- package/dist/module/CurrencyCrossTableWidget/ValidationWrapper.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/Cell.js +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/Cell.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/CellWithData.js +7 -7
- package/dist/module/CurrencyCrossTableWidget/components/CellWithData.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/TextCell.js +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/TextCell.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/components/types.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/constant.js +1 -1
- package/dist/module/CurrencyCrossTableWidget/constant.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/index.js +1 -1
- package/dist/module/CurrencyCrossTableWidget/index.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/render.js +6 -6
- package/dist/module/CurrencyCrossTableWidget/render.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/types.js.map +1 -1
- package/dist/module/CurrencyCrossTableWidget/utils.js +1 -1
- package/dist/module/CurrencyCrossTableWidget/utils.js.map +1 -1
- package/dist/module/gql/types/fragment-masking.js.map +1 -1
- package/dist/module/gql/types/gql.js +1 -1
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +73 -73
- 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/gql/validateInstruments.js +4 -1
- package/dist/module/gql/validateInstruments.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/CurrencyCrossTableWidget/CurrencyCrossTableWidget.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/Main.d.ts +2 -2
- package/dist/types/CurrencyCrossTableWidget/ValidationWrapper.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/components/Cell.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/components/CellWithData.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/components/TextCell.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/components/types.d.ts +2 -2
- package/dist/types/CurrencyCrossTableWidget/constant.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/index.d.ts +1 -1
- package/dist/types/CurrencyCrossTableWidget/types.d.ts +2 -2
- package/dist/types/CurrencyCrossTableWidget/utils.d.ts +3 -3
- package/dist/types/gql/types/gql.d.ts +2 -2
- 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/CurrencyCrossTableWidget/CurrencyCrossTableWidget.tsx +11 -13
- package/src/CurrencyCrossTableWidget/Main.tsx +21 -28
- package/src/CurrencyCrossTableWidget/ValidationWrapper.tsx +28 -21
- package/src/CurrencyCrossTableWidget/components/Cell.tsx +11 -8
- package/src/CurrencyCrossTableWidget/components/CellWithData.tsx +24 -15
- package/src/CurrencyCrossTableWidget/components/TextCell.tsx +14 -9
- package/src/CurrencyCrossTableWidget/components/types.ts +3 -2
- package/src/CurrencyCrossTableWidget/constant.ts +13 -4
- package/src/CurrencyCrossTableWidget/index.ts +1 -1
- package/src/CurrencyCrossTableWidget/render.tsx +44 -30
- package/src/CurrencyCrossTableWidget/types.tsx +3 -2
- package/src/CurrencyCrossTableWidget/utils.ts +10 -7
- package/src/gql/types/fragment-masking.ts +41 -21
- package/src/gql/types/gql.ts +7 -3
- package/src/gql/types/graphql.ts +129 -47
- package/src/gql/types/index.ts +2 -2
- package/src/gql/validateInstruments.ts +4 -1
- package/src/translations/index.ts +4 -4
- package/src/translations/translations.ts +2 -1
- package/test/Main.test.tsx +17 -5
- package/test/mocks.ts +23 -14
- package/test/utils.test.ts +119 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateInstruments.js","names":["gql","validateInstruments"],"sources":["../../../src/gql/validateInstruments.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nexport const validateInstruments = gql`\n query validateInstruments($instruments: [String]!, $division: Division!) {\n resolveInstrumentsByDivision(instruments: $instruments
|
|
1
|
+
{"version":3,"file":"validateInstruments.js","names":["gql","validateInstruments"],"sources":["../../../src/gql/validateInstruments.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nexport const validateInstruments = gql`\n query validateInstruments($instruments: [String]!, $division: Division!) {\n resolveInstrumentsByDivision(\n instruments: $instruments\n division: $division\n ) {\n name\n displayName\n }\n }\n`;\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AAEpC,OAAO,MAAMC,mBAAmB,GAAGD,GAAG;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Locale } from '@oanda/mono-i18n';
|
|
2
2
|
import en from './sources/en.json';
|
|
3
|
-
import zhTW from './sources/zh_TW.json';
|
|
4
3
|
import es from './sources/es.json';
|
|
5
4
|
import th from './sources/th.json';
|
|
5
|
+
import zhTW from './sources/zh_TW.json';
|
|
6
6
|
export const translations = {
|
|
7
7
|
[Locale.en]: {
|
|
8
8
|
translation: en
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Locale","en","
|
|
1
|
+
{"version":3,"file":"index.js","names":["Locale","en","es","th","zhTW","translations","translation"],"sources":["../../../src/translations/index.ts"],"sourcesContent":["import type { Translations } from '@oanda/mono-i18n';\nimport { Locale } from '@oanda/mono-i18n';\n\nimport en from './sources/en.json';\nimport es from './sources/es.json';\nimport th from './sources/th.json';\nimport zhTW from './sources/zh_TW.json';\nimport type { defaultTranslations } from './translations';\n\nexport type TranslationKey = keyof typeof defaultTranslations;\n\nexport const translations: Translations = {\n [Locale.en]: { translation: en },\n [Locale.zhTW]: { translation: zhTW },\n [Locale.es]: { translation: es },\n [Locale.th]: { translation: th },\n};\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,kBAAkB;AAEzC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,IAAI,MAAM,sBAAsB;AAKvC,OAAO,MAAMC,YAA0B,GAAG;EACxC,CAACL,MAAM,CAACC,EAAE,GAAG;IAAEK,WAAW,EAAEL;EAAG,CAAC;EAChC,CAACD,MAAM,CAACI,IAAI,GAAG;IAAEE,WAAW,EAAEF;EAAK,CAAC;EACpC,CAACJ,MAAM,CAACE,EAAE,GAAG;IAAEI,WAAW,EAAEJ;EAAG,CAAC;EAChC,CAACF,MAAM,CAACG,EAAE,GAAG;IAAEG,WAAW,EAAEH;EAAG;AACjC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.js","names":["defaultTranslations","data_unavailable","pagination_entries_range"],"sources":["../../../src/translations/translations.ts"],"sourcesContent":["export const defaultTranslations = {\n data_unavailable: 'Data unavailable',\n pagination_entries_range
|
|
1
|
+
{"version":3,"file":"translations.js","names":["defaultTranslations","data_unavailable","pagination_entries_range"],"sources":["../../../src/translations/translations.ts"],"sourcesContent":["export const defaultTranslations = {\n data_unavailable: 'Data unavailable',\n pagination_entries_range:\n '{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries',\n};\n"],"mappings":"AAAA,OAAO,MAAMA,mBAAmB,GAAG;EACjCC,gBAAgB,EAAE,kBAAkB;EACpCC,wBAAwB,EACtB;AACJ,CAAC","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CurrencyCrossTableConfig } from './types';
|
|
2
|
+
import type { CurrencyCrossTableConfig } from './types';
|
|
3
3
|
declare const CurrencyCrossTableWidget: ({ graphqlUrl, liveRatesUrl, currencies, division, locale, theme, isParamError, removePadding, logoLink, }: CurrencyCrossTableConfig) => React.JSX.Element;
|
|
4
4
|
export { CurrencyCrossTableWidget };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { MainProps } from './types';
|
|
3
|
-
declare const Main: ({ currencies, validInstruments, division
|
|
2
|
+
import type { MainProps } from './types';
|
|
3
|
+
declare const Main: ({ currencies, validInstruments, division }: MainProps) => React.JSX.Element;
|
|
4
4
|
export { Main };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ValidationWrapperProps } from './types';
|
|
2
|
+
import type { ValidationWrapperProps } from './types';
|
|
3
3
|
declare const ValidationWrapper: ({ currencies, division, isParamError, }: ValidationWrapperProps) => React.JSX.Element;
|
|
4
4
|
export { ValidationWrapper };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { CellWithDataProps } from './types';
|
|
2
|
+
import type { CellWithDataProps } from './types';
|
|
3
3
|
declare const CellWithData: ({ currency, pair, isValid, target, division, setSelectedCurrency, setSelectedPair, }: CellWithDataProps) => React.JSX.Element;
|
|
4
4
|
export { CellWithData };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LoaderSize } from '@oanda/labs-widget-common';
|
|
2
|
-
import { Division } from '../../gql/types/graphql';
|
|
1
|
+
import type { LoaderSize } from '@oanda/labs-widget-common';
|
|
2
|
+
import type { Division } from '../../gql/types/graphql';
|
|
3
3
|
export interface CellWithDataProps {
|
|
4
4
|
currency: string;
|
|
5
5
|
pair: string;
|
|
@@ -2,4 +2,4 @@ declare const MAJOR_CURRENCIES: string[];
|
|
|
2
2
|
declare const INSTRUMENT_TOOLTIP_ID = "instrument_tooltip_id";
|
|
3
3
|
declare const CELL_LOADING_VALUE = "...";
|
|
4
4
|
declare const CELL_EMPTY_VALUE = "\u2014";
|
|
5
|
-
export {
|
|
5
|
+
export { CELL_EMPTY_VALUE, CELL_LOADING_VALUE, INSTRUMENT_TOOLTIP_ID, MAJOR_CURRENCIES, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { WidgetConfig } from '@oanda/labs-widget-common';
|
|
2
|
-
import { Division } from '../gql/types/graphql';
|
|
1
|
+
import type { WidgetConfig } from '@oanda/labs-widget-common';
|
|
2
|
+
import type { Division } from '../gql/types/graphql';
|
|
3
3
|
export { Locale } from '@oanda/mono-i18n';
|
|
4
4
|
export interface CurrencyCrossTableConfig extends WidgetConfig {
|
|
5
5
|
division: Division;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Division } from '../gql/types/graphql';
|
|
1
|
+
import type { Division } from '../gql/types/graphql';
|
|
2
2
|
declare const validCurrencies: (currencies: string[]) => boolean;
|
|
3
3
|
declare const divisionMapper: (division: Division) => "" | "_";
|
|
4
|
-
declare const currenciesToInstruments: (currencies: string[], division:
|
|
4
|
+
declare const currenciesToInstruments: (currencies: string[], division: Division) => string[];
|
|
5
5
|
declare const getPriceMovement: (priceMovement: number | undefined, isReversed: boolean) => number;
|
|
6
6
|
declare const getBuyPrice: (price: number | undefined, isReversed: boolean) => number;
|
|
7
|
-
export {
|
|
7
|
+
export { currenciesToInstruments, divisionMapper, getBuyPrice, getPriceMovement, validCurrencies, };
|
|
@@ -11,7 +11,7 @@ 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 validateInstruments($instruments: [String]!, $division: Division!) {\n resolveInstrumentsByDivision(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n': DocumentNode<types.ValidateInstrumentsQuery, types.Exact<{
|
|
15
15
|
instruments: Array<types.InputMaybe<types.Scalars["String"]["input"]>> | types.InputMaybe<types.Scalars["String"]["input"]>;
|
|
16
16
|
division: types.Division;
|
|
17
17
|
}>>;
|
|
@@ -32,6 +32,6 @@ export declare function graphql(source: string): unknown;
|
|
|
32
32
|
/**
|
|
33
33
|
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
|
|
34
34
|
*/
|
|
35
|
-
export declare function graphql(source:
|
|
35
|
+
export declare function graphql(source: '\n query validateInstruments($instruments: [String]!, $division: Division!) {\n resolveInstrumentsByDivision(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n'): (typeof documents)['\n query validateInstruments($instruments: [String]!, $division: Division!) {\n resolveInstrumentsByDivision(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n'];
|
|
36
36
|
export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;
|
|
37
37
|
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-currency-cross-table",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"description": "Labs Currency Cross Table",
|
|
5
5
|
"main": "dist/main/index.js",
|
|
6
6
|
"module": "dist/module/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"author": "OANDA",
|
|
13
13
|
"license": "UNLICENSED",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@oanda/labs-widget-common": "^1.0.
|
|
15
|
+
"@oanda/labs-widget-common": "^1.0.174",
|
|
16
16
|
"@oanda/mono-i18n": "10.0.1",
|
|
17
17
|
"graphql": "16.8.1"
|
|
18
18
|
},
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"@graphql-codegen/cli": "5.0.0",
|
|
21
21
|
"@graphql-codegen/client-preset": "4.1.0"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "4c5d84b00c7fbf3acd7ef27634fbd2a9ef0afd6b"
|
|
24
24
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
|
3
2
|
import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { Division } from '../gql/types/graphql';
|
|
4
6
|
import { translations } from '../translations';
|
|
5
|
-
import { CurrencyCrossTableConfig } from './types';
|
|
7
|
+
import type { CurrencyCrossTableConfig } from './types';
|
|
6
8
|
import { ValidationWrapper } from './ValidationWrapper';
|
|
7
|
-
import { Division } from '../gql/types/graphql';
|
|
8
9
|
|
|
9
10
|
const CurrencyCrossTableWidget = ({
|
|
10
11
|
graphqlUrl,
|
|
@@ -28,22 +29,19 @@ const CurrencyCrossTableWidget = ({
|
|
|
28
29
|
return (
|
|
29
30
|
<WidgetProvider
|
|
30
31
|
withSuspense
|
|
31
|
-
locale={locale}
|
|
32
|
-
translations={translations}
|
|
33
32
|
client={client}
|
|
34
|
-
theme={theme}
|
|
35
|
-
styling={{
|
|
36
|
-
removePadding,
|
|
37
|
-
}}
|
|
38
33
|
liveRates={{
|
|
39
34
|
url: liveRatesUrl,
|
|
40
35
|
options: { divisionCode, dataSource },
|
|
41
36
|
}}
|
|
37
|
+
locale={locale}
|
|
38
|
+
styling={{
|
|
39
|
+
removePadding,
|
|
40
|
+
}}
|
|
41
|
+
theme={theme}
|
|
42
|
+
translations={translations}
|
|
42
43
|
>
|
|
43
|
-
<WidgetWrapper
|
|
44
|
-
logoLink={logoLink}
|
|
45
|
-
linkArea="full"
|
|
46
|
-
>
|
|
44
|
+
<WidgetWrapper linkArea="full" logoLink={logoLink}>
|
|
47
45
|
<ValidationWrapper
|
|
48
46
|
currencies={currencies}
|
|
49
47
|
division={division}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
Fragment, useEffect, useState,
|
|
3
|
-
} from 'react';
|
|
4
1
|
import { useLiveRatesQuery } from '@oanda/labs-widget-common';
|
|
5
|
-
import {
|
|
2
|
+
import React, { Fragment, useEffect, useState } from 'react';
|
|
3
|
+
|
|
6
4
|
import { CellWithData, TextCell } from './components';
|
|
5
|
+
import type { MainProps } from './types';
|
|
7
6
|
import { divisionMapper } from './utils';
|
|
8
7
|
|
|
9
|
-
const Main = ({
|
|
10
|
-
currencies,
|
|
11
|
-
validInstruments,
|
|
12
|
-
division,
|
|
13
|
-
}: MainProps) => {
|
|
8
|
+
const Main = ({ currencies, validInstruments, division }: MainProps) => {
|
|
14
9
|
const [selectedCurrency, setSelectedCurrency] = useState('');
|
|
15
10
|
const [selectedPair, setSelectedPair] = useState('');
|
|
16
11
|
const { target, setQuery } = useLiveRatesQuery();
|
|
@@ -21,38 +16,36 @@ const Main = ({
|
|
|
21
16
|
}, validInstruments);
|
|
22
17
|
|
|
23
18
|
return (
|
|
24
|
-
<div
|
|
19
|
+
<div
|
|
20
|
+
className="lw-w-full lw-overflow-x-auto lw-overflow-y-hidden lw-border lw-border-b-0 lw-border-solid lw-border-border-primary"
|
|
21
|
+
data-testid="currency-cross-table-wrapper"
|
|
22
|
+
>
|
|
25
23
|
<div className="lw-flex lw-w-max lw-min-w-full">
|
|
26
24
|
<TextCell sticky />
|
|
27
|
-
{currencies.map((
|
|
28
|
-
<TextCell
|
|
29
|
-
|
|
30
|
-
label={pair}
|
|
31
|
-
hovered={pair === selectedPair}
|
|
32
|
-
/>
|
|
33
|
-
)))}
|
|
25
|
+
{currencies.map((pair) => (
|
|
26
|
+
<TextCell key={pair} hovered={pair === selectedPair} label={pair} />
|
|
27
|
+
))}
|
|
34
28
|
</div>
|
|
35
|
-
{currencies.map((
|
|
36
|
-
<div
|
|
37
|
-
key={currency}
|
|
38
|
-
className="lw-flex lw-w-max lw-min-w-full"
|
|
39
|
-
>
|
|
29
|
+
{currencies.map((currency, index, arr) => (
|
|
30
|
+
<div key={currency} className="lw-flex lw-w-max lw-min-w-full">
|
|
40
31
|
<TextCell
|
|
41
|
-
label={currency}
|
|
42
|
-
hovered={currency === selectedCurrency}
|
|
43
32
|
sticky
|
|
33
|
+
hovered={currency === selectedCurrency}
|
|
34
|
+
label={currency}
|
|
44
35
|
/>
|
|
45
36
|
{arr.map((pair) => (
|
|
46
37
|
<Fragment key={`${currency}_${pair}`}>
|
|
47
38
|
{currency !== pair ? (
|
|
48
39
|
<CellWithData
|
|
49
40
|
currency={currency}
|
|
41
|
+
division={division}
|
|
42
|
+
isValid={validInstruments.includes(
|
|
43
|
+
`${currency}${divisionMapper(division)}${pair}`
|
|
44
|
+
)}
|
|
50
45
|
pair={pair}
|
|
51
|
-
isValid={validInstruments.includes(`${currency}${divisionMapper(division)}${pair}`)}
|
|
52
|
-
target={target}
|
|
53
46
|
setSelectedCurrency={setSelectedCurrency}
|
|
54
47
|
setSelectedPair={setSelectedPair}
|
|
55
|
-
|
|
48
|
+
target={target}
|
|
56
49
|
/>
|
|
57
50
|
) : (
|
|
58
51
|
<TextCell emptyIndicator />
|
|
@@ -60,7 +53,7 @@ const Main = ({
|
|
|
60
53
|
</Fragment>
|
|
61
54
|
))}
|
|
62
55
|
</div>
|
|
63
|
-
))
|
|
56
|
+
))}
|
|
64
57
|
</div>
|
|
65
58
|
);
|
|
66
59
|
};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
3
|
-
import { ChartError } from '@oanda/labs-widget-common';
|
|
4
1
|
import { useSuspenseQuery } from '@apollo/client';
|
|
5
|
-
import {
|
|
2
|
+
import { ChartError } from '@oanda/labs-widget-common';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
ValidateInstrumentsQuery,
|
|
8
|
+
ValidateInstrumentsQueryVariables,
|
|
9
|
+
} from '../gql/types/graphql';
|
|
6
10
|
import { validateInstruments } from '../gql/validateInstruments';
|
|
7
|
-
import { currenciesToInstruments, validCurrencies } from './utils';
|
|
8
|
-
import { ValidationWrapperProps } from './types';
|
|
9
11
|
import { Main } from './Main';
|
|
12
|
+
import type { ValidationWrapperProps } from './types';
|
|
13
|
+
import { currenciesToInstruments, validCurrencies } from './utils';
|
|
10
14
|
|
|
11
15
|
const ValidationWrapper = ({
|
|
12
16
|
currencies,
|
|
@@ -16,8 +20,8 @@ const ValidationWrapper = ({
|
|
|
16
20
|
const instruments = currenciesToInstruments(currencies, division);
|
|
17
21
|
|
|
18
22
|
const { data, error } = useSuspenseQuery<
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
ValidateInstrumentsQuery,
|
|
24
|
+
ValidateInstrumentsQueryVariables
|
|
21
25
|
>(validateInstruments, {
|
|
22
26
|
variables: {
|
|
23
27
|
instruments,
|
|
@@ -27,29 +31,32 @@ const ValidationWrapper = ({
|
|
|
27
31
|
errorPolicy: 'all',
|
|
28
32
|
});
|
|
29
33
|
|
|
30
|
-
const validInstruments = data
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const showError =
|
|
34
|
-
||
|
|
35
|
-
||
|
|
36
|
-
||
|
|
37
|
-
|
|
34
|
+
const validInstruments = data?.resolveInstrumentsByDivision?.map(
|
|
35
|
+
(instrument) => instrument.name
|
|
36
|
+
);
|
|
37
|
+
const showError =
|
|
38
|
+
!validCurrencies(currencies) ||
|
|
39
|
+
isParamError ||
|
|
40
|
+
error ||
|
|
41
|
+
!validInstruments ||
|
|
42
|
+
validInstruments.length === 0;
|
|
38
43
|
|
|
39
44
|
return (
|
|
40
45
|
<>
|
|
41
|
-
<div
|
|
42
|
-
className="lw-flex lw-w-full lw-text-sm lw-tracking-normal lw-text-text-primary"
|
|
43
|
-
>
|
|
46
|
+
<div className="lw-flex lw-w-full lw-text-sm lw-tracking-normal lw-text-text-primary">
|
|
44
47
|
{!showError && (
|
|
45
48
|
<Main
|
|
46
|
-
validInstruments={validInstruments}
|
|
47
49
|
currencies={currencies}
|
|
48
50
|
division={division}
|
|
51
|
+
validInstruments={validInstruments}
|
|
49
52
|
/>
|
|
50
53
|
)}
|
|
51
54
|
{showError && (
|
|
52
|
-
<div
|
|
55
|
+
<div
|
|
56
|
+
className={classnames(
|
|
57
|
+
'lw-flex lw-h-[250px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary'
|
|
58
|
+
)}
|
|
59
|
+
>
|
|
53
60
|
<ChartError />
|
|
54
61
|
</div>
|
|
55
62
|
)}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import classnames from 'classnames';
|
|
3
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
4
|
import { CELL_EMPTY_VALUE, CELL_LOADING_VALUE } from '../constant';
|
|
5
|
+
import type { CellProps } from './types';
|
|
5
6
|
|
|
6
7
|
const Cell = ({
|
|
7
8
|
children,
|
|
@@ -12,17 +13,19 @@ const Cell = ({
|
|
|
12
13
|
mouseLeaveHandler,
|
|
13
14
|
}: CellProps) => (
|
|
14
15
|
<div
|
|
15
|
-
className={classnames(
|
|
16
|
-
'lw-
|
|
17
|
-
|
|
16
|
+
className={classnames(
|
|
17
|
+
'lw-flex lw-h-11 lw-min-w-[70px] lw-flex-1 lw-items-center lw-justify-center lw-border-b lw-border-r lw-border-solid lw-border-border-primary last:lw-border-r-[0px]',
|
|
18
|
+
{
|
|
19
|
+
'lw-bg-border-primary lw-font-semibold lw-shadow-innerBorderBgColor':
|
|
20
|
+
hovered,
|
|
21
|
+
}
|
|
22
|
+
)}
|
|
18
23
|
onMouseEnter={mouseEnterHandler}
|
|
19
24
|
onMouseLeave={mouseLeaveHandler}
|
|
20
25
|
>
|
|
21
26
|
{isLoading && <div className="lw-px-3 lw-py-3.5">{CELL_LOADING_VALUE}</div>}
|
|
22
27
|
{!isLoading && !isError && children}
|
|
23
|
-
{!isLoading && isError &&
|
|
24
|
-
<span>{CELL_EMPTY_VALUE}</span>
|
|
25
|
-
)}
|
|
28
|
+
{!isLoading && isError && <span>{CELL_EMPTY_VALUE}</span>}
|
|
26
29
|
</div>
|
|
27
30
|
);
|
|
28
31
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
1
|
import { Price, useLiveRatesMessage } from '@oanda/labs-widget-common';
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
|
|
5
4
|
import { divisionMapper, getBuyPrice, getPriceMovement } from '../utils';
|
|
5
|
+
import { Cell } from './Cell';
|
|
6
|
+
import type { CellWithDataProps } from './types';
|
|
6
7
|
|
|
7
8
|
const CellWithData = ({
|
|
8
9
|
currency,
|
|
@@ -16,22 +17,25 @@ const CellWithData = ({
|
|
|
16
17
|
const [hovered, setHovered] = useState(false);
|
|
17
18
|
|
|
18
19
|
const instrument = `${currency}${divisionMapper(division)}${pair}`;
|
|
19
|
-
const instrumentForUpdates = isValid
|
|
20
|
+
const instrumentForUpdates = isValid
|
|
21
|
+
? instrument
|
|
22
|
+
: `${pair}${divisionMapper(division)}${currency}`;
|
|
20
23
|
|
|
21
24
|
const { update, error: liveRatesError } = useLiveRatesMessage(
|
|
22
25
|
instrumentForUpdates,
|
|
23
|
-
target
|
|
26
|
+
target
|
|
24
27
|
);
|
|
25
28
|
|
|
26
|
-
const updatedRecord
|
|
29
|
+
const updatedRecord = {
|
|
27
30
|
displayName: `${currency}/${pair}`,
|
|
28
31
|
instrument,
|
|
29
32
|
buy: update?.ask,
|
|
30
33
|
buyPriceMovement: update?.askPriceMovement,
|
|
31
|
-
displayPrecision:
|
|
34
|
+
displayPrecision:
|
|
35
|
+
currency === 'JPY' && !isValid ? 6 : update?.displayPrecision,
|
|
32
36
|
};
|
|
33
37
|
|
|
34
|
-
const checkLoading = (
|
|
38
|
+
const checkLoading = () => !liveRatesError && updatedRecord.buy === undefined;
|
|
35
39
|
|
|
36
40
|
const handleMouseEnter = () => {
|
|
37
41
|
setHovered(true);
|
|
@@ -47,18 +51,23 @@ const CellWithData = ({
|
|
|
47
51
|
|
|
48
52
|
return (
|
|
49
53
|
<Cell
|
|
50
|
-
isLoading={checkLoading('buy')}
|
|
51
|
-
isError={!!liveRatesError}
|
|
52
54
|
hovered={hovered}
|
|
55
|
+
isError={!!liveRatesError}
|
|
56
|
+
isLoading={checkLoading()}
|
|
53
57
|
mouseEnterHandler={handleMouseEnter}
|
|
54
58
|
mouseLeaveHandler={handleMouseLeave}
|
|
55
59
|
>
|
|
56
|
-
<Price
|
|
60
|
+
<Price
|
|
61
|
+
movementIndicator="background"
|
|
62
|
+
priceMovement={getPriceMovement(
|
|
63
|
+
updatedRecord.buyPriceMovement,
|
|
64
|
+
!isValid
|
|
65
|
+
)}
|
|
66
|
+
>
|
|
57
67
|
<span>
|
|
58
|
-
{getBuyPrice(
|
|
59
|
-
updatedRecord.
|
|
60
|
-
|
|
61
|
-
).toFixed(updatedRecord.displayPrecision)}
|
|
68
|
+
{getBuyPrice(updatedRecord.buy, !isValid).toFixed(
|
|
69
|
+
updatedRecord.displayPrecision
|
|
70
|
+
)}
|
|
62
71
|
</span>
|
|
63
72
|
</Price>
|
|
64
73
|
</Cell>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import classnames from 'classnames';
|
|
3
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import type { TextCellProps } from './types';
|
|
4
5
|
|
|
5
6
|
const TextCell = ({
|
|
6
7
|
label,
|
|
@@ -8,13 +9,17 @@ const TextCell = ({
|
|
|
8
9
|
hovered,
|
|
9
10
|
sticky,
|
|
10
11
|
}: TextCellProps) => (
|
|
11
|
-
<span
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
<span
|
|
13
|
+
className={classnames(
|
|
14
|
+
'lw-h-11 lw-min-w-[70px] lw-flex-1 lw-border-b lw-border-r lw-border-solid lw-border-border-primary lw-py-3.5 lw-text-center last:lw-border-r-[0px]',
|
|
15
|
+
{
|
|
16
|
+
'lw-bg-border-primary': emptyIndicator,
|
|
17
|
+
'lw-shadow-innerBorderBgColor': emptyIndicator && hovered,
|
|
18
|
+
'lw-bg-border-primary lw-font-semibold': hovered,
|
|
19
|
+
'lw-sticky lw-left-0 lw-z-10': sticky,
|
|
20
|
+
'lw-bg-bg-primary': sticky && !hovered,
|
|
21
|
+
}
|
|
22
|
+
)}
|
|
18
23
|
>
|
|
19
24
|
{label}
|
|
20
25
|
</span>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { LoaderSize } from '@oanda/labs-widget-common';
|
|
2
|
-
|
|
1
|
+
import type { LoaderSize } from '@oanda/labs-widget-common';
|
|
2
|
+
|
|
3
|
+
import type { Division } from '../../gql/types/graphql';
|
|
3
4
|
|
|
4
5
|
export interface CellWithDataProps {
|
|
5
6
|
currency: string;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
const MAJOR_CURRENCIES = [
|
|
1
|
+
const MAJOR_CURRENCIES = [
|
|
2
|
+
'EUR',
|
|
3
|
+
'USD',
|
|
4
|
+
'JPY',
|
|
5
|
+
'GBP',
|
|
6
|
+
'CHF',
|
|
7
|
+
'AUD',
|
|
8
|
+
'CAD',
|
|
9
|
+
'NZD',
|
|
10
|
+
];
|
|
2
11
|
|
|
3
12
|
const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';
|
|
4
13
|
|
|
@@ -7,8 +16,8 @@ const CELL_LOADING_VALUE = '...';
|
|
|
7
16
|
const CELL_EMPTY_VALUE = '\u2014';
|
|
8
17
|
|
|
9
18
|
export {
|
|
10
|
-
MAJOR_CURRENCIES,
|
|
11
|
-
INSTRUMENT_TOOLTIP_ID,
|
|
12
|
-
CELL_LOADING_VALUE,
|
|
13
19
|
CELL_EMPTY_VALUE,
|
|
20
|
+
CELL_LOADING_VALUE,
|
|
21
|
+
INSTRUMENT_TOOLTIP_ID,
|
|
22
|
+
MAJOR_CURRENCIES,
|
|
14
23
|
};
|