@oanda/labs-currency-power-balance-widget 1.0.31 → 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.
- package/CHANGELOG.md +132 -0
- package/dist/main/CurrencyPowerBalanceWidget/Tool.js +1 -6
- package/dist/main/CurrencyPowerBalanceWidget/Tool.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +9 -4
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +20 -11
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/config.js +24 -6
- package/dist/main/CurrencyPowerBalanceWidget/config.js.map +1 -1
- package/dist/main/translations/sources/en.json +7 -7
- package/dist/main/translations/sources/zh_TW.json +4 -7
- package/dist/module/CurrencyPowerBalanceWidget/Tool.js +1 -6
- package/dist/module/CurrencyPowerBalanceWidget/Tool.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +9 -4
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +20 -11
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/config.js +24 -6
- package/dist/module/CurrencyPowerBalanceWidget/config.js.map +1 -1
- package/dist/module/translations/sources/en.json +7 -7
- package/dist/module/translations/sources/zh_TW.json +4 -7
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.d.ts +6 -2
- package/dist/types/CurrencyPowerBalanceWidget/config.d.ts +5 -2
- package/package.json +3 -3
- package/src/CurrencyPowerBalanceWidget/Tool.tsx +0 -3
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +7 -3
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +12 -11
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts +6 -2
- package/src/CurrencyPowerBalanceWidget/config.ts +32 -6
- package/src/translations/sources/en.json +7 -7
- package/src/translations/sources/zh_TW.json +4 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,138 @@
|
|
|
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
|
+
|
|
6
138
|
## 1.0.31 (2024-02-28)
|
|
7
139
|
|
|
8
140
|
|
|
@@ -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","
|
|
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,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,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAEpE,MAAMY,IAAI,GAAGA,CAAA,KAAM;EACjB,MAAM,CAACC,gBAAgB,EAAEC,mBAAmB,CAAC,GAAG,IAAAC,eAAQ,EAACC,qCAA4B,CAACC,UAAU,CAAC;EAEjG,OACEjC,MAAA,CAAAa,OAAA,CAAAqB,aAAA;IACE,eAAY,gCAAgC;IAC5CC,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
|
-
|
|
24
|
+
tooltipLabel
|
|
22
25
|
} = _ref2;
|
|
23
26
|
return {
|
|
24
27
|
id,
|
|
25
|
-
label:
|
|
28
|
+
label: tooltipLabel ? lang(tooltipLabel.translationKey, {
|
|
29
|
+
count: tooltipLabel.count
|
|
30
|
+
}) : lang(label)
|
|
26
31
|
};
|
|
27
32
|
});
|
|
28
33
|
const [{
|
package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeUnitSelect.js","names":["_react","_interopRequireDefault","require","_labsWidgetCommon","obj","__esModule","default","TimeUnitSelect","_ref","selected","options","callback","
|
|
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(
|
|
31
|
-
|
|
32
|
-
|
|
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:
|
|
44
|
+
key: value,
|
|
35
45
|
size: _labsWidgetCommon.ButtonSize.full,
|
|
36
|
-
variant: selected ===
|
|
46
|
+
variant: selected === value ? _labsWidgetCommon.ButtonVariant.primary : _labsWidgetCommon.ButtonVariant.secondary,
|
|
37
47
|
onClick: handleButtonClick,
|
|
38
|
-
value:
|
|
48
|
+
value: value,
|
|
39
49
|
"data-tooltip-id": _constants.CURRENCY_POWER_BALANCE_TOOLTIP_ID,
|
|
40
50
|
"data-tooltip-content": tooltip
|
|
41
|
-
},
|
|
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;
|
package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map
CHANGED
|
@@ -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","
|
|
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,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAElD,MAAMY,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,MAAM;IAAEC;EAAK,CAAC,GAAG,IAAAC,iBAAU,EAACC,8BAAY,CAAC;EACzC,MAAMC,SAAS,GAAGH,IAAI,KAAKI,sBAAI,CAACC,OAAO;EAEvC,MAAMC,iBAAiB,GAAIjC,CAA0C,IAAK;IACxEwB,QAAQ,CAACxB,CAAC,CAACkC,aAAa,CAACC,KAAqC,CAAC;EACjE,CAAC;EAED,OACE3C,MAAA,CAAAa,OAAA,CAAA+B,aAAA,CAAA5C,MAAA,CAAAa,OAAA,CAAAgC,QAAA,QACGP,SAAS,GAENtC,MAAA,CAAAa,OAAA,CAAA+B,aAAA;IAAK,eAAY,kBAAkB;IAACE,SAAS,EAAC;EAAsC,GACjFf,OAAO,CAACgB,GAAG,CAACC,KAAA,IAAoC;IAAA,IAAnC;MAAEL,KAAK;MAAEM,KAAK;MAAEC;IAAa,CAAC,GAAAF,KAAA;IAC1C,MAAMG,OAAO,GAAGD,YAAY,GACxBjB,IAAI,CAACiB,YAAY,CAACE,cAAc,EAAE;MAAEC,KAAK,EAAEH,YAAY,CAACG;IAAM,CAAC,CAAC,GAChEH,YAAY;IAChB,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
|
|
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
|
-
|
|
11
|
+
tooltipLabel: {
|
|
12
|
+
translationKey: 'month',
|
|
13
|
+
count: 3
|
|
14
|
+
}
|
|
12
15
|
}, {
|
|
13
16
|
value: _graphql.CurrencyPowerBalanceTimeUnit.M1,
|
|
14
17
|
label: '1m',
|
|
15
|
-
|
|
18
|
+
tooltipLabel: {
|
|
19
|
+
translationKey: 'month',
|
|
20
|
+
count: 1
|
|
21
|
+
}
|
|
16
22
|
}, {
|
|
17
23
|
value: _graphql.CurrencyPowerBalanceTimeUnit.W1,
|
|
18
24
|
label: '1w',
|
|
19
|
-
|
|
25
|
+
tooltipLabel: {
|
|
26
|
+
translationKey: 'week',
|
|
27
|
+
count: 1
|
|
28
|
+
}
|
|
20
29
|
}, {
|
|
21
30
|
value: _graphql.CurrencyPowerBalanceTimeUnit.H24,
|
|
22
31
|
label: '24h',
|
|
23
|
-
|
|
32
|
+
tooltipLabel: {
|
|
33
|
+
translationKey: 'hour',
|
|
34
|
+
count: 24
|
|
35
|
+
}
|
|
24
36
|
}, {
|
|
25
37
|
value: _graphql.CurrencyPowerBalanceTimeUnit.H8,
|
|
26
38
|
label: '8h',
|
|
27
|
-
|
|
39
|
+
tooltipLabel: {
|
|
40
|
+
translationKey: 'hour',
|
|
41
|
+
count: 8
|
|
42
|
+
}
|
|
28
43
|
}, {
|
|
29
44
|
value: _graphql.CurrencyPowerBalanceTimeUnit.H4,
|
|
30
45
|
label: '4h',
|
|
31
|
-
|
|
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","
|
|
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","
|
|
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
|
-
|
|
17
|
+
tooltipLabel
|
|
15
18
|
} = _ref2;
|
|
16
19
|
return {
|
|
17
20
|
id,
|
|
18
|
-
label:
|
|
21
|
+
label: tooltipLabel ? lang(tooltipLabel.translationKey, {
|
|
22
|
+
count: tooltipLabel.count
|
|
23
|
+
}) : lang(label)
|
|
19
24
|
};
|
|
20
25
|
});
|
|
21
26
|
const [{
|
package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeUnitSelect.js","names":["React","Select","TimeUnitSelect","_ref","selected","options","callback","
|
|
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 }) => callback(id as CurrencyPowerBalanceTimeUnit)}\n />\n </div>\n );\n};\n\nexport { TimeUnitSelect };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,2BAA2B;AAClD,SAASC,SAAS,QAAQ,kBAAkB;AAI5C,MAAMC,cAAc,GAAGC,IAAA,IAEI;EAAA,IAFH;IACtBC,QAAQ;IAAEC,OAAO;IAAEC;EACA,CAAC,GAAAH,IAAA;EACpB,MAAM;IAAEI;EAAK,CAAC,GAAGN,SAAS,CAAC,CAAC;EAC5B,MAAMO,aAAa,GAAGH,OAAO,CAC1BI,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,KAAK,EAAEC,EAAE;MAAEC,KAAK;MAAEC;IAAa,CAAC,GAAAJ,KAAA;IAAA,OAAM;MAC5CE,EAAE;MACFC,KAAK,EAAEC,YAAY,GACfP,IAAI,CAACO,YAAY,CAACC,cAAc,EAAE;QAAEC,KAAK,EAAEF,YAAY,CAACE;MAAM,CAAC,CAAC,GAChET,IAAI,CAACM,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,KAAKR,QAAQ;EAAA,EAAC;EAEpF,OACEL,KAAA,CAAAqB,aAAA;IAAK,eAAY,kBAAkB;IAACC,SAAS,EAAC;EAAmB,GAC/DtB,KAAA,CAAAqB,aAAA,CAACpB,MAAM;IACLK,OAAO,EAAEG,aAAc;IACvBc,cAAc,EAAE;MAAEV,EAAE,EAAER,QAAQ;MAAES,KAAK,EAAEI;IAAc,CAAE;IACvDM,iBAAiB,EAAEC,KAAA;MAAA,IAAC;QAAEZ;MAAG,CAAC,GAAAY,KAAA;MAAA,OAAKlB,QAAQ,CAACM,EAAkC,CAAC;IAAA;EAAC,CAC7E,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(
|
|
23
|
-
|
|
24
|
-
|
|
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:
|
|
36
|
+
key: value,
|
|
27
37
|
size: ButtonSize.full,
|
|
28
|
-
variant: selected ===
|
|
38
|
+
variant: selected === value ? ButtonVariant.primary : ButtonVariant.secondary,
|
|
29
39
|
onClick: handleButtonClick,
|
|
30
|
-
value:
|
|
40
|
+
value: value,
|
|
31
41
|
"data-tooltip-id": CURRENCY_POWER_BALANCE_TOOLTIP_ID,
|
|
32
42
|
"data-tooltip-content": tooltip
|
|
33
|
-
},
|
|
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 };
|
package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map
CHANGED
|
@@ -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","
|
|
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
|
|
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
|
-
|
|
5
|
+
tooltipLabel: {
|
|
6
|
+
translationKey: 'month',
|
|
7
|
+
count: 3
|
|
8
|
+
}
|
|
6
9
|
}, {
|
|
7
10
|
value: CurrencyPowerBalanceTimeUnit.M1,
|
|
8
11
|
label: '1m',
|
|
9
|
-
|
|
12
|
+
tooltipLabel: {
|
|
13
|
+
translationKey: 'month',
|
|
14
|
+
count: 1
|
|
15
|
+
}
|
|
10
16
|
}, {
|
|
11
17
|
value: CurrencyPowerBalanceTimeUnit.W1,
|
|
12
18
|
label: '1w',
|
|
13
|
-
|
|
19
|
+
tooltipLabel: {
|
|
20
|
+
translationKey: 'week',
|
|
21
|
+
count: 1
|
|
22
|
+
}
|
|
14
23
|
}, {
|
|
15
24
|
value: CurrencyPowerBalanceTimeUnit.H24,
|
|
16
25
|
label: '24h',
|
|
17
|
-
|
|
26
|
+
tooltipLabel: {
|
|
27
|
+
translationKey: 'hour',
|
|
28
|
+
count: 24
|
|
29
|
+
}
|
|
18
30
|
}, {
|
|
19
31
|
value: CurrencyPowerBalanceTimeUnit.H8,
|
|
20
32
|
label: '8h',
|
|
21
|
-
|
|
33
|
+
tooltipLabel: {
|
|
34
|
+
translationKey: 'hour',
|
|
35
|
+
count: 8
|
|
36
|
+
}
|
|
22
37
|
}, {
|
|
23
38
|
value: CurrencyPowerBalanceTimeUnit.H4,
|
|
24
39
|
label: '4h',
|
|
25
|
-
|
|
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","
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
5
|
+
tooltipLabel: {
|
|
6
|
+
translationKey: string;
|
|
7
|
+
count: number;
|
|
8
|
+
};
|
|
6
9
|
} | {
|
|
7
10
|
value: CurrencyPowerBalanceTimeUnit;
|
|
8
11
|
label: string;
|
|
9
|
-
|
|
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.
|
|
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.
|
|
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": "
|
|
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,
|
|
8
|
+
selected, options, callback,
|
|
8
9
|
}: TimeUnitSwitchProps) => {
|
|
10
|
+
const { lang } = useLocale();
|
|
9
11
|
const selectOptions = options
|
|
10
|
-
.map(({ value: id, label,
|
|
12
|
+
.map(({ value: id, label, tooltipLabel }) => ({
|
|
11
13
|
id,
|
|
12
|
-
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,
|
|
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((
|
|
26
|
-
const tooltip =
|
|
27
|
-
?
|
|
28
|
-
:
|
|
29
|
-
const
|
|
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={
|
|
35
|
+
key={value}
|
|
34
36
|
size={ButtonSize.full}
|
|
35
|
-
variant={selected ===
|
|
37
|
+
variant={selected === value
|
|
36
38
|
? ButtonVariant.primary
|
|
37
39
|
: ButtonVariant.secondary}
|
|
38
40
|
onClick={handleButtonClick}
|
|
39
|
-
value={
|
|
41
|
+
value={value}
|
|
40
42
|
data-tooltip-id={CURRENCY_POWER_BALANCE_TOOLTIP_ID}
|
|
41
43
|
data-tooltip-content={tooltip}
|
|
42
44
|
>
|
|
43
|
-
{
|
|
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
|
-
|
|
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
|
-
|
|
7
|
+
tooltipLabel: {
|
|
8
|
+
translationKey: 'month',
|
|
9
|
+
count: 3,
|
|
10
|
+
},
|
|
8
11
|
},
|
|
9
12
|
{
|
|
10
13
|
value: CurrencyPowerBalanceTimeUnit.M1,
|
|
11
14
|
label: '1m',
|
|
12
|
-
|
|
15
|
+
tooltipLabel: {
|
|
16
|
+
translationKey: 'month',
|
|
17
|
+
count: 1,
|
|
18
|
+
},
|
|
13
19
|
},
|
|
14
20
|
{
|
|
15
21
|
value: CurrencyPowerBalanceTimeUnit.W1,
|
|
16
22
|
label: '1w',
|
|
17
|
-
|
|
23
|
+
tooltipLabel: {
|
|
24
|
+
translationKey: 'week',
|
|
25
|
+
count: 1,
|
|
26
|
+
},
|
|
18
27
|
},
|
|
19
28
|
{
|
|
20
29
|
value: CurrencyPowerBalanceTimeUnit.H24,
|
|
21
30
|
label: '24h',
|
|
22
|
-
|
|
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
|
}
|