@oanda/labs-crowd-view-widget 1.0.1

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 (103) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/codegen.ts +15 -0
  3. package/dist/main/CrowdViewWidget/CrowdViewWidget.js +40 -0
  4. package/dist/main/CrowdViewWidget/CrowdViewWidget.js.map +1 -0
  5. package/dist/main/CrowdViewWidget/Main.js +65 -0
  6. package/dist/main/CrowdViewWidget/Main.js.map +1 -0
  7. package/dist/main/CrowdViewWidget/config.js +97 -0
  8. package/dist/main/CrowdViewWidget/config.js.map +1 -0
  9. package/dist/main/CrowdViewWidget/index.js +28 -0
  10. package/dist/main/CrowdViewWidget/index.js.map +1 -0
  11. package/dist/main/CrowdViewWidget/render.js +41 -0
  12. package/dist/main/CrowdViewWidget/render.js.map +1 -0
  13. package/dist/main/CrowdViewWidget/types.js +33 -0
  14. package/dist/main/CrowdViewWidget/types.js.map +1 -0
  15. package/dist/main/gql/types/fragment-masking.js +23 -0
  16. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  17. package/dist/main/gql/types/gql.js +16 -0
  18. package/dist/main/gql/types/gql.js.map +1 -0
  19. package/dist/main/gql/types/graphql.js +223 -0
  20. package/dist/main/gql/types/graphql.js.map +1 -0
  21. package/dist/main/gql/types/index.js +28 -0
  22. package/dist/main/gql/types/index.js.map +1 -0
  23. package/dist/main/gql/validateInstruments.js +16 -0
  24. package/dist/main/gql/validateInstruments.js.map +1 -0
  25. package/dist/main/index.js +17 -0
  26. package/dist/main/index.js.map +1 -0
  27. package/dist/main/translations/index.js +27 -0
  28. package/dist/main/translations/index.js.map +1 -0
  29. package/dist/main/translations/sources/en.json +2 -0
  30. package/dist/main/translations/sources/es.json +2 -0
  31. package/dist/main/translations/sources/th.json +2 -0
  32. package/dist/main/translations/sources/zh_TW.json +2 -0
  33. package/dist/main/translations/translations.js +8 -0
  34. package/dist/main/translations/translations.js.map +1 -0
  35. package/dist/module/CrowdViewWidget/CrowdViewWidget.js +33 -0
  36. package/dist/module/CrowdViewWidget/CrowdViewWidget.js.map +1 -0
  37. package/dist/module/CrowdViewWidget/Main.js +57 -0
  38. package/dist/module/CrowdViewWidget/Main.js.map +1 -0
  39. package/dist/module/CrowdViewWidget/config.js +92 -0
  40. package/dist/module/CrowdViewWidget/config.js.map +1 -0
  41. package/dist/module/CrowdViewWidget/index.js +3 -0
  42. package/dist/module/CrowdViewWidget/index.js.map +1 -0
  43. package/dist/module/CrowdViewWidget/render.js +38 -0
  44. package/dist/module/CrowdViewWidget/render.js.map +1 -0
  45. package/dist/module/CrowdViewWidget/types.js +27 -0
  46. package/dist/module/CrowdViewWidget/types.js.map +1 -0
  47. package/dist/module/gql/types/fragment-masking.js +15 -0
  48. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  49. package/dist/module/gql/types/gql.js +8 -0
  50. package/dist/module/gql/types/gql.js.map +1 -0
  51. package/dist/module/gql/types/graphql.js +217 -0
  52. package/dist/module/gql/types/graphql.js.map +1 -0
  53. package/dist/module/gql/types/index.js +3 -0
  54. package/dist/module/gql/types/index.js.map +1 -0
  55. package/dist/module/gql/validateInstruments.js +10 -0
  56. package/dist/module/gql/validateInstruments.js.map +1 -0
  57. package/dist/module/index.js +2 -0
  58. package/dist/module/index.js.map +1 -0
  59. package/dist/module/translations/index.js +20 -0
  60. package/dist/module/translations/index.js.map +1 -0
  61. package/dist/module/translations/sources/en.json +2 -0
  62. package/dist/module/translations/sources/es.json +2 -0
  63. package/dist/module/translations/sources/th.json +2 -0
  64. package/dist/module/translations/sources/zh_TW.json +2 -0
  65. package/dist/module/translations/translations.js +2 -0
  66. package/dist/module/translations/translations.js.map +1 -0
  67. package/dist/types/CrowdViewWidget/CrowdViewWidget.d.ts +4 -0
  68. package/dist/types/CrowdViewWidget/Main.d.ts +4 -0
  69. package/dist/types/CrowdViewWidget/config.d.ts +20 -0
  70. package/dist/types/CrowdViewWidget/index.d.ts +2 -0
  71. package/dist/types/CrowdViewWidget/render.d.ts +1 -0
  72. package/dist/types/CrowdViewWidget/types.d.ts +32 -0
  73. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  74. package/dist/types/gql/types/gql.d.ts +37 -0
  75. package/dist/types/gql/types/graphql.d.ts +389 -0
  76. package/dist/types/gql/types/index.d.ts +2 -0
  77. package/dist/types/gql/validateInstruments.d.ts +1 -0
  78. package/dist/types/index.d.ts +1 -0
  79. package/dist/types/translations/index.d.ts +4 -0
  80. package/dist/types/translations/translations.d.ts +1 -0
  81. package/index.ts +1 -0
  82. package/lokalise.config.json +18 -0
  83. package/package.json +24 -0
  84. package/src/CrowdViewWidget/CrowdViewWidget.tsx +40 -0
  85. package/src/CrowdViewWidget/Main.tsx +91 -0
  86. package/src/CrowdViewWidget/config.ts +130 -0
  87. package/src/CrowdViewWidget/index.ts +2 -0
  88. package/src/CrowdViewWidget/render.tsx +51 -0
  89. package/src/CrowdViewWidget/types.ts +36 -0
  90. package/src/gql/types/fragment-masking.ts +86 -0
  91. package/src/gql/types/gql.ts +46 -0
  92. package/src/gql/types/graphql.ts +509 -0
  93. package/src/gql/types/index.ts +2 -0
  94. package/src/gql/validateInstruments.ts +10 -0
  95. package/src/index.ts +1 -0
  96. package/src/translations/index.ts +17 -0
  97. package/src/translations/sources/en.json +2 -0
  98. package/src/translations/sources/es.json +2 -0
  99. package/src/translations/sources/th.json +2 -0
  100. package/src/translations/sources/zh_TW.json +2 -0
  101. package/src/translations/translations.ts +1 -0
  102. package/test/Main.test.tsx +21 -0
  103. package/tsconfig.types.json +12 -0
@@ -0,0 +1,389 @@
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
+ resolveInstrumentsByDivision?: Maybe<Array<Instrument>>;
184
+ sentiment?: Maybe<Array<SentimentInstrument>>;
185
+ sentimentList?: Maybe<Array<SentimentInstrument>>;
186
+ topicalInstruments?: Maybe<Array<TopicalInstrument>>;
187
+ topicalInstrumentsCharts?: Maybe<Array<TopicalInstrumentChart>>;
188
+ topicalInstrumentsTotalCount: Scalars['Int']['output'];
189
+ valueAtRiskAssetClasses?: Maybe<Array<AssetClass>>;
190
+ valueAtRiskChart?: Maybe<ValueAtRiskChart>;
191
+ volatilityChart?: Maybe<Array<Maybe<VolatilityChart>>>;
192
+ volatilityChartAssetClasses?: Maybe<Array<AssetClass>>;
193
+ };
194
+ export type QueryAssetClassesArgs = {
195
+ division: Division;
196
+ };
197
+ export type QueryCorrelationHeatmapArgs = {
198
+ division: Division;
199
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
200
+ timeSpans?: InputMaybe<Array<InputMaybe<CorrelationTimeUnit>>>;
201
+ };
202
+ export type QueryCorrelationMatrixArgs = {
203
+ division: Division;
204
+ instruments?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
205
+ };
206
+ export type QueryCurrencyPowerBalanceArgs = {
207
+ timeUnit: CurrencyPowerBalanceTimeUnit;
208
+ };
209
+ export type QueryIsAllowedPartnerArgs = {
210
+ url: Scalars['String']['input'];
211
+ };
212
+ export type QueryMapInstrumentNamesArgs = {
213
+ division?: InputMaybe<Division>;
214
+ instruments: Array<InputMaybe<Scalars['String']['input']>>;
215
+ };
216
+ export type QueryOrderPositionBooksArgs = {
217
+ bookType: BookType;
218
+ dataSource?: InputMaybe<DataSource>;
219
+ instrument: Scalars['String']['input'];
220
+ recentHours?: InputMaybe<Scalars['Int']['input']>;
221
+ region?: InputMaybe<Region>;
222
+ };
223
+ export type QueryResolveInstrumentsByDivisionArgs = {
224
+ division: Division;
225
+ instruments: Array<InputMaybe<Scalars['String']['input']>>;
226
+ };
227
+ export type QuerySentimentArgs = {
228
+ division?: InputMaybe<Division>;
229
+ name: Scalars['String']['input'];
230
+ };
231
+ export type QuerySentimentListArgs = {
232
+ division?: InputMaybe<Division>;
233
+ sort?: InputMaybe<Sort>;
234
+ };
235
+ export type QueryTopicalInstrumentsArgs = {
236
+ assetClass?: InputMaybe<AssetClassName>;
237
+ count?: InputMaybe<Scalars['Int']['input']>;
238
+ division?: InputMaybe<Division>;
239
+ offset?: InputMaybe<Scalars['Int']['input']>;
240
+ sort: TopicalSort;
241
+ };
242
+ export type QueryTopicalInstrumentsChartsArgs = {
243
+ division?: InputMaybe<Division>;
244
+ instruments?: InputMaybe<Array<Scalars['String']['input']>>;
245
+ };
246
+ export type QueryTopicalInstrumentsTotalCountArgs = {
247
+ assetClass?: InputMaybe<AssetClassName>;
248
+ division?: InputMaybe<Division>;
249
+ sort: TopicalSort;
250
+ };
251
+ export type QueryValueAtRiskAssetClassesArgs = {
252
+ division?: InputMaybe<Division>;
253
+ };
254
+ export type QueryValueAtRiskChartArgs = {
255
+ bars: ValueAtRiskBars;
256
+ division?: InputMaybe<Division>;
257
+ duration: ValueAtRiskDuration;
258
+ instrument: Scalars['String']['input'];
259
+ };
260
+ export type QueryVolatilityChartArgs = {
261
+ division?: InputMaybe<Division>;
262
+ instrument: Scalars['String']['input'];
263
+ timeSpan: VolatilityChartTimeSpan;
264
+ timeUnit: VolatilityChartTimeUnit;
265
+ };
266
+ export type QueryVolatilityChartAssetClassesArgs = {
267
+ division?: InputMaybe<Division>;
268
+ };
269
+ export declare enum Region {
270
+ Amer = "AMER",
271
+ Apac = "APAC",
272
+ Emea = "EMEA"
273
+ }
274
+ export type Sentiment = {
275
+ __typename?: 'Sentiment';
276
+ longPercent: Scalars['Float']['output'];
277
+ shortPercent: Scalars['Float']['output'];
278
+ };
279
+ export type SentimentInstrument = {
280
+ __typename?: 'SentimentInstrument';
281
+ displayName: Scalars['String']['output'];
282
+ name: Scalars['String']['output'];
283
+ sentiment: Sentiment;
284
+ updatedAt: Scalars['String']['output'];
285
+ };
286
+ export declare enum Sort {
287
+ Bearish = "BEARISH",
288
+ Bullish = "BULLISH"
289
+ }
290
+ export type StrengthRelation = {
291
+ __typename?: 'StrengthRelation';
292
+ currency: CurrencyName;
293
+ percentage: Scalars['Float']['output'];
294
+ };
295
+ export type TimeCorrelation = {
296
+ __typename?: 'TimeCorrelation';
297
+ timeUnit: CorrelationTimeUnit;
298
+ value?: Maybe<Scalars['Float']['output']>;
299
+ };
300
+ export type TopicalInstrument = {
301
+ __typename?: 'TopicalInstrument';
302
+ assetClass?: Maybe<AssetClassName>;
303
+ displayName: Scalars['String']['output'];
304
+ name: Scalars['String']['output'];
305
+ sentiment: Sentiment;
306
+ updatedAt: Scalars['String']['output'];
307
+ };
308
+ export type TopicalInstrumentChart = {
309
+ __typename?: 'TopicalInstrumentChart';
310
+ chart?: Maybe<Array<Scalars['Float']['output']>>;
311
+ name: Scalars['String']['output'];
312
+ };
313
+ export declare enum TopicalSort {
314
+ Bearish = "BEARISH",
315
+ Bullish = "BULLISH",
316
+ Hot = "HOT",
317
+ Popular = "POPULAR",
318
+ Volatile = "VOLATILE"
319
+ }
320
+ export declare enum ValueAtRiskBars {
321
+ C100 = "C100",
322
+ C200 = "C200",
323
+ C300 = "C300"
324
+ }
325
+ export type ValueAtRiskChart = {
326
+ __typename?: 'ValueAtRiskChart';
327
+ down: ValueAtRiskChartData;
328
+ up: ValueAtRiskChartData;
329
+ };
330
+ export type ValueAtRiskChartData = {
331
+ __typename?: 'ValueAtRiskChartData';
332
+ average: Scalars['Float']['output'];
333
+ max: Scalars['Float']['output'];
334
+ median: Scalars['Float']['output'];
335
+ points?: Maybe<Array<ValueAtRiskChartPoint>>;
336
+ threshold: Scalars['Float']['output'];
337
+ };
338
+ export type ValueAtRiskChartPoint = {
339
+ __typename?: 'ValueAtRiskChartPoint';
340
+ percent: Scalars['Float']['output'];
341
+ pips: Scalars['Float']['output'];
342
+ };
343
+ export declare enum ValueAtRiskDuration {
344
+ C1 = "C1",
345
+ C2 = "C2",
346
+ C3 = "C3",
347
+ C4 = "C4",
348
+ C5 = "C5",
349
+ C10 = "C10"
350
+ }
351
+ export type VolatilityChart = {
352
+ __typename?: 'VolatilityChart';
353
+ pips: Scalars['Float']['output'];
354
+ /** Time point - hour in format hh:mm, Date in UTC, Week in format 'Mo' */
355
+ point: Scalars['String']['output'];
356
+ updatedAt: Scalars['String']['output'];
357
+ };
358
+ export declare enum VolatilityChartTimeSpan {
359
+ /** Valid for: H */
360
+ D5 = "D5",
361
+ /** Valid for: H */
362
+ D10 = "D10",
363
+ /** Valid for: D */
364
+ M1 = "M1",
365
+ /** Valid for: D */
366
+ M3 = "M3",
367
+ /** Valid for: W */
368
+ W5 = "W5",
369
+ /** Valid for: W */
370
+ W10 = "W10"
371
+ }
372
+ export declare enum VolatilityChartTimeUnit {
373
+ D = "D",
374
+ H = "H",
375
+ W = "W"
376
+ }
377
+ export type ValidateInstrumentsQueryVariables = Exact<{
378
+ instruments: Array<InputMaybe<Scalars['String']['input']>> | InputMaybe<Scalars['String']['input']>;
379
+ division?: InputMaybe<Division>;
380
+ }>;
381
+ export type ValidateInstrumentsQuery = {
382
+ __typename?: 'Query';
383
+ mapInstrumentNames?: Array<{
384
+ __typename?: 'Instrument';
385
+ name: string;
386
+ displayName: string;
387
+ } | null> | null;
388
+ };
389
+ 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;
@@ -0,0 +1 @@
1
+ export * from './CrowdViewWidget';
@@ -0,0 +1,4 @@
1
+ import type { Translations } from '@oanda/mono-i18n';
2
+ import type { defaultTranslations } from './translations';
3
+ export type TranslationKey = keyof typeof defaultTranslations;
4
+ export declare const translations: Translations;
@@ -0,0 +1 @@
1
+ export declare const defaultTranslations: {};
package/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,18 @@
1
+ {
2
+ "projectId": "19607517615e88022ba782.45168463",
3
+ "outputDir": "src/translations/sources",
4
+ "esModuleTranslations": "src/translations/translations.ts",
5
+ "messagesFormat": "esModule",
6
+ "esModuleConstName": "defaultTranslations",
7
+ "includeEmptyTranslations": true,
8
+ "downloadOptions": {
9
+ "format": "json",
10
+ "add_newline_eof": true,
11
+ "placeholder_format": "i18n",
12
+ "indentation": "2sp",
13
+ "plural_format": "i18next",
14
+ "export_empty_as": "skip",
15
+ "include_tags": ["common_widgets"],
16
+ "filter_langs": ["en", "zh_TW", "es", "th"]
17
+ }
18
+ }
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@oanda/labs-crowd-view-widget",
3
+ "version": "1.0.1",
4
+ "description": "Labs Crowd View Widget",
5
+ "main": "dist/main/index.js",
6
+ "module": "dist/module/index.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "scripts": {
9
+ "codegen": "graphql-codegen --config codegen.ts"
10
+ },
11
+ "keywords": [],
12
+ "author": "OANDA",
13
+ "license": "UNLICENSED",
14
+ "dependencies": {
15
+ "@oanda/labs-widget-common": "^1.0.183",
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"
22
+ },
23
+ "gitHead": "d3d9d7195725da2215d54d465998ad208e2ce25e"
24
+ }
@@ -0,0 +1,40 @@
1
+ import { ApolloClient, InMemoryCache } from '@apollo/client';
2
+ import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
3
+ import React from 'react';
4
+
5
+ import { Division } from '../gql/types/graphql';
6
+ import { translations } from '../translations';
7
+ import { Main } from './Main';
8
+ import type { CrowdViewConfig } from './types';
9
+
10
+ const CrowdViewWidget = ({
11
+ graphqlUrl,
12
+ locale,
13
+ theme,
14
+ isParamError,
15
+ logoLink,
16
+ }: CrowdViewConfig) => {
17
+ const client = new ApolloClient({
18
+ uri: graphqlUrl,
19
+ cache: new InMemoryCache(),
20
+ });
21
+
22
+ return (
23
+ <WidgetProvider
24
+ client={client}
25
+ locale={locale}
26
+ theme={theme}
27
+ translations={translations}
28
+ >
29
+ <WidgetWrapper
30
+ isParamError={isParamError}
31
+ linkArea="logo"
32
+ logoLink={logoLink}
33
+ >
34
+ <Main division={Division.Oc} />
35
+ </WidgetWrapper>
36
+ </WidgetProvider>
37
+ );
38
+ };
39
+
40
+ export { CrowdViewWidget };
@@ -0,0 +1,91 @@
1
+ import {
2
+ cn,
3
+ Select,
4
+ Size,
5
+ Tabs,
6
+ useLayoutProvider,
7
+ WidgetError,
8
+ } from '@oanda/labs-widget-common';
9
+ import { useLocale } from '@oanda/mono-i18n';
10
+ import React, { useState } from 'react';
11
+
12
+ import { BookType, Division } from '../gql/types/graphql';
13
+ import {
14
+ granularitySelectConfig,
15
+ instrumentSelectConfig,
16
+ instrumentSelectConfigOC,
17
+ navigationConfig,
18
+ } from './config';
19
+ import type { GranularityId, InstrumentId, MainProps } from './types';
20
+
21
+ const Main = ({ division }: MainProps) => {
22
+ const instrumentSelectConfigWithDivision =
23
+ division === Division.Oc
24
+ ? instrumentSelectConfigOC
25
+ : instrumentSelectConfig;
26
+
27
+ const { size } = useLayoutProvider();
28
+ const isDesktop = size === Size.DESKTOP;
29
+ const [bookType, setBookType] = useState(BookType.Order);
30
+ const [instrument, setInstrument] = useState(
31
+ instrumentSelectConfigWithDivision[0]
32
+ );
33
+ const [granularity, setGranularity] = useState(granularitySelectConfig[0]);
34
+ const { lang } = useLocale();
35
+
36
+ return (
37
+ <>
38
+ {size && (
39
+ <div
40
+ className="lw-text-sm lw-tracking-normal"
41
+ data-testid="crowd-view-widget"
42
+ >
43
+ <Tabs
44
+ mobileFullWidth
45
+ activeTab={bookType}
46
+ handleClick={(e) => setBookType(e.currentTarget.value as BookType)}
47
+ items={navigationConfig}
48
+ labelCallback={lang}
49
+ />
50
+ <div className="lw-mb-6 lw-mt-12 lw-flex">
51
+ <div
52
+ className={cn('lw-mr-2', {
53
+ 'lw-w-full': !isDesktop,
54
+ 'lw-w-[280px]': isDesktop,
55
+ })}
56
+ >
57
+ <Select
58
+ options={instrumentSelectConfigWithDivision}
59
+ searchPlaceholder={lang('search')}
60
+ selectLabel={lang('instrument')}
61
+ selectedOption={instrument}
62
+ setSelectedOption={(val) =>
63
+ setInstrument(val as { id: InstrumentId; label: string })
64
+ }
65
+ />
66
+ </div>
67
+ <div
68
+ className={cn({
69
+ 'lw-w-full': !isDesktop,
70
+ 'lw-w-[280px]': isDesktop,
71
+ })}
72
+ >
73
+ <Select
74
+ options={granularitySelectConfig}
75
+ searchPlaceholder={lang('search')}
76
+ selectLabel={lang('granularity')}
77
+ selectedOption={granularity}
78
+ setSelectedOption={(val) =>
79
+ setGranularity(val as { id: GranularityId; label: string })
80
+ }
81
+ />
82
+ </div>
83
+ </div>
84
+ <WidgetError />
85
+ </div>
86
+ )}
87
+ </>
88
+ );
89
+ };
90
+
91
+ export { Main };