@oanda/labs-currency-strength-widget 1.0.24 → 1.0.26

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 (41) hide show
  1. package/CHANGELOG.md +212 -0
  2. package/dist/main/CurrencyStrengthWidget/ChartsWithData.js +26 -13
  3. package/dist/main/CurrencyStrengthWidget/ChartsWithData.js.map +1 -1
  4. package/dist/main/CurrencyStrengthWidget/CurrencyStrengthWidget.js +4 -1
  5. package/dist/main/CurrencyStrengthWidget/CurrencyStrengthWidget.js.map +1 -1
  6. package/dist/main/CurrencyStrengthWidget/Main.js +7 -2
  7. package/dist/main/CurrencyStrengthWidget/Main.js.map +1 -1
  8. package/dist/main/CurrencyStrengthWidget/components/Chart/formatters.js +3 -8
  9. package/dist/main/CurrencyStrengthWidget/components/Chart/formatters.js.map +1 -1
  10. package/dist/main/CurrencyStrengthWidget/components/Chart/types.js.map +1 -1
  11. package/dist/main/CurrencyStrengthWidget/render.js +5 -3
  12. package/dist/main/CurrencyStrengthWidget/render.js.map +1 -1
  13. package/dist/main/CurrencyStrengthWidget/types.js.map +1 -1
  14. package/dist/module/CurrencyStrengthWidget/ChartsWithData.js +27 -14
  15. package/dist/module/CurrencyStrengthWidget/ChartsWithData.js.map +1 -1
  16. package/dist/module/CurrencyStrengthWidget/CurrencyStrengthWidget.js +4 -1
  17. package/dist/module/CurrencyStrengthWidget/CurrencyStrengthWidget.js.map +1 -1
  18. package/dist/module/CurrencyStrengthWidget/Main.js +7 -2
  19. package/dist/module/CurrencyStrengthWidget/Main.js.map +1 -1
  20. package/dist/module/CurrencyStrengthWidget/components/Chart/formatters.js +3 -7
  21. package/dist/module/CurrencyStrengthWidget/components/Chart/formatters.js.map +1 -1
  22. package/dist/module/CurrencyStrengthWidget/components/Chart/types.js.map +1 -1
  23. package/dist/module/CurrencyStrengthWidget/render.js +5 -3
  24. package/dist/module/CurrencyStrengthWidget/render.js.map +1 -1
  25. package/dist/module/CurrencyStrengthWidget/types.js.map +1 -1
  26. package/dist/types/CurrencyStrengthWidget/ChartsWithData.d.ts +2 -1
  27. package/dist/types/CurrencyStrengthWidget/CurrencyStrengthWidget.d.ts +1 -1
  28. package/dist/types/CurrencyStrengthWidget/Main.d.ts +2 -1
  29. package/dist/types/CurrencyStrengthWidget/components/Chart/formatters.d.ts +4 -4
  30. package/dist/types/CurrencyStrengthWidget/components/Chart/types.d.ts +6 -3
  31. package/dist/types/CurrencyStrengthWidget/types.d.ts +4 -0
  32. package/package.json +3 -3
  33. package/src/CurrencyStrengthWidget/ChartsWithData.tsx +24 -8
  34. package/src/CurrencyStrengthWidget/CurrencyStrengthWidget.tsx +2 -2
  35. package/src/CurrencyStrengthWidget/Main.tsx +3 -2
  36. package/src/CurrencyStrengthWidget/components/Chart/formatters.ts +9 -16
  37. package/src/CurrencyStrengthWidget/components/Chart/types.ts +7 -3
  38. package/src/CurrencyStrengthWidget/render.tsx +4 -3
  39. package/src/CurrencyStrengthWidget/types.ts +5 -0
  40. package/test/Main.test.tsx +15 -0
  41. package/test/sortData.test.ts +24 -67
package/CHANGELOG.md CHANGED
@@ -3,6 +3,218 @@
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.26 (2024-04-04)
7
+
8
+
9
+
10
+ ## 1.0.107 (2024-04-03)
11
+
12
+
13
+
14
+ ## 1.0.106 (2024-03-29)
15
+
16
+
17
+
18
+ ## 1.0.105 (2024-03-28)
19
+
20
+
21
+
22
+ ## 1.0.104 (2024-03-21)
23
+
24
+
25
+
26
+ ## 1.0.103 (2024-03-20)
27
+
28
+
29
+
30
+ ## 1.0.102 (2024-03-20)
31
+
32
+
33
+
34
+ ## 1.0.101 (2024-03-13)
35
+
36
+
37
+
38
+ ## 1.0.100 (2024-03-12)
39
+
40
+
41
+
42
+ ## 1.0.99 (2024-03-11)
43
+
44
+
45
+
46
+ ## 1.0.98 (2024-03-07)
47
+
48
+
49
+
50
+ ## 1.0.97 (2024-03-06)
51
+
52
+
53
+
54
+ ## 1.0.96 (2024-03-06)
55
+
56
+
57
+
58
+ ## 1.0.95 (2024-03-04)
59
+
60
+
61
+
62
+ ## 1.0.94 (2024-02-29)
63
+
64
+
65
+
66
+ ## 1.0.93 (2024-02-28)
67
+
68
+
69
+
70
+ ## 1.0.92 (2024-02-28)
71
+
72
+
73
+
74
+ ## 1.0.91 (2024-02-23)
75
+
76
+
77
+
78
+ ## 1.0.90 (2024-02-23)
79
+
80
+
81
+
82
+ ## 1.0.89 (2024-02-21)
83
+
84
+
85
+
86
+ ## 1.0.88 (2024-02-21)
87
+
88
+
89
+
90
+ ## 1.0.87 (2024-02-20)
91
+
92
+
93
+
94
+ ## 1.0.86 (2024-02-20)
95
+
96
+
97
+
98
+ ## 1.0.85 (2024-02-13)
99
+
100
+
101
+
102
+ ## 1.0.84 (2024-02-13)
103
+
104
+
105
+
106
+ ## 1.0.83 (2024-02-09)
107
+
108
+ **Note:** Version bump only for package @oanda/labs-currency-strength-widget
109
+
110
+
111
+
112
+
113
+
114
+ ## 1.0.25 (2024-04-03)
115
+
116
+
117
+
118
+ ## 1.0.106 (2024-03-29)
119
+
120
+
121
+
122
+ ## 1.0.105 (2024-03-28)
123
+
124
+
125
+
126
+ ## 1.0.104 (2024-03-21)
127
+
128
+
129
+
130
+ ## 1.0.103 (2024-03-20)
131
+
132
+
133
+
134
+ ## 1.0.102 (2024-03-20)
135
+
136
+
137
+
138
+ ## 1.0.101 (2024-03-13)
139
+
140
+
141
+
142
+ ## 1.0.100 (2024-03-12)
143
+
144
+
145
+
146
+ ## 1.0.99 (2024-03-11)
147
+
148
+
149
+
150
+ ## 1.0.98 (2024-03-07)
151
+
152
+
153
+
154
+ ## 1.0.97 (2024-03-06)
155
+
156
+
157
+
158
+ ## 1.0.96 (2024-03-06)
159
+
160
+
161
+
162
+ ## 1.0.95 (2024-03-04)
163
+
164
+
165
+
166
+ ## 1.0.94 (2024-02-29)
167
+
168
+
169
+
170
+ ## 1.0.93 (2024-02-28)
171
+
172
+
173
+
174
+ ## 1.0.92 (2024-02-28)
175
+
176
+
177
+
178
+ ## 1.0.91 (2024-02-23)
179
+
180
+
181
+
182
+ ## 1.0.90 (2024-02-23)
183
+
184
+
185
+
186
+ ## 1.0.89 (2024-02-21)
187
+
188
+
189
+
190
+ ## 1.0.88 (2024-02-21)
191
+
192
+
193
+
194
+ ## 1.0.87 (2024-02-20)
195
+
196
+
197
+
198
+ ## 1.0.86 (2024-02-20)
199
+
200
+
201
+
202
+ ## 1.0.85 (2024-02-13)
203
+
204
+
205
+
206
+ ## 1.0.84 (2024-02-13)
207
+
208
+
209
+
210
+ ## 1.0.83 (2024-02-09)
211
+
212
+ **Note:** Version bump only for package @oanda/labs-currency-strength-widget
213
+
214
+
215
+
216
+
217
+
6
218
  ## 1.0.24 (2024-03-29)
7
219
 
8
220
 
@@ -14,8 +14,11 @@ var _formatters = require("./components/Chart/formatters");
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
- const ChartWithData = () => {
18
- var _data$currencyStrengt, _data$currencyStrengt2, _sortData$currencyStr;
17
+ const ChartWithData = _ref => {
18
+ var _data$currencyStrengt, _data$currencyStrengt2, _data$currencyStrengt3, _data$currencyStrengt4;
19
+ let {
20
+ currency
21
+ } = _ref;
19
22
  const {
20
23
  size
21
24
  } = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
@@ -29,24 +32,34 @@ const ChartWithData = () => {
29
32
  });
30
33
  const showChart = (data === null || data === void 0 ? void 0 : data.currencyStrength) && (data === null || data === void 0 || (_data$currencyStrengt = data.currencyStrength) === null || _data$currencyStrengt === void 0 ? void 0 : _data$currencyStrengt.length) > 0;
31
34
  const showError = (data === null || data === void 0 || (_data$currencyStrengt2 = data.currencyStrength) === null || _data$currencyStrengt2 === void 0 ? void 0 : _data$currencyStrengt2.length) === 0 || error;
35
+ const currencyData = currency ? data === null || data === void 0 || (_data$currencyStrengt3 = data.currencyStrength) === null || _data$currencyStrengt3 === void 0 ? void 0 : _data$currencyStrengt3.filter(item => item.currency === currency) : data === null || data === void 0 || (_data$currencyStrengt4 = data.currencyStrength) === null || _data$currencyStrengt4 === void 0 ? void 0 : _data$currencyStrengt4.slice().sort(_formatters.sortCurrencies);
32
36
  return _react.default.createElement(_react.default.Fragment, null, loading && _react.default.createElement("div", {
33
- className: "lw-flex lw-h-[461px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
37
+ className: (0, _classnames.default)('lw-flex lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary', {
38
+ 'lw-h-[461px]': !currency,
39
+ 'lw-h-[135px]': currency
40
+ })
34
41
  }, _react.default.createElement(_labsWidgetCommon.Spinner, {
35
42
  size: _labsWidgetCommon.SpinnerSize.lg
36
43
  })), !loading && showChart && _react.default.createElement("div", {
37
44
  "data-testid": "currency-strength-chart-wrapper",
38
45
  className: (0, _classnames.default)('lw-grid lw-place-content-center lw-gap-7', {
39
- 'lw-grid-cols-3 ': isDesktop,
40
- 'lw-grid-cols-1': !isDesktop
46
+ 'lw-grid-cols-3 ': isDesktop && !currency,
47
+ 'lw-grid-cols-1': !isDesktop || currency
48
+ })
49
+ }, currencyData && currencyData.map(item => {
50
+ var _item$strengthRelatio;
51
+ return _react.default.createElement("div", {
52
+ key: item.currency,
53
+ className: "lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center"
54
+ }, _react.default.createElement(_Chart.Chart, {
55
+ currency: item.currency,
56
+ values: (_item$strengthRelatio = item.strengthRelation) === null || _item$strengthRelatio === void 0 ? void 0 : _item$strengthRelatio.slice().sort(_formatters.sortCurrencies)
57
+ }));
58
+ })), !loading && showError && _react.default.createElement("div", {
59
+ className: (0, _classnames.default)('lw-flex lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary', {
60
+ 'lw-h-[425px]': !currency,
61
+ 'lw-h-[135px]': currency
41
62
  })
42
- }, (_sortData$currencyStr = (0, _formatters.sortData)(data).currencyStrength) === null || _sortData$currencyStr === void 0 ? void 0 : _sortData$currencyStr.map(item => _react.default.createElement("div", {
43
- key: item.currency,
44
- className: "lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center"
45
- }, _react.default.createElement(_Chart.Chart, {
46
- currency: item.currency,
47
- values: item.strengthRelation
48
- })))), !loading && showError && _react.default.createElement("div", {
49
- className: "lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
50
63
  }, _react.default.createElement(_labsWidgetCommon.ChartError, null)));
51
64
  };
52
65
  exports.ChartWithData = ChartWithData;
@@ -1 +1 @@
1
- {"version":3,"file":"ChartsWithData.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_classnames","_interopRequireDefault","_getCurrencyStrength","_Chart","_formatters","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ChartWithData","_data$currencyStrengt","_data$currencyStrengt2","_sortData$currencyStr","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","loading","data","error","useQuery","getCurrencyStrength","fetchPolicy","showChart","currencyStrength","length","showError","createElement","Fragment","className","Spinner","SpinnerSize","lg","classnames","sortData","map","item","key","currency","Chart","values","strengthRelation","ChartError","exports"],"sources":["../../../src/CurrencyStrengthWidget/ChartsWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Size, Spinner, SpinnerSize,\n ThemeContext,\n} from '@oanda/labs-widget-common';\nimport classnames from 'classnames';\nimport { getCurrencyStrength } from '../gql/getCurrencyStrength';\nimport { GetCurrencyStrengthQuery } from '../gql/types/graphql';\nimport { Chart } from './components/Chart';\nimport { sortData } from './components/Chart/formatters';\n\nconst ChartWithData = () => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<GetCurrencyStrengthQuery>(getCurrencyStrength, {\n fetchPolicy: 'cache-and-network',\n });\n\n const showChart = data?.currencyStrength && data?.currencyStrength?.length > 0;\n const showError = data?.currencyStrength?.length === 0 || error;\n\n return (\n <>\n {loading\n && (\n <div className=\"lw-flex lw-h-[461px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && showChart && (\n <div\n data-testid=\"currency-strength-chart-wrapper\"\n className={classnames('lw-grid lw-place-content-center lw-gap-7', {\n 'lw-grid-cols-3 ': isDesktop,\n 'lw-grid-cols-1': !isDesktop,\n })}\n >\n {sortData(data).currencyStrength?.map((item) => (\n <div key={item.currency} className=\"lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center\">\n <Chart currency={item.currency} values={item.strengthRelation!} />\n </div>\n ))}\n </div>\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAA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Y,iCAAiC;IAC7CE,SAAS,EAAE,IAAAI,mBAAU,EAAC,0CAA0C,EAAE;MAChE,iBAAiB,EAAEnB,SAAS;MAC5B,gBAAgB,EAAE,CAACA;IACrB,CAAC;EAAE,IAAAJ,qBAAA,GAEF,IAAAwB,oBAAQ,EAAChB,IAAI,CAAC,CAACM,gBAAgB,cAAAd,qBAAA,uBAA/BA,qBAAA,CAAiCyB,GAAG,CAAEC,IAAI,IACzC5D,MAAA,CAAAY,OAAA,CAAAuC,aAAA;IAAKU,GAAG,EAAED,IAAI,CAACE,QAAS;IAACT,SAAS,EAAC;EAAkE,GACnGrD,MAAA,CAAAY,OAAA,CAAAuC,aAAA,CAAC3C,MAAA,CAAAuD,KAAK;IAACD,QAAQ,EAAEF,IAAI,CAACE,QAAS;IAACE,MAAM,EAAEJ,IAAI,CAACK;EAAkB,CAAE,CAC9D,CACN,CACE,CACN,EACA,CAACxB,OAAO,IAAIS,SAAS,IACpBlD,MAAA,CAAAY,OAAA,CAAAuC,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChHrD,MAAA,CAAAY,OAAA,CAAAuC,aAAA,CAAC/C,iBAAA,CAAA8D,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAACC,OAAA,CAAApC,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"file":"ChartsWithData.js","names":["_react","_interopRequireWildcard","require","_client","_labsWidgetCommon","_classnames","_interopRequireDefault","_getCurrencyStrength","_Chart","_formatters","obj","__esModule","default","_getRequireWildcardCache","e","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ChartWithData","_ref","_data$currencyStrengt","_data$currencyStrengt2","_data$currencyStrengt3","_data$currencyStrengt4","currency","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","loading","data","error","useQuery","getCurrencyStrength","fetchPolicy","showChart","currencyStrength","length","showError","currencyData","filter","item","slice","sort","sortCurrencies","createElement","Fragment","className","classnames","Spinner","SpinnerSize","lg","map","_item$strengthRelatio","key","Chart","values","strengthRelation","ChartError","exports"],"sources":["../../../src/CurrencyStrengthWidget/ChartsWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Size, Spinner, SpinnerSize,\n ThemeContext,\n} from '@oanda/labs-widget-common';\nimport classnames from 'classnames';\nimport { getCurrencyStrength } from '../gql/getCurrencyStrength';\nimport { GetCurrencyStrengthQuery } from '../gql/types/graphql';\nimport { Chart } from './components/Chart';\nimport { sortCurrencies } from './components/Chart/formatters';\nimport { WidgetProps } from './types';\n\nconst ChartWithData = ({ currency }: WidgetProps) => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<GetCurrencyStrengthQuery>(getCurrencyStrength, {\n fetchPolicy: 'cache-and-network',\n });\n\n const showChart = data?.currencyStrength && data?.currencyStrength?.length > 0;\n const showError = data?.currencyStrength?.length === 0 || error;\n\n const currencyData = currency\n ? data?.currencyStrength?.filter((item) => item.currency === currency)\n : data?.currencyStrength?.slice().sort(sortCurrencies);\n\n return (\n <>\n {loading\n && (\n <div className={classnames('lw-flex lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary', {\n 'lw-h-[461px]': !currency,\n 'lw-h-[135px]': currency,\n })}\n >\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && showChart && (\n <div\n data-testid=\"currency-strength-chart-wrapper\"\n className={classnames('lw-grid lw-place-content-center lw-gap-7', {\n 'lw-grid-cols-3 ': isDesktop && !currency,\n 'lw-grid-cols-1': !isDesktop || currency,\n })}\n >\n {currencyData && currencyData.map((item) => (\n <div key={item.currency} className=\"lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center\">\n <Chart\n currency={item.currency}\n values={item.strengthRelation?.slice().sort(sortCurrencies)!}\n />\n </div>\n ))}\n </div>\n )}\n {!loading && showError && (\n <div className={classnames('lw-flex lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary', {\n 'lw-h-[425px]': !currency,\n 'lw-h-[135px]': currency,\n })}\n >\n <ChartError />\n </div>\n )}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAIA,IAAAG,WAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AAEA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAA+D,SAAAI,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAb,wBAAAa,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAH,UAAA,SAAAG,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAF,OAAA,EAAAE,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAJ,CAAA,UAAAG,CAAA,CAAAE,GAAA,CAAAL,CAAA,OAAAM,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAZ,CAAA,oBAAAY,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAd,CAAA,EAAAY,CAAA,SAAAG,CAAA,GAAAP,CAAA,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KAAK;MACJjC,QAAQ,EAAEmB,IAAI,CAACnB,QAAS;MACxBkC,MAAM,GAAAH,qBAAA,GAAEZ,IAAI,CAACgB,gBAAgB,cAAAJ,qBAAA,uBAArBA,qBAAA,CAAuBX,KAAK,CAAC,CAAC,CAACC,IAAI,CAACC,0BAAc;IAAG,CAC9D,CACE,CAAC;EAAA,CACP,CACE,CACN,EACA,CAACf,OAAO,IAAIS,SAAS,IACpBrD,MAAA,CAAAY,OAAA,CAAAgD,aAAA;IAAKE,SAAS,EAAE,IAAAC,mBAAU,EAAC,sFAAsF,EAAE;MACjH,cAAc,EAAE,CAAC1B,QAAQ;MACzB,cAAc,EAAEA;IAClB,CAAC;EAAE,GAEDrC,MAAA,CAAAY,OAAA,CAAAgD,aAAA,CAACxD,iBAAA,CAAAqE,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAACC,OAAA,CAAA3C,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -14,6 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
14
14
  const CurrencyStrengthWidget = _ref => {
15
15
  let {
16
16
  graphqlUrl,
17
+ currency,
17
18
  locale,
18
19
  theme,
19
20
  isParamError
@@ -31,7 +32,9 @@ const CurrencyStrengthWidget = _ref => {
31
32
  client: client
32
33
  }, isParamError ? _react.default.createElement("div", {
33
34
  className: "lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
34
- }, _react.default.createElement(_labsWidgetCommon.ChartError, null)) : _react.default.createElement(_Main.Main, null))));
35
+ }, _react.default.createElement(_labsWidgetCommon.ChartError, null)) : _react.default.createElement(_Main.Main, {
36
+ currency: currency
37
+ }))));
35
38
  };
36
39
  exports.CurrencyStrengthWidget = CurrencyStrengthWidget;
37
40
  //# sourceMappingURL=CurrencyStrengthWidget.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurrencyStrengthWidget.js","names":["_react","_interopRequireDefault","require","_monoI18n","_client","_labsWidgetCommon","_translations","_Main","obj","__esModule","default","CurrencyStrengthWidget","_ref","graphqlUrl","locale","theme","isParamError","client","ApolloClient","uri","cache","InMemoryCache","createElement","ThemeProvider","LocaleProvider","getLocale","translations","ApolloProvider","className","ChartError","Main","exports"],"sources":["../../../src/CurrencyStrengthWidget/CurrencyStrengthWidget.tsx"],"sourcesContent":["import React from 'react';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { ChartError, ThemeProvider, getLocale } from '@oanda/labs-widget-common';\nimport { CurrencyStrengthConfig } from './types';\nimport { translations } from '../translations';\nimport { Main } from './Main';\n\nconst CurrencyStrengthWidget = ({\n graphqlUrl, locale, theme, isParamError,\n}: CurrencyStrengthConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n return (\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : <Main />}\n </ApolloProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { CurrencyStrengthWidget };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA8B,SAAAD,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE9B,MAAMG,sBAAsB,GAAGC,IAAA,IAED;EAAA,IAFE;IAC9BC,UAAU;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EACL,CAAC,GAAAJ,IAAA;EACvB,MAAMK,MAAM,GAAG,IAAIC,oBAAY,CAAC;IAC9BC,GAAG,EAAEN,UAAU;IACfO,KAAK,EAAE,IAAIC,qBAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,OACErB,MAAA,CAAAU,OAAA,CAAAY,aAAA,CAACjB,iBAAA,CAAAkB,aAAa;IAACR,KAAK,EAAEA;EAAM,GAC1Bf,MAAA,CAAAU,OAAA,CAAAY,aAAA,CAACnB,SAAA,CAAAqB,cAAc;IAACV,MAAM,EAAE,IAAAW,2BAAS,EAACX,MAAM,CAAE;IAACY,YAAY,EAAEA;EAAa,GACpE1B,MAAA,CAAAU,OAAA,CAAAY,aAAA,CAAClB,OAAA,CAAAuB,cAAc;IAACV,MAAM,EAAEA;EAAO,GAC5BD,YAAY,GACXhB,MAAA,CAAAU,OAAA,CAAAY,aAAA;IAAKM,SAAS,EAAC;EAAmG,GAChH5B,MAAA,CAAAU,OAAA,CAAAY,aAAA,CAACjB,iBAAA,CAAAwB,UAAU,MAAE,CACV,CAAC,GACJ7B,MAAA,CAAAU,OAAA,CAAAY,aAAA,CAACf,KAAA,CAAAuB,IAAI,MAAE,CACG,CACF,CACH,CAAC;AAEpB,CAAC;AAACC,OAAA,CAAApB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"file":"CurrencyStrengthWidget.js","names":["_react","_interopRequireDefault","require","_monoI18n","_client","_labsWidgetCommon","_translations","_Main","obj","__esModule","default","CurrencyStrengthWidget","_ref","graphqlUrl","currency","locale","theme","isParamError","client","ApolloClient","uri","cache","InMemoryCache","createElement","ThemeProvider","LocaleProvider","getLocale","translations","ApolloProvider","className","ChartError","Main","exports"],"sources":["../../../src/CurrencyStrengthWidget/CurrencyStrengthWidget.tsx"],"sourcesContent":["import React from 'react';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { ChartError, ThemeProvider, getLocale } from '@oanda/labs-widget-common';\nimport { CurrencyStrengthConfig } from './types';\nimport { translations } from '../translations';\nimport { Main } from './Main';\n\nconst CurrencyStrengthWidget = ({\n graphqlUrl, currency, locale, theme, isParamError,\n}: CurrencyStrengthConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n return (\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : <Main currency={currency} />}\n </ApolloProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { CurrencyStrengthWidget };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA8B,SAAAD,uBAAAO,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE9B,MAAMG,sBAAsB,GAAGC,IAAA,IAED;EAAA,IAFE;IAC9BC,UAAU;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EACf,CAAC,GAAAL,IAAA;EACvB,MAAMM,MAAM,GAAG,IAAIC,oBAAY,CAAC;IAC9BC,GAAG,EAAEP,UAAU;IACfQ,KAAK,EAAE,IAAIC,qBAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,OACEtB,MAAA,CAAAU,OAAA,CAAAa,aAAA,CAAClB,iBAAA,CAAAmB,aAAa;IAACR,KAAK,EAAEA;EAAM,GAC1BhB,MAAA,CAAAU,OAAA,CAAAa,aAAA,CAACpB,SAAA,CAAAsB,cAAc;IAACV,MAAM,EAAE,IAAAW,2BAAS,EAACX,MAAM,CAAE;IAACY,YAAY,EAAEA;EAAa,GACpE3B,MAAA,CAAAU,OAAA,CAAAa,aAAA,CAACnB,OAAA,CAAAwB,cAAc;IAACV,MAAM,EAAEA;EAAO,GAC5BD,YAAY,GACXjB,MAAA,CAAAU,OAAA,CAAAa,aAAA;IAAKM,SAAS,EAAC;EAAmG,GAChH7B,MAAA,CAAAU,OAAA,CAAAa,aAAA,CAAClB,iBAAA,CAAAyB,UAAU,MAAE,CACV,CAAC,GACJ9B,MAAA,CAAAU,OAAA,CAAAa,aAAA,CAAChB,KAAA,CAAAwB,IAAI;IAACjB,QAAQ,EAAEA;EAAS,CAAE,CACjB,CACF,CACH,CAAC;AAEpB,CAAC;AAACkB,OAAA,CAAArB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
@@ -10,7 +10,10 @@ var _labsWidgetCommon = require("@oanda/labs-widget-common");
10
10
  var _ChartsWithData = require("./ChartsWithData");
11
11
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
12
12
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
13
- const Main = () => {
13
+ const Main = _ref => {
14
+ let {
15
+ currency
16
+ } = _ref;
14
17
  const {
15
18
  lang
16
19
  } = (0, _monoI18n.useLocale)();
@@ -23,7 +26,9 @@ const Main = () => {
23
26
  className: "lw-mb-8 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold"
24
27
  }, _react.default.createElement("span", null, "".concat(lang('daily'), " (").concat(lang('minute', {
25
28
  count: 5
26
- }), ")"))), _react.default.createElement(_ChartsWithData.ChartWithData, null)));
29
+ }), ")"))), _react.default.createElement(_ChartsWithData.ChartWithData, {
30
+ currency: currency
31
+ })));
27
32
  };
28
33
  exports.Main = Main;
29
34
  //# sourceMappingURL=Main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_monoI18n","_labsWidgetCommon","_ChartsWithData","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","lang","useLocale","size","useContext","ThemeContext","createElement","Fragment","className","concat","count","ChartWithData","exports"],"sources":["../../../src/CurrencyStrengthWidget/Main.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { ThemeContext } from '@oanda/labs-widget-common';\nimport { ChartWithData } from './ChartsWithData';\n\nconst Main = () => {\n const { lang } = useLocale();\n const { size } = useContext(ThemeContext);\n\n return (\n <>\n {size && (\n <div data-testid=\"currency-strength-wrapper\">\n <div className=\"lw-mb-8 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold\">\n <span>{`${lang('daily')} (${lang('minute', { count: 5 })})`}</span>\n </div>\n <ChartWithData />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAAiD,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAA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OAAA,CAAAoB,aAAA;IAAK,eAAY;EAA2B,GAC1ChC,MAAA,CAAAY,OAAA,CAAAoB,aAAA;IAAKE,SAAS,EAAC;EAAwE,GACrFlC,MAAA,CAAAY,OAAA,CAAAoB,aAAA,kBAAAG,MAAA,CAAUR,IAAI,CAAC,OAAO,CAAC,QAAAQ,MAAA,CAAKR,IAAI,CAAC,QAAQ,EAAE;IAAES,KAAK,EAAE;EAAE,CAAC,CAAC,MAAU,CAC/D,CAAC,EACNpC,MAAA,CAAAY,OAAA,CAAAoB,aAAA,CAAC3B,eAAA,CAAAgC,aAAa,MAAE,CACb,CAEL,CAAC;AAEP,CAAC;AAACC,OAAA,CAAAZ,IAAA,GAAAA,IAAA","ignoreList":[]}
1
+ {"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_monoI18n","_labsWidgetCommon","_ChartsWithData","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","currency","lang","useLocale","size","useContext","ThemeContext","createElement","Fragment","className","concat","count","ChartWithData","exports"],"sources":["../../../src/CurrencyStrengthWidget/Main.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { ThemeContext } from '@oanda/labs-widget-common';\nimport { ChartWithData } from './ChartsWithData';\nimport { WidgetProps } from './types';\n\nconst Main = ({ currency }: WidgetProps) => {\n const { lang } = useLocale();\n const { size } = useContext(ThemeContext);\n\n return (\n <>\n {size && (\n <div data-testid=\"currency-strength-wrapper\">\n <div className=\"lw-mb-8 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold\">\n <span>{`${lang('daily')} (${lang('minute', { count: 5 })})`}</span>\n </div>\n <ChartWithData currency={currency} />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,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,GAAAD,IAAA;EACrC,MAAM;IAAEE;EAAK,CAAC,GAAG,IAAAC,mBAAS,EAAC,CAAC;EAC5B,MAAM;IAAEC;EAAK,CAAC,GAAG,IAAAC,iBAAU,EAACC,8BAAY,CAAC;EAEzC,OACEjC,MAAA,CAAAY,OAAA,CAAAsB,aAAA,CAAAlC,MAAA,CAAAY,OAAA,CAAAuB,QAAA,QACGJ,IAAI,IACL/B,MAAA,CAAAY,OAAA,CAAAsB,aAAA;IAAK,eAAY;EAA2B,GAC1ClC,MAAA,CAAAY,OAAA,CAAAsB,aAAA;IAAKE,SAAS,EAAC;EAAwE,GACrFpC,MAAA,CAAAY,OAAA,CAAAsB,aAAA,kBAAAG,MAAA,CAAUR,IAAI,CAAC,OAAO,CAAC,QAAAQ,MAAA,CAAKR,IAAI,CAAC,QAAQ,EAAE;IAAES,KAAK,EAAE;EAAE,CAAC,CAAC,MAAU,CAC/D,CAAC,EACNtC,MAAA,CAAAY,OAAA,CAAAsB,aAAA,CAAC7B,eAAA,CAAAkC,aAAa;IAACX,QAAQ,EAAEA;EAAS,CAAE,CACjC,CAEL,CAAC;AAEP,CAAC;AAACY,OAAA,CAAAd,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.tooltipFormatter = exports.sortData = void 0;
6
+ exports.tooltipFormatter = exports.sortCurrencies = void 0;
7
7
  var _constants = require("./constants");
8
8
  const tooltipFormatter = _ref => {
9
9
  let {
@@ -16,11 +16,6 @@ const tooltipFormatter = _ref => {
16
16
  return "\n<div>\n <div style=\"margin-bottom:5px;\">".concat(currency, " ").concat(lang('vs'), " ").concat(name, "</div>\n <div style=\"display:flex;align-items:center;\">").concat(marker, " ").concat(value, "%</div>\n</div>");
17
17
  };
18
18
  exports.tooltipFormatter = tooltipFormatter;
19
- const sortData = data => ({
20
- currencyStrength: data.currencyStrength && [...data.currencyStrength].sort((a, b) => _constants.instrumentsConfig.indexOf(a.currency) - _constants.instrumentsConfig.indexOf(b.currency)).map(item => ({
21
- currency: item.currency,
22
- strengthRelation: item.strengthRelation && [...item.strengthRelation].sort((a, b) => _constants.instrumentsConfig.indexOf(a.currency) - _constants.instrumentsConfig.indexOf(b.currency))
23
- }))
24
- });
25
- exports.sortData = sortData;
19
+ const sortCurrencies = (a, b) => _constants.instrumentsConfig.indexOf(a.currency) - _constants.instrumentsConfig.indexOf(b.currency);
20
+ exports.sortCurrencies = sortCurrencies;
26
21
  //# sourceMappingURL=formatters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","names":["_constants","require","tooltipFormatter","_ref","marker","name","value","currency","lang","concat","exports","sortData","data","currencyStrength","sort","a","b","instrumentsConfig","indexOf","map","item","strengthRelation"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/formatters.ts"],"sourcesContent":["import { GetCurrencyStrengthQuery } from '../../../gql/types/graphql';\nimport { instrumentsConfig } from './constants';\nimport { TooltipFormatterParams } from './types';\n\nexport const tooltipFormatter = ({\n marker,\n name,\n value,\n currency,\n lang,\n}: TooltipFormatterParams) => `\n<div>\n <div style=\"margin-bottom:5px;\">${currency} ${lang('vs')} ${name}</div>\n <div style=\"display:flex;align-items:center;\">${marker} ${value}%</div>\n</div>`;\n\nexport const sortData: (data: GetCurrencyStrengthQuery) => GetCurrencyStrengthQuery = (\n data,\n) => ({\n currencyStrength: data.currencyStrength\n && [...data.currencyStrength].sort(\n (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),\n ).map((item) => ({\n currency: item.currency,\n strengthRelation: item.strengthRelation && [...item.strengthRelation].sort(\n (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),\n ),\n })),\n});\n"],"mappings":";;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAGO,MAAMC,gBAAgB,GAAGC,IAAA;EAAA,IAAC;IAC/BC,MAAM;IACNC,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC;EACsB,CAAC,GAAAL,IAAA;EAAA,uDAAAM,MAAA,CAEWF,QAAQ,OAAAE,MAAA,CAAID,IAAI,CAAC,IAAI,CAAC,OAAAC,MAAA,CAAIJ,IAAI,gEAAAI,MAAA,CAChBL,MAAM,OAAAK,MAAA,CAAIH,KAAK;AAAA,CAC1D;AAACI,OAAA,CAAAR,gBAAA,GAAAA,gBAAA;AAED,MAAMS,QAAsE,GACjFC,IAAI,KACA;EACJC,gBAAgB,EAAED,IAAI,CAACC,gBAAgB,IACpC,CAAC,GAAGD,IAAI,CAACC,gBAAgB,CAAC,CAACC,IAAI,CAChC,CAACC,CAAC,EAAEC,CAAC,KAAKC,4BAAiB,CAACC,OAAO,CAACH,CAAC,CAACR,QAAQ,CAAC,GAAGU,4BAAiB,CAACC,OAAO,CAACF,CAAC,CAACT,QAAQ,CACxF,CAAC,CAACY,GAAG,CAAEC,IAAI,KAAM;IACfb,QAAQ,EAAEa,IAAI,CAACb,QAAQ;IACvBc,gBAAgB,EAAED,IAAI,CAACC,gBAAgB,IAAI,CAAC,GAAGD,IAAI,CAACC,gBAAgB,CAAC,CAACP,IAAI,CACxE,CAACC,CAAC,EAAEC,CAAC,KAAKC,4BAAiB,CAACC,OAAO,CAACH,CAAC,CAACR,QAAQ,CAAC,GAAGU,4BAAiB,CAACC,OAAO,CAACF,CAAC,CAACT,QAAQ,CACxF;EACF,CAAC,CAAC;AACJ,CAAC,CAAC;AAACG,OAAA,CAAAC,QAAA,GAAAA,QAAA","ignoreList":[]}
1
+ {"version":3,"file":"formatters.js","names":["_constants","require","tooltipFormatter","_ref","marker","name","value","currency","lang","concat","exports","sortCurrencies","a","b","instrumentsConfig","indexOf"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/formatters.ts"],"sourcesContent":["import { instrumentsConfig } from './constants';\nimport { SortingParams, TooltipFormatterParams } from './types';\n\nconst tooltipFormatter = ({\n marker,\n name,\n value,\n currency,\n lang,\n}: TooltipFormatterParams) => `\n<div>\n <div style=\"margin-bottom:5px;\">${currency} ${lang('vs')} ${name}</div>\n <div style=\"display:flex;align-items:center;\">${marker} ${value}%</div>\n</div>`;\n\nconst sortCurrencies = (a: SortingParams, b: SortingParams) => instrumentsConfig\n .indexOf(a.currency) - instrumentsConfig.indexOf(b.currency);\n\nexport {\n tooltipFormatter,\n sortCurrencies,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAGA,MAAMC,gBAAgB,GAAGC,IAAA;EAAA,IAAC;IACxBC,MAAM;IACNC,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC;EACsB,CAAC,GAAAL,IAAA;EAAA,uDAAAM,MAAA,CAEWF,QAAQ,OAAAE,MAAA,CAAID,IAAI,CAAC,IAAI,CAAC,OAAAC,MAAA,CAAIJ,IAAI,gEAAAI,MAAA,CAChBL,MAAM,OAAAK,MAAA,CAAIH,KAAK;AAAA,CAC1D;AAACI,OAAA,CAAAR,gBAAA,GAAAA,gBAAA;AAER,MAAMS,cAAc,GAAGA,CAACC,CAAgB,EAAEC,CAAgB,KAAKC,4BAAiB,CAC7EC,OAAO,CAACH,CAAC,CAACL,QAAQ,CAAC,GAAGO,4BAAiB,CAACC,OAAO,CAACF,CAAC,CAACN,QAAQ,CAAC;AAACG,OAAA,CAAAC,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/types.ts"],"sourcesContent":["import { CurrencyName } from '../../../gql/types/graphql';\n\nexport interface CPBChartDataValues {\n currency: CurrencyName;\n percentage: number;\n}\nexport interface ChartProps {\n values: CPBChartDataValues[];\n currency: CurrencyName;\n}\n\nexport interface TooltipFormatterParams {\n marker: string;\n name: string;\n value: number;\n currency: CurrencyName;\n lang: (label: string) => string;\n}\n\nexport type GetOptionProps = {\n values: CPBChartDataValues[],\n currency: CurrencyName,\n lang: (label: string) => string,\n isDark: boolean;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/types.ts"],"sourcesContent":["import { CurrencyName } from '../../../gql/types/graphql';\n\nexport interface CSChartDataValues {\n currency: CurrencyName;\n percentage: number;\n}\nexport interface ChartProps {\n values: CSChartDataValues[];\n currency: CurrencyName;\n}\n\nexport interface TooltipFormatterParams {\n marker: string;\n name: string;\n value: number;\n currency: CurrencyName;\n lang: (label: string) => string;\n}\n\nexport type GetOptionProps = {\n values: CSChartDataValues[],\n currency: CurrencyName,\n lang: (label: string) => string,\n isDark: boolean;\n};\n\nexport type SortingParams = {\n currency: CurrencyName;\n};\n"],"mappings":"","ignoreList":[]}
@@ -8,12 +8,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
8
8
  const {
9
9
  graphqlUrl
10
10
  } = window.widgetsConfig || {};
11
- const volatilityChartParamsElements = document.querySelectorAll('div[data-currency-strength-params]');
12
- volatilityChartParamsElements.forEach(element => {
11
+ const currencyStrengthParamsElements = document.querySelectorAll('div[data-currency-strength-params]');
12
+ currencyStrengthParamsElements.forEach(element => {
13
13
  const root = (0, _client.createRoot)(element);
14
14
  const params = element.getAttribute('data-currency-strength-params');
15
15
  const mode = element.getAttribute('data-mode');
16
16
  const {
17
+ currency,
17
18
  locale
18
19
  } = JSON.parse(params);
19
20
  const isParamError = (0, _labsWidgetCommon.validateToolParams)({
@@ -29,7 +30,8 @@ volatilityChartParamsElements.forEach(element => {
29
30
  graphqlUrl: graphqlUrl,
30
31
  locale: locale,
31
32
  theme: mode,
32
- isParamError: isParamError
33
+ isParamError: isParamError,
34
+ currency: currency
33
35
  }));
34
36
  });
35
37
  //# sourceMappingURL=render.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_CurrencyStrengthWidget","obj","__esModule","default","graphqlUrl","window","widgetsConfig","volatilityChartParamsElements","document","querySelectorAll","forEach","element","root","createRoot","params","getAttribute","mode","locale","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","split","render","createElement","CurrencyStrengthWidget","theme"],"sources":["../../../src/CurrencyStrengthWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateToolParams } from '@oanda/labs-widget-common';\nimport { CurrencyStrengthWidget } from './CurrencyStrengthWidget';\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst volatilityChartParamsElements = document.querySelectorAll('div[data-currency-strength-params]');\n\nvolatilityChartParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-currency-strength-params');\n const mode = element.getAttribute('data-mode');\n const { locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({ locale, graphqlUrl }, [\n {\n name: 'locale',\n valueCheck: (value) => value.split('-')[0] === 'en' || value.split('-')[0] === 'zh',\n }, {\n name: 'graphqlUrl',\n }]);\n\n root.render(\n <CurrencyStrengthWidget\n graphqlUrl={graphqlUrl}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n />,\n );\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AAAkE,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAElE,MAAM;EACJG;AACF,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE9B,MAAMC,6BAA6B,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,oCAAoC,CAAC;AAErGF,6BAA6B,CAACG,OAAO,CAAEC,OAAO,IAAK;EACjD,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;IAAEE;EAAO,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACL,MAAgB,CAAC;EAE/C,MAAMM,YAAY,GAAG,IAAAC,oCAAkB,EAAC;IAAEJ,MAAM;IAAEb;EAAW,CAAC,EAAE,CAC9D;IACEkB,IAAI,EAAE,QAAQ;IACdC,UAAU,EAAGC,KAAK,IAAKA,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAID,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK;EACjF,CAAC,EAAE;IACDH,IAAI,EAAE;EACR,CAAC,CAAC,CAAC;EAELV,IAAI,CAACc,MAAM,CACT/B,MAAA,CAAAQ,OAAA,CAAAwB,aAAA,CAAC3B,uBAAA,CAAA4B,sBAAsB;IACrBxB,UAAU,EAAEA,UAAW;IACvBa,MAAM,EAAEA,MAAO;IACfY,KAAK,EAAEb,IAAc;IACrBI,YAAY,EAAEA;EAAa,CAC5B,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"render.js","names":["_react","_interopRequireDefault","require","_client","_labsWidgetCommon","_CurrencyStrengthWidget","obj","__esModule","default","graphqlUrl","window","widgetsConfig","currencyStrengthParamsElements","document","querySelectorAll","forEach","element","root","createRoot","params","getAttribute","mode","currency","locale","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","split","render","createElement","CurrencyStrengthWidget","theme"],"sources":["../../../src/CurrencyStrengthWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateToolParams } from '@oanda/labs-widget-common';\nimport { CurrencyStrengthWidget } from './CurrencyStrengthWidget';\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst currencyStrengthParamsElements = document.querySelectorAll('div[data-currency-strength-params]');\n\ncurrencyStrengthParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-currency-strength-params');\n const mode = element.getAttribute('data-mode');\n const { currency, locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({ locale, graphqlUrl }, [\n {\n name: 'locale',\n valueCheck: (value) => value.split('-')[0] === 'en' || value.split('-')[0] === 'zh',\n }, {\n name: 'graphqlUrl',\n }]);\n\n root.render(\n <CurrencyStrengthWidget\n graphqlUrl={graphqlUrl}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n currency={currency}\n />,\n );\n});\n"],"mappings":";;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AAAkE,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAElE,MAAM;EACJG;AACF,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE9B,MAAMC,8BAA8B,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,oCAAoC,CAAC;AAEtGF,8BAA8B,CAACG,OAAO,CAAEC,OAAO,IAAK;EAClD,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;IAAEE,QAAQ;IAAEC;EAAO,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACN,MAAgB,CAAC;EAEzD,MAAMO,YAAY,GAAG,IAAAC,oCAAkB,EAAC;IAAEJ,MAAM;IAAEd;EAAW,CAAC,EAAE,CAC9D;IACEmB,IAAI,EAAE,QAAQ;IACdC,UAAU,EAAGC,KAAK,IAAKA,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAID,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK;EACjF,CAAC,EAAE;IACDH,IAAI,EAAE;EACR,CAAC,CAAC,CAAC;EAELX,IAAI,CAACe,MAAM,CACThC,MAAA,CAAAQ,OAAA,CAAAyB,aAAA,CAAC5B,uBAAA,CAAA6B,sBAAsB;IACrBzB,UAAU,EAAEA,UAAW;IACvBc,MAAM,EAAEA,MAAO;IACfY,KAAK,EAAEd,IAAc;IACrBK,YAAY,EAAEA,YAAa;IAC3BJ,QAAQ,EAAEA;EAAS,CACpB,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/CurrencyStrengthWidget/types.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\n\nexport interface CurrencyStrengthConfig {\n graphqlUrl: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n}\n\nexport interface CurrencyStrengthWrapperConfig extends CurrencyStrengthConfig {\n renderElementId: string;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/CurrencyStrengthWidget/types.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\n\nexport interface CurrencyStrengthConfig {\n graphqlUrl: string;\n locale: Locale;\n theme?: Theme;\n currency?: string;\n isParamError?: boolean;\n}\n\nexport interface CurrencyStrengthWrapperConfig extends CurrencyStrengthConfig {\n renderElementId: string;\n}\n\nexport interface WidgetProps {\n currency?: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -4,9 +4,12 @@ import { ChartError, Size, Spinner, SpinnerSize, ThemeContext } from '@oanda/lab
4
4
  import classnames from 'classnames';
5
5
  import { getCurrencyStrength } from '../gql/getCurrencyStrength';
6
6
  import { Chart } from './components/Chart';
7
- import { sortData } from './components/Chart/formatters';
8
- const ChartWithData = () => {
9
- var _data$currencyStrengt, _data$currencyStrengt2, _sortData$currencyStr;
7
+ import { sortCurrencies } from './components/Chart/formatters';
8
+ const ChartWithData = _ref => {
9
+ var _data$currencyStrengt, _data$currencyStrengt2, _data$currencyStrengt3, _data$currencyStrengt4;
10
+ let {
11
+ currency
12
+ } = _ref;
10
13
  const {
11
14
  size
12
15
  } = useContext(ThemeContext);
@@ -20,24 +23,34 @@ const ChartWithData = () => {
20
23
  });
21
24
  const showChart = (data === null || data === void 0 ? void 0 : data.currencyStrength) && (data === null || data === void 0 || (_data$currencyStrengt = data.currencyStrength) === null || _data$currencyStrengt === void 0 ? void 0 : _data$currencyStrengt.length) > 0;
22
25
  const showError = (data === null || data === void 0 || (_data$currencyStrengt2 = data.currencyStrength) === null || _data$currencyStrengt2 === void 0 ? void 0 : _data$currencyStrengt2.length) === 0 || error;
26
+ const currencyData = currency ? data === null || data === void 0 || (_data$currencyStrengt3 = data.currencyStrength) === null || _data$currencyStrengt3 === void 0 ? void 0 : _data$currencyStrengt3.filter(item => item.currency === currency) : data === null || data === void 0 || (_data$currencyStrengt4 = data.currencyStrength) === null || _data$currencyStrengt4 === void 0 ? void 0 : _data$currencyStrengt4.slice().sort(sortCurrencies);
23
27
  return React.createElement(React.Fragment, null, loading && React.createElement("div", {
24
- className: "lw-flex lw-h-[461px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
28
+ className: classnames('lw-flex lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary', {
29
+ 'lw-h-[461px]': !currency,
30
+ 'lw-h-[135px]': currency
31
+ })
25
32
  }, React.createElement(Spinner, {
26
33
  size: SpinnerSize.lg
27
34
  })), !loading && showChart && React.createElement("div", {
28
35
  "data-testid": "currency-strength-chart-wrapper",
29
36
  className: classnames('lw-grid lw-place-content-center lw-gap-7', {
30
- 'lw-grid-cols-3 ': isDesktop,
31
- 'lw-grid-cols-1': !isDesktop
37
+ 'lw-grid-cols-3 ': isDesktop && !currency,
38
+ 'lw-grid-cols-1': !isDesktop || currency
39
+ })
40
+ }, currencyData && currencyData.map(item => {
41
+ var _item$strengthRelatio;
42
+ return React.createElement("div", {
43
+ key: item.currency,
44
+ className: "lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center"
45
+ }, React.createElement(Chart, {
46
+ currency: item.currency,
47
+ values: (_item$strengthRelatio = item.strengthRelation) === null || _item$strengthRelatio === void 0 ? void 0 : _item$strengthRelatio.slice().sort(sortCurrencies)
48
+ }));
49
+ })), !loading && showError && React.createElement("div", {
50
+ className: classnames('lw-flex lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary', {
51
+ 'lw-h-[425px]': !currency,
52
+ 'lw-h-[135px]': currency
32
53
  })
33
- }, (_sortData$currencyStr = sortData(data).currencyStrength) === null || _sortData$currencyStr === void 0 ? void 0 : _sortData$currencyStr.map(item => React.createElement("div", {
34
- key: item.currency,
35
- className: "lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center"
36
- }, React.createElement(Chart, {
37
- currency: item.currency,
38
- values: item.strengthRelation
39
- })))), !loading && showError && React.createElement("div", {
40
- className: "lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
41
54
  }, React.createElement(ChartError, null)));
42
55
  };
43
56
  export { ChartWithData };
@@ -1 +1 @@
1
- {"version":3,"file":"ChartsWithData.js","names":["React","useContext","useQuery","ChartError","Size","Spinner","SpinnerSize","ThemeContext","classnames","getCurrencyStrength","Chart","sortData","ChartWithData","_data$currencyStrengt","_data$currencyStrengt2","_sortData$currencyStr","size","isDesktop","DESKTOP","loading","data","error","fetchPolicy","showChart","currencyStrength","length","showError","createElement","Fragment","className","lg","map","item","key","currency","values","strengthRelation"],"sources":["../../../src/CurrencyStrengthWidget/ChartsWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Size, Spinner, SpinnerSize,\n ThemeContext,\n} from '@oanda/labs-widget-common';\nimport classnames from 'classnames';\nimport { getCurrencyStrength } from '../gql/getCurrencyStrength';\nimport { GetCurrencyStrengthQuery } from '../gql/types/graphql';\nimport { Chart } from './components/Chart';\nimport { sortData } from './components/Chart/formatters';\n\nconst ChartWithData = () => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<GetCurrencyStrengthQuery>(getCurrencyStrength, {\n fetchPolicy: 'cache-and-network',\n });\n\n const showChart = data?.currencyStrength && data?.currencyStrength?.length > 0;\n const showError = data?.currencyStrength?.length === 0 || error;\n\n return (\n <>\n {loading\n && (\n <div className=\"lw-flex lw-h-[461px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && showChart && (\n <div\n data-testid=\"currency-strength-chart-wrapper\"\n className={classnames('lw-grid lw-place-content-center lw-gap-7', {\n 'lw-grid-cols-3 ': isDesktop,\n 'lw-grid-cols-1': !isDesktop,\n })}\n >\n {sortData(data).currencyStrength?.map((item) => (\n <div key={item.currency} className=\"lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center\">\n <Chart currency={item.currency} values={item.strengthRelation!} />\n </div>\n ))}\n </div>\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SACEC,UAAU,EAAEC,IAAI,EAAEC,OAAO,EAAEC,WAAW,EACtCC,YAAY,QACP,2BAA2B;AAClC,OAAOC,UAAU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C5B,gBAAgB,EAAE,CAACA;IACrB,CAAC;EAAE,IAAAF,qBAAA,GAEFJ,QAAQ,CAACS,IAAI,CAAC,CAACI,gBAAgB,cAAAT,qBAAA,uBAA/BA,qBAAA,CAAiCgB,GAAG,CAAEC,IAAI,IACzChC,KAAA,CAAA2B,aAAA;IAAKM,GAAG,EAAED,IAAI,CAACE,QAAS;IAACL,SAAS,EAAC;EAAkE,GACnG7B,KAAA,CAAA2B,aAAA,CAACjB,KAAK;IAACwB,QAAQ,EAAEF,IAAI,CAACE,QAAS;IAACC,MAAM,EAAEH,IAAI,CAACI;EAAkB,CAAE,CAC9D,CACN,CACE,CACN,EACA,CAACjB,OAAO,IAAIO,SAAS,IACpB1B,KAAA,CAAA2B,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChH7B,KAAA,CAAA2B,aAAA,CAACxB,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAED,SAASS,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"ChartsWithData.js","names":["React","useContext","useQuery","ChartError","Size","Spinner","SpinnerSize","ThemeContext","classnames","getCurrencyStrength","Chart","sortCurrencies","ChartWithData","_ref","_data$currencyStrengt","_data$currencyStrengt2","_data$currencyStrengt3","_data$currencyStrengt4","currency","size","isDesktop","DESKTOP","loading","data","error","fetchPolicy","showChart","currencyStrength","length","showError","currencyData","filter","item","slice","sort","createElement","Fragment","className","lg","map","_item$strengthRelatio","key","values","strengthRelation"],"sources":["../../../src/CurrencyStrengthWidget/ChartsWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError, Size, Spinner, SpinnerSize,\n ThemeContext,\n} from '@oanda/labs-widget-common';\nimport classnames from 'classnames';\nimport { getCurrencyStrength } from '../gql/getCurrencyStrength';\nimport { GetCurrencyStrengthQuery } from '../gql/types/graphql';\nimport { Chart } from './components/Chart';\nimport { sortCurrencies } from './components/Chart/formatters';\nimport { WidgetProps } from './types';\n\nconst ChartWithData = ({ currency }: WidgetProps) => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { loading, data, error } = useQuery<GetCurrencyStrengthQuery>(getCurrencyStrength, {\n fetchPolicy: 'cache-and-network',\n });\n\n const showChart = data?.currencyStrength && data?.currencyStrength?.length > 0;\n const showError = data?.currencyStrength?.length === 0 || error;\n\n const currencyData = currency\n ? data?.currencyStrength?.filter((item) => item.currency === currency)\n : data?.currencyStrength?.slice().sort(sortCurrencies);\n\n return (\n <>\n {loading\n && (\n <div className={classnames('lw-flex lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary', {\n 'lw-h-[461px]': !currency,\n 'lw-h-[135px]': currency,\n })}\n >\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && showChart && (\n <div\n data-testid=\"currency-strength-chart-wrapper\"\n className={classnames('lw-grid lw-place-content-center lw-gap-7', {\n 'lw-grid-cols-3 ': isDesktop && !currency,\n 'lw-grid-cols-1': !isDesktop || currency,\n })}\n >\n {currencyData && currencyData.map((item) => (\n <div key={item.currency} className=\"lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center\">\n <Chart\n currency={item.currency}\n values={item.strengthRelation?.slice().sort(sortCurrencies)!}\n />\n </div>\n ))}\n </div>\n )}\n {!loading && showError && (\n <div className={classnames('lw-flex lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary', {\n 'lw-h-[425px]': !currency,\n 'lw-h-[135px]': currency,\n })}\n >\n <ChartError />\n </div>\n )}\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SACEC,UAAU,EAAEC,IAAI,EAAEC,OAAO,EAAEC,WAAW,EACtCC,YAAY,QACP,2BAA2B;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,SAASC,mBAAmB,QAAQ,4BAA4B;AAEhE,SAASC,KAA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AAED,SAASS,aAAa","ignoreList":[]}
@@ -7,6 +7,7 @@ import { Main } from './Main';
7
7
  const CurrencyStrengthWidget = _ref => {
8
8
  let {
9
9
  graphqlUrl,
10
+ currency,
10
11
  locale,
11
12
  theme,
12
13
  isParamError
@@ -24,7 +25,9 @@ const CurrencyStrengthWidget = _ref => {
24
25
  client: client
25
26
  }, isParamError ? React.createElement("div", {
26
27
  className: "lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
27
- }, React.createElement(ChartError, null)) : React.createElement(Main, null))));
28
+ }, React.createElement(ChartError, null)) : React.createElement(Main, {
29
+ currency: currency
30
+ }))));
28
31
  };
29
32
  export { CurrencyStrengthWidget };
30
33
  //# sourceMappingURL=CurrencyStrengthWidget.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurrencyStrengthWidget.js","names":["React","LocaleProvider","ApolloClient","InMemoryCache","ApolloProvider","ChartError","ThemeProvider","getLocale","translations","Main","CurrencyStrengthWidget","_ref","graphqlUrl","locale","theme","isParamError","client","uri","cache","createElement","className"],"sources":["../../../src/CurrencyStrengthWidget/CurrencyStrengthWidget.tsx"],"sourcesContent":["import React from 'react';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { ChartError, ThemeProvider, getLocale } from '@oanda/labs-widget-common';\nimport { CurrencyStrengthConfig } from './types';\nimport { translations } from '../translations';\nimport { Main } from './Main';\n\nconst CurrencyStrengthWidget = ({\n graphqlUrl, locale, theme, isParamError,\n}: CurrencyStrengthConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n return (\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : <Main />}\n </ApolloProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { CurrencyStrengthWidget };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,YAAY,EAAEC,aAAa,EAAEC,cAAc,QAAQ,gBAAgB;AAC5E,SAASC,UAAU,EAAEC,aAAa,EAAEC,SAAS,QAAQ,2BAA2B;AAEhF,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,IAAI,QAAQ,QAAQ;AAE7B,MAAMC,sBAAsB,GAAGC,IAAA,IAED;EAAA,IAFE;IAC9BC,UAAU;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EACL,CAAC,GAAAJ,IAAA;EACvB,MAAMK,MAAM,GAAG,IAAId,YAAY,CAAC;IAC9Be,GAAG,EAAEL,UAAU;IACfM,KAAK,EAAE,IAAIf,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,OACEH,KAAA,CAAAmB,aAAA,CAACb,aAAa;IAACQ,KAAK,EAAEA;EAAM,GAC1Bd,KAAA,CAAAmB,aAAA,CAAClB,cAAc;IAACY,MAAM,EAAEN,SAAS,CAACM,MAAM,CAAE;IAACL,YAAY,EAAEA;EAAa,GACpER,KAAA,CAAAmB,aAAA,CAACf,cAAc;IAACY,MAAM,EAAEA;EAAO,GAC5BD,YAAY,GACXf,KAAA,CAAAmB,aAAA;IAAKC,SAAS,EAAC;EAAmG,GAChHpB,KAAA,CAAAmB,aAAA,CAACd,UAAU,MAAE,CACV,CAAC,GACJL,KAAA,CAAAmB,aAAA,CAACV,IAAI,MAAE,CACG,CACF,CACH,CAAC;AAEpB,CAAC;AAED,SAASC,sBAAsB","ignoreList":[]}
1
+ {"version":3,"file":"CurrencyStrengthWidget.js","names":["React","LocaleProvider","ApolloClient","InMemoryCache","ApolloProvider","ChartError","ThemeProvider","getLocale","translations","Main","CurrencyStrengthWidget","_ref","graphqlUrl","currency","locale","theme","isParamError","client","uri","cache","createElement","className"],"sources":["../../../src/CurrencyStrengthWidget/CurrencyStrengthWidget.tsx"],"sourcesContent":["import React from 'react';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { ChartError, ThemeProvider, getLocale } from '@oanda/labs-widget-common';\nimport { CurrencyStrengthConfig } from './types';\nimport { translations } from '../translations';\nimport { Main } from './Main';\n\nconst CurrencyStrengthWidget = ({\n graphqlUrl, currency, locale, theme, isParamError,\n}: CurrencyStrengthConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n return (\n <ThemeProvider theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : <Main currency={currency} />}\n </ApolloProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { CurrencyStrengthWidget };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,cAAc,QAAQ,kBAAkB;AACjD,SAASC,YAAY,EAAEC,aAAa,EAAEC,cAAc,QAAQ,gBAAgB;AAC5E,SAASC,UAAU,EAAEC,aAAa,EAAEC,SAAS,QAAQ,2BAA2B;AAEhF,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,IAAI,QAAQ,QAAQ;AAE7B,MAAMC,sBAAsB,GAAGC,IAAA,IAED;EAAA,IAFE;IAC9BC,UAAU;IAAEC,QAAQ;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EACf,CAAC,GAAAL,IAAA;EACvB,MAAMM,MAAM,GAAG,IAAIf,YAAY,CAAC;IAC9BgB,GAAG,EAAEN,UAAU;IACfO,KAAK,EAAE,IAAIhB,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,OACEH,KAAA,CAAAoB,aAAA,CAACd,aAAa;IAACS,KAAK,EAAEA;EAAM,GAC1Bf,KAAA,CAAAoB,aAAA,CAACnB,cAAc;IAACa,MAAM,EAAEP,SAAS,CAACO,MAAM,CAAE;IAACN,YAAY,EAAEA;EAAa,GACpER,KAAA,CAAAoB,aAAA,CAAChB,cAAc;IAACa,MAAM,EAAEA;EAAO,GAC5BD,YAAY,GACXhB,KAAA,CAAAoB,aAAA;IAAKC,SAAS,EAAC;EAAmG,GAChHrB,KAAA,CAAAoB,aAAA,CAACf,UAAU,MAAE,CACV,CAAC,GACJL,KAAA,CAAAoB,aAAA,CAACX,IAAI;IAACI,QAAQ,EAAEA;EAAS,CAAE,CACjB,CACF,CACH,CAAC;AAEpB,CAAC;AAED,SAASH,sBAAsB","ignoreList":[]}
@@ -2,7 +2,10 @@ import React, { useContext } from 'react';
2
2
  import { useLocale } from '@oanda/mono-i18n';
3
3
  import { ThemeContext } from '@oanda/labs-widget-common';
4
4
  import { ChartWithData } from './ChartsWithData';
5
- const Main = () => {
5
+ const Main = _ref => {
6
+ let {
7
+ currency
8
+ } = _ref;
6
9
  const {
7
10
  lang
8
11
  } = useLocale();
@@ -15,7 +18,9 @@ const Main = () => {
15
18
  className: "lw-mb-8 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold"
16
19
  }, React.createElement("span", null, "".concat(lang('daily'), " (").concat(lang('minute', {
17
20
  count: 5
18
- }), ")"))), React.createElement(ChartWithData, null)));
21
+ }), ")"))), React.createElement(ChartWithData, {
22
+ currency: currency
23
+ })));
19
24
  };
20
25
  export { Main };
21
26
  //# sourceMappingURL=Main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Main.js","names":["React","useContext","useLocale","ThemeContext","ChartWithData","Main","lang","size","createElement","Fragment","className","concat","count"],"sources":["../../../src/CurrencyStrengthWidget/Main.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { ThemeContext } from '@oanda/labs-widget-common';\nimport { ChartWithData } from './ChartsWithData';\n\nconst Main = () => {\n const { lang } = useLocale();\n const { size } = useContext(ThemeContext);\n\n return (\n <>\n {size && (\n <div data-testid=\"currency-strength-wrapper\">\n <div className=\"lw-mb-8 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold\">\n <span>{`${lang('daily')} (${lang('minute', { count: 5 })})`}</span>\n </div>\n <ChartWithData />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,YAAY,QAAQ,2BAA2B;AACxD,SAASC,aAAa,QAAQ,kBAAkB;AAEhD,MAAMC,IAAI,GAAGA,CAAA,KAAM;EACjB,MAAM;IAAEC;EAAK,CAAC,GAAGJ,SAAS,CAAC,CAAC;EAC5B,MAAM;IAAEK;EAAK,CAAC,GAAGN,UAAU,CAACE,YAAY,CAAC;EAEzC,OACEH,KAAA,CAAAQ,aAAA,CAAAR,KAAA,CAAAS,QAAA,QACGF,IAAI,IACLP,KAAA,CAAAQ,aAAA;IAAK,eAAY;EAA2B,GAC1CR,KAAA,CAAAQ,aAAA;IAAKE,SAAS,EAAC;EAAwE,GACrFV,KAAA,CAAAQ,aAAA,kBAAAG,MAAA,CAAUL,IAAI,CAAC,OAAO,CAAC,QAAAK,MAAA,CAAKL,IAAI,CAAC,QAAQ,EAAE;IAAEM,KAAK,EAAE;EAAE,CAAC,CAAC,MAAU,CAC/D,CAAC,EACNZ,KAAA,CAAAQ,aAAA,CAACJ,aAAa,MAAE,CACb,CAEL,CAAC;AAEP,CAAC;AAED,SAASC,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"Main.js","names":["React","useContext","useLocale","ThemeContext","ChartWithData","Main","_ref","currency","lang","size","createElement","Fragment","className","concat","count"],"sources":["../../../src/CurrencyStrengthWidget/Main.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { ThemeContext } from '@oanda/labs-widget-common';\nimport { ChartWithData } from './ChartsWithData';\nimport { WidgetProps } from './types';\n\nconst Main = ({ currency }: WidgetProps) => {\n const { lang } = useLocale();\n const { size } = useContext(ThemeContext);\n\n return (\n <>\n {size && (\n <div data-testid=\"currency-strength-wrapper\">\n <div className=\"lw-mb-8 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold\">\n <span>{`${lang('daily')} (${lang('minute', { count: 5 })})`}</span>\n </div>\n <ChartWithData currency={currency} />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,YAAY,QAAQ,2BAA2B;AACxD,SAASC,aAAa,QAAQ,kBAAkB;AAGhD,MAAMC,IAAI,GAAGC,IAAA,IAA+B;EAAA,IAA9B;IAAEC;EAAsB,CAAC,GAAAD,IAAA;EACrC,MAAM;IAAEE;EAAK,CAAC,GAAGN,SAAS,CAAC,CAAC;EAC5B,MAAM;IAAEO;EAAK,CAAC,GAAGR,UAAU,CAACE,YAAY,CAAC;EAEzC,OACEH,KAAA,CAAAU,aAAA,CAAAV,KAAA,CAAAW,QAAA,QACGF,IAAI,IACLT,KAAA,CAAAU,aAAA;IAAK,eAAY;EAA2B,GAC1CV,KAAA,CAAAU,aAAA;IAAKE,SAAS,EAAC;EAAwE,GACrFZ,KAAA,CAAAU,aAAA,kBAAAG,MAAA,CAAUL,IAAI,CAAC,OAAO,CAAC,QAAAK,MAAA,CAAKL,IAAI,CAAC,QAAQ,EAAE;IAAEM,KAAK,EAAE;EAAE,CAAC,CAAC,MAAU,CAC/D,CAAC,EACNd,KAAA,CAAAU,aAAA,CAACN,aAAa;IAACG,QAAQ,EAAEA;EAAS,CAAE,CACjC,CAEL,CAAC;AAEP,CAAC;AAED,SAASF,IAAI","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import { instrumentsConfig } from './constants';
2
- export const tooltipFormatter = _ref => {
2
+ const tooltipFormatter = _ref => {
3
3
  let {
4
4
  marker,
5
5
  name,
@@ -9,10 +9,6 @@ export const tooltipFormatter = _ref => {
9
9
  } = _ref;
10
10
  return "\n<div>\n <div style=\"margin-bottom:5px;\">".concat(currency, " ").concat(lang('vs'), " ").concat(name, "</div>\n <div style=\"display:flex;align-items:center;\">").concat(marker, " ").concat(value, "%</div>\n</div>");
11
11
  };
12
- export const sortData = data => ({
13
- currencyStrength: data.currencyStrength && [...data.currencyStrength].sort((a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency)).map(item => ({
14
- currency: item.currency,
15
- strengthRelation: item.strengthRelation && [...item.strengthRelation].sort((a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency))
16
- }))
17
- });
12
+ const sortCurrencies = (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency);
13
+ export { tooltipFormatter, sortCurrencies };
18
14
  //# sourceMappingURL=formatters.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"formatters.js","names":["instrumentsConfig","tooltipFormatter","_ref","marker","name","value","currency","lang","concat","sortData","data","currencyStrength","sort","a","b","indexOf","map","item","strengthRelation"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/formatters.ts"],"sourcesContent":["import { GetCurrencyStrengthQuery } from '../../../gql/types/graphql';\nimport { instrumentsConfig } from './constants';\nimport { TooltipFormatterParams } from './types';\n\nexport const tooltipFormatter = ({\n marker,\n name,\n value,\n currency,\n lang,\n}: TooltipFormatterParams) => `\n<div>\n <div style=\"margin-bottom:5px;\">${currency} ${lang('vs')} ${name}</div>\n <div style=\"display:flex;align-items:center;\">${marker} ${value}%</div>\n</div>`;\n\nexport const sortData: (data: GetCurrencyStrengthQuery) => GetCurrencyStrengthQuery = (\n data,\n) => ({\n currencyStrength: data.currencyStrength\n && [...data.currencyStrength].sort(\n (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),\n ).map((item) => ({\n currency: item.currency,\n strengthRelation: item.strengthRelation && [...item.strengthRelation].sort(\n (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),\n ),\n })),\n});\n"],"mappings":"AACA,SAASA,iBAAiB,QAAQ,aAAa;AAG/C,OAAO,MAAMC,gBAAgB,GAAGC,IAAA;EAAA,IAAC;IAC/BC,MAAM;IACNC,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC;EACsB,CAAC,GAAAL,IAAA;EAAA,uDAAAM,MAAA,CAEWF,QAAQ,OAAAE,MAAA,CAAID,IAAI,CAAC,IAAI,CAAC,OAAAC,MAAA,CAAIJ,IAAI,gEAAAI,MAAA,CAChBL,MAAM,OAAAK,MAAA,CAAIH,KAAK;AAAA,CAC1D;AAEP,OAAO,MAAMI,QAAsE,GACjFC,IAAI,KACA;EACJC,gBAAgB,EAAED,IAAI,CAACC,gBAAgB,IACpC,CAAC,GAAGD,IAAI,CAACC,gBAAgB,CAAC,CAACC,IAAI,CAChC,CAACC,CAAC,EAAEC,CAAC,KAAKd,iBAAiB,CAACe,OAAO,CAACF,CAAC,CAACP,QAAQ,CAAC,GAAGN,iBAAiB,CAACe,OAAO,CAACD,CAAC,CAACR,QAAQ,CACxF,CAAC,CAACU,GAAG,CAAEC,IAAI,KAAM;IACfX,QAAQ,EAAEW,IAAI,CAACX,QAAQ;IACvBY,gBAAgB,EAAED,IAAI,CAACC,gBAAgB,IAAI,CAAC,GAAGD,IAAI,CAACC,gBAAgB,CAAC,CAACN,IAAI,CACxE,CAACC,CAAC,EAAEC,CAAC,KAAKd,iBAAiB,CAACe,OAAO,CAACF,CAAC,CAACP,QAAQ,CAAC,GAAGN,iBAAiB,CAACe,OAAO,CAACD,CAAC,CAACR,QAAQ,CACxF;EACF,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"formatters.js","names":["instrumentsConfig","tooltipFormatter","_ref","marker","name","value","currency","lang","concat","sortCurrencies","a","b","indexOf"],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/formatters.ts"],"sourcesContent":["import { instrumentsConfig } from './constants';\nimport { SortingParams, TooltipFormatterParams } from './types';\n\nconst tooltipFormatter = ({\n marker,\n name,\n value,\n currency,\n lang,\n}: TooltipFormatterParams) => `\n<div>\n <div style=\"margin-bottom:5px;\">${currency} ${lang('vs')} ${name}</div>\n <div style=\"display:flex;align-items:center;\">${marker} ${value}%</div>\n</div>`;\n\nconst sortCurrencies = (a: SortingParams, b: SortingParams) => instrumentsConfig\n .indexOf(a.currency) - instrumentsConfig.indexOf(b.currency);\n\nexport {\n tooltipFormatter,\n sortCurrencies,\n};\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,aAAa;AAG/C,MAAMC,gBAAgB,GAAGC,IAAA;EAAA,IAAC;IACxBC,MAAM;IACNC,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC;EACsB,CAAC,GAAAL,IAAA;EAAA,uDAAAM,MAAA,CAEWF,QAAQ,OAAAE,MAAA,CAAID,IAAI,CAAC,IAAI,CAAC,OAAAC,MAAA,CAAIJ,IAAI,gEAAAI,MAAA,CAChBL,MAAM,OAAAK,MAAA,CAAIH,KAAK;AAAA,CAC1D;AAEP,MAAMI,cAAc,GAAGA,CAACC,CAAgB,EAAEC,CAAgB,KAAKX,iBAAiB,CAC7EY,OAAO,CAACF,CAAC,CAACJ,QAAQ,CAAC,GAAGN,iBAAiB,CAACY,OAAO,CAACD,CAAC,CAACL,QAAQ,CAAC;AAE9D,SACEL,gBAAgB,EAChBQ,cAAc","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/types.ts"],"sourcesContent":["import { CurrencyName } from '../../../gql/types/graphql';\n\nexport interface CPBChartDataValues {\n currency: CurrencyName;\n percentage: number;\n}\nexport interface ChartProps {\n values: CPBChartDataValues[];\n currency: CurrencyName;\n}\n\nexport interface TooltipFormatterParams {\n marker: string;\n name: string;\n value: number;\n currency: CurrencyName;\n lang: (label: string) => string;\n}\n\nexport type GetOptionProps = {\n values: CPBChartDataValues[],\n currency: CurrencyName,\n lang: (label: string) => string,\n isDark: boolean;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyStrengthWidget/components/Chart/types.ts"],"sourcesContent":["import { CurrencyName } from '../../../gql/types/graphql';\n\nexport interface CSChartDataValues {\n currency: CurrencyName;\n percentage: number;\n}\nexport interface ChartProps {\n values: CSChartDataValues[];\n currency: CurrencyName;\n}\n\nexport interface TooltipFormatterParams {\n marker: string;\n name: string;\n value: number;\n currency: CurrencyName;\n lang: (label: string) => string;\n}\n\nexport type GetOptionProps = {\n values: CSChartDataValues[],\n currency: CurrencyName,\n lang: (label: string) => string,\n isDark: boolean;\n};\n\nexport type SortingParams = {\n currency: CurrencyName;\n};\n"],"mappings":"","ignoreList":[]}
@@ -5,12 +5,13 @@ import { CurrencyStrengthWidget } from './CurrencyStrengthWidget';
5
5
  const {
6
6
  graphqlUrl
7
7
  } = window.widgetsConfig || {};
8
- const volatilityChartParamsElements = document.querySelectorAll('div[data-currency-strength-params]');
9
- volatilityChartParamsElements.forEach(element => {
8
+ const currencyStrengthParamsElements = document.querySelectorAll('div[data-currency-strength-params]');
9
+ currencyStrengthParamsElements.forEach(element => {
10
10
  const root = createRoot(element);
11
11
  const params = element.getAttribute('data-currency-strength-params');
12
12
  const mode = element.getAttribute('data-mode');
13
13
  const {
14
+ currency,
14
15
  locale
15
16
  } = JSON.parse(params);
16
17
  const isParamError = validateToolParams({
@@ -26,7 +27,8 @@ volatilityChartParamsElements.forEach(element => {
26
27
  graphqlUrl: graphqlUrl,
27
28
  locale: locale,
28
29
  theme: mode,
29
- isParamError: isParamError
30
+ isParamError: isParamError,
31
+ currency: currency
30
32
  }));
31
33
  });
32
34
  //# sourceMappingURL=render.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["React","createRoot","validateToolParams","CurrencyStrengthWidget","graphqlUrl","window","widgetsConfig","volatilityChartParamsElements","document","querySelectorAll","forEach","element","root","params","getAttribute","mode","locale","JSON","parse","isParamError","name","valueCheck","value","split","render","createElement","theme"],"sources":["../../../src/CurrencyStrengthWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateToolParams } from '@oanda/labs-widget-common';\nimport { CurrencyStrengthWidget } from './CurrencyStrengthWidget';\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst volatilityChartParamsElements = document.querySelectorAll('div[data-currency-strength-params]');\n\nvolatilityChartParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-currency-strength-params');\n const mode = element.getAttribute('data-mode');\n const { locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({ locale, graphqlUrl }, [\n {\n name: 'locale',\n valueCheck: (value) => value.split('-')[0] === 'en' || value.split('-')[0] === 'zh',\n }, {\n name: 'graphqlUrl',\n }]);\n\n root.render(\n <CurrencyStrengthWidget\n graphqlUrl={graphqlUrl}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n />,\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAAgBC,kBAAkB,QAAQ,2BAA2B;AACrE,SAASC,sBAAsB,QAAQ,0BAA0B;AAEjE,MAAM;EACJC;AACF,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE9B,MAAMC,6BAA6B,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,oCAAoC,CAAC;AAErGF,6BAA6B,CAACG,OAAO,CAAEC,OAAO,IAAK;EACjD,MAAMC,IAAI,GAAGX,UAAU,CAACU,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;IAAEE;EAAO,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACL,MAAgB,CAAC;EAE/C,MAAMM,YAAY,GAAGjB,kBAAkB,CAAC;IAAEc,MAAM;IAAEZ;EAAW,CAAC,EAAE,CAC9D;IACEgB,IAAI,EAAE,QAAQ;IACdC,UAAU,EAAGC,KAAK,IAAKA,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAID,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK;EACjF,CAAC,EAAE;IACDH,IAAI,EAAE;EACR,CAAC,CAAC,CAAC;EAELR,IAAI,CAACY,MAAM,CACTxB,KAAA,CAAAyB,aAAA,CAACtB,sBAAsB;IACrBC,UAAU,EAAEA,UAAW;IACvBY,MAAM,EAAEA,MAAO;IACfU,KAAK,EAAEX,IAAc;IACrBI,YAAY,EAAEA;EAAa,CAC5B,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"render.js","names":["React","createRoot","validateToolParams","CurrencyStrengthWidget","graphqlUrl","window","widgetsConfig","currencyStrengthParamsElements","document","querySelectorAll","forEach","element","root","params","getAttribute","mode","currency","locale","JSON","parse","isParamError","name","valueCheck","value","split","render","createElement","theme"],"sources":["../../../src/CurrencyStrengthWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateToolParams } from '@oanda/labs-widget-common';\nimport { CurrencyStrengthWidget } from './CurrencyStrengthWidget';\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst currencyStrengthParamsElements = document.querySelectorAll('div[data-currency-strength-params]');\n\ncurrencyStrengthParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-currency-strength-params');\n const mode = element.getAttribute('data-mode');\n const { currency, locale } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({ locale, graphqlUrl }, [\n {\n name: 'locale',\n valueCheck: (value) => value.split('-')[0] === 'en' || value.split('-')[0] === 'zh',\n }, {\n name: 'graphqlUrl',\n }]);\n\n root.render(\n <CurrencyStrengthWidget\n graphqlUrl={graphqlUrl}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n currency={currency}\n />,\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAAgBC,kBAAkB,QAAQ,2BAA2B;AACrE,SAASC,sBAAsB,QAAQ,0BAA0B;AAEjE,MAAM;EACJC;AACF,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAE9B,MAAMC,8BAA8B,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,oCAAoC,CAAC;AAEtGF,8BAA8B,CAACG,OAAO,CAAEC,OAAO,IAAK;EAClD,MAAMC,IAAI,GAAGX,UAAU,CAACU,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;IAAEE,QAAQ;IAAEC;EAAO,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACN,MAAgB,CAAC;EAEzD,MAAMO,YAAY,GAAGlB,kBAAkB,CAAC;IAAEe,MAAM;IAAEb;EAAW,CAAC,EAAE,CAC9D;IACEiB,IAAI,EAAE,QAAQ;IACdC,UAAU,EAAGC,KAAK,IAAKA,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,IAAID,KAAK,CAACC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK;EACjF,CAAC,EAAE;IACDH,IAAI,EAAE;EACR,CAAC,CAAC,CAAC;EAELT,IAAI,CAACa,MAAM,CACTzB,KAAA,CAAA0B,aAAA,CAACvB,sBAAsB;IACrBC,UAAU,EAAEA,UAAW;IACvBa,MAAM,EAAEA,MAAO;IACfU,KAAK,EAAEZ,IAAc;IACrBK,YAAY,EAAEA,YAAa;IAC3BJ,QAAQ,EAAEA;EAAS,CACpB,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/CurrencyStrengthWidget/types.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\n\nexport interface CurrencyStrengthConfig {\n graphqlUrl: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n}\n\nexport interface CurrencyStrengthWrapperConfig extends CurrencyStrengthConfig {\n renderElementId: string;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/CurrencyStrengthWidget/types.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\n\nexport interface CurrencyStrengthConfig {\n graphqlUrl: string;\n locale: Locale;\n theme?: Theme;\n currency?: string;\n isParamError?: boolean;\n}\n\nexport interface CurrencyStrengthWrapperConfig extends CurrencyStrengthConfig {\n renderElementId: string;\n}\n\nexport interface WidgetProps {\n currency?: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
- declare const ChartWithData: () => React.JSX.Element;
2
+ import { WidgetProps } from './types';
3
+ declare const ChartWithData: ({ currency }: WidgetProps) => React.JSX.Element;
3
4
  export { ChartWithData };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CurrencyStrengthConfig } from './types';
3
- declare const CurrencyStrengthWidget: ({ graphqlUrl, locale, theme, isParamError, }: CurrencyStrengthConfig) => React.JSX.Element;
3
+ declare const CurrencyStrengthWidget: ({ graphqlUrl, currency, locale, theme, isParamError, }: CurrencyStrengthConfig) => React.JSX.Element;
4
4
  export { CurrencyStrengthWidget };
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
- declare const Main: () => React.JSX.Element;
2
+ import { WidgetProps } from './types';
3
+ declare const Main: ({ currency }: WidgetProps) => React.JSX.Element;
3
4
  export { Main };
@@ -1,4 +1,4 @@
1
- import { GetCurrencyStrengthQuery } from '../../../gql/types/graphql';
2
- import { TooltipFormatterParams } from './types';
3
- export declare const tooltipFormatter: ({ marker, name, value, currency, lang, }: TooltipFormatterParams) => string;
4
- export declare const sortData: (data: GetCurrencyStrengthQuery) => GetCurrencyStrengthQuery;
1
+ import { SortingParams, TooltipFormatterParams } from './types';
2
+ declare const tooltipFormatter: ({ marker, name, value, currency, lang, }: TooltipFormatterParams) => string;
3
+ declare const sortCurrencies: (a: SortingParams, b: SortingParams) => number;
4
+ export { tooltipFormatter, sortCurrencies, };
@@ -1,10 +1,10 @@
1
1
  import { CurrencyName } from '../../../gql/types/graphql';
2
- export interface CPBChartDataValues {
2
+ export interface CSChartDataValues {
3
3
  currency: CurrencyName;
4
4
  percentage: number;
5
5
  }
6
6
  export interface ChartProps {
7
- values: CPBChartDataValues[];
7
+ values: CSChartDataValues[];
8
8
  currency: CurrencyName;
9
9
  }
10
10
  export interface TooltipFormatterParams {
@@ -15,8 +15,11 @@ export interface TooltipFormatterParams {
15
15
  lang: (label: string) => string;
16
16
  }
17
17
  export type GetOptionProps = {
18
- values: CPBChartDataValues[];
18
+ values: CSChartDataValues[];
19
19
  currency: CurrencyName;
20
20
  lang: (label: string) => string;
21
21
  isDark: boolean;
22
22
  };
23
+ export type SortingParams = {
24
+ currency: CurrencyName;
25
+ };
@@ -4,8 +4,12 @@ export interface CurrencyStrengthConfig {
4
4
  graphqlUrl: string;
5
5
  locale: Locale;
6
6
  theme?: Theme;
7
+ currency?: string;
7
8
  isParamError?: boolean;
8
9
  }
9
10
  export interface CurrencyStrengthWrapperConfig extends CurrencyStrengthConfig {
10
11
  renderElementId: string;
11
12
  }
13
+ export interface WidgetProps {
14
+ currency?: string;
15
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-currency-strength-widget",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "description": "Labs Currency Strength Widget",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
@@ -13,7 +13,7 @@
13
13
  "license": "UNLICENSED",
14
14
  "dependencies": {
15
15
  "@apollo/client": "3.9.9",
16
- "@oanda/labs-widget-common": "^1.0.106",
16
+ "@oanda/labs-widget-common": "^1.0.108",
17
17
  "@oanda/mono-i18n": "9.0.0",
18
18
  "echarts": "5.5.0",
19
19
  "echarts-for-react": "3.0.2",
@@ -24,5 +24,5 @@
24
24
  "@graphql-codegen/client-preset": "4.1.0",
25
25
  "@graphql-codegen/typescript": "4.0.1"
26
26
  },
27
- "gitHead": "5c25e850c05391672cee9dfdf1b53aa03b102c12"
27
+ "gitHead": "2081e80b7e0d161cd3d4e7e8c32850a3918e24a3"
28
28
  }
@@ -8,9 +8,10 @@ import classnames from 'classnames';
8
8
  import { getCurrencyStrength } from '../gql/getCurrencyStrength';
9
9
  import { GetCurrencyStrengthQuery } from '../gql/types/graphql';
10
10
  import { Chart } from './components/Chart';
11
- import { sortData } from './components/Chart/formatters';
11
+ import { sortCurrencies } from './components/Chart/formatters';
12
+ import { WidgetProps } from './types';
12
13
 
13
- const ChartWithData = () => {
14
+ const ChartWithData = ({ currency }: WidgetProps) => {
14
15
  const { size } = useContext(ThemeContext);
15
16
  const isDesktop = size === Size.DESKTOP;
16
17
  const { loading, data, error } = useQuery<GetCurrencyStrengthQuery>(getCurrencyStrength, {
@@ -20,11 +21,19 @@ const ChartWithData = () => {
20
21
  const showChart = data?.currencyStrength && data?.currencyStrength?.length > 0;
21
22
  const showError = data?.currencyStrength?.length === 0 || error;
22
23
 
24
+ const currencyData = currency
25
+ ? data?.currencyStrength?.filter((item) => item.currency === currency)
26
+ : data?.currencyStrength?.slice().sort(sortCurrencies);
27
+
23
28
  return (
24
29
  <>
25
30
  {loading
26
31
  && (
27
- <div className="lw-flex lw-h-[461px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
32
+ <div className={classnames('lw-flex lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary', {
33
+ 'lw-h-[461px]': !currency,
34
+ 'lw-h-[135px]': currency,
35
+ })}
36
+ >
28
37
  <Spinner size={SpinnerSize.lg} />
29
38
  </div>
30
39
  )}
@@ -32,19 +41,26 @@ const ChartWithData = () => {
32
41
  <div
33
42
  data-testid="currency-strength-chart-wrapper"
34
43
  className={classnames('lw-grid lw-place-content-center lw-gap-7', {
35
- 'lw-grid-cols-3 ': isDesktop,
36
- 'lw-grid-cols-1': !isDesktop,
44
+ 'lw-grid-cols-3 ': isDesktop && !currency,
45
+ 'lw-grid-cols-1': !isDesktop || currency,
37
46
  })}
38
47
  >
39
- {sortData(data).currencyStrength?.map((item) => (
48
+ {currencyData && currencyData.map((item) => (
40
49
  <div key={item.currency} className="lw-flex lw-h-[135px] lw-flex-1 lw-items-center lw-justify-center">
41
- <Chart currency={item.currency} values={item.strengthRelation!} />
50
+ <Chart
51
+ currency={item.currency}
52
+ values={item.strengthRelation?.slice().sort(sortCurrencies)!}
53
+ />
42
54
  </div>
43
55
  ))}
44
56
  </div>
45
57
  )}
46
58
  {!loading && showError && (
47
- <div className="lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
59
+ <div className={classnames('lw-flex lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary', {
60
+ 'lw-h-[425px]': !currency,
61
+ 'lw-h-[135px]': currency,
62
+ })}
63
+ >
48
64
  <ChartError />
49
65
  </div>
50
66
  )}
@@ -7,7 +7,7 @@ import { translations } from '../translations';
7
7
  import { Main } from './Main';
8
8
 
9
9
  const CurrencyStrengthWidget = ({
10
- graphqlUrl, locale, theme, isParamError,
10
+ graphqlUrl, currency, locale, theme, isParamError,
11
11
  }: CurrencyStrengthConfig) => {
12
12
  const client = new ApolloClient({
13
13
  uri: graphqlUrl,
@@ -22,7 +22,7 @@ const CurrencyStrengthWidget = ({
22
22
  <div className="lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary">
23
23
  <ChartError />
24
24
  </div>
25
- ) : <Main />}
25
+ ) : <Main currency={currency} />}
26
26
  </ApolloProvider>
27
27
  </LocaleProvider>
28
28
  </ThemeProvider>
@@ -2,8 +2,9 @@ import React, { useContext } from 'react';
2
2
  import { useLocale } from '@oanda/mono-i18n';
3
3
  import { ThemeContext } from '@oanda/labs-widget-common';
4
4
  import { ChartWithData } from './ChartsWithData';
5
+ import { WidgetProps } from './types';
5
6
 
6
- const Main = () => {
7
+ const Main = ({ currency }: WidgetProps) => {
7
8
  const { lang } = useLocale();
8
9
  const { size } = useContext(ThemeContext);
9
10
 
@@ -14,7 +15,7 @@ const Main = () => {
14
15
  <div className="lw-mb-8 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold">
15
16
  <span>{`${lang('daily')} (${lang('minute', { count: 5 })})`}</span>
16
17
  </div>
17
- <ChartWithData />
18
+ <ChartWithData currency={currency} />
18
19
  </div>
19
20
  )}
20
21
  </>
@@ -1,8 +1,7 @@
1
- import { GetCurrencyStrengthQuery } from '../../../gql/types/graphql';
2
1
  import { instrumentsConfig } from './constants';
3
- import { TooltipFormatterParams } from './types';
2
+ import { SortingParams, TooltipFormatterParams } from './types';
4
3
 
5
- export const tooltipFormatter = ({
4
+ const tooltipFormatter = ({
6
5
  marker,
7
6
  name,
8
7
  value,
@@ -14,16 +13,10 @@ export const tooltipFormatter = ({
14
13
  <div style="display:flex;align-items:center;">${marker} ${value}%</div>
15
14
  </div>`;
16
15
 
17
- export const sortData: (data: GetCurrencyStrengthQuery) => GetCurrencyStrengthQuery = (
18
- data,
19
- ) => ({
20
- currencyStrength: data.currencyStrength
21
- && [...data.currencyStrength].sort(
22
- (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),
23
- ).map((item) => ({
24
- currency: item.currency,
25
- strengthRelation: item.strengthRelation && [...item.strengthRelation].sort(
26
- (a, b) => instrumentsConfig.indexOf(a.currency) - instrumentsConfig.indexOf(b.currency),
27
- ),
28
- })),
29
- });
16
+ const sortCurrencies = (a: SortingParams, b: SortingParams) => instrumentsConfig
17
+ .indexOf(a.currency) - instrumentsConfig.indexOf(b.currency);
18
+
19
+ export {
20
+ tooltipFormatter,
21
+ sortCurrencies,
22
+ };
@@ -1,11 +1,11 @@
1
1
  import { CurrencyName } from '../../../gql/types/graphql';
2
2
 
3
- export interface CPBChartDataValues {
3
+ export interface CSChartDataValues {
4
4
  currency: CurrencyName;
5
5
  percentage: number;
6
6
  }
7
7
  export interface ChartProps {
8
- values: CPBChartDataValues[];
8
+ values: CSChartDataValues[];
9
9
  currency: CurrencyName;
10
10
  }
11
11
 
@@ -18,8 +18,12 @@ export interface TooltipFormatterParams {
18
18
  }
19
19
 
20
20
  export type GetOptionProps = {
21
- values: CPBChartDataValues[],
21
+ values: CSChartDataValues[],
22
22
  currency: CurrencyName,
23
23
  lang: (label: string) => string,
24
24
  isDark: boolean;
25
25
  };
26
+
27
+ export type SortingParams = {
28
+ currency: CurrencyName;
29
+ };
@@ -7,13 +7,13 @@ const {
7
7
  graphqlUrl,
8
8
  } = window.widgetsConfig || {};
9
9
 
10
- const volatilityChartParamsElements = document.querySelectorAll('div[data-currency-strength-params]');
10
+ const currencyStrengthParamsElements = document.querySelectorAll('div[data-currency-strength-params]');
11
11
 
12
- volatilityChartParamsElements.forEach((element) => {
12
+ currencyStrengthParamsElements.forEach((element) => {
13
13
  const root = createRoot(element);
14
14
  const params = element.getAttribute('data-currency-strength-params');
15
15
  const mode = element.getAttribute('data-mode');
16
- const { locale } = JSON.parse(params as string);
16
+ const { currency, locale } = JSON.parse(params as string);
17
17
 
18
18
  const isParamError = validateToolParams({ locale, graphqlUrl }, [
19
19
  {
@@ -29,6 +29,7 @@ volatilityChartParamsElements.forEach((element) => {
29
29
  locale={locale}
30
30
  theme={mode as Theme}
31
31
  isParamError={isParamError}
32
+ currency={currency}
32
33
  />,
33
34
  );
34
35
  });
@@ -5,9 +5,14 @@ export interface CurrencyStrengthConfig {
5
5
  graphqlUrl: string;
6
6
  locale: Locale;
7
7
  theme?: Theme;
8
+ currency?: string;
8
9
  isParamError?: boolean;
9
10
  }
10
11
 
11
12
  export interface CurrencyStrengthWrapperConfig extends CurrencyStrengthConfig {
12
13
  renderElementId: string;
13
14
  }
15
+
16
+ export interface WidgetProps {
17
+ currency?: string;
18
+ }
@@ -27,5 +27,20 @@ describe('Main component', () => {
27
27
  expect(getByTestId('currency-strength-wrapper')).toBeInTheDocument();
28
28
  expect(getByTestId('spinner')).toBeInTheDocument();
29
29
  expect(await findByTestId('currency-strength-chart-wrapper')).toBeInTheDocument();
30
+ expect(getByTestId('currency-strength-chart-wrapper').children.length).toEqual(8);
31
+ });
32
+ it('should render widget view', async () => {
33
+ const { findByTestId, getByTestId } = render(
34
+ <MockedProvider mocks={mock}>
35
+ <ThemeContext.Provider value={{ size: Size.DESKTOP, isDark: true }}>
36
+ <Main currency="USD" />
37
+ </ThemeContext.Provider>
38
+ </MockedProvider>,
39
+ );
40
+
41
+ expect(getByTestId('currency-strength-wrapper')).toBeInTheDocument();
42
+ expect(getByTestId('spinner')).toBeInTheDocument();
43
+ expect(await findByTestId('currency-strength-chart-wrapper')).toBeInTheDocument();
44
+ expect(getByTestId('currency-strength-chart-wrapper').children.length).toEqual(1);
30
45
  });
31
46
  });
@@ -1,73 +1,30 @@
1
- import { sortData } from '../src/CurrencyStrengthWidget/components/Chart/formatters';
2
- import { CurrencyName, GetCurrencyStrengthQuery } from '../src/gql/types/graphql';
1
+ import { sortCurrencies } from '../src/CurrencyStrengthWidget/components/Chart/formatters';
2
+ import { CurrencyName } from '../src/gql/types/graphql';
3
3
 
4
- const topLevelData: GetCurrencyStrengthQuery = {
5
- currencyStrength: [
6
- { currency: CurrencyName.Aud },
7
- { currency: CurrencyName.Gbp },
8
- { currency: CurrencyName.Jpy },
9
- { currency: CurrencyName.Chf },
10
- { currency: CurrencyName.Cad },
11
- { currency: CurrencyName.Nzd },
12
- { currency: CurrencyName.Usd },
13
- { currency: CurrencyName.Eur },
14
- ],
15
- };
4
+ const topLevelData = [
5
+ { currency: CurrencyName.Aud },
6
+ { currency: CurrencyName.Gbp },
7
+ { currency: CurrencyName.Jpy },
8
+ { currency: CurrencyName.Chf },
9
+ { currency: CurrencyName.Cad },
10
+ { currency: CurrencyName.Nzd },
11
+ { currency: CurrencyName.Usd },
12
+ { currency: CurrencyName.Eur },
13
+ ];
16
14
 
17
- const nestedData: GetCurrencyStrengthQuery = {
18
- currencyStrength: [
19
- {
20
- currency: CurrencyName.Aud,
21
- strengthRelation: [
22
- { currency: CurrencyName.Gbp, percentage: 0.1 },
23
- { currency: CurrencyName.Eur, percentage: 0.2 },
24
- { currency: CurrencyName.Aud, percentage: 0.3 },
25
- { currency: CurrencyName.Jpy, percentage: 0.4 },
26
- { currency: CurrencyName.Nzd, percentage: 0.5 },
27
- { currency: CurrencyName.Chf, percentage: 0.6 },
28
- { currency: CurrencyName.Usd, percentage: 0.7 },
29
- { currency: CurrencyName.Cad, percentage: 0.8 },
30
- ],
31
- },
32
- ],
33
- };
34
-
35
- describe('sortData', () => {
15
+ describe('sortCurrencies', () => {
36
16
  it('should sort top level values', () => {
37
- expect(sortData(topLevelData)).toEqual(
38
- {
39
- currencyStrength: [
40
- { currency: CurrencyName.Usd },
41
- { currency: CurrencyName.Eur },
42
- { currency: CurrencyName.Gbp },
43
- { currency: CurrencyName.Cad },
44
- { currency: CurrencyName.Aud },
45
- { currency: CurrencyName.Chf },
46
- { currency: CurrencyName.Jpy },
47
- { currency: CurrencyName.Nzd },
48
- ],
49
- },
50
- );
51
- });
52
- it('should sort nested values currencies', () => {
53
- expect(sortData(nestedData)).toEqual(
54
- {
55
- currencyStrength: [
56
- {
57
- currency: CurrencyName.Aud,
58
- strengthRelation: [
59
- { currency: CurrencyName.Usd, percentage: 0.7 },
60
- { currency: CurrencyName.Eur, percentage: 0.2 },
61
- { currency: CurrencyName.Gbp, percentage: 0.1 },
62
- { currency: CurrencyName.Cad, percentage: 0.8 },
63
- { currency: CurrencyName.Aud, percentage: 0.3 },
64
- { currency: CurrencyName.Chf, percentage: 0.6 },
65
- { currency: CurrencyName.Jpy, percentage: 0.4 },
66
- { currency: CurrencyName.Nzd, percentage: 0.5 },
67
- ],
68
- },
69
- ],
70
- },
17
+ expect(topLevelData.sort(sortCurrencies)).toEqual(
18
+ [
19
+ { currency: CurrencyName.Usd },
20
+ { currency: CurrencyName.Eur },
21
+ { currency: CurrencyName.Gbp },
22
+ { currency: CurrencyName.Cad },
23
+ { currency: CurrencyName.Aud },
24
+ { currency: CurrencyName.Chf },
25
+ { currency: CurrencyName.Jpy },
26
+ { currency: CurrencyName.Nzd },
27
+ ],
71
28
  );
72
29
  });
73
30
  });