@oanda/labs-instrument-live-rate-widget 1.0.9 → 1.0.10
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 +44 -0
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +8 -12
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/Main.js +21 -56
- package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/ValidationWrapper.js +52 -0
- package/dist/main/InstrumentLiveRateWidget/ValidationWrapper.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/types.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +7 -12
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/Main.js +24 -58
- package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/ValidationWrapper.js +45 -0
- package/dist/module/InstrumentLiveRateWidget/ValidationWrapper.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/types.js.map +1 -1
- package/dist/types/InstrumentLiveRateWidget/Main.d.ts +1 -1
- package/dist/types/InstrumentLiveRateWidget/ValidationWrapper.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/types.d.ts +10 -4
- package/package.json +3 -4
- package/src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx +11 -20
- package/src/InstrumentLiveRateWidget/Main.tsx +27 -66
- package/src/InstrumentLiveRateWidget/ValidationWrapper.tsx +62 -0
- package/src/InstrumentLiveRateWidget/types.tsx +10 -4
- package/test/Main.test.tsx +7 -3
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +0 -46
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js +0 -28
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js +0 -6
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js +0 -25
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +0 -42
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/index.js +0 -17
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/index.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js +0 -6
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/index.js +0 -28
- package/dist/main/InstrumentLiveRateWidget/components/index.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +0 -38
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js +0 -3
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js +0 -2
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js +0 -18
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +0 -35
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/index.js +0 -2
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/index.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js +0 -2
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/index.js +0 -3
- package/dist/module/InstrumentLiveRateWidget/components/index.js.map +0 -1
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.d.ts +0 -4
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.d.ts +0 -2
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.d.ts +0 -9
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.d.ts +0 -3
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.d.ts +0 -4
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/index.d.ts +0 -1
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/types.d.ts +0 -8
- package/dist/types/InstrumentLiveRateWidget/components/index.d.ts +0 -2
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx +0 -43
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.ts +0 -2
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.ts +0 -10
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.ts +0 -25
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx +0 -43
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/index.ts +0 -1
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx +0 -9
- package/src/InstrumentLiveRateWidget/components/index.ts +0 -2
- package/test/LineChartWithData.test.tsx +0 -164
- package/test/components/InstrumentRateWithChart.test.tsx +0 -62
- package/test/components/utils.test.ts +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,50 @@
|
|
|
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.10 (2024-08-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 1.0.148 (2024-08-01)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 1.0.147 (2024-08-01)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 1.0.146 (2024-07-26)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 1.0.145 (2024-07-25)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## 1.0.144 (2024-07-22)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## 1.0.143 (2024-07-19)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## 1.0.142 (2024-07-16)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## 1.0.141 (2024-07-16)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## 1.0.140 (2024-07-12)
|
|
43
|
+
|
|
44
|
+
**Note:** Version bump only for package @oanda/labs-instrument-live-rate-widget
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
6
50
|
## 1.0.9 (2024-08-01)
|
|
7
51
|
|
|
8
52
|
|
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.InstrumentLiveRateWidget = void 0;
|
|
7
|
-
var _react =
|
|
8
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
8
|
var _client = require("@apollo/client");
|
|
10
9
|
var _monoI18n = require("@oanda/mono-i18n");
|
|
11
10
|
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
12
11
|
var _translations = require("../translations");
|
|
13
|
-
var _Main = require("./Main");
|
|
14
12
|
var _types = require("./types");
|
|
15
|
-
|
|
13
|
+
var _ValidationWrapper = require("./ValidationWrapper");
|
|
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
|
+
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 InstrumentLiveRateWidget = _ref => {
|
|
17
17
|
let {
|
|
18
18
|
graphqlUrl,
|
|
@@ -45,16 +45,12 @@ const InstrumentLiveRateWidget = _ref => {
|
|
|
45
45
|
}
|
|
46
46
|
}, _react.default.createElement(_client.ApolloProvider, {
|
|
47
47
|
client: client
|
|
48
|
-
},
|
|
49
|
-
className: (0, _classnames.default)('lw-flex lw-items-center lw-border lw-border-solid lw-border-border-primary lw-px-4', {
|
|
50
|
-
'lw-h-[82px]': size !== 'compact',
|
|
51
|
-
'lw-h-[54px]': size === 'compact'
|
|
52
|
-
})
|
|
53
|
-
}, _react.default.createElement(_labsWidgetCommon.Error, null)) : _react.default.createElement(_Main.Main, {
|
|
48
|
+
}, _react.default.createElement(_react.Suspense, null, _react.default.createElement(_ValidationWrapper.ValidationWrapper, {
|
|
54
49
|
size: size,
|
|
55
50
|
instrument: instrument,
|
|
56
|
-
division: division
|
|
57
|
-
|
|
51
|
+
division: division,
|
|
52
|
+
isParamError: isParamError
|
|
53
|
+
}))))));
|
|
58
54
|
};
|
|
59
55
|
exports.InstrumentLiveRateWidget = InstrumentLiveRateWidget;
|
|
60
56
|
//# sourceMappingURL=InstrumentLiveRateWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentLiveRateWidget.js","names":["_react","
|
|
1
|
+
{"version":3,"file":"InstrumentLiveRateWidget.js","names":["_react","_interopRequireWildcard","require","_client","_monoI18n","_labsWidgetCommon","_translations","_types","_ValidationWrapper","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","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","Suspense","ValidationWrapper","exports"],"sources":["../../../src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx"],"sourcesContent":["import React, { Suspense } from 'react';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport {\n LiveRatesProvider, ThemeProvider, getLocale,\n} from '@oanda/labs-widget-common';\nimport { translations } from '../translations';\nimport { Division, InstrumentLiveRateConfig } from './types';\nimport { ValidationWrapper } from './ValidationWrapper';\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 <Suspense>\n <ValidationWrapper\n size={size}\n instrument={instrument}\n division={division}\n isParamError={isParamError}\n />\n </Suspense>\n </ApolloProvider>\n </LiveRatesProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { InstrumentLiveRateWidget };\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -6,81 +6,46 @@ 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"));
|
|
10
9
|
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
11
|
-
var _utils = require("./utils");
|
|
12
10
|
var _constant = require("./constant");
|
|
13
|
-
var
|
|
14
|
-
var _InstrumentRateWithChart = require("./components/InstrumentRateWithChart");
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
var _getInstrumentsChart = require("../gql/getInstrumentsChart");
|
|
16
12
|
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); }
|
|
17
13
|
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; }
|
|
18
14
|
const Main = _ref => {
|
|
19
15
|
let {
|
|
20
|
-
instrument,
|
|
21
16
|
division,
|
|
22
|
-
size: widgetSize = 'fullWithChart'
|
|
17
|
+
size: widgetSize = 'fullWithChart',
|
|
18
|
+
record
|
|
23
19
|
} = _ref;
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
} = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
|
|
27
|
-
const {
|
|
28
|
-
target,
|
|
29
|
-
setQuery
|
|
30
|
-
} = (0, _labsWidgetCommon.useLiveRatesQuery)();
|
|
31
|
-
const [records, setRecords] = (0, _react.useState)([]);
|
|
32
|
-
const {
|
|
33
|
-
loading,
|
|
34
|
-
data,
|
|
35
|
-
error
|
|
36
|
-
} = (0, _client.useQuery)(_validateInstruments.validateInstruments, {
|
|
20
|
+
const hasInstrument = !!record.instrument;
|
|
21
|
+
const [queryRef] = (0, _client.useBackgroundQuery)(_getInstrumentsChart.getInstrumentsChart, {
|
|
37
22
|
variables: {
|
|
38
|
-
instruments: [instrument],
|
|
23
|
+
instruments: [record.instrument],
|
|
39
24
|
division
|
|
40
25
|
},
|
|
41
|
-
fetchPolicy: 'network-only'
|
|
42
|
-
|
|
43
|
-
(0, _react.useEffect)(() => {
|
|
44
|
-
if (!loading && data) {
|
|
45
|
-
setRecords((0, _utils.getRecords)(data));
|
|
46
|
-
}
|
|
47
|
-
}, [loading, data]);
|
|
48
|
-
const instrumentsNames = records.map(_ref2 => {
|
|
49
|
-
let {
|
|
50
|
-
instrument: instrumentName
|
|
51
|
-
} = _ref2;
|
|
52
|
-
return instrumentName;
|
|
26
|
+
fetchPolicy: 'network-only',
|
|
27
|
+
skip: !hasInstrument
|
|
53
28
|
});
|
|
29
|
+
const {
|
|
30
|
+
target,
|
|
31
|
+
setQuery
|
|
32
|
+
} = (0, _labsWidgetCommon.useLiveRatesQuery)();
|
|
54
33
|
(0, _react.useEffect)(() => {
|
|
55
|
-
if (
|
|
34
|
+
if (hasInstrument) {
|
|
56
35
|
setQuery({
|
|
57
|
-
instruments:
|
|
36
|
+
instruments: [record?.instrument]
|
|
58
37
|
});
|
|
59
38
|
}
|
|
60
|
-
}, [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"data-testid": "instrument-live-rate-wrapper",
|
|
64
|
-
className: "lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary"
|
|
65
|
-
}, !showError && _react.default.createElement("div", {
|
|
66
|
-
className: (0, _classnames.default)({
|
|
67
|
-
'lw-h-[82px]': widgetSize !== 'compact',
|
|
68
|
-
'lw-h-[54px]': widgetSize === 'compact'
|
|
69
|
-
})
|
|
70
|
-
}, _react.default.createElement(_InstrumentRateWithChart.InstrumentRateWithChart, {
|
|
71
|
-
loading: loading,
|
|
72
|
-
record: records[0] || {},
|
|
39
|
+
}, [record]);
|
|
40
|
+
return _react.default.createElement("div", null, _react.default.createElement(_labsWidgetCommon.InstrumentRateWithChart, {
|
|
41
|
+
record: record,
|
|
73
42
|
target: target,
|
|
74
|
-
|
|
75
|
-
|
|
43
|
+
size: widgetSize,
|
|
44
|
+
tooltipId: _constant.INSTRUMENT_TOOLTIP_ID,
|
|
45
|
+
queryRef: queryRef
|
|
76
46
|
}), _react.default.createElement(_labsWidgetCommon.Tooltip, {
|
|
77
47
|
id: _constant.INSTRUMENT_TOOLTIP_ID
|
|
78
|
-
}))
|
|
79
|
-
className: (0, _classnames.default)('lw-flex lw-w-full lw-items-center', {
|
|
80
|
-
'lw-h-[82px]': widgetSize !== 'compact',
|
|
81
|
-
'lw-h-[54px]': widgetSize === 'compact'
|
|
82
|
-
})
|
|
83
|
-
}, _react.default.createElement(_labsWidgetCommon.Error, null))));
|
|
48
|
+
}));
|
|
84
49
|
};
|
|
85
50
|
exports.Main = Main;
|
|
86
51
|
//# sourceMappingURL=Main.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_client","
|
|
1
|
+
{"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_constant","_getInstrumentsChart","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","division","size","widgetSize","record","hasInstrument","instrument","queryRef","useBackgroundQuery","getInstrumentsChart","variables","instruments","fetchPolicy","skip","target","setQuery","useLiveRatesQuery","useEffect","createElement","InstrumentRateWithChart","tooltipId","INSTRUMENT_TOOLTIP_ID","Tooltip","id","exports"],"sources":["../../../src/InstrumentLiveRateWidget/Main.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useBackgroundQuery } from '@apollo/client';\nimport {\n InstrumentRateWithChart,\n Tooltip,\n useLiveRatesQuery,\n} from '@oanda/labs-widget-common';\nimport { MainProps } from './types';\nimport { INSTRUMENT_TOOLTIP_ID } from './constant';\nimport { getInstrumentsChart } from '../gql/getInstrumentsChart';\nimport { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../gql/types/graphql';\n\nconst Main = ({\n division,\n size: widgetSize = 'fullWithChart',\n record,\n}: MainProps) => {\n const hasInstrument = !!record.instrument;\n\n const [queryRef] = useBackgroundQuery<\n GetInstrumentsChartQuery,\n GetInstrumentsChartQueryVariables\n >(getInstrumentsChart, {\n variables: {\n instruments: [record.instrument],\n division,\n },\n fetchPolicy: 'network-only',\n skip: !hasInstrument,\n });\n\n const { target, setQuery } = useLiveRatesQuery();\n\n useEffect(() => {\n if (hasInstrument) {\n setQuery({ instruments: [record?.instrument] });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [record]);\n\n return (\n <div>\n <InstrumentRateWithChart<GetInstrumentsChartQuery>\n record={record}\n target={target}\n size={widgetSize}\n tooltipId={INSTRUMENT_TOOLTIP_ID}\n queryRef={queryRef}\n />\n <Tooltip id={INSTRUMENT_TOOLTIP_ID} />\n </div>\n );\n};\n\nexport { Main };\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ValidationWrapper = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _client = require("@apollo/client");
|
|
9
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
|
+
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
11
|
+
var _utils = require("./utils");
|
|
12
|
+
var _validateInstruments = require("../gql/validateInstruments");
|
|
13
|
+
var _Main = require("./Main");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
const ValidationWrapper = _ref => {
|
|
16
|
+
let {
|
|
17
|
+
instrument,
|
|
18
|
+
division,
|
|
19
|
+
size: widgetSize,
|
|
20
|
+
isParamError
|
|
21
|
+
} = _ref;
|
|
22
|
+
const {
|
|
23
|
+
data,
|
|
24
|
+
error
|
|
25
|
+
} = (0, _client.useSuspenseQuery)(_validateInstruments.validateInstruments, {
|
|
26
|
+
variables: {
|
|
27
|
+
instruments: [instrument],
|
|
28
|
+
division
|
|
29
|
+
},
|
|
30
|
+
fetchPolicy: 'network-only'
|
|
31
|
+
});
|
|
32
|
+
const showError = !!error || isParamError;
|
|
33
|
+
return _react.default.createElement(_react.default.Fragment, null, _react.default.createElement("div", {
|
|
34
|
+
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"
|
|
35
|
+
}, !showError && _react.default.createElement("div", {
|
|
36
|
+
className: (0, _classnames.default)({
|
|
37
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
38
|
+
'lw-h-[54px]': widgetSize === 'compact'
|
|
39
|
+
})
|
|
40
|
+
}, _react.default.createElement(_Main.Main, {
|
|
41
|
+
size: widgetSize,
|
|
42
|
+
division: division,
|
|
43
|
+
record: (0, _utils.getRecords)(data)?.[0]
|
|
44
|
+
})), showError && _react.default.createElement("div", {
|
|
45
|
+
className: (0, _classnames.default)('lw-flex lw-w-full lw-items-center', {
|
|
46
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
47
|
+
'lw-h-[54px]': widgetSize === 'compact'
|
|
48
|
+
})
|
|
49
|
+
}, _react.default.createElement(_labsWidgetCommon.Error, null))));
|
|
50
|
+
};
|
|
51
|
+
exports.ValidationWrapper = ValidationWrapper;
|
|
52
|
+
//# sourceMappingURL=ValidationWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationWrapper.js","names":["_react","_interopRequireDefault","require","_client","_classnames","_labsWidgetCommon","_utils","_validateInstruments","_Main","e","__esModule","default","ValidationWrapper","_ref","instrument","division","size","widgetSize","isParamError","data","error","useSuspenseQuery","validateInstruments","variables","instruments","fetchPolicy","showError","createElement","Fragment","className","classnames","Main","record","getRecords","Error","exports"],"sources":["../../../src/InstrumentLiveRateWidget/ValidationWrapper.tsx"],"sourcesContent":["import React from 'react';\nimport { useSuspenseQuery } from '@apollo/client';\nimport classnames from 'classnames';\nimport { Error } from '@oanda/labs-widget-common';\nimport { getRecords } from './utils';\nimport { ValidationWrapperProps } from './types';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';\nimport { Main } from './Main';\n\nconst ValidationWrapper = ({\n instrument,\n division,\n size: widgetSize,\n isParamError,\n}: ValidationWrapperProps) => {\n const { data, error } = useSuspenseQuery<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables\n >(validateInstruments, {\n variables: {\n instruments: [instrument],\n division,\n },\n fetchPolicy: 'network-only',\n });\n\n const showError = !!error || isParamError;\n\n return (\n <>\n <div\n className=\"lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary\"\n >\n {!showError && (\n <div className={classnames({\n 'lw-h-[82px]': widgetSize !== 'compact',\n 'lw-h-[54px]': widgetSize === 'compact',\n })}\n >\n <Main\n size={widgetSize}\n division={division}\n record={getRecords(data!)?.[0]!}\n />\n </div>\n )}\n {showError && (\n <div className={classnames('lw-flex lw-w-full lw-items-center', {\n 'lw-h-[82px]': widgetSize !== 'compact',\n 'lw-h-[54px]': widgetSize === 'compact',\n })}\n >\n <Error />\n </div>\n )}\n </div>\n </>\n );\n};\n\nexport { ValidationWrapper };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAAAK,oBAAA,GAAAL,OAAA;AAEA,IAAAM,KAAA,GAAAN,OAAA;AAA8B,SAAAD,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9B,MAAMG,iBAAiB,GAAGC,IAAA,IAKI;EAAA,IALH;IACzBC,UAAU;IACVC,QAAQ;IACRC,IAAI,EAAEC,UAAU;IAChBC;EACsB,CAAC,GAAAL,IAAA;EACvB,MAAM;IAAEM,IAAI;IAAEC;EAAM,CAAC,GAAG,IAAAC,wBAAgB,EAGtCC,wCAAmB,EAAE;IACrBC,SAAS,EAAE;MACTC,WAAW,EAAE,CAACV,UAAU,CAAC;MACzBC;IACF,CAAC;IACDU,WAAW,EAAE;EACf,CAAC,CAAC;EAEF,MAAMC,SAAS,GAAG,CAAC,CAACN,KAAK,IAAIF,YAAY;EAEzC,OACElB,MAAA,CAAAW,OAAA,CAAAgB,aAAA,CAAA3B,MAAA,CAAAW,OAAA,CAAAiB,QAAA,QACE5B,MAAA,CAAAW,OAAA,CAAAgB,aAAA;IACEE,SAAS,EAAC;EAAuH,GAEhI,CAACH,SAAS,IACT1B,MAAA,CAAAW,OAAA,CAAAgB,aAAA;IAAKE,SAAS,EAAE,IAAAC,mBAAU,EAAC;MACzB,aAAa,EAAEb,UAAU,KAAK,SAAS;MACvC,aAAa,EAAEA,UAAU,KAAK;IAChC,CAAC;EAAE,GAEDjB,MAAA,CAAAW,OAAA,CAAAgB,aAAA,CAACnB,KAAA,CAAAuB,IAAI;IACHf,IAAI,EAAEC,UAAW;IACjBF,QAAQ,EAAEA,QAAS;IACnBiB,MAAM,EAAE,IAAAC,iBAAU,EAACd,IAAK,CAAC,GAAG,CAAC;EAAG,CACjC,CACE,CACN,EACAO,SAAS,IACR1B,MAAA,CAAAW,OAAA,CAAAgB,aAAA;IAAKE,SAAS,EAAE,IAAAC,mBAAU,EAAC,mCAAmC,EAAE;MAC9D,aAAa,EAAEb,UAAU,KAAK,SAAS;MACvC,aAAa,EAAEA,UAAU,KAAK;IAChC,CAAC;EAAE,GAEDjB,MAAA,CAAAW,OAAA,CAAAgB,aAAA,CAACtB,iBAAA,CAAA6B,KAAK,MAAE,CACL,CAEJ,CACL,CAAC;AAEP,CAAC;AAACC,OAAA,CAAAvB,iBAAA,GAAAA,iBAAA","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?:
|
|
1
|
+
{"version":3,"file":"types.js","names":["_monoI18n","require","_graphql"],"sources":["../../../src/InstrumentLiveRateWidget/types.tsx"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { DataRecord, Theme, WidgetSize } 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?: WidgetSize;\n}\n\nexport interface ValidationWrapperProps {\n instrument: string;\n division: Division;\n size?: WidgetSize;\n isParamError?: boolean;\n}\nexport interface MainProps {\n record: DataRecord;\n division: Division;\n size?: WidgetSize;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAIA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import classnames from 'classnames';
|
|
1
|
+
import React, { Suspense } from 'react';
|
|
3
2
|
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
4
3
|
import { LocaleProvider } from '@oanda/mono-i18n';
|
|
5
|
-
import {
|
|
4
|
+
import { LiveRatesProvider, ThemeProvider, getLocale } from '@oanda/labs-widget-common';
|
|
6
5
|
import { translations } from '../translations';
|
|
7
|
-
import { Main } from './Main';
|
|
8
6
|
import { Division } from './types';
|
|
7
|
+
import { ValidationWrapper } from './ValidationWrapper';
|
|
9
8
|
const InstrumentLiveRateWidget = _ref => {
|
|
10
9
|
let {
|
|
11
10
|
graphqlUrl,
|
|
@@ -38,16 +37,12 @@ const InstrumentLiveRateWidget = _ref => {
|
|
|
38
37
|
}
|
|
39
38
|
}, React.createElement(ApolloProvider, {
|
|
40
39
|
client: client
|
|
41
|
-
},
|
|
42
|
-
className: classnames('lw-flex lw-items-center lw-border lw-border-solid lw-border-border-primary lw-px-4', {
|
|
43
|
-
'lw-h-[82px]': size !== 'compact',
|
|
44
|
-
'lw-h-[54px]': size === 'compact'
|
|
45
|
-
})
|
|
46
|
-
}, React.createElement(Error, null)) : React.createElement(Main, {
|
|
40
|
+
}, React.createElement(Suspense, null, React.createElement(ValidationWrapper, {
|
|
47
41
|
size: size,
|
|
48
42
|
instrument: instrument,
|
|
49
|
-
division: division
|
|
50
|
-
|
|
43
|
+
division: division,
|
|
44
|
+
isParamError: isParamError
|
|
45
|
+
}))))));
|
|
51
46
|
};
|
|
52
47
|
export { InstrumentLiveRateWidget };
|
|
53
48
|
//# sourceMappingURL=InstrumentLiveRateWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentLiveRateWidget.js","names":["React","
|
|
1
|
+
{"version":3,"file":"InstrumentLiveRateWidget.js","names":["React","Suspense","ApolloClient","InMemoryCache","ApolloProvider","LocaleProvider","LiveRatesProvider","ThemeProvider","getLocale","translations","Division","ValidationWrapper","InstrumentLiveRateWidget","_ref","graphqlUrl","liveRatesUrl","instrument","division","locale","theme","isParamError","removePadding","size","client","uri","cache","divisionCode","Opt","Ogm","dataSource","createElement","url","options"],"sources":["../../../src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx"],"sourcesContent":["import React, { Suspense } from 'react';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport {\n LiveRatesProvider, ThemeProvider, getLocale,\n} from '@oanda/labs-widget-common';\nimport { translations } from '../translations';\nimport { Division, InstrumentLiveRateConfig } from './types';\nimport { ValidationWrapper } from './ValidationWrapper';\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 <Suspense>\n <ValidationWrapper\n size={size}\n instrument={instrument}\n division={division}\n isParamError={isParamError}\n />\n </Suspense>\n </ApolloProvider>\n </LiveRatesProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { InstrumentLiveRateWidget };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,YAAY,EAAEC,aAAa,EAAEC,cAAc,QAAQ,gBAAgB;AAC5E,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SACEC,iBAAiB,EAAEC,aAAa,EAAEC,SAAS,QACtC,2BAA2B;AAClC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,QAAQ,QAAkC,SAAS;AAC5D,SAASC,iBAAiB,QAAQ,qBAAqB;AAEvD,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,IAAIrB,YAAY,CAAC;IAC9BsB,GAAG,EAAEV,UAAU;IACfW,KAAK,EAAE,IAAItB,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMuB,YAAY,GAAGT,QAAQ,KAAKP,QAAQ,CAACiB,GAAG,GAAGjB,QAAQ,CAACkB,GAAG,GAAGX,QAAQ;EACxE,MAAMY,UAAU,GAAGH,YAAY,KAAKhB,QAAQ,CAACkB,GAAG,GAAG,KAAK,GAAG,KAAK;EAEhE,OACE5B,KAAA,CAAA8B,aAAA,CAACvB,aAAa;IAACc,aAAa,EAAEA,aAAc;IAACF,KAAK,EAAEA;EAAM,GACxDnB,KAAA,CAAA8B,aAAA,CAACzB,cAAc;IAACa,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,CAAC1B,cAAc;IAACmB,MAAM,EAAEA;EAAO,GAC7BvB,KAAA,CAAA8B,aAAA,CAAC7B,QAAQ,QACPD,KAAA,CAAA8B,aAAA,CAACnB,iBAAiB;IAChBW,IAAI,EAAEA,IAAK;IACXN,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAEA,QAAS;IACnBG,YAAY,EAAEA;EAAa,CAC5B,CACO,CACI,CACC,CACL,CACH,CAAC;AAEpB,CAAC;AAED,SAASR,wBAAwB","ignoreList":[]}
|
|
@@ -1,77 +1,43 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { Error, ThemeContext, Tooltip, useLiveRatesQuery } from '@oanda/labs-widget-common';
|
|
5
|
-
import { getRecords } from './utils';
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { useBackgroundQuery } from '@apollo/client';
|
|
3
|
+
import { InstrumentRateWithChart, Tooltip, useLiveRatesQuery } from '@oanda/labs-widget-common';
|
|
6
4
|
import { INSTRUMENT_TOOLTIP_ID } from './constant';
|
|
7
|
-
import {
|
|
8
|
-
import { InstrumentRateWithChart } from './components/InstrumentRateWithChart';
|
|
5
|
+
import { getInstrumentsChart } from '../gql/getInstrumentsChart';
|
|
9
6
|
const Main = _ref => {
|
|
10
7
|
let {
|
|
11
|
-
instrument,
|
|
12
8
|
division,
|
|
13
|
-
size: widgetSize = 'fullWithChart'
|
|
9
|
+
size: widgetSize = 'fullWithChart',
|
|
10
|
+
record
|
|
14
11
|
} = _ref;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
} = useContext(ThemeContext);
|
|
18
|
-
const {
|
|
19
|
-
target,
|
|
20
|
-
setQuery
|
|
21
|
-
} = useLiveRatesQuery();
|
|
22
|
-
const [records, setRecords] = useState([]);
|
|
23
|
-
const {
|
|
24
|
-
loading,
|
|
25
|
-
data,
|
|
26
|
-
error
|
|
27
|
-
} = useQuery(validateInstruments, {
|
|
12
|
+
const hasInstrument = !!record.instrument;
|
|
13
|
+
const [queryRef] = useBackgroundQuery(getInstrumentsChart, {
|
|
28
14
|
variables: {
|
|
29
|
-
instruments: [instrument],
|
|
15
|
+
instruments: [record.instrument],
|
|
30
16
|
division
|
|
31
17
|
},
|
|
32
|
-
fetchPolicy: 'network-only'
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!loading && data) {
|
|
36
|
-
setRecords(getRecords(data));
|
|
37
|
-
}
|
|
38
|
-
}, [loading, data]);
|
|
39
|
-
const instrumentsNames = records.map(_ref2 => {
|
|
40
|
-
let {
|
|
41
|
-
instrument: instrumentName
|
|
42
|
-
} = _ref2;
|
|
43
|
-
return instrumentName;
|
|
18
|
+
fetchPolicy: 'network-only',
|
|
19
|
+
skip: !hasInstrument
|
|
44
20
|
});
|
|
21
|
+
const {
|
|
22
|
+
target,
|
|
23
|
+
setQuery
|
|
24
|
+
} = useLiveRatesQuery();
|
|
45
25
|
useEffect(() => {
|
|
46
|
-
if (
|
|
26
|
+
if (hasInstrument) {
|
|
47
27
|
setQuery({
|
|
48
|
-
instruments:
|
|
28
|
+
instruments: [record?.instrument]
|
|
49
29
|
});
|
|
50
30
|
}
|
|
51
|
-
}, [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"data-testid": "instrument-live-rate-wrapper",
|
|
55
|
-
className: "lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary"
|
|
56
|
-
}, !showError && React.createElement("div", {
|
|
57
|
-
className: classnames({
|
|
58
|
-
'lw-h-[82px]': widgetSize !== 'compact',
|
|
59
|
-
'lw-h-[54px]': widgetSize === 'compact'
|
|
60
|
-
})
|
|
61
|
-
}, React.createElement(InstrumentRateWithChart, {
|
|
62
|
-
loading: loading,
|
|
63
|
-
record: records[0] || {},
|
|
31
|
+
}, [record]);
|
|
32
|
+
return React.createElement("div", null, React.createElement(InstrumentRateWithChart, {
|
|
33
|
+
record: record,
|
|
64
34
|
target: target,
|
|
65
|
-
|
|
66
|
-
|
|
35
|
+
size: widgetSize,
|
|
36
|
+
tooltipId: INSTRUMENT_TOOLTIP_ID,
|
|
37
|
+
queryRef: queryRef
|
|
67
38
|
}), React.createElement(Tooltip, {
|
|
68
39
|
id: INSTRUMENT_TOOLTIP_ID
|
|
69
|
-
}))
|
|
70
|
-
className: classnames('lw-flex lw-w-full lw-items-center', {
|
|
71
|
-
'lw-h-[82px]': widgetSize !== 'compact',
|
|
72
|
-
'lw-h-[54px]': widgetSize === 'compact'
|
|
73
|
-
})
|
|
74
|
-
}, React.createElement(Error, null))));
|
|
40
|
+
}));
|
|
75
41
|
};
|
|
76
42
|
export { Main };
|
|
77
43
|
//# sourceMappingURL=Main.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["React","
|
|
1
|
+
{"version":3,"file":"Main.js","names":["React","useEffect","useBackgroundQuery","InstrumentRateWithChart","Tooltip","useLiveRatesQuery","INSTRUMENT_TOOLTIP_ID","getInstrumentsChart","Main","_ref","division","size","widgetSize","record","hasInstrument","instrument","queryRef","variables","instruments","fetchPolicy","skip","target","setQuery","createElement","tooltipId","id"],"sources":["../../../src/InstrumentLiveRateWidget/Main.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useBackgroundQuery } from '@apollo/client';\nimport {\n InstrumentRateWithChart,\n Tooltip,\n useLiveRatesQuery,\n} from '@oanda/labs-widget-common';\nimport { MainProps } from './types';\nimport { INSTRUMENT_TOOLTIP_ID } from './constant';\nimport { getInstrumentsChart } from '../gql/getInstrumentsChart';\nimport { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../gql/types/graphql';\n\nconst Main = ({\n division,\n size: widgetSize = 'fullWithChart',\n record,\n}: MainProps) => {\n const hasInstrument = !!record.instrument;\n\n const [queryRef] = useBackgroundQuery<\n GetInstrumentsChartQuery,\n GetInstrumentsChartQueryVariables\n >(getInstrumentsChart, {\n variables: {\n instruments: [record.instrument],\n division,\n },\n fetchPolicy: 'network-only',\n skip: !hasInstrument,\n });\n\n const { target, setQuery } = useLiveRatesQuery();\n\n useEffect(() => {\n if (hasInstrument) {\n setQuery({ instruments: [record?.instrument] });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [record]);\n\n return (\n <div>\n <InstrumentRateWithChart<GetInstrumentsChartQuery>\n record={record}\n target={target}\n size={widgetSize}\n tooltipId={INSTRUMENT_TOOLTIP_ID}\n queryRef={queryRef}\n />\n <Tooltip id={INSTRUMENT_TOOLTIP_ID} />\n </div>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AACxC,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SACEC,uBAAuB,EACvBC,OAAO,EACPC,iBAAiB,QACZ,2BAA2B;AAElC,SAASC,qBAAqB,QAAQ,YAAY;AAClD,SAASC,mBAAmB,QAAQ,4BAA4B;AAGhE,MAAMC,IAAI,GAAGC,IAAA,IAII;EAAA,IAJH;IACZC,QAAQ;IACRC,IAAI,EAAEC,UAAU,GAAG,eAAe;IAClCC;EACS,CAAC,GAAAJ,IAAA;EACV,MAAMK,aAAa,GAAG,CAAC,CAACD,MAAM,CAACE,UAAU;EAEzC,MAAM,CAACC,QAAQ,CAAC,GAAGd,kBAAkB,CAGnCK,mBAAmB,EAAE;IACrBU,SAAS,EAAE;MACTC,WAAW,EAAE,CAACL,MAAM,CAACE,UAAU,CAAC;MAChCL;IACF,CAAC;IACDS,WAAW,EAAE,cAAc;IAC3BC,IAAI,EAAE,CAACN;EACT,CAAC,CAAC;EAEF,MAAM;IAAEO,MAAM;IAAEC;EAAS,CAAC,GAAGjB,iBAAiB,CAAC,CAAC;EAEhDJ,SAAS,CAAC,MAAM;IACd,IAAIa,aAAa,EAAE;MACjBQ,QAAQ,CAAC;QAAEJ,WAAW,EAAE,CAACL,MAAM,EAAEE,UAAU;MAAE,CAAC,CAAC;IACjD;EAEF,CAAC,EAAE,CAACF,MAAM,CAAC,CAAC;EAEZ,OACEb,KAAA,CAAAuB,aAAA,cACEvB,KAAA,CAAAuB,aAAA,CAACpB,uBAAuB;IACtBU,MAAM,EAAEA,MAAO;IACfQ,MAAM,EAAEA,MAAO;IACfV,IAAI,EAAEC,UAAW;IACjBY,SAAS,EAAElB,qBAAsB;IACjCU,QAAQ,EAAEA;EAAS,CACpB,CAAC,EACFhB,KAAA,CAAAuB,aAAA,CAACnB,OAAO;IAACqB,EAAE,EAAEnB;EAAsB,CAAE,CAClC,CAAC;AAEV,CAAC;AAED,SAASE,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSuspenseQuery } from '@apollo/client';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { Error } from '@oanda/labs-widget-common';
|
|
5
|
+
import { getRecords } from './utils';
|
|
6
|
+
import { validateInstruments } from '../gql/validateInstruments';
|
|
7
|
+
import { Main } from './Main';
|
|
8
|
+
const ValidationWrapper = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
instrument,
|
|
11
|
+
division,
|
|
12
|
+
size: widgetSize,
|
|
13
|
+
isParamError
|
|
14
|
+
} = _ref;
|
|
15
|
+
const {
|
|
16
|
+
data,
|
|
17
|
+
error
|
|
18
|
+
} = useSuspenseQuery(validateInstruments, {
|
|
19
|
+
variables: {
|
|
20
|
+
instruments: [instrument],
|
|
21
|
+
division
|
|
22
|
+
},
|
|
23
|
+
fetchPolicy: 'network-only'
|
|
24
|
+
});
|
|
25
|
+
const showError = !!error || isParamError;
|
|
26
|
+
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
27
|
+
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"
|
|
28
|
+
}, !showError && React.createElement("div", {
|
|
29
|
+
className: classnames({
|
|
30
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
31
|
+
'lw-h-[54px]': widgetSize === 'compact'
|
|
32
|
+
})
|
|
33
|
+
}, React.createElement(Main, {
|
|
34
|
+
size: widgetSize,
|
|
35
|
+
division: division,
|
|
36
|
+
record: getRecords(data)?.[0]
|
|
37
|
+
})), showError && React.createElement("div", {
|
|
38
|
+
className: classnames('lw-flex lw-w-full lw-items-center', {
|
|
39
|
+
'lw-h-[82px]': widgetSize !== 'compact',
|
|
40
|
+
'lw-h-[54px]': widgetSize === 'compact'
|
|
41
|
+
})
|
|
42
|
+
}, React.createElement(Error, null))));
|
|
43
|
+
};
|
|
44
|
+
export { ValidationWrapper };
|
|
45
|
+
//# sourceMappingURL=ValidationWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationWrapper.js","names":["React","useSuspenseQuery","classnames","Error","getRecords","validateInstruments","Main","ValidationWrapper","_ref","instrument","division","size","widgetSize","isParamError","data","error","variables","instruments","fetchPolicy","showError","createElement","Fragment","className","record"],"sources":["../../../src/InstrumentLiveRateWidget/ValidationWrapper.tsx"],"sourcesContent":["import React from 'react';\nimport { useSuspenseQuery } from '@apollo/client';\nimport classnames from 'classnames';\nimport { Error } from '@oanda/labs-widget-common';\nimport { getRecords } from './utils';\nimport { ValidationWrapperProps } from './types';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';\nimport { Main } from './Main';\n\nconst ValidationWrapper = ({\n instrument,\n division,\n size: widgetSize,\n isParamError,\n}: ValidationWrapperProps) => {\n const { data, error } = useSuspenseQuery<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables\n >(validateInstruments, {\n variables: {\n instruments: [instrument],\n division,\n },\n fetchPolicy: 'network-only',\n });\n\n const showError = !!error || isParamError;\n\n return (\n <>\n <div\n className=\"lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary\"\n >\n {!showError && (\n <div className={classnames({\n 'lw-h-[82px]': widgetSize !== 'compact',\n 'lw-h-[54px]': widgetSize === 'compact',\n })}\n >\n <Main\n size={widgetSize}\n division={division}\n record={getRecords(data!)?.[0]!}\n />\n </div>\n )}\n {showError && (\n <div className={classnames('lw-flex lw-w-full lw-items-center', {\n 'lw-h-[82px]': widgetSize !== 'compact',\n 'lw-h-[54px]': widgetSize === 'compact',\n })}\n >\n <Error />\n </div>\n )}\n </div>\n </>\n );\n};\n\nexport { ValidationWrapper };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,gBAAgB,QAAQ,gBAAgB;AACjD,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,UAAU,QAAQ,SAAS;AAEpC,SAASC,mBAAmB,QAAQ,4BAA4B;AAEhE,SAASC,IAAI,QAAQ,QAAQ;AAE7B,MAAMC,iBAAiB,GAAGC,IAAA,IAKI;EAAA,IALH;IACzBC,UAAU;IACVC,QAAQ;IACRC,IAAI,EAAEC,UAAU;IAChBC;EACsB,CAAC,GAAAL,IAAA;EACvB,MAAM;IAAEM,IAAI;IAAEC;EAAM,CAAC,GAAGd,gBAAgB,CAGtCI,mBAAmB,EAAE;IACrBW,SAAS,EAAE;MACTC,WAAW,EAAE,CAACR,UAAU,CAAC;MACzBC;IACF,CAAC;IACDQ,WAAW,EAAE;EACf,CAAC,CAAC;EAEF,MAAMC,SAAS,GAAG,CAAC,CAACJ,KAAK,IAAIF,YAAY;EAEzC,OACEb,KAAA,CAAAoB,aAAA,CAAApB,KAAA,CAAAqB,QAAA,QACErB,KAAA,CAAAoB,aAAA;IACEE,SAAS,EAAC;EAAuH,GAEhI,CAACH,SAAS,IACTnB,KAAA,CAAAoB,aAAA;IAAKE,SAAS,EAAEpB,UAAU,CAAC;MACzB,aAAa,EAAEU,UAAU,KAAK,SAAS;MACvC,aAAa,EAAEA,UAAU,KAAK;IAChC,CAAC;EAAE,GAEDZ,KAAA,CAAAoB,aAAA,CAACd,IAAI;IACHK,IAAI,EAAEC,UAAW;IACjBF,QAAQ,EAAEA,QAAS;IACnBa,MAAM,EAAEnB,UAAU,CAACU,IAAK,CAAC,GAAG,CAAC;EAAG,CACjC,CACE,CACN,EACAK,SAAS,IACRnB,KAAA,CAAAoB,aAAA;IAAKE,SAAS,EAAEpB,UAAU,CAAC,mCAAmC,EAAE;MAC9D,aAAa,EAAEU,UAAU,KAAK,SAAS;MACvC,aAAa,EAAEA,UAAU,KAAK;IAChC,CAAC;EAAE,GAEDZ,KAAA,CAAAoB,aAAA,CAACjB,KAAK,MAAE,CACL,CAEJ,CACL,CAAC;AAEP,CAAC;AAED,SAASI,iBAAiB","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?:
|
|
1
|
+
{"version":3,"file":"types.js","names":["Locale","Division"],"sources":["../../../src/InstrumentLiveRateWidget/types.tsx"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { DataRecord, Theme, WidgetSize } 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?: WidgetSize;\n}\n\nexport interface ValidationWrapperProps {\n instrument: string;\n division: Division;\n size?: WidgetSize;\n isParamError?: boolean;\n}\nexport interface MainProps {\n record: DataRecord;\n division: Division;\n size?: WidgetSize;\n}\n"],"mappings":"AAIA,SAASA,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,sBAAsB","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MainProps } from './types';
|
|
3
|
-
declare const Main: ({
|
|
3
|
+
declare const Main: ({ division, size: widgetSize, record, }: MainProps) => React.JSX.Element;
|
|
4
4
|
export { Main };
|