@oanda/labs-instrument-live-rate-widget 1.0.1 → 1.0.3
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 +28 -0
- package/dist/main/InstrumentLiveRateWidget/Main.js +4 -4
- package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +46 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/index.js +4 -4
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js +6 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +7 -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/components/index.js +11 -0
- package/dist/main/InstrumentLiveRateWidget/components/index.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/types.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/utils.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/Main.js +4 -4
- package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +38 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js +3 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js +2 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +8 -6
- 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/components/index.js +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/index.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/types.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/utils.js.map +1 -1
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.d.ts +2 -0
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.d.ts +9 -0
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/types.d.ts +1 -2
- package/dist/types/InstrumentLiveRateWidget/components/index.d.ts +1 -0
- package/dist/types/InstrumentLiveRateWidget/types.d.ts +0 -22
- package/dist/types/InstrumentLiveRateWidget/utils.d.ts +2 -3
- package/package.json +3 -3
- package/src/InstrumentLiveRateWidget/Main.tsx +6 -5
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx +43 -0
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.ts +2 -0
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.ts +10 -0
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx +14 -15
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx +1 -2
- package/src/InstrumentLiveRateWidget/components/index.ts +1 -0
- package/src/InstrumentLiveRateWidget/types.tsx +0 -26
- package/src/InstrumentLiveRateWidget/utils.ts +2 -3
- package/test/components/{InstrumentRateWithData.test.tsx → InstrumentRateWithChart.test.tsx} +7 -7
- package/test/components/utils.test.ts +1 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +0 -83
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +0 -74
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js +0 -3
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +0 -1
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.d.ts +0 -4
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.d.ts +0 -2
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.tsx +0 -92
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.ts +0 -2
- /package/dist/main/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.js +0 -0
- /package/dist/module/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.js +0 -0
- /package/dist/types/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.d.ts +0 -0
- /package/src/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
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.3 (2024-07-16)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 1.0.141 (2024-07-16)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 1.0.140 (2024-07-12)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @oanda/labs-instrument-live-rate-widget
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 1.0.2 (2024-07-16)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## 1.0.140 (2024-07-12)
|
|
27
|
+
|
|
28
|
+
**Note:** Version bump only for package @oanda/labs-instrument-live-rate-widget
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
## 1.0.1 (2024-07-12)
|
|
7
35
|
|
|
8
36
|
**Note:** Version bump only for package @oanda/labs-instrument-live-rate-widget
|
|
@@ -10,14 +10,14 @@ var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
|
10
10
|
var _utils = require("./utils");
|
|
11
11
|
var _constant = require("./constant");
|
|
12
12
|
var _validateInstruments = require("../gql/validateInstruments");
|
|
13
|
-
var
|
|
13
|
+
var _InstrumentRateWithChart = require("./components/InstrumentRateWithChart");
|
|
14
14
|
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
15
|
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
16
|
const Main = _ref => {
|
|
17
17
|
let {
|
|
18
18
|
instrument,
|
|
19
19
|
division,
|
|
20
|
-
size: widgetSize
|
|
20
|
+
size: widgetSize = 'fullWithChart'
|
|
21
21
|
} = _ref;
|
|
22
22
|
const {
|
|
23
23
|
size
|
|
@@ -60,8 +60,8 @@ const Main = _ref => {
|
|
|
60
60
|
const showError = !!error;
|
|
61
61
|
return _react.default.createElement(_react.default.Fragment, null, records.length > 0 && _react.default.createElement("div", {
|
|
62
62
|
"data-testid": "instrument-live-rate-wrapper",
|
|
63
|
-
className: "lw-
|
|
64
|
-
}, _react.default.createElement(
|
|
63
|
+
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"
|
|
64
|
+
}, _react.default.createElement(_InstrumentRateWithChart.InstrumentRateWithChart, {
|
|
65
65
|
loading: loading,
|
|
66
66
|
record: records[0],
|
|
67
67
|
target: target,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_utils","_constant","_validateInstruments","
|
|
1
|
+
{"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_utils","_constant","_validateInstruments","_InstrumentRateWithChart","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","instrument","division","size","widgetSize","useContext","ThemeContext","isDesktop","Size","DESKTOP","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","InstrumentRateWithChart","record","Tooltip","id","INSTRUMENT_TOOLTIP_ID","ChartError","exports"],"sources":["../../../src/InstrumentLiveRateWidget/Main.tsx"],"sourcesContent":["import React, { useEffect, useState, useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError,\n DataRecord,\n Size,\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 isDesktop = size === Size.DESKTOP;\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, isDesktop]);\n\n const showError = !!error;\n\n return (\n <>\n {records.length > 0 && (\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 <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,iBAAA,GAAAF,OAAA;AAQA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AAEA,IAAAM,wBAAA,GAAAN,OAAA;AAA+E,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,G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
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InstrumentRateWithChart = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
var _constant = require("../../constant");
|
|
11
|
+
var _LineChartWithData = require("../LineChartWithData");
|
|
12
|
+
var _utils2 = require("../../utils");
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
const InstrumentRateWithChart = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
loading,
|
|
18
|
+
record,
|
|
19
|
+
target,
|
|
20
|
+
division,
|
|
21
|
+
size
|
|
22
|
+
} = _ref;
|
|
23
|
+
const {
|
|
24
|
+
isDark
|
|
25
|
+
} = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
|
|
26
|
+
const {
|
|
27
|
+
updatedRecord,
|
|
28
|
+
error
|
|
29
|
+
} = (0, _utils2.useRecords)(record, record.instrument ? target : null);
|
|
30
|
+
const indicator = (0, _utils.getColorIndicator)(updatedRecord.dailyPercentChange);
|
|
31
|
+
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_labsWidgetCommon.InstrumentRate, {
|
|
32
|
+
isLoading: loading,
|
|
33
|
+
isError: !!error,
|
|
34
|
+
record: updatedRecord,
|
|
35
|
+
size: size,
|
|
36
|
+
tooltipId: _constant.INSTRUMENT_TOOLTIP_ID,
|
|
37
|
+
colorIndicator: indicator
|
|
38
|
+
}), size === 'fullWithChart' && _react.default.createElement(_LineChartWithData.LineChartWithData, {
|
|
39
|
+
record: record,
|
|
40
|
+
isLoading: loading,
|
|
41
|
+
division: division,
|
|
42
|
+
color: (0, _utils.getChartColor)(indicator, isDark)
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
exports.InstrumentRateWithChart = InstrumentRateWithChart;
|
|
46
|
+
//# sourceMappingURL=InstrumentRateWithChart.js.map
|
|
@@ -0,0 +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.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,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC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Ac,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":[]}
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
Object.keys(
|
|
6
|
+
var _InstrumentRateWithChart = require("./InstrumentRateWithChart");
|
|
7
|
+
Object.keys(_InstrumentRateWithChart).forEach(function (key) {
|
|
8
8
|
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] ===
|
|
9
|
+
if (key in exports && exports[key] === _InstrumentRateWithChart[key]) return;
|
|
10
10
|
Object.defineProperty(exports, key, {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function () {
|
|
13
|
-
return
|
|
13
|
+
return _InstrumentRateWithChart[key];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["_InstrumentRateWithChart","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_utils"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.ts"],"sourcesContent":["export * from './InstrumentRateWithChart';\nexport * from './utils';\n"],"mappings":";;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,wBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,wBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,wBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.ts"],"sourcesContent":["import { DataRecord } from '@oanda/labs-widget-common';\nimport { Division } from '../../types';\n\nexport interface InstrumentRateWithChartProps {\n loading: boolean;\n record: DataRecord;\n target: EventTarget | null;\n division: Division;\n size?: 'compact' | 'full' | 'fullWithChart'\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_labsWidgetCommon","require","getColorIndicator","dailyChange","numberValue","Number","substring","length","Math","sign","exports","getChartColor","indicator","isDarkMode","theme","darkTheme","lightTheme","textOk","textDanger","textDisabled"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.ts"],"sourcesContent":["import { lightTheme, darkTheme } from '@oanda/labs-widget-common';\n\nconst getColorIndicator = (dailyChange?: string) => {\n const numberValue = Number(dailyChange?.substring(0, dailyChange.length - 1));\n\n return Math.sign(numberValue);\n};\n\nconst getChartColor = (indicator?: number, isDarkMode?: boolean) => {\n const theme = isDarkMode ? darkTheme : lightTheme;\n\n switch (indicator) {\n case 1:\n return theme.textOk;\n case -1:\n return theme.textDanger;\n default:\n return theme.textDisabled;\n }\n};\n\nexport {\n getColorIndicator,\n getChartColor,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,MAAMC,iBAAiB,GAAIC,WAAoB,IAAK;EAClD,MAAMC,WAAW,GAAGC,MAAM,CAACF,WAAW,EAAEG,SAAS,CAAC,CAAC,EAAEH,WAAW,CAACI,MAAM,GAAG,CAAC,CAAC,CAAC;EAE7E,OAAOC,IAAI,CAACC,IAAI,CAACL,WAAW,CAAC;AAC/B,CAAC;AAACM,OAAA,CAAAR,iBAAA,GAAAA,iBAAA;AAEF,MAAMS,aAAa,GAAGA,CAACC,SAAkB,EAAEC,UAAoB,KAAK;EAClE,MAAMC,KAAK,GAAGD,UAAU,GAAGE,2BAAS,GAAGC,4BAAU;EAEjD,QAAQJ,SAAS;IACf,KAAK,CAAC;MACJ,OAAOE,KAAK,CAACG,MAAM;IACrB,KAAK,CAAC,CAAC;MACL,OAAOH,KAAK,CAACI,UAAU;IACzB;MACE,OAAOJ,KAAK,CAACK,YAAY;EAC7B;AACF,CAAC;AAACT,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js
CHANGED
|
@@ -29,16 +29,18 @@ const LineChartWithData = _ref => {
|
|
|
29
29
|
fetchPolicy: 'network-only',
|
|
30
30
|
skip: !record.instrument
|
|
31
31
|
});
|
|
32
|
-
const
|
|
32
|
+
const showChart = isLoading || loading;
|
|
33
33
|
const chart = data?.topicalInstrumentsCharts?.[0].chart || [];
|
|
34
|
-
return _react.default.createElement(
|
|
35
|
-
|
|
36
|
-
}
|
|
34
|
+
return _react.default.createElement("div", {
|
|
35
|
+
className: "lw-relative"
|
|
36
|
+
}, !showChart ? _react.default.createElement("div", {
|
|
37
|
+
className: "lw-absolute lw-bottom-0 lw-right-0"
|
|
38
|
+
}, _react.default.createElement(_labsWidgetCommon.LineChart, {
|
|
37
39
|
padding: padding,
|
|
38
40
|
size: size,
|
|
39
41
|
color: color,
|
|
40
42
|
data: chart
|
|
41
|
-
}));
|
|
43
|
+
})) : null);
|
|
42
44
|
};
|
|
43
45
|
exports.LineChartWithData = LineChartWithData;
|
|
44
46
|
//# sourceMappingURL=LineChartWithData.js.map
|
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","padding","record","size","isLoading","division","color","loading","data","useQuery","getInstrumentsChart","variables","instruments","instrument","fetchPolicy","skip","
|
|
1
|
+
{"version":3,"file":"LineChartWithData.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_getInstrumentsChart","e","__esModule","default","LineChartWithData","_ref","padding","record","size","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 padding,\n record,\n size,\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\">\n <LineChart\n padding={padding}\n size={size}\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,IAOI;EAAA,IAPH;IACzBC,OAAO;IACPC,MAAM;IACNC,IAAI;IACJC,SAAS;IACTC,QAAQ;IACRC;EACsB,CAAC,GAAAN,IAAA;EACvB,MAAM;IAAEO,OAAO;IAAEC;EAAK,CAAC,GAAG,IAAAC,gBAAQ,EAGhCC,wCAAmB,EAAE;IACrBC,SAAS,EAAE;MACTC,WAAW,EAAE,CAACV,MAAM,CAACW,UAAU,CAAC;MAChCR;IACF,CAAC;IACDS,WAAW,EAAE,cAAc;IAC3BC,IAAI,EAAE,CAACb,MAAM,CAACW;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,OACE3B,MAAA,CAAAQ,OAAA,CAAAqB,aAAA;IAAKC,SAAS,EAAC;EAAa,GACzB,CAACJ,SAAS,GACT1B,MAAA,CAAAQ,OAAA,CAAAqB,aAAA;IAAKC,SAAS,EAAC;EAAoC,GACjD9B,MAAA,CAAAQ,OAAA,CAAAqB,aAAA,CAACzB,iBAAA,CAAA2B,SAAS;IACRpB,OAAO,EAAEA,OAAQ;IACjBE,IAAI,EAAEA,IAAK;IACXG,KAAK,EAAEA,KAAM;IACbE,IAAI,EAAES;EAAM,CACb,CACE,CAAC,GACJ,IACD,CAAC;AAEV,CAAC;AAACK,OAAA,CAAAvB,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { LineChartSize } from '@oanda/labs-widget-common';\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { DataRecord, LineChartSize } from '@oanda/labs-widget-common';\nimport { Division } from '../../../gql/types/graphql';\n\nexport interface LineChartWithDataProps {\n padding?: number;\n record: DataRecord;\n size?: LineChartSize;\n isLoading: boolean;\n division: Division;\n color: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _InstrumentRateWithChart = require("./InstrumentRateWithChart");
|
|
7
|
+
Object.keys(_InstrumentRateWithChart).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _InstrumentRateWithChart[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _InstrumentRateWithChart[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
6
17
|
var _LineChartWithData = require("./LineChartWithData");
|
|
7
18
|
Object.keys(_LineChartWithData).forEach(function (key) {
|
|
8
19
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["_InstrumentRateWithChart","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_LineChartWithData"],"sources":["../../../../src/InstrumentLiveRateWidget/components/index.ts"],"sourcesContent":["export * from './InstrumentRateWithChart';\nexport * from './LineChartWithData';\n"],"mappings":";;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,wBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,wBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,wBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,kBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,kBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,kBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,kBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["_monoI18n","require","_graphql"],"sources":["../../../src/InstrumentLiveRateWidget/types.tsx"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { Division } from '../gql/types/graphql';\n\nexport { Locale } from '@oanda/mono-i18n';\nexport { Division } from '../gql/types/graphql';\n\nexport interface InstrumentLiveRateConfig {\n graphqlUrl: string;\n division: Division;\n liveRatesUrl: string;\n instrument: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n removePadding?: boolean;\n size?: 'compact' | 'full' | 'fullWithChart';\n}\n\nexport interface MainProps {\n instrument: string;\n division: Division;\n size?: 'compact' | 'full' | 'fullWithChart'\n}\n
|
|
1
|
+
{"version":3,"file":"types.js","names":["_monoI18n","require","_graphql"],"sources":["../../../src/InstrumentLiveRateWidget/types.tsx"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { Division } from '../gql/types/graphql';\n\nexport { Locale } from '@oanda/mono-i18n';\nexport { Division } from '../gql/types/graphql';\n\nexport interface InstrumentLiveRateConfig {\n graphqlUrl: string;\n division: Division;\n liveRatesUrl: string;\n instrument: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n removePadding?: boolean;\n size?: 'compact' | 'full' | 'fullWithChart';\n}\n\nexport interface MainProps {\n instrument: string;\n division: Division;\n size?: 'compact' | 'full' | 'fullWithChart'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_react","require","_labsWidgetCommon","getRecords","data","mapInstrumentNames","map","item","instrument","name","displayName","exports","useRecords","record","target","updatedRecord","setUpdatedRecord","useState","sentiment","error","setError","update","liveRatesError","useLiveRatesMessage","useEffect","buy","bid","buyPriceMovement","bidPriceMovement","dailyPercentChange","dailyPercentChangeFromOpen","dailyPipsChange","dailyPipsChangeFromOpen","displayPrecision"],"sources":["../../../src/InstrumentLiveRateWidget/utils.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { LiveRatesErrorMessage, useLiveRatesMessage } from '@oanda/labs-widget-common';\nimport {
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_react","require","_labsWidgetCommon","getRecords","data","mapInstrumentNames","map","item","instrument","name","displayName","exports","useRecords","record","target","updatedRecord","setUpdatedRecord","useState","sentiment","error","setError","update","liveRatesError","useLiveRatesMessage","useEffect","buy","bid","buyPriceMovement","bidPriceMovement","dailyPercentChange","dailyPercentChangeFromOpen","dailyPipsChange","dailyPipsChangeFromOpen","displayPrecision"],"sources":["../../../src/InstrumentLiveRateWidget/utils.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { DataRecord, LiveRatesErrorMessage, useLiveRatesMessage } from '@oanda/labs-widget-common';\nimport { ValidateInstrumentsQuery } from '../gql/types/graphql';\n\nconst getRecords = (data: ValidateInstrumentsQuery) => data?.mapInstrumentNames?.map((item) => ({\n instrument: item?.name || '',\n displayName: item?.displayName || '',\n}));\n\nconst useRecords = (\n record: DataRecord,\n target: EventTarget | null,\n) => {\n const [updatedRecord, setUpdatedRecord] = useState<DataRecord>({\n displayName: record.displayName,\n instrument: record.instrument,\n sentiment: record.sentiment,\n });\n const [error, setError] = useState<LiveRatesErrorMessage | null>(null);\n\n const { update, error: liveRatesError } = useLiveRatesMessage(\n record.instrument,\n target,\n );\n\n useEffect(() => {\n setUpdatedRecord({\n displayName: record.displayName,\n instrument: record.instrument,\n buy: update?.bid,\n buyPriceMovement: update?.bidPriceMovement,\n dailyPercentChange: update?.dailyPercentChangeFromOpen,\n dailyPipsChange: update?.dailyPipsChangeFromOpen,\n displayPrecision: update?.displayPrecision,\n });\n setError(liveRatesError);\n }, [update, record, liveRatesError]);\n\n return {\n updatedRecord,\n error,\n };\n};\n\nexport {\n getRecords,\n useRecords,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAGA,MAAME,UAAU,GAAIC,IAA8B,IAAKA,IAAI,EAAEC,kBAAkB,EAAEC,GAAG,CAAEC,IAAI,KAAM;EAC9FC,UAAU,EAAED,IAAI,EA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'@oan
|
|
|
4
4
|
import { getRecords } from './utils';
|
|
5
5
|
import { INSTRUMENT_TOOLTIP_ID } from './constant';
|
|
6
6
|
import { validateInstruments } from '../gql/validateInstruments';
|
|
7
|
-
import {
|
|
7
|
+
import { InstrumentRateWithChart } from './components/InstrumentRateWithChart';
|
|
8
8
|
const Main = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
instrument,
|
|
11
11
|
division,
|
|
12
|
-
size: widgetSize
|
|
12
|
+
size: widgetSize = 'fullWithChart'
|
|
13
13
|
} = _ref;
|
|
14
14
|
const {
|
|
15
15
|
size
|
|
@@ -52,8 +52,8 @@ const Main = _ref => {
|
|
|
52
52
|
const showError = !!error;
|
|
53
53
|
return React.createElement(React.Fragment, null, records.length > 0 && React.createElement("div", {
|
|
54
54
|
"data-testid": "instrument-live-rate-wrapper",
|
|
55
|
-
className: "lw-
|
|
56
|
-
}, React.createElement(
|
|
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
|
+
}, React.createElement(InstrumentRateWithChart, {
|
|
57
57
|
loading: loading,
|
|
58
58
|
record: records[0],
|
|
59
59
|
target: target,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["React","useEffect","useState","useContext","useQuery","ChartError","Size","ThemeContext","Tooltip","useLiveRatesQuery","getRecords","INSTRUMENT_TOOLTIP_ID","validateInstruments","
|
|
1
|
+
{"version":3,"file":"Main.js","names":["React","useEffect","useState","useContext","useQuery","ChartError","Size","ThemeContext","Tooltip","useLiveRatesQuery","getRecords","INSTRUMENT_TOOLTIP_ID","validateInstruments","InstrumentRateWithChart","Main","_ref","instrument","division","size","widgetSize","isDesktop","DESKTOP","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, useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError,\n DataRecord,\n Size,\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 isDesktop = size === Size.DESKTOP;\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, isDesktop]);\n\n const showError = !!error;\n\n return (\n <>\n {records.length > 0 && (\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 <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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AAG,CAACC,KAAA;IAAA,IAAC;MAAElB,UAAU,EAAEmB;IAAe,CAAC,GAAAD,KAAA;IAAA,OAAKC,cAAc;EAAA,EAAC;EAExFlC,SAAS,CAAC,MAAM;IACd,IAAI+B,gBAAgB,CAAC,CAAC,CAAC,EAAE;MACvBT,QAAQ,CAAC;QAAEO,WAAW,EAAEE;MAAiB,CAAC,CAAC;IAC7C;EAEF,CAAC,EAAE,CAACR,OAAO,EAAEJ,SAAS,CAAC,CAAC;EAExB,MAAMgB,SAAS,GAAG,CAAC,CAACR,KAAK;EAEzB,OACE5B,KAAA,CAAAqC,aAAA,CAAArC,KAAA,CAAAsC,QAAA,QACGd,OAAO,CAACe,MAAM,GAAG,CAAC,IACjBvC,KAAA,CAAAqC,aAAA;IACE,eAAY,8BAA8B;IAC1CG,SAAS,EAAC;EAAuH,GAEjIxC,KAAA,CAAAqC,aAAA,CAACxB,uBAAuB;IACtBa,OAAO,EAAEA,OAAQ;IACjBe,MAAM,EAAEjB,OAAO,CAAC,CAAC,CAAE;IACnBF,MAAM,EAAEA,MAAO;IACfL,QAAQ,EAAEA,QAAS;IACnBC,IAAI,EAAEC;EAAW,CAClB,CAAC,EACFnB,KAAA,CAAAqC,aAAA,CAAC7B,OAAO;IAACkC,EAAE,EAAE/B;EAAsB,CAAE,CAClC,CACN,EACA,CAACe,OAAO,IAAIU,SAAS,IACpBpC,KAAA,CAAAqC,aAAA;IAAKG,SAAS,EAAC;EAAmG,GAChHxC,KAAA,CAAAqC,aAAA,CAAChC,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAED,SAASS,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { InstrumentRate, ThemeContext } from '@oanda/labs-widget-common';
|
|
3
|
+
import { getChartColor, getColorIndicator } from './utils';
|
|
4
|
+
import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
|
|
5
|
+
import { LineChartWithData } from '../LineChartWithData';
|
|
6
|
+
import { useRecords } from '../../utils';
|
|
7
|
+
const InstrumentRateWithChart = _ref => {
|
|
8
|
+
let {
|
|
9
|
+
loading,
|
|
10
|
+
record,
|
|
11
|
+
target,
|
|
12
|
+
division,
|
|
13
|
+
size
|
|
14
|
+
} = _ref;
|
|
15
|
+
const {
|
|
16
|
+
isDark
|
|
17
|
+
} = useContext(ThemeContext);
|
|
18
|
+
const {
|
|
19
|
+
updatedRecord,
|
|
20
|
+
error
|
|
21
|
+
} = useRecords(record, record.instrument ? target : null);
|
|
22
|
+
const indicator = getColorIndicator(updatedRecord.dailyPercentChange);
|
|
23
|
+
return React.createElement(React.Fragment, null, React.createElement(InstrumentRate, {
|
|
24
|
+
isLoading: loading,
|
|
25
|
+
isError: !!error,
|
|
26
|
+
record: updatedRecord,
|
|
27
|
+
size: size,
|
|
28
|
+
tooltipId: INSTRUMENT_TOOLTIP_ID,
|
|
29
|
+
colorIndicator: indicator
|
|
30
|
+
}), size === 'fullWithChart' && React.createElement(LineChartWithData, {
|
|
31
|
+
record: record,
|
|
32
|
+
isLoading: loading,
|
|
33
|
+
division: division,
|
|
34
|
+
color: getChartColor(indicator, isDark)
|
|
35
|
+
}));
|
|
36
|
+
};
|
|
37
|
+
export { InstrumentRateWithChart };
|
|
38
|
+
//# sourceMappingURL=InstrumentRateWithChart.js.map
|
|
@@ -0,0 +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.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,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,cAAc,EAAEC,YAAY,QAAQ,2BAA2B;AAExE,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,SAAS;AAC1D,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,UAAU,QAAQ,aAAa;AAExC,MAAMC,uBAAuB,GAAGC,IAAA,IAMI;EAAA,IANH;IAC/BC,OAAO;IACPC,MAAM;IACNC,MAAM;IACNC,QAAQ;IACRC;EAC4B,CAAC,GAAAL,IAAA;EAC7B,MAAM;IAAEM;EAAO,CAAC,GAAGf,UAAU,CAACE,YAAY,CAAC;EAC3C,MAAM;IAAEc,aAAa;IAAEC;EAAM,CAAC,GAAGV,UAAU,CAACI,MAAM,EAAEA,MAAM,CAACO,UAAU,GAAGN,MAAM,GAAG,IAAI,CAAC;EAEtF,MAAMO,SAAS,GAAGf,iBAAiB,CAACY,aAAa,CAACI,kBAAkB,CAAC;EAErE,OACErB,KAAA,CAAAsB,aAAA,CAAAtB,KAAA,CAAAuB,QAAA,QACEvB,KAAA,CAAAsB,aAAA,CAACpB,cAAc;IACbsB,SAAS,EAAEb,OAAQ;IACnBc,OAAO,EAAE,CAAC,CAACP,KAAM;IACjBN,MAAM,EAAEK,aAAc;IACtBF,IAAI,EAAEA,IAAK;IACXW,SAAS,EAAEpB,qBAAsB;IACjCqB,cAAc,EAAEP;EAAU,CAC3B,CAAC,EACDL,IAAI,KAAK,eAAe,IACvBf,KAAA,CAAAsB,aAAA,CAACf,iBAAiB;IAChBK,MAAM,EAAEA,MAAO;IACfY,SAAS,EAAEb,OAAQ;IACnBG,QAAQ,EAAEA,QAAS;IACnBc,KAAK,EAAExB,aAAa,CAACgB,SAAS,EAAEJ,MAAM;EAAE,CACzC,CAEH,CAAC;AAEP,CAAC;AAED,SAASP,uBAAuB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.ts"],"sourcesContent":["export * from './InstrumentRateWithChart';\nexport * from './utils';\n"],"mappings":"AAAA,cAAc,2BAA2B;AACzC,cAAc,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.ts"],"sourcesContent":["import { DataRecord } from '@oanda/labs-widget-common';\nimport { Division } from '../../types';\n\nexport interface InstrumentRateWithChartProps {\n loading: boolean;\n record: DataRecord;\n target: EventTarget | null;\n division: Division;\n size?: 'compact' | 'full' | 'fullWithChart'\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["lightTheme","darkTheme","getColorIndicator","dailyChange","numberValue","Number","substring","length","Math","sign","getChartColor","indicator","isDarkMode","theme","textOk","textDanger","textDisabled"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.ts"],"sourcesContent":["import { lightTheme, darkTheme } from '@oanda/labs-widget-common';\n\nconst getColorIndicator = (dailyChange?: string) => {\n const numberValue = Number(dailyChange?.substring(0, dailyChange.length - 1));\n\n return Math.sign(numberValue);\n};\n\nconst getChartColor = (indicator?: number, isDarkMode?: boolean) => {\n const theme = isDarkMode ? darkTheme : lightTheme;\n\n switch (indicator) {\n case 1:\n return theme.textOk;\n case -1:\n return theme.textDanger;\n default:\n return theme.textDisabled;\n }\n};\n\nexport {\n getColorIndicator,\n getChartColor,\n};\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,SAAS,QAAQ,2BAA2B;AAEjE,MAAMC,iBAAiB,GAAIC,WAAoB,IAAK;EAClD,MAAMC,WAAW,GAAGC,MAAM,CAACF,WAAW,EAAEG,SAAS,CAAC,CAAC,EAAEH,WAAW,CAACI,MAAM,GAAG,CAAC,CAAC,CAAC;EAE7E,OAAOC,IAAI,CAACC,IAAI,CAACL,WAAW,CAAC;AAC/B,CAAC;AAED,MAAMM,aAAa,GAAGA,CAACC,SAAkB,EAAEC,UAAoB,KAAK;EAClE,MAAMC,KAAK,GAAGD,UAAU,GAAGX,SAAS,GAAGD,UAAU;EAEjD,QAAQW,SAAS;IACf,KAAK,CAAC;MACJ,OAAOE,KAAK,CAACC,MAAM;IACrB,KAAK,CAAC,CAAC;MACL,OAAOD,KAAK,CAACE,UAAU;IACzB;MACE,OAAOF,KAAK,CAACG,YAAY;EAC7B;AACF,CAAC;AAED,SACEd,iBAAiB,EACjBQ,aAAa","ignoreList":[]}
|
package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useQuery } from '@apollo/client';
|
|
3
|
-
import { LineChart
|
|
3
|
+
import { LineChart } from '@oanda/labs-widget-common';
|
|
4
4
|
import { getInstrumentsChart } from '../../../gql/getInstrumentsChart';
|
|
5
5
|
const LineChartWithData = _ref => {
|
|
6
6
|
let {
|
|
@@ -22,16 +22,18 @@ const LineChartWithData = _ref => {
|
|
|
22
22
|
fetchPolicy: 'network-only',
|
|
23
23
|
skip: !record.instrument
|
|
24
24
|
});
|
|
25
|
-
const
|
|
25
|
+
const showChart = isLoading || loading;
|
|
26
26
|
const chart = data?.topicalInstrumentsCharts?.[0].chart || [];
|
|
27
|
-
return React.createElement(
|
|
28
|
-
|
|
29
|
-
}
|
|
27
|
+
return React.createElement("div", {
|
|
28
|
+
className: "lw-relative"
|
|
29
|
+
}, !showChart ? React.createElement("div", {
|
|
30
|
+
className: "lw-absolute lw-bottom-0 lw-right-0"
|
|
31
|
+
}, React.createElement(LineChart, {
|
|
30
32
|
padding: padding,
|
|
31
33
|
size: size,
|
|
32
34
|
color: color,
|
|
33
35
|
data: chart
|
|
34
|
-
}));
|
|
36
|
+
})) : null);
|
|
35
37
|
};
|
|
36
38
|
export { LineChartWithData };
|
|
37
39
|
//# sourceMappingURL=LineChartWithData.js.map
|
package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChartWithData.js","names":["React","useQuery","LineChart","
|
|
1
|
+
{"version":3,"file":"LineChartWithData.js","names":["React","useQuery","LineChart","getInstrumentsChart","LineChartWithData","_ref","padding","record","size","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 padding,\n record,\n size,\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\">\n <LineChart\n padding={padding}\n size={size}\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,IAOI;EAAA,IAPH;IACzBC,OAAO;IACPC,MAAM;IACNC,IAAI;IACJC,SAAS;IACTC,QAAQ;IACRC;EACsB,CAAC,GAAAN,IAAA;EACvB,MAAM;IAAEO,OAAO;IAAEC;EAAK,CAAC,GAAGZ,QAAQ,CAGhCE,mBAAmB,EAAE;IACrBW,SAAS,EAAE;MACTC,WAAW,EAAE,CAACR,MAAM,CAACS,UAAU,CAAC;MAChCN;IACF,CAAC;IACDO,WAAW,EAAE,cAAc;IAC3BC,IAAI,EAAE,CAACX,MAAM,CAACS;EAChB,CAAC,CAAC;EAEF,MAAMG,SAAS,GAAGV,SAAS,IAAIG,OAAO;EACtC,MAAMQ,KAAK,GAAGP,IAAI,EAAEQ,wBAAwB,GAAG,CAAC,CAAC,CAACD,KAAK,IAAI,EAAE;EAE7D,OACEpB,KAAA,CAAAsB,aAAA;IAAKC,SAAS,EAAC;EAAa,GACzB,CAACJ,SAAS,GACTnB,KAAA,CAAAsB,aAAA;IAAKC,SAAS,EAAC;EAAoC,GACjDvB,KAAA,CAAAsB,aAAA,CAACpB,SAAS;IACRI,OAAO,EAAEA,OAAQ;IACjBE,IAAI,EAAEA,IAAK;IACXG,KAAK,EAAEA,KAAM;IACbE,IAAI,EAAEO;EAAM,CACb,CACE,CAAC,GACJ,IACD,CAAC;AAEV,CAAC;AAED,SAAShB,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { LineChartSize } from '@oanda/labs-widget-common';\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { DataRecord, LineChartSize } from '@oanda/labs-widget-common';\nimport { Division } from '../../../gql/types/graphql';\n\nexport interface LineChartWithDataProps {\n padding?: number;\n record: DataRecord;\n size?: LineChartSize;\n isLoading: boolean;\n division: Division;\n color: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/InstrumentLiveRateWidget/components/index.ts"],"sourcesContent":["export * from './LineChartWithData';\n"],"mappings":"AAAA,cAAc,qBAAqB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../../src/InstrumentLiveRateWidget/components/index.ts"],"sourcesContent":["export * from './InstrumentRateWithChart';\nexport * from './LineChartWithData';\n"],"mappings":"AAAA,cAAc,2BAA2B;AACzC,cAAc,qBAAqB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["Locale","Division"],"sources":["../../../src/InstrumentLiveRateWidget/types.tsx"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { Division } from '../gql/types/graphql';\n\nexport { Locale } from '@oanda/mono-i18n';\nexport { Division } from '../gql/types/graphql';\n\nexport interface InstrumentLiveRateConfig {\n graphqlUrl: string;\n division: Division;\n liveRatesUrl: string;\n instrument: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n removePadding?: boolean;\n size?: 'compact' | 'full' | 'fullWithChart';\n}\n\nexport interface MainProps {\n instrument: string;\n division: Division;\n size?: 'compact' | 'full' | 'fullWithChart'\n}\n
|
|
1
|
+
{"version":3,"file":"types.js","names":["Locale","Division"],"sources":["../../../src/InstrumentLiveRateWidget/types.tsx"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { Division } from '../gql/types/graphql';\n\nexport { Locale } from '@oanda/mono-i18n';\nexport { Division } from '../gql/types/graphql';\n\nexport interface InstrumentLiveRateConfig {\n graphqlUrl: string;\n division: Division;\n liveRatesUrl: string;\n instrument: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n removePadding?: boolean;\n size?: 'compact' | 'full' | 'fullWithChart';\n}\n\nexport interface MainProps {\n instrument: string;\n division: Division;\n size?: 'compact' | 'full' | 'fullWithChart'\n}\n"],"mappings":"AAIA,SAASA,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,sBAAsB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["useState","useEffect","useLiveRatesMessage","getRecords","data","mapInstrumentNames","map","item","instrument","name","displayName","useRecords","record","target","updatedRecord","setUpdatedRecord","sentiment","error","setError","update","liveRatesError","buy","bid","buyPriceMovement","bidPriceMovement","dailyPercentChange","dailyPercentChangeFromOpen","dailyPipsChange","dailyPipsChangeFromOpen","displayPrecision"],"sources":["../../../src/InstrumentLiveRateWidget/utils.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { LiveRatesErrorMessage, useLiveRatesMessage } from '@oanda/labs-widget-common';\nimport {
|
|
1
|
+
{"version":3,"file":"utils.js","names":["useState","useEffect","useLiveRatesMessage","getRecords","data","mapInstrumentNames","map","item","instrument","name","displayName","useRecords","record","target","updatedRecord","setUpdatedRecord","sentiment","error","setError","update","liveRatesError","buy","bid","buyPriceMovement","bidPriceMovement","dailyPercentChange","dailyPercentChangeFromOpen","dailyPipsChange","dailyPipsChangeFromOpen","displayPrecision"],"sources":["../../../src/InstrumentLiveRateWidget/utils.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { DataRecord, LiveRatesErrorMessage, useLiveRatesMessage } from '@oanda/labs-widget-common';\nimport { ValidateInstrumentsQuery } from '../gql/types/graphql';\n\nconst getRecords = (data: ValidateInstrumentsQuery) => data?.mapInstrumentNames?.map((item) => ({\n instrument: item?.name || '',\n displayName: item?.displayName || '',\n}));\n\nconst useRecords = (\n record: DataRecord,\n target: EventTarget | null,\n) => {\n const [updatedRecord, setUpdatedRecord] = useState<DataRecord>({\n displayName: record.displayName,\n instrument: record.instrument,\n sentiment: record.sentiment,\n });\n const [error, setError] = useState<LiveRatesErrorMessage | null>(null);\n\n const { update, error: liveRatesError } = useLiveRatesMessage(\n record.instrument,\n target,\n );\n\n useEffect(() => {\n setUpdatedRecord({\n displayName: record.displayName,\n instrument: record.instrument,\n buy: update?.bid,\n buyPriceMovement: update?.bidPriceMovement,\n dailyPercentChange: update?.dailyPercentChangeFromOpen,\n dailyPipsChange: update?.dailyPipsChangeFromOpen,\n displayPrecision: update?.displayPrecision,\n });\n setError(liveRatesError);\n }, [update, record, liveRatesError]);\n\n return {\n updatedRecord,\n error,\n };\n};\n\nexport {\n getRecords,\n useRecords,\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAC3C,SAA4CC,mBAAmB,QAAQ,2BAA2B;AAGlG,MAAMC,UAAU,GAAIC,IAA8B,IAAKA,IAAI,EAAEC,kBAAkB,EAAEC,GAAG,CAAEC,IAAI,KAAM;EAC9FC,UAAU,EAAED,IAAI,EAAEE,IAAI,IAAI,EAAE;EAC5BC,WAAW,EAAEH,IAAI,EAAEG,WAAW,IAAI;AACpC,CAAC,CAAC,CAAC;AAEH,MAAMC,UAAU,GAAGA,CACjBC,MAAkB,EAClBC,MAA0B,KACvB;EACH,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGf,QAAQ,CAAa;IAC7DU,WAAW,EAAEE,MAAM,CAACF,WAAW;IAC/BF,UAAU,EAAEI,MAAM,CAACJ,UAAU;IAC7BQ,SAAS,EAAEJ,MAAM,CAACI;EACpB,CAAC,CAAC;EACF,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGlB,QAAQ,CAA+B,IAAI,CAAC;EAEtE,MAAM;IAAEmB,MAAM;IAAEF,KAAK,EAAEG;EAAe,CAAC,GAAGlB,mBAAmB,CAC3DU,MAAM,CAACJ,UAAU,EACjBK,MACF,CAAC;EAEDZ,SAAS,CAAC,MAAM;IACdc,gBAAgB,CAAC;MACfL,WAAW,EAAEE,MAAM,CAACF,WAAW;MAC/BF,UAAU,EAAEI,MAAM,CAACJ,UAAU;MAC7Ba,GAAG,EAAEF,MAAM,EAAEG,GAAG;MAChBC,gBAAgB,EAAEJ,MAAM,EAAEK,gBAAgB;MAC1CC,kBAAkB,EAAEN,MAAM,EAAEO,0BAA0B;MACtDC,eAAe,EAAER,MAAM,EAAES,uBAAuB;MAChDC,gBAAgB,EAAEV,MAAM,EAAEU;IAC5B,CAAC,CAAC;IACFX,QAAQ,CAACE,cAAc,CAAC;EAC1B,CAAC,EAAE,CAACD,MAAM,EAAEP,MAAM,EAAEQ,cAAc,CAAC,CAAC;EAEpC,OAAO;IACLN,aAAa;IACbG;EACF,CAAC;AACH,CAAC;AAED,SACEd,UAAU,EACVQ,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DataRecord } from '@oanda/labs-widget-common';
|
|
2
|
+
import { Division } from '../../types';
|
|
3
|
+
export interface InstrumentRateWithChartProps {
|
|
4
|
+
loading: boolean;
|
|
5
|
+
record: DataRecord;
|
|
6
|
+
target: EventTarget | null;
|
|
7
|
+
division: Division;
|
|
8
|
+
size?: 'compact' | 'full' | 'fullWithChart';
|
|
9
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { LineChartSize } from '@oanda/labs-widget-common';
|
|
2
|
-
import { DataRecord } from '../../types';
|
|
1
|
+
import { DataRecord, LineChartSize } from '@oanda/labs-widget-common';
|
|
3
2
|
import { Division } from '../../../gql/types/graphql';
|
|
4
3
|
export interface LineChartWithDataProps {
|
|
5
4
|
padding?: number;
|