@oanda/labs-currency-power-balance-widget 1.0.30 → 1.0.32

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 (35) hide show
  1. package/CHANGELOG.md +260 -0
  2. package/dist/main/CurrencyPowerBalanceWidget/Tool.js +1 -6
  3. package/dist/main/CurrencyPowerBalanceWidget/Tool.js.map +1 -1
  4. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +9 -4
  5. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
  6. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +20 -11
  7. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
  8. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -1
  9. package/dist/main/CurrencyPowerBalanceWidget/config.js +24 -6
  10. package/dist/main/CurrencyPowerBalanceWidget/config.js.map +1 -1
  11. package/dist/main/translations/sources/en.json +7 -7
  12. package/dist/main/translations/sources/zh_TW.json +4 -7
  13. package/dist/module/CurrencyPowerBalanceWidget/Tool.js +1 -6
  14. package/dist/module/CurrencyPowerBalanceWidget/Tool.js.map +1 -1
  15. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +9 -4
  16. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
  17. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +20 -11
  18. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
  19. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -1
  20. package/dist/module/CurrencyPowerBalanceWidget/config.js +24 -6
  21. package/dist/module/CurrencyPowerBalanceWidget/config.js.map +1 -1
  22. package/dist/module/translations/sources/en.json +7 -7
  23. package/dist/module/translations/sources/zh_TW.json +4 -7
  24. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.d.ts +1 -1
  25. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.d.ts +1 -1
  26. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.d.ts +6 -2
  27. package/dist/types/CurrencyPowerBalanceWidget/config.d.ts +5 -2
  28. package/package.json +3 -3
  29. package/src/CurrencyPowerBalanceWidget/Tool.tsx +0 -3
  30. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +7 -3
  31. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +12 -11
  32. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts +6 -2
  33. package/src/CurrencyPowerBalanceWidget/config.ts +32 -6
  34. package/src/translations/sources/en.json +7 -7
  35. package/src/translations/sources/zh_TW.json +4 -7
package/CHANGELOG.md CHANGED
@@ -3,6 +3,266 @@
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.32 (2024-02-28)
7
+
8
+
9
+
10
+ ## 1.0.92 (2024-02-28)
11
+
12
+
13
+
14
+ ## 1.0.91 (2024-02-23)
15
+
16
+
17
+
18
+ ## 1.0.90 (2024-02-23)
19
+
20
+
21
+
22
+ ## 1.0.89 (2024-02-21)
23
+
24
+
25
+
26
+ ## 1.0.88 (2024-02-21)
27
+
28
+
29
+
30
+ ## 1.0.87 (2024-02-20)
31
+
32
+
33
+
34
+ ## 1.0.86 (2024-02-20)
35
+
36
+
37
+
38
+ ## 1.0.85 (2024-02-13)
39
+
40
+
41
+
42
+ ## 1.0.84 (2024-02-13)
43
+
44
+
45
+
46
+ ## 1.0.83 (2024-02-09)
47
+
48
+
49
+
50
+ ## 1.0.82 (2024-02-05)
51
+
52
+
53
+
54
+ ## 1.0.81 (2024-02-05)
55
+
56
+
57
+
58
+ ## 1.0.80 (2024-02-05)
59
+
60
+
61
+
62
+ ## 1.0.79 (2024-02-05)
63
+
64
+
65
+
66
+ ## 1.0.78 (2024-01-30)
67
+
68
+
69
+
70
+ ## 1.0.77 (2024-01-25)
71
+
72
+
73
+
74
+ ## 1.0.76 (2024-01-25)
75
+
76
+
77
+
78
+ ## 1.0.75 (2024-01-22)
79
+
80
+
81
+
82
+ ## 1.0.74 (2024-01-22)
83
+
84
+
85
+
86
+ ## 1.0.73 (2024-01-22)
87
+
88
+
89
+
90
+ ## 1.0.72 (2024-01-19)
91
+
92
+
93
+
94
+ ## 1.0.71 (2024-01-18)
95
+
96
+
97
+
98
+ ## 1.0.70 (2024-01-17)
99
+
100
+
101
+
102
+ ## 1.0.69 (2024-01-17)
103
+
104
+
105
+
106
+ ## 1.0.68 (2024-01-15)
107
+
108
+
109
+
110
+ ## 1.0.67 (2024-01-15)
111
+
112
+
113
+
114
+ ## 1.0.66 (2024-01-12)
115
+
116
+
117
+
118
+ ## 1.0.65 (2024-01-11)
119
+
120
+
121
+
122
+ ## 1.0.64 (2024-01-11)
123
+
124
+
125
+
126
+ ## 1.0.63 (2024-01-11)
127
+
128
+
129
+
130
+ ## 1.0.62 (2024-01-10)
131
+
132
+ **Note:** Version bump only for package @oanda/labs-currency-power-balance-widget
133
+
134
+
135
+
136
+
137
+
138
+ ## 1.0.31 (2024-02-28)
139
+
140
+
141
+
142
+ ## 1.0.91 (2024-02-23)
143
+
144
+
145
+
146
+ ## 1.0.90 (2024-02-23)
147
+
148
+
149
+
150
+ ## 1.0.89 (2024-02-21)
151
+
152
+
153
+
154
+ ## 1.0.88 (2024-02-21)
155
+
156
+
157
+
158
+ ## 1.0.87 (2024-02-20)
159
+
160
+
161
+
162
+ ## 1.0.86 (2024-02-20)
163
+
164
+
165
+
166
+ ## 1.0.85 (2024-02-13)
167
+
168
+
169
+
170
+ ## 1.0.84 (2024-02-13)
171
+
172
+
173
+
174
+ ## 1.0.83 (2024-02-09)
175
+
176
+
177
+
178
+ ## 1.0.82 (2024-02-05)
179
+
180
+
181
+
182
+ ## 1.0.81 (2024-02-05)
183
+
184
+
185
+
186
+ ## 1.0.80 (2024-02-05)
187
+
188
+
189
+
190
+ ## 1.0.79 (2024-02-05)
191
+
192
+
193
+
194
+ ## 1.0.78 (2024-01-30)
195
+
196
+
197
+
198
+ ## 1.0.77 (2024-01-25)
199
+
200
+
201
+
202
+ ## 1.0.76 (2024-01-25)
203
+
204
+
205
+
206
+ ## 1.0.75 (2024-01-22)
207
+
208
+
209
+
210
+ ## 1.0.74 (2024-01-22)
211
+
212
+
213
+
214
+ ## 1.0.73 (2024-01-22)
215
+
216
+
217
+
218
+ ## 1.0.72 (2024-01-19)
219
+
220
+
221
+
222
+ ## 1.0.71 (2024-01-18)
223
+
224
+
225
+
226
+ ## 1.0.70 (2024-01-17)
227
+
228
+
229
+
230
+ ## 1.0.69 (2024-01-17)
231
+
232
+
233
+
234
+ ## 1.0.68 (2024-01-15)
235
+
236
+
237
+
238
+ ## 1.0.67 (2024-01-15)
239
+
240
+
241
+
242
+ ## 1.0.66 (2024-01-12)
243
+
244
+
245
+
246
+ ## 1.0.65 (2024-01-11)
247
+
248
+
249
+
250
+ ## 1.0.64 (2024-01-11)
251
+
252
+
253
+
254
+ ## 1.0.63 (2024-01-11)
255
+
256
+
257
+
258
+ ## 1.0.62 (2024-01-10)
259
+
260
+ **Note:** Version bump only for package @oanda/labs-currency-power-balance-widget
261
+
262
+
263
+
264
+
265
+
6
266
  ## 1.0.30 (2024-02-23)
7
267
 
8
268
 
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Tool = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
- var _monoI18n = require("@oanda/mono-i18n");
9
8
  var _config = require("./config");
10
9
  var _TimeUnitSwitch = require("./components/TimeUnitSwitch");
11
10
  var _ChartWithData = require("./ChartWithData");
@@ -14,17 +13,13 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
14
13
  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 && Object.prototype.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; }
15
14
  const Tool = () => {
16
15
  const [selectedTimeUnit, setSelectedTimeUnit] = (0, _react.useState)(_graphql.CurrencyPowerBalanceTimeUnit.CurrentDay);
17
- const {
18
- lang
19
- } = (0, _monoI18n.useLocale)();
20
16
  return _react.default.createElement("div", {
21
17
  "data-testid": "currency-power-balance-wrapper",
22
18
  className: "lw-flex lw-flex-col lw-text-sm lw-tracking-normal"
23
19
  }, _react.default.createElement(_TimeUnitSwitch.TimeUnitSwitch, {
24
20
  selected: selectedTimeUnit,
25
21
  callback: setSelectedTimeUnit,
26
- options: _config.timeUnitConfig,
27
- labelCallback: lang
22
+ options: _config.timeUnitConfig
28
23
  }), _react.default.createElement(_ChartWithData.ChartWithData, {
29
24
  timeUnit: selectedTimeUnit
30
25
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"Tool.js","names":["_react","_interopRequireWildcard","require","_monoI18n","_config","_TimeUnitSwitch","_ChartWithData","_graphql","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Tool","selectedTimeUnit","setSelectedTimeUnit","useState","CurrencyPowerBalanceTimeUnit","CurrentDay","lang","useLocale","createElement","className","TimeUnitSwitch","selected","callback","options","timeUnitConfig","labelCallback","ChartWithData","timeUnit","exports"],"sources":["../../../src/CurrencyPowerBalanceWidget/Tool.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { timeUnitConfig } from './config';\nimport { TimeUnitSwitch } from './components/TimeUnitSwitch';\nimport { ChartWithData } from './ChartWithData';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nconst Tool = () => {\n const [selectedTimeUnit, setSelectedTimeUnit] = useState(CurrencyPowerBalanceTimeUnit.CurrentDay);\n const { lang } = useLocale();\n\n return (\n <div\n data-testid=\"currency-power-balance-wrapper\"\n className=\"lw-flex lw-flex-col lw-text-sm lw-tracking-normal\"\n >\n <TimeUnitSwitch\n selected={selectedTimeUnit}\n callback={setSelectedTimeUnit}\n options={timeUnitConfig}\n labelCallback={lang}\n />\n <ChartWithData\n timeUnit={selectedTimeUnit}\n />\n </div>\n );\n};\n\nexport { Tool };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAAoE,SAAAM,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,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAA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,aAAA,CAAC/B,cAAA,CAAAuC,aAAa;IACZC,QAAQ,EAAEhB;EAAiB,CAC5B,CACE,CAAC;AAEV,CAAC;AAACiB,OAAA,CAAAlB,IAAA,GAAAA,IAAA"}
1
+ {"version":3,"file":"Tool.js","names":["_react","_interopRequireWildcard","require","_config","_TimeUnitSwitch","_ChartWithData","_graphql","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","Tool","selectedTimeUnit","setSelectedTimeUnit","useState","CurrencyPowerBalanceTimeUnit","CurrentDay","createElement","className","TimeUnitSwitch","selected","callback","options","timeUnitConfig","ChartWithData","timeUnit","exports"],"sources":["../../../src/CurrencyPowerBalanceWidget/Tool.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { timeUnitConfig } from './config';\nimport { TimeUnitSwitch } from './components/TimeUnitSwitch';\nimport { ChartWithData } from './ChartWithData';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nconst Tool = () => {\n const [selectedTimeUnit, setSelectedTimeUnit] = useState(CurrencyPowerBalanceTimeUnit.CurrentDay);\n\n return (\n <div\n data-testid=\"currency-power-balance-wrapper\"\n className=\"lw-flex lw-flex-col lw-text-sm lw-tracking-normal\"\n >\n <TimeUnitSwitch\n selected={selectedTimeUnit}\n callback={setSelectedTimeUnit}\n options={timeUnitConfig}\n />\n <ChartWithData\n timeUnit={selectedTimeUnit}\n />\n </div>\n );\n};\n\nexport { Tool };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAoE,SAAAK,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAA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SAAS,EAAC;EAAmD,GAE7DnC,MAAA,CAAAa,OAAA,CAAAqB,aAAA,CAAC9B,eAAA,CAAAgC,cAAc;IACbC,QAAQ,EAAER,gBAAiB;IAC3BS,QAAQ,EAAER,mBAAoB;IAC9BS,OAAO,EAAEC;EAAe,CACzB,CAAC,EACFxC,MAAA,CAAAa,OAAA,CAAAqB,aAAA,CAAC7B,cAAA,CAAAoC,aAAa;IACZC,QAAQ,EAAEb;EAAiB,CAC5B,CACE,CAAC;AAEV,CAAC;AAACc,OAAA,CAAAf,IAAA,GAAAA,IAAA"}
@@ -6,23 +6,28 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.TimeUnitSelect = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _labsWidgetCommon = require("@oanda/labs-widget-common");
9
+ var _monoI18n = require("@oanda/mono-i18n");
9
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
11
  const TimeUnitSelect = _ref => {
11
12
  let {
12
13
  selected,
13
14
  options,
14
- callback,
15
- labelCallback
15
+ callback
16
16
  } = _ref;
17
+ const {
18
+ lang
19
+ } = (0, _monoI18n.useLocale)();
17
20
  const selectOptions = options.map(_ref2 => {
18
21
  let {
19
22
  value: id,
20
23
  label,
21
- tooltip
24
+ tooltipLabel
22
25
  } = _ref2;
23
26
  return {
24
27
  id,
25
- label: labelCallback ? labelCallback(tooltip || label) : tooltip || label
28
+ label: tooltipLabel ? lang(tooltipLabel.translationKey, {
29
+ count: tooltipLabel.count
30
+ }) : lang(label)
26
31
  };
27
32
  });
28
33
  const [{
@@ -1 +1 @@
1
- {"version":3,"file":"TimeUnitSelect.js","names":["_react","_interopRequireDefault","require","_labsWidgetCommon","obj","__esModule","default","TimeUnitSelect","_ref","selected","options","callback","labelCallback","selectOptions","map","_ref2","value","id","label","tooltip","selectedLabel","filter","_ref3","createElement","className","Select","selectedOption","setSelectedOption","_ref4","exports"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { Select } from '@oanda/labs-widget-common';\nimport { TimeUnitSwitchProps } from './types';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nconst TimeUnitSelect = ({\n selected, options, callback, labelCallback,\n}: TimeUnitSwitchProps) => {\n const selectOptions = options\n .map(({ value: id, label, tooltip }) => ({\n id,\n label: labelCallback ? labelCallback(tooltip || label) : tooltip || label,\n }));\n const [{ label: selectedLabel }] = selectOptions.filter(({ id }) => id === selected);\n\n return (\n <div data-testid=\"time-unit-select\" className=\"lw-mb-6 lw-w-full\">\n <Select\n options={selectOptions}\n selectedOption={{ id: selected, label: selectedLabel }}\n setSelectedOption={({ id }) => callback(id as CurrencyPowerBalanceTimeUnit)}\n />\n </div>\n );\n};\n\nexport { TimeUnitSelect };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAAmD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAInD,MAAMG,cAAc,GAAGC,IAAA,IAEI;EAAA,IAFH;IACtBC,QAAQ;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EACV,CAAC,GAAAJ,IAAA;EACpB,MAAMK,aAAa,GAAGH,OAAO,CAC1BI,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,KAAK,EAAEC,EAAE;MAAEC,KAAK;MAAEC;IAAQ,CAAC,GAAAJ,KAAA;IAAA,OAAM;MACvCE,EAAE;MACFC,KAAK,EAAEN,aAAa,GAAGA,aAAa,CAACO,OAAO,IAAID,KAAK,CAAC,GAAGC,OAAO,IAAID;IACtE,CAAC;EAAA,CAAC,CAAC;EACL,MAAM,CAAC;IAAEA,KAAK,EAAEE;EAAc,CAAC,CAAC,GAAGP,aAAa,CAACQ,MAAM,CAACC,KAAA;IAAA,IAAC;MAAEL;IAAG,CAAC,GAAAK,KAAA;IAAA,OAAKL,EAAE,KAAKR,QAAQ;EAAA,EAAC;EAEpF,OACET,MAAA,CAAAM,OAAA,CAAAiB,aAAA;IAAK,eAAY,kBAAkB;IAACC,SAAS,EAAC;EAAmB,GAC/DxB,MAAA,CAAAM,OAAA,CAAAiB,aAAA,CAACpB,iBAAA,CAAAsB,MAAM;IACLf,OAAO,EAAEG,aAAc;IACvBa,cAAc,EAAE;MAAET,EAAE,EAAER,QAAQ;MAAES,KAAK,EAAEE;IAAc,CAAE;IACvDO,iBAAiB,EAAEC,KAAA;MAAA,IAAC;QAAEX;MAAG,CAAC,GAAAW,KAAA;MAAA,OAAKjB,QAAQ,CAACM,EAAkC,CAAC;IAAA;EAAC,CAC7E,CACE,CAAC;AAEV,CAAC;AAACY,OAAA,CAAAtB,cAAA,GAAAA,cAAA"}
1
+ {"version":3,"file":"TimeUnitSelect.js","names":["_react","_interopRequireDefault","require","_labsWidgetCommon","_monoI18n","obj","__esModule","default","TimeUnitSelect","_ref","selected","options","callback","lang","useLocale","selectOptions","map","_ref2","value","id","label","tooltipLabel","translationKey","count","selectedLabel","filter","_ref3","createElement","className","Select","selectedOption","setSelectedOption","_ref4","exports"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { Select } from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { TimeUnitSwitchProps } from './types';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nconst TimeUnitSelect = ({\n selected, options, callback,\n}: TimeUnitSwitchProps) => {\n const { lang } = useLocale();\n const selectOptions = options\n .map(({ value: id, label, tooltipLabel }) => ({\n id,\n label: tooltipLabel\n ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })\n : lang(label),\n }));\n const [{ label: selectedLabel }] = selectOptions.filter(({ id }) => id === selected);\n\n return (\n <div data-testid=\"time-unit-select\" className=\"lw-mb-6 lw-w-full\">\n <Select\n options={selectOptions}\n selectedOption={{ id: selected, label: selectedLabel }}\n setSelectedOption={({ id }) => callback(id as CurrencyPowerBalanceTimeUnit)}\n />\n </div>\n );\n};\n\nexport { TimeUnitSelect };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAA6C,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAI7C,MAAMG,cAAc,GAAGC,IAAA,IAEI;EAAA,IAFH;IACtBC,QAAQ;IAAEC,OAAO;IAAEC;EACA,CAAC,GAAAH,IAAA;EACpB,MAAM;IAAEI;EAAK,CAAC,GAAG,IAAAC,mBAAS,EAAC,CAAC;EAC5B,MAAMC,aAAa,GAAGJ,OAAO,CAC1BK,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,KAAK,EAAEC,EAAE;MAAEC,KAAK;MAAEC;IAAa,CAAC,GAAAJ,KAAA;IAAA,OAAM;MAC5CE,EAAE;MACFC,KAAK,EAAEC,YAAY,GACfR,IAAI,CAACQ,YAAY,CAACC,cAAc,EAAE;QAAEC,KAAK,EAAEF,YAAY,CAACE;MAAM,CAAC,CAAC,GAChEV,IAAI,CAACO,KAAK;IAChB,CAAC;EAAA,CAAC,CAAC;EACL,MAAM,CAAC;IAAEA,KAAK,EAAEI;EAAc,CAAC,CAAC,GAAGT,aAAa,CAACU,MAAM,CAACC,KAAA;IAAA,IAAC;MAAEP;IAAG,CAAC,GAAAO,KAAA;IAAA,OAAKP,EAAE,KAAKT,QAAQ;EAAA,EAAC;EAEpF,OACEV,MAAA,CAAAO,OAAA,CAAAoB,aAAA;IAAK,eAAY,kBAAkB;IAACC,SAAS,EAAC;EAAmB,GAC/D5B,MAAA,CAAAO,OAAA,CAAAoB,aAAA,CAACxB,iBAAA,CAAA0B,MAAM;IACLlB,OAAO,EAAEI,aAAc;IACvBe,cAAc,EAAE;MAAEX,EAAE,EAAET,QAAQ;MAAEU,KAAK,EAAEI;IAAc,CAAE;IACvDO,iBAAiB,EAAEC,KAAA;MAAA,IAAC;QAAEb;MAAG,CAAC,GAAAa,KAAA;MAAA,OAAKpB,QAAQ,CAACO,EAAkC,CAAC;IAAA;EAAC,CAC7E,CACE,CAAC;AAEV,CAAC;AAACc,OAAA,CAAAzB,cAAA,GAAAA,cAAA"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.TimeUnitSwitch = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _labsWidgetCommon = require("@oanda/labs-widget-common");
9
+ var _monoI18n = require("@oanda/mono-i18n");
9
10
  var _constants = require("../../constants");
10
11
  var _TimeUnitSelect = require("./TimeUnitSelect");
11
12
  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); }
@@ -14,9 +15,11 @@ const TimeUnitSwitch = _ref => {
14
15
  let {
15
16
  selected,
16
17
  options,
17
- callback,
18
- labelCallback
18
+ callback
19
19
  } = _ref;
20
+ const {
21
+ lang
22
+ } = (0, _monoI18n.useLocale)();
20
23
  const {
21
24
  size
22
25
  } = (0, _react.useContext)(_labsWidgetCommon.ThemeContext);
@@ -27,23 +30,29 @@ const TimeUnitSwitch = _ref => {
27
30
  return _react.default.createElement(_react.default.Fragment, null, isDesktop ? _react.default.createElement("div", {
28
31
  "data-testid": "time-unit-switch",
29
32
  className: "lw-mb-6 lw-flex lw-gap-1 lw-self-end"
30
- }, options.map(item => {
31
- const tooltip = labelCallback && item.tooltip ? labelCallback(item.tooltip) : item.tooltip;
32
- const label = labelCallback ? labelCallback(item.label) : item.label;
33
+ }, options.map(_ref2 => {
34
+ let {
35
+ value,
36
+ label,
37
+ tooltipLabel
38
+ } = _ref2;
39
+ const tooltip = tooltipLabel ? lang(tooltipLabel.translationKey, {
40
+ count: tooltipLabel.count
41
+ }) : tooltipLabel;
42
+ const buttonLabel = lang(label);
33
43
  return _react.default.createElement(_labsWidgetCommon.Button, {
34
- key: item.value,
44
+ key: value,
35
45
  size: _labsWidgetCommon.ButtonSize.full,
36
- variant: selected === item.value ? _labsWidgetCommon.ButtonVariant.primary : _labsWidgetCommon.ButtonVariant.secondary,
46
+ variant: selected === value ? _labsWidgetCommon.ButtonVariant.primary : _labsWidgetCommon.ButtonVariant.secondary,
37
47
  onClick: handleButtonClick,
38
- value: item.value,
48
+ value: value,
39
49
  "data-tooltip-id": _constants.CURRENCY_POWER_BALANCE_TOOLTIP_ID,
40
50
  "data-tooltip-content": tooltip
41
- }, label);
51
+ }, buttonLabel);
42
52
  })) : _react.default.createElement(_TimeUnitSelect.TimeUnitSelect, {
43
53
  selected: selected,
44
54
  callback: callback,
45
- options: options,
46
- labelCallback: labelCallback
55
+ options: options
47
56
  }));
48
57
  };
49
58
  exports.TimeUnitSwitch = TimeUnitSwitch;
@@ -1 +1 @@
1
- {"version":3,"file":"TimeUnitSwitch.js","names":["_react","_interopRequireWildcard","require","_labsWidgetCommon","_constants","_TimeUnitSelect","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","TimeUnitSwitch","_ref","selected","options","callback","labelCallback","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","handleButtonClick","currentTarget","value","createElement","Fragment","className","map","item","tooltip","label","Button","key","ButtonSize","full","variant","ButtonVariant","primary","secondary","onClick","CURRENCY_POWER_BALANCE_TOOLTIP_ID","TimeUnitSelect","exports"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport {\n Button, ButtonSize, ButtonVariant, ThemeContext, Size,\n} from '@oanda/labs-widget-common';\nimport { TimeUnitSwitchProps } from './types';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from '../../constants';\nimport { TimeUnitSelect } from './TimeUnitSelect';\n\nconst TimeUnitSwitch = ({\n selected, options, callback, labelCallback,\n}: TimeUnitSwitchProps) => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n\n const handleButtonClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {\n callback(e.currentTarget.value as CurrencyPowerBalanceTimeUnit);\n };\n\n return (\n <>\n {isDesktop\n ? (\n <div data-testid=\"time-unit-switch\" className=\"lw-mb-6 lw-flex lw-gap-1 lw-self-end\">\n {options.map((item) => {\n const tooltip = labelCallback && item.tooltip\n ? labelCallback(item.tooltip)\n : item.tooltip;\n const label = labelCallback ? labelCallback(item.label) : item.label;\n\n return (\n <Button\n key={item.value}\n size={ButtonSize.full}\n variant={selected === item.value\n ? ButtonVariant.primary\n : ButtonVariant.secondary}\n onClick={handleButtonClick}\n value={item.value}\n data-tooltip-id={CURRENCY_POWER_BALANCE_TOOLTIP_ID}\n data-tooltip-content={tooltip}\n >\n {label}\n </Button>\n );\n })}\n </div>\n )\n : (\n <TimeUnitSelect\n selected={selected}\n callback={callback}\n options={options}\n labelCallback={labelCallback}\n />\n )}\n </>\n );\n};\n\nexport { TimeUnitSwitch };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAKA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAAkD,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA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GAAAA,cAAA"}
1
+ {"version":3,"file":"TimeUnitSwitch.js","names":["_react","_interopRequireWildcard","require","_labsWidgetCommon","_monoI18n","_constants","_TimeUnitSelect","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","TimeUnitSwitch","_ref","selected","options","callback","lang","useLocale","size","useContext","ThemeContext","isDesktop","Size","DESKTOP","handleButtonClick","currentTarget","value","createElement","Fragment","className","map","_ref2","label","tooltipLabel","tooltip","translationKey","count","buttonLabel","Button","key","ButtonSize","full","variant","ButtonVariant","primary","secondary","onClick","CURRENCY_POWER_BALANCE_TOOLTIP_ID","TimeUnitSelect","exports"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport {\n Button, ButtonSize, ButtonVariant, ThemeContext, Size,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { TimeUnitSwitchProps } from './types';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from '../../constants';\nimport { TimeUnitSelect } from './TimeUnitSelect';\n\nconst TimeUnitSwitch = ({\n selected, options, callback,\n}: TimeUnitSwitchProps) => {\n const { lang } = useLocale();\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n\n const handleButtonClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {\n callback(e.currentTarget.value as CurrencyPowerBalanceTimeUnit);\n };\n\n return (\n <>\n {isDesktop\n ? (\n <div data-testid=\"time-unit-switch\" className=\"lw-mb-6 lw-flex lw-gap-1 lw-self-end\">\n {options.map(({ value, label, tooltipLabel }) => {\n const tooltip = tooltipLabel\n ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })\n : tooltipLabel;\n const buttonLabel = lang(label);\n\n return (\n <Button\n key={value}\n size={ButtonSize.full}\n variant={selected === value\n ? ButtonVariant.primary\n : ButtonVariant.secondary}\n onClick={handleButtonClick}\n value={value}\n data-tooltip-id={CURRENCY_POWER_BALANCE_TOOLTIP_ID}\n data-tooltip-content={tooltip}\n >\n {buttonLabel}\n </Button>\n );\n })}\n </div>\n )\n : (\n <TimeUnitSelect\n selected={selected}\n callback={callback}\n options={options}\n />\n )}\n </>\n );\n};\n\nexport { TimeUnitSwitch };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAGA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AAAkD,SAAAK,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,SAAAP,wBAAAO,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,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MAAMI,WAAW,GAAGrB,IAAI,CAACgB,KAAK,CAAC;IAE/B,OACEjD,MAAA,CAAAa,OAAA,CAAA+B,aAAA,CAACzC,iBAAA,CAAAoD,MAAM;MACLC,GAAG,EAAEb,KAAM;MACXR,IAAI,EAAEsB,4BAAU,CAACC,IAAK;MACtBC,OAAO,EAAE7B,QAAQ,KAAKa,KAAK,GACvBiB,+BAAa,CAACC,OAAO,GACrBD,+BAAa,CAACE,SAAU;MAC5BC,OAAO,EAAEtB,iBAAkB;MAC3BE,KAAK,EAAEA,KAAM;MACb,mBAAiBqB,4CAAkC;MACnD,wBAAsBb;IAAQ,GAE7BG,WACK,CAAC;EAEb,CAAC,CACE,CAAC,GAGNtD,MAAA,CAAAa,OAAA,CAAA+B,aAAA,CAACtC,eAAA,CAAA2D,cAAc;IACbnC,QAAQ,EAAEA,QAAS;IACnBE,QAAQ,EAAEA,QAAS;IACnBD,OAAO,EAAEA;EAAQ,CAClB,CAEL,CAAC;AAEP,CAAC;AAACmC,OAAA,CAAAtC,cAAA,GAAAA,cAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nexport interface TimeUnitOption {\n value: CurrencyPowerBalanceTimeUnit;\n label: string;\n tooltip?: string;\n}\n\nexport interface TimeUnitSwitchProps {\n selected: CurrencyPowerBalanceTimeUnit;\n options: TimeUnitOption[];\n callback: (value: CurrencyPowerBalanceTimeUnit) => void;\n labelCallback?: (value: string) => string;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nexport interface TimeUnitOption {\n value: CurrencyPowerBalanceTimeUnit;\n label: string;\n tooltipLabel?: TooltipLabel;\n}\n\nexport interface TimeUnitSwitchProps {\n selected: CurrencyPowerBalanceTimeUnit;\n options: TimeUnitOption[];\n callback: (value: CurrencyPowerBalanceTimeUnit) => void;\n}\n\ntype TooltipLabel = {\n translationKey: string;\n count: number;\n};\n"],"mappings":""}
@@ -8,27 +8,45 @@ var _graphql = require("../gql/types/graphql");
8
8
  const timeUnitConfig = exports.timeUnitConfig = [{
9
9
  value: _graphql.CurrencyPowerBalanceTimeUnit.M3,
10
10
  label: '3m',
11
- tooltip: '3_months'
11
+ tooltipLabel: {
12
+ translationKey: 'month',
13
+ count: 3
14
+ }
12
15
  }, {
13
16
  value: _graphql.CurrencyPowerBalanceTimeUnit.M1,
14
17
  label: '1m',
15
- tooltip: '1_month'
18
+ tooltipLabel: {
19
+ translationKey: 'month',
20
+ count: 1
21
+ }
16
22
  }, {
17
23
  value: _graphql.CurrencyPowerBalanceTimeUnit.W1,
18
24
  label: '1w',
19
- tooltip: '1_week'
25
+ tooltipLabel: {
26
+ translationKey: 'week',
27
+ count: 1
28
+ }
20
29
  }, {
21
30
  value: _graphql.CurrencyPowerBalanceTimeUnit.H24,
22
31
  label: '24h',
23
- tooltip: '24_hours'
32
+ tooltipLabel: {
33
+ translationKey: 'hour',
34
+ count: 24
35
+ }
24
36
  }, {
25
37
  value: _graphql.CurrencyPowerBalanceTimeUnit.H8,
26
38
  label: '8h',
27
- tooltip: '8_hours'
39
+ tooltipLabel: {
40
+ translationKey: 'hour',
41
+ count: 8
42
+ }
28
43
  }, {
29
44
  value: _graphql.CurrencyPowerBalanceTimeUnit.H4,
30
45
  label: '4h',
31
- tooltip: '4_hours'
46
+ tooltipLabel: {
47
+ translationKey: 'hour',
48
+ count: 4
49
+ }
32
50
  }, {
33
51
  value: _graphql.CurrencyPowerBalanceTimeUnit.PreviousDay,
34
52
  label: 'previous_business_day'
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["_graphql","require","timeUnitConfig","exports","value","CurrencyPowerBalanceTimeUnit","M3","label","tooltip","M1","W1","H24","H8","H4","PreviousDay","CurrentDay"],"sources":["../../../src/CurrencyPowerBalanceWidget/config.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nconst timeUnitConfig = [\n {\n value: CurrencyPowerBalanceTimeUnit.M3,\n label: '3m',\n tooltip: '3_months',\n },\n {\n value: CurrencyPowerBalanceTimeUnit.M1,\n label: '1m',\n tooltip: '1_month',\n },\n {\n value: CurrencyPowerBalanceTimeUnit.W1,\n label: '1w',\n tooltip: '1_week',\n },\n {\n value: CurrencyPowerBalanceTimeUnit.H24,\n label: '24h',\n tooltip: '24_hours',\n },\n { value: CurrencyPowerBalanceTimeUnit.H8, label: '8h', tooltip: '8_hours' },\n { value: CurrencyPowerBalanceTimeUnit.H4, label: '4h', tooltip: '4_hours' },\n { value: CurrencyPowerBalanceTimeUnit.PreviousDay, label: 'previous_business_day' },\n { value: CurrencyPowerBalanceTimeUnit.CurrentDay, label: 'current_business_day' },\n];\n\nexport { timeUnitConfig };\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,CACrB;EACEE,KAAK,EAAEC,qCAA4B,CAACC,EAAE;EACtCC,KAAK,EAAE,IAAI;EACXC,OAAO,EAAE;AACX,CAAC,EACD;EACEJ,KAAK,EAAEC,qCAA4B,CAACI,EAAE;EACtCF,KAAK,EAAE,IAAI;EACXC,OAAO,EAAE;AACX,CAAC,EACD;EACEJ,KAAK,EAAEC,qCAA4B,CAACK,EAAE;EACtCH,KAAK,EAAE,IAAI;EACXC,OAAO,EAAE;AACX,CAAC,EACD;EACEJ,KAAK,EAAEC,qCAA4B,CAACM,GAAG;EACvCJ,KAAK,EAAE,KAAK;EACZC,OAAO,EAAE;AACX,CAAC,EACD;EAAEJ,KAAK,EAAEC,qCAA4B,CAACO,EAAE;EAAEL,KAAK,EAAE,IAAI;EAAEC,OAAO,EAAE;AAAU,CAAC,EAC3E;EAAEJ,KAAK,EAAEC,qCAA4B,CAACQ,EAAE;EAAEN,KAAK,EAAE,IAAI;EAAEC,OAAO,EAAE;AAAU,CAAC,EAC3E;EAAEJ,KAAK,EAAEC,qCAA4B,CAACS,WAAW;EAAEP,KAAK,EAAE;AAAwB,CAAC,EACnF;EAAEH,KAAK,EAAEC,qCAA4B,CAACU,UAAU;EAAER,KAAK,EAAE;AAAuB,CAAC,CAClF"}
1
+ {"version":3,"file":"config.js","names":["_graphql","require","timeUnitConfig","exports","value","CurrencyPowerBalanceTimeUnit","M3","label","tooltipLabel","translationKey","count","M1","W1","H24","H8","H4","PreviousDay","CurrentDay"],"sources":["../../../src/CurrencyPowerBalanceWidget/config.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nconst timeUnitConfig = [\n {\n value: CurrencyPowerBalanceTimeUnit.M3,\n label: '3m',\n tooltipLabel: {\n translationKey: 'month',\n count: 3,\n },\n },\n {\n value: CurrencyPowerBalanceTimeUnit.M1,\n label: '1m',\n tooltipLabel: {\n translationKey: 'month',\n count: 1,\n },\n },\n {\n value: CurrencyPowerBalanceTimeUnit.W1,\n label: '1w',\n tooltipLabel: {\n translationKey: 'week',\n count: 1,\n },\n },\n {\n value: CurrencyPowerBalanceTimeUnit.H24,\n label: '24h',\n tooltipLabel: {\n translationKey: 'hour',\n count: 24,\n },\n },\n {\n value: CurrencyPowerBalanceTimeUnit.H8,\n label: '8h',\n tooltipLabel: {\n translationKey: 'hour',\n count: 8,\n },\n },\n {\n value: CurrencyPowerBalanceTimeUnit.H4,\n label: '4h',\n tooltipLabel: {\n translationKey: 'hour',\n count: 4,\n },\n },\n { value: CurrencyPowerBalanceTimeUnit.PreviousDay, label: 'previous_business_day' },\n { value: CurrencyPowerBalanceTimeUnit.CurrentDay, label: 'current_business_day' },\n];\n\nexport { timeUnitConfig };\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,MAAMC,cAAc,GAAAC,OAAA,CAAAD,cAAA,GAAG,CACrB;EACEE,KAAK,EAAEC,qCAA4B,CAACC,EAAE;EACtCC,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,OAAO;IACvBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEN,KAAK,EAAEC,qCAA4B,CAACM,EAAE;EACtCJ,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,OAAO;IACvBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEN,KAAK,EAAEC,qCAA4B,CAACO,EAAE;EACtCL,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,MAAM;IACtBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEN,KAAK,EAAEC,qCAA4B,CAACQ,GAAG;EACvCN,KAAK,EAAE,KAAK;EACZC,YAAY,EAAE;IACZC,cAAc,EAAE,MAAM;IACtBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEN,KAAK,EAAEC,qCAA4B,CAACS,EAAE;EACtCP,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,MAAM;IACtBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEN,KAAK,EAAEC,qCAA4B,CAACU,EAAE;EACtCR,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,MAAM;IACtBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EAAEN,KAAK,EAAEC,qCAA4B,CAACW,WAAW;EAAET,KAAK,EAAE;AAAwB,CAAC,EACnF;EAAEH,KAAK,EAAEC,qCAA4B,CAACY,UAAU;EAAEV,KAAK,EAAE;AAAuB,CAAC,CAClF"}
@@ -1,18 +1,18 @@
1
1
  {
2
- "1_month": "1 month",
3
- "1_week": "1 week",
4
2
  "1m": "1M",
5
3
  "1w": "1W",
6
- "24_hours": "24 hours",
7
4
  "24h": "24H",
8
- "3_months": "3 months",
9
5
  "3m": "3M",
10
- "4_hours": "4 hours",
11
6
  "4h": "4H",
12
- "8_hours": "8 hours",
13
7
  "8h": "8H",
14
8
  "current_business_day": "Current Business Day",
15
9
  "data_unavailable": "Data unavailable",
10
+ "hour": "{{count}} Hour",
11
+ "hour_plural": "{{count}} Hours",
12
+ "month": "{{count}} Month",
13
+ "month_plural": "{{count}} Months",
16
14
  "pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries",
17
- "previous_business_day": "Previous Business Day"
15
+ "previous_business_day": "Previous Business Day",
16
+ "week": "{{count}} Week",
17
+ "week_plural": "{{count}} Weeks"
18
18
  }
@@ -1,18 +1,15 @@
1
1
  {
2
- "1_month": "1 個月",
3
- "1_week": "1星期",
4
2
  "1m": "1M",
5
3
  "1w": "1W",
6
- "24_hours": "24小時",
7
4
  "24h": "24H",
8
- "3_months": "3 個月",
9
5
  "3m": "3M",
10
- "4_hours": "4小時",
11
6
  "4h": "4H",
12
- "8_hours": "8小時",
13
7
  "8h": "8H",
14
8
  "current_business_day": "目前營業日",
15
9
  "data_unavailable": "沒有數據",
10
+ "hour_0": "{{count}} 時",
11
+ "month_0": "{{count}} 月",
16
12
  "pagination_entries_range": "{{itemCount}}个挂单中的{{firstItemOnPage}}-{{lastItemOnPage}}",
17
- "previous_business_day": "前一營業日"
13
+ "previous_business_day": "前一營業日",
14
+ "week_0": "{{count}}週"
18
15
  }
@@ -1,22 +1,17 @@
1
1
  import React, { useState } from 'react';
2
- import { useLocale } from '@oanda/mono-i18n';
3
2
  import { timeUnitConfig } from './config';
4
3
  import { TimeUnitSwitch } from './components/TimeUnitSwitch';
5
4
  import { ChartWithData } from './ChartWithData';
6
5
  import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
7
6
  const Tool = () => {
8
7
  const [selectedTimeUnit, setSelectedTimeUnit] = useState(CurrencyPowerBalanceTimeUnit.CurrentDay);
9
- const {
10
- lang
11
- } = useLocale();
12
8
  return React.createElement("div", {
13
9
  "data-testid": "currency-power-balance-wrapper",
14
10
  className: "lw-flex lw-flex-col lw-text-sm lw-tracking-normal"
15
11
  }, React.createElement(TimeUnitSwitch, {
16
12
  selected: selectedTimeUnit,
17
13
  callback: setSelectedTimeUnit,
18
- options: timeUnitConfig,
19
- labelCallback: lang
14
+ options: timeUnitConfig
20
15
  }), React.createElement(ChartWithData, {
21
16
  timeUnit: selectedTimeUnit
22
17
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"Tool.js","names":["React","useState","useLocale","timeUnitConfig","TimeUnitSwitch","ChartWithData","CurrencyPowerBalanceTimeUnit","Tool","selectedTimeUnit","setSelectedTimeUnit","CurrentDay","lang","createElement","className","selected","callback","options","labelCallback","timeUnit"],"sources":["../../../src/CurrencyPowerBalanceWidget/Tool.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { timeUnitConfig } from './config';\nimport { TimeUnitSwitch } from './components/TimeUnitSwitch';\nimport { ChartWithData } from './ChartWithData';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nconst Tool = () => {\n const [selectedTimeUnit, setSelectedTimeUnit] = useState(CurrencyPowerBalanceTimeUnit.CurrentDay);\n const { lang } = useLocale();\n\n return (\n <div\n data-testid=\"currency-power-balance-wrapper\"\n className=\"lw-flex lw-flex-col lw-text-sm lw-tracking-normal\"\n >\n <TimeUnitSwitch\n selected={selectedTimeUnit}\n callback={setSelectedTimeUnit}\n options={timeUnitConfig}\n labelCallback={lang}\n />\n <ChartWithData\n timeUnit={selectedTimeUnit}\n />\n </div>\n );\n};\n\nexport { Tool };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,cAAc,QAAQ,UAAU;AACzC,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,4BAA4B,QAAQ,sBAAsB;AAEnE,MAAMC,IAAI,GAAGA,CAAA,KAAM;EACjB,MAAM,CAACC,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGR,QAAQ,CAACK,4BAA4B,CAACI,UAAU,CAAC;EACjG,MAAM;IAAEC;EAAK,CAAC,GAAGT,SAAS,CAAC,CAAC;EAE5B,OACEF,KAAA,CAAAY,aAAA;IACE,eAAY,gCAAgC;IAC5CC,SAAS,EAAC;EAAmD,GAE7Db,KAAA,CAAAY,aAAA,CAACR,cAAc;IACbU,QAAQ,EAAEN,gBAAiB;IAC3BO,QAAQ,EAAEN,mBAAoB;IAC9BO,OAAO,EAAEb,cAAe;IACxBc,aAAa,EAAEN;EAAK,CACrB,CAAC,EACFX,KAAA,CAAAY,aAAA,CAACP,aAAa;IACZa,QAAQ,EAAEV;EAAiB,CAC5B,CACE,CAAC;AAEV,CAAC;AAED,SAASD,IAAI"}
1
+ {"version":3,"file":"Tool.js","names":["React","useState","timeUnitConfig","TimeUnitSwitch","ChartWithData","CurrencyPowerBalanceTimeUnit","Tool","selectedTimeUnit","setSelectedTimeUnit","CurrentDay","createElement","className","selected","callback","options","timeUnit"],"sources":["../../../src/CurrencyPowerBalanceWidget/Tool.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { timeUnitConfig } from './config';\nimport { TimeUnitSwitch } from './components/TimeUnitSwitch';\nimport { ChartWithData } from './ChartWithData';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nconst Tool = () => {\n const [selectedTimeUnit, setSelectedTimeUnit] = useState(CurrencyPowerBalanceTimeUnit.CurrentDay);\n\n return (\n <div\n data-testid=\"currency-power-balance-wrapper\"\n className=\"lw-flex lw-flex-col lw-text-sm lw-tracking-normal\"\n >\n <TimeUnitSwitch\n selected={selectedTimeUnit}\n callback={setSelectedTimeUnit}\n options={timeUnitConfig}\n />\n <ChartWithData\n timeUnit={selectedTimeUnit}\n />\n </div>\n );\n};\n\nexport { Tool };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,cAAc,QAAQ,UAAU;AACzC,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,4BAA4B,QAAQ,sBAAsB;AAEnE,MAAMC,IAAI,GAAGA,CAAA,KAAM;EACjB,MAAM,CAACC,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGP,QAAQ,CAACI,4BAA4B,CAACI,UAAU,CAAC;EAEjG,OACET,KAAA,CAAAU,aAAA;IACE,eAAY,gCAAgC;IAC5CC,SAAS,EAAC;EAAmD,GAE7DX,KAAA,CAAAU,aAAA,CAACP,cAAc;IACbS,QAAQ,EAAEL,gBAAiB;IAC3BM,QAAQ,EAAEL,mBAAoB;IAC9BM,OAAO,EAAEZ;EAAe,CACzB,CAAC,EACFF,KAAA,CAAAU,aAAA,CAACN,aAAa;IACZW,QAAQ,EAAER;EAAiB,CAC5B,CACE,CAAC;AAEV,CAAC;AAED,SAASD,IAAI"}
@@ -1,21 +1,26 @@
1
1
  import React from 'react';
2
2
  import { Select } from '@oanda/labs-widget-common';
3
+ import { useLocale } from '@oanda/mono-i18n';
3
4
  const TimeUnitSelect = _ref => {
4
5
  let {
5
6
  selected,
6
7
  options,
7
- callback,
8
- labelCallback
8
+ callback
9
9
  } = _ref;
10
+ const {
11
+ lang
12
+ } = useLocale();
10
13
  const selectOptions = options.map(_ref2 => {
11
14
  let {
12
15
  value: id,
13
16
  label,
14
- tooltip
17
+ tooltipLabel
15
18
  } = _ref2;
16
19
  return {
17
20
  id,
18
- label: labelCallback ? labelCallback(tooltip || label) : tooltip || label
21
+ label: tooltipLabel ? lang(tooltipLabel.translationKey, {
22
+ count: tooltipLabel.count
23
+ }) : lang(label)
19
24
  };
20
25
  });
21
26
  const [{
@@ -1 +1 @@
1
- {"version":3,"file":"TimeUnitSelect.js","names":["React","Select","TimeUnitSelect","_ref","selected","options","callback","labelCallback","selectOptions","map","_ref2","value","id","label","tooltip","selectedLabel","filter","_ref3","createElement","className","selectedOption","setSelectedOption","_ref4"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { Select } from '@oanda/labs-widget-common';\nimport { TimeUnitSwitchProps } from './types';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nconst TimeUnitSelect = ({\n selected, options, callback, labelCallback,\n}: TimeUnitSwitchProps) => {\n const selectOptions = options\n .map(({ value: id, label, tooltip }) => ({\n id,\n label: labelCallback ? labelCallback(tooltip || label) : tooltip || label,\n }));\n const [{ label: selectedLabel }] = selectOptions.filter(({ id }) => id === selected);\n\n return (\n <div data-testid=\"time-unit-select\" className=\"lw-mb-6 lw-w-full\">\n <Select\n options={selectOptions}\n selectedOption={{ id: selected, label: selectedLabel }}\n setSelectedOption={({ id }) => callback(id as CurrencyPowerBalanceTimeUnit)}\n />\n </div>\n );\n};\n\nexport { TimeUnitSelect };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,2BAA2B;AAIlD,MAAMC,cAAc,GAAGC,IAAA,IAEI;EAAA,IAFH;IACtBC,QAAQ;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EACV,CAAC,GAAAJ,IAAA;EACpB,MAAMK,aAAa,GAAGH,OAAO,CAC1BI,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,KAAK,EAAEC,EAAE;MAAEC,KAAK;MAAEC;IAAQ,CAAC,GAAAJ,KAAA;IAAA,OAAM;MACvCE,EAAE;MACFC,KAAK,EAAEN,aAAa,GAAGA,aAAa,CAACO,OAAO,IAAID,KAAK,CAAC,GAAGC,OAAO,IAAID;IACtE,CAAC;EAAA,CAAC,CAAC;EACL,MAAM,CAAC;IAAEA,KAAK,EAAEE;EAAc,CAAC,CAAC,GAAGP,aAAa,CAACQ,MAAM,CAACC,KAAA;IAAA,IAAC;MAAEL;IAAG,CAAC,GAAAK,KAAA;IAAA,OAAKL,EAAE,KAAKR,QAAQ;EAAA,EAAC;EAEpF,OACEJ,KAAA,CAAAkB,aAAA;IAAK,eAAY,kBAAkB;IAACC,SAAS,EAAC;EAAmB,GAC/DnB,KAAA,CAAAkB,aAAA,CAACjB,MAAM;IACLI,OAAO,EAAEG,aAAc;IACvBY,cAAc,EAAE;MAAER,EAAE,EAAER,QAAQ;MAAES,KAAK,EAAEE;IAAc,CAAE;IACvDM,iBAAiB,EAAEC,KAAA;MAAA,IAAC;QAAEV;MAAG,CAAC,GAAAU,KAAA;MAAA,OAAKhB,QAAQ,CAACM,EAAkC,CAAC;IAAA;EAAC,CAC7E,CACE,CAAC;AAEV,CAAC;AAED,SAASV,cAAc"}
1
+ {"version":3,"file":"TimeUnitSelect.js","names":["React","Select","useLocale","TimeUnitSelect","_ref","selected","options","callback","lang","selectOptions","map","_ref2","value","id","label","tooltipLabel","translationKey","count","selectedLabel","filter","_ref3","createElement","className","selectedOption","setSelectedOption","_ref4"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx"],"sourcesContent":["import React from 'react';\nimport { Select } from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { TimeUnitSwitchProps } from './types';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nconst TimeUnitSelect = ({\n selected, options, callback,\n}: TimeUnitSwitchProps) => {\n const { lang } = useLocale();\n const selectOptions = options\n .map(({ value: id, label, tooltipLabel }) => ({\n id,\n label: tooltipLabel\n ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })\n : lang(label),\n }));\n const [{ label: selectedLabel }] = selectOptions.filter(({ id }) => id === selected);\n\n return (\n <div data-testid=\"time-unit-select\" className=\"lw-mb-6 lw-w-full\">\n <Select\n options={selectOptions}\n selectedOption={{ id: selected, label: selectedLabel }}\n setSelectedOption={({ id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7E,CACE,CAAC;AAEV,CAAC;AAED,SAASV,cAAc"}
@@ -1,14 +1,17 @@
1
1
  import React, { useContext } from 'react';
2
2
  import { Button, ButtonSize, ButtonVariant, ThemeContext, Size } from '@oanda/labs-widget-common';
3
+ import { useLocale } from '@oanda/mono-i18n';
3
4
  import { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from '../../constants';
4
5
  import { TimeUnitSelect } from './TimeUnitSelect';
5
6
  const TimeUnitSwitch = _ref => {
6
7
  let {
7
8
  selected,
8
9
  options,
9
- callback,
10
- labelCallback
10
+ callback
11
11
  } = _ref;
12
+ const {
13
+ lang
14
+ } = useLocale();
12
15
  const {
13
16
  size
14
17
  } = useContext(ThemeContext);
@@ -19,23 +22,29 @@ const TimeUnitSwitch = _ref => {
19
22
  return React.createElement(React.Fragment, null, isDesktop ? React.createElement("div", {
20
23
  "data-testid": "time-unit-switch",
21
24
  className: "lw-mb-6 lw-flex lw-gap-1 lw-self-end"
22
- }, options.map(item => {
23
- const tooltip = labelCallback && item.tooltip ? labelCallback(item.tooltip) : item.tooltip;
24
- const label = labelCallback ? labelCallback(item.label) : item.label;
25
+ }, options.map(_ref2 => {
26
+ let {
27
+ value,
28
+ label,
29
+ tooltipLabel
30
+ } = _ref2;
31
+ const tooltip = tooltipLabel ? lang(tooltipLabel.translationKey, {
32
+ count: tooltipLabel.count
33
+ }) : tooltipLabel;
34
+ const buttonLabel = lang(label);
25
35
  return React.createElement(Button, {
26
- key: item.value,
36
+ key: value,
27
37
  size: ButtonSize.full,
28
- variant: selected === item.value ? ButtonVariant.primary : ButtonVariant.secondary,
38
+ variant: selected === value ? ButtonVariant.primary : ButtonVariant.secondary,
29
39
  onClick: handleButtonClick,
30
- value: item.value,
40
+ value: value,
31
41
  "data-tooltip-id": CURRENCY_POWER_BALANCE_TOOLTIP_ID,
32
42
  "data-tooltip-content": tooltip
33
- }, label);
43
+ }, buttonLabel);
34
44
  })) : React.createElement(TimeUnitSelect, {
35
45
  selected: selected,
36
46
  callback: callback,
37
- options: options,
38
- labelCallback: labelCallback
47
+ options: options
39
48
  }));
40
49
  };
41
50
  export { TimeUnitSwitch };
@@ -1 +1 @@
1
- {"version":3,"file":"TimeUnitSwitch.js","names":["React","useContext","Button","ButtonSize","ButtonVariant","ThemeContext","Size","CURRENCY_POWER_BALANCE_TOOLTIP_ID","TimeUnitSelect","TimeUnitSwitch","_ref","selected","options","callback","labelCallback","size","isDesktop","DESKTOP","handleButtonClick","e","currentTarget","value","createElement","Fragment","className","map","item","tooltip","label","key","full","variant","primary","secondary","onClick"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport {\n Button, ButtonSize, ButtonVariant, ThemeContext, Size,\n} from '@oanda/labs-widget-common';\nimport { TimeUnitSwitchProps } from './types';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from '../../constants';\nimport { TimeUnitSelect } from './TimeUnitSelect';\n\nconst TimeUnitSwitch = ({\n selected, options, callback, labelCallback,\n}: TimeUnitSwitchProps) => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n\n const handleButtonClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {\n callback(e.currentTarget.value as CurrencyPowerBalanceTimeUnit);\n };\n\n return (\n <>\n {isDesktop\n ? (\n <div data-testid=\"time-unit-switch\" className=\"lw-mb-6 lw-flex lw-gap-1 lw-self-end\">\n {options.map((item) => {\n const tooltip = labelCallback && item.tooltip\n ? labelCallback(item.tooltip)\n : item.tooltip;\n const label = labelCallback ? labelCallback(item.label) : item.label;\n\n return (\n <Button\n key={item.value}\n size={ButtonSize.full}\n variant={selected === item.value\n ? ButtonVariant.primary\n : ButtonVariant.secondary}\n onClick={handleButtonClick}\n value={item.value}\n data-tooltip-id={CURRENCY_POWER_BALANCE_TOOLTIP_ID}\n data-tooltip-content={tooltip}\n >\n {label}\n </Button>\n );\n })}\n </div>\n )\n : (\n <TimeUnitSelect\n selected={selected}\n callback={callback}\n options={options}\n labelCallback={labelCallback}\n />\n )}\n </>\n );\n};\n\nexport { TimeUnitSwitch };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SACEC,MAAM,EAAEC,UAAU,EAAEC,aAAa,EAAEC,YAAY,EAAEC,IAAI,QAChD,2BAA2B;AAGlC,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,MAAMC,cAAc,GAAGC,IAAA,IAEI;EAAA,IAFH;IACtBC,QAAQ;IAAEC,OAAO;IAAEC,QAAQ;IAAEC;EACV,CAAC,GAAAJ,IAAA;EACpB,MAAM;IAAEK;EAAK,CAAC,GAAGd,UAAU,CAACI,YAAY,CAAC;EACzC,MAAMW,SAAS,GAAGD,IAAI,KAAKT,IAAI,CAACW,OAAO;EAEvC,MAAMC,iBAAiB,GAAIC,CAA0C,IAAK;IACxEN,QAAQ,CAACM,CAAC,CAACC,aAAa,CAACC,KAAqC,CAAC;EACjE,CAAC;EAED,OACErB,KAAA,CAAAsB,aAAA,CAAAtB,KAAA,CAAAuB,QAAA,QACGP,SAAS,GAENhB,KAAA,CAAAsB,aAAA;IAAK,eAAY,kBAAkB;IAACE,SAAS,EAAC;EAAsC,GACjFZ,OAAO,CAACa,GAAG,CAAEC,IAAI,IAAK;IACrB,MAAMC,OAAO,GAAGb,aAAa,IAAIY,IAAI,CAACC,OAAO,GACzCb,aAAa,CAACY,IAAI,CAACC,OAAO,CAAC,GAC3BD,IAAI,CAACC,OAAO;IAChB,MAAMC,KAAK,GAAGd,aAAa,GAAGA,aAAa,CAACY,IAAI,CAACE,KAAK,CAAC,GAAGF,IAAI,CAACE,KAAK;IAEpE,OACE5B,KAAA,CAAAsB,aAAA,CAACpB,MAAM;MACL2B,GAAG,EAAEH,IAAI,CAACL,KAAM;MAChBN,IAAI,EAAEZ,UAAU,CAAC2B,IAAK;MACtBC,OAAO,EAAEpB,QAAQ,KAAKe,IAAI,CAACL,KAAK,GAC5BjB,aAAa,CAAC4B,OAAO,GACrB5B,aAAa,CAAC6B,SAAU;MAC5BC,OAAO,EAAEhB,iBAAkB;MAC3BG,KAAK,EAAEK,IAAI,CAACL,KAAM;MAClB,mBAAiBd,iCAAkC;MACnD,wBAAsBoB;IAAQ,GAE7BC,KACK,CAAC;EAEb,CAAC,CACE,CAAC,GAGN5B,KAAA,CAAAsB,aAAA,CAACd,cAAc;IACbG,QAAQ,EAAEA,QAAS;IACnBE,QAAQ,EAAEA,QAAS;IACnBD,OAAO,EAAEA,OAAQ;IACjBE,aAAa,EAAEA;EAAc,CAC9B,CAEL,CAAC;AAEP,CAAC;AAED,SAASL,cAAc"}
1
+ {"version":3,"file":"TimeUnitSwitch.js","names":["React","useContext","Button","ButtonSize","ButtonVariant","ThemeContext","Size","useLocale","CURRENCY_POWER_BALANCE_TOOLTIP_ID","TimeUnitSelect","TimeUnitSwitch","_ref","selected","options","callback","lang","size","isDesktop","DESKTOP","handleButtonClick","e","currentTarget","value","createElement","Fragment","className","map","_ref2","label","tooltipLabel","tooltip","translationKey","count","buttonLabel","key","full","variant","primary","secondary","onClick"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport {\n Button, ButtonSize, ButtonVariant, ThemeContext, Size,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { TimeUnitSwitchProps } from './types';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from '../../constants';\nimport { TimeUnitSelect } from './TimeUnitSelect';\n\nconst TimeUnitSwitch = ({\n selected, options, callback,\n}: TimeUnitSwitchProps) => {\n const { lang } = useLocale();\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n\n const handleButtonClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {\n callback(e.currentTarget.value as CurrencyPowerBalanceTimeUnit);\n };\n\n return (\n <>\n {isDesktop\n ? (\n <div data-testid=\"time-unit-switch\" className=\"lw-mb-6 lw-flex lw-gap-1 lw-self-end\">\n {options.map(({ value, label, tooltipLabel }) => {\n const tooltip = tooltipLabel\n ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })\n : tooltipLabel;\n const buttonLabel = lang(label);\n\n return (\n <Button\n key={value}\n size={ButtonSize.full}\n variant={selected === value\n ? ButtonVariant.primary\n : ButtonVariant.secondary}\n onClick={handleButtonClick}\n value={value}\n data-tooltip-id={CURRENCY_POWER_BALANCE_TOOLTIP_ID}\n data-tooltip-content={tooltip}\n >\n {buttonLabel}\n </Button>\n );\n })}\n </div>\n )\n : (\n <TimeUnitSelect\n selected={selected}\n callback={callback}\n options={options}\n />\n )}\n </>\n );\n};\n\nexport { TimeUnitSwitch };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SACEC,MAAM,EAAEC,UAAU,EAAEC,aAAa,EAAEC,YAAY,EAAEC,IAAI,QAChD,2BAA2B;AAClC,SAASC,SAAS,QAAQ,kBAAkB;AAG5C,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,cAAc,QAAQ,kBAAkB;AAEjD,MAAMC,cAAc,GAAGC,IAAA,IAEI;EAAA,IAFH;IACtBC,QAAQ;IAAEC,OAAO;IAAEC;EACA,CAAC,GAAAH,IAAA;EACpB,MAAM;IAAEI;EAAK,CAAC,GAAGR,SAAS,CAAC,CAAC;EAC5B,MAAM;IAAES;EAAK,CAAC,GAAGf,UAAU,CAACI,YAAY,CAAC;EACzC,MAAMY,SAAS,GAAGD,IAAI,KAAKV,IAAI,CAACY,OAAO;EAEvC,MAAMC,iBAAiB,GAAIC,CAA0C,IAAK;IACxEN,QAAQ,CAACM,CAAC,CAACC,aAAa,CAACC,KAAqC,CAAC;EACjE,CAAC;EAED,OACEtB,KAAA,CAAAuB,aAAA,CAAAvB,KAAA,CAAAwB,QAAA,QACGP,SAAS,GAENjB,KAAA,CAAAuB,aAAA;IAAK,eAAY,kBAAkB;IAACE,SAAS,EAAC;EAAsC,GACjFZ,OAAO,CAACa,GAAG,CAACC,KAAA,IAAoC;IAAA,IAAnC;MAAEL,KAAK;MAAEM,KAAK;MAAEC;IAAa,CAAC,GAAAF,KAAA;IAC1C,MAAMG,OAAO,GAAGD,YAAY,GACxBd,IAAI,CAACc,YAAY,CAACE,cAAc,EAAE;MAAEC,KAAK,EAAEH,YAAY,CAACG;IAAM,CAAC,CAAC,GAChEH,YAAY;IAChB,MAAMI,WAAW,GAAGlB,IAAI,CAACa,KAAK,CAAC;IAE/B,OACE5B,KAAA,CAAAuB,aAAA,CAACrB,MAAM;MACLgC,GAAG,EAAEZ,KAAM;MACXN,IAAI,EAAEb,UAAU,CAACgC,IAAK;MACtBC,OAAO,EAAExB,QAAQ,KAAKU,KAAK,GACvBlB,aAAa,CAACiC,OAAO,GACrBjC,aAAa,CAACkC,SAAU;MAC5BC,OAAO,EAAEpB,iBAAkB;MAC3BG,KAAK,EAAEA,KAAM;MACb,mBAAiBd,iCAAkC;MACnD,wBAAsBsB;IAAQ,GAE7BG,WACK,CAAC;EAEb,CAAC,CACE,CAAC,GAGNjC,KAAA,CAAAuB,aAAA,CAACd,cAAc;IACbG,QAAQ,EAAEA,QAAS;IACnBE,QAAQ,EAAEA,QAAS;IACnBD,OAAO,EAAEA;EAAQ,CAClB,CAEL,CAAC;AAEP,CAAC;AAED,SAASH,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nexport interface TimeUnitOption {\n value: CurrencyPowerBalanceTimeUnit;\n label: string;\n tooltip?: string;\n}\n\nexport interface TimeUnitSwitchProps {\n selected: CurrencyPowerBalanceTimeUnit;\n options: TimeUnitOption[];\n callback: (value: CurrencyPowerBalanceTimeUnit) => void;\n labelCallback?: (value: string) => string;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nexport interface TimeUnitOption {\n value: CurrencyPowerBalanceTimeUnit;\n label: string;\n tooltipLabel?: TooltipLabel;\n}\n\nexport interface TimeUnitSwitchProps {\n selected: CurrencyPowerBalanceTimeUnit;\n options: TimeUnitOption[];\n callback: (value: CurrencyPowerBalanceTimeUnit) => void;\n}\n\ntype TooltipLabel = {\n translationKey: string;\n count: number;\n};\n"],"mappings":""}
@@ -2,27 +2,45 @@ import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
2
2
  const timeUnitConfig = [{
3
3
  value: CurrencyPowerBalanceTimeUnit.M3,
4
4
  label: '3m',
5
- tooltip: '3_months'
5
+ tooltipLabel: {
6
+ translationKey: 'month',
7
+ count: 3
8
+ }
6
9
  }, {
7
10
  value: CurrencyPowerBalanceTimeUnit.M1,
8
11
  label: '1m',
9
- tooltip: '1_month'
12
+ tooltipLabel: {
13
+ translationKey: 'month',
14
+ count: 1
15
+ }
10
16
  }, {
11
17
  value: CurrencyPowerBalanceTimeUnit.W1,
12
18
  label: '1w',
13
- tooltip: '1_week'
19
+ tooltipLabel: {
20
+ translationKey: 'week',
21
+ count: 1
22
+ }
14
23
  }, {
15
24
  value: CurrencyPowerBalanceTimeUnit.H24,
16
25
  label: '24h',
17
- tooltip: '24_hours'
26
+ tooltipLabel: {
27
+ translationKey: 'hour',
28
+ count: 24
29
+ }
18
30
  }, {
19
31
  value: CurrencyPowerBalanceTimeUnit.H8,
20
32
  label: '8h',
21
- tooltip: '8_hours'
33
+ tooltipLabel: {
34
+ translationKey: 'hour',
35
+ count: 8
36
+ }
22
37
  }, {
23
38
  value: CurrencyPowerBalanceTimeUnit.H4,
24
39
  label: '4h',
25
- tooltip: '4_hours'
40
+ tooltipLabel: {
41
+ translationKey: 'hour',
42
+ count: 4
43
+ }
26
44
  }, {
27
45
  value: CurrencyPowerBalanceTimeUnit.PreviousDay,
28
46
  label: 'previous_business_day'
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["CurrencyPowerBalanceTimeUnit","timeUnitConfig","value","M3","label","tooltip","M1","W1","H24","H8","H4","PreviousDay","CurrentDay"],"sources":["../../../src/CurrencyPowerBalanceWidget/config.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nconst timeUnitConfig = [\n {\n value: CurrencyPowerBalanceTimeUnit.M3,\n label: '3m',\n tooltip: '3_months',\n },\n {\n value: CurrencyPowerBalanceTimeUnit.M1,\n label: '1m',\n tooltip: '1_month',\n },\n {\n value: CurrencyPowerBalanceTimeUnit.W1,\n label: '1w',\n tooltip: '1_week',\n },\n {\n value: CurrencyPowerBalanceTimeUnit.H24,\n label: '24h',\n tooltip: '24_hours',\n },\n { value: CurrencyPowerBalanceTimeUnit.H8, label: '8h', tooltip: '8_hours' },\n { value: CurrencyPowerBalanceTimeUnit.H4, label: '4h', tooltip: '4_hours' },\n { value: CurrencyPowerBalanceTimeUnit.PreviousDay, label: 'previous_business_day' },\n { value: CurrencyPowerBalanceTimeUnit.CurrentDay, label: 'current_business_day' },\n];\n\nexport { timeUnitConfig };\n"],"mappings":"AAAA,SAASA,4BAA4B,QAAQ,sBAAsB;AAEnE,MAAMC,cAAc,GAAG,CACrB;EACEC,KAAK,EAAEF,4BAA4B,CAACG,EAAE;EACtCC,KAAK,EAAE,IAAI;EACXC,OAAO,EAAE;AACX,CAAC,EACD;EACEH,KAAK,EAAEF,4BAA4B,CAACM,EAAE;EACtCF,KAAK,EAAE,IAAI;EACXC,OAAO,EAAE;AACX,CAAC,EACD;EACEH,KAAK,EAAEF,4BAA4B,CAACO,EAAE;EACtCH,KAAK,EAAE,IAAI;EACXC,OAAO,EAAE;AACX,CAAC,EACD;EACEH,KAAK,EAAEF,4BAA4B,CAACQ,GAAG;EACvCJ,KAAK,EAAE,KAAK;EACZC,OAAO,EAAE;AACX,CAAC,EACD;EAAEH,KAAK,EAAEF,4BAA4B,CAACS,EAAE;EAAEL,KAAK,EAAE,IAAI;EAAEC,OAAO,EAAE;AAAU,CAAC,EAC3E;EAAEH,KAAK,EAAEF,4BAA4B,CAACU,EAAE;EAAEN,KAAK,EAAE,IAAI;EAAEC,OAAO,EAAE;AAAU,CAAC,EAC3E;EAAEH,KAAK,EAAEF,4BAA4B,CAACW,WAAW;EAAEP,KAAK,EAAE;AAAwB,CAAC,EACnF;EAAEF,KAAK,EAAEF,4BAA4B,CAACY,UAAU;EAAER,KAAK,EAAE;AAAuB,CAAC,CAClF;AAED,SAASH,cAAc"}
1
+ {"version":3,"file":"config.js","names":["CurrencyPowerBalanceTimeUnit","timeUnitConfig","value","M3","label","tooltipLabel","translationKey","count","M1","W1","H24","H8","H4","PreviousDay","CurrentDay"],"sources":["../../../src/CurrencyPowerBalanceWidget/config.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nconst timeUnitConfig = [\n {\n value: CurrencyPowerBalanceTimeUnit.M3,\n label: '3m',\n tooltipLabel: {\n translationKey: 'month',\n count: 3,\n },\n },\n {\n value: CurrencyPowerBalanceTimeUnit.M1,\n label: '1m',\n tooltipLabel: {\n translationKey: 'month',\n count: 1,\n },\n },\n {\n value: CurrencyPowerBalanceTimeUnit.W1,\n label: '1w',\n tooltipLabel: {\n translationKey: 'week',\n count: 1,\n },\n },\n {\n value: CurrencyPowerBalanceTimeUnit.H24,\n label: '24h',\n tooltipLabel: {\n translationKey: 'hour',\n count: 24,\n },\n },\n {\n value: CurrencyPowerBalanceTimeUnit.H8,\n label: '8h',\n tooltipLabel: {\n translationKey: 'hour',\n count: 8,\n },\n },\n {\n value: CurrencyPowerBalanceTimeUnit.H4,\n label: '4h',\n tooltipLabel: {\n translationKey: 'hour',\n count: 4,\n },\n },\n { value: CurrencyPowerBalanceTimeUnit.PreviousDay, label: 'previous_business_day' },\n { value: CurrencyPowerBalanceTimeUnit.CurrentDay, label: 'current_business_day' },\n];\n\nexport { timeUnitConfig };\n"],"mappings":"AAAA,SAASA,4BAA4B,QAAQ,sBAAsB;AAEnE,MAAMC,cAAc,GAAG,CACrB;EACEC,KAAK,EAAEF,4BAA4B,CAACG,EAAE;EACtCC,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,OAAO;IACvBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEL,KAAK,EAAEF,4BAA4B,CAACQ,EAAE;EACtCJ,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,OAAO;IACvBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEL,KAAK,EAAEF,4BAA4B,CAACS,EAAE;EACtCL,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,MAAM;IACtBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEL,KAAK,EAAEF,4BAA4B,CAACU,GAAG;EACvCN,KAAK,EAAE,KAAK;EACZC,YAAY,EAAE;IACZC,cAAc,EAAE,MAAM;IACtBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEL,KAAK,EAAEF,4BAA4B,CAACW,EAAE;EACtCP,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,MAAM;IACtBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EACEL,KAAK,EAAEF,4BAA4B,CAACY,EAAE;EACtCR,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE;IACZC,cAAc,EAAE,MAAM;IACtBC,KAAK,EAAE;EACT;AACF,CAAC,EACD;EAAEL,KAAK,EAAEF,4BAA4B,CAACa,WAAW;EAAET,KAAK,EAAE;AAAwB,CAAC,EACnF;EAAEF,KAAK,EAAEF,4BAA4B,CAACc,UAAU;EAAEV,KAAK,EAAE;AAAuB,CAAC,CAClF;AAED,SAASH,cAAc"}
@@ -1,18 +1,18 @@
1
1
  {
2
- "1_month": "1 month",
3
- "1_week": "1 week",
4
2
  "1m": "1M",
5
3
  "1w": "1W",
6
- "24_hours": "24 hours",
7
4
  "24h": "24H",
8
- "3_months": "3 months",
9
5
  "3m": "3M",
10
- "4_hours": "4 hours",
11
6
  "4h": "4H",
12
- "8_hours": "8 hours",
13
7
  "8h": "8H",
14
8
  "current_business_day": "Current Business Day",
15
9
  "data_unavailable": "Data unavailable",
10
+ "hour": "{{count}} Hour",
11
+ "hour_plural": "{{count}} Hours",
12
+ "month": "{{count}} Month",
13
+ "month_plural": "{{count}} Months",
16
14
  "pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries",
17
- "previous_business_day": "Previous Business Day"
15
+ "previous_business_day": "Previous Business Day",
16
+ "week": "{{count}} Week",
17
+ "week_plural": "{{count}} Weeks"
18
18
  }
@@ -1,18 +1,15 @@
1
1
  {
2
- "1_month": "1 個月",
3
- "1_week": "1星期",
4
2
  "1m": "1M",
5
3
  "1w": "1W",
6
- "24_hours": "24小時",
7
4
  "24h": "24H",
8
- "3_months": "3 個月",
9
5
  "3m": "3M",
10
- "4_hours": "4小時",
11
6
  "4h": "4H",
12
- "8_hours": "8小時",
13
7
  "8h": "8H",
14
8
  "current_business_day": "目前營業日",
15
9
  "data_unavailable": "沒有數據",
10
+ "hour_0": "{{count}} 時",
11
+ "month_0": "{{count}} 月",
16
12
  "pagination_entries_range": "{{itemCount}}个挂单中的{{firstItemOnPage}}-{{lastItemOnPage}}",
17
- "previous_business_day": "前一營業日"
13
+ "previous_business_day": "前一營業日",
14
+ "week_0": "{{count}}週"
18
15
  }
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { TimeUnitSwitchProps } from './types';
3
- declare const TimeUnitSelect: ({ selected, options, callback, labelCallback, }: TimeUnitSwitchProps) => JSX.Element;
3
+ declare const TimeUnitSelect: ({ selected, options, callback, }: TimeUnitSwitchProps) => JSX.Element;
4
4
  export { TimeUnitSelect };
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import { TimeUnitSwitchProps } from './types';
3
- declare const TimeUnitSwitch: ({ selected, options, callback, labelCallback, }: TimeUnitSwitchProps) => JSX.Element;
3
+ declare const TimeUnitSwitch: ({ selected, options, callback, }: TimeUnitSwitchProps) => JSX.Element;
4
4
  export { TimeUnitSwitch };
@@ -2,11 +2,15 @@ import { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
2
2
  export interface TimeUnitOption {
3
3
  value: CurrencyPowerBalanceTimeUnit;
4
4
  label: string;
5
- tooltip?: string;
5
+ tooltipLabel?: TooltipLabel;
6
6
  }
7
7
  export interface TimeUnitSwitchProps {
8
8
  selected: CurrencyPowerBalanceTimeUnit;
9
9
  options: TimeUnitOption[];
10
10
  callback: (value: CurrencyPowerBalanceTimeUnit) => void;
11
- labelCallback?: (value: string) => string;
12
11
  }
12
+ type TooltipLabel = {
13
+ translationKey: string;
14
+ count: number;
15
+ };
16
+ export {};
@@ -2,10 +2,13 @@ import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
2
2
  declare const timeUnitConfig: ({
3
3
  value: CurrencyPowerBalanceTimeUnit;
4
4
  label: string;
5
- tooltip: string;
5
+ tooltipLabel: {
6
+ translationKey: string;
7
+ count: number;
8
+ };
6
9
  } | {
7
10
  value: CurrencyPowerBalanceTimeUnit;
8
11
  label: string;
9
- tooltip?: undefined;
12
+ tooltipLabel?: undefined;
10
13
  })[];
11
14
  export { timeUnitConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-currency-power-balance-widget",
3
- "version": "1.0.30",
3
+ "version": "1.0.32",
4
4
  "description": "Labs Currency Power Balance 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.7.17",
16
- "@oanda/labs-widget-common": "^1.0.91",
16
+ "@oanda/labs-widget-common": "^1.0.93",
17
17
  "@oanda/mono-i18n": "9.0.0",
18
18
  "echarts": "5.4.3",
19
19
  "echarts-for-react": "3.0.2",
@@ -23,5 +23,5 @@
23
23
  "@graphql-codegen/cli": "5.0.0",
24
24
  "@graphql-codegen/client-preset": "4.1.0"
25
25
  },
26
- "gitHead": "527eb086ecdb29c9eb048c91e2099f0aff564ff6"
26
+ "gitHead": "ae1e2376d3fcfde7d53852798426f625d5ac67cf"
27
27
  }
@@ -1,5 +1,4 @@
1
1
  import React, { useState } from 'react';
2
- import { useLocale } from '@oanda/mono-i18n';
3
2
  import { timeUnitConfig } from './config';
4
3
  import { TimeUnitSwitch } from './components/TimeUnitSwitch';
5
4
  import { ChartWithData } from './ChartWithData';
@@ -7,7 +6,6 @@ import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
7
6
 
8
7
  const Tool = () => {
9
8
  const [selectedTimeUnit, setSelectedTimeUnit] = useState(CurrencyPowerBalanceTimeUnit.CurrentDay);
10
- const { lang } = useLocale();
11
9
 
12
10
  return (
13
11
  <div
@@ -18,7 +16,6 @@ const Tool = () => {
18
16
  selected={selectedTimeUnit}
19
17
  callback={setSelectedTimeUnit}
20
18
  options={timeUnitConfig}
21
- labelCallback={lang}
22
19
  />
23
20
  <ChartWithData
24
21
  timeUnit={selectedTimeUnit}
@@ -1,15 +1,19 @@
1
1
  import React from 'react';
2
2
  import { Select } from '@oanda/labs-widget-common';
3
+ import { useLocale } from '@oanda/mono-i18n';
3
4
  import { TimeUnitSwitchProps } from './types';
4
5
  import { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
5
6
 
6
7
  const TimeUnitSelect = ({
7
- selected, options, callback, labelCallback,
8
+ selected, options, callback,
8
9
  }: TimeUnitSwitchProps) => {
10
+ const { lang } = useLocale();
9
11
  const selectOptions = options
10
- .map(({ value: id, label, tooltip }) => ({
12
+ .map(({ value: id, label, tooltipLabel }) => ({
11
13
  id,
12
- label: labelCallback ? labelCallback(tooltip || label) : tooltip || label,
14
+ label: tooltipLabel
15
+ ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })
16
+ : lang(label),
13
17
  }));
14
18
  const [{ label: selectedLabel }] = selectOptions.filter(({ id }) => id === selected);
15
19
 
@@ -2,14 +2,16 @@ import React, { useContext } from 'react';
2
2
  import {
3
3
  Button, ButtonSize, ButtonVariant, ThemeContext, Size,
4
4
  } from '@oanda/labs-widget-common';
5
+ import { useLocale } from '@oanda/mono-i18n';
5
6
  import { TimeUnitSwitchProps } from './types';
6
7
  import { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
7
8
  import { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from '../../constants';
8
9
  import { TimeUnitSelect } from './TimeUnitSelect';
9
10
 
10
11
  const TimeUnitSwitch = ({
11
- selected, options, callback, labelCallback,
12
+ selected, options, callback,
12
13
  }: TimeUnitSwitchProps) => {
14
+ const { lang } = useLocale();
13
15
  const { size } = useContext(ThemeContext);
14
16
  const isDesktop = size === Size.DESKTOP;
15
17
 
@@ -22,25 +24,25 @@ const TimeUnitSwitch = ({
22
24
  {isDesktop
23
25
  ? (
24
26
  <div data-testid="time-unit-switch" className="lw-mb-6 lw-flex lw-gap-1 lw-self-end">
25
- {options.map((item) => {
26
- const tooltip = labelCallback && item.tooltip
27
- ? labelCallback(item.tooltip)
28
- : item.tooltip;
29
- const label = labelCallback ? labelCallback(item.label) : item.label;
27
+ {options.map(({ value, label, tooltipLabel }) => {
28
+ const tooltip = tooltipLabel
29
+ ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })
30
+ : tooltipLabel;
31
+ const buttonLabel = lang(label);
30
32
 
31
33
  return (
32
34
  <Button
33
- key={item.value}
35
+ key={value}
34
36
  size={ButtonSize.full}
35
- variant={selected === item.value
37
+ variant={selected === value
36
38
  ? ButtonVariant.primary
37
39
  : ButtonVariant.secondary}
38
40
  onClick={handleButtonClick}
39
- value={item.value}
41
+ value={value}
40
42
  data-tooltip-id={CURRENCY_POWER_BALANCE_TOOLTIP_ID}
41
43
  data-tooltip-content={tooltip}
42
44
  >
43
- {label}
45
+ {buttonLabel}
44
46
  </Button>
45
47
  );
46
48
  })}
@@ -51,7 +53,6 @@ const TimeUnitSwitch = ({
51
53
  selected={selected}
52
54
  callback={callback}
53
55
  options={options}
54
- labelCallback={labelCallback}
55
56
  />
56
57
  )}
57
58
  </>
@@ -3,12 +3,16 @@ import { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
3
3
  export interface TimeUnitOption {
4
4
  value: CurrencyPowerBalanceTimeUnit;
5
5
  label: string;
6
- tooltip?: string;
6
+ tooltipLabel?: TooltipLabel;
7
7
  }
8
8
 
9
9
  export interface TimeUnitSwitchProps {
10
10
  selected: CurrencyPowerBalanceTimeUnit;
11
11
  options: TimeUnitOption[];
12
12
  callback: (value: CurrencyPowerBalanceTimeUnit) => void;
13
- labelCallback?: (value: string) => string;
14
13
  }
14
+
15
+ type TooltipLabel = {
16
+ translationKey: string;
17
+ count: number;
18
+ };
@@ -4,25 +4,51 @@ const timeUnitConfig = [
4
4
  {
5
5
  value: CurrencyPowerBalanceTimeUnit.M3,
6
6
  label: '3m',
7
- tooltip: '3_months',
7
+ tooltipLabel: {
8
+ translationKey: 'month',
9
+ count: 3,
10
+ },
8
11
  },
9
12
  {
10
13
  value: CurrencyPowerBalanceTimeUnit.M1,
11
14
  label: '1m',
12
- tooltip: '1_month',
15
+ tooltipLabel: {
16
+ translationKey: 'month',
17
+ count: 1,
18
+ },
13
19
  },
14
20
  {
15
21
  value: CurrencyPowerBalanceTimeUnit.W1,
16
22
  label: '1w',
17
- tooltip: '1_week',
23
+ tooltipLabel: {
24
+ translationKey: 'week',
25
+ count: 1,
26
+ },
18
27
  },
19
28
  {
20
29
  value: CurrencyPowerBalanceTimeUnit.H24,
21
30
  label: '24h',
22
- tooltip: '24_hours',
31
+ tooltipLabel: {
32
+ translationKey: 'hour',
33
+ count: 24,
34
+ },
35
+ },
36
+ {
37
+ value: CurrencyPowerBalanceTimeUnit.H8,
38
+ label: '8h',
39
+ tooltipLabel: {
40
+ translationKey: 'hour',
41
+ count: 8,
42
+ },
43
+ },
44
+ {
45
+ value: CurrencyPowerBalanceTimeUnit.H4,
46
+ label: '4h',
47
+ tooltipLabel: {
48
+ translationKey: 'hour',
49
+ count: 4,
50
+ },
23
51
  },
24
- { value: CurrencyPowerBalanceTimeUnit.H8, label: '8h', tooltip: '8_hours' },
25
- { value: CurrencyPowerBalanceTimeUnit.H4, label: '4h', tooltip: '4_hours' },
26
52
  { value: CurrencyPowerBalanceTimeUnit.PreviousDay, label: 'previous_business_day' },
27
53
  { value: CurrencyPowerBalanceTimeUnit.CurrentDay, label: 'current_business_day' },
28
54
  ];
@@ -1,18 +1,18 @@
1
1
  {
2
- "1_month": "1 month",
3
- "1_week": "1 week",
4
2
  "1m": "1M",
5
3
  "1w": "1W",
6
- "24_hours": "24 hours",
7
4
  "24h": "24H",
8
- "3_months": "3 months",
9
5
  "3m": "3M",
10
- "4_hours": "4 hours",
11
6
  "4h": "4H",
12
- "8_hours": "8 hours",
13
7
  "8h": "8H",
14
8
  "current_business_day": "Current Business Day",
15
9
  "data_unavailable": "Data unavailable",
10
+ "hour": "{{count}} Hour",
11
+ "hour_plural": "{{count}} Hours",
12
+ "month": "{{count}} Month",
13
+ "month_plural": "{{count}} Months",
16
14
  "pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries",
17
- "previous_business_day": "Previous Business Day"
15
+ "previous_business_day": "Previous Business Day",
16
+ "week": "{{count}} Week",
17
+ "week_plural": "{{count}} Weeks"
18
18
  }
@@ -1,18 +1,15 @@
1
1
  {
2
- "1_month": "1 個月",
3
- "1_week": "1星期",
4
2
  "1m": "1M",
5
3
  "1w": "1W",
6
- "24_hours": "24小時",
7
4
  "24h": "24H",
8
- "3_months": "3 個月",
9
5
  "3m": "3M",
10
- "4_hours": "4小時",
11
6
  "4h": "4H",
12
- "8_hours": "8小時",
13
7
  "8h": "8H",
14
8
  "current_business_day": "目前營業日",
15
9
  "data_unavailable": "沒有數據",
10
+ "hour_0": "{{count}} 時",
11
+ "month_0": "{{count}} 月",
16
12
  "pagination_entries_range": "{{itemCount}}个挂单中的{{firstItemOnPage}}-{{lastItemOnPage}}",
17
- "previous_business_day": "前一營業日"
13
+ "previous_business_day": "前一營業日",
14
+ "week_0": "{{count}}週"
18
15
  }