@oanda/labs-instrument-live-rate-widget 1.0.6 → 1.0.7
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 +32 -0
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +6 -2
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/Main.js +13 -5
- package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +1 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +7 -3
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/Main.js +15 -7
- package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +1 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -1
- package/package.json +3 -3
- package/src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx +8 -3
- package/src/InstrumentLiveRateWidget/Main.tsx +31 -20
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 1.0.7 (2024-07-26)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 1.0.145 (2024-07-25)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 1.0.144 (2024-07-22)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 1.0.143 (2024-07-19)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 1.0.142 (2024-07-16)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## 1.0.141 (2024-07-16)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## 1.0.140 (2024-07-12)
|
|
31
|
+
|
|
32
|
+
**Note:** Version bump only for package @oanda/labs-instrument-live-rate-widget
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
6
38
|
## 1.0.6 (2024-07-25)
|
|
7
39
|
|
|
8
40
|
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.InstrumentLiveRateWidget = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
9
|
var _client = require("@apollo/client");
|
|
9
10
|
var _monoI18n = require("@oanda/mono-i18n");
|
|
10
11
|
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
@@ -45,8 +46,11 @@ const InstrumentLiveRateWidget = _ref => {
|
|
|
45
46
|
}, _react.default.createElement(_client.ApolloProvider, {
|
|
46
47
|
client: client
|
|
47
48
|
}, isParamError ? _react.default.createElement("div", {
|
|
48
|
-
className:
|
|
49
|
-
|
|
49
|
+
className: (0, _classnames.default)('lw-flex lw-items-center lw-border lw-border-solid lw-border-border-primary lw-px-4', {
|
|
50
|
+
'lw-h-[82px]': size !== 'compact',
|
|
51
|
+
'lw-h-[54px]': size === 'compact'
|
|
52
|
+
})
|
|
53
|
+
}, _react.default.createElement(_labsWidgetCommon.Error, null)) : _react.default.createElement(_Main.Main, {
|
|
50
54
|
size: size,
|
|
51
55
|
instrument: instrument,
|
|
52
56
|
division: division
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentLiveRateWidget.js","names":["_react","_interopRequireDefault","require","_client","_monoI18n","_labsWidgetCommon","_translations","_Main","_types","e","__esModule","default","InstrumentLiveRateWidget","_ref","graphqlUrl","liveRatesUrl","instrument","division","locale","theme","isParamError","removePadding","size","client","ApolloClient","uri","cache","InMemoryCache","divisionCode","Division","Opt","Ogm","dataSource","createElement","ThemeProvider","LocaleProvider","getLocale","translations","LiveRatesProvider","url","options","ApolloProvider","className","
|
|
1
|
+
{"version":3,"file":"InstrumentLiveRateWidget.js","names":["_react","_interopRequireDefault","require","_classnames","_client","_monoI18n","_labsWidgetCommon","_translations","_Main","_types","e","__esModule","default","InstrumentLiveRateWidget","_ref","graphqlUrl","liveRatesUrl","instrument","division","locale","theme","isParamError","removePadding","size","client","ApolloClient","uri","cache","InMemoryCache","divisionCode","Division","Opt","Ogm","dataSource","createElement","ThemeProvider","LocaleProvider","getLocale","translations","LiveRatesProvider","url","options","ApolloProvider","className","classnames","Error","Main","exports"],"sources":["../../../src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport {\n Error, LiveRatesProvider, ThemeProvider, getLocale,\n} from '@oanda/labs-widget-common';\nimport { translations } from '../translations';\nimport { Main } from './Main';\nimport { Division, InstrumentLiveRateConfig } from './types';\n\nconst InstrumentLiveRateWidget = ({\n graphqlUrl,\n liveRatesUrl,\n instrument,\n division,\n locale,\n theme,\n isParamError,\n removePadding,\n size,\n}: InstrumentLiveRateConfig) => {\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 <ThemeProvider removePadding={removePadding} theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <LiveRatesProvider\n url={liveRatesUrl}\n options={{ divisionCode, dataSource }}\n >\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className={classnames('lw-flex lw-items-center lw-border lw-border-solid lw-border-border-primary lw-px-4', {\n 'lw-h-[82px]': size !== 'compact',\n 'lw-h-[54px]': size === 'compact',\n })}\n >\n <Error />\n </div>\n )\n : (\n <Main\n size={size}\n instrument={instrument}\n division={division}\n />\n )}\n </ApolloProvider>\n </LiveRatesProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { InstrumentLiveRateWidget };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAGA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAA6D,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7D,MAAMG,wBAAwB,GAAGC,IAAA,IAUD;EAAA,IAVE;IAChCC,UAAU;IACVC,YAAY;IACZC,UAAU;IACVC,QAAQ;IACRC,MAAM;IACNC,KAAK;IACLC,YAAY;IACZC,aAAa;IACbC;EACwB,CAAC,GAAAT,IAAA;EACzB,MAAMU,MAAM,GAAG,IAAIC,oBAAY,CAAC;IAC9BC,GAAG,EAAEX,UAAU;IACfY,KAAK,EAAE,IAAIC,qBAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMC,YAAY,GAAGX,QAAQ,KAAKY,eAAQ,CAACC,GAAG,GAAGD,eAAQ,CAACE,GAAG,GAAGd,QAAQ;EACx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fullWithChart'
|
|
23
23
|
} = _ref;
|
|
24
|
+
const {
|
|
25
|
+
size
|
|
26
|
+
} = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
|
|
24
27
|
const {
|
|
25
28
|
target,
|
|
26
29
|
setQuery
|
|
@@ -56,23 +59,28 @@ const Main = _ref => {
|
|
|
56
59
|
}
|
|
57
60
|
}, [records]);
|
|
58
61
|
const showError = !!error;
|
|
59
|
-
return _react.default.createElement(_react.default.Fragment, null,
|
|
62
|
+
return _react.default.createElement(_react.default.Fragment, null, size && _react.default.createElement("div", {
|
|
60
63
|
"data-testid": "instrument-live-rate-wrapper",
|
|
61
|
-
className:
|
|
64
|
+
className: "lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary"
|
|
65
|
+
}, !showError && _react.default.createElement("div", {
|
|
66
|
+
className: (0, _classnames.default)({
|
|
62
67
|
'lw-h-[82px]': widgetSize !== 'compact',
|
|
63
68
|
'lw-h-[54px]': widgetSize === 'compact'
|
|
64
69
|
})
|
|
65
70
|
}, _react.default.createElement(_InstrumentRateWithChart.InstrumentRateWithChart, {
|
|
66
71
|
loading: loading,
|
|
67
|
-
record: records[0],
|
|
72
|
+
record: records[0] || {},
|
|
68
73
|
target: target,
|
|
69
74
|
division: division,
|
|
70
75
|
size: widgetSize
|
|
71
76
|
}), _react.default.createElement(_labsWidgetCommon.Tooltip, {
|
|
72
77
|
id: _constant.INSTRUMENT_TOOLTIP_ID
|
|
73
78
|
})), !loading && showError && _react.default.createElement("div", {
|
|
74
|
-
className:
|
|
75
|
-
|
|
79
|
+
className: (0, _classnames.default)('lw-flex lw-w-full lw-items-center', {
|
|
80
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
81
|
+
'lw-h-[54px]': widgetSize === 'compact'
|
|
82
|
+
})
|
|
83
|
+
}, _react.default.createElement(_labsWidgetCommon.Error, null))));
|
|
76
84
|
};
|
|
77
85
|
exports.Main = Main;
|
|
78
86
|
//# sourceMappingURL=Main.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_client","_classnames","_interopRequireDefault","_labsWidgetCommon","_utils","_constant","_validateInstruments","_InstrumentRateWithChart","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","instrument","division","size","widgetSize","target","setQuery","useLiveRatesQuery","records","setRecords","useState","loading","data","error","useQuery","validateInstruments","variables","instruments","fetchPolicy","useEffect","getRecords","instrumentsNames","map","_ref2","instrumentName","showError","createElement","Fragment","
|
|
1
|
+
{"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_client","_classnames","_interopRequireDefault","_labsWidgetCommon","_utils","_constant","_validateInstruments","_InstrumentRateWithChart","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","instrument","division","size","widgetSize","useContext","ThemeContext","target","setQuery","useLiveRatesQuery","records","setRecords","useState","loading","data","error","useQuery","validateInstruments","variables","instruments","fetchPolicy","useEffect","getRecords","instrumentsNames","map","_ref2","instrumentName","showError","createElement","Fragment","className","classnames","InstrumentRateWithChart","record","Tooltip","id","INSTRUMENT_TOOLTIP_ID","Error","exports"],"sources":["../../../src/InstrumentLiveRateWidget/Main.tsx"],"sourcesContent":["import React, { useContext, useEffect, useState } from 'react';\nimport { useQuery } from '@apollo/client';\nimport classnames from 'classnames';\nimport {\n Error,\n DataRecord,\n ThemeContext,\n Tooltip,\n useLiveRatesQuery,\n} from '@oanda/labs-widget-common';\nimport { getRecords } from './utils';\nimport { MainProps } from './types';\nimport { INSTRUMENT_TOOLTIP_ID } from './constant';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';\nimport { InstrumentRateWithChart } from './components/InstrumentRateWithChart';\n\nconst Main = ({\n instrument,\n division,\n size: widgetSize = 'fullWithChart',\n}: MainProps) => {\n const { size } = useContext(ThemeContext);\n const { target, setQuery } = useLiveRatesQuery();\n const [records, setRecords] = useState<DataRecord[]>([]);\n\n const { loading, data, error } = useQuery<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables\n >(validateInstruments, {\n variables: {\n instruments: [instrument],\n division,\n },\n fetchPolicy: 'network-only',\n });\n\n useEffect(() => {\n if (!loading && data) {\n setRecords(getRecords(data)!);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [loading, data]);\n\n const instrumentsNames = records.map(({ instrument: instrumentName }) => instrumentName);\n\n useEffect(() => {\n if (instrumentsNames[0]) {\n setQuery({ instruments: instrumentsNames });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [records]);\n\n const showError = !!error;\n\n return (\n <>\n {size && (\n <div\n data-testid=\"instrument-live-rate-wrapper\"\n className=\"lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary\"\n >\n {!showError && (\n <div className={classnames({\n 'lw-h-[82px]': widgetSize !== 'compact',\n 'lw-h-[54px]': widgetSize === 'compact',\n })}\n >\n <InstrumentRateWithChart\n loading={loading}\n record={records[0] || {}}\n target={target}\n division={division}\n size={widgetSize}\n />\n <Tooltip id={INSTRUMENT_TOOLTIP_ID} />\n </div>\n )}\n {!loading && showError && (\n <div className={classnames('lw-flex lw-w-full lw-items-center', {\n 'lw-h-[82px]': widgetSize !== 'compact',\n 'lw-h-[54px]': widgetSize === 'compact',\n })}\n >\n <Error />\n </div>\n )}\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,I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
|
updatedRecord,
|
|
28
28
|
error
|
|
29
|
-
} = (0, _utils2.useRecords)(record, record
|
|
29
|
+
} = (0, _utils2.useRecords)(record, record?.instrument ? target : null);
|
|
30
30
|
const indicator = (0, _utils.getColorIndicator)(updatedRecord.dailyPercentChange);
|
|
31
31
|
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_labsWidgetCommon.InstrumentRate, {
|
|
32
32
|
isLoading: loading,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentRateWithChart.js","names":["_react","_interopRequireWildcard","require","_labsWidgetCommon","_utils","_constant","_LineChartWithData","_utils2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","InstrumentRateWithChart","_ref","loading","record","target","division","size","isDark","useContext","ThemeContext","updatedRecord","error","useRecords","instrument","indicator","getColorIndicator","dailyPercentChange","createElement","Fragment","InstrumentRate","isLoading","isError","tooltipId","INSTRUMENT_TOOLTIP_ID","colorIndicator","LineChartWithData","color","getChartColor","exports"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { InstrumentRate, ThemeContext } from '@oanda/labs-widget-common';\nimport { InstrumentRateWithChartProps } from './types';\nimport { getChartColor, getColorIndicator } from './utils';\nimport { INSTRUMENT_TOOLTIP_ID } from '../../constant';\nimport { LineChartWithData } from '../LineChartWithData';\nimport { useRecords } from '../../utils';\n\nconst InstrumentRateWithChart = ({\n loading,\n record,\n target,\n division,\n size,\n}: InstrumentRateWithChartProps) => {\n const { isDark } = useContext(ThemeContext);\n const { updatedRecord, error } = useRecords(record, record
|
|
1
|
+
{"version":3,"file":"InstrumentRateWithChart.js","names":["_react","_interopRequireWildcard","require","_labsWidgetCommon","_utils","_constant","_LineChartWithData","_utils2","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","InstrumentRateWithChart","_ref","loading","record","target","division","size","isDark","useContext","ThemeContext","updatedRecord","error","useRecords","instrument","indicator","getColorIndicator","dailyPercentChange","createElement","Fragment","InstrumentRate","isLoading","isError","tooltipId","INSTRUMENT_TOOLTIP_ID","colorIndicator","LineChartWithData","color","getChartColor","exports"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { InstrumentRate, ThemeContext } from '@oanda/labs-widget-common';\nimport { InstrumentRateWithChartProps } from './types';\nimport { getChartColor, getColorIndicator } from './utils';\nimport { INSTRUMENT_TOOLTIP_ID } from '../../constant';\nimport { LineChartWithData } from '../LineChartWithData';\nimport { useRecords } from '../../utils';\n\nconst InstrumentRateWithChart = ({\n loading,\n record,\n target,\n division,\n size,\n}: InstrumentRateWithChartProps) => {\n const { isDark } = useContext(ThemeContext);\n const { updatedRecord, error } = useRecords(record, record?.instrument ? target : null);\n\n const indicator = getColorIndicator(updatedRecord.dailyPercentChange);\n\n return (\n <>\n <InstrumentRate\n isLoading={loading}\n isError={!!error}\n record={updatedRecord}\n size={size}\n tooltipId={INSTRUMENT_TOOLTIP_ID}\n colorIndicator={indicator}\n />\n {size === 'fullWithChart' && (\n <LineChartWithData\n record={record}\n isLoading={loading}\n division={division}\n color={getChartColor(indicator, isDark)}\n />\n )}\n </>\n );\n};\n\nexport { InstrumentRateWithChart };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAAyC,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBA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,CAAC;EAC3C,MAAM;IAAEC,aAAa;IAAEC;EAAM,CAAC,GAAG,IAAAC,kBAAU,EAACT,MAAM,EAAEA,MAAM,EAAEU,UAAU,GAAGT,MAAM,GAAG,IAAI,CAAC;EAEvF,MAAMU,SAAS,GAAG,IAAAC,wBAAiB,EAACL,aAAa,CAACM,kBAAkB,CAAC;EAErE,OACE5C,MAAA,CAAAc,OAAA,CAAA+B,aAAA,CAAA7C,MAAA,CAAAc,OAAA,CAAAgC,QAAA,QACE9C,MAAA,CAAAc,OAAA,CAAA+B,aAAA,CAAC1C,iBAAA,CAAA4C,cAAc;IACbC,SAAS,EAAElB,OAAQ;IACnBmB,OAAO,EAAE,CAAC,CAACV,KAAM;IACjBR,MAAM,EAAEO,aAAc;IACtBJ,IAAI,EAAEA,IAAK;IACXgB,SAAS,EAAEC,+BAAsB;IACjCC,cAAc,EAAEV;EAAU,CAC3B,CAAC,EACDR,IAAI,KAAK,eAAe,IACvBlC,MAAA,CAAAc,OAAA,CAAA+B,aAAA,CAACvC,kBAAA,CAAA+C,iBAAiB;IAChBtB,MAAM,EAAEA,MAAO;IACfiB,SAAS,EAAElB,OAAQ;IACnBG,QAAQ,EAAEA,QAAS;IACnBqB,KAAK,EAAE,IAAAC,oBAAa,EAACb,SAAS,EAAEP,MAAM;EAAE,CACzC,CAEH,CAAC;AAEP,CAAC;AAACqB,OAAA,CAAA5B,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
2
3
|
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
3
4
|
import { LocaleProvider } from '@oanda/mono-i18n';
|
|
4
|
-
import {
|
|
5
|
+
import { Error, LiveRatesProvider, ThemeProvider, getLocale } from '@oanda/labs-widget-common';
|
|
5
6
|
import { translations } from '../translations';
|
|
6
7
|
import { Main } from './Main';
|
|
7
8
|
import { Division } from './types';
|
|
@@ -38,8 +39,11 @@ const InstrumentLiveRateWidget = _ref => {
|
|
|
38
39
|
}, React.createElement(ApolloProvider, {
|
|
39
40
|
client: client
|
|
40
41
|
}, isParamError ? React.createElement("div", {
|
|
41
|
-
className:
|
|
42
|
-
|
|
42
|
+
className: classnames('lw-flex lw-items-center lw-border lw-border-solid lw-border-border-primary lw-px-4', {
|
|
43
|
+
'lw-h-[82px]': size !== 'compact',
|
|
44
|
+
'lw-h-[54px]': size === 'compact'
|
|
45
|
+
})
|
|
46
|
+
}, React.createElement(Error, null)) : React.createElement(Main, {
|
|
43
47
|
size: size,
|
|
44
48
|
instrument: instrument,
|
|
45
49
|
division: division
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentLiveRateWidget.js","names":["React","ApolloClient","InMemoryCache","ApolloProvider","LocaleProvider","
|
|
1
|
+
{"version":3,"file":"InstrumentLiveRateWidget.js","names":["React","classnames","ApolloClient","InMemoryCache","ApolloProvider","LocaleProvider","Error","LiveRatesProvider","ThemeProvider","getLocale","translations","Main","Division","InstrumentLiveRateWidget","_ref","graphqlUrl","liveRatesUrl","instrument","division","locale","theme","isParamError","removePadding","size","client","uri","cache","divisionCode","Opt","Ogm","dataSource","createElement","url","options","className"],"sources":["../../../src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport {\n Error, LiveRatesProvider, ThemeProvider, getLocale,\n} from '@oanda/labs-widget-common';\nimport { translations } from '../translations';\nimport { Main } from './Main';\nimport { Division, InstrumentLiveRateConfig } from './types';\n\nconst InstrumentLiveRateWidget = ({\n graphqlUrl,\n liveRatesUrl,\n instrument,\n division,\n locale,\n theme,\n isParamError,\n removePadding,\n size,\n}: InstrumentLiveRateConfig) => {\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 <ThemeProvider removePadding={removePadding} theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <LiveRatesProvider\n url={liveRatesUrl}\n options={{ divisionCode, dataSource }}\n >\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className={classnames('lw-flex lw-items-center lw-border lw-border-solid lw-border-border-primary lw-px-4', {\n 'lw-h-[82px]': size !== 'compact',\n 'lw-h-[54px]': size === 'compact',\n })}\n >\n <Error />\n </div>\n )\n : (\n <Main\n size={size}\n instrument={instrument}\n division={division}\n />\n )}\n </ApolloProvider>\n </LiveRatesProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { InstrumentLiveRateWidget };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,YAAY,EAAEC,aAAa,EAAEC,cAAc,QAAQ,gBAAgB;AAC5E,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,KAAK,EAAEC,iBAAiB,EAAEC,aAAa,EAAEC,SAAS,QAC7C,2BAA2B;AAClC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SAASC,QAAQ,QAAkC,SAAS;AAE5D,MAAMC,wBAAwB,GAAGC,IAAA,IAUD;EAAA,IAVE;IAChCC,UAAU;IACVC,YAAY;IACZC,UAAU;IACVC,QAAQ;IACRC,MAAM;IACNC,KAAK;IACLC,YAAY;IACZC,aAAa;IACbC;EACwB,CAAC,GAAAT,IAAA;EACzB,MAAMU,MAAM,GAAG,IAAItB,YAAY,CAAC;IAC9BuB,GAAG,EAAEV,UAAU;IACfW,KAAK,EAAE,IAAIvB,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMwB,YAAY,GAAGT,QAAQ,KAAKN,QAAQ,CAACgB,GAAG,GAAGhB,QAAQ,CAACiB,GAAG,GAAGX,QAAQ;EACxE,MAAMY,UAAU,GAAGH,YAAY,KAAKf,QAAQ,CAACiB,GAAG,GAAG,KAAK,GAAG,KAAK;EAEhE,OACE7B,KAAA,CAAA+B,aAAA,CAACvB,aAAa;IAACc,aAAa,EAAEA,aAAc;IAACF,KAAK,EAAEA;EAAM,GACxDpB,KAAA,CAAA+B,aAAA,CAAC1B,cAAc;IAACc,MAAM,EAAEV,SAAS,CAACU,MAAM,CAAE;IAACT,YAAY,EAAEA;EAAa,GACpEV,KAAA,CAAA+B,aAAA,CAACxB,iBAAiB;IAChByB,GAAG,EAAEhB,YAAa;IAClBiB,OAAO,EAAE;MAAEN,YAAY;MAAEG;IAAW;EAAE,GAEtC9B,KAAA,CAAA+B,aAAA,CAAC3B,cAAc;IAACoB,MAAM,EAAEA;EAAO,GAC5BH,YAAY,GACXrB,KAAA,CAAA+B,aAAA;IAAKG,SAAS,EAAEjC,UAAU,CAAC,oFAAoF,EAAE;MAC/G,aAAa,EAAEsB,IAAI,KAAK,SAAS;MACjC,aAAa,EAAEA,IAAI,KAAK;IAC1B,CAAC;EAAE,GAEDvB,KAAA,CAAA+B,aAAA,CAACzB,KAAK,MAAE,CACL,CAAC,GAGJN,KAAA,CAAA+B,aAAA,CAACpB,IAAI;IACHY,IAAI,EAAEA,IAAK;IACXN,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAEA;EAAS,CACpB,CAES,CACC,CACL,CACH,CAAC;AAEpB,CAAC;AAED,SAASL,wBAAwB","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
2
2
|
import { useQuery } from '@apollo/client';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
|
-
import {
|
|
4
|
+
import { Error, ThemeContext, Tooltip, useLiveRatesQuery } from '@oanda/labs-widget-common';
|
|
5
5
|
import { getRecords } from './utils';
|
|
6
6
|
import { INSTRUMENT_TOOLTIP_ID } from './constant';
|
|
7
7
|
import { validateInstruments } from '../gql/validateInstruments';
|
|
@@ -12,6 +12,9 @@ const Main = _ref => {
|
|
|
12
12
|
division,
|
|
13
13
|
size: widgetSize = 'fullWithChart'
|
|
14
14
|
} = _ref;
|
|
15
|
+
const {
|
|
16
|
+
size
|
|
17
|
+
} = useContext(ThemeContext);
|
|
15
18
|
const {
|
|
16
19
|
target,
|
|
17
20
|
setQuery
|
|
@@ -47,23 +50,28 @@ const Main = _ref => {
|
|
|
47
50
|
}
|
|
48
51
|
}, [records]);
|
|
49
52
|
const showError = !!error;
|
|
50
|
-
return React.createElement(React.Fragment, null,
|
|
53
|
+
return React.createElement(React.Fragment, null, size && React.createElement("div", {
|
|
51
54
|
"data-testid": "instrument-live-rate-wrapper",
|
|
52
|
-
className:
|
|
55
|
+
className: "lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary"
|
|
56
|
+
}, !showError && React.createElement("div", {
|
|
57
|
+
className: classnames({
|
|
53
58
|
'lw-h-[82px]': widgetSize !== 'compact',
|
|
54
59
|
'lw-h-[54px]': widgetSize === 'compact'
|
|
55
60
|
})
|
|
56
61
|
}, React.createElement(InstrumentRateWithChart, {
|
|
57
62
|
loading: loading,
|
|
58
|
-
record: records[0],
|
|
63
|
+
record: records[0] || {},
|
|
59
64
|
target: target,
|
|
60
65
|
division: division,
|
|
61
66
|
size: widgetSize
|
|
62
67
|
}), React.createElement(Tooltip, {
|
|
63
68
|
id: INSTRUMENT_TOOLTIP_ID
|
|
64
69
|
})), !loading && showError && React.createElement("div", {
|
|
65
|
-
className:
|
|
66
|
-
|
|
70
|
+
className: classnames('lw-flex lw-w-full lw-items-center', {
|
|
71
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
72
|
+
'lw-h-[54px]': widgetSize === 'compact'
|
|
73
|
+
})
|
|
74
|
+
}, React.createElement(Error, null))));
|
|
67
75
|
};
|
|
68
76
|
export { Main };
|
|
69
77
|
//# sourceMappingURL=Main.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["React","useEffect","useState","useQuery","classnames","
|
|
1
|
+
{"version":3,"file":"Main.js","names":["React","useContext","useEffect","useState","useQuery","classnames","Error","ThemeContext","Tooltip","useLiveRatesQuery","getRecords","INSTRUMENT_TOOLTIP_ID","validateInstruments","InstrumentRateWithChart","Main","_ref","instrument","division","size","widgetSize","target","setQuery","records","setRecords","loading","data","error","variables","instruments","fetchPolicy","instrumentsNames","map","_ref2","instrumentName","showError","createElement","Fragment","className","record","id"],"sources":["../../../src/InstrumentLiveRateWidget/Main.tsx"],"sourcesContent":["import React, { useContext, useEffect, useState } from 'react';\nimport { useQuery } from '@apollo/client';\nimport classnames from 'classnames';\nimport {\n Error,\n DataRecord,\n ThemeContext,\n Tooltip,\n useLiveRatesQuery,\n} from '@oanda/labs-widget-common';\nimport { getRecords } from './utils';\nimport { MainProps } from './types';\nimport { INSTRUMENT_TOOLTIP_ID } from './constant';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';\nimport { InstrumentRateWithChart } from './components/InstrumentRateWithChart';\n\nconst Main = ({\n instrument,\n division,\n size: widgetSize = 'fullWithChart',\n}: MainProps) => {\n const { size } = useContext(ThemeContext);\n const { target, setQuery } = useLiveRatesQuery();\n const [records, setRecords] = useState<DataRecord[]>([]);\n\n const { loading, data, error } = useQuery<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables\n >(validateInstruments, {\n variables: {\n instruments: [instrument],\n division,\n },\n fetchPolicy: 'network-only',\n });\n\n useEffect(() => {\n if (!loading && data) {\n setRecords(getRecords(data)!);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [loading, data]);\n\n const instrumentsNames = records.map(({ instrument: instrumentName }) => instrumentName);\n\n useEffect(() => {\n if (instrumentsNames[0]) {\n setQuery({ instruments: instrumentsNames });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [records]);\n\n const showError = !!error;\n\n return (\n <>\n {size && (\n <div\n data-testid=\"instrument-live-rate-wrapper\"\n className=\"lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary\"\n >\n {!showError && (\n <div className={classnames({\n 'lw-h-[82px]': widgetSize !== 'compact',\n 'lw-h-[54px]': widgetSize === 'compact',\n })}\n >\n <InstrumentRateWithChart\n loading={loading}\n record={records[0] || {}}\n target={target}\n division={division}\n size={widgetSize}\n />\n <Tooltip id={INSTRUMENT_TOOLTIP_ID} />\n </div>\n )}\n {!loading && showError && (\n <div className={classnames('lw-flex lw-w-full lw-items-center', {\n 'lw-h-[82px]': widgetSize !== 'compact',\n 'lw-h-[54px]': widgetSize === 'compact',\n })}\n >\n <Error />\n </div>\n )}\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC9D,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,UAAU,MAAM,YAAY;AACnC,SACEC,KAAK,EAELC,YAAY,EACZC,OAAO,EACPC,iBAAiB,QACZ,2BAA2B;AAClC,SAASC,UAAU,QAAQ,SAAS;AAEpC,SAASC,qBAAqB,QAAQ,YAAY;AAClD,SAASC,mBAAmB,QAAQ,4BAA4B;AAEhE,SAASC,uBAAuB,QAAQ,sCAAsC;AAE9E,MAAMC,IAAI,GAAGC,IAAA,IAII;EAAA,IAJH;IACZC,UAAU;IACVC,QAAQ;IACRC,IAAI,EAAEC,UAAU,GAAG;EACV,CAAC,GAAAJ,IAAA;EACV,MAAM;IAAEG;EAAK,CAAC,GAAGjB,UAAU,CAACM,YAAY,CAAC;EACzC,MAAM;IAAEa,MAAM;IAAEC;EAAS,CAAC,GAAGZ,iB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OAAO,EAAEA,OAAQ;IACjBc,MAAM,EAAEhB,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAE;IACzBF,MAAM,EAAEA,MAAO;IACfH,QAAQ,EAAEA,QAAS;IACnBC,IAAI,EAAEC;EAAW,CAClB,CAAC,EACFnB,KAAA,CAAAmC,aAAA,CAAC3B,OAAO;IAAC+B,EAAE,EAAE5B;EAAsB,CAAE,CAClC,CACN,EACA,CAACa,OAAO,IAAIU,SAAS,IACpBlC,KAAA,CAAAmC,aAAA;IAAKE,SAAS,EAAEhC,UAAU,CAAC,mCAAmC,EAAE;MAC9D,aAAa,EAAEc,UAAU,KAAK,SAAS;MACvC,aAAa,EAAEA,UAAU,KAAK;IAChC,CAAC;EAAE,GAEDnB,KAAA,CAAAmC,aAAA,CAAC7B,KAAK,MAAE,CACL,CAEJ,CAEP,CAAC;AAEP,CAAC;AAED,SAASQ,IAAI","ignoreList":[]}
|
|
@@ -18,7 +18,7 @@ const InstrumentRateWithChart = _ref => {
|
|
|
18
18
|
const {
|
|
19
19
|
updatedRecord,
|
|
20
20
|
error
|
|
21
|
-
} = useRecords(record, record
|
|
21
|
+
} = useRecords(record, record?.instrument ? target : null);
|
|
22
22
|
const indicator = getColorIndicator(updatedRecord.dailyPercentChange);
|
|
23
23
|
return React.createElement(React.Fragment, null, React.createElement(InstrumentRate, {
|
|
24
24
|
isLoading: loading,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentRateWithChart.js","names":["React","useContext","InstrumentRate","ThemeContext","getChartColor","getColorIndicator","INSTRUMENT_TOOLTIP_ID","LineChartWithData","useRecords","InstrumentRateWithChart","_ref","loading","record","target","division","size","isDark","updatedRecord","error","instrument","indicator","dailyPercentChange","createElement","Fragment","isLoading","isError","tooltipId","colorIndicator","color"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { InstrumentRate, ThemeContext } from '@oanda/labs-widget-common';\nimport { InstrumentRateWithChartProps } from './types';\nimport { getChartColor, getColorIndicator } from './utils';\nimport { INSTRUMENT_TOOLTIP_ID } from '../../constant';\nimport { LineChartWithData } from '../LineChartWithData';\nimport { useRecords } from '../../utils';\n\nconst InstrumentRateWithChart = ({\n loading,\n record,\n target,\n division,\n size,\n}: InstrumentRateWithChartProps) => {\n const { isDark } = useContext(ThemeContext);\n const { updatedRecord, error } = useRecords(record, record
|
|
1
|
+
{"version":3,"file":"InstrumentRateWithChart.js","names":["React","useContext","InstrumentRate","ThemeContext","getChartColor","getColorIndicator","INSTRUMENT_TOOLTIP_ID","LineChartWithData","useRecords","InstrumentRateWithChart","_ref","loading","record","target","division","size","isDark","updatedRecord","error","instrument","indicator","dailyPercentChange","createElement","Fragment","isLoading","isError","tooltipId","colorIndicator","color"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { InstrumentRate, ThemeContext } from '@oanda/labs-widget-common';\nimport { InstrumentRateWithChartProps } from './types';\nimport { getChartColor, getColorIndicator } from './utils';\nimport { INSTRUMENT_TOOLTIP_ID } from '../../constant';\nimport { LineChartWithData } from '../LineChartWithData';\nimport { useRecords } from '../../utils';\n\nconst InstrumentRateWithChart = ({\n loading,\n record,\n target,\n division,\n size,\n}: InstrumentRateWithChartProps) => {\n const { isDark } = useContext(ThemeContext);\n const { updatedRecord, error } = useRecords(record, record?.instrument ? target : null);\n\n const indicator = getColorIndicator(updatedRecord.dailyPercentChange);\n\n return (\n <>\n <InstrumentRate\n isLoading={loading}\n isError={!!error}\n record={updatedRecord}\n size={size}\n tooltipId={INSTRUMENT_TOOLTIP_ID}\n colorIndicator={indicator}\n />\n {size === 'fullWithChart' && (\n <LineChartWithData\n record={record}\n isLoading={loading}\n division={division}\n color={getChartColor(indicator, isDark)}\n />\n )}\n </>\n );\n};\n\nexport { InstrumentRateWithChart };\n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-1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oanda/labs-instrument-live-rate-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Labs Instrument Live Rate Widget",
|
|
5
5
|
"main": "dist/main/index.js",
|
|
6
6
|
"module": "dist/module/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"license": "UNLICENSED",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@apollo/client": "3.9.9",
|
|
16
|
-
"@oanda/labs-widget-common": "^1.0.
|
|
16
|
+
"@oanda/labs-widget-common": "^1.0.146",
|
|
17
17
|
"@oanda/mono-i18n": "10.0.1",
|
|
18
18
|
"graphql": "16.8.1"
|
|
19
19
|
},
|
|
@@ -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": "7495097f53b89904a3bedc52e8e7b998c8fd5d02"
|
|
25
25
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
2
3
|
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
3
4
|
import { LocaleProvider } from '@oanda/mono-i18n';
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
+
Error, LiveRatesProvider, ThemeProvider, getLocale,
|
|
6
7
|
} from '@oanda/labs-widget-common';
|
|
7
8
|
import { translations } from '../translations';
|
|
8
9
|
import { Main } from './Main';
|
|
@@ -36,8 +37,12 @@ const InstrumentLiveRateWidget = ({
|
|
|
36
37
|
>
|
|
37
38
|
<ApolloProvider client={client}>
|
|
38
39
|
{isParamError ? (
|
|
39
|
-
<div className=
|
|
40
|
-
|
|
40
|
+
<div className={classnames('lw-flex lw-items-center lw-border lw-border-solid lw-border-border-primary lw-px-4', {
|
|
41
|
+
'lw-h-[82px]': size !== 'compact',
|
|
42
|
+
'lw-h-[54px]': size === 'compact',
|
|
43
|
+
})}
|
|
44
|
+
>
|
|
45
|
+
<Error />
|
|
41
46
|
</div>
|
|
42
47
|
)
|
|
43
48
|
: (
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
1
|
+
import React, { useContext, useEffect, useState } from 'react';
|
|
2
2
|
import { useQuery } from '@apollo/client';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
Error,
|
|
6
6
|
DataRecord,
|
|
7
|
+
ThemeContext,
|
|
7
8
|
Tooltip,
|
|
8
9
|
useLiveRatesQuery,
|
|
9
10
|
} from '@oanda/labs-widget-common';
|
|
@@ -19,6 +20,7 @@ const Main = ({
|
|
|
19
20
|
division,
|
|
20
21
|
size: widgetSize = 'fullWithChart',
|
|
21
22
|
}: MainProps) => {
|
|
23
|
+
const { size } = useContext(ThemeContext);
|
|
22
24
|
const { target, setQuery } = useLiveRatesQuery();
|
|
23
25
|
const [records, setRecords] = useState<DataRecord[]>([]);
|
|
24
26
|
|
|
@@ -53,27 +55,36 @@ const Main = ({
|
|
|
53
55
|
|
|
54
56
|
return (
|
|
55
57
|
<>
|
|
56
|
-
{
|
|
58
|
+
{size && (
|
|
57
59
|
<div
|
|
58
60
|
data-testid="instrument-live-rate-wrapper"
|
|
59
|
-
className=
|
|
60
|
-
'lw-h-[82px]': widgetSize !== 'compact',
|
|
61
|
-
'lw-h-[54px]': widgetSize === 'compact',
|
|
62
|
-
})}
|
|
61
|
+
className="lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary"
|
|
63
62
|
>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
63
|
+
{!showError && (
|
|
64
|
+
<div className={classnames({
|
|
65
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
66
|
+
'lw-h-[54px]': widgetSize === 'compact',
|
|
67
|
+
})}
|
|
68
|
+
>
|
|
69
|
+
<InstrumentRateWithChart
|
|
70
|
+
loading={loading}
|
|
71
|
+
record={records[0] || {}}
|
|
72
|
+
target={target}
|
|
73
|
+
division={division}
|
|
74
|
+
size={widgetSize}
|
|
75
|
+
/>
|
|
76
|
+
<Tooltip id={INSTRUMENT_TOOLTIP_ID} />
|
|
77
|
+
</div>
|
|
78
|
+
)}
|
|
79
|
+
{!loading && showError && (
|
|
80
|
+
<div className={classnames('lw-flex lw-w-full lw-items-center', {
|
|
81
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
82
|
+
'lw-h-[54px]': widgetSize === 'compact',
|
|
83
|
+
})}
|
|
84
|
+
>
|
|
85
|
+
<Error />
|
|
86
|
+
</div>
|
|
87
|
+
)}
|
|
77
88
|
</div>
|
|
78
89
|
)}
|
|
79
90
|
</>
|
package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx
CHANGED
|
@@ -14,7 +14,7 @@ const InstrumentRateWithChart = ({
|
|
|
14
14
|
size,
|
|
15
15
|
}: InstrumentRateWithChartProps) => {
|
|
16
16
|
const { isDark } = useContext(ThemeContext);
|
|
17
|
-
const { updatedRecord, error } = useRecords(record, record
|
|
17
|
+
const { updatedRecord, error } = useRecords(record, record?.instrument ? target : null);
|
|
18
18
|
|
|
19
19
|
const indicator = getColorIndicator(updatedRecord.dailyPercentChange);
|
|
20
20
|
|