@oanda/labs-currency-cross-table 1.0.6 → 1.0.8

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.
Files changed (97) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/codegen.ts +15 -0
  3. package/dist/main/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js +12 -4
  4. package/dist/main/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js.map +1 -1
  5. package/dist/main/CurrencyCrossTableWidget/Main.js +19 -17
  6. package/dist/main/CurrencyCrossTableWidget/Main.js.map +1 -1
  7. package/dist/main/CurrencyCrossTableWidget/ValidationWrapper.js +2 -1
  8. package/dist/main/CurrencyCrossTableWidget/ValidationWrapper.js.map +1 -1
  9. package/dist/main/CurrencyCrossTableWidget/components/Cell.js +2 -4
  10. package/dist/main/CurrencyCrossTableWidget/components/Cell.js.map +1 -1
  11. package/dist/main/CurrencyCrossTableWidget/components/CellValidationWrapper.js +49 -0
  12. package/dist/main/CurrencyCrossTableWidget/components/CellValidationWrapper.js.map +1 -0
  13. package/dist/main/CurrencyCrossTableWidget/components/CellWithData.js +19 -13
  14. package/dist/main/CurrencyCrossTableWidget/components/CellWithData.js.map +1 -1
  15. package/dist/main/CurrencyCrossTableWidget/components/TextCell.js +7 -5
  16. package/dist/main/CurrencyCrossTableWidget/components/TextCell.js.map +1 -1
  17. package/dist/main/CurrencyCrossTableWidget/components/types.js.map +1 -1
  18. package/dist/main/CurrencyCrossTableWidget/render.js +7 -2
  19. package/dist/main/CurrencyCrossTableWidget/render.js.map +1 -1
  20. package/dist/main/CurrencyCrossTableWidget/types.js +0 -13
  21. package/dist/main/CurrencyCrossTableWidget/types.js.map +1 -1
  22. package/dist/main/CurrencyCrossTableWidget/utils.js +13 -30
  23. package/dist/main/CurrencyCrossTableWidget/utils.js.map +1 -1
  24. package/dist/main/gql/types/fragment-masking.js +23 -0
  25. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  26. package/dist/main/gql/types/gql.js +16 -0
  27. package/dist/main/gql/types/gql.js.map +1 -0
  28. package/dist/main/gql/types/graphql.js +223 -0
  29. package/dist/main/gql/types/graphql.js.map +1 -0
  30. package/dist/main/gql/types/index.js +28 -0
  31. package/dist/main/gql/types/index.js.map +1 -0
  32. package/dist/main/gql/validateInstruments.js +16 -0
  33. package/dist/main/gql/validateInstruments.js.map +1 -0
  34. package/dist/module/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js +10 -2
  35. package/dist/module/CurrencyCrossTableWidget/CurrencyCrossTableWidget.js.map +1 -1
  36. package/dist/module/CurrencyCrossTableWidget/Main.js +21 -19
  37. package/dist/module/CurrencyCrossTableWidget/Main.js.map +1 -1
  38. package/dist/module/CurrencyCrossTableWidget/ValidationWrapper.js +2 -1
  39. package/dist/module/CurrencyCrossTableWidget/ValidationWrapper.js.map +1 -1
  40. package/dist/module/CurrencyCrossTableWidget/components/Cell.js +2 -4
  41. package/dist/module/CurrencyCrossTableWidget/components/Cell.js.map +1 -1
  42. package/dist/module/CurrencyCrossTableWidget/components/CellValidationWrapper.js +42 -0
  43. package/dist/module/CurrencyCrossTableWidget/components/CellValidationWrapper.js.map +1 -0
  44. package/dist/module/CurrencyCrossTableWidget/components/CellWithData.js +20 -14
  45. package/dist/module/CurrencyCrossTableWidget/components/CellWithData.js.map +1 -1
  46. package/dist/module/CurrencyCrossTableWidget/components/TextCell.js +7 -5
  47. package/dist/module/CurrencyCrossTableWidget/components/TextCell.js.map +1 -1
  48. package/dist/module/CurrencyCrossTableWidget/components/types.js.map +1 -1
  49. package/dist/module/CurrencyCrossTableWidget/render.js +6 -1
  50. package/dist/module/CurrencyCrossTableWidget/render.js.map +1 -1
  51. package/dist/module/CurrencyCrossTableWidget/types.js +0 -12
  52. package/dist/module/CurrencyCrossTableWidget/types.js.map +1 -1
  53. package/dist/module/CurrencyCrossTableWidget/utils.js +10 -29
  54. package/dist/module/CurrencyCrossTableWidget/utils.js.map +1 -1
  55. package/dist/module/gql/types/fragment-masking.js +15 -0
  56. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  57. package/dist/module/gql/types/gql.js +8 -0
  58. package/dist/module/gql/types/gql.js.map +1 -0
  59. package/dist/module/gql/types/graphql.js +217 -0
  60. package/dist/module/gql/types/graphql.js.map +1 -0
  61. package/dist/module/gql/types/index.js +3 -0
  62. package/dist/module/gql/types/index.js.map +1 -0
  63. package/dist/module/gql/validateInstruments.js +10 -0
  64. package/dist/module/gql/validateInstruments.js.map +1 -0
  65. package/dist/types/CurrencyCrossTableWidget/CurrencyCrossTableWidget.d.ts +1 -1
  66. package/dist/types/CurrencyCrossTableWidget/Main.d.ts +1 -1
  67. package/dist/types/CurrencyCrossTableWidget/components/Cell.d.ts +1 -1
  68. package/dist/types/CurrencyCrossTableWidget/components/CellValidationWrapper.d.ts +4 -0
  69. package/dist/types/CurrencyCrossTableWidget/components/CellWithData.d.ts +1 -1
  70. package/dist/types/CurrencyCrossTableWidget/components/TextCell.d.ts +1 -1
  71. package/dist/types/CurrencyCrossTableWidget/components/types.d.ts +15 -4
  72. package/dist/types/CurrencyCrossTableWidget/types.d.ts +3 -11
  73. package/dist/types/CurrencyCrossTableWidget/utils.d.ts +5 -6
  74. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  75. package/dist/types/gql/types/gql.d.ts +37 -0
  76. package/dist/types/gql/types/graphql.d.ts +384 -0
  77. package/dist/types/gql/types/index.d.ts +2 -0
  78. package/dist/types/gql/validateInstruments.d.ts +1 -0
  79. package/package.json +12 -4
  80. package/src/CurrencyCrossTableWidget/CurrencyCrossTableWidget.tsx +16 -6
  81. package/src/CurrencyCrossTableWidget/Main.tsx +23 -19
  82. package/src/CurrencyCrossTableWidget/ValidationWrapper.tsx +1 -0
  83. package/src/CurrencyCrossTableWidget/components/Cell.tsx +2 -4
  84. package/src/CurrencyCrossTableWidget/components/CellValidationWrapper.tsx +49 -0
  85. package/src/CurrencyCrossTableWidget/components/CellWithData.tsx +30 -16
  86. package/src/CurrencyCrossTableWidget/components/TextCell.tsx +6 -4
  87. package/src/CurrencyCrossTableWidget/components/types.ts +15 -4
  88. package/src/CurrencyCrossTableWidget/render.tsx +6 -2
  89. package/src/CurrencyCrossTableWidget/types.tsx +3 -12
  90. package/src/CurrencyCrossTableWidget/utils.ts +17 -37
  91. package/src/gql/types/fragment-masking.ts +66 -0
  92. package/src/gql/types/gql.ts +42 -0
  93. package/src/gql/types/graphql.ts +423 -0
  94. package/src/gql/types/index.ts +2 -0
  95. package/src/gql/validateInstruments.ts +10 -0
  96. package/test/Main.test.tsx +12 -6
  97. package/test/mocks.ts +225 -0
@@ -0,0 +1,384 @@
1
+ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
2
+ export type Maybe<T> = T | null;
3
+ export type InputMaybe<T> = Maybe<T>;
4
+ export type Exact<T extends {
5
+ [key: string]: unknown;
6
+ }> = {
7
+ [K in keyof T]: T[K];
8
+ };
9
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
+ [SubKey in K]?: Maybe<T[SubKey]>;
11
+ };
12
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
+ [SubKey in K]: Maybe<T[SubKey]>;
14
+ };
15
+ export type MakeEmpty<T extends {
16
+ [key: string]: unknown;
17
+ }, K extends keyof T> = {
18
+ [_ in K]?: never;
19
+ };
20
+ export type Incremental<T> = T | {
21
+ [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never;
22
+ };
23
+ /** All built-in and custom scalars, mapped to their actual values */
24
+ export type Scalars = {
25
+ ID: {
26
+ input: string;
27
+ output: string;
28
+ };
29
+ String: {
30
+ input: string;
31
+ output: string;
32
+ };
33
+ Boolean: {
34
+ input: boolean;
35
+ output: boolean;
36
+ };
37
+ Int: {
38
+ input: number;
39
+ output: number;
40
+ };
41
+ Float: {
42
+ input: number;
43
+ output: number;
44
+ };
45
+ };
46
+ export type AssetClass = {
47
+ __typename?: 'AssetClass';
48
+ instruments: Array<Instrument>;
49
+ name: Scalars['String']['output'];
50
+ };
51
+ export declare enum AssetClassName {
52
+ Commodities = "COMMODITIES",
53
+ Cryptocurrency = "CRYPTOCURRENCY",
54
+ Currency = "CURRENCY",
55
+ EquityShares = "EQUITY_SHARES",
56
+ Indices = "INDICES",
57
+ Rates = "RATES"
58
+ }
59
+ export declare enum BookType {
60
+ Order = "ORDER",
61
+ Position = "POSITION"
62
+ }
63
+ export type CorrelationHeatmap = {
64
+ __typename?: 'CorrelationHeatmap';
65
+ baseInstrument: Instrument;
66
+ heatmap: Array<Heatmap>;
67
+ };
68
+ export type CorrelationMatrix = {
69
+ __typename?: 'CorrelationMatrix';
70
+ baseTimeUnit: CorrelationTimeUnit;
71
+ matrix: Array<Matrix>;
72
+ };
73
+ export declare enum CorrelationTimeUnit {
74
+ H1 = "H1",
75
+ H4 = "H4",
76
+ H24 = "H24",
77
+ M1 = "M1",
78
+ M3 = "M3",
79
+ M6 = "M6",
80
+ W1 = "W1",
81
+ Y1 = "Y1"
82
+ }
83
+ export declare enum CurrencyName {
84
+ Aud = "AUD",
85
+ Cad = "CAD",
86
+ Chf = "CHF",
87
+ Eur = "EUR",
88
+ Gbp = "GBP",
89
+ Jpy = "JPY",
90
+ Nzd = "NZD",
91
+ Usd = "USD"
92
+ }
93
+ export type CurrencyPower = {
94
+ __typename?: 'CurrencyPower';
95
+ /** UTC Timestamp */
96
+ point: Scalars['String']['output'];
97
+ price: Scalars['Float']['output'];
98
+ };
99
+ export type CurrencyPowerBalance = {
100
+ __typename?: 'CurrencyPowerBalance';
101
+ currency: CurrencyName;
102
+ power: Array<CurrencyPower>;
103
+ updatedAt: Scalars['String']['output'];
104
+ };
105
+ export declare enum CurrencyPowerBalanceTimeUnit {
106
+ CurrentDay = "CURRENT_DAY",
107
+ H4 = "H4",
108
+ H8 = "H8",
109
+ H24 = "H24",
110
+ M1 = "M1",
111
+ M3 = "M3",
112
+ PreviousDay = "PREVIOUS_DAY",
113
+ W1 = "W1"
114
+ }
115
+ export type CurrencyStrength = {
116
+ __typename?: 'CurrencyStrength';
117
+ currency: CurrencyName;
118
+ strengthRelation?: Maybe<Array<StrengthRelation>>;
119
+ updatedAt: Scalars['String']['output'];
120
+ };
121
+ export declare enum DataSource {
122
+ Ny4 = "NY4",
123
+ Ty3 = "TY3"
124
+ }
125
+ export declare enum Division {
126
+ Oap = "OAP",
127
+ Oau = "OAU",
128
+ Oc = "OC",
129
+ Ocan = "OCAN",
130
+ Oel = "OEL",
131
+ Ogm = "OGM",
132
+ Oj = "OJ",
133
+ Opt = "OPT",
134
+ Otms = "OTMS"
135
+ }
136
+ export type Heatmap = {
137
+ __typename?: 'Heatmap';
138
+ instrument: Instrument;
139
+ timeCorrelation: Array<TimeCorrelation>;
140
+ };
141
+ export type Instrument = {
142
+ __typename?: 'Instrument';
143
+ displayName: Scalars['String']['output'];
144
+ name: Scalars['String']['output'];
145
+ };
146
+ export type InstrumentCorrelation = {
147
+ __typename?: 'InstrumentCorrelation';
148
+ instrument: Instrument;
149
+ value?: Maybe<Scalars['Float']['output']>;
150
+ };
151
+ export type Matrix = {
152
+ __typename?: 'Matrix';
153
+ instrument: Instrument;
154
+ instrumentCorrelation: Array<InstrumentCorrelation>;
155
+ };
156
+ export type OrderPositionBucket = {
157
+ __typename?: 'OrderPositionBucket';
158
+ longCountPercent: Scalars['Float']['output'];
159
+ price: Scalars['Float']['output'];
160
+ shortCountPercent: Scalars['Float']['output'];
161
+ };
162
+ export type OrderPositionData = {
163
+ __typename?: 'OrderPositionData';
164
+ bucketWidth: Scalars['Float']['output'];
165
+ buckets: Array<Maybe<OrderPositionBucket>>;
166
+ dataSource?: Maybe<Scalars['String']['output']>;
167
+ instrument: Scalars['String']['output'];
168
+ price?: Maybe<Scalars['Float']['output']>;
169
+ region?: Maybe<Scalars['String']['output']>;
170
+ time: Scalars['String']['output'];
171
+ unixTime: Scalars['Int']['output'];
172
+ };
173
+ export type Query = {
174
+ __typename?: 'Query';
175
+ assetClasses?: Maybe<Array<Maybe<AssetClass>>>;
176
+ correlationHeatmap: CorrelationHeatmap;
177
+ correlationMatrix: CorrelationMatrix;
178
+ currencyPowerBalance?: Maybe<Array<CurrencyPowerBalance>>;
179
+ currencyStrength?: Maybe<Array<CurrencyStrength>>;
180
+ isAllowedPartner?: Maybe<Scalars['Boolean']['output']>;
181
+ mapInstrumentNames?: Maybe<Array<Maybe<Instrument>>>;
182
+ orderPositionBooks: Array<Maybe<OrderPositionData>>;
183
+ sentiment?: Maybe<Array<SentimentInstrument>>;
184
+ sentimentList?: Maybe<Array<SentimentInstrument>>;
185
+ topicalInstruments?: Maybe<Array<TopicalInstrument>>;
186
+ topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
187
+ topicalInstrumentsTotalCount: Scalars['Int']['output'];
188
+ valueAtRiskAssetClasses?: Maybe<Array<AssetClass>>;
189
+ valueAtRiskChart?: Maybe<ValueAtRiskChart>;
190
+ volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
191
+ volatilityChartAssetClasses?: Maybe<Array<AssetClass>>;
192
+ };
193
+ export type QueryAssetClassesArgs = {
194
+ division: Division;
195
+ };
196
+ export type QueryCorrelationHeatmapArgs = {
197
+ division: Division;
198
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
199
+ timeSpans?: InputMaybe<Array<InputMaybe<CorrelationTimeUnit>>>;
200
+ };
201
+ export type QueryCorrelationMatrixArgs = {
202
+ division: Division;
203
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
204
+ };
205
+ export type QueryCurrencyPowerBalanceArgs = {
206
+ timeUnit: CurrencyPowerBalanceTimeUnit;
207
+ };
208
+ export type QueryIsAllowedPartnerArgs = {
209
+ url: Scalars['String']['input'];
210
+ };
211
+ export type QueryMapInstrumentNamesArgs = {
212
+ division?: InputMaybe<Division>;
213
+ instruments: Array<InputMaybe<Scalars['String']['input']>>;
214
+ };
215
+ export type QueryOrderPositionBooksArgs = {
216
+ bookType: BookType;
217
+ dataSource?: InputMaybe<DataSource>;
218
+ instrument: Scalars['String']['input'];
219
+ recentHours?: InputMaybe<Scalars['Int']['input']>;
220
+ region?: InputMaybe<Region>;
221
+ };
222
+ export type QuerySentimentArgs = {
223
+ division?: InputMaybe<Division>;
224
+ name: Scalars['String']['input'];
225
+ };
226
+ export type QuerySentimentListArgs = {
227
+ division?: InputMaybe<Division>;
228
+ sort?: InputMaybe<Sort>;
229
+ };
230
+ export type QueryTopicalInstrumentsArgs = {
231
+ assetClass?: InputMaybe<AssetClassName>;
232
+ count?: InputMaybe<Scalars['Int']['input']>;
233
+ division?: InputMaybe<Division>;
234
+ offset?: InputMaybe<Scalars['Int']['input']>;
235
+ sort: TopicalSort;
236
+ };
237
+ export type QueryTopicalInstrumentsChartsArgs = {
238
+ division?: InputMaybe<Division>;
239
+ instruments?: InputMaybe<Array<Scalars['String']['input']>>;
240
+ };
241
+ export type QueryTopicalInstrumentsTotalCountArgs = {
242
+ assetClass?: InputMaybe<AssetClassName>;
243
+ division?: InputMaybe<Division>;
244
+ sort: TopicalSort;
245
+ };
246
+ export type QueryValueAtRiskAssetClassesArgs = {
247
+ division?: InputMaybe<Division>;
248
+ };
249
+ export type QueryValueAtRiskChartArgs = {
250
+ bars: ValueAtRiskBars;
251
+ division?: InputMaybe<Division>;
252
+ duration: ValueAtRiskDuration;
253
+ instrument: Scalars['String']['input'];
254
+ };
255
+ export type QueryVolatilityChartArgs = {
256
+ division?: InputMaybe<Division>;
257
+ instrument: Scalars['String']['input'];
258
+ timeSpan: VolatilityChartTimeSpan;
259
+ timeUnit: VolatilityChartTimeUnit;
260
+ };
261
+ export type QueryVolatilityChartAssetClassesArgs = {
262
+ division?: InputMaybe<Division>;
263
+ };
264
+ export declare enum Region {
265
+ Amer = "AMER",
266
+ Apac = "APAC",
267
+ Emea = "EMEA"
268
+ }
269
+ export type Sentiment = {
270
+ __typename?: 'Sentiment';
271
+ longPercent: Scalars['Float']['output'];
272
+ shortPercent: Scalars['Float']['output'];
273
+ };
274
+ export type SentimentInstrument = {
275
+ __typename?: 'SentimentInstrument';
276
+ displayName: Scalars['String']['output'];
277
+ name: Scalars['String']['output'];
278
+ sentiment: Sentiment;
279
+ updatedAt: Scalars['String']['output'];
280
+ };
281
+ export declare enum Sort {
282
+ Bearish = "BEARISH",
283
+ Bullish = "BULLISH"
284
+ }
285
+ export type StrengthRelation = {
286
+ __typename?: 'StrengthRelation';
287
+ currency: CurrencyName;
288
+ percentage: Scalars['Float']['output'];
289
+ };
290
+ export type TimeCorrelation = {
291
+ __typename?: 'TimeCorrelation';
292
+ timeUnit: CorrelationTimeUnit;
293
+ value?: Maybe<Scalars['Float']['output']>;
294
+ };
295
+ export type TopicalInstrument = {
296
+ __typename?: 'TopicalInstrument';
297
+ assetClass?: Maybe<AssetClassName>;
298
+ displayName: Scalars['String']['output'];
299
+ name: Scalars['String']['output'];
300
+ sentiment: Sentiment;
301
+ updatedAt: Scalars['String']['output'];
302
+ };
303
+ export type TopicalInstrumentChart = {
304
+ __typename?: 'TopicalInstrumentChart';
305
+ chart?: Maybe<Array<Scalars['Float']['output']>>;
306
+ name: Scalars['String']['output'];
307
+ };
308
+ export declare enum TopicalSort {
309
+ Bearish = "BEARISH",
310
+ Bullish = "BULLISH",
311
+ Hot = "HOT",
312
+ Popular = "POPULAR",
313
+ Volatile = "VOLATILE"
314
+ }
315
+ export declare enum ValueAtRiskBars {
316
+ C100 = "C100",
317
+ C200 = "C200",
318
+ C300 = "C300"
319
+ }
320
+ export type ValueAtRiskChart = {
321
+ __typename?: 'ValueAtRiskChart';
322
+ down: ValueAtRiskChartData;
323
+ up: ValueAtRiskChartData;
324
+ };
325
+ export type ValueAtRiskChartData = {
326
+ __typename?: 'ValueAtRiskChartData';
327
+ average: Scalars['Float']['output'];
328
+ max: Scalars['Float']['output'];
329
+ median: Scalars['Float']['output'];
330
+ points?: Maybe<Array<ValueAtRiskChartPoint>>;
331
+ threshold: Scalars['Float']['output'];
332
+ };
333
+ export type ValueAtRiskChartPoint = {
334
+ __typename?: 'ValueAtRiskChartPoint';
335
+ percent: Scalars['Float']['output'];
336
+ pips: Scalars['Float']['output'];
337
+ };
338
+ export declare enum ValueAtRiskDuration {
339
+ C1 = "C1",
340
+ C2 = "C2",
341
+ C3 = "C3",
342
+ C4 = "C4",
343
+ C5 = "C5",
344
+ C10 = "C10"
345
+ }
346
+ export type VolatilityChart = {
347
+ __typename?: 'VolatilityChart';
348
+ pips: Scalars['Float']['output'];
349
+ /** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
350
+ point: Scalars['String']['output'];
351
+ updatedAt: Scalars['String']['output'];
352
+ };
353
+ export declare enum VolatilityChartTimeSpan {
354
+ /** Valid for: H */
355
+ D5 = "D5",
356
+ /** Valid for: H */
357
+ D10 = "D10",
358
+ /** Valid for: D */
359
+ M1 = "M1",
360
+ /** Valid for: D */
361
+ M3 = "M3",
362
+ /** Valid for: W */
363
+ W5 = "W5",
364
+ /** Valid for: W */
365
+ W10 = "W10"
366
+ }
367
+ export declare enum VolatilityChartTimeUnit {
368
+ D = "D",
369
+ H = "H",
370
+ W = "W"
371
+ }
372
+ export type ValidateInstrumentsQueryVariables = Exact<{
373
+ instruments: Array<InputMaybe<Scalars['String']['input']>> | InputMaybe<Scalars['String']['input']>;
374
+ division?: InputMaybe<Division>;
375
+ }>;
376
+ export type ValidateInstrumentsQuery = {
377
+ __typename?: 'Query';
378
+ mapInstrumentNames?: Array<{
379
+ __typename?: 'Instrument';
380
+ name: string;
381
+ displayName: string;
382
+ } | null> | null;
383
+ };
384
+ export declare const ValidateInstrumentsDocument: DocumentNode<ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables>;
@@ -0,0 +1,2 @@
1
+ export * from "./fragment-masking";
2
+ export * from "./gql";
@@ -0,0 +1 @@
1
+ export declare const validateInstruments: import("@apollo/client").DocumentNode;
package/package.json CHANGED
@@ -1,16 +1,24 @@
1
1
  {
2
2
  "name": "@oanda/labs-currency-cross-table",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Labs Currency Cross Table",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
7
7
  "types": "dist/types/index.d.ts",
8
+ "scripts": {
9
+ "codegen": "graphql-codegen --config codegen.ts"
10
+ },
8
11
  "keywords": [],
9
12
  "author": "OANDA",
10
13
  "license": "UNLICENSED",
11
14
  "dependencies": {
12
- "@oanda/labs-widget-common": "^1.0.155",
13
- "@oanda/mono-i18n": "10.0.1"
15
+ "@oanda/labs-widget-common": "^1.0.157",
16
+ "@oanda/mono-i18n": "10.0.1",
17
+ "graphql": "16.8.1"
18
+ },
19
+ "devDependencies": {
20
+ "@graphql-codegen/cli": "5.0.0",
21
+ "@graphql-codegen/client-preset": "4.1.0"
14
22
  },
15
- "gitHead": "eecb0d8d995023c4374b106577b8be81b27604d4"
23
+ "gitHead": "60a2bfe5c3adb01f35e853dd1596a444033f4847"
16
24
  }
@@ -1,13 +1,16 @@
1
1
  import React from 'react';
2
+ import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
2
3
  import { LocaleProvider } from '@oanda/mono-i18n';
3
4
  import {
4
5
  LiveRatesProvider, ThemeProvider, getLocale,
5
6
  } from '@oanda/labs-widget-common';
6
7
  import { translations } from '../translations';
7
- import { Division, CurrencyCrossTableConfig } from './types';
8
+ import { CurrencyCrossTableConfig } from './types';
8
9
  import { ValidationWrapper } from './ValidationWrapper';
10
+ import { Division } from '../gql/types/graphql';
9
11
 
10
12
  const CurrencyCrossTableWidget = ({
13
+ graphqlUrl,
11
14
  liveRatesUrl,
12
15
  currencies,
13
16
  division,
@@ -16,6 +19,11 @@ const CurrencyCrossTableWidget = ({
16
19
  isParamError,
17
20
  removePadding,
18
21
  }: CurrencyCrossTableConfig) => {
22
+ const client = new ApolloClient({
23
+ uri: graphqlUrl,
24
+ cache: new InMemoryCache(),
25
+ });
26
+
19
27
  const divisionCode = division === Division.Opt ? Division.Ogm : division;
20
28
  const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';
21
29
 
@@ -26,11 +34,13 @@ const CurrencyCrossTableWidget = ({
26
34
  url={liveRatesUrl}
27
35
  options={{ divisionCode, dataSource }}
28
36
  >
29
- <ValidationWrapper
30
- currencies={currencies}
31
- division={division}
32
- isParamError={isParamError}
33
- />
37
+ <ApolloProvider client={client}>
38
+ <ValidationWrapper
39
+ currencies={currencies}
40
+ division={division}
41
+ isParamError={isParamError}
42
+ />
43
+ </ApolloProvider>
34
44
  </LiveRatesProvider>
35
45
  </LocaleProvider>
36
46
  </ThemeProvider>
@@ -1,11 +1,16 @@
1
- import React, { Fragment, useEffect, useState } from 'react';
1
+ import React, {
2
+ Fragment, Suspense, useEffect, useState,
3
+ } from 'react';
2
4
  import { useLiveRatesQuery } from '@oanda/labs-widget-common';
3
5
  import { MainProps } from './types';
4
- import { CellWithData, TextCell } from './components';
6
+ import { TextCell } from './components';
7
+ import { CellValidationWrapper } from './components/CellValidationWrapper';
8
+ import { divisionMapper } from './utils';
5
9
 
6
10
  const Main = ({
7
11
  instruments,
8
12
  currencies,
13
+ division,
9
14
  }: MainProps) => {
10
15
  const [selectedCurrency, setSelectedCurrency] = useState('');
11
16
  const [selectedPair, setSelectedPair] = useState('');
@@ -22,9 +27,9 @@ const Main = ({
22
27
  }, instruments);
23
28
 
24
29
  return (
25
- <div data-testid="currency-cross-table-wrapper" className="lw-w-full">
26
- <div className="lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary">
27
- <TextCell />
30
+ <div data-testid="currency-cross-table-wrapper" className="lw-w-full lw-overflow-x-auto lw-overflow-y-hidden lw-border lw-border-b-0 lw-border-solid lw-border-border-primary">
31
+ <div className="lw-flex lw-w-max lw-min-w-full">
32
+ <TextCell sticky />
28
33
  {currencies.map(((pair) => (
29
34
  <TextCell
30
35
  key={pair}
@@ -36,30 +41,29 @@ const Main = ({
36
41
  {currencies.map(((currency, index, arr) => (
37
42
  <div
38
43
  key={currency}
39
- className="lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary"
44
+ className="lw-flex lw-w-max lw-min-w-full"
40
45
  >
41
46
  <TextCell
42
47
  label={currency}
43
- additionalBorderBottom={index === arr.length - 1}
44
48
  hovered={currency === selectedCurrency}
49
+ sticky
45
50
  />
46
51
  {arr.map((pair) => (
47
52
  <Fragment key={`${currency}_${pair}`}>
48
53
  {currency !== pair ? (
49
- <CellWithData
50
- loading={false}
51
- record={{
52
- instrument: `${currency}_${pair}`,
53
- displayName: `${currency}/${pair}`,
54
- }}
55
- target={target}
56
- additionalBorderBottom={index === arr.length - 1}
57
- setSelectedCurrency={setSelectedCurrency}
58
- setSelectedPair={setSelectedPair}
59
- />
54
+ <Suspense>
55
+ <CellValidationWrapper
56
+ currency={currency}
57
+ pair={pair}
58
+ instrument={`${currency}${divisionMapper(division)}${pair}`}
59
+ target={target}
60
+ setSelectedCurrency={setSelectedCurrency}
61
+ setSelectedPair={setSelectedPair}
62
+ division={division}
63
+ />
64
+ </Suspense>
60
65
  ) : (
61
66
  <TextCell
62
- additionalBorderBottom={index === arr.length - 1}
63
67
  emptyIndicator
64
68
  />
65
69
  )}
@@ -21,6 +21,7 @@ const ValidationWrapper = ({
21
21
  <Main
22
22
  instruments={currenciesToInstruments(currencies, division)}
23
23
  currencies={currencies}
24
+ division={division}
24
25
  />
25
26
  )}
26
27
  {showError && (
@@ -7,15 +7,13 @@ const Cell = ({
7
7
  children,
8
8
  isError,
9
9
  isLoading,
10
- additionalBorderBottom,
11
10
  hovered,
12
11
  mouseEnterHandler,
13
12
  mouseLeaveHandler,
14
13
  }: CellProps) => (
15
14
  <div
16
- className={classnames('lw-flex lw-h-[inherit] lw-flex-1 lw-items-center lw-justify-center lw-border-r lw-border-solid lw-border-border-primary', {
17
- 'lw-border-b': additionalBorderBottom,
18
- 'lw-font-semibold': hovered,
15
+ className={classnames('lw-flex lw-h-11 lw-min-w-[70px] lw-flex-1 lw-items-center lw-justify-center lw-border-b lw-border-r lw-border-solid lw-border-border-primary last:lw-border-r-[0px]', {
16
+ 'lw-bg-border-primary lw-font-semibold lw-shadow-innerBorderBgColor': hovered,
19
17
  })}
20
18
  onMouseEnter={mouseEnterHandler}
21
19
  onMouseLeave={mouseLeaveHandler}
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { useSuspenseQuery } from '@apollo/client';
3
+ import { CellValidationWrapperProps } from './types';
4
+ import { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../../gql/types/graphql';
5
+ import { validateInstruments } from '../../gql/validateInstruments';
6
+ import { CellWithData } from './CellWithData';
7
+ import { divisionMapper } from '../utils';
8
+
9
+ const CellValidationWrapper = ({
10
+ currency,
11
+ pair,
12
+ instrument,
13
+ target,
14
+ setSelectedCurrency,
15
+ setSelectedPair,
16
+ division,
17
+ }: CellValidationWrapperProps) => {
18
+ const { error } = useSuspenseQuery<
19
+ ValidateInstrumentsQuery,
20
+ ValidateInstrumentsQueryVariables
21
+ >(validateInstruments, {
22
+ variables: {
23
+ instruments: [instrument],
24
+ division,
25
+ },
26
+ fetchPolicy: 'network-only',
27
+ errorPolicy: 'all',
28
+ });
29
+
30
+ const instrumentForCalculations = error ? `${pair}${divisionMapper(division)}${currency}` : '';
31
+
32
+ return (
33
+ <CellWithData
34
+ currency={currency}
35
+ pair={pair}
36
+ record={{
37
+ instrument,
38
+ displayName: `${currency}${divisionMapper(division)}${pair}`,
39
+ }}
40
+ instrumentForCalculations={instrumentForCalculations}
41
+ target={target}
42
+ setSelectedCurrency={setSelectedCurrency}
43
+ setSelectedPair={setSelectedPair}
44
+ division={division}
45
+ />
46
+ );
47
+ };
48
+
49
+ export { CellValidationWrapper };