@oanda/labs-instruments-table-widget 1.0.18 → 1.0.20
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 +164 -0
- package/dist/main/InstrumentsTableWidget/InstrumentsTableWidget.js +5 -3
- package/dist/main/InstrumentsTableWidget/InstrumentsTableWidget.js.map +1 -1
- package/dist/main/InstrumentsTableWidget/render.js +3 -1
- package/dist/main/InstrumentsTableWidget/render.js.map +1 -1
- package/dist/main/InstrumentsTableWidget/types.js +6 -0
- package/dist/main/InstrumentsTableWidget/types.js.map +1 -1
- package/dist/main/InstrumentsTableWidget/utils.js +23 -0
- package/dist/main/InstrumentsTableWidget/utils.js.map +1 -0
- package/dist/module/InstrumentsTableWidget/InstrumentsTableWidget.js +5 -3
- package/dist/module/InstrumentsTableWidget/InstrumentsTableWidget.js.map +1 -1
- package/dist/module/InstrumentsTableWidget/render.js +3 -1
- package/dist/module/InstrumentsTableWidget/render.js.map +1 -1
- package/dist/module/InstrumentsTableWidget/types.js +5 -1
- package/dist/module/InstrumentsTableWidget/types.js.map +1 -1
- package/dist/module/InstrumentsTableWidget/utils.js +17 -0
- package/dist/module/InstrumentsTableWidget/utils.js.map +1 -0
- package/dist/types/InstrumentsTableWidget/InstrumentsTableWidget.d.ts +2 -2
- package/dist/types/InstrumentsTableWidget/types.d.ts +5 -0
- package/dist/types/InstrumentsTableWidget/utils.d.ts +4 -0
- package/package.json +3 -3
- package/src/InstrumentsTableWidget/InstrumentsTableWidget.tsx +8 -3
- package/src/InstrumentsTableWidget/render.tsx +2 -0
- package/src/InstrumentsTableWidget/types.ts +6 -0
- package/src/InstrumentsTableWidget/utils.ts +22 -0
- package/test/utils.test.ts +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,170 @@
|
|
|
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.20 (2025-05-30)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## 1.0.199 (2025-05-29)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 1.0.198 (2025-05-26)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## 1.0.197 (2025-05-23)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 1.0.196 (2025-05-22)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## 1.0.195 (2025-05-21)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## 1.0.194 (2025-05-21)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## 1.0.193 (2025-05-15)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
## 1.0.192 (2025-05-14)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## 1.0.191 (2025-04-30)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## 1.0.190 (2025-04-28)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## 1.0.189 (2025-04-23)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## 1.0.188 (2025-04-22)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## 1.0.187 (2025-04-18)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
## 1.0.186 (2025-04-10)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## 1.0.185 (2025-04-09)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## 1.0.184 (2025-04-08)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
## 1.0.183 (2025-04-04)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## 1.0.182 (2025-03-21)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
## 1.0.181 (2025-03-13)
|
|
83
|
+
|
|
84
|
+
**Note:** Version bump only for package @oanda/labs-instruments-table-widget
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
## 1.0.19 (2025-05-29)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
## 1.0.198 (2025-05-26)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
## 1.0.197 (2025-05-23)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
## 1.0.196 (2025-05-22)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## 1.0.195 (2025-05-21)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## 1.0.194 (2025-05-21)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## 1.0.193 (2025-05-15)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
## 1.0.192 (2025-05-14)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## 1.0.191 (2025-04-30)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
## 1.0.190 (2025-04-28)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
## 1.0.189 (2025-04-23)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
## 1.0.188 (2025-04-22)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
## 1.0.187 (2025-04-18)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
## 1.0.186 (2025-04-10)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## 1.0.185 (2025-04-09)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
## 1.0.184 (2025-04-08)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
## 1.0.183 (2025-04-04)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
## 1.0.182 (2025-03-21)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
## 1.0.181 (2025-03-13)
|
|
163
|
+
|
|
164
|
+
**Note:** Version bump only for package @oanda/labs-instruments-table-widget
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
6
170
|
## 1.0.18 (2025-05-26)
|
|
7
171
|
|
|
8
172
|
|
|
@@ -7,9 +7,10 @@ exports.InstrumentsTableWidget = void 0;
|
|
|
7
7
|
var _client = require("@apollo/client");
|
|
8
8
|
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _graphql = require("../gql/types/graphql");
|
|
11
10
|
var _translations = require("../translations");
|
|
12
11
|
var _Main = require("./Main");
|
|
12
|
+
var _types = require("./types");
|
|
13
|
+
var _utils = require("./utils");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
15
|
const InstrumentsTableWidget = _ref => {
|
|
15
16
|
let {
|
|
@@ -26,13 +27,14 @@ const InstrumentsTableWidget = _ref => {
|
|
|
26
27
|
isAssetClassFilterEnabled,
|
|
27
28
|
isInstrumentSearchEnabled,
|
|
28
29
|
recordsPerPage,
|
|
29
|
-
dataSource
|
|
30
|
+
dataSource,
|
|
31
|
+
priceType = _types.PriceType.Division
|
|
30
32
|
} = _ref;
|
|
31
33
|
const client = new _client.ApolloClient({
|
|
32
34
|
uri: graphqlUrl,
|
|
33
35
|
cache: new _client.InMemoryCache()
|
|
34
36
|
});
|
|
35
|
-
const divisionCode =
|
|
37
|
+
const divisionCode = (0, _utils.getLiveRatesDivisionCode)(division, priceType, dataSource);
|
|
36
38
|
return _react.default.createElement(_labsWidgetCommon.WidgetProvider, {
|
|
37
39
|
client: client,
|
|
38
40
|
liveRates: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentsTableWidget.js","names":["_client","require","_labsWidgetCommon","_react","_interopRequireDefault","
|
|
1
|
+
{"version":3,"file":"InstrumentsTableWidget.js","names":["_client","require","_labsWidgetCommon","_react","_interopRequireDefault","_translations","_Main","_types","_utils","e","__esModule","default","InstrumentsTableWidget","_ref","division","instruments","columns","graphqlUrl","locale","theme","isParamError","logoLink","liveRatesUrl","assetClasses","isAssetClassFilterEnabled","isInstrumentSearchEnabled","recordsPerPage","dataSource","priceType","PriceType","Division","client","ApolloClient","uri","cache","InMemoryCache","divisionCode","getLiveRatesDivisionCode","createElement","WidgetProvider","liveRates","url","options","translations","WidgetWrapper","linkArea","Main","exports"],"sources":["../../../src/InstrumentsTableWidget/InstrumentsTableWidget.tsx"],"sourcesContent":["import { ApolloClient, InMemoryCache } from '@apollo/client';\nimport { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport { translations } from '../translations';\nimport { Main } from './Main';\nimport { type InstrumentsTableConfig, PriceType } from './types';\nimport { getLiveRatesDivisionCode } from './utils';\n\nconst InstrumentsTableWidget = ({\n division,\n instruments,\n columns,\n graphqlUrl,\n locale,\n theme,\n isParamError,\n logoLink,\n liveRatesUrl,\n assetClasses,\n isAssetClassFilterEnabled,\n isInstrumentSearchEnabled,\n recordsPerPage,\n dataSource,\n priceType = PriceType.Division,\n}: InstrumentsTableConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n const divisionCode = getLiveRatesDivisionCode(\n division,\n priceType,\n dataSource\n );\n\n return (\n <WidgetProvider\n client={client}\n liveRates={{\n url: liveRatesUrl,\n options: { divisionCode, dataSource },\n }}\n locale={locale}\n theme={theme}\n translations={translations}\n >\n <WidgetWrapper\n isParamError={isParamError}\n linkArea=\"logo\"\n logoLink={logoLink}\n >\n <Main\n assetClasses={assetClasses}\n columns={columns}\n dataSource={dataSource}\n division={division}\n instruments={instruments}\n isAssetClassFilterEnabled={isAssetClassFilterEnabled}\n isInstrumentSearchEnabled={isInstrumentSearchEnabled}\n recordsPerPage={recordsPerPage}\n />\n </WidgetWrapper>\n </WidgetProvider>\n );\n};\n\nexport { InstrumentsTableWidget };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAAmD,SAAAG,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnD,MAAMG,sBAAsB,GAAGC,IAAA,IAgBD;EAAA,IAhBE;IAC9BC,QAAQ;IACRC,WAAW;IACXC,OAAO;IACPC,UAAU;IACVC,MAAM;IACNC,KAAK;IACLC,YAAY;IACZC,QAAQ;IACRC,YAAY;IACZC,YAAY;IACZC,yBAAyB;IACzBC,yBAAyB;IACzBC,cAAc;IACdC,UAAU;IACVC,SAAS,GAAGC,gBAAS,CAACC;EACA,CAAC,GAAAjB,IAAA;EACvB,MAAMkB,MAAM,GAAG,IAAIC,oBAAY,CAAC;IAC9BC,GAAG,EAAEhB,UAAU;IACfiB,KAAK,EAAE,IAAIC,qBAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMC,YAAY,GAAG,IAAAC,+BAAwB,EAC3CvB,QAAQ,EACRc,SAAS,EACTD,UACF,CAAC;EAED,OACExB,MAAA,CAAAQ,OAAA,CAAA2B,aAAA,CAACpC,iBAAA,CAAAqC,cAAc;IACbR,MAAM,EAAEA,MAAO;IACfS,SAAS,EAAE;MACTC,GAAG,EAAEnB,YAAY;MACjBoB,OAAO,EAAE;QAAEN,YAAY;QAAET;MAAW;IACtC,CAAE;IACFT,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEA,KAAM;IACbwB,YAAY,EAAEA;EAAa,GAE3BxC,MAAA,CAAAQ,OAAA,CAAA2B,aAAA,CAACpC,iBAAA,CAAA0C,aAAa;IACZxB,YAAY,EAAEA,YAAa;IAC3ByB,QAAQ,EAAC,MAAM;IACfxB,QAAQ,EAAEA;EAAS,GAEnBlB,MAAA,CAAAQ,OAAA,CAAA2B,aAAA,CAAChC,KAAA,CAAAwC,IAAI;IACHvB,YAAY,EAAEA,YAAa;IAC3BP,OAAO,EAAEA,OAAQ;IACjBW,UAAU,EAAEA,UAAW;IACvBb,QAAQ,EAAEA,QAAS;IACnBC,WAAW,EAAEA,WAAY;IACzBS,yBAAyB,EAAEA,yBAA0B;IACrDC,yBAAyB,EAAEA,yBAA0B;IACrDC,cAAc,EAAEA;EAAe,CAChC,CACY,CACD,CAAC;AAErB,CAAC;AAACqB,OAAA,CAAAnC,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|
|
@@ -24,7 +24,8 @@ dataInstrumentsTableParamsElements.forEach(element => {
|
|
|
24
24
|
isAssetClassFilterEnabled,
|
|
25
25
|
isInstrumentSearchEnabled,
|
|
26
26
|
recordsPerPage,
|
|
27
|
-
dataSource
|
|
27
|
+
dataSource,
|
|
28
|
+
priceType
|
|
28
29
|
} = JSON.parse(params);
|
|
29
30
|
const isParamError = (0, _labsWidgetCommon.validateToolParams)({
|
|
30
31
|
columns,
|
|
@@ -62,6 +63,7 @@ dataInstrumentsTableParamsElements.forEach(element => {
|
|
|
62
63
|
isParamError: isParamError,
|
|
63
64
|
liveRatesUrl: liveRatesUrl,
|
|
64
65
|
locale: locale,
|
|
66
|
+
priceType: priceType,
|
|
65
67
|
recordsPerPage: recordsPerPage,
|
|
66
68
|
theme: mode
|
|
67
69
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["_labsWidgetCommon","require","_react","_interopRequireDefault","_client","_graphql","_InstrumentsTableWidget","e","__esModule","default","graphqlUrl","liveRatesUrl","window","widgetsConfig","dataInstrumentsTableParamsElements","document","querySelectorAll","forEach","element","root","createRoot","params","getAttribute","mode","instruments","columns","division","locale","assetClasses","isAssetClassFilterEnabled","isInstrumentSearchEnabled","recordsPerPage","dataSource","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","length","Object","values","Division","includes","validateLocale","InstrumentDataSource","render","createElement","InstrumentsTableWidget","theme"],"sources":["../../../src/InstrumentsTableWidget/render.tsx"],"sourcesContent":["import type { Theme } from '@oanda/labs-widget-common';\nimport { validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { Division, InstrumentDataSource } from '../gql/types/graphql';\nimport { InstrumentsTableWidget } from './InstrumentsTableWidget';\n\nconst { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};\n\nconst dataInstrumentsTableParamsElements = document.querySelectorAll(\n 'div[data-instruments-table-params]'\n);\n\ndataInstrumentsTableParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-instruments-table-params');\n const mode = element.getAttribute('data-mode');\n const {\n instruments,\n columns,\n division,\n locale,\n assetClasses,\n isAssetClassFilterEnabled,\n isInstrumentSearchEnabled,\n recordsPerPage,\n dataSource,\n } = JSON.parse(params as string);\n\n const isParamError = validateToolParams(\n {\n columns,\n division,\n locale,\n graphqlUrl,\n liveRatesUrl,\n dataSource,\n },\n [\n {\n name: 'columns',\n valueCheck: (value) => (value as string[]).length > 0,\n },\n {\n name: 'division',\n valueCheck: (value: Division) =>\n Object.values(Division).includes(value),\n },\n {\n name: 'locale',\n valueCheck: (value: string | undefined) => validateLocale(value),\n },\n {\n name: 'graphqlUrl',\n },\n {\n name: 'liveRatesUrl',\n },\n {\n name: 'dataSource',\n valueCheck: (value: InstrumentDataSource) =>\n Object.values(InstrumentDataSource).includes(value),\n },\n ]\n );\n\n root.render(\n <InstrumentsTableWidget\n assetClasses={assetClasses}\n columns={columns}\n dataSource={dataSource}\n division={division}\n graphqlUrl={graphqlUrl}\n instruments={instruments}\n isAssetClassFilterEnabled={isAssetClassFilterEnabled}\n isInstrumentSearchEnabled={isInstrumentSearchEnabled}\n isParamError={isParamError}\n liveRatesUrl={liveRatesUrl}\n locale={locale}\n recordsPerPage={recordsPerPage}\n theme={mode as Theme}\n />\n );\n});\n"],"mappings":";;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AAAkE,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElE,MAAM;EAAEG,UAAU;EAAEC;AAAa,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE/D,MAAMC,kCAAkC,GAAGC,QAAQ,CAACC,gBAAgB,CAClE,oCACF,CAAC;AAEDF,kCAAkC,CAACG,OAAO,CAAEC,OAAO,IAAK;EACtD,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAACF,OAAO,CAAC;EAChC,MAAMG,MAAM,GAAGH,OAAO,CAACI,YAAY,CAAC,+BAA+B,CAAC;EACpE,MAAMC,IAAI,GAAGL,OAAO,CAACI,YAAY,CAAC,WAAW,CAAC;EAC9C,MAAM;IACJE,WAAW;IACXC,OAAO;IACPC,QAAQ;IACRC,MAAM;IACNC,YAAY;IACZC,yBAAyB;IACzBC,yBAAyB;IACzBC,cAAc;IACdC;EACF,CAAC,GAAGC,IAAI,CAACC,KAAK,
|
|
1
|
+
{"version":3,"file":"render.js","names":["_labsWidgetCommon","require","_react","_interopRequireDefault","_client","_graphql","_InstrumentsTableWidget","e","__esModule","default","graphqlUrl","liveRatesUrl","window","widgetsConfig","dataInstrumentsTableParamsElements","document","querySelectorAll","forEach","element","root","createRoot","params","getAttribute","mode","instruments","columns","division","locale","assetClasses","isAssetClassFilterEnabled","isInstrumentSearchEnabled","recordsPerPage","dataSource","priceType","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","length","Object","values","Division","includes","validateLocale","InstrumentDataSource","render","createElement","InstrumentsTableWidget","theme"],"sources":["../../../src/InstrumentsTableWidget/render.tsx"],"sourcesContent":["import type { Theme } from '@oanda/labs-widget-common';\nimport { validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { Division, InstrumentDataSource } from '../gql/types/graphql';\nimport { InstrumentsTableWidget } from './InstrumentsTableWidget';\n\nconst { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};\n\nconst dataInstrumentsTableParamsElements = document.querySelectorAll(\n 'div[data-instruments-table-params]'\n);\n\ndataInstrumentsTableParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-instruments-table-params');\n const mode = element.getAttribute('data-mode');\n const {\n instruments,\n columns,\n division,\n locale,\n assetClasses,\n isAssetClassFilterEnabled,\n isInstrumentSearchEnabled,\n recordsPerPage,\n dataSource,\n priceType,\n } = JSON.parse(params as string);\n\n const isParamError = validateToolParams(\n {\n columns,\n division,\n locale,\n graphqlUrl,\n liveRatesUrl,\n dataSource,\n },\n [\n {\n name: 'columns',\n valueCheck: (value) => (value as string[]).length > 0,\n },\n {\n name: 'division',\n valueCheck: (value: Division) =>\n Object.values(Division).includes(value),\n },\n {\n name: 'locale',\n valueCheck: (value: string | undefined) => validateLocale(value),\n },\n {\n name: 'graphqlUrl',\n },\n {\n name: 'liveRatesUrl',\n },\n {\n name: 'dataSource',\n valueCheck: (value: InstrumentDataSource) =>\n Object.values(InstrumentDataSource).includes(value),\n },\n ]\n );\n\n root.render(\n <InstrumentsTableWidget\n assetClasses={assetClasses}\n columns={columns}\n dataSource={dataSource}\n division={division}\n graphqlUrl={graphqlUrl}\n instruments={instruments}\n isAssetClassFilterEnabled={isAssetClassFilterEnabled}\n isInstrumentSearchEnabled={isInstrumentSearchEnabled}\n isParamError={isParamError}\n liveRatesUrl={liveRatesUrl}\n locale={locale}\n priceType={priceType}\n recordsPerPage={recordsPerPage}\n theme={mode as Theme}\n />\n );\n});\n"],"mappings":";;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,uBAAA,GAAAL,OAAA;AAAkE,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElE,MAAM;EAAEG,UAAU;EAAEC;AAAa,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE/D,MAAMC,kCAAkC,GAAGC,QAAQ,CAACC,gBAAgB,CAClE,oCACF,CAAC;AAEDF,kCAAkC,CAACG,OAAO,CAAEC,OAAO,IAAK;EACtD,MAAMC,IAAI,GAAG,IAAAC,kBAAU,EAACF,OAAO,CAAC;EAChC,MAAMG,MAAM,GAAGH,OAAO,CAACI,YAAY,CAAC,+BAA+B,CAAC;EACpE,MAAMC,IAAI,GAAGL,OAAO,CAACI,YAAY,CAAC,WAAW,CAAC;EAC9C,MAAM;IACJE,WAAW;IACXC,OAAO;IACPC,QAAQ;IACRC,MAAM;IACNC,YAAY;IACZC,yBAAyB;IACzBC,yBAAyB;IACzBC,cAAc;IACdC,UAAU;IACVC;EACF,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACd,MAAgB,CAAC;EAEhC,MAAMe,YAAY,GAAG,IAAAC,oCAAkB,EACrC;IACEZ,OAAO;IACPC,QAAQ;IACRC,MAAM;IACNjB,UAAU;IACVC,YAAY;IACZqB;EACF,CAAC,EACD,CACE;IACEM,IAAI,EAAE,SAAS;IACfC,UAAU,EAAGC,KAAK,IAAMA,KAAK,CAAcC,MAAM,GAAG;EACtD,CAAC,EACD;IACEH,IAAI,EAAE,UAAU;IAChBC,UAAU,EAAGC,KAAe,IAC1BE,MAAM,CAACC,MAAM,CAACC,iBAAQ,CAAC,CAACC,QAAQ,CAACL,KAAK;EAC1C,CAAC,EACD;IACEF,IAAI,EAAE,QAAQ;IACdC,UAAU,EAAGC,KAAyB,IAAK,IAAAM,gCAAc,EAACN,KAAK;EACjE,CAAC,EACD;IACEF,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE,YAAY;IAClBC,UAAU,EAAGC,KAA2B,IACtCE,MAAM,CAACC,MAAM,CAACI,6BAAoB,CAAC,CAACF,QAAQ,CAACL,KAAK;EACtD,CAAC,CAEL,CAAC;EAEDrB,IAAI,CAAC6B,MAAM,CACT9C,MAAA,CAAAO,OAAA,CAAAwC,aAAA,CAAC3C,uBAAA,CAAA4C,sBAAsB;IACrBtB,YAAY,EAAEA,YAAa;IAC3BH,OAAO,EAAEA,OAAQ;IACjBO,UAAU,EAAEA,UAAW;IACvBN,QAAQ,EAAEA,QAAS;IACnBhB,UAAU,EAAEA,UAAW;IACvBc,WAAW,EAAEA,WAAY;IACzBK,yBAAyB,EAAEA,yBAA0B;IACrDC,yBAAyB,EAAEA,yBAA0B;IACrDM,YAAY,EAAEA,YAAa;IAC3BzB,YAAY,EAAEA,YAAa;IAC3BgB,MAAM,EAAEA,MAAO;IACfM,SAAS,EAAEA,SAAU;IACrBF,cAAc,EAAEA,cAAe;IAC/BoB,KAAK,EAAE5B;EAAc,CACtB,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -3,4 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.PriceType = void 0;
|
|
7
|
+
let PriceType = exports.PriceType = function (PriceType) {
|
|
8
|
+
PriceType["Raw"] = "raw";
|
|
9
|
+
PriceType["Division"] = "division";
|
|
10
|
+
return PriceType;
|
|
11
|
+
}({});
|
|
6
12
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/InstrumentsTableWidget/types.ts"],"sourcesContent":["import type { DataRecordType, WidgetConfig } from '@oanda/labs-widget-common';\n\nimport type { Division, InstrumentDataSource } from '../gql/types/graphql';\n\nexport interface InstrumentsTableConfig extends WidgetConfig {\n liveRatesUrl: string;\n instruments?: string[];\n division: Division;\n columns?: DataRecordType[];\n assetClasses?: string[];\n isAssetClassFilterEnabled?: boolean;\n isInstrumentSearchEnabled?: boolean;\n recordsPerPage?: number;\n dataSource: InstrumentDataSource;\n}\n\nexport interface MainProps {\n instruments?: string[];\n division: Division;\n columns?: DataRecordType[];\n assetClasses?: string[];\n isAssetClassFilterEnabled?: boolean;\n isInstrumentSearchEnabled?: boolean;\n recordsPerPage?: number;\n dataSource: InstrumentDataSource;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":["PriceType","exports"],"sources":["../../../src/InstrumentsTableWidget/types.ts"],"sourcesContent":["import type { DataRecordType, WidgetConfig } from '@oanda/labs-widget-common';\n\nimport type { Division, InstrumentDataSource } from '../gql/types/graphql';\n\nexport enum PriceType {\n Raw = 'raw',\n Division = 'division',\n}\n\nexport interface InstrumentsTableConfig extends WidgetConfig {\n liveRatesUrl: string;\n instruments?: string[];\n division: Division;\n columns?: DataRecordType[];\n assetClasses?: string[];\n isAssetClassFilterEnabled?: boolean;\n isInstrumentSearchEnabled?: boolean;\n recordsPerPage?: number;\n dataSource: InstrumentDataSource;\n priceType?: PriceType;\n}\n\nexport interface MainProps {\n instruments?: string[];\n division: Division;\n columns?: DataRecordType[];\n assetClasses?: string[];\n isAssetClassFilterEnabled?: boolean;\n isInstrumentSearchEnabled?: boolean;\n recordsPerPage?: number;\n dataSource: InstrumentDataSource;\n}\n"],"mappings":";;;;;;IAIYA,SAAS,GAAAC,OAAA,CAAAD,SAAA,aAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAAA,OAATA,SAAS;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getLiveRatesDivisionCode = void 0;
|
|
7
|
+
var _graphql = require("../gql/types/graphql");
|
|
8
|
+
var _types = require("./types");
|
|
9
|
+
const getLiveRatesDivisionCode = (division, priceType, dataSource) => {
|
|
10
|
+
const divisionMap = {
|
|
11
|
+
[_types.PriceType.Raw]: {
|
|
12
|
+
[_graphql.InstrumentDataSource.Mt5]: _graphql.Division.Oc,
|
|
13
|
+
[_graphql.InstrumentDataSource.V20]: 'MKTD'
|
|
14
|
+
},
|
|
15
|
+
[_types.PriceType.Division]: {
|
|
16
|
+
[_graphql.InstrumentDataSource.Mt5]: division,
|
|
17
|
+
[_graphql.InstrumentDataSource.V20]: division
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return divisionMap[priceType]?.[dataSource];
|
|
21
|
+
};
|
|
22
|
+
exports.getLiveRatesDivisionCode = getLiveRatesDivisionCode;
|
|
23
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["_graphql","require","_types","getLiveRatesDivisionCode","division","priceType","dataSource","divisionMap","PriceType","Raw","InstrumentDataSource","Mt5","Division","Oc","V20","exports"],"sources":["../../../src/InstrumentsTableWidget/utils.ts"],"sourcesContent":["import { Division, InstrumentDataSource } from '../gql/types/graphql';\nimport { PriceType } from './types';\n\nconst getLiveRatesDivisionCode = (\n division: Division,\n priceType: PriceType,\n dataSource: InstrumentDataSource\n): Division | string | undefined => {\n const divisionMap = {\n [PriceType.Raw]: {\n [InstrumentDataSource.Mt5]: Division.Oc,\n [InstrumentDataSource.V20]: 'MKTD',\n },\n [PriceType.Division]: {\n [InstrumentDataSource.Mt5]: division,\n [InstrumentDataSource.V20]: division,\n },\n };\n return divisionMap[priceType]?.[dataSource];\n};\n\nexport { getLiveRatesDivisionCode };\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,MAAME,wBAAwB,GAAGA,CAC/BC,QAAkB,EAClBC,SAAoB,EACpBC,UAAgC,KACE;EAClC,MAAMC,WAAW,GAAG;IAClB,CAACC,gBAAS,CAACC,GAAG,GAAG;MACf,CAACC,6BAAoB,CAACC,GAAG,GAAGC,iBAAQ,CAACC,EAAE;MACvC,CAACH,6BAAoB,CAACI,GAAG,GAAG;IAC9B,CAAC;IACD,CAACN,gBAAS,CAACI,QAAQ,GAAG;MACpB,CAACF,6BAAoB,CAACC,GAAG,GAAGP,QAAQ;MACpC,CAACM,6BAAoB,CAACI,GAAG,GAAGV;IAC9B;EACF,CAAC;EACD,OAAOG,WAAW,CAACF,SAAS,CAAC,GAAGC,UAAU,CAAC;AAC7C,CAAC;AAACS,OAAA,CAAAZ,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
|
2
2
|
import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { Division } from '../gql/types/graphql';
|
|
5
4
|
import { translations } from '../translations';
|
|
6
5
|
import { Main } from './Main';
|
|
6
|
+
import { PriceType } from './types';
|
|
7
|
+
import { getLiveRatesDivisionCode } from './utils';
|
|
7
8
|
const InstrumentsTableWidget = _ref => {
|
|
8
9
|
let {
|
|
9
10
|
division,
|
|
@@ -19,13 +20,14 @@ const InstrumentsTableWidget = _ref => {
|
|
|
19
20
|
isAssetClassFilterEnabled,
|
|
20
21
|
isInstrumentSearchEnabled,
|
|
21
22
|
recordsPerPage,
|
|
22
|
-
dataSource
|
|
23
|
+
dataSource,
|
|
24
|
+
priceType = PriceType.Division
|
|
23
25
|
} = _ref;
|
|
24
26
|
const client = new ApolloClient({
|
|
25
27
|
uri: graphqlUrl,
|
|
26
28
|
cache: new InMemoryCache()
|
|
27
29
|
});
|
|
28
|
-
const divisionCode = division
|
|
30
|
+
const divisionCode = getLiveRatesDivisionCode(division, priceType, dataSource);
|
|
29
31
|
return React.createElement(WidgetProvider, {
|
|
30
32
|
client: client,
|
|
31
33
|
liveRates: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InstrumentsTableWidget.js","names":["ApolloClient","InMemoryCache","WidgetProvider","WidgetWrapper","React","
|
|
1
|
+
{"version":3,"file":"InstrumentsTableWidget.js","names":["ApolloClient","InMemoryCache","WidgetProvider","WidgetWrapper","React","translations","Main","PriceType","getLiveRatesDivisionCode","InstrumentsTableWidget","_ref","division","instruments","columns","graphqlUrl","locale","theme","isParamError","logoLink","liveRatesUrl","assetClasses","isAssetClassFilterEnabled","isInstrumentSearchEnabled","recordsPerPage","dataSource","priceType","Division","client","uri","cache","divisionCode","createElement","liveRates","url","options","linkArea"],"sources":["../../../src/InstrumentsTableWidget/InstrumentsTableWidget.tsx"],"sourcesContent":["import { ApolloClient, InMemoryCache } from '@apollo/client';\nimport { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport { translations } from '../translations';\nimport { Main } from './Main';\nimport { type InstrumentsTableConfig, PriceType } from './types';\nimport { getLiveRatesDivisionCode } from './utils';\n\nconst InstrumentsTableWidget = ({\n division,\n instruments,\n columns,\n graphqlUrl,\n locale,\n theme,\n isParamError,\n logoLink,\n liveRatesUrl,\n assetClasses,\n isAssetClassFilterEnabled,\n isInstrumentSearchEnabled,\n recordsPerPage,\n dataSource,\n priceType = PriceType.Division,\n}: InstrumentsTableConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n const divisionCode = getLiveRatesDivisionCode(\n division,\n priceType,\n dataSource\n );\n\n return (\n <WidgetProvider\n client={client}\n liveRates={{\n url: liveRatesUrl,\n options: { divisionCode, dataSource },\n }}\n locale={locale}\n theme={theme}\n translations={translations}\n >\n <WidgetWrapper\n isParamError={isParamError}\n linkArea=\"logo\"\n logoLink={logoLink}\n >\n <Main\n assetClasses={assetClasses}\n columns={columns}\n dataSource={dataSource}\n division={division}\n instruments={instruments}\n isAssetClassFilterEnabled={isAssetClassFilterEnabled}\n isInstrumentSearchEnabled={isInstrumentSearchEnabled}\n recordsPerPage={recordsPerPage}\n />\n </WidgetWrapper>\n </WidgetProvider>\n );\n};\n\nexport { InstrumentsTableWidget };\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,aAAa,QAAQ,gBAAgB;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,2BAA2B;AACzE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,IAAI,QAAQ,QAAQ;AAC7B,SAAsCC,SAAS,QAAQ,SAAS;AAChE,SAASC,wBAAwB,QAAQ,SAAS;AAElD,MAAMC,sBAAsB,GAAGC,IAAA,IAgBD;EAAA,IAhBE;IAC9BC,QAAQ;IACRC,WAAW;IACXC,OAAO;IACPC,UAAU;IACVC,MAAM;IACNC,KAAK;IACLC,YAAY;IACZC,QAAQ;IACRC,YAAY;IACZC,YAAY;IACZC,yBAAyB;IACzBC,yBAAyB;IACzBC,cAAc;IACdC,UAAU;IACVC,SAAS,GAAGlB,SAAS,CAACmB;EACA,CAAC,GAAAhB,IAAA;EACvB,MAAMiB,MAAM,GAAG,IAAI3B,YAAY,CAAC;IAC9B4B,GAAG,EAAEd,UAAU;IACfe,KAAK,EAAE,IAAI5B,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAM6B,YAAY,GAAGtB,wBAAwB,CAC3CG,QAAQ,EACRc,SAAS,EACTD,UACF,CAAC;EAED,OACEpB,KAAA,CAAA2B,aAAA,CAAC7B,cAAc;IACbyB,MAAM,EAAEA,MAAO;IACfK,SAAS,EAAE;MACTC,GAAG,EAAEd,YAAY;MACjBe,OAAO,EAAE;QAAEJ,YAAY;QAAEN;MAAW;IACtC,CAAE;IACFT,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEA,KAAM;IACbX,YAAY,EAAEA;EAAa,GAE3BD,KAAA,CAAA2B,aAAA,CAAC5B,aAAa;IACZc,YAAY,EAAEA,YAAa;IAC3BkB,QAAQ,EAAC,MAAM;IACfjB,QAAQ,EAAEA;EAAS,GAEnBd,KAAA,CAAA2B,aAAA,CAACzB,IAAI;IACHc,YAAY,EAAEA,YAAa;IAC3BP,OAAO,EAAEA,OAAQ;IACjBW,UAAU,EAAEA,UAAW;IACvBb,QAAQ,EAAEA,QAAS;IACnBC,WAAW,EAAEA,WAAY;IACzBS,yBAAyB,EAAEA,yBAA0B;IACrDC,yBAAyB,EAAEA,yBAA0B;IACrDC,cAAc,EAAEA;EAAe,CAChC,CACY,CACD,CAAC;AAErB,CAAC;AAED,SAASd,sBAAsB","ignoreList":[]}
|
|
@@ -21,7 +21,8 @@ dataInstrumentsTableParamsElements.forEach(element => {
|
|
|
21
21
|
isAssetClassFilterEnabled,
|
|
22
22
|
isInstrumentSearchEnabled,
|
|
23
23
|
recordsPerPage,
|
|
24
|
-
dataSource
|
|
24
|
+
dataSource,
|
|
25
|
+
priceType
|
|
25
26
|
} = JSON.parse(params);
|
|
26
27
|
const isParamError = validateToolParams({
|
|
27
28
|
columns,
|
|
@@ -59,6 +60,7 @@ dataInstrumentsTableParamsElements.forEach(element => {
|
|
|
59
60
|
isParamError: isParamError,
|
|
60
61
|
liveRatesUrl: liveRatesUrl,
|
|
61
62
|
locale: locale,
|
|
63
|
+
priceType: priceType,
|
|
62
64
|
recordsPerPage: recordsPerPage,
|
|
63
65
|
theme: mode
|
|
64
66
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["validateLocale","validateToolParams","React","createRoot","Division","InstrumentDataSource","InstrumentsTableWidget","graphqlUrl","liveRatesUrl","window","widgetsConfig","dataInstrumentsTableParamsElements","document","querySelectorAll","forEach","element","root","params","getAttribute","mode","instruments","columns","division","locale","assetClasses","isAssetClassFilterEnabled","isInstrumentSearchEnabled","recordsPerPage","dataSource","JSON","parse","isParamError","name","valueCheck","value","length","Object","values","includes","render","createElement","theme"],"sources":["../../../src/InstrumentsTableWidget/render.tsx"],"sourcesContent":["import type { Theme } from '@oanda/labs-widget-common';\nimport { validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { Division, InstrumentDataSource } from '../gql/types/graphql';\nimport { InstrumentsTableWidget } from './InstrumentsTableWidget';\n\nconst { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};\n\nconst dataInstrumentsTableParamsElements = document.querySelectorAll(\n 'div[data-instruments-table-params]'\n);\n\ndataInstrumentsTableParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-instruments-table-params');\n const mode = element.getAttribute('data-mode');\n const {\n instruments,\n columns,\n division,\n locale,\n assetClasses,\n isAssetClassFilterEnabled,\n isInstrumentSearchEnabled,\n recordsPerPage,\n dataSource,\n } = JSON.parse(params as string);\n\n const isParamError = validateToolParams(\n {\n columns,\n division,\n locale,\n graphqlUrl,\n liveRatesUrl,\n dataSource,\n },\n [\n {\n name: 'columns',\n valueCheck: (value) => (value as string[]).length > 0,\n },\n {\n name: 'division',\n valueCheck: (value: Division) =>\n Object.values(Division).includes(value),\n },\n {\n name: 'locale',\n valueCheck: (value: string | undefined) => validateLocale(value),\n },\n {\n name: 'graphqlUrl',\n },\n {\n name: 'liveRatesUrl',\n },\n {\n name: 'dataSource',\n valueCheck: (value: InstrumentDataSource) =>\n Object.values(InstrumentDataSource).includes(value),\n },\n ]\n );\n\n root.render(\n <InstrumentsTableWidget\n assetClasses={assetClasses}\n columns={columns}\n dataSource={dataSource}\n division={division}\n graphqlUrl={graphqlUrl}\n instruments={instruments}\n isAssetClassFilterEnabled={isAssetClassFilterEnabled}\n isInstrumentSearchEnabled={isInstrumentSearchEnabled}\n isParamError={isParamError}\n liveRatesUrl={liveRatesUrl}\n locale={locale}\n recordsPerPage={recordsPerPage}\n theme={mode as Theme}\n />\n );\n});\n"],"mappings":"AACA,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,2BAA2B;AAC9E,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,SAASC,QAAQ,EAAEC,oBAAoB,QAAQ,sBAAsB;AACrE,SAASC,sBAAsB,QAAQ,0BAA0B;AAEjE,MAAM;EAAEC,UAAU;EAAEC;AAAa,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE/D,MAAMC,kCAAkC,GAAGC,QAAQ,CAACC,gBAAgB,CAClE,oCACF,CAAC;AAEDF,kCAAkC,CAACG,OAAO,CAAEC,OAAO,IAAK;EACtD,MAAMC,IAAI,GAAGb,UAAU,CAACY,OAAO,CAAC;EAChC,MAAME,MAAM,GAAGF,OAAO,CAACG,YAAY,CAAC,+BAA+B,CAAC;EACpE,MAAMC,IAAI,GAAGJ,OAAO,CAACG,YAAY,CAAC,WAAW,CAAC;EAC9C,MAAM;IACJE,WAAW;IACXC,OAAO;IACPC,QAAQ;IACRC,MAAM;IACNC,YAAY;IACZC,yBAAyB;IACzBC,yBAAyB;IACzBC,cAAc;IACdC;EACF,CAAC,GAAGC,IAAI,CAACC,KAAK,
|
|
1
|
+
{"version":3,"file":"render.js","names":["validateLocale","validateToolParams","React","createRoot","Division","InstrumentDataSource","InstrumentsTableWidget","graphqlUrl","liveRatesUrl","window","widgetsConfig","dataInstrumentsTableParamsElements","document","querySelectorAll","forEach","element","root","params","getAttribute","mode","instruments","columns","division","locale","assetClasses","isAssetClassFilterEnabled","isInstrumentSearchEnabled","recordsPerPage","dataSource","priceType","JSON","parse","isParamError","name","valueCheck","value","length","Object","values","includes","render","createElement","theme"],"sources":["../../../src/InstrumentsTableWidget/render.tsx"],"sourcesContent":["import type { Theme } from '@oanda/labs-widget-common';\nimport { validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { Division, InstrumentDataSource } from '../gql/types/graphql';\nimport { InstrumentsTableWidget } from './InstrumentsTableWidget';\n\nconst { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};\n\nconst dataInstrumentsTableParamsElements = document.querySelectorAll(\n 'div[data-instruments-table-params]'\n);\n\ndataInstrumentsTableParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-instruments-table-params');\n const mode = element.getAttribute('data-mode');\n const {\n instruments,\n columns,\n division,\n locale,\n assetClasses,\n isAssetClassFilterEnabled,\n isInstrumentSearchEnabled,\n recordsPerPage,\n dataSource,\n priceType,\n } = JSON.parse(params as string);\n\n const isParamError = validateToolParams(\n {\n columns,\n division,\n locale,\n graphqlUrl,\n liveRatesUrl,\n dataSource,\n },\n [\n {\n name: 'columns',\n valueCheck: (value) => (value as string[]).length > 0,\n },\n {\n name: 'division',\n valueCheck: (value: Division) =>\n Object.values(Division).includes(value),\n },\n {\n name: 'locale',\n valueCheck: (value: string | undefined) => validateLocale(value),\n },\n {\n name: 'graphqlUrl',\n },\n {\n name: 'liveRatesUrl',\n },\n {\n name: 'dataSource',\n valueCheck: (value: InstrumentDataSource) =>\n Object.values(InstrumentDataSource).includes(value),\n },\n ]\n );\n\n root.render(\n <InstrumentsTableWidget\n assetClasses={assetClasses}\n columns={columns}\n dataSource={dataSource}\n division={division}\n graphqlUrl={graphqlUrl}\n instruments={instruments}\n isAssetClassFilterEnabled={isAssetClassFilterEnabled}\n isInstrumentSearchEnabled={isInstrumentSearchEnabled}\n isParamError={isParamError}\n liveRatesUrl={liveRatesUrl}\n locale={locale}\n priceType={priceType}\n recordsPerPage={recordsPerPage}\n theme={mode as Theme}\n />\n );\n});\n"],"mappings":"AACA,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,2BAA2B;AAC9E,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,SAASC,QAAQ,EAAEC,oBAAoB,QAAQ,sBAAsB;AACrE,SAASC,sBAAsB,QAAQ,0BAA0B;AAEjE,MAAM;EAAEC,UAAU;EAAEC;AAAa,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE/D,MAAMC,kCAAkC,GAAGC,QAAQ,CAACC,gBAAgB,CAClE,oCACF,CAAC;AAEDF,kCAAkC,CAACG,OAAO,CAAEC,OAAO,IAAK;EACtD,MAAMC,IAAI,GAAGb,UAAU,CAACY,OAAO,CAAC;EAChC,MAAME,MAAM,GAAGF,OAAO,CAACG,YAAY,CAAC,+BAA+B,CAAC;EACpE,MAAMC,IAAI,GAAGJ,OAAO,CAACG,YAAY,CAAC,WAAW,CAAC;EAC9C,MAAM;IACJE,WAAW;IACXC,OAAO;IACPC,QAAQ;IACRC,MAAM;IACNC,YAAY;IACZC,yBAAyB;IACzBC,yBAAyB;IACzBC,cAAc;IACdC,UAAU;IACVC;EACF,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACd,MAAgB,CAAC;EAEhC,MAAMe,YAAY,GAAG/B,kBAAkB,CACrC;IACEoB,OAAO;IACPC,QAAQ;IACRC,MAAM;IACNhB,UAAU;IACVC,YAAY;IACZoB;EACF,CAAC,EACD,CACE;IACEK,IAAI,EAAE,SAAS;IACfC,UAAU,EAAGC,KAAK,IAAMA,KAAK,CAAcC,MAAM,GAAG;EACtD,CAAC,EACD;IACEH,IAAI,EAAE,UAAU;IAChBC,UAAU,EAAGC,KAAe,IAC1BE,MAAM,CAACC,MAAM,CAAClC,QAAQ,CAAC,CAACmC,QAAQ,CAACJ,KAAK;EAC1C,CAAC,EACD;IACEF,IAAI,EAAE,QAAQ;IACdC,UAAU,EAAGC,KAAyB,IAAKnC,cAAc,CAACmC,KAAK;EACjE,CAAC,EACD;IACEF,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE,YAAY;IAClBC,UAAU,EAAGC,KAA2B,IACtCE,MAAM,CAACC,MAAM,CAACjC,oBAAoB,CAAC,CAACkC,QAAQ,CAACJ,KAAK;EACtD,CAAC,CAEL,CAAC;EAEDnB,IAAI,CAACwB,MAAM,CACTtC,KAAA,CAAAuC,aAAA,CAACnC,sBAAsB;IACrBkB,YAAY,EAAEA,YAAa;IAC3BH,OAAO,EAAEA,OAAQ;IACjBO,UAAU,EAAEA,UAAW;IACvBN,QAAQ,EAAEA,QAAS;IACnBf,UAAU,EAAEA,UAAW;IACvBa,WAAW,EAAEA,WAAY;IACzBK,yBAAyB,EAAEA,yBAA0B;IACrDC,yBAAyB,EAAEA,yBAA0B;IACrDM,YAAY,EAAEA,YAAa;IAC3BxB,YAAY,EAAEA,YAAa;IAC3Be,MAAM,EAAEA,MAAO;IACfM,SAAS,EAAEA,SAAU;IACrBF,cAAc,EAAEA,cAAe;IAC/Be,KAAK,EAAEvB;EAAc,CACtB,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/InstrumentsTableWidget/types.ts"],"sourcesContent":["import type { DataRecordType, WidgetConfig } from '@oanda/labs-widget-common';\n\nimport type { Division, InstrumentDataSource } from '../gql/types/graphql';\n\nexport interface InstrumentsTableConfig extends WidgetConfig {\n liveRatesUrl: string;\n instruments?: string[];\n division: Division;\n columns?: DataRecordType[];\n assetClasses?: string[];\n isAssetClassFilterEnabled?: boolean;\n isInstrumentSearchEnabled?: boolean;\n recordsPerPage?: number;\n dataSource: InstrumentDataSource;\n}\n\nexport interface MainProps {\n instruments?: string[];\n division: Division;\n columns?: DataRecordType[];\n assetClasses?: string[];\n isAssetClassFilterEnabled?: boolean;\n isInstrumentSearchEnabled?: boolean;\n recordsPerPage?: number;\n dataSource: InstrumentDataSource;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":["PriceType"],"sources":["../../../src/InstrumentsTableWidget/types.ts"],"sourcesContent":["import type { DataRecordType, WidgetConfig } from '@oanda/labs-widget-common';\n\nimport type { Division, InstrumentDataSource } from '../gql/types/graphql';\n\nexport enum PriceType {\n Raw = 'raw',\n Division = 'division',\n}\n\nexport interface InstrumentsTableConfig extends WidgetConfig {\n liveRatesUrl: string;\n instruments?: string[];\n division: Division;\n columns?: DataRecordType[];\n assetClasses?: string[];\n isAssetClassFilterEnabled?: boolean;\n isInstrumentSearchEnabled?: boolean;\n recordsPerPage?: number;\n dataSource: InstrumentDataSource;\n priceType?: PriceType;\n}\n\nexport interface MainProps {\n instruments?: string[];\n division: Division;\n columns?: DataRecordType[];\n assetClasses?: string[];\n isAssetClassFilterEnabled?: boolean;\n isInstrumentSearchEnabled?: boolean;\n recordsPerPage?: number;\n dataSource: InstrumentDataSource;\n}\n"],"mappings":"AAIA,WAAYA,SAAS,aAATA,SAAS;EAATA,SAAS;EAATA,SAAS;EAAA,OAATA,SAAS;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Division, InstrumentDataSource } from '../gql/types/graphql';
|
|
2
|
+
import { PriceType } from './types';
|
|
3
|
+
const getLiveRatesDivisionCode = (division, priceType, dataSource) => {
|
|
4
|
+
const divisionMap = {
|
|
5
|
+
[PriceType.Raw]: {
|
|
6
|
+
[InstrumentDataSource.Mt5]: Division.Oc,
|
|
7
|
+
[InstrumentDataSource.V20]: 'MKTD'
|
|
8
|
+
},
|
|
9
|
+
[PriceType.Division]: {
|
|
10
|
+
[InstrumentDataSource.Mt5]: division,
|
|
11
|
+
[InstrumentDataSource.V20]: division
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
return divisionMap[priceType]?.[dataSource];
|
|
15
|
+
};
|
|
16
|
+
export { getLiveRatesDivisionCode };
|
|
17
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["Division","InstrumentDataSource","PriceType","getLiveRatesDivisionCode","division","priceType","dataSource","divisionMap","Raw","Mt5","Oc","V20"],"sources":["../../../src/InstrumentsTableWidget/utils.ts"],"sourcesContent":["import { Division, InstrumentDataSource } from '../gql/types/graphql';\nimport { PriceType } from './types';\n\nconst getLiveRatesDivisionCode = (\n division: Division,\n priceType: PriceType,\n dataSource: InstrumentDataSource\n): Division | string | undefined => {\n const divisionMap = {\n [PriceType.Raw]: {\n [InstrumentDataSource.Mt5]: Division.Oc,\n [InstrumentDataSource.V20]: 'MKTD',\n },\n [PriceType.Division]: {\n [InstrumentDataSource.Mt5]: division,\n [InstrumentDataSource.V20]: division,\n },\n };\n return divisionMap[priceType]?.[dataSource];\n};\n\nexport { getLiveRatesDivisionCode };\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,oBAAoB,QAAQ,sBAAsB;AACrE,SAASC,SAAS,QAAQ,SAAS;AAEnC,MAAMC,wBAAwB,GAAGA,CAC/BC,QAAkB,EAClBC,SAAoB,EACpBC,UAAgC,KACE;EAClC,MAAMC,WAAW,GAAG;IAClB,CAACL,SAAS,CAACM,GAAG,GAAG;MACf,CAACP,oBAAoB,CAACQ,GAAG,GAAGT,QAAQ,CAACU,EAAE;MACvC,CAACT,oBAAoB,CAACU,GAAG,GAAG;IAC9B,CAAC;IACD,CAACT,SAAS,CAACF,QAAQ,GAAG;MACpB,CAACC,oBAAoB,CAACQ,GAAG,GAAGL,QAAQ;MACpC,CAACH,oBAAoB,CAACU,GAAG,GAAGP;IAC9B;EACF,CAAC;EACD,OAAOG,WAAW,CAACF,SAAS,CAAC,GAAGC,UAAU,CAAC;AAC7C,CAAC;AAED,SAASH,wBAAwB","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type
|
|
3
|
-
declare const InstrumentsTableWidget: ({ division, instruments, columns, graphqlUrl, locale, theme, isParamError, logoLink, liveRatesUrl, assetClasses, isAssetClassFilterEnabled, isInstrumentSearchEnabled, recordsPerPage, dataSource, }: InstrumentsTableConfig) => React.JSX.Element;
|
|
2
|
+
import { type InstrumentsTableConfig } from './types';
|
|
3
|
+
declare const InstrumentsTableWidget: ({ division, instruments, columns, graphqlUrl, locale, theme, isParamError, logoLink, liveRatesUrl, assetClasses, isAssetClassFilterEnabled, isInstrumentSearchEnabled, recordsPerPage, dataSource, priceType, }: InstrumentsTableConfig) => React.JSX.Element;
|
|
4
4
|
export { InstrumentsTableWidget };
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { DataRecordType, WidgetConfig } from '@oanda/labs-widget-common';
|
|
2
2
|
import type { Division, InstrumentDataSource } from '../gql/types/graphql';
|
|
3
|
+
export declare enum PriceType {
|
|
4
|
+
Raw = "raw",
|
|
5
|
+
Division = "division"
|
|
6
|
+
}
|
|
3
7
|
export interface InstrumentsTableConfig extends WidgetConfig {
|
|
4
8
|
liveRatesUrl: string;
|
|
5
9
|
instruments?: string[];
|
|
@@ -10,6 +14,7 @@ export interface InstrumentsTableConfig extends WidgetConfig {
|
|
|
10
14
|
isInstrumentSearchEnabled?: boolean;
|
|
11
15
|
recordsPerPage?: number;
|
|
12
16
|
dataSource: InstrumentDataSource;
|
|
17
|
+
priceType?: PriceType;
|
|
13
18
|
}
|
|
14
19
|
export interface MainProps {
|
|
15
20
|
instruments?: string[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Division, InstrumentDataSource } from '../gql/types/graphql';
|
|
2
|
+
import { PriceType } from './types';
|
|
3
|
+
declare const getLiveRatesDivisionCode: (division: Division, priceType: PriceType, dataSource: InstrumentDataSource) => Division | string | undefined;
|
|
4
|
+
export { getLiveRatesDivisionCode };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oanda/labs-instruments-table-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"description": "Labs Instruments Table 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.200",
|
|
16
16
|
"@oanda/mono-i18n": "10.0.1",
|
|
17
17
|
"graphql": "16.8.1"
|
|
18
18
|
},
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"@graphql-codegen/cli": "5.0.0",
|
|
21
21
|
"@graphql-codegen/client-preset": "4.1.0"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "343ba4fef9b87385c70127b417107e91e1ebaab3"
|
|
24
24
|
}
|
|
@@ -2,10 +2,10 @@ import { ApolloClient, InMemoryCache } from '@apollo/client';
|
|
|
2
2
|
import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
|
|
5
|
-
import { Division } from '../gql/types/graphql';
|
|
6
5
|
import { translations } from '../translations';
|
|
7
6
|
import { Main } from './Main';
|
|
8
|
-
import type
|
|
7
|
+
import { type InstrumentsTableConfig, PriceType } from './types';
|
|
8
|
+
import { getLiveRatesDivisionCode } from './utils';
|
|
9
9
|
|
|
10
10
|
const InstrumentsTableWidget = ({
|
|
11
11
|
division,
|
|
@@ -22,13 +22,18 @@ const InstrumentsTableWidget = ({
|
|
|
22
22
|
isInstrumentSearchEnabled,
|
|
23
23
|
recordsPerPage,
|
|
24
24
|
dataSource,
|
|
25
|
+
priceType = PriceType.Division,
|
|
25
26
|
}: InstrumentsTableConfig) => {
|
|
26
27
|
const client = new ApolloClient({
|
|
27
28
|
uri: graphqlUrl,
|
|
28
29
|
cache: new InMemoryCache(),
|
|
29
30
|
});
|
|
30
31
|
|
|
31
|
-
const divisionCode =
|
|
32
|
+
const divisionCode = getLiveRatesDivisionCode(
|
|
33
|
+
division,
|
|
34
|
+
priceType,
|
|
35
|
+
dataSource
|
|
36
|
+
);
|
|
32
37
|
|
|
33
38
|
return (
|
|
34
39
|
<WidgetProvider
|
|
@@ -26,6 +26,7 @@ dataInstrumentsTableParamsElements.forEach((element) => {
|
|
|
26
26
|
isInstrumentSearchEnabled,
|
|
27
27
|
recordsPerPage,
|
|
28
28
|
dataSource,
|
|
29
|
+
priceType,
|
|
29
30
|
} = JSON.parse(params as string);
|
|
30
31
|
|
|
31
32
|
const isParamError = validateToolParams(
|
|
@@ -78,6 +79,7 @@ dataInstrumentsTableParamsElements.forEach((element) => {
|
|
|
78
79
|
isParamError={isParamError}
|
|
79
80
|
liveRatesUrl={liveRatesUrl}
|
|
80
81
|
locale={locale}
|
|
82
|
+
priceType={priceType}
|
|
81
83
|
recordsPerPage={recordsPerPage}
|
|
82
84
|
theme={mode as Theme}
|
|
83
85
|
/>
|
|
@@ -2,6 +2,11 @@ import type { DataRecordType, WidgetConfig } from '@oanda/labs-widget-common';
|
|
|
2
2
|
|
|
3
3
|
import type { Division, InstrumentDataSource } from '../gql/types/graphql';
|
|
4
4
|
|
|
5
|
+
export enum PriceType {
|
|
6
|
+
Raw = 'raw',
|
|
7
|
+
Division = 'division',
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
export interface InstrumentsTableConfig extends WidgetConfig {
|
|
6
11
|
liveRatesUrl: string;
|
|
7
12
|
instruments?: string[];
|
|
@@ -12,6 +17,7 @@ export interface InstrumentsTableConfig extends WidgetConfig {
|
|
|
12
17
|
isInstrumentSearchEnabled?: boolean;
|
|
13
18
|
recordsPerPage?: number;
|
|
14
19
|
dataSource: InstrumentDataSource;
|
|
20
|
+
priceType?: PriceType;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
export interface MainProps {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Division, InstrumentDataSource } from '../gql/types/graphql';
|
|
2
|
+
import { PriceType } from './types';
|
|
3
|
+
|
|
4
|
+
const getLiveRatesDivisionCode = (
|
|
5
|
+
division: Division,
|
|
6
|
+
priceType: PriceType,
|
|
7
|
+
dataSource: InstrumentDataSource
|
|
8
|
+
): Division | string | undefined => {
|
|
9
|
+
const divisionMap = {
|
|
10
|
+
[PriceType.Raw]: {
|
|
11
|
+
[InstrumentDataSource.Mt5]: Division.Oc,
|
|
12
|
+
[InstrumentDataSource.V20]: 'MKTD',
|
|
13
|
+
},
|
|
14
|
+
[PriceType.Division]: {
|
|
15
|
+
[InstrumentDataSource.Mt5]: division,
|
|
16
|
+
[InstrumentDataSource.V20]: division,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
return divisionMap[priceType]?.[dataSource];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { getLiveRatesDivisionCode };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PriceType } from '../src';
|
|
2
|
+
import { Division, InstrumentDataSource } from '../src/gql/types/graphql';
|
|
3
|
+
import { getLiveRatesDivisionCode } from '../src/InstrumentsTableWidget/utils';
|
|
4
|
+
|
|
5
|
+
describe('getLiveRatesDivisionCode', () => {
|
|
6
|
+
it('should return Division.Oc for PriceType.Raw and InstrumentDataSource.Mt5', () => {
|
|
7
|
+
const division = Division.Oc;
|
|
8
|
+
const priceType = PriceType.Raw;
|
|
9
|
+
const dataSource = InstrumentDataSource.Mt5;
|
|
10
|
+
expect(getLiveRatesDivisionCode(division, priceType, dataSource)).toBe(
|
|
11
|
+
Division.Oc
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should return "MKTD" for PriceType.Raw and InstrumentDataSource.V20', () => {
|
|
16
|
+
const division = Division.Oc;
|
|
17
|
+
const priceType = PriceType.Raw;
|
|
18
|
+
const dataSource = InstrumentDataSource.V20;
|
|
19
|
+
expect(getLiveRatesDivisionCode(division, priceType, dataSource)).toBe(
|
|
20
|
+
'MKTD'
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should return the division for PriceType.Division', () => {
|
|
25
|
+
const division = Division.Oc;
|
|
26
|
+
const priceType = PriceType.Division;
|
|
27
|
+
const dataSource = InstrumentDataSource.Mt5;
|
|
28
|
+
expect(getLiveRatesDivisionCode(division, priceType, dataSource)).toBe(
|
|
29
|
+
Division.Oc
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
});
|