@oanda/labs-live-rates-table-widget 1.0.38 → 1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +324 -0
- package/dist/main/LiveRatesTableWidget/LiveRatesTableWidget.js +25 -27
- package/dist/main/LiveRatesTableWidget/LiveRatesTableWidget.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/Main.js +16 -16
- package/dist/main/LiveRatesTableWidget/Main.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js +17 -17
- package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js +6 -6
- package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/Cards/types.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +4 -4
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js +25 -27
- package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/components/index.js +12 -12
- package/dist/main/LiveRatesTableWidget/components/index.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/config.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/constant.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/render.js +6 -6
- package/dist/main/LiveRatesTableWidget/render.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/types.js +1 -1
- package/dist/main/LiveRatesTableWidget/types.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/utils.js +2 -2
- package/dist/main/LiveRatesTableWidget/utils.js.map +1 -1
- package/dist/main/gql/types/fragment-masking.js.map +1 -1
- package/dist/main/gql/types/gql.js +2 -2
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +142 -142
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/main/gql/types/index.js.map +1 -1
- package/dist/main/index.js +8 -8
- package/dist/main/index.js.map +1 -1
- package/dist/main/translations/index.js +1 -1
- package/dist/main/translations/index.js.map +1 -1
- package/dist/main/translations/translations.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/LiveRatesTableWidget.js +26 -28
- package/dist/module/LiveRatesTableWidget/LiveRatesTableWidget.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/Main.js +18 -18
- package/dist/module/LiveRatesTableWidget/Main.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js +18 -18
- package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js +6 -6
- package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/Cards/types.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +4 -4
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js +1 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js +25 -25
- package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/components/index.js +2 -2
- package/dist/module/LiveRatesTableWidget/components/index.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/config.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/constant.js +1 -1
- package/dist/module/LiveRatesTableWidget/constant.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/render.js +6 -6
- package/dist/module/LiveRatesTableWidget/render.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/types.js +1 -1
- package/dist/module/LiveRatesTableWidget/types.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/utils.js +3 -3
- package/dist/module/LiveRatesTableWidget/utils.js.map +1 -1
- package/dist/module/gql/types/fragment-masking.js.map +1 -1
- package/dist/module/gql/types/gql.js +2 -2
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +142 -142
- package/dist/module/gql/types/graphql.js.map +1 -1
- package/dist/module/gql/types/index.js +2 -2
- package/dist/module/gql/types/index.js.map +1 -1
- package/dist/module/index.js +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/translations/index.js +1 -1
- package/dist/module/translations/index.js.map +1 -1
- package/dist/module/translations/translations.js.map +1 -1
- package/dist/types/LiveRatesTableWidget/LiveRatesTableWidget.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/Main.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/components/CardWithData/CardWithData.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/components/Cards/Cards.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/components/Cards/types.d.ts +2 -2
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/types.d.ts +3 -3
- package/dist/types/LiveRatesTableWidget/components/RowWithData/RowWithData.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/components/index.d.ts +2 -2
- package/dist/types/LiveRatesTableWidget/config.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/constant.d.ts +1 -1
- package/dist/types/LiveRatesTableWidget/types.d.ts +4 -4
- package/dist/types/LiveRatesTableWidget/utils.d.ts +5 -4
- package/dist/types/gql/types/gql.d.ts +4 -4
- package/dist/types/gql/types/index.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/translations/index.d.ts +2 -2
- package/package.json +3 -3
- package/src/LiveRatesTableWidget/LiveRatesTableWidget.tsx +28 -35
- package/src/LiveRatesTableWidget/Main.tsx +50 -44
- package/src/LiveRatesTableWidget/components/CardWithData/CardWithData.tsx +43 -28
- package/src/LiveRatesTableWidget/components/Cards/Cards.tsx +15 -8
- package/src/LiveRatesTableWidget/components/Cards/types.tsx +2 -2
- package/src/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.tsx +12 -10
- package/src/LiveRatesTableWidget/components/LineChartWithData/types.tsx +4 -3
- package/src/LiveRatesTableWidget/components/LineChartWithData/utils.ts +1 -1
- package/src/LiveRatesTableWidget/components/RowWithData/RowWithData.tsx +64 -31
- package/src/LiveRatesTableWidget/components/index.ts +2 -2
- package/src/LiveRatesTableWidget/config.ts +2 -4
- package/src/LiveRatesTableWidget/constant.ts +4 -1
- package/src/LiveRatesTableWidget/render.tsx +52 -34
- package/src/LiveRatesTableWidget/types.tsx +5 -4
- package/src/LiveRatesTableWidget/utils.ts +20 -17
- package/src/gql/types/fragment-masking.ts +41 -21
- package/src/gql/types/gql.ts +12 -5
- package/src/gql/types/graphql.ts +214 -49
- package/src/gql/types/index.ts +2 -2
- package/src/index.ts +1 -1
- package/src/translations/index.ts +4 -4
- package/src/translations/translations.ts +2 -1
- package/test/CardWithData.test.tsx +16 -12
- package/test/Cards.test.tsx +48 -40
- package/test/LineChartWithData.test.tsx +77 -32
- package/test/Main.test.tsx +14 -11
- package/test/RowWithData.test.tsx +21 -17
- package/test/mocks.ts +1 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.js","names":["defaultTranslations","exports","bearish","bullish","buy","buy_orders","buy_price","daily_change","data_unavailable","hot","instrument","pagination_entries_range","popular","sell","sell_price","sentiment","spread","volatile"],"sources":["../../../src/translations/translations.ts"],"sourcesContent":["export const defaultTranslations = {\n '24h_chart': '24h Chart',\n bearish: 'Bearish',\n bullish: 'Bullish',\n buy: 'Buy',\n buy_orders: 'Buy Orders',\n buy_price: 'Buy Price',\n daily_change: 'Daily Change (%)',\n data_unavailable: 'Data unavailable',\n hot: 'Hot',\n instrument: 'Instrument',\n pagination_entries_range
|
|
1
|
+
{"version":3,"file":"translations.js","names":["defaultTranslations","exports","bearish","bullish","buy","buy_orders","buy_price","daily_change","data_unavailable","hot","instrument","pagination_entries_range","popular","sell","sell_price","sentiment","spread","volatile"],"sources":["../../../src/translations/translations.ts"],"sourcesContent":["export const defaultTranslations = {\n '24h_chart': '24h Chart',\n bearish: 'Bearish',\n bullish: 'Bullish',\n buy: 'Buy',\n buy_orders: 'Buy Orders',\n buy_price: 'Buy Price',\n daily_change: 'Daily Change (%)',\n data_unavailable: 'Data unavailable',\n hot: 'Hot',\n instrument: 'Instrument',\n pagination_entries_range:\n '{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries',\n popular: 'Popular',\n sell: 'Sell',\n sell_price: 'Sell Price',\n sentiment: 'Sentiment',\n spread: 'Spread',\n volatile: 'Volatile',\n};\n"],"mappings":";;;;;;AAAO,MAAMA,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG;EACjC,WAAW,EAAE,WAAW;EACxBE,OAAO,EAAE,SAAS;EAClBC,OAAO,EAAE,SAAS;EAClBC,GAAG,EAAE,KAAK;EACVC,UAAU,EAAE,YAAY;EACxBC,SAAS,EAAE,WAAW;EACtBC,YAAY,EAAE,kBAAkB;EAChCC,gBAAgB,EAAE,kBAAkB;EACpCC,GAAG,EAAE,KAAK;EACVC,UAAU,EAAE,YAAY;EACxBC,wBAAwB,EACtB,iEAAiE;EACnEC,OAAO,EAAE,SAAS;EAClBC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,YAAY;EACxBC,SAAS,EAAE,WAAW;EACtBC,MAAM,EAAE,QAAQ;EAChBC,QAAQ,EAAE;AACZ,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
|
2
|
+
import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
|
|
1
3
|
import React from 'react';
|
|
2
|
-
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
3
|
-
import { LocaleProvider } from '@oanda/mono-i18n';
|
|
4
|
-
import { ChartError, LiveRatesProvider, ThemeProvider, getLocale, renderComponent } from '@oanda/labs-widget-common';
|
|
5
4
|
import { translations } from '../translations';
|
|
5
|
+
import { sizeConfig } from './config';
|
|
6
6
|
import { Main } from './Main';
|
|
7
7
|
import { Division } from './types';
|
|
8
|
-
import { sizeConfig } from './config';
|
|
9
8
|
const LiveRatesTableWidget = _ref => {
|
|
10
9
|
let {
|
|
11
10
|
graphqlUrl,
|
|
@@ -26,32 +25,31 @@ const LiveRatesTableWidget = _ref => {
|
|
|
26
25
|
});
|
|
27
26
|
const divisionCode = division === Division.Opt ? Division.Ogm : division;
|
|
28
27
|
const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';
|
|
29
|
-
return React.createElement(
|
|
30
|
-
|
|
28
|
+
return React.createElement(WidgetProvider, {
|
|
29
|
+
client: client,
|
|
30
|
+
liveRates: {
|
|
31
|
+
url: liveRatesUrl,
|
|
32
|
+
options: {
|
|
33
|
+
divisionCode,
|
|
34
|
+
dataSource
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
locale: locale,
|
|
38
|
+
styling: {
|
|
39
|
+
removePadding,
|
|
40
|
+
size: view && sizeConfig[view]
|
|
41
|
+
},
|
|
31
42
|
theme: theme,
|
|
32
|
-
size: view && sizeConfig[view]
|
|
33
|
-
}, React.createElement(LocaleProvider, {
|
|
34
|
-
locale: getLocale(locale),
|
|
35
43
|
translations: translations
|
|
36
|
-
}, React.createElement(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
className: "lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
|
|
46
|
-
}, React.createElement(ChartError, null)) : renderComponent({
|
|
47
|
-
Component: React.createElement(Main, {
|
|
48
|
-
instruments: instruments,
|
|
49
|
-
division: division,
|
|
50
|
-
columns: columns
|
|
51
|
-
}),
|
|
52
|
-
logoLink,
|
|
53
|
-
linkArea: 'logo'
|
|
54
|
-
})))));
|
|
44
|
+
}, React.createElement(WidgetWrapper, {
|
|
45
|
+
isParamError: isParamError,
|
|
46
|
+
linkArea: "logo",
|
|
47
|
+
logoLink: logoLink
|
|
48
|
+
}, React.createElement(Main, {
|
|
49
|
+
columns: columns,
|
|
50
|
+
division: division,
|
|
51
|
+
instruments: instruments
|
|
52
|
+
})));
|
|
55
53
|
};
|
|
56
54
|
export { LiveRatesTableWidget };
|
|
57
55
|
//# sourceMappingURL=LiveRatesTableWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveRatesTableWidget.js","names":["
|
|
1
|
+
{"version":3,"file":"LiveRatesTableWidget.js","names":["ApolloClient","InMemoryCache","WidgetProvider","WidgetWrapper","React","translations","sizeConfig","Main","Division","LiveRatesTableWidget","_ref","graphqlUrl","liveRatesUrl","instruments","division","columns","locale","theme","isParamError","removePadding","view","logoLink","client","uri","cache","divisionCode","Opt","Ogm","dataSource","createElement","liveRates","url","options","styling","size","linkArea"],"sources":["../../../src/LiveRatesTableWidget/LiveRatesTableWidget.tsx"],"sourcesContent":["import { ApolloClient, InMemoryCache } from '@apollo/client';\nimport { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport { translations } from '../translations';\nimport { sizeConfig } from './config';\nimport { Main } from './Main';\nimport type { LiveRatesTableConfig } from './types';\nimport { Division } from './types';\n\nconst LiveRatesTableWidget = ({\n graphqlUrl,\n liveRatesUrl,\n instruments,\n division,\n columns,\n locale,\n theme,\n isParamError,\n removePadding,\n view,\n logoLink,\n}: LiveRatesTableConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n const divisionCode = division === Division.Opt ? Division.Ogm : division;\n const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';\n\n return (\n <WidgetProvider\n client={client}\n liveRates={{\n url: liveRatesUrl,\n options: { divisionCode, dataSource },\n }}\n locale={locale}\n styling={{\n removePadding,\n size: view && sizeConfig[view],\n }}\n theme={theme}\n translations={translations}\n >\n <WidgetWrapper\n isParamError={isParamError}\n linkArea=\"logo\"\n logoLink={logoLink}\n >\n <Main columns={columns} division={division} instruments={instruments} />\n </WidgetWrapper>\n </WidgetProvider>\n );\n};\n\nexport { LiveRatesTableWidget };\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,aAAa,QAAQ,gBAAgB;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,2BAA2B;AACzE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,IAAI,QAAQ,QAAQ;AAE7B,SAASC,QAAQ,QAAQ,SAAS;AAElC,MAAMC,oBAAoB,GAAGC,IAAA,IAYD;EAAA,IAZE;IAC5BC,UAAU;IACVC,YAAY;IACZC,WAAW;IACXC,QAAQ;IACRC,OAAO;IACPC,MAAM;IACNC,KAAK;IACLC,YAAY;IACZC,aAAa;IACbC,IAAI;IACJC;EACoB,CAAC,GAAAX,IAAA;EACrB,MAAMY,MAAM,GAAG,IAAItB,YAAY,CAAC;IAC9BuB,GAAG,EAAEZ,UAAU;IACfa,KAAK,EAAE,IAAIvB,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMwB,YAAY,GAAGX,QAAQ,KAAKN,QAAQ,CAACkB,GAAG,GAAGlB,QAAQ,CAACmB,GAAG,GAAGb,QAAQ;EACxE,MAAMc,UAAU,GAAGH,YAAY,KAAKjB,QAAQ,CAACmB,GAAG,GAAG,KAAK,GAAG,KAAK;EAEhE,OACEvB,KAAA,CAAAyB,aAAA,CAAC3B,cAAc;IACboB,MAAM,EAAEA,MAAO;IACfQ,SAAS,EAAE;MACTC,GAAG,EAAEnB,YAAY;MACjBoB,OAAO,EAAE;QAAEP,YAAY;QAAEG;MAAW;IACtC,CAAE;IACFZ,MAAM,EAAEA,MAAO;IACfiB,OAAO,EAAE;MACPd,aAAa;MACbe,IAAI,EAAEd,IAAI,IAAId,UAAU,CAACc,IAAI;IAC/B,CAAE;IACFH,KAAK,EAAEA,KAAM;IACbZ,YAAY,EAAEA;EAAa,GAE3BD,KAAA,CAAAyB,aAAA,CAAC1B,aAAa;IACZe,YAAY,EAAEA,YAAa;IAC3BiB,QAAQ,EAAC,MAAM;IACfd,QAAQ,EAAEA;EAAS,GAEnBjB,KAAA,CAAAyB,aAAA,CAACtB,IAAI;IAACQ,OAAO,EAAEA,OAAQ;IAACD,QAAQ,EAAEA,QAAS;IAACD,WAAW,EAAEA;EAAY,CAAE,CAC1D,CACD,CAAC;AAErB,CAAC;AAED,SAASJ,oBAAoB","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { useEffect, useState, useContext } from 'react';
|
|
2
1
|
import { useQuery } from '@apollo/client';
|
|
3
|
-
import { Size, Table,
|
|
4
|
-
import {
|
|
5
|
-
import { RowWithData, Cards } from './components';
|
|
6
|
-
import { DEFAULT_COLUMNS, INSTRUMENT_TOOLTIP_ID } from './constant';
|
|
2
|
+
import { Size, Table, Tooltip, useLayoutProvider, useLiveRatesQuery } from '@oanda/labs-widget-common';
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
7
4
|
import { validateInstruments } from '../gql/validateInstruments';
|
|
5
|
+
import { Cards, RowWithData } from './components';
|
|
6
|
+
import { DEFAULT_COLUMNS, INSTRUMENT_TOOLTIP_ID } from './constant';
|
|
7
|
+
import { getHeaderConfig, getRecords } from './utils';
|
|
8
8
|
const Main = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
instruments,
|
|
@@ -13,7 +13,7 @@ const Main = _ref => {
|
|
|
13
13
|
} = _ref;
|
|
14
14
|
const {
|
|
15
15
|
size
|
|
16
|
-
} =
|
|
16
|
+
} = useLayoutProvider();
|
|
17
17
|
const isDesktop = size === Size.DESKTOP;
|
|
18
18
|
const {
|
|
19
19
|
target,
|
|
@@ -51,31 +51,31 @@ const Main = _ref => {
|
|
|
51
51
|
}, [records, isDesktop]);
|
|
52
52
|
const showError = !loading && !!error || !loading && !data;
|
|
53
53
|
return React.createElement(React.Fragment, null, size && React.createElement("div", {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
className: "lw-relative lw-text-sm lw-tracking-normal lw-text-text-primary",
|
|
55
|
+
"data-testid": "live-rates-table-wrapper"
|
|
56
56
|
}, isDesktop ? React.createElement("div", {
|
|
57
57
|
className: "lw-border lw-border-solid lw-border-border-primary"
|
|
58
58
|
}, React.createElement(Table, {
|
|
59
|
+
headerConfig: getHeaderConfig(columns),
|
|
59
60
|
isError: showError,
|
|
60
61
|
records: records,
|
|
61
|
-
headerConfig: getHeaderConfig(columns),
|
|
62
62
|
renderRow: (record, index, isScrolled) => React.createElement(RowWithData, {
|
|
63
|
+
key: `row_${index}`,
|
|
64
|
+
activeColumns: columns,
|
|
65
|
+
division: division,
|
|
66
|
+
hasBackgroundColor: index % 2 === 0,
|
|
63
67
|
isScrolled: isScrolled,
|
|
64
68
|
loading: loading,
|
|
65
|
-
key: `row_${index}`,
|
|
66
69
|
record: record,
|
|
67
|
-
target: target
|
|
68
|
-
hasBackgroundColor: index % 2 === 0,
|
|
69
|
-
activeColumns: columns,
|
|
70
|
-
division: division
|
|
70
|
+
target: target
|
|
71
71
|
})
|
|
72
72
|
})) : React.createElement(Cards, {
|
|
73
|
-
records: records,
|
|
74
|
-
division: division,
|
|
75
|
-
target: target,
|
|
76
73
|
columns: columns,
|
|
74
|
+
division: division,
|
|
77
75
|
isError: showError,
|
|
78
|
-
isLoading: loading
|
|
76
|
+
isLoading: loading,
|
|
77
|
+
records: records,
|
|
78
|
+
target: target
|
|
79
79
|
}), React.createElement(Tooltip, {
|
|
80
80
|
id: INSTRUMENT_TOOLTIP_ID
|
|
81
81
|
})));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["
|
|
1
|
+
{"version":3,"file":"Main.js","names":["useQuery","Size","Table","Tooltip","useLayoutProvider","useLiveRatesQuery","React","useEffect","useState","validateInstruments","Cards","RowWithData","DEFAULT_COLUMNS","INSTRUMENT_TOOLTIP_ID","getHeaderConfig","getRecords","Main","_ref","instruments","division","columns","size","isDesktop","DESKTOP","target","setQuery","records","setRecords","Array","length","fill","loading","data","error","variables","fetchPolicy","instrumentsNames","map","_ref2","instrument","showError","createElement","Fragment","className","headerConfig","isError","renderRow","record","index","isScrolled","key","activeColumns","hasBackgroundColor","isLoading","id"],"sources":["../../../src/LiveRatesTableWidget/Main.tsx"],"sourcesContent":["import { useQuery } from '@apollo/client';\nimport {\n Size,\n Table,\n Tooltip,\n useLayoutProvider,\n useLiveRatesQuery,\n} from '@oanda/labs-widget-common';\nimport React, { useEffect, useState } from 'react';\n\nimport type {\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables,\n} from '../gql/types/graphql';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { Cards, RowWithData } from './components';\nimport { DEFAULT_COLUMNS, INSTRUMENT_TOOLTIP_ID } from './constant';\nimport type { DataRecord, MainProps } from './types';\nimport { getHeaderConfig, getRecords } from './utils';\n\nconst Main = ({\n instruments,\n division,\n columns = DEFAULT_COLUMNS,\n}: MainProps) => {\n const { size } = useLayoutProvider();\n const isDesktop = size === Size.DESKTOP;\n const { target, setQuery } = useLiveRatesQuery();\n const [records, setRecords] = useState<DataRecord[]>(\n new Array(instruments.length).fill({})\n );\n\n const { loading, data, error } = useQuery<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables\n >(validateInstruments, {\n variables: {\n instruments,\n division,\n },\n fetchPolicy: 'network-only',\n });\n\n useEffect(() => {\n if (!loading && data) {\n setRecords(getRecords(data)!);\n }\n }, [loading, data]);\n\n const instrumentsNames = records.map(({ instrument }) => instrument);\n\n useEffect(() => {\n if (instrumentsNames[0]) {\n setQuery({ instruments: instrumentsNames });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [records, isDesktop]);\n\n const showError = (!loading && !!error) || (!loading && !data);\n\n return (\n <>\n {size && (\n <div\n className=\"lw-relative lw-text-sm lw-tracking-normal lw-text-text-primary\"\n data-testid=\"live-rates-table-wrapper\"\n >\n {isDesktop ? (\n <div className=\"lw-border lw-border-solid lw-border-border-primary\">\n <Table<DataRecord>\n headerConfig={getHeaderConfig(columns)}\n isError={showError}\n records={records}\n renderRow={(record, index, isScrolled) => (\n <RowWithData\n key={`row_${index}`}\n activeColumns={columns}\n division={division}\n hasBackgroundColor={index % 2 === 0}\n isScrolled={isScrolled}\n loading={loading}\n record={record}\n target={target}\n />\n )}\n />\n </div>\n ) : (\n <Cards\n columns={columns}\n division={division}\n isError={showError}\n isLoading={loading}\n records={records}\n target={target}\n />\n )}\n <Tooltip id={INSTRUMENT_TOOLTIP_ID} />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SACEC,IAAI,EACJC,KAAK,EACLC,OAAO,EACPC,iBAAiB,EACjBC,iBAAiB,QACZ,2BAA2B;AAClC,OAAOC,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAMlD,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,KAAK,EAAEC,WAAW,QAAQ,cAAc;AACjD,SAASC,eAAe,EAAEC,qBAAqB,QAAQ,YAAY;AAEnE,SAASC,eAAe,EAAEC,UAAU,QAAQ,SAAS;AAErD,MAAMC,IAAI,GAAGC,IAAA,IAII;EAAA,IAJH;IACZC,WAAW;IACXC,QAAQ;IACRC,OAAO,G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AA,QACGrB,IAAI,IACHf,KAAA,CAAAmC,aAAA;IACEE,SAAS,EAAC,gEAAgE;IAC1E,eAAY;EAA0B,GAErCrB,SAAS,GACRhB,KAAA,CAAAmC,aAAA;IAAKE,SAAS,EAAC;EAAoD,GACjErC,KAAA,CAAAmC,aAAA,CAACvC,KAAK;IACJ0C,YAAY,EAAE9B,eAAe,CAACM,OAAO,CAAE;IACvCyB,OAAO,EAAEL,SAAU;IACnBd,OAAO,EAAEA,OAAQ;IACjBoB,SAAS,EAAEA,CAACC,MAAM,EAAEC,KAAK,EAAEC,UAAU,KACnC3C,KAAA,CAAAmC,aAAA,CAAC9B,WAAW;MACVuC,GAAG,EAAE,OAAOF,KAAK,EAAG;MACpBG,aAAa,EAAE/B,OAAQ;MACvBD,QAAQ,EAAEA,QAAS;MACnBiC,kBAAkB,EAAEJ,KAAK,GAAG,CAAC,KAAK,CAAE;MACpCC,UAAU,EAAEA,UAAW;MACvBlB,OAAO,EAAEA,OAAQ;MACjBgB,MAAM,EAAEA,MAAO;MACfvB,MAAM,EAAEA;IAAO,CAChB;EACD,CACH,CACE,CAAC,GAENlB,KAAA,CAAAmC,aAAA,CAAC/B,KAAK;IACJU,OAAO,EAAEA,OAAQ;IACjBD,QAAQ,EAAEA,QAAS;IACnB0B,OAAO,EAAEL,SAAU;IACnBa,SAAS,EAAEtB,OAAQ;IACnBL,OAAO,EAAEA,OAAQ;IACjBF,MAAM,EAAEA;EAAO,CAChB,CACF,EACDlB,KAAA,CAAAmC,aAAA,CAACtC,OAAO;IAACmD,EAAE,EAAEzC;EAAsB,CAAE,CAClC,CAEP,CAAC;AAEP,CAAC;AAED,SAASG,IAAI","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Card, CardHeader, CardRow, Price, ArrowPosition, LineChartSize, Truncate } from '@oanda/labs-widget-common';
|
|
1
|
+
import { ArrowPosition, Card, CardHeader, CardRow, LineChartSize, Price, Truncate } from '@oanda/labs-widget-common';
|
|
3
2
|
import { useLocale } from '@oanda/mono-i18n';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
|
|
4
5
|
import { ColumnsNames } from '../../types';
|
|
5
|
-
import { LineChartWithData } from '../LineChartWithData';
|
|
6
6
|
import { useRecords } from '../../utils';
|
|
7
|
-
import {
|
|
7
|
+
import { LineChartWithData } from '../LineChartWithData';
|
|
8
8
|
const CardWithData = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
isLoading,
|
|
@@ -38,48 +38,48 @@ const CardWithData = _ref => {
|
|
|
38
38
|
}, activeColumns.includes(ColumnsNames.CHART) && React.createElement(LineChartWithData, {
|
|
39
39
|
division: division,
|
|
40
40
|
isLoading: checkLoading('instrument'),
|
|
41
|
-
size: LineChartSize.xs,
|
|
42
41
|
padding: 4,
|
|
43
|
-
record: updatedRecord
|
|
42
|
+
record: updatedRecord,
|
|
43
|
+
size: LineChartSize.xs
|
|
44
44
|
})), activeColumns.map(item => {
|
|
45
45
|
if (item === ColumnsNames.SELL) {
|
|
46
46
|
return React.createElement(CardRow, {
|
|
47
47
|
key: ColumnsNames.SELL,
|
|
48
|
-
|
|
48
|
+
isError: !!error,
|
|
49
49
|
isLoading: checkLoading(ColumnsNames.SELL),
|
|
50
|
-
|
|
50
|
+
label: lang('sell_price')
|
|
51
51
|
}, React.createElement(Price, {
|
|
52
52
|
arrowPosition: ArrowPosition.left,
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
movementIndicator: "arrow",
|
|
54
|
+
priceMovement: updatedRecord.sellPriceMovement
|
|
55
55
|
}, React.createElement("span", null, updatedRecord.sell?.toFixed(updatedRecord.displayPrecision))));
|
|
56
56
|
}
|
|
57
57
|
if (item === ColumnsNames.BUY) {
|
|
58
58
|
return React.createElement(CardRow, {
|
|
59
59
|
key: ColumnsNames.BUY,
|
|
60
|
-
|
|
60
|
+
isError: !!error,
|
|
61
61
|
isLoading: checkLoading(ColumnsNames.BUY),
|
|
62
|
-
|
|
62
|
+
label: lang('buy_price')
|
|
63
63
|
}, React.createElement(Price, {
|
|
64
64
|
arrowPosition: ArrowPosition.left,
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
movementIndicator: "arrow",
|
|
66
|
+
priceMovement: updatedRecord.buyPriceMovement
|
|
67
67
|
}, React.createElement("span", null, updatedRecord.buy?.toFixed(updatedRecord.displayPrecision))));
|
|
68
68
|
}
|
|
69
69
|
if (item === ColumnsNames.DAILY_CHANGE) {
|
|
70
70
|
return React.createElement(CardRow, {
|
|
71
71
|
key: ColumnsNames.DAILY_CHANGE,
|
|
72
|
-
|
|
72
|
+
isError: !!error,
|
|
73
73
|
isLoading: checkLoading('dailyPercentChange'),
|
|
74
|
-
|
|
74
|
+
label: lang('daily_percent_change')
|
|
75
75
|
}, React.createElement("span", null, updatedRecord.dailyPercentChange));
|
|
76
76
|
}
|
|
77
77
|
if (item === ColumnsNames.SPREAD) {
|
|
78
78
|
return React.createElement(CardRow, {
|
|
79
79
|
key: ColumnsNames.SPREAD,
|
|
80
|
-
|
|
80
|
+
isError: !!error,
|
|
81
81
|
isLoading: checkLoading(ColumnsNames.SPREAD),
|
|
82
|
-
|
|
82
|
+
label: lang('spread')
|
|
83
83
|
}, React.createElement("span", null, updatedRecord.spread));
|
|
84
84
|
}
|
|
85
85
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardWithData.js","names":["
|
|
1
|
+
{"version":3,"file":"CardWithData.js","names":["ArrowPosition","Card","CardHeader","CardRow","LineChartSize","Price","Truncate","useLocale","React","INSTRUMENT_TOOLTIP_ID","ColumnsNames","useRecords","LineChartWithData","CardWithData","_ref","isLoading","record","target","activeColumns","index","division","isLast","updatedRecord","error","ref","instrument","lang","checkLoading","id","undefined","createElement","withoutBottomBorder","number","title","text","displayName","tooltipId","includes","CHART","padding","size","xs","map","item","SELL","key","isError","label","arrowPosition","left","movementIndicator","priceMovement","sellPriceMovement","sell","toFixed","displayPrecision","BUY","buyPriceMovement","buy","DAILY_CHANGE","dailyPercentChange","SPREAD","spread"],"sources":["../../../../../src/LiveRatesTableWidget/components/CardWithData/CardWithData.tsx"],"sourcesContent":["import {\n ArrowPosition,\n Card,\n CardHeader,\n CardRow,\n LineChartSize,\n Price,\n Truncate,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport React from 'react';\n\nimport { INSTRUMENT_TOOLTIP_ID } from '../../constant';\nimport type { CardWithDataProps } from '../../types';\nimport { ColumnsNames } from '../../types';\nimport { useRecords } from '../../utils';\nimport { LineChartWithData } from '../LineChartWithData';\n\nconst CardWithData = ({\n isLoading,\n record,\n target,\n activeColumns,\n index,\n division,\n isLast,\n}: CardWithDataProps) => {\n const { updatedRecord, error, ref } = useRecords(\n record,\n record.instrument ? target : null\n );\n const { lang } = useLocale();\n\n const checkLoading = (id: string) =>\n isLoading || (!error && updatedRecord?.[id] === undefined);\n\n return (\n <Card ref={ref} data-testid=\"card\" withoutBottomBorder={!isLast}>\n <CardHeader\n isLoading={isLoading}\n number={index}\n title={\n <Truncate\n text={record.displayName}\n tooltipId={INSTRUMENT_TOOLTIP_ID}\n />\n }\n >\n {activeColumns.includes(ColumnsNames.CHART) && (\n <LineChartWithData\n division={division}\n isLoading={checkLoading('instrument')}\n padding={4}\n record={updatedRecord}\n size={LineChartSize.xs}\n />\n )}\n </CardHeader>\n {activeColumns.map((item) => {\n if (item === ColumnsNames.SELL) {\n return (\n <CardRow\n key={ColumnsNames.SELL}\n isError={!!error}\n isLoading={checkLoading(ColumnsNames.SELL)}\n label={lang('sell_price')}\n >\n <Price\n arrowPosition={ArrowPosition.left}\n movementIndicator=\"arrow\"\n priceMovement={updatedRecord.sellPriceMovement}\n >\n <span>\n {updatedRecord.sell?.toFixed(updatedRecord.displayPrecision)}\n </span>\n </Price>\n </CardRow>\n );\n }\n\n if (item === ColumnsNames.BUY) {\n return (\n <CardRow\n key={ColumnsNames.BUY}\n isError={!!error}\n isLoading={checkLoading(ColumnsNames.BUY)}\n label={lang('buy_price')}\n >\n <Price\n arrowPosition={ArrowPosition.left}\n movementIndicator=\"arrow\"\n priceMovement={updatedRecord.buyPriceMovement}\n >\n <span>\n {updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}\n </span>\n </Price>\n </CardRow>\n );\n }\n\n if (item === ColumnsNames.DAILY_CHANGE) {\n return (\n <CardRow\n key={ColumnsNames.DAILY_CHANGE}\n isError={!!error}\n isLoading={checkLoading('dailyPercentChange')}\n label={lang('daily_percent_change')}\n >\n <span>{updatedRecord.dailyPercentChange}</span>\n </CardRow>\n );\n }\n\n if (item === ColumnsNames.SPREAD) {\n return (\n <CardRow\n key={ColumnsNames.SPREAD}\n isError={!!error}\n isLoading={checkLoading(ColumnsNames.SPREAD)}\n label={lang('spread')}\n >\n <span>{updatedRecord.spread}</span>\n </CardRow>\n );\n }\n return null;\n })}\n </Card>\n );\n};\n\nexport { CardWithData };\n"],"mappings":"AAAA,SACEA,aAAa,EACbC,IAAI,EACJC,UAAU,EACVC,OAAO,EACPC,aAAa,EACbC,KAAK,EACLC,QAAQ,QACH,2BAA2B;AAClC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,qBAAqB,QAAQ,gBAAgB;AAEtD,SAASC,YAAY,QAAQ,aAAa;AAC1C,SAASC,UAAU,QAAQ,aAAa;AACxC,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,MAAMC,YAAY,GAAGC,IAAA,IAQI;EAAA,IARH;IACpBC,SAAS;IACTC,MAAM;IACNC,MAAM;IACNC,aAAa;IACbC,KAAK;IACLC,QAAQ;IACRC;EACiB,CAAC,GAAAP,IAAA;EAClB,MAAM;IAAEQ,aAAa;IAAEC,KAAK;IAAEC;EAAI,CAAC,GAAGb,UAAU,CAC9CK,MAAM,EACNA,MAAM,CAACS,UAAU,GAAGR,MAAM,GAAG,IAC/B,CAAC;EACD,MAAM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G,EAAEnC,YAAY,CAACmD,MAAO;QACzBf,OAAO,EAAE,CAAC,CAACvB,KAAM;QACjBR,SAAS,EAAEY,YAAY,CAACjB,YAAY,CAACmD,MAAM,CAAE;QAC7Cd,KAAK,EAAErB,IAAI,CAAC,QAAQ;MAAE,GAEtBlB,KAAA,CAAAsB,aAAA,eAAOR,aAAa,CAACwC,MAAa,CAC3B,CAAC;IAEd;IACA,OAAO,IAAI;EACb,CAAC,CACG,CAAC;AAEX,CAAC;AAED,SAASjD,YAAY","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { Card, ChartError } from '@oanda/labs-widget-common';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { CardWithData } from '../CardWithData/CardWithData';
|
|
4
4
|
const Cards = _ref => {
|
|
5
5
|
let {
|
|
@@ -16,14 +16,14 @@ const Cards = _ref => {
|
|
|
16
16
|
}, React.createElement(ChartError, null))) : React.createElement(React.Fragment, null, records.map((record, index) => React.createElement("div", {
|
|
17
17
|
key: `card_${startIndex + index}`
|
|
18
18
|
}, React.createElement(CardWithData, {
|
|
19
|
-
index: startIndex + index + 1,
|
|
20
|
-
division: division,
|
|
21
|
-
record: record,
|
|
22
|
-
target: target,
|
|
23
19
|
activeColumns: columns,
|
|
20
|
+
division: division,
|
|
21
|
+
index: startIndex + index + 1,
|
|
24
22
|
isError: isError,
|
|
23
|
+
isLast: index + 1 === records.length,
|
|
25
24
|
isLoading: isLoading,
|
|
26
|
-
|
|
25
|
+
record: record,
|
|
26
|
+
target: target
|
|
27
27
|
})))));
|
|
28
28
|
};
|
|
29
29
|
export { Cards };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cards.js","names":["
|
|
1
|
+
{"version":3,"file":"Cards.js","names":["Card","ChartError","React","CardWithData","Cards","_ref","records","target","columns","isError","isLoading","division","startIndex","createElement","Fragment","className","map","record","index","key","activeColumns","isLast","length"],"sources":["../../../../../src/LiveRatesTableWidget/components/Cards/Cards.tsx"],"sourcesContent":["import { Card, ChartError } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport { CardWithData } from '../CardWithData/CardWithData';\nimport type { CardsProps } from './types';\n\nconst Cards = ({\n records,\n target,\n columns,\n isError,\n isLoading,\n division,\n startIndex = 0,\n}: CardsProps) => (\n <>\n {isError ? (\n <Card>\n <div className=\"lw-flex lw-h-[150px] lw-w-full lw-items-center lw-justify-center\">\n <ChartError />\n </div>\n </Card>\n ) : (\n <>\n {records.map((record, index) => (\n <div key={`card_${startIndex + index}`}>\n <CardWithData\n activeColumns={columns}\n division={division}\n index={startIndex + index + 1}\n isError={isError}\n isLast={index + 1 === records.length}\n isLoading={isLoading}\n record={record}\n target={target}\n />\n </div>\n ))}\n </>\n )}\n </>\n);\n\nexport { Cards };\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,UAAU,QAAQ,2BAA2B;AAC5D,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAY,QAAQ,8BAA8B;AAG3D,MAAMC,KAAK,GAAGC,IAAA;EAAA,IAAC;IACbC,OAAO;IACPC,MAAM;IACNC,OAAO;IACPC,OAAO;IACPC,SAAS;IACTC,QAAQ;IACRC,UAAU,GAAG;EACH,CAAC,GAAAP,IAAA;EAAA,OACXH,KAAA,CAAAW,aAAA,CAAAX,KAAA,CAAAY,QAAA,QACGL,OAAO,GACNP,KAAA,CAAAW,aAAA,CAACb,IAAI,QACHE,KAAA,CAAAW,aAAA;IAAKE,SAAS,EAAC;EAAkE,GAC/Eb,KAAA,CAAAW,aAAA,CAACZ,UAAU,MAAE,CACV,CACD,CAAC,GAEPC,KAAA,CAAAW,aAAA,CAAAX,KAAA,CAAAY,QAAA,QACGR,OAAO,CAACU,GAAG,CAAC,CAACC,MAAM,EAAEC,KAAK,KACzBhB,KAAA,CAAAW,aAAA;IAAKM,GAAG,EAAE,QAAQP,UAAU,GAAGM,KAAK;EAAG,GACrChB,KAAA,CAAAW,aAAA,CAACV,YAAY;IACXiB,aAAa,EAAEZ,OAAQ;IACvBG,QAAQ,EAAEA,QAAS;IACnBO,KAAK,EAAEN,UAAU,GAAGM,KAAK,GAAG,CAAE;IAC9BT,OAAO,EAAEA,OAAQ;IACjBY,MAAM,EAAEH,KAAK,GAAG,CAAC,KAAKZ,OAAO,CAACgB,MAAO;IACrCZ,SAAS,EAAEA,SAAU;IACrBO,MAAM,EAAEA,MAAO;IACfV,MAAM,EAAEA;EAAO,CAChB,CACE,CACN,CACD,CAEJ,CAAC;AAAA,CACJ;AAED,SAASH,KAAK","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/LiveRatesTableWidget/components/Cards/types.tsx"],"sourcesContent":["import { Division } from '../../../gql/types/graphql';\nimport { ColumnsNames, DataRecord } from '../../types';\n\nexport interface CardsProps {\n startIndex?: number;\n emptyCardsCount?: number;\n isLoading?: boolean;\n isError?: boolean;\n records: DataRecord[];\n target: EventTarget | null;\n columns: ColumnsNames[];\n division: Division;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/LiveRatesTableWidget/components/Cards/types.tsx"],"sourcesContent":["import type { Division } from '../../../gql/types/graphql';\nimport type { ColumnsNames, DataRecord } from '../../types';\n\nexport interface CardsProps {\n startIndex?: number;\n emptyCardsCount?: number;\n isLoading?: boolean;\n isError?: boolean;\n records: DataRecord[];\n target: EventTarget | null;\n columns: ColumnsNames[];\n division: Division;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { useQuery } from '@apollo/client';
|
|
3
2
|
import { LineChart, Loader, LoaderSize } from '@oanda/labs-widget-common';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
import { getInstrumentsChart } from '../../../gql/getInstrumentsChart';
|
|
5
5
|
import { getChartColor } from './utils';
|
|
6
6
|
const LineChartWithData = _ref => {
|
|
@@ -29,10 +29,10 @@ const LineChartWithData = _ref => {
|
|
|
29
29
|
return React.createElement(React.Fragment, null, showLoader && React.createElement(Loader, {
|
|
30
30
|
size: LoaderSize.md
|
|
31
31
|
}), !showLoader && React.createElement(LineChart, {
|
|
32
|
-
padding: padding,
|
|
33
|
-
size: size,
|
|
34
32
|
color: chartColor,
|
|
35
|
-
data: chart
|
|
33
|
+
data: chart,
|
|
34
|
+
padding: padding,
|
|
35
|
+
size: size
|
|
36
36
|
}));
|
|
37
37
|
};
|
|
38
38
|
export { LineChartWithData };
|
package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChartWithData.js","names":["
|
|
1
|
+
{"version":3,"file":"LineChartWithData.js","names":["useQuery","LineChart","Loader","LoaderSize","React","getInstrumentsChart","getChartColor","LineChartWithData","_ref","padding","record","size","isLoading","division","isDarkMode","loading","data","variables","instruments","instrument","fetchPolicy","skip","showLoader","chart","topicalInstrumentsCharts","chartColor","dailyPercentChange","createElement","Fragment","md","color"],"sources":["../../../../../src/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.tsx"],"sourcesContent":["import { useQuery } from '@apollo/client';\nimport { LineChart, Loader, LoaderSize } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport { getInstrumentsChart } from '../../../gql/getInstrumentsChart';\nimport type {\n GetInstrumentsChartQuery,\n GetInstrumentsChartQueryVariables,\n} from '../../../gql/types/graphql';\nimport type { LineChartWithDataProps } from './types';\nimport { getChartColor } from './utils';\n\nconst LineChartWithData = ({\n padding,\n record,\n size,\n isLoading,\n division,\n isDarkMode = false,\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 showLoader = isLoading || loading;\n const chart = data?.topicalInstrumentsCharts?.[0].chart || [];\n\n const chartColor = getChartColor(record.dailyPercentChange, isDarkMode);\n\n return (\n <>\n {showLoader && <Loader size={LoaderSize.md} />}\n {!showLoader && (\n <LineChart\n color={chartColor}\n data={chart}\n padding={padding}\n size={size}\n />\n )}\n </>\n );\n};\n\nexport { LineChartWithData };\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,EAAEC,MAAM,EAAEC,UAAU,QAAQ,2BAA2B;AACzE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,mBAAmB,QAAQ,kCAAkC;AAMtE,SAASC,aAAa,QAAQ,SAAS;AAEvC,MAAMC,iBAAiB,GAAGC,IAAA,IAOI;EAAA,IAPH;IACzBC,OAAO;IACPC,MAAM;IACNC,IAAI;IACJC,SAAS;IACTC,QAAQ;IACRC,UAAU,GAAG;EACS,CAAC,GAAAN,IAAA;EACvB,MAAM;IAAEO,OAAO;IAAEC;EAAK,CAAC,GAAGhB,QAAQ,CAGhCK,mBAAmB,EAAE;IACrBY,SAAS,EAAE;MACTC,WAAW,EAAE,CAACR,MAAM,CAACS,UAAU,CAAC;MAChCN;IACF,CAAC;IACDO,WAAW,EAAE,cAAc;IAC3BC,IAAI,EAAE,CAACX,MAAM,CAACS;EAChB,CAAC,CAAC;EAEF,MAAMG,UAAU,GAAGV,SAAS,IAAIG,OAAO;EACvC,MAAMQ,KAAK,GAAGP,IAAI,EAAEQ,wBAAwB,GAAG,CAAC,CAAC,CAACD,KAAK,IAAI,EAAE;EAE7D,MAAME,UAAU,GAAGnB,aAAa,CAACI,MAAM,CAACgB,kBAAkB,EAAEZ,UAAU,CAAC;EAEvE,OACEV,KAAA,CAAAuB,aAAA,CAAAvB,KAAA,CAAAwB,QAAA,QACGN,UAAU,IAAIlB,KAAA,CAAAuB,aAAA,CAACzB,MAAM;IAACS,IAAI,EAAER,UAAU,CAAC0B;EAAG,CAAE,CAAC,EAC7C,CAACP,UAAU,IACVlB,KAAA,CAAAuB,aAAA,CAAC1B,SAAS;IACR6B,KAAK,EAAEL,UAAW;IAClBT,IAAI,EAAEO,KAAM;IACZd,OAAO,EAAEA,OAAQ;IACjBE,IAAI,EAAEA;EAAK,CACZ,CAEH,CAAC;AAEP,CAAC;AAED,SAASJ,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/LiveRatesTableWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { LineChartSize } from '@oanda/labs-widget-common';\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/LiveRatesTableWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import type { LineChartSize } from '@oanda/labs-widget-common';\n\nimport type { Division } from '../../../gql/types/graphql';\nimport type { DataRecord } from '../../types';\n\nexport interface LineChartWithDataProps {\n padding?: number;\n record: DataRecord;\n size?: LineChartSize;\n isLoading: boolean;\n division: Division;\n isDarkMode?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { darkTheme, lightTheme } from '@oanda/labs-widget-common';
|
|
2
2
|
export const getChartColor = (dailyChange, isDarkMode) => {
|
|
3
3
|
const theme = isDarkMode ? darkTheme : lightTheme;
|
|
4
4
|
switch (dailyChange?.charAt(0)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["
|
|
1
|
+
{"version":3,"file":"utils.js","names":["darkTheme","lightTheme","getChartColor","dailyChange","isDarkMode","theme","charAt","ok","danger","borderDisabled"],"sources":["../../../../../src/LiveRatesTableWidget/components/LineChartWithData/utils.ts"],"sourcesContent":["import { darkTheme, lightTheme } from '@oanda/labs-widget-common';\n\nexport const getChartColor = (dailyChange?: string, isDarkMode?: boolean) => {\n const theme = isDarkMode ? darkTheme : lightTheme;\n\n switch (dailyChange?.charAt(0)) {\n case '+':\n return theme.ok;\n case '-':\n return theme.danger;\n default:\n return theme.borderDisabled;\n }\n};\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU,QAAQ,2BAA2B;AAEjE,OAAO,MAAMC,aAAa,GAAGA,CAACC,WAAoB,EAAEC,UAAoB,KAAK;EAC3E,MAAMC,KAAK,GAAGD,UAAU,GAAGJ,SAAS,GAAGC,UAAU;EAEjD,QAAQE,WAAW,EAAEG,MAAM,CAAC,CAAC,CAAC;IAC5B,KAAK,GAAG;MACN,OAAOD,KAAK,CAACE,EAAE;IACjB,KAAK,GAAG;MACN,OAAOF,KAAK,CAACG,MAAM;IACrB;MACE,OAAOH,KAAK,CAACI,cAAc;EAC/B;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { LoaderSize, Price, TableCell, TableRow, Truncate, useLayoutProvider } from '@oanda/labs-widget-common';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
|
-
import
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
|
|
4
5
|
import { ColumnsNames } from '../../types';
|
|
5
|
-
import { LineChartWithData } from '../LineChartWithData';
|
|
6
6
|
import { useRecords } from '../../utils';
|
|
7
|
-
import {
|
|
7
|
+
import { LineChartWithData } from '../LineChartWithData';
|
|
8
8
|
const RowWithData = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
loading,
|
|
@@ -17,7 +17,7 @@ const RowWithData = _ref => {
|
|
|
17
17
|
} = _ref;
|
|
18
18
|
const {
|
|
19
19
|
isDark
|
|
20
|
-
} =
|
|
20
|
+
} = useLayoutProvider();
|
|
21
21
|
const {
|
|
22
22
|
updatedRecord,
|
|
23
23
|
error,
|
|
@@ -26,15 +26,15 @@ const RowWithData = _ref => {
|
|
|
26
26
|
const checkLoading = id => loading || !error && updatedRecord?.[id] === undefined;
|
|
27
27
|
return React.createElement(TableRow, {
|
|
28
28
|
ref: ref,
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
hasBackgroundColor: hasBackgroundColor,
|
|
30
|
+
isScrolled: isScrolled
|
|
31
31
|
}, React.createElement(React.Fragment, null, React.createElement(TableCell, {
|
|
32
|
-
|
|
32
|
+
key: ColumnsNames.INSTRUMENT,
|
|
33
33
|
classNames: classnames('lw-font-bold', {
|
|
34
34
|
'[&>*:first-child]:lw-border-r [&>*:first-child]:lw-border-border-primary': isDark && isScrolled
|
|
35
35
|
}),
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
isLoading: checkLoading(ColumnsNames.INSTRUMENT),
|
|
37
|
+
type: "text"
|
|
38
38
|
}, React.createElement(Truncate, {
|
|
39
39
|
maxWidth: 130,
|
|
40
40
|
text: record.displayName,
|
|
@@ -43,50 +43,50 @@ const RowWithData = _ref => {
|
|
|
43
43
|
if (item === ColumnsNames.SELL) {
|
|
44
44
|
return React.createElement(TableCell, {
|
|
45
45
|
key: ColumnsNames.SELL,
|
|
46
|
-
|
|
46
|
+
additionalPaddingRight: true,
|
|
47
47
|
isError: !!error,
|
|
48
|
-
|
|
48
|
+
isLoading: checkLoading(ColumnsNames.SELL)
|
|
49
49
|
}, React.createElement(Price, {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
movementIndicator: "arrow",
|
|
51
|
+
priceMovement: updatedRecord.sellPriceMovement
|
|
52
52
|
}, React.createElement("span", null, updatedRecord.sell?.toFixed(updatedRecord.displayPrecision))));
|
|
53
53
|
}
|
|
54
54
|
if (item === ColumnsNames.BUY) {
|
|
55
55
|
return React.createElement(TableCell, {
|
|
56
56
|
key: ColumnsNames.BUY,
|
|
57
|
-
|
|
57
|
+
additionalPaddingRight: true,
|
|
58
58
|
isError: !!error,
|
|
59
|
-
|
|
59
|
+
isLoading: checkLoading(ColumnsNames.BUY)
|
|
60
60
|
}, React.createElement(Price, {
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
movementIndicator: "arrow",
|
|
62
|
+
priceMovement: updatedRecord.buyPriceMovement
|
|
63
63
|
}, React.createElement("span", null, updatedRecord.buy?.toFixed(updatedRecord.displayPrecision))));
|
|
64
64
|
}
|
|
65
65
|
if (item === ColumnsNames.DAILY_CHANGE) {
|
|
66
66
|
return React.createElement(TableCell, {
|
|
67
67
|
key: ColumnsNames.DAILY_CHANGE,
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
isError: !!error,
|
|
69
|
+
isLoading: checkLoading('dailyPercentChange')
|
|
70
70
|
}, React.createElement("span", null, updatedRecord.dailyPercentChange));
|
|
71
71
|
}
|
|
72
72
|
if (item === ColumnsNames.CHART) {
|
|
73
73
|
return React.createElement("td", {
|
|
74
|
-
|
|
74
|
+
key: ColumnsNames.CHART,
|
|
75
75
|
className: "lw-relative lw-px-3 lw-py-0 lw-text-right",
|
|
76
|
-
|
|
76
|
+
"data-testid": "chart-table-cell"
|
|
77
77
|
}, React.createElement("div", {
|
|
78
78
|
className: "lw-flex lw-justify-center"
|
|
79
79
|
}, React.createElement(LineChartWithData, {
|
|
80
|
-
|
|
80
|
+
division: division,
|
|
81
81
|
isLoading: checkLoading('instrument'),
|
|
82
|
-
|
|
82
|
+
record: updatedRecord
|
|
83
83
|
})));
|
|
84
84
|
}
|
|
85
85
|
if (item === ColumnsNames.SPREAD) {
|
|
86
86
|
return React.createElement(TableCell, {
|
|
87
87
|
key: ColumnsNames.SPREAD,
|
|
88
|
-
isLoading: checkLoading(ColumnsNames.SPREAD),
|
|
89
88
|
isError: !!error,
|
|
89
|
+
isLoading: checkLoading(ColumnsNames.SPREAD),
|
|
90
90
|
loaderSize: LoaderSize.sm
|
|
91
91
|
}, React.createElement("span", null, updatedRecord.spread));
|
|
92
92
|
}
|