@oanda/labs-instrument-live-rate-widget 1.0.2 → 1.0.4
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 +36 -0
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +1 -1
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/Main.js +7 -6
- package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +1 -5
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/render.js +4 -0
- package/dist/main/InstrumentLiveRateWidget/render.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +1 -1
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/Main.js +8 -8
- package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +1 -5
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/render.js +4 -0
- package/dist/module/InstrumentLiveRateWidget/render.js.map +1 -1
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.d.ts +1 -1
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/types.d.ts +1 -3
- package/package.json +3 -3
- package/src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx +1 -1
- package/src/InstrumentLiveRateWidget/Main.tsx +7 -7
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx +1 -5
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx +1 -3
- package/src/InstrumentLiveRateWidget/render.tsx +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,42 @@
|
|
|
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.4 (2024-07-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 1.0.142 (2024-07-16)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 1.0.141 (2024-07-16)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 1.0.140 (2024-07-12)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @oanda/labs-instrument-live-rate-widget
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## 1.0.3 (2024-07-16)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## 1.0.141 (2024-07-16)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## 1.0.140 (2024-07-12)
|
|
35
|
+
|
|
36
|
+
**Note:** Version bump only for package @oanda/labs-instrument-live-rate-widget
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
6
42
|
## 1.0.2 (2024-07-16)
|
|
7
43
|
|
|
8
44
|
|
|
@@ -45,7 +45,7 @@ const InstrumentLiveRateWidget = _ref => {
|
|
|
45
45
|
}, _react.default.createElement(_client.ApolloProvider, {
|
|
46
46
|
client: client
|
|
47
47
|
}, isParamError ? _react.default.createElement("div", {
|
|
48
|
-
className: "lw-flex lw-h-[
|
|
48
|
+
className: "lw-flex lw-h-[150px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
|
|
49
49
|
}, _react.default.createElement(_labsWidgetCommon.ChartError, null)) : _react.default.createElement(_Main.Main, {
|
|
50
50
|
size: size,
|
|
51
51
|
instrument: instrument,
|
|
@@ -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","ChartError","Main","exports"],"sources":["../../../src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx"],"sourcesContent":["import React from 'react';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport {\n ChartError, 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=\"lw-flex lw-h-[
|
|
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","ChartError","Main","exports"],"sources":["../../../src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx"],"sourcesContent":["import React from 'react';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport {\n ChartError, 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=\"lw-flex lw-h-[150px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\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,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AAA,CAAAW,OAAA,CAAAsB,aAAA,CAAC9B,OAAA,CAAAsC,cAAc;IAAClB,MAAM,EAAEA;EAAO,GAC5BH,YAAY,GACXpB,MAAA,CAAAW,OAAA,CAAAsB,aAAA;IAAKS,SAAS,EAAC;EAAmG,GAChH1C,MAAA,CAAAW,OAAA,CAAAsB,aAAA,CAAC5B,iBAAA,CAAAsC,UAAU,MAAE,CACV,CAAC,GAGJ3C,MAAA,CAAAW,OAAA,CAAAsB,aAAA,CAAC1B,KAAA,CAAAqC,IAAI;IACHtB,IAAI,EAAEA,IAAK;IACXN,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAEA;EAAS,CACpB,CAES,CACC,CACL,CACH,CAAC;AAEpB,CAAC;AAAC4B,OAAA,CAAAjC,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -6,11 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Main = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _client = require("@apollo/client");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
10
|
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
10
11
|
var _utils = require("./utils");
|
|
11
12
|
var _constant = require("./constant");
|
|
12
13
|
var _validateInstruments = require("../gql/validateInstruments");
|
|
13
14
|
var _InstrumentRateWithChart = require("./components/InstrumentRateWithChart");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
18
|
const Main = _ref => {
|
|
@@ -19,10 +21,6 @@ const Main = _ref => {
|
|
|
19
21
|
division,
|
|
20
22
|
size: widgetSize = 'fullWithChart'
|
|
21
23
|
} = _ref;
|
|
22
|
-
const {
|
|
23
|
-
size
|
|
24
|
-
} = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
|
|
25
|
-
const isDesktop = size === _labsWidgetCommon.Size.DESKTOP;
|
|
26
24
|
const {
|
|
27
25
|
target,
|
|
28
26
|
setQuery
|
|
@@ -56,11 +54,14 @@ const Main = _ref => {
|
|
|
56
54
|
instruments: instrumentsNames
|
|
57
55
|
});
|
|
58
56
|
}
|
|
59
|
-
}, [records
|
|
57
|
+
}, [records]);
|
|
60
58
|
const showError = !!error;
|
|
61
59
|
return _react.default.createElement(_react.default.Fragment, null, records.length > 0 && _react.default.createElement("div", {
|
|
62
60
|
"data-testid": "instrument-live-rate-wrapper",
|
|
63
|
-
className:
|
|
61
|
+
className: (0, _classnames.default)('lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary', {
|
|
62
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
63
|
+
'lw-h-[54px]': widgetSize === 'compact'
|
|
64
|
+
})
|
|
64
65
|
}, _react.default.createElement(_InstrumentRateWithChart.InstrumentRateWithChart, {
|
|
65
66
|
loading: loading,
|
|
66
67
|
record: records[0],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_utils","_constant","_validateInstruments","_InstrumentRateWithChart","
|
|
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","length","className","classnames","InstrumentRateWithChart","record","Tooltip","id","INSTRUMENT_TOOLTIP_ID","ChartError","exports"],"sources":["../../../src/InstrumentLiveRateWidget/Main.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { useQuery } from '@apollo/client';\nimport classnames from 'classnames';\nimport {\n ChartError,\n DataRecord,\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 { 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 {records.length > 0 && (\n <div\n data-testid=\"instrument-live-rate-wrapper\"\n className={classnames('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 '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=\"lw-flex lw-h-[150px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\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,IAAAI,iBAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAP,OAAA;AAEA,IAAAQ,wBAAA,GAAAR,OAAA;AAA+E,SAAAG,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA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IAACC,EAAE,EAAEC;EAAsB,CAAE,CAClC,CACN,EACA,CAACxB,OAAO,IAAIc,SAAS,IACpBzD,MAAA,CAAAa,OAAA,CAAA6C,aAAA;IAAKG,SAAS,EAAC;EAAmG,GAChH7D,MAAA,CAAAa,OAAA,CAAA6C,aAAA,CAACpD,iBAAA,CAAA8D,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAACC,OAAA,CAAAtC,IAAA,GAAAA,IAAA","ignoreList":[]}
|
package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js
CHANGED
|
@@ -11,9 +11,7 @@ var _getInstrumentsChart = require("../../../gql/getInstrumentsChart");
|
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
const LineChartWithData = _ref => {
|
|
13
13
|
let {
|
|
14
|
-
padding,
|
|
15
14
|
record,
|
|
16
|
-
size,
|
|
17
15
|
isLoading,
|
|
18
16
|
division,
|
|
19
17
|
color
|
|
@@ -34,10 +32,8 @@ const LineChartWithData = _ref => {
|
|
|
34
32
|
return _react.default.createElement("div", {
|
|
35
33
|
className: "lw-relative"
|
|
36
34
|
}, !showChart ? _react.default.createElement("div", {
|
|
37
|
-
className: "lw-absolute lw-bottom-0 lw-right-0"
|
|
35
|
+
className: "lw-absolute lw-bottom-0 lw-right-0 lw--z-50 lw-flex lw-h-10 lw-w-[100px] lw-items-center lw-justify-center"
|
|
38
36
|
}, _react.default.createElement(_labsWidgetCommon.LineChart, {
|
|
39
|
-
padding: padding,
|
|
40
|
-
size: size,
|
|
41
37
|
color: color,
|
|
42
38
|
data: chart
|
|
43
39
|
})) : null);
|
package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChartWithData.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_getInstrumentsChart","e","__esModule","default","LineChartWithData","_ref","
|
|
1
|
+
{"version":3,"file":"LineChartWithData.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_getInstrumentsChart","e","__esModule","default","LineChartWithData","_ref","record","isLoading","division","color","loading","data","useQuery","getInstrumentsChart","variables","instruments","instrument","fetchPolicy","skip","showChart","chart","topicalInstrumentsCharts","createElement","className","LineChart","exports"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx"],"sourcesContent":["import React from 'react';\nimport { useQuery } from '@apollo/client';\nimport { LineChart } from '@oanda/labs-widget-common';\nimport { LineChartWithDataProps } from './types';\nimport { getInstrumentsChart } from '../../../gql/getInstrumentsChart';\nimport { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../../../gql/types/graphql';\n\nconst LineChartWithData = ({\n record,\n isLoading,\n division,\n color,\n}: LineChartWithDataProps) => {\n const { loading, data } = useQuery<\n GetInstrumentsChartQuery,\n GetInstrumentsChartQueryVariables\n >(getInstrumentsChart, {\n variables: {\n instruments: [record.instrument],\n division,\n },\n fetchPolicy: 'network-only',\n skip: !record.instrument,\n });\n\n const showChart = isLoading || loading;\n const chart = data?.topicalInstrumentsCharts?.[0].chart || [];\n\n return (\n <div className=\"lw-relative\">\n {!showChart ? (\n <div className=\"lw-absolute lw-bottom-0 lw-right-0 lw--z-50 lw-flex lw-h-10 lw-w-[100px] lw-items-center lw-justify-center\">\n <LineChart\n color={color}\n data={chart}\n />\n </div>\n ) : null}\n </div>\n );\n};\n\nexport { LineChartWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,oBAAA,GAAAH,OAAA;AAAuE,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGvE,MAAMG,iBAAiB,GAAGC,IAAA,IAKI;EAAA,IALH;IACzBC,MAAM;IACNC,SAAS;IACTC,QAAQ;IACRC;EACsB,CAAC,GAAAJ,IAAA;EACvB,MAAM;IAAEK,OAAO;IAAEC;EAAK,CAAC,GAAG,IAAAC,gBAAQ,EAGhCC,wCAAmB,EAAE;IACrBC,SAAS,EAAE;MACTC,WAAW,EAAE,CAACT,MAAM,CAACU,UAAU,CAAC;MAChCR;IACF,CAAC;IACDS,WAAW,EAAE,cAAc;IAC3BC,IAAI,EAAE,CAACZ,MAAM,CAACU;EAChB,CAAC,CAAC;EAEF,MAAMG,SAAS,GAAGZ,SAAS,IAAIG,OAAO;EACtC,MAAMU,KAAK,GAAGT,IAAI,EAAEU,wBAAwB,GAAG,CAAC,CAAC,CAACD,KAAK,IAAI,EAAE;EAE7D,OACEzB,MAAA,CAAAQ,OAAA,CAAAmB,aAAA;IAAKC,SAAS,EAAC;EAAa,GACzB,CAACJ,SAAS,GACTxB,MAAA,CAAAQ,OAAA,CAAAmB,aAAA;IAAKC,SAAS,EAAC;EAA4G,GACzH5B,MAAA,CAAAQ,OAAA,CAAAmB,aAAA,CAACvB,iBAAA,CAAAyB,SAAS;IACRf,KAAK,EAAEA,KAAM;IACbE,IAAI,EAAES;EAAM,CACb,CACE,CAAC,GACJ,IACD,CAAC;AAEV,CAAC;AAACK,OAAA,CAAArB,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { DataRecord
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { DataRecord } from '@oanda/labs-widget-common';\nimport { Division } from '../../../gql/types/graphql';\n\nexport interface LineChartWithDataProps {\n record: DataRecord;\n isLoading: boolean;\n division: Division;\n color: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -24,6 +24,7 @@ instrumentLiveRateElements.forEach(element => {
|
|
|
24
24
|
const isParamError = (0, _labsWidgetCommon.validateToolParams)({
|
|
25
25
|
division,
|
|
26
26
|
locale,
|
|
27
|
+
instrument,
|
|
27
28
|
graphqlUrl,
|
|
28
29
|
liveRatesUrl
|
|
29
30
|
}, [{
|
|
@@ -32,6 +33,9 @@ instrumentLiveRateElements.forEach(element => {
|
|
|
32
33
|
}, {
|
|
33
34
|
name: 'division',
|
|
34
35
|
valueCheck: value => Object.values(_graphql.Division).includes(value)
|
|
36
|
+
}, {
|
|
37
|
+
name: 'instrument',
|
|
38
|
+
valueCheck: value => value.length > 0
|
|
35
39
|
}, {
|
|
36
40
|
name: 'graphqlUrl'
|
|
37
41
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_InstrumentLiveRateWidget","_graphql","e","__esModule","default","graphqlUrl","liveRatesUrl","window","widgetsConfig","instrumentLiveRateElements","document","querySelectorAll","forEach","element","root","createRoot","params","getAttribute","mode","instrument","division","locale","size","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","validateLocale","Object","values","Division","includes","render","createElement","InstrumentLiveRateWidget","theme"],"sources":["../../../src/InstrumentLiveRateWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport { InstrumentLiveRateWidget } from './InstrumentLiveRateWidget';\nimport { Division } from '../gql/types/graphql';\n\nconst {\n graphqlUrl,\n liveRatesUrl,\n} = window.widgetsConfig || {};\n\nconst instrumentLiveRateElements = document.querySelectorAll('div[data-instrument-live-rate-params]');\n\ninstrumentLiveRateElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-instrument-live-rate-params');\n const mode = element.getAttribute('data-mode');\n const {\n instrument, division, locale, size,\n } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({\n division, locale, graphqlUrl, liveRatesUrl,\n }, [{\n name: 'locale',\n valueCheck: (value) => validateLocale(value),\n }, {\n name: 'division',\n valueCheck: (value) => Object.values(Division).includes(value),\n }, {\n name: 'graphqlUrl',\n }, {\n name: 'liveRatesUrl',\n }]);\n\n root.render(\n <InstrumentLiveRateWidget\n graphqlUrl={graphqlUrl}\n liveRatesUrl={liveRatesUrl}\n division={division}\n instrument={instrument}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n size={size}\n />,\n );\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,yBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAgD,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEhD,MAAM;EACJG,UAAU;EACVC;AACF,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE9B,MAAMC,0BAA0B,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,uCAAuC,CAAC;AAErGF,0BAA0B,CAACG,OAAO,CAAEC,OAAO,IAAK;EAC9C,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAACF,OAAO,CAAC;EAChC,MAAMG,MAAM,GAAGH,OAAO,CAACI,YAAY,CAAC,kCAAkC,CAAC;EACvE,MAAMC,IAAI,GAAGL,OAAO,CAACI,YAAY,CAAC,WAAW,CAAC;EAC9C,MAAM;IACJE,UAAU;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EAChC,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACR,MAAgB,CAAC;EAEhC,MAAMS,YAAY,GAAG,IAAAC,oCAAkB,EAAC;IACtCN,QAAQ;IAAEC,MAAM;
|
|
1
|
+
{"version":3,"file":"render.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_InstrumentLiveRateWidget","_graphql","e","__esModule","default","graphqlUrl","liveRatesUrl","window","widgetsConfig","instrumentLiveRateElements","document","querySelectorAll","forEach","element","root","createRoot","params","getAttribute","mode","instrument","division","locale","size","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","validateLocale","Object","values","Division","includes","length","render","createElement","InstrumentLiveRateWidget","theme"],"sources":["../../../src/InstrumentLiveRateWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport { InstrumentLiveRateWidget } from './InstrumentLiveRateWidget';\nimport { Division } from '../gql/types/graphql';\n\nconst {\n graphqlUrl,\n liveRatesUrl,\n} = window.widgetsConfig || {};\n\nconst instrumentLiveRateElements = document.querySelectorAll('div[data-instrument-live-rate-params]');\n\ninstrumentLiveRateElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-instrument-live-rate-params');\n const mode = element.getAttribute('data-mode');\n const {\n instrument, division, locale, size,\n } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({\n division, locale, instrument, graphqlUrl, liveRatesUrl,\n }, [{\n name: 'locale',\n valueCheck: (value) => validateLocale(value),\n }, {\n name: 'division',\n valueCheck: (value) => Object.values(Division).includes(value),\n }, {\n name: 'instrument',\n valueCheck: (value) => (value as string).length > 0,\n }, {\n name: 'graphqlUrl',\n }, {\n name: 'liveRatesUrl',\n }]);\n\n root.render(\n <InstrumentLiveRateWidget\n graphqlUrl={graphqlUrl}\n liveRatesUrl={liveRatesUrl}\n division={division}\n instrument={instrument}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n size={size}\n />,\n );\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,I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AEHb,IAAI,CAACsB,MAAM,CACTzC,MAAA,CAAAS,OAAA,CAAAiC,aAAA,CAACrC,yBAAA,CAAAsC,wBAAwB;IACvBjC,UAAU,EAAEA,UAAW;IACvBC,YAAY,EAAEA,YAAa;IAC3Bc,QAAQ,EAAEA,QAAS;IACnBD,UAAU,EAAEA,UAAW;IACvBE,MAAM,EAAEA,MAAO;IACfkB,KAAK,EAAErB,IAAc;IACrBO,YAAY,EAAEA,YAAa;IAC3BH,IAAI,EAAEA;EAAK,CACZ,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -38,7 +38,7 @@ const InstrumentLiveRateWidget = _ref => {
|
|
|
38
38
|
}, React.createElement(ApolloProvider, {
|
|
39
39
|
client: client
|
|
40
40
|
}, isParamError ? React.createElement("div", {
|
|
41
|
-
className: "lw-flex lw-h-[
|
|
41
|
+
className: "lw-flex lw-h-[150px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
|
|
42
42
|
}, React.createElement(ChartError, null)) : React.createElement(Main, {
|
|
43
43
|
size: size,
|
|
44
44
|
instrument: instrument,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentLiveRateWidget.js","names":["React","ApolloClient","InMemoryCache","ApolloProvider","LocaleProvider","ChartError","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 { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport {\n ChartError, 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=\"lw-flex lw-h-[
|
|
1
|
+
{"version":3,"file":"InstrumentLiveRateWidget.js","names":["React","ApolloClient","InMemoryCache","ApolloProvider","LocaleProvider","ChartError","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 { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport {\n ChartError, 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=\"lw-flex lw-h-[150px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\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,SAASC,YAAY,EAAEC,aAAa,EAAEC,cAAc,QAAQ,gBAAgB;AAC5E,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,UAAU,EAAEC,iBAAiB,EAAEC,aAAa,EAAEC,SAAS,QAClD,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,OACE5B,KAAA,CAAA8B,aAAA,CAACvB,aAAa;IAACc,aAAa,EAAEA,aAAc;IAACF,KAAK,EAAEA;EAAM,GACxDnB,KAAA,CAAA8B,aAAA,CAAC1B,cAAc;IAACc,MAAM,EAAEV,SAAS,CAACU,MAAM,CAAE;IAACT,YAAY,EAAEA;EAAa,GACpET,KAAA,CAAA8B,aAAA,CAACxB,iBAAiB;IAChByB,GAAG,EAAEhB,YAAa;IAClBiB,OAAO,EAAE;MAAEN,YAAY;MAAEG;IAAW;EAAE,GAEtC7B,KAAA,CAAA8B,aAAA,CAAC3B,cAAc;IAACoB,MAAM,EAAEA;EAAO,GAC5BH,YAAY,GACXpB,KAAA,CAAA8B,aAAA;IAAKG,SAAS,EAAC;EAAmG,GAChHjC,KAAA,CAAA8B,aAAA,CAACzB,UAAU,MAAE,CACV,CAAC,GAGJL,KAAA,CAAA8B,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,6 +1,7 @@
|
|
|
1
|
-
import React, { useEffect, useState
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { useQuery } from '@apollo/client';
|
|
3
|
-
import
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { ChartError, Tooltip, useLiveRatesQuery } from '@oanda/labs-widget-common';
|
|
4
5
|
import { getRecords } from './utils';
|
|
5
6
|
import { INSTRUMENT_TOOLTIP_ID } from './constant';
|
|
6
7
|
import { validateInstruments } from '../gql/validateInstruments';
|
|
@@ -11,10 +12,6 @@ const Main = _ref => {
|
|
|
11
12
|
division,
|
|
12
13
|
size: widgetSize = 'fullWithChart'
|
|
13
14
|
} = _ref;
|
|
14
|
-
const {
|
|
15
|
-
size
|
|
16
|
-
} = useContext(ThemeContext);
|
|
17
|
-
const isDesktop = size === Size.DESKTOP;
|
|
18
15
|
const {
|
|
19
16
|
target,
|
|
20
17
|
setQuery
|
|
@@ -48,11 +45,14 @@ const Main = _ref => {
|
|
|
48
45
|
instruments: instrumentsNames
|
|
49
46
|
});
|
|
50
47
|
}
|
|
51
|
-
}, [records
|
|
48
|
+
}, [records]);
|
|
52
49
|
const showError = !!error;
|
|
53
50
|
return React.createElement(React.Fragment, null, records.length > 0 && React.createElement("div", {
|
|
54
51
|
"data-testid": "instrument-live-rate-wrapper",
|
|
55
|
-
className:
|
|
52
|
+
className: classnames('lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary', {
|
|
53
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
54
|
+
'lw-h-[54px]': widgetSize === 'compact'
|
|
55
|
+
})
|
|
56
56
|
}, React.createElement(InstrumentRateWithChart, {
|
|
57
57
|
loading: loading,
|
|
58
58
|
record: records[0],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["React","useEffect","useState","
|
|
1
|
+
{"version":3,"file":"Main.js","names":["React","useEffect","useState","useQuery","classnames","ChartError","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","length","className","record","id"],"sources":["../../../src/InstrumentLiveRateWidget/Main.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { useQuery } from '@apollo/client';\nimport classnames from 'classnames';\nimport {\n ChartError,\n DataRecord,\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 { 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 {records.length > 0 && (\n <div\n data-testid=\"instrument-live-rate-wrapper\"\n className={classnames('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 '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=\"lw-flex lw-h-[150px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,UAAU,MAAM,YAAY;AACnC,SACEC,UAAU,EAEVC,OAAO,EACPC,iBAAiB,QACZ,2BAA2B;AAClC,SAASC,UAAU,QAAQ,SAAS;AAEpC,SA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GAAG,CAAC,IACjBnC,KAAA,CAAAiC,aAAA;IACE,eAAY,8BAA8B;IAC1CG,SAAS,EAAEhC,UAAU,CAAC,uHAAuH,EAAE;MAC7I,aAAa,EAAEa,UAAU,KAAK,SAAS;MACvC,aAAa,EAAEA,UAAU,KAAK;IAChC,CAAC;EAAE,GAEHjB,KAAA,CAAAiC,aAAA,CAACtB,uBAAuB;IACtBW,OAAO,EAAEA,OAAQ;IACjBe,MAAM,EAAEjB,OAAO,CAAC,CAAC,CAAE;IACnBF,MAAM,EAAEA,MAAO;IACfH,QAAQ,EAAEA,QAAS;IACnBC,IAAI,EAAEC;EAAW,CAClB,CAAC,EACFjB,KAAA,CAAAiC,aAAA,CAAC3B,OAAO;IAACgC,EAAE,EAAE7B;EAAsB,CAAE,CAClC,CACN,EACA,CAACa,OAAO,IAAIU,SAAS,IACpBhC,KAAA,CAAAiC,aAAA;IAAKG,SAAS,EAAC;EAAmG,GAChHpC,KAAA,CAAAiC,aAAA,CAAC5B,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAED,SAASO,IAAI","ignoreList":[]}
|
package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js
CHANGED
|
@@ -4,9 +4,7 @@ import { LineChart } from '@oanda/labs-widget-common';
|
|
|
4
4
|
import { getInstrumentsChart } from '../../../gql/getInstrumentsChart';
|
|
5
5
|
const LineChartWithData = _ref => {
|
|
6
6
|
let {
|
|
7
|
-
padding,
|
|
8
7
|
record,
|
|
9
|
-
size,
|
|
10
8
|
isLoading,
|
|
11
9
|
division,
|
|
12
10
|
color
|
|
@@ -27,10 +25,8 @@ const LineChartWithData = _ref => {
|
|
|
27
25
|
return React.createElement("div", {
|
|
28
26
|
className: "lw-relative"
|
|
29
27
|
}, !showChart ? React.createElement("div", {
|
|
30
|
-
className: "lw-absolute lw-bottom-0 lw-right-0"
|
|
28
|
+
className: "lw-absolute lw-bottom-0 lw-right-0 lw--z-50 lw-flex lw-h-10 lw-w-[100px] lw-items-center lw-justify-center"
|
|
31
29
|
}, React.createElement(LineChart, {
|
|
32
|
-
padding: padding,
|
|
33
|
-
size: size,
|
|
34
30
|
color: color,
|
|
35
31
|
data: chart
|
|
36
32
|
})) : null);
|
package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChartWithData.js","names":["React","useQuery","LineChart","getInstrumentsChart","LineChartWithData","_ref","
|
|
1
|
+
{"version":3,"file":"LineChartWithData.js","names":["React","useQuery","LineChart","getInstrumentsChart","LineChartWithData","_ref","record","isLoading","division","color","loading","data","variables","instruments","instrument","fetchPolicy","skip","showChart","chart","topicalInstrumentsCharts","createElement","className"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx"],"sourcesContent":["import React from 'react';\nimport { useQuery } from '@apollo/client';\nimport { LineChart } from '@oanda/labs-widget-common';\nimport { LineChartWithDataProps } from './types';\nimport { getInstrumentsChart } from '../../../gql/getInstrumentsChart';\nimport { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../../../gql/types/graphql';\n\nconst LineChartWithData = ({\n record,\n isLoading,\n division,\n color,\n}: LineChartWithDataProps) => {\n const { loading, data } = useQuery<\n GetInstrumentsChartQuery,\n GetInstrumentsChartQueryVariables\n >(getInstrumentsChart, {\n variables: {\n instruments: [record.instrument],\n division,\n },\n fetchPolicy: 'network-only',\n skip: !record.instrument,\n });\n\n const showChart = isLoading || loading;\n const chart = data?.topicalInstrumentsCharts?.[0].chart || [];\n\n return (\n <div className=\"lw-relative\">\n {!showChart ? (\n <div className=\"lw-absolute lw-bottom-0 lw-right-0 lw--z-50 lw-flex lw-h-10 lw-w-[100px] lw-items-center lw-justify-center\">\n <LineChart\n color={color}\n data={chart}\n />\n </div>\n ) : null}\n </div>\n );\n};\n\nexport { LineChartWithData };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,SAAS,QAAQ,2BAA2B;AAErD,SAASC,mBAAmB,QAAQ,kCAAkC;AAGtE,MAAMC,iBAAiB,GAAGC,IAAA,IAKI;EAAA,IALH;IACzBC,MAAM;IACNC,SAAS;IACTC,QAAQ;IACRC;EACsB,CAAC,GAAAJ,IAAA;EACvB,MAAM;IAAEK,OAAO;IAAEC;EAAK,CAAC,GAAGV,QAAQ,CAGhCE,mBAAmB,EAAE;IACrBS,SAAS,EAAE;MACTC,WAAW,EAAE,CAACP,MAAM,CAACQ,UAAU,CAAC;MAChCN;IACF,CAAC;IACDO,WAAW,EAAE,cAAc;IAC3BC,IAAI,EAAE,CAACV,MAAM,CAACQ;EAChB,CAAC,CAAC;EAEF,MAAMG,SAAS,GAAGV,SAAS,IAAIG,OAAO;EACtC,MAAMQ,KAAK,GAAGP,IAAI,EAAEQ,wBAAwB,GAAG,CAAC,CAAC,CAACD,KAAK,IAAI,EAAE;EAE7D,OACElB,KAAA,CAAAoB,aAAA;IAAKC,SAAS,EAAC;EAAa,GACzB,CAACJ,SAAS,GACTjB,KAAA,CAAAoB,aAAA;IAAKC,SAAS,EAAC;EAA4G,GACzHrB,KAAA,CAAAoB,aAAA,CAAClB,SAAS;IACRO,KAAK,EAAEA,KAAM;IACbE,IAAI,EAAEO;EAAM,CACb,CACE,CAAC,GACJ,IACD,CAAC;AAEV,CAAC;AAED,SAASd,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { DataRecord
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { DataRecord } from '@oanda/labs-widget-common';\nimport { Division } from '../../../gql/types/graphql';\n\nexport interface LineChartWithDataProps {\n record: DataRecord;\n isLoading: boolean;\n division: Division;\n color: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -21,6 +21,7 @@ instrumentLiveRateElements.forEach(element => {
|
|
|
21
21
|
const isParamError = validateToolParams({
|
|
22
22
|
division,
|
|
23
23
|
locale,
|
|
24
|
+
instrument,
|
|
24
25
|
graphqlUrl,
|
|
25
26
|
liveRatesUrl
|
|
26
27
|
}, [{
|
|
@@ -29,6 +30,9 @@ instrumentLiveRateElements.forEach(element => {
|
|
|
29
30
|
}, {
|
|
30
31
|
name: 'division',
|
|
31
32
|
valueCheck: value => Object.values(Division).includes(value)
|
|
33
|
+
}, {
|
|
34
|
+
name: 'instrument',
|
|
35
|
+
valueCheck: value => value.length > 0
|
|
32
36
|
}, {
|
|
33
37
|
name: 'graphqlUrl'
|
|
34
38
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["React","createRoot","validateLocale","validateToolParams","InstrumentLiveRateWidget","Division","graphqlUrl","liveRatesUrl","window","widgetsConfig","instrumentLiveRateElements","document","querySelectorAll","forEach","element","root","params","getAttribute","mode","instrument","division","locale","size","JSON","parse","isParamError","name","valueCheck","value","Object","values","includes","render","createElement","theme"],"sources":["../../../src/InstrumentLiveRateWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport { InstrumentLiveRateWidget } from './InstrumentLiveRateWidget';\nimport { Division } from '../gql/types/graphql';\n\nconst {\n graphqlUrl,\n liveRatesUrl,\n} = window.widgetsConfig || {};\n\nconst instrumentLiveRateElements = document.querySelectorAll('div[data-instrument-live-rate-params]');\n\ninstrumentLiveRateElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-instrument-live-rate-params');\n const mode = element.getAttribute('data-mode');\n const {\n instrument, division, locale, size,\n } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({\n division, locale, graphqlUrl, liveRatesUrl,\n }, [{\n name: 'locale',\n valueCheck: (value) => validateLocale(value),\n }, {\n name: 'division',\n valueCheck: (value) => Object.values(Division).includes(value),\n }, {\n name: 'graphqlUrl',\n }, {\n name: 'liveRatesUrl',\n }]);\n\n root.render(\n <InstrumentLiveRateWidget\n graphqlUrl={graphqlUrl}\n liveRatesUrl={liveRatesUrl}\n division={division}\n instrument={instrument}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n size={size}\n />,\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAAgBC,cAAc,EAAEC,kBAAkB,QAAQ,2BAA2B;AACrF,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,QAAQ,QAAQ,sBAAsB;AAE/C,MAAM;EACJC,UAAU;EACVC;AACF,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE9B,MAAMC,0BAA0B,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,uCAAuC,CAAC;AAErGF,0BAA0B,CAACG,OAAO,CAAEC,OAAO,IAAK;EAC9C,MAAMC,IAAI,GAAGd,UAAU,CAACa,OAAO,CAAC;EAChC,MAAME,MAAM,GAAGF,OAAO,CAACG,YAAY,CAAC,kCAAkC,CAAC;EACvE,MAAMC,IAAI,GAAGJ,OAAO,CAACG,YAAY,CAAC,WAAW,CAAC;EAC9C,MAAM;IACJE,UAAU;IAAEC,QAAQ;IAAEC,MAAM;IAAEC;EAChC,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACR,MAAgB,CAAC;EAEhC,MAAMS,YAAY,GAAGtB,kBAAkB,CAAC;IACtCiB,QAAQ;IAAEC,MAAM;
|
|
1
|
+
{"version":3,"file":"render.js","names":["React","createRoot","validateLocale","validateToolParams","InstrumentLiveRateWidget","Division","graphqlUrl","liveRatesUrl","window","widgetsConfig","instrumentLiveRateElements","document","querySelectorAll","forEach","element","root","params","getAttribute","mode","instrument","division","locale","size","JSON","parse","isParamError","name","valueCheck","value","Object","values","includes","length","render","createElement","theme"],"sources":["../../../src/InstrumentLiveRateWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport { InstrumentLiveRateWidget } from './InstrumentLiveRateWidget';\nimport { Division } from '../gql/types/graphql';\n\nconst {\n graphqlUrl,\n liveRatesUrl,\n} = window.widgetsConfig || {};\n\nconst instrumentLiveRateElements = document.querySelectorAll('div[data-instrument-live-rate-params]');\n\ninstrumentLiveRateElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-instrument-live-rate-params');\n const mode = element.getAttribute('data-mode');\n const {\n instrument, division, locale, size,\n } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({\n division, locale, instrument, graphqlUrl, liveRatesUrl,\n }, [{\n name: 'locale',\n valueCheck: (value) => validateLocale(value),\n }, {\n name: 'division',\n valueCheck: (value) => Object.values(Division).includes(value),\n }, {\n name: 'instrument',\n valueCheck: (value) => (value as string).length > 0,\n }, {\n name: 'graphqlUrl',\n }, {\n name: 'liveRatesUrl',\n }]);\n\n root.render(\n <InstrumentLiveRateWidget\n graphqlUrl={graphqlUrl}\n liveRatesUrl={liveRatesUrl}\n division={division}\n instrument={instrument}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n size={size}\n />,\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAAgBC,cAAc,EAAEC,kBAAkB,QAAQ,2BAA2B;AACrF,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,QAAQ,QAAQ,sBAAsB;AAE/C,MAAM;EACJC,UAAU;EACVC;AACF,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE9B,MAAMC,0BAA0B,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,uCAA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[]}
|
package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { LineChartWithDataProps } from './types';
|
|
3
|
-
declare const LineChartWithData: ({
|
|
3
|
+
declare const LineChartWithData: ({ record, isLoading, division, color, }: LineChartWithDataProps) => React.JSX.Element;
|
|
4
4
|
export { LineChartWithData };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { DataRecord
|
|
1
|
+
import { DataRecord } from '@oanda/labs-widget-common';
|
|
2
2
|
import { Division } from '../../../gql/types/graphql';
|
|
3
3
|
export interface LineChartWithDataProps {
|
|
4
|
-
padding?: number;
|
|
5
4
|
record: DataRecord;
|
|
6
|
-
size?: LineChartSize;
|
|
7
5
|
isLoading: boolean;
|
|
8
6
|
division: Division;
|
|
9
7
|
color: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oanda/labs-instrument-live-rate-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
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.143",
|
|
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": "1e9ffb3c3da25339612feb41bbf8d129ed97369a"
|
|
25
25
|
}
|
|
@@ -36,7 +36,7 @@ const InstrumentLiveRateWidget = ({
|
|
|
36
36
|
>
|
|
37
37
|
<ApolloProvider client={client}>
|
|
38
38
|
{isParamError ? (
|
|
39
|
-
<div className="lw-flex lw-h-[
|
|
39
|
+
<div className="lw-flex lw-h-[150px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
|
|
40
40
|
<ChartError />
|
|
41
41
|
</div>
|
|
42
42
|
)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React, { useEffect, useState
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { useQuery } from '@apollo/client';
|
|
3
|
+
import classnames from 'classnames';
|
|
3
4
|
import {
|
|
4
5
|
ChartError,
|
|
5
6
|
DataRecord,
|
|
6
|
-
Size,
|
|
7
|
-
ThemeContext,
|
|
8
7
|
Tooltip,
|
|
9
8
|
useLiveRatesQuery,
|
|
10
9
|
} from '@oanda/labs-widget-common';
|
|
@@ -20,8 +19,6 @@ const Main = ({
|
|
|
20
19
|
division,
|
|
21
20
|
size: widgetSize = 'fullWithChart',
|
|
22
21
|
}: MainProps) => {
|
|
23
|
-
const { size } = useContext(ThemeContext);
|
|
24
|
-
const isDesktop = size === Size.DESKTOP;
|
|
25
22
|
const { target, setQuery } = useLiveRatesQuery();
|
|
26
23
|
const [records, setRecords] = useState<DataRecord[]>([]);
|
|
27
24
|
|
|
@@ -50,7 +47,7 @@ const Main = ({
|
|
|
50
47
|
setQuery({ instruments: instrumentsNames });
|
|
51
48
|
}
|
|
52
49
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
-
}, [records
|
|
50
|
+
}, [records]);
|
|
54
51
|
|
|
55
52
|
const showError = !!error;
|
|
56
53
|
|
|
@@ -59,7 +56,10 @@ const Main = ({
|
|
|
59
56
|
{records.length > 0 && (
|
|
60
57
|
<div
|
|
61
58
|
data-testid="instrument-live-rate-wrapper"
|
|
62
|
-
className=
|
|
59
|
+
className={classnames('lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary', {
|
|
60
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
61
|
+
'lw-h-[54px]': widgetSize === 'compact',
|
|
62
|
+
})}
|
|
63
63
|
>
|
|
64
64
|
<InstrumentRateWithChart
|
|
65
65
|
loading={loading}
|
|
@@ -6,9 +6,7 @@ import { getInstrumentsChart } from '../../../gql/getInstrumentsChart';
|
|
|
6
6
|
import { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../../../gql/types/graphql';
|
|
7
7
|
|
|
8
8
|
const LineChartWithData = ({
|
|
9
|
-
padding,
|
|
10
9
|
record,
|
|
11
|
-
size,
|
|
12
10
|
isLoading,
|
|
13
11
|
division,
|
|
14
12
|
color,
|
|
@@ -31,10 +29,8 @@ const LineChartWithData = ({
|
|
|
31
29
|
return (
|
|
32
30
|
<div className="lw-relative">
|
|
33
31
|
{!showChart ? (
|
|
34
|
-
<div className="lw-absolute lw-bottom-0 lw-right-0">
|
|
32
|
+
<div className="lw-absolute lw-bottom-0 lw-right-0 lw--z-50 lw-flex lw-h-10 lw-w-[100px] lw-items-center lw-justify-center">
|
|
35
33
|
<LineChart
|
|
36
|
-
padding={padding}
|
|
37
|
-
size={size}
|
|
38
34
|
color={color}
|
|
39
35
|
data={chart}
|
|
40
36
|
/>
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { DataRecord
|
|
1
|
+
import { DataRecord } from '@oanda/labs-widget-common';
|
|
2
2
|
import { Division } from '../../../gql/types/graphql';
|
|
3
3
|
|
|
4
4
|
export interface LineChartWithDataProps {
|
|
5
|
-
padding?: number;
|
|
6
5
|
record: DataRecord;
|
|
7
|
-
size?: LineChartSize;
|
|
8
6
|
isLoading: boolean;
|
|
9
7
|
division: Division;
|
|
10
8
|
color: string;
|
|
@@ -20,13 +20,16 @@ instrumentLiveRateElements.forEach((element) => {
|
|
|
20
20
|
} = JSON.parse(params as string);
|
|
21
21
|
|
|
22
22
|
const isParamError = validateToolParams({
|
|
23
|
-
division, locale, graphqlUrl, liveRatesUrl,
|
|
23
|
+
division, locale, instrument, graphqlUrl, liveRatesUrl,
|
|
24
24
|
}, [{
|
|
25
25
|
name: 'locale',
|
|
26
26
|
valueCheck: (value) => validateLocale(value),
|
|
27
27
|
}, {
|
|
28
28
|
name: 'division',
|
|
29
29
|
valueCheck: (value) => Object.values(Division).includes(value),
|
|
30
|
+
}, {
|
|
31
|
+
name: 'instrument',
|
|
32
|
+
valueCheck: (value) => (value as string).length > 0,
|
|
30
33
|
}, {
|
|
31
34
|
name: 'graphqlUrl',
|
|
32
35
|
}, {
|