@oanda/labs-order-book-widget 1.0.154 → 1.0.156
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 +1220 -0
- package/dist/main/OrderBookWidget/ChartWithData.js +2 -2
- package/dist/main/OrderBookWidget/ChartWithData.js.map +1 -1
- package/dist/main/OrderBookWidget/Main.js +5 -3
- package/dist/main/OrderBookWidget/Main.js.map +1 -1
- package/dist/main/OrderBookWidget/OrderBookWidget.js +4 -2
- package/dist/main/OrderBookWidget/OrderBookWidget.js.map +1 -1
- package/dist/main/OrderBookWidget/config.js +4 -3
- package/dist/main/OrderBookWidget/config.js.map +1 -1
- package/dist/main/OrderBookWidget/render.js +35 -6
- package/dist/main/OrderBookWidget/render.js.map +1 -1
- package/dist/main/OrderBookWidget/types.js +16 -16
- package/dist/main/OrderBookWidget/types.js.map +1 -1
- package/dist/module/OrderBookWidget/ChartWithData.js +2 -2
- package/dist/module/OrderBookWidget/ChartWithData.js.map +1 -1
- package/dist/module/OrderBookWidget/Main.js +7 -5
- package/dist/module/OrderBookWidget/Main.js.map +1 -1
- package/dist/module/OrderBookWidget/OrderBookWidget.js +4 -2
- package/dist/module/OrderBookWidget/OrderBookWidget.js.map +1 -1
- package/dist/module/OrderBookWidget/config.js +4 -3
- package/dist/module/OrderBookWidget/config.js.map +1 -1
- package/dist/module/OrderBookWidget/render.js +35 -6
- package/dist/module/OrderBookWidget/render.js.map +1 -1
- package/dist/module/OrderBookWidget/types.js +16 -16
- package/dist/module/OrderBookWidget/types.js.map +1 -1
- package/dist/types/OrderBookWidget/Main.d.ts +1 -1
- package/dist/types/OrderBookWidget/OrderBookWidget.d.ts +1 -1
- package/dist/types/OrderBookWidget/config.d.ts +5 -1
- package/dist/types/OrderBookWidget/types.d.ts +19 -17
- package/package.json +3 -3
- package/src/OrderBookWidget/ChartWithData.tsx +3 -3
- package/src/OrderBookWidget/Main.tsx +6 -5
- package/src/OrderBookWidget/OrderBookWidget.tsx +2 -1
- package/src/OrderBookWidget/config.ts +14 -8
- package/src/OrderBookWidget/render.tsx +34 -2
- package/src/OrderBookWidget/types.ts +19 -17
- package/test/Main.test.tsx +3 -3
|
@@ -2,11 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { validateLocale, validateToolParams } from '@oanda/labs-widget-common';
|
|
4
4
|
import { OrderBookWidget } from './OrderBookWidget';
|
|
5
|
+
import { Division } from '../gql/types/graphql';
|
|
6
|
+
import { instrumentSelectConfigOC, instrumentSelectConfig } from './config';
|
|
5
7
|
const {
|
|
6
8
|
graphqlUrl: configGraphQl,
|
|
7
9
|
instrument: configInstrument,
|
|
8
10
|
renderElementId: configRenderElementId,
|
|
9
|
-
locale: configLocale
|
|
11
|
+
locale: configLocale,
|
|
12
|
+
division: configDivision
|
|
10
13
|
} = window.volatilityChartWidgetConfig || {};
|
|
11
14
|
const {
|
|
12
15
|
graphqlUrl
|
|
@@ -19,23 +22,48 @@ if (orderBookElements.length > 0) {
|
|
|
19
22
|
const mode = element.getAttribute('data-mode');
|
|
20
23
|
const {
|
|
21
24
|
instrument,
|
|
22
|
-
locale
|
|
25
|
+
locale,
|
|
26
|
+
division
|
|
23
27
|
} = JSON.parse(params);
|
|
24
|
-
const isParamError = validateToolParams({
|
|
28
|
+
const isParamError = instrument ? validateToolParams({
|
|
29
|
+
locale,
|
|
30
|
+
graphqlUrl,
|
|
31
|
+
division,
|
|
32
|
+
instrument
|
|
33
|
+
}, [{
|
|
34
|
+
name: 'locale',
|
|
35
|
+
valueCheck: value => validateLocale(value)
|
|
36
|
+
}, {
|
|
37
|
+
name: 'graphqlUrl'
|
|
38
|
+
}, {
|
|
39
|
+
name: 'division',
|
|
40
|
+
valueCheck: value => Object.values(Division).includes(value)
|
|
41
|
+
}, {
|
|
42
|
+
name: 'instrument',
|
|
43
|
+
valueCheck: value => {
|
|
44
|
+
const acceptableInstruments = division === Division.Oc ? instrumentSelectConfigOC : instrumentSelectConfig;
|
|
45
|
+
return Object.values(acceptableInstruments.map(x => x.id)).includes(value.replace(/\/|_/g, ''));
|
|
46
|
+
}
|
|
47
|
+
}]) : validateToolParams({
|
|
25
48
|
locale,
|
|
26
|
-
graphqlUrl
|
|
49
|
+
graphqlUrl,
|
|
50
|
+
division
|
|
27
51
|
}, [{
|
|
28
52
|
name: 'locale',
|
|
29
53
|
valueCheck: value => validateLocale(value)
|
|
30
54
|
}, {
|
|
31
55
|
name: 'graphqlUrl'
|
|
56
|
+
}, {
|
|
57
|
+
name: 'division',
|
|
58
|
+
valueCheck: value => Object.values(Division).includes(value)
|
|
32
59
|
}]);
|
|
33
60
|
root.render(React.createElement(OrderBookWidget, {
|
|
34
61
|
locale: locale,
|
|
35
62
|
graphqlUrl: graphqlUrl,
|
|
36
63
|
instrument: instrument,
|
|
37
64
|
theme: mode,
|
|
38
|
-
isParamError: isParamError
|
|
65
|
+
isParamError: isParamError,
|
|
66
|
+
division: division
|
|
39
67
|
}));
|
|
40
68
|
});
|
|
41
69
|
} else {
|
|
@@ -44,7 +72,8 @@ if (orderBookElements.length > 0) {
|
|
|
44
72
|
root.render(React.createElement(OrderBookWidget, {
|
|
45
73
|
locale: configLocale,
|
|
46
74
|
graphqlUrl: configGraphQl,
|
|
47
|
-
instrument: configInstrument
|
|
75
|
+
instrument: configInstrument,
|
|
76
|
+
division: configDivision
|
|
48
77
|
}));
|
|
49
78
|
}
|
|
50
79
|
//# sourceMappingURL=render.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["React","createRoot","validateLocale","validateToolParams","OrderBookWidget","graphqlUrl","configGraphQl","instrument","configInstrument","renderElementId","configRenderElementId","locale","configLocale","window","volatilityChartWidgetConfig","widgetsConfig","orderBookElements","document","querySelectorAll","length","forEach","element","root","params","getAttribute","mode","JSON","parse","isParamError","name","valueCheck","value","render","createElement","theme","container","getElementById"],"sources":["../../../src/OrderBookWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport { OrderBookWidget } from './OrderBookWidget';\n\nconst {\n graphqlUrl: configGraphQl,\n instrument: configInstrument,\n renderElementId: configRenderElementId,\n locale: configLocale,\n} = window.volatilityChartWidgetConfig || {};\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst orderBookElements = document.querySelectorAll('div[data-order-book-params]');\n\nif (orderBookElements.length > 0) {\n orderBookElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-order-book-params');\n const mode = element.getAttribute('data-mode');\n const { instrument, locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({ locale, graphqlUrl }, [\n {\n name: 'locale',\n valueCheck: (value) => validateLocale(value),\n }, {\n name: 'graphqlUrl',\n }]);\n root.render(\n <OrderBookWidget\n locale={locale}\n graphqlUrl={graphqlUrl}\n instrument={instrument}\n theme={mode as Theme}\n isParamError={isParamError}\n />,\n );\n });\n} else {\n const container = document.getElementById(configRenderElementId);\n const root = createRoot(container!);\n\n root.render(\n <OrderBookWidget\n locale={configLocale}\n graphqlUrl={configGraphQl}\n instrument={configInstrument}\n />,\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAAgBC,cAAc,EAAEC,kBAAkB,QAAQ,2BAA2B;AACrF,SAASC,eAAe,QAAQ,mBAAmB;
|
|
1
|
+
{"version":3,"file":"render.js","names":["React","createRoot","validateLocale","validateToolParams","OrderBookWidget","Division","instrumentSelectConfigOC","instrumentSelectConfig","graphqlUrl","configGraphQl","instrument","configInstrument","renderElementId","configRenderElementId","locale","configLocale","division","configDivision","window","volatilityChartWidgetConfig","widgetsConfig","orderBookElements","document","querySelectorAll","length","forEach","element","root","params","getAttribute","mode","JSON","parse","isParamError","name","valueCheck","value","Object","values","includes","acceptableInstruments","Oc","map","x","id","replace","render","createElement","theme","container","getElementById"],"sources":["../../../src/OrderBookWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport { OrderBookWidget } from './OrderBookWidget';\nimport { Division } from '../gql/types/graphql';\nimport { instrumentSelectConfigOC, instrumentSelectConfig } from './config';\n\nconst {\n graphqlUrl: configGraphQl,\n instrument: configInstrument,\n renderElementId: configRenderElementId,\n locale: configLocale,\n division: configDivision,\n} = window.volatilityChartWidgetConfig || {};\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst orderBookElements = document.querySelectorAll('div[data-order-book-params]');\n\nif (orderBookElements.length > 0) {\n orderBookElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-order-book-params');\n const mode = element.getAttribute('data-mode');\n const { instrument, locale, division } = JSON.parse(params as string);\n\n const isParamError = instrument ? validateToolParams({\n locale, graphqlUrl, division, instrument,\n }, [\n {\n name: 'locale',\n valueCheck: (value) => validateLocale(value),\n }, {\n name: 'graphqlUrl',\n }, {\n name: 'division',\n valueCheck: (value) => Object.values(Division).includes(value),\n }, {\n name: 'instrument',\n valueCheck: (value) => {\n const acceptableInstruments = division === Division.Oc\n ? instrumentSelectConfigOC\n : instrumentSelectConfig;\n\n return Object.values(\n acceptableInstruments.map((x) => x.id),\n ).includes(value.replace(/\\/|_/g, ''));\n },\n },\n ]) : validateToolParams({ locale, graphqlUrl, division }, [\n {\n name: 'locale',\n valueCheck: (value) => validateLocale(value),\n }, {\n name: 'graphqlUrl',\n }, {\n name: 'division',\n valueCheck: (value) => Object.values(Division).includes(value),\n }]);\n\n root.render(\n <OrderBookWidget\n locale={locale}\n graphqlUrl={graphqlUrl}\n instrument={instrument}\n theme={mode as Theme}\n isParamError={isParamError}\n division={division}\n />,\n );\n });\n} else {\n const container = document.getElementById(configRenderElementId);\n const root = createRoot(container!);\n\n root.render(\n <OrderBookWidget\n locale={config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,MAAMiC,SAAS,GAAG3B,QAAQ,CAAC4B,cAAc,CAACrC,qBAAqB,CAAC;EAChE,MAAMc,IAAI,GAAG1B,UAAU,CAACgD,SAAU,CAAC;EAEnCtB,IAAI,CAACmB,MAAM,CACT9C,KAAA,CAAA+C,aAAA,CAAC3C,eAAe;IACdU,MAAM,EAAEC,YAAa;IACrBP,UAAU,EAAEC,aAAc;IAC1BC,UAAU,EAAEC,gBAAiB;IAC7BK,QAAQ,EAAEC;EAAe,CAC1B,CACH,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export let InstrumentId = function (InstrumentId) {
|
|
2
|
-
InstrumentId["EUR_AUD"] = "
|
|
3
|
-
InstrumentId["EUR_GBP"] = "
|
|
4
|
-
InstrumentId["EUR_JPY"] = "
|
|
5
|
-
InstrumentId["EUR_USD"] = "
|
|
6
|
-
InstrumentId["EUR_CHF"] = "
|
|
7
|
-
InstrumentId["USD_CHF"] = "
|
|
8
|
-
InstrumentId["USD_JPY"] = "
|
|
9
|
-
InstrumentId["USD_CAD"] = "
|
|
10
|
-
InstrumentId["GBP_USD"] = "
|
|
11
|
-
InstrumentId["GBP_JPY"] = "
|
|
12
|
-
InstrumentId["GBP_CHF"] = "
|
|
13
|
-
InstrumentId["AUD_JPY"] = "
|
|
14
|
-
InstrumentId["AUD_USD"] = "
|
|
15
|
-
InstrumentId["NZD_USD"] = "
|
|
16
|
-
InstrumentId["XAU_USD"] = "
|
|
17
|
-
InstrumentId["XAG_USD"] = "
|
|
2
|
+
InstrumentId["EUR_AUD"] = "EURAUD";
|
|
3
|
+
InstrumentId["EUR_GBP"] = "EURGBP";
|
|
4
|
+
InstrumentId["EUR_JPY"] = "EURJPY";
|
|
5
|
+
InstrumentId["EUR_USD"] = "EURUSD";
|
|
6
|
+
InstrumentId["EUR_CHF"] = "EURCHF";
|
|
7
|
+
InstrumentId["USD_CHF"] = "USDCHF";
|
|
8
|
+
InstrumentId["USD_JPY"] = "USDJPY";
|
|
9
|
+
InstrumentId["USD_CAD"] = "USDCAD";
|
|
10
|
+
InstrumentId["GBP_USD"] = "GBPUSD";
|
|
11
|
+
InstrumentId["GBP_JPY"] = "GBPJPY";
|
|
12
|
+
InstrumentId["GBP_CHF"] = "GBPCHF";
|
|
13
|
+
InstrumentId["AUD_JPY"] = "AUDJPY";
|
|
14
|
+
InstrumentId["AUD_USD"] = "AUDUSD";
|
|
15
|
+
InstrumentId["NZD_USD"] = "NZDUSD";
|
|
16
|
+
InstrumentId["XAU_USD"] = "XAUUSD";
|
|
17
|
+
InstrumentId["XAG_USD"] = "XAGUSD";
|
|
18
18
|
return InstrumentId;
|
|
19
19
|
}({});
|
|
20
20
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["InstrumentId"],"sources":["../../../src/OrderBookWidget/types.ts"],"sourcesContent":["import { Theme } from '@oanda/labs-widget-common';\nimport { Locale } from '@oanda/mono-i18n';\nimport { BookType } from '../gql/types/graphql';\n\nexport interface OrderBookWidgetConfig {\n graphqlUrl: string;\n instrument: InstrumentId;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n}\n\nexport interface OrderBookWrapperConfig extends OrderBookWidgetConfig {\n renderElementId: string;\n}\n\nexport interface MainProps {\n instrument?: InstrumentId;\n}\n\nexport interface ChartWithDataProps {\n instrument: InstrumentId;\n bookType: BookType;\n}\n\nexport enum InstrumentId {\n EUR_AUD = '
|
|
1
|
+
{"version":3,"file":"types.js","names":["InstrumentId"],"sources":["../../../src/OrderBookWidget/types.ts"],"sourcesContent":["import { Theme } from '@oanda/labs-widget-common';\nimport { Locale } from '@oanda/mono-i18n';\nimport { BookType, Division } from '../gql/types/graphql';\n\nexport interface OrderBookWidgetConfig {\n graphqlUrl: string;\n instrument: InstrumentId;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n division: Division;\n}\n\nexport interface OrderBookWrapperConfig extends OrderBookWidgetConfig {\n renderElementId: string;\n}\n\nexport interface MainProps {\n instrument?: InstrumentId;\n division: Division;\n}\n\nexport interface ChartWithDataProps {\n instrument: InstrumentId;\n bookType: BookType;\n}\n\nexport enum InstrumentId {\n EUR_AUD = 'EURAUD',\n EUR_GBP = 'EURGBP',\n EUR_JPY = 'EURJPY',\n EUR_USD = 'EURUSD',\n EUR_CHF = 'EURCHF',\n USD_CHF = 'USDCHF',\n USD_JPY = 'USDJPY',\n USD_CAD = 'USDCAD',\n GBP_USD = 'GBPUSD',\n GBP_JPY = 'GBPJPY',\n GBP_CHF = 'GBPCHF',\n AUD_JPY = 'AUDJPY',\n AUD_USD = 'AUDUSD',\n NZD_USD = 'NZDUSD',\n XAU_USD = 'XAUUSD',\n XAG_USD = 'XAGUSD',\n}\n"],"mappings":"AA2BA,WAAYA,YAAY,aAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAZA,YAAY;EAAA,OAAZA,YAAY;AAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { OrderBookWidgetConfig } from './types';
|
|
3
|
-
declare const OrderBookWidget: ({ graphqlUrl, instrument, locale, theme, isParamError, }: OrderBookWidgetConfig) => React.JSX.Element;
|
|
3
|
+
declare const OrderBookWidget: ({ graphqlUrl, instrument, locale, theme, isParamError, division, }: OrderBookWidgetConfig) => React.JSX.Element;
|
|
4
4
|
export { OrderBookWidget };
|
|
@@ -4,9 +4,13 @@ declare const navigationConfig: {
|
|
|
4
4
|
id: BookType;
|
|
5
5
|
label: string;
|
|
6
6
|
}[];
|
|
7
|
+
declare const instrumentSelectConfigOC: {
|
|
8
|
+
id: InstrumentId;
|
|
9
|
+
label: string;
|
|
10
|
+
}[];
|
|
7
11
|
declare const instrumentSelectConfig: {
|
|
8
12
|
id: InstrumentId;
|
|
9
13
|
label: string;
|
|
10
14
|
}[];
|
|
11
15
|
declare const instrumentPrecisionConfig: Record<InstrumentId, number>;
|
|
12
|
-
export { navigationConfig, instrumentSelectConfig, instrumentPrecisionConfig };
|
|
16
|
+
export { navigationConfig, instrumentSelectConfig, instrumentPrecisionConfig, instrumentSelectConfigOC, };
|
|
@@ -1,38 +1,40 @@
|
|
|
1
1
|
import { Theme } from '@oanda/labs-widget-common';
|
|
2
2
|
import { Locale } from '@oanda/mono-i18n';
|
|
3
|
-
import { BookType } from '../gql/types/graphql';
|
|
3
|
+
import { BookType, Division } from '../gql/types/graphql';
|
|
4
4
|
export interface OrderBookWidgetConfig {
|
|
5
5
|
graphqlUrl: string;
|
|
6
6
|
instrument: InstrumentId;
|
|
7
7
|
locale: Locale;
|
|
8
8
|
theme?: Theme;
|
|
9
9
|
isParamError?: boolean;
|
|
10
|
+
division: Division;
|
|
10
11
|
}
|
|
11
12
|
export interface OrderBookWrapperConfig extends OrderBookWidgetConfig {
|
|
12
13
|
renderElementId: string;
|
|
13
14
|
}
|
|
14
15
|
export interface MainProps {
|
|
15
16
|
instrument?: InstrumentId;
|
|
17
|
+
division: Division;
|
|
16
18
|
}
|
|
17
19
|
export interface ChartWithDataProps {
|
|
18
20
|
instrument: InstrumentId;
|
|
19
21
|
bookType: BookType;
|
|
20
22
|
}
|
|
21
23
|
export declare enum InstrumentId {
|
|
22
|
-
EUR_AUD = "
|
|
23
|
-
EUR_GBP = "
|
|
24
|
-
EUR_JPY = "
|
|
25
|
-
EUR_USD = "
|
|
26
|
-
EUR_CHF = "
|
|
27
|
-
USD_CHF = "
|
|
28
|
-
USD_JPY = "
|
|
29
|
-
USD_CAD = "
|
|
30
|
-
GBP_USD = "
|
|
31
|
-
GBP_JPY = "
|
|
32
|
-
GBP_CHF = "
|
|
33
|
-
AUD_JPY = "
|
|
34
|
-
AUD_USD = "
|
|
35
|
-
NZD_USD = "
|
|
36
|
-
XAU_USD = "
|
|
37
|
-
XAG_USD = "
|
|
24
|
+
EUR_AUD = "EURAUD",
|
|
25
|
+
EUR_GBP = "EURGBP",
|
|
26
|
+
EUR_JPY = "EURJPY",
|
|
27
|
+
EUR_USD = "EURUSD",
|
|
28
|
+
EUR_CHF = "EURCHF",
|
|
29
|
+
USD_CHF = "USDCHF",
|
|
30
|
+
USD_JPY = "USDJPY",
|
|
31
|
+
USD_CAD = "USDCAD",
|
|
32
|
+
GBP_USD = "GBPUSD",
|
|
33
|
+
GBP_JPY = "GBPJPY",
|
|
34
|
+
GBP_CHF = "GBPCHF",
|
|
35
|
+
AUD_JPY = "AUDJPY",
|
|
36
|
+
AUD_USD = "AUDUSD",
|
|
37
|
+
NZD_USD = "NZDUSD",
|
|
38
|
+
XAU_USD = "XAUUSD",
|
|
39
|
+
XAG_USD = "XAGUSD"
|
|
38
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oanda/labs-order-book-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.156",
|
|
4
4
|
"description": "Labs Order Book Widget",
|
|
5
5
|
"main": "dist/main/index.js",
|
|
6
6
|
"module": "dist/module/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"author": "OANDA",
|
|
13
13
|
"license": "UNLICENSED",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@oanda/labs-widget-common": "^1.0.
|
|
15
|
+
"@oanda/labs-widget-common": "^1.0.156",
|
|
16
16
|
"@oanda/mono-i18n": "10.0.1",
|
|
17
17
|
"echarts": "5.5.0",
|
|
18
18
|
"echarts-for-react": "3.0.2",
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"@graphql-codegen/client-preset": "4.1.0",
|
|
24
24
|
"@graphql-codegen/typescript": "4.0.1"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "0805ed728b9b0cf74d1cf0ef6db7beab69943000"
|
|
27
27
|
}
|
|
@@ -84,11 +84,11 @@ const ChartWithData = ({
|
|
|
84
84
|
</div>
|
|
85
85
|
)}
|
|
86
86
|
</div>
|
|
87
|
-
{!loading && !isError && (
|
|
88
87
|
<div className="lw-mt-2 lw-h-8">
|
|
89
|
-
|
|
88
|
+
{!loading && !isError && (
|
|
89
|
+
<LastUpdated timestamp={updatedAt} labelCallback={lang} />
|
|
90
|
+
)}
|
|
90
91
|
</div>
|
|
91
|
-
)}
|
|
92
92
|
</>
|
|
93
93
|
);
|
|
94
94
|
};
|
|
@@ -5,15 +5,16 @@ import {
|
|
|
5
5
|
} from '@oanda/labs-widget-common';
|
|
6
6
|
import { useLocale } from '@oanda/mono-i18n';
|
|
7
7
|
import { InstrumentId, MainProps } from './types';
|
|
8
|
-
import { BookType } from '../gql/types/graphql';
|
|
9
|
-
import { instrumentSelectConfig, navigationConfig } from './config';
|
|
8
|
+
import { BookType, Division } from '../gql/types/graphql';
|
|
9
|
+
import { instrumentSelectConfig, instrumentSelectConfigOC, navigationConfig } from './config';
|
|
10
10
|
import { ChartWithData } from './ChartWithData';
|
|
11
11
|
|
|
12
|
-
const Main = ({ instrument }: MainProps) => {
|
|
12
|
+
const Main = ({ instrument, division }: MainProps) => {
|
|
13
|
+
const selectConfig = division === Division.Oc ? instrumentSelectConfigOC : instrumentSelectConfig;
|
|
13
14
|
const { size } = useContext(ThemeContext);
|
|
14
15
|
const isDesktop = size === Size.DESKTOP;
|
|
15
16
|
const [bookType, setBookType] = useState(BookType.Order);
|
|
16
|
-
const [toolInstrument, setToolInstrument] = useState(
|
|
17
|
+
const [toolInstrument, setToolInstrument] = useState(selectConfig[0]);
|
|
17
18
|
const { lang } = useLocale();
|
|
18
19
|
|
|
19
20
|
return (
|
|
@@ -35,7 +36,7 @@ const Main = ({ instrument }: MainProps) => {
|
|
|
35
36
|
>
|
|
36
37
|
<Select
|
|
37
38
|
selectLabel={lang('instrument')}
|
|
38
|
-
options={
|
|
39
|
+
options={selectConfig}
|
|
39
40
|
selectedOption={toolInstrument}
|
|
40
41
|
setSelectedOption={
|
|
41
42
|
(val) => setToolInstrument(val as { id: InstrumentId; label: string })
|
|
@@ -12,6 +12,7 @@ const OrderBookWidget = ({
|
|
|
12
12
|
locale,
|
|
13
13
|
theme,
|
|
14
14
|
isParamError,
|
|
15
|
+
division,
|
|
15
16
|
}: OrderBookWidgetConfig) => {
|
|
16
17
|
const client = new ApolloClient({
|
|
17
18
|
uri: graphqlUrl,
|
|
@@ -26,7 +27,7 @@ const OrderBookWidget = ({
|
|
|
26
27
|
<div className="lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
|
|
27
28
|
<ChartError />
|
|
28
29
|
</div>
|
|
29
|
-
) : <Main instrument={instrument} />}
|
|
30
|
+
) : <Main instrument={instrument} division={division} />}
|
|
30
31
|
</ApolloProvider>
|
|
31
32
|
</LocaleProvider>
|
|
32
33
|
</ThemeProvider>
|
|
@@ -9,7 +9,7 @@ const navigationConfig = [{
|
|
|
9
9
|
label: 'position_book',
|
|
10
10
|
}];
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const instrumentSelectConfigOC = [{
|
|
13
13
|
id: InstrumentId.EUR_AUD,
|
|
14
14
|
label: 'EUR/AUD',
|
|
15
15
|
}, {
|
|
@@ -51,14 +51,18 @@ const instrumentSelectConfig = [{
|
|
|
51
51
|
}, {
|
|
52
52
|
id: InstrumentId.NZD_USD,
|
|
53
53
|
label: 'NZD/USD',
|
|
54
|
-
}, {
|
|
55
|
-
id: InstrumentId.XAU_USD,
|
|
56
|
-
label: 'XAU/USD',
|
|
57
|
-
}, {
|
|
58
|
-
id: InstrumentId.XAG_USD,
|
|
59
|
-
label: 'XAG/USD',
|
|
60
54
|
}];
|
|
61
55
|
|
|
56
|
+
const instrumentSelectConfig = [
|
|
57
|
+
...instrumentSelectConfigOC,
|
|
58
|
+
{
|
|
59
|
+
id: InstrumentId.XAU_USD,
|
|
60
|
+
label: 'XAU/USD',
|
|
61
|
+
}, {
|
|
62
|
+
id: InstrumentId.XAG_USD,
|
|
63
|
+
label: 'XAG/USD',
|
|
64
|
+
}];
|
|
65
|
+
|
|
62
66
|
const instrumentPrecisionConfig: Record<InstrumentId, number> = {
|
|
63
67
|
[InstrumentId.EUR_AUD]: 5,
|
|
64
68
|
[InstrumentId.EUR_GBP]: 5,
|
|
@@ -77,4 +81,6 @@ const instrumentPrecisionConfig: Record<InstrumentId, number> = {
|
|
|
77
81
|
[InstrumentId.XAU_USD]: 3,
|
|
78
82
|
[InstrumentId.XAG_USD]: 5,
|
|
79
83
|
};
|
|
80
|
-
export {
|
|
84
|
+
export {
|
|
85
|
+
navigationConfig, instrumentSelectConfig, instrumentPrecisionConfig, instrumentSelectConfigOC,
|
|
86
|
+
};
|
|
@@ -2,12 +2,15 @@ import React from 'react';
|
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';
|
|
4
4
|
import { OrderBookWidget } from './OrderBookWidget';
|
|
5
|
+
import { Division } from '../gql/types/graphql';
|
|
6
|
+
import { instrumentSelectConfigOC, instrumentSelectConfig } from './config';
|
|
5
7
|
|
|
6
8
|
const {
|
|
7
9
|
graphqlUrl: configGraphQl,
|
|
8
10
|
instrument: configInstrument,
|
|
9
11
|
renderElementId: configRenderElementId,
|
|
10
12
|
locale: configLocale,
|
|
13
|
+
division: configDivision,
|
|
11
14
|
} = window.volatilityChartWidgetConfig || {};
|
|
12
15
|
|
|
13
16
|
const {
|
|
@@ -21,15 +24,42 @@ if (orderBookElements.length > 0) {
|
|
|
21
24
|
const root = createRoot(element);
|
|
22
25
|
const params = element.getAttribute('data-order-book-params');
|
|
23
26
|
const mode = element.getAttribute('data-mode');
|
|
24
|
-
const { instrument, locale } = JSON.parse(params as string);
|
|
27
|
+
const { instrument, locale, division } = JSON.parse(params as string);
|
|
25
28
|
|
|
26
|
-
const isParamError = validateToolParams({
|
|
29
|
+
const isParamError = instrument ? validateToolParams({
|
|
30
|
+
locale, graphqlUrl, division, instrument,
|
|
31
|
+
}, [
|
|
27
32
|
{
|
|
28
33
|
name: 'locale',
|
|
29
34
|
valueCheck: (value) => validateLocale(value),
|
|
30
35
|
}, {
|
|
31
36
|
name: 'graphqlUrl',
|
|
37
|
+
}, {
|
|
38
|
+
name: 'division',
|
|
39
|
+
valueCheck: (value) => Object.values(Division).includes(value),
|
|
40
|
+
}, {
|
|
41
|
+
name: 'instrument',
|
|
42
|
+
valueCheck: (value) => {
|
|
43
|
+
const acceptableInstruments = division === Division.Oc
|
|
44
|
+
? instrumentSelectConfigOC
|
|
45
|
+
: instrumentSelectConfig;
|
|
46
|
+
|
|
47
|
+
return Object.values(
|
|
48
|
+
acceptableInstruments.map((x) => x.id),
|
|
49
|
+
).includes(value.replace(/\/|_/g, ''));
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
]) : validateToolParams({ locale, graphqlUrl, division }, [
|
|
53
|
+
{
|
|
54
|
+
name: 'locale',
|
|
55
|
+
valueCheck: (value) => validateLocale(value),
|
|
56
|
+
}, {
|
|
57
|
+
name: 'graphqlUrl',
|
|
58
|
+
}, {
|
|
59
|
+
name: 'division',
|
|
60
|
+
valueCheck: (value) => Object.values(Division).includes(value),
|
|
32
61
|
}]);
|
|
62
|
+
|
|
33
63
|
root.render(
|
|
34
64
|
<OrderBookWidget
|
|
35
65
|
locale={locale}
|
|
@@ -37,6 +67,7 @@ if (orderBookElements.length > 0) {
|
|
|
37
67
|
instrument={instrument}
|
|
38
68
|
theme={mode as Theme}
|
|
39
69
|
isParamError={isParamError}
|
|
70
|
+
division={division}
|
|
40
71
|
/>,
|
|
41
72
|
);
|
|
42
73
|
});
|
|
@@ -49,6 +80,7 @@ if (orderBookElements.length > 0) {
|
|
|
49
80
|
locale={configLocale}
|
|
50
81
|
graphqlUrl={configGraphQl}
|
|
51
82
|
instrument={configInstrument}
|
|
83
|
+
division={configDivision}
|
|
52
84
|
/>,
|
|
53
85
|
);
|
|
54
86
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Theme } from '@oanda/labs-widget-common';
|
|
2
2
|
import { Locale } from '@oanda/mono-i18n';
|
|
3
|
-
import { BookType } from '../gql/types/graphql';
|
|
3
|
+
import { BookType, Division } from '../gql/types/graphql';
|
|
4
4
|
|
|
5
5
|
export interface OrderBookWidgetConfig {
|
|
6
6
|
graphqlUrl: string;
|
|
@@ -8,6 +8,7 @@ export interface OrderBookWidgetConfig {
|
|
|
8
8
|
locale: Locale;
|
|
9
9
|
theme?: Theme;
|
|
10
10
|
isParamError?: boolean;
|
|
11
|
+
division: Division;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export interface OrderBookWrapperConfig extends OrderBookWidgetConfig {
|
|
@@ -16,6 +17,7 @@ export interface OrderBookWrapperConfig extends OrderBookWidgetConfig {
|
|
|
16
17
|
|
|
17
18
|
export interface MainProps {
|
|
18
19
|
instrument?: InstrumentId;
|
|
20
|
+
division: Division;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export interface ChartWithDataProps {
|
|
@@ -24,20 +26,20 @@ export interface ChartWithDataProps {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export enum InstrumentId {
|
|
27
|
-
EUR_AUD = '
|
|
28
|
-
EUR_GBP = '
|
|
29
|
-
EUR_JPY = '
|
|
30
|
-
EUR_USD = '
|
|
31
|
-
EUR_CHF = '
|
|
32
|
-
USD_CHF = '
|
|
33
|
-
USD_JPY = '
|
|
34
|
-
USD_CAD = '
|
|
35
|
-
GBP_USD = '
|
|
36
|
-
GBP_JPY = '
|
|
37
|
-
GBP_CHF = '
|
|
38
|
-
AUD_JPY = '
|
|
39
|
-
AUD_USD = '
|
|
40
|
-
NZD_USD = '
|
|
41
|
-
XAU_USD = '
|
|
42
|
-
XAG_USD = '
|
|
29
|
+
EUR_AUD = 'EURAUD',
|
|
30
|
+
EUR_GBP = 'EURGBP',
|
|
31
|
+
EUR_JPY = 'EURJPY',
|
|
32
|
+
EUR_USD = 'EURUSD',
|
|
33
|
+
EUR_CHF = 'EURCHF',
|
|
34
|
+
USD_CHF = 'USDCHF',
|
|
35
|
+
USD_JPY = 'USDJPY',
|
|
36
|
+
USD_CAD = 'USDCAD',
|
|
37
|
+
GBP_USD = 'GBPUSD',
|
|
38
|
+
GBP_JPY = 'GBPJPY',
|
|
39
|
+
GBP_CHF = 'GBPCHF',
|
|
40
|
+
AUD_JPY = 'AUDJPY',
|
|
41
|
+
AUD_USD = 'AUDUSD',
|
|
42
|
+
NZD_USD = 'NZDUSD',
|
|
43
|
+
XAU_USD = 'XAUUSD',
|
|
44
|
+
XAG_USD = 'XAGUSD',
|
|
43
45
|
}
|
package/test/Main.test.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { MockedProvider } from '@apollo/client/testing';
|
|
|
7
7
|
import { Size, ThemeContext } from '@oanda/labs-widget-common';
|
|
8
8
|
import { Main } from '../src/OrderBookWidget/Main';
|
|
9
9
|
import { getOrderPositionBooks } from '../src/gql/getOrderPositionBooks';
|
|
10
|
-
import { BookType } from '../src/gql/types/graphql';
|
|
10
|
+
import { BookType, Division } from '../src/gql/types/graphql';
|
|
11
11
|
import { InstrumentId } from '../src';
|
|
12
12
|
|
|
13
13
|
const mocks = [
|
|
@@ -68,7 +68,7 @@ describe('Main component', () => {
|
|
|
68
68
|
const { findByTestId } = render(
|
|
69
69
|
<MockedProvider mocks={mocks}>
|
|
70
70
|
<ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
|
|
71
|
-
<Main />
|
|
71
|
+
<Main division={Division.Oc} />
|
|
72
72
|
</ThemeContext.Provider>
|
|
73
73
|
</MockedProvider>,
|
|
74
74
|
);
|
|
@@ -82,7 +82,7 @@ describe('Main component', () => {
|
|
|
82
82
|
const { findByTestId, queryAllByTestId } = render(
|
|
83
83
|
<MockedProvider mocks={mocks}>
|
|
84
84
|
<ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
|
|
85
|
-
<Main instrument={InstrumentId.EUR_AUD} />
|
|
85
|
+
<Main division={Division.Oc} instrument={InstrumentId.EUR_AUD} />
|
|
86
86
|
</ThemeContext.Provider>
|
|
87
87
|
</MockedProvider>,
|
|
88
88
|
);
|