@oanda/labs-order-book-widget 1.0.154 → 1.0.155
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 +608 -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
|
@@ -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.155",
|
|
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.155",
|
|
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": "eecb0d8d995023c4374b106577b8be81b27604d4"
|
|
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
|
);
|