@oanda/labs-currency-power-balance-widget 1.0.2 → 1.0.4
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 +36 -0
- package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +2 -1
- package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +8 -2
- package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/Tool.js +7 -2
- package/dist/main/CurrencyPowerBalanceWidget/Tool.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +2 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +3 -2
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +2 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/config.js +3 -3
- package/dist/main/CurrencyPowerBalanceWidget/config.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/render.js +8 -1
- package/dist/main/CurrencyPowerBalanceWidget/render.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/types.js.map +1 -1
- package/dist/main/translations/index.js +19 -0
- package/dist/main/translations/index.js.map +1 -0
- package/dist/main/translations/sources/en.json +18 -0
- package/dist/main/translations/sources/zh_TW.json +18 -0
- package/dist/main/translations/translations.js +25 -0
- package/dist/main/translations/translations.js.map +1 -0
- package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +2 -1
- package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +9 -3
- package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/Tool.js +7 -2
- package/dist/module/CurrencyPowerBalanceWidget/Tool.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +2 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +3 -2
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +2 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/config.js +3 -3
- package/dist/module/CurrencyPowerBalanceWidget/config.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/render.js +8 -1
- package/dist/module/CurrencyPowerBalanceWidget/render.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/types.js.map +1 -1
- package/dist/module/translations/index.js +12 -0
- package/dist/module/translations/index.js.map +1 -0
- package/dist/module/translations/sources/en.json +18 -0
- package/dist/module/translations/sources/zh_TW.json +18 -0
- package/dist/module/translations/translations.js +19 -0
- package/dist/module/translations/translations.js.map +1 -0
- package/dist/types/CurrencyPowerBalanceWidget/CurrencyPowerBalance.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +1 -0
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/types.d.ts +3 -0
- package/dist/types/translations/index.d.ts +4 -0
- package/dist/types/translations/translations.d.ts +18 -0
- package/lokalise.config.json +18 -0
- package/package.json +4 -3
- package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +1 -0
- package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +9 -5
- package/src/CurrencyPowerBalanceWidget/Tool.tsx +4 -1
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +1 -1
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +1 -0
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +5 -2
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +1 -0
- package/src/CurrencyPowerBalanceWidget/config.ts +3 -3
- package/src/CurrencyPowerBalanceWidget/render.tsx +5 -0
- package/src/CurrencyPowerBalanceWidget/types.ts +3 -0
- package/src/translations/index.ts +13 -0
- package/src/translations/sources/en.json +18 -0
- package/src/translations/sources/zh_TW.json +18 -0
- package/src/translations/translations.ts +18 -0
- package/test/chartFormatters.test.ts +5 -5
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
+
import { useLocale } from '@oanda/mono-i18n';
|
|
2
3
|
import { timeUnitConfig } from './config';
|
|
3
4
|
import { TimeUnitSwitch } from './components/TimeUnitSwitch';
|
|
4
5
|
import { ChartWithData } from './ChartWithData';
|
|
5
6
|
import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
|
|
6
7
|
const Tool = () => {
|
|
7
8
|
const [selectedTimeUnit, setSelectedTimeUnit] = useState(CurrencyPowerBalanceTimeUnit.CurrentDay);
|
|
9
|
+
const {
|
|
10
|
+
lang
|
|
11
|
+
} = useLocale();
|
|
8
12
|
return React.createElement("div", {
|
|
9
13
|
"data-testid": "currency-power-balance-wrapper",
|
|
10
|
-
className: "lw-flex lw-flex-col lw-
|
|
14
|
+
className: "lw-flex lw-flex-col lw-text-sm lw-tracking-normal"
|
|
11
15
|
}, React.createElement(TimeUnitSwitch, {
|
|
12
16
|
selected: selectedTimeUnit,
|
|
13
17
|
callback: setSelectedTimeUnit,
|
|
14
|
-
options: timeUnitConfig
|
|
18
|
+
options: timeUnitConfig,
|
|
19
|
+
labelCallback: lang
|
|
15
20
|
}), React.createElement(ChartWithData, {
|
|
16
21
|
timeUnit: selectedTimeUnit
|
|
17
22
|
}));
|
|
@@ -1 +1 @@
|
|
|
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-
|
|
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"}
|
|
@@ -46,7 +46,7 @@ const tooltipFormatter = values => {
|
|
|
46
46
|
} = _ref4;
|
|
47
47
|
return "<div style=\"display:flex;align-items:center;\">\n <div style=\"display:flex;align-items:center;width:50px;margin-right:10px;\">\n ".concat(marker, "\n <span>").concat(seriesName, "</span>\n </div>\n <span>").concat(value[1], "</span>\n </div>");
|
|
48
48
|
});
|
|
49
|
-
return "<div style=\"display:flex; flex-direction:column;\">\n <
|
|
49
|
+
return "<div style=\"display:flex; flex-direction:column;\">\n <span style=\"margin-bottom:5px;\">".concat(date, "</span>\n ").concat(row.join('\n'), "\n </div>");
|
|
50
50
|
};
|
|
51
51
|
export { tooltipFormatter, xAxisLabelFormatter };
|
|
52
52
|
//# sourceMappingURL=formatters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","names":["getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","concat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","xAxisLabelFormatter","label","timeUnit","isDateFormat","startsWith","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { TooltipFormatterParams } from './types';\n\nconst getDateAndTime = (param: string) => {\n const dateAndTime = param.split('T');\n\n return {\n date: dateAndTime[0],\n time: dateAndTime[1].substring(0, 5),\n };\n};\n\nconst dateFormat = (date: string) => `${new Date(date).toLocaleDateString(undefined, { month: 'numeric', day: 'numeric' })}`;\n\nconst dateTimeFormat = ({ date, time }: { date: string, time: string }) => `${new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: 'numeric', day: 'numeric' })}, ${time} UTC`;\n\nconst xAxisLabelFormatter = (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => {\n const { date, time } = getDateAndTime(label);\n const isDateFormat = timeUnit.startsWith('M') || timeUnit.startsWith('W') || time === '00:00';\n\n return isDateFormat ? dateFormat(date) : time;\n};\n\nconst tooltipFormatter = (values: TooltipFormatterParams[]) => {\n const date = dateTimeFormat(getDateAndTime(values[0].value[0]));\n\n const row = values\n .sort(({ value: valueA }, { value: valueB }) => Number(valueB[1]) - Number(valueA[1]))\n .map(({ marker, seriesName, value }) => `<div style=\"display:flex;align-items:center;\">\n <div style=\"display:flex;align-items:center;width:50px;margin-right:10px;\">\n ${marker}\n <span>${seriesName}</span>\n </div>\n <span>${value[1]}</span>\n </div>`);\n\n return `<div style=\"display:flex; flex-direction:column;\">\n <
|
|
1
|
+
{"version":3,"file":"formatters.js","names":["getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","concat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","xAxisLabelFormatter","label","timeUnit","isDateFormat","startsWith","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { TooltipFormatterParams } from './types';\n\nconst getDateAndTime = (param: string) => {\n const dateAndTime = param.split('T');\n\n return {\n date: dateAndTime[0],\n time: dateAndTime[1].substring(0, 5),\n };\n};\n\nconst dateFormat = (date: string) => `${new Date(date).toLocaleDateString(undefined, { month: 'numeric', day: 'numeric' })}`;\n\nconst dateTimeFormat = ({ date, time }: { date: string, time: string }) => `${new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: 'numeric', day: 'numeric' })}, ${time} UTC`;\n\nconst xAxisLabelFormatter = (label: string, timeUnit: CurrencyPowerBalanceTimeUnit) => {\n const { date, time } = getDateAndTime(label);\n const isDateFormat = timeUnit.startsWith('M') || timeUnit.startsWith('W') || time === '00:00';\n\n return isDateFormat ? dateFormat(date) : time;\n};\n\nconst tooltipFormatter = (values: TooltipFormatterParams[]) => {\n const date = dateTimeFormat(getDateAndTime(values[0].value[0]));\n\n const row = values\n .sort(({ value: valueA }, { value: valueB }) => Number(valueB[1]) - Number(valueA[1]))\n .map(({ marker, seriesName, value }) => `<div style=\"display:flex;align-items:center;\">\n <div style=\"display:flex;align-items:center;width:50px;margin-right:10px;\">\n ${marker}\n <span>${seriesName}</span>\n </div>\n <span>${value[1]}</span>\n </div>`);\n\n return `<div style=\"display:flex; flex-direction:column;\">\n <span style=\"margin-bottom:5px;\">${date}</span>\n ${row.join('\\n')}\n </div>`;\n};\n\nexport {\n tooltipFormatter,\n xAxisLabelFormatter,\n};\n"],"mappings":"AAGA,MAAMA,cAAc,GAAIC,KAAa,IAAK;EACxC,MAAMC,WAAW,GAAGD,KAAK,CAACE,KAAK,CAAC,GAAG,CAAC;EAEpC,OAAO;IACLC,IAAI,EAAEF,WAAW,CAAC,CAAC,CAAC;IACpBG,IAAI,EAAEH,WAAW,CAAC,CAAC,CAAC,CAACI,SAAS,CAAC,CAAC,EAAE,CAAC;EACrC,CAAC;AACH,CAAC;AAED,MAAMC,UAAU,GAAIH,IAAY,OAAAI,MAAA,CAAQ,IAAIC,IAAI,CAACL,IAAI,CAAC,CAACM,kBAAkB,CAACC,SAAS,EAAE;EAAEC,KAAK,EAAE,SAAS;EAAEC,GAAG,EAAE;AAAU,CAAC,CAAC,CAAE;AAE5H,MAAMC,cAAc,GAAGC,IAAA;EAAA,IAAC;IAAEX,IAAI;IAAEC;EAAqC,CAAC,GAAAU,IAAA;EAAA,UAAAP,MAAA,CAAQ,IAAIC,IAAI,CAACL,IAAI,CAAC,CAACM,kBAAkB,CAACC,SAAS,EAAE;IAAEK,IAAI,EAAE,SAAS;IAAEJ,KAAK,EAAE,SAAS;IAAEC,GAAG,EAAE;EAAU,CAAC,CAAC,QAAAL,MAAA,CAAKH,IAAI;AAAA,CAAM;AAEhM,MAAMY,mBAAmB,GAAGA,CAACC,KAAa,EAAEC,QAAsC,KAAK;EACrF,MAAM;IAAEf,IAAI;IAAEC;EAAK,CAAC,GAAGL,cAAc,CAACkB,KAAK,CAAC;EAC5C,MAAME,YAAY,GAAGD,QAAQ,CAACE,UAAU,CAAC,GAAG,CAAC,IAAIF,QAAQ,CAACE,UAAU,CAAC,GAAG,CAAC,IAAIhB,IAAI,KAAK,OAAO;EAE7F,OAAOe,YAAY,GAAGb,UAAU,CAACH,IAAI,CAAC,GAAGC,IAAI;AAC/C,CAAC;AAED,MAAMiB,gBAAgB,GAAIC,MAAgC,IAAK;EAC7D,MAAMnB,IAAI,GAAGU,cAAc,CAACd,cAAc,CAACuB,MAAM,CAAC,CAAC,CAAC,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;EAE/D,MAAMC,GAAG,GAAGF,MAAM,CACfG,IAAI,CAAC,CAAAC,KAAA,EAAAC,KAAA;IAAA,IAAC;MAAEJ,KAAK,EAAEK;IAAO,CAAC,GAAAF,KAAA;IAAA,IAAE;MAAEH,KAAK,EAAEM;IAAO,CAAC,GAAAF,KAAA;IAAA,OAAKG,MAAM,CAACD,MAAM,CAAC,CAAC,CAAC,CAAC,GAAGC,MAAM,CAACF,MAAM,CAAC,CAAC,CAAC,CAAC;EAAA,EAAC,CACrFG,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,MAAM;MAAEC,UAAU;MAAEX;IAAM,CAAC,GAAAS,KAAA;IAAA,yJAAAzB,MAAA,CAE7B0B,MAAM,sBAAA1B,MAAA,CACA2B,UAAU,yCAAA3B,MAAA,CAEZgB,KAAK,CAAC,CAAC,CAAC;EAAA,CACX,CAAC;EAEV,uGAAAhB,MAAA,CACqCJ,IAAI,mBAAAI,MAAA,CACrCiB,GAAG,CAACW,IAAI,CAAC,IAAI,CAAC;AAEpB,CAAC;AAED,SACEd,gBAAgB,EAChBL,mBAAmB"}
|
|
@@ -53,7 +53,8 @@ const getOption = (values, timeUnit, isDark) => {
|
|
|
53
53
|
color: isDark ? TOOLTIP_LINE_COLOR_CONFIG.DARK : TOOLTIP_LINE_COLOR_CONFIG.LIGHT
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
formatter: tooltipFormatter
|
|
56
|
+
formatter: tooltipFormatter,
|
|
57
|
+
extraCssText: 'z-index: 1'
|
|
57
58
|
},
|
|
58
59
|
xAxis: {
|
|
59
60
|
type: 'category',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOption.js","names":["COLOR_CONFIG","TOOLTIP_LINE_COLOR_CONFIG","VERTICAL_LINE_COUNT","tooltipFormatter","xAxisLabelFormatter","getOption","values","timeUnit","isDark","seriesData","map","_ref","currency","power","name","type","symbol","showSymbol","itemStyle","color","lineStyle","data","_ref2","point","price","legendData","_ref3","animation","legend","bottom","icon","tooltip","trigger","axisPointer","axis","z","DARK","LIGHT","formatter","xAxis","axisTick","show","axisLine","splitLine","axisLabel","margin","showMinLabel","rotate","interval","Math","round","length","label","yAxis","position","splitNumber","boundaryGap","showMaxLabel","series"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts"],"sourcesContent":["import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, VERTICAL_LINE_COUNT } from './constants';\nimport { tooltipFormatter, xAxisLabelFormatter } from './formatters';\nimport { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\n\nconst getOption = (\n values: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n) => {\n const seriesData = values.map(({ currency, power }) => ({\n name: currency,\n type: 'line',\n symbol: 'circle',\n showSymbol: false,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n lineStyle: {\n color: COLOR_CONFIG[currency],\n },\n data: power.map(({ point, price }) => [point, price]),\n }));\n\n const legendData = values.map(({ currency }) => ({\n name: currency,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n }));\n\n return {\n animation: false,\n legend: {\n data: legendData,\n bottom: 10,\n icon: 'circle',\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n axis: 'x',\n z: 0,\n lineStyle: {\n color: isDark ? TOOLTIP_LINE_COLOR_CONFIG.DARK : TOOLTIP_LINE_COLOR_CONFIG.LIGHT,\n },\n },\n formatter: tooltipFormatter,\n },\n xAxis: {\n type: 'category',\n axisTick: {\n show: false,\n },\n axisLine: { show: false },\n splitLine: {\n show: true,\n },\n axisLabel: {\n margin: 10,\n showMinLabel: false,\n rotate: -45,\n interval: Math.round(seriesData[0].data.length / VERTICAL_LINE_COUNT),\n formatter: (label: string) => xAxisLabelFormatter(label, timeUnit),\n },\n },\n yAxis: {\n type: 'value',\n position: 'right',\n splitNumber: 5,\n axisLine: { show: false },\n axisTick: { show: false },\n boundaryGap: ['10%', '10%'],\n axisLabel: {\n showMaxLabel: false,\n showMinLabel: false,\n },\n },\n series: seriesData,\n };\n};\n\nexport { getOption };\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,yBAAyB,EAAEC,mBAAmB,QAAQ,aAAa;AAC1F,SAASC,gBAAgB,EAAEC,mBAAmB,QAAQ,cAAc;AAGpE,MAAMC,SAAS,GAAGA,CAChBC,MAA8B,EAC9BC,QAAsC,EACtCC,MAAe,KACZ;EACH,MAAMC,UAAU,GAAGH,MAAM,CAACI,GAAG,CAACC,IAAA;IAAA,IAAC;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAAF,IAAA;IAAA,OAAM;MACtDG,IAAI,EAAEF,QAAQ;MACdG,IAAI,EAAE,MAAM;MACZC,MAAM,EAAE,QAAQ;MAChBC,UAAU,EAAE,KAAK;MACjBC,SAAS,EAAE;QACTC,KAAK,EAAEnB,YAAY,CAACY,QAAQ;MAC9B,CAAC;MACDQ,SAAS,EAAE;QACTD,KAAK,EAAEnB,YAAY,CAACY,QAAQ;MAC9B,CAAC;MACDS,IAAI,EAAER,KAAK,CAACH,GAAG,CAACY,KAAA;QAAA,IAAC;UAAEC,KAAK;UAAEC;QAAM,CAAC,GAAAF,KAAA;QAAA,OAAK,CAACC,KAAK,EAAEC,KAAK,CAAC;MAAA;IACtD,CAAC;EAAA,CAAC,CAAC;EAEH,MAAMC,UAAU,GAAGnB,MAAM,CAACI,GAAG,CAACgB,KAAA;IAAA,IAAC;MAAEd;IAAS,CAAC,GAAAc,KAAA;IAAA,OAAM;MAC/CZ,IAAI,EAAEF,QAAQ;MACdM,SAAS,EAAE;QACTC,KAAK,EAAEnB,YAAY,CAACY,QAAQ;MAC9B;IACF,CAAC;EAAA,CAAC,CAAC;EAEH,OAAO;IACLe,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAE;MACNP,IAAI,EAAEI,UAAU;MAChBI,MAAM,EAAE,EAAE;MACVC,IAAI,EAAE;IACR,CAAC;IACDC,OAAO,EAAE;MACPC,OAAO,EAAE,MAAM;MACfC,WAAW,EAAE;QACXC,IAAI,EAAE,GAAG;QACTC,CAAC,EAAE,CAAC;QACJf,SAAS,EAAE;UACTD,KAAK,EAAEX,MAAM,GAAGP,yBAAyB,CAACmC,IAAI,GAAGnC,yBAAyB,CAACoC;QAC7E;MACF,CAAC;MACDC,SAAS,EAAEnC;
|
|
1
|
+
{"version":3,"file":"getOption.js","names":["COLOR_CONFIG","TOOLTIP_LINE_COLOR_CONFIG","VERTICAL_LINE_COUNT","tooltipFormatter","xAxisLabelFormatter","getOption","values","timeUnit","isDark","seriesData","map","_ref","currency","power","name","type","symbol","showSymbol","itemStyle","color","lineStyle","data","_ref2","point","price","legendData","_ref3","animation","legend","bottom","icon","tooltip","trigger","axisPointer","axis","z","DARK","LIGHT","formatter","extraCssText","xAxis","axisTick","show","axisLine","splitLine","axisLabel","margin","showMinLabel","rotate","interval","Math","round","length","label","yAxis","position","splitNumber","boundaryGap","showMaxLabel","series"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts"],"sourcesContent":["import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG, VERTICAL_LINE_COUNT } from './constants';\nimport { tooltipFormatter, xAxisLabelFormatter } from './formatters';\nimport { CurrencyPowerBalance, CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\n\nconst getOption = (\n values: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n) => {\n const seriesData = values.map(({ currency, power }) => ({\n name: currency,\n type: 'line',\n symbol: 'circle',\n showSymbol: false,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n lineStyle: {\n color: COLOR_CONFIG[currency],\n },\n data: power.map(({ point, price }) => [point, price]),\n }));\n\n const legendData = values.map(({ currency }) => ({\n name: currency,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n }));\n\n return {\n animation: false,\n legend: {\n data: legendData,\n bottom: 10,\n icon: 'circle',\n },\n tooltip: {\n trigger: 'axis',\n axisPointer: {\n axis: 'x',\n z: 0,\n lineStyle: {\n color: isDark ? TOOLTIP_LINE_COLOR_CONFIG.DARK : TOOLTIP_LINE_COLOR_CONFIG.LIGHT,\n },\n },\n formatter: tooltipFormatter,\n extraCssText: 'z-index: 1',\n },\n xAxis: {\n type: 'category',\n axisTick: {\n show: false,\n },\n axisLine: { show: false },\n splitLine: {\n show: true,\n },\n axisLabel: {\n margin: 10,\n showMinLabel: false,\n rotate: -45,\n interval: Math.round(seriesData[0].data.length / VERTICAL_LINE_COUNT),\n formatter: (label: string) => xAxisLabelFormatter(label, timeUnit),\n },\n },\n yAxis: {\n type: 'value',\n position: 'right',\n splitNumber: 5,\n axisLine: { show: false },\n axisTick: { show: false },\n boundaryGap: ['10%', '10%'],\n axisLabel: {\n showMaxLabel: false,\n showMinLabel: false,\n },\n },\n series: seriesData,\n };\n};\n\nexport { getOption };\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,yBAAyB,EAAEC,mBAAmB,QAAQ,aAAa;AAC1F,SAASC,gBAAgB,EAAEC,mBAAmB,QAAQ,cAAc;AAGpE,MAAMC,SAAS,GAAGA,CAChBC,MAA8B,EAC9BC,QAAsC,EACtCC,MAAe,KACZ;EACH,MAAMC,UAAU,GAAGH,MAAM,CAACI,GAAG,CAACC,IAAA;IAAA,IAAC;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAAF,IAAA;IAAA,OAAM;MACtDG,IAAI,EAAEF,QAAQ;MACdG,IAAI,EAAE,MAAM;MACZC,MAAM,EAAE,QAAQ;MAChBC,UAAU,EAAE,KAAK;MACjBC,SAAS,EAAE;QACTC,KAAK,EAAEnB,YAAY,CAACY,QAAQ;MAC9B,CAAC;MACDQ,SAAS,EAAE;QACTD,KAAK,EAAEnB,YAAY,CAACY,QAAQ;MAC9B,CAAC;MACDS,IAAI,EAAER,KAAK,CAACH,GAAG,CAACY,KAAA;QAAA,IAAC;UAAEC,KAAK;UAAEC;QAAM,CAAC,GAAAF,KAAA;QAAA,OAAK,CAACC,KAAK,EAAEC,KAAK,CAAC;MAAA;IACtD,CAAC;EAAA,CAAC,CAAC;EAEH,MAAMC,UAAU,GAAGnB,MAAM,CAACI,GAAG,CAACgB,KAAA;IAAA,IAAC;MAAEd;IAAS,CAAC,GAAAc,KAAA;IAAA,OAAM;MAC/CZ,IAAI,EAAEF,QAAQ;MACdM,SAAS,EAAE;QACTC,KAAK,EAAEnB,YAAY,CAACY,QAAQ;MAC9B;IACF,CAAC;EAAA,CAAC,CAAC;EAEH,OAAO;IACLe,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAE;MACNP,IAAI,EAAEI,UAAU;MAChBI,MAAM,EAAE,EAAE;MACVC,IAAI,EAAE;IACR,CAAC;IACDC,OAAO,EAAE;MACPC,OAAO,EAAE,MAAM;MACfC,WAAW,EAAE;QACXC,IAAI,EAAE,GAAG;QACTC,CAAC,EAAE,CAAC;QACJf,SAAS,EAAE;UACTD,KAAK,EAAEX,MAAM,GAAGP,yBAAyB,CAACmC,IAAI,GAAGnC,yBAAyB,CAACoC;QAC7E;MACF,CAAC;MACDC,SAAS,EAAEnC,gBAAgB;MAC3BoC,YAAY,EAAE;IAChB,CAAC;IACDC,KAAK,EAAE;MACLzB,IAAI,EAAE,UAAU;MAChB0B,QAAQ,EAAE;QACRC,IAAI,EAAE;MACR,CAAC;MACDC,QAAQ,EAAE;QAAED,IAAI,EAAE;MAAM,CAAC;MACzBE,SAAS,EAAE;QACTF,IAAI,EAAE;MACR,CAAC;MACDG,SAAS,EAAE;QACTC,MAAM,EAAE,EAAE;QACVC,YAAY,EAAE,KAAK;QACnBC,MAAM,EAAE,CAAC,EAAE;QACXC,QAAQ,EAAEC,IAAI,CAACC,KAAK,CAAC1C,UAAU,CAAC,CAAC,CAAC,CAACY,IAAI,CAAC+B,MAAM,GAAGlD,mBAAmB,CAAC;QACrEoC,SAAS,EAAGe,KAAa,IAAKjD,mBAAmB,CAACiD,KAAK,EAAE9C,QAAQ;MACnE;IACF,CAAC;IACD+C,KAAK,EAAE;MACLvC,IAAI,EAAE,OAAO;MACbwC,QAAQ,EAAE,OAAO;MACjBC,WAAW,EAAE,CAAC;MACdb,QAAQ,EAAE;QAAED,IAAI,EAAE;MAAM,CAAC;MACzBD,QAAQ,EAAE;QAAEC,IAAI,EAAE;MAAM,CAAC;MACzBe,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;MAC3BZ,SAAS,EAAE;QACTa,YAAY,EAAE,KAAK;QACnBX,YAAY,EAAE;MAChB;IACF,CAAC;IACDY,MAAM,EAAElD;EACV,CAAC;AACH,CAAC;AAED,SAASJ,SAAS"}
|
|
@@ -4,7 +4,8 @@ const TimeUnitSelect = _ref => {
|
|
|
4
4
|
let {
|
|
5
5
|
selected,
|
|
6
6
|
options,
|
|
7
|
-
callback
|
|
7
|
+
callback,
|
|
8
|
+
labelCallback
|
|
8
9
|
} = _ref;
|
|
9
10
|
const selectOptions = options.map(_ref2 => {
|
|
10
11
|
let {
|
|
@@ -14,7 +15,7 @@ const TimeUnitSelect = _ref => {
|
|
|
14
15
|
} = _ref2;
|
|
15
16
|
return {
|
|
16
17
|
id,
|
|
17
|
-
label: tooltip || label
|
|
18
|
+
label: labelCallback ? labelCallback(tooltip || label) : tooltip || label
|
|
18
19
|
};
|
|
19
20
|
});
|
|
20
21
|
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","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,\n}: TimeUnitSwitchProps) => {\n const selectOptions = options\n .map(({ value: id, label, tooltip }) => ({
|
|
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"}
|
package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeUnitSwitch.js","names":["React","Button","ButtonSize","ButtonVariant","useMediaQuery","CURRENCY_POWER_BALANCE_TOOLTIP_ID","TimeUnitSelect","TimeUnitSwitch","_ref","selected","options","callback","labelCallback","isDesktop","handleButtonClick","e","currentTarget","value","createElement","Fragment","className","map","item","tooltip","label","key","size","full","variant","primary","secondary","onClick"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx"],"sourcesContent":["import React from 'react';\nimport { Button, ButtonSize, ButtonVariant } from '@oanda/labs-widget-common';\nimport { useMediaQuery } from 'usehooks-ts';\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 isDesktop = useMediaQuery('(min-width: 768px)');\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 />\n )}\n </>\n );\n};\n\nexport { TimeUnitSwitch };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,EAAEC,UAAU,EAAEC,aAAa,QAAQ,2BAA2B;AAC7E,SAASC,aAAa,QAAQ,aAAa;AAG3C,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,MAAMK,SAAS,GAAGT,aAAa,CAAC,oBAAoB,CAAC;EAErD,MAAMU,iBAAiB,GAAIC,CAA0C,IAAK;IACxEJ,QAAQ,CAACI,CAAC,CAACC,aAAa,CAACC,KAAqC,CAAC;EACjE,CAAC;EAED,OACEjB,KAAA,CAAAkB,aAAA,CAAAlB,KAAA,CAAAmB,QAAA,QACGN,SAAS,GAENb,KAAA,CAAAkB,aAAA;IAAK,eAAY,kBAAkB;IAACE,SAAS,EAAC;EAAsC,GACjFV,OAAO,CAACW,GAAG,CAAEC,IAAI,IAAK;IACrB,MAAMC,OAAO,GAAGX,aAAa,IAAIU,IAAI,CAACC,OAAO,GACzCX,aAAa,CAACU,IAAI,CAACC,OAAO,CAAC,GAC3BD,IAAI,CAACC,OAAO;IAChB,MAAMC,KAAK,GAAGZ,aAAa,GAAGA,aAAa,CAACU,IAAI,CAACE,KAAK,CAAC,GAAGF,IAAI,CAACE,KAAK;IAEpE,OACExB,KAAA,CAAAkB,aAAA,CAACjB,MAAM;MACLwB,GAAG,EAAEH,IAAI,CAACL,KAAM;MAChBS,IAAI,EAAExB,UAAU,CAACyB,IAAK;MACtBC,OAAO,EAAEnB,QAAQ,KAAKa,IAAI,CAACL,KAAK,GAC5Bd,aAAa,CAAC0B,OAAO,GACrB1B,aAAa,CAAC2B,SAAU;MAC5BC,OAAO,EAAEjB,iBAAkB;MAC3BG,KAAK,EAAEK,IAAI,CAACL,KAAM;MAClB,mBAAiBZ,iCAAkC;MACnD,wBAAsBkB;IAAQ,GAE7BC,KACK,CAAC;EAEb,CAAC,CACE,CAAC,GAGNxB,KAAA,CAAAkB,aAAA,CAACZ,cAAc;IACbG,QAAQ,EAAEA,QAAS;IACnBE,QAAQ,EAAEA,QAAS;IACnBD,OAAO,EAAEA;
|
|
1
|
+
{"version":3,"file":"TimeUnitSwitch.js","names":["React","Button","ButtonSize","ButtonVariant","useMediaQuery","CURRENCY_POWER_BALANCE_TOOLTIP_ID","TimeUnitSelect","TimeUnitSwitch","_ref","selected","options","callback","labelCallback","isDesktop","handleButtonClick","e","currentTarget","value","createElement","Fragment","className","map","item","tooltip","label","key","size","full","variant","primary","secondary","onClick"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx"],"sourcesContent":["import React from 'react';\nimport { Button, ButtonSize, ButtonVariant } from '@oanda/labs-widget-common';\nimport { useMediaQuery } from 'usehooks-ts';\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 isDesktop = useMediaQuery('(min-width: 768px)');\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,MAAM,OAAO;AACzB,SAASC,MAAM,EAAEC,UAAU,EAAEC,aAAa,QAAQ,2BAA2B;AAC7E,SAASC,aAAa,QAAQ,aAAa;AAG3C,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,MAAMK,SAAS,GAAGT,aAAa,CAAC,oBAAoB,CAAC;EAErD,MAAMU,iBAAiB,GAAIC,CAA0C,IAAK;IACxEJ,QAAQ,CAACI,CAAC,CAACC,aAAa,CAACC,KAAqC,CAAC;EACjE,CAAC;EAED,OACEjB,KAAA,CAAAkB,aAAA,CAAAlB,KAAA,CAAAmB,QAAA,QACGN,SAAS,GAENb,KAAA,CAAAkB,aAAA;IAAK,eAAY,kBAAkB;IAACE,SAAS,EAAC;EAAsC,GACjFV,OAAO,CAACW,GAAG,CAAEC,IAAI,IAAK;IACrB,MAAMC,OAAO,GAAGX,aAAa,IAAIU,IAAI,CAACC,OAAO,GACzCX,aAAa,CAACU,IAAI,CAACC,OAAO,CAAC,GAC3BD,IAAI,CAACC,OAAO;IAChB,MAAMC,KAAK,GAAGZ,aAAa,GAAGA,aAAa,CAACU,IAAI,CAACE,KAAK,CAAC,GAAGF,IAAI,CAACE,KAAK;IAEpE,OACExB,KAAA,CAAAkB,aAAA,CAACjB,MAAM;MACLwB,GAAG,EAAEH,IAAI,CAACL,KAAM;MAChBS,IAAI,EAAExB,UAAU,CAACyB,IAAK;MACtBC,OAAO,EAAEnB,QAAQ,KAAKa,IAAI,CAACL,KAAK,GAC5Bd,aAAa,CAAC0B,OAAO,GACrB1B,aAAa,CAAC2B,SAAU;MAC5BC,OAAO,EAAEjB,iBAAkB;MAC3BG,KAAK,EAAEK,IAAI,CAACL,KAAM;MAClB,mBAAiBZ,iCAAkC;MACnD,wBAAsBkB;IAAQ,GAE7BC,KACK,CAAC;EAEb,CAAC,CACE,CAAC,GAGNxB,KAAA,CAAAkB,aAAA,CAACZ,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"}
|
|
@@ -14,7 +14,7 @@ const timeUnitConfig = [{
|
|
|
14
14
|
}, {
|
|
15
15
|
value: CurrencyPowerBalanceTimeUnit.H24,
|
|
16
16
|
label: '24h',
|
|
17
|
-
tooltip: '
|
|
17
|
+
tooltip: '24_hours'
|
|
18
18
|
}, {
|
|
19
19
|
value: CurrencyPowerBalanceTimeUnit.H8,
|
|
20
20
|
label: '8h',
|
|
@@ -25,10 +25,10 @@ const timeUnitConfig = [{
|
|
|
25
25
|
tooltip: '4_hours'
|
|
26
26
|
}, {
|
|
27
27
|
value: CurrencyPowerBalanceTimeUnit.PreviousDay,
|
|
28
|
-
label: '
|
|
28
|
+
label: 'previous_business_day'
|
|
29
29
|
}, {
|
|
30
30
|
value: CurrencyPowerBalanceTimeUnit.CurrentDay,
|
|
31
|
-
label: '
|
|
31
|
+
label: 'current_business_day'
|
|
32
32
|
}];
|
|
33
33
|
export { timeUnitConfig };
|
|
34
34
|
//# sourceMappingURL=config.js.map
|
|
@@ -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: '
|
|
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"}
|
|
@@ -3,7 +3,8 @@ import { render } from 'react-dom';
|
|
|
3
3
|
import { CurrencyPowerBalance } from './CurrencyPowerBalance';
|
|
4
4
|
const {
|
|
5
5
|
graphqlUrl: configGraphQl,
|
|
6
|
-
renderElementId: configRenderElementId
|
|
6
|
+
renderElementId: configRenderElementId,
|
|
7
|
+
locale: configLocale
|
|
7
8
|
} = window.currencyPowerBalanceWidgetConfig || {};
|
|
8
9
|
const {
|
|
9
10
|
graphqlUrl
|
|
@@ -11,14 +12,20 @@ const {
|
|
|
11
12
|
const currencyPowerBalanceParamsElements = document.querySelectorAll('div[data-currency-power-balance-params]');
|
|
12
13
|
if (currencyPowerBalanceParamsElements.length > 0) {
|
|
13
14
|
currencyPowerBalanceParamsElements.forEach(element => {
|
|
15
|
+
const params = element.getAttribute('data-currency-power-balance-params');
|
|
14
16
|
const mode = element.getAttribute('data-mode');
|
|
17
|
+
const {
|
|
18
|
+
locale
|
|
19
|
+
} = JSON.parse(params);
|
|
15
20
|
render(React.createElement(CurrencyPowerBalance, {
|
|
16
21
|
graphqlUrl: graphqlUrl,
|
|
22
|
+
locale: locale,
|
|
17
23
|
theme: mode
|
|
18
24
|
}), element);
|
|
19
25
|
});
|
|
20
26
|
} else {
|
|
21
27
|
render(React.createElement(CurrencyPowerBalance, {
|
|
28
|
+
locale: configLocale,
|
|
22
29
|
graphqlUrl: configGraphQl
|
|
23
30
|
}), document.getElementById(configRenderElementId));
|
|
24
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["React","render","CurrencyPowerBalance","graphqlUrl","configGraphQl","renderElementId","configRenderElementId","window","currencyPowerBalanceWidgetConfig","widgetsConfig","currencyPowerBalanceParamsElements","document","querySelectorAll","length","forEach","element","
|
|
1
|
+
{"version":3,"file":"render.js","names":["React","render","CurrencyPowerBalance","graphqlUrl","configGraphQl","renderElementId","configRenderElementId","locale","configLocale","window","currencyPowerBalanceWidgetConfig","widgetsConfig","currencyPowerBalanceParamsElements","document","querySelectorAll","length","forEach","element","params","getAttribute","mode","JSON","parse","createElement","theme","getElementById"],"sources":["../../../src/CurrencyPowerBalanceWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { render } from 'react-dom';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalance } from './CurrencyPowerBalance';\n\nconst {\n graphqlUrl: configGraphQl,\n renderElementId: configRenderElementId,\n locale: configLocale,\n} = window.currencyPowerBalanceWidgetConfig || {};\n\nconst {\n graphqlUrl,\n} = window.widgetsConfig || {};\n\nconst currencyPowerBalanceParamsElements = document.querySelectorAll('div[data-currency-power-balance-params]');\n\nif (currencyPowerBalanceParamsElements.length > 0) {\n currencyPowerBalanceParamsElements.forEach((element) => {\n const params = element.getAttribute('data-currency-power-balance-params');\n const mode = element.getAttribute('data-mode');\n const { locale } = JSON.parse(params as string);\n\n render(\n <CurrencyPowerBalance\n graphqlUrl={graphqlUrl}\n locale={locale}\n theme={mode as Theme}\n />,\n element,\n );\n });\n} else {\n render(\n <CurrencyPowerBalance\n locale={configLocale}\n graphqlUrl={configGraphQl}\n />,\n document.getElementById(configRenderElementId),\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,MAAM,QAAQ,WAAW;AAElC,SAASC,oBAAoB,QAAQ,wBAAwB;AAE7D,MAAM;EACJC,UAAU,EAAEC,aAAa;EACzBC,eAAe,EAAEC,qBAAqB;EACtCC,MAAM,EAAEC;AACV,CAAC,GAAGC,MAAM,CAACC,gCAAgC,IAAI,CAAC,CAAC;AAEjD,MAAM;EACJP;AACF,CAAC,GAAGM,MAAM,CAACE,aAAa,IAAI,CAAC,CAAC;AAE9B,MAAMC,kCAAkC,GAAGC,QAAQ,CAACC,gBAAgB,CAAC,yCAAyC,CAAC;AAE/G,IAAIF,kCAAkC,CAACG,MAAM,GAAG,CAAC,EAAE;EACjDH,kCAAkC,CAACI,OAAO,CAAEC,OAAO,IAAK;IACtD,MAAMC,MAAM,GAAGD,OAAO,CAACE,YAAY,CAAC,oCAAoC,CAAC;IACzE,MAAMC,IAAI,GAAGH,OAAO,CAACE,YAAY,CAAC,WAAW,CAAC;IAC9C,MAAM;MAAEZ;IAAO,CAAC,GAAGc,IAAI,CAACC,KAAK,CAACJ,MAAgB,CAAC;IAE/CjB,MAAM,CACJD,KAAA,CAAAuB,aAAA,CAACrB,oBAAoB;MACnBC,UAAU,EAAEA,UAAW;MACvBI,MAAM,EAAEA,MAAO;MACfiB,KAAK,EAAEJ;IAAc,CACtB,CAAC,EACFH,OACF,CAAC;EACH,CAAC,CAAC;AACJ,CAAC,MAAM;EACLhB,MAAM,CACJD,KAAA,CAAAuB,aAAA,CAACrB,oBAAoB;IACnBK,MAAM,EAAEC,YAAa;IACrBL,UAAU,EAAEC;EAAc,CAC3B,CAAC,EACFS,QAAQ,CAACY,cAAc,CAACnB,qBAAqB,CAC/C,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/CurrencyPowerBalanceWidget/types.ts"],"sourcesContent":["import { Theme } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nexport interface CurrencyPowerBalanceConfig {\n graphqlUrl: string;\n theme?: Theme;\n}\n\nexport interface CurrencyPowerBalanceWrapperConfig extends CurrencyPowerBalanceConfig {\n renderElementId: string;\n}\n\nexport interface ChartWithDataProps {\n timeUnit: CurrencyPowerBalanceTimeUnit;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/CurrencyPowerBalanceWidget/types.ts"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\n\nexport interface CurrencyPowerBalanceConfig {\n graphqlUrl: string;\n locale: Locale;\n theme?: Theme;\n}\n\nexport interface CurrencyPowerBalanceWrapperConfig extends CurrencyPowerBalanceConfig {\n renderElementId: string;\n locale: Locale;\n}\n\nexport interface ChartWithDataProps {\n timeUnit: CurrencyPowerBalanceTimeUnit;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Locale } from '@oanda/mono-i18n';
|
|
2
|
+
import en from './sources/en.json';
|
|
3
|
+
import zhTW from './sources/zh_TW.json';
|
|
4
|
+
export const translations = {
|
|
5
|
+
[Locale.en]: {
|
|
6
|
+
translation: en
|
|
7
|
+
},
|
|
8
|
+
[Locale.zhTW]: {
|
|
9
|
+
translation: zhTW
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["Locale","en","zhTW","translations","translation"],"sources":["../../../src/translations/index.ts"],"sourcesContent":["import { Locale, Translations } from '@oanda/mono-i18n';\n\nimport en from './sources/en.json';\nimport zhTW from './sources/zh_TW.json';\n\nimport { defaultTranslations } from './translations';\n\nexport type TranslationKey = keyof typeof defaultTranslations;\n\nexport const translations: Translations = {\n [Locale.en]: { translation: en },\n [Locale.zhTW]: { translation: zhTW },\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAsB,kBAAkB;AAEvD,OAAOC,EAAE,MAAM,mBAAmB;AAClC,OAAOC,IAAI,MAAM,sBAAsB;AAMvC,OAAO,MAAMC,YAA0B,GAAG;EACxC,CAACH,MAAM,CAACC,EAAE,GAAG;IAAEG,WAAW,EAAEH;EAAG,CAAC;EAChC,CAACD,MAAM,CAACE,IAAI,GAAG;IAAEE,WAAW,EAAEF;EAAK;AACrC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"1_month": "1 month",
|
|
3
|
+
"1_week": "1 week",
|
|
4
|
+
"1m": "1M",
|
|
5
|
+
"1w": "1W",
|
|
6
|
+
"24_hours": "24 hours",
|
|
7
|
+
"24h": "24H",
|
|
8
|
+
"3_months": "3 months",
|
|
9
|
+
"3m": "3M",
|
|
10
|
+
"4_hours": "4 hours",
|
|
11
|
+
"4h": "4H",
|
|
12
|
+
"8_hours": "8 hours",
|
|
13
|
+
"8h": "8H",
|
|
14
|
+
"current_business_day": "Current Business Day",
|
|
15
|
+
"data_unavailable": "Data unavailable",
|
|
16
|
+
"pagination_entries_range": "{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries",
|
|
17
|
+
"previous_business_day": "Previous Business Day"
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"1_month": "1 個月",
|
|
3
|
+
"1_week": "1星期",
|
|
4
|
+
"1m": "1M",
|
|
5
|
+
"1w": "1W",
|
|
6
|
+
"24_hours": "24小時",
|
|
7
|
+
"24h": "24H",
|
|
8
|
+
"3_months": "3 個月",
|
|
9
|
+
"3m": "3M",
|
|
10
|
+
"4_hours": "4小時",
|
|
11
|
+
"4h": "4H",
|
|
12
|
+
"8_hours": "8小時",
|
|
13
|
+
"8h": "8H",
|
|
14
|
+
"current_business_day": "目前營業日",
|
|
15
|
+
"data_unavailable": "沒有數據",
|
|
16
|
+
"pagination_entries_range": "{{itemCount}}个挂单中的{{firstItemOnPage}}-{{lastItemOnPage}}",
|
|
17
|
+
"previous_business_day": "前一營業日"
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const defaultTranslations = {
|
|
2
|
+
'1_month': '1 month',
|
|
3
|
+
'1_week': '1 week',
|
|
4
|
+
'1m': '1M',
|
|
5
|
+
'1w': '1W',
|
|
6
|
+
'24_hours': '24 hours',
|
|
7
|
+
'24h': '24H',
|
|
8
|
+
'3_months': '3 months',
|
|
9
|
+
'3m': '3M',
|
|
10
|
+
'4_hours': '4 hours',
|
|
11
|
+
'4h': '4H',
|
|
12
|
+
'8_hours': '8 hours',
|
|
13
|
+
'8h': '8H',
|
|
14
|
+
current_business_day: 'Current Business Day',
|
|
15
|
+
data_unavailable: 'Data unavailable',
|
|
16
|
+
pagination_entries_range: '{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries',
|
|
17
|
+
previous_business_day: 'Previous Business Day'
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=translations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translations.js","names":["defaultTranslations","current_business_day","data_unavailable","pagination_entries_range","previous_business_day"],"sources":["../../../src/translations/translations.ts"],"sourcesContent":["export const defaultTranslations = {\n '1_month': '1 month',\n '1_week': '1 week',\n '1m': '1M',\n '1w': '1W',\n '24_hours': '24 hours',\n '24h': '24H',\n '3_months': '3 months',\n '3m': '3M',\n '4_hours': '4 hours',\n '4h': '4H',\n '8_hours': '8 hours',\n '8h': '8H',\n current_business_day: 'Current Business Day',\n data_unavailable: 'Data unavailable',\n pagination_entries_range: '{{firstItemOnPage}}-{{lastItemOnPage}} of {{itemCount}} entries',\n previous_business_day: 'Previous Business Day',\n};\n"],"mappings":"AAAA,OAAO,MAAMA,mBAAmB,GAAG;EACjC,SAAS,EAAE,SAAS;EACpB,QAAQ,EAAE,QAAQ;EAClB,IAAI,EAAE,IAAI;EACV,IAAI,EAAE,IAAI;EACV,UAAU,EAAE,UAAU;EACtB,KAAK,EAAE,KAAK;EACZ,UAAU,EAAE,UAAU;EACtB,IAAI,EAAE,IAAI;EACV,SAAS,EAAE,SAAS;EACpB,IAAI,EAAE,IAAI;EACV,SAAS,EAAE,SAAS;EACpB,IAAI,EAAE,IAAI;EACVC,oBAAoB,EAAE,sBAAsB;EAC5CC,gBAAgB,EAAE,kBAAkB;EACpCC,wBAAwB,EAAE,iEAAiE;EAC3FC,qBAAqB,EAAE;AACzB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CurrencyPowerBalanceConfig } from './types';
|
|
3
|
-
declare const CurrencyPowerBalance: ({ graphqlUrl, theme, }: CurrencyPowerBalanceConfig) => JSX.Element;
|
|
3
|
+
declare const CurrencyPowerBalance: ({ graphqlUrl, theme, locale, }: CurrencyPowerBalanceConfig) => JSX.Element;
|
|
4
4
|
export { CurrencyPowerBalance };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TimeUnitSwitchProps } from './types';
|
|
3
|
-
declare const TimeUnitSelect: ({ selected, options, callback, }: TimeUnitSwitchProps) => JSX.Element;
|
|
3
|
+
declare const TimeUnitSelect: ({ selected, options, callback, labelCallback, }: TimeUnitSwitchProps) => JSX.Element;
|
|
4
4
|
export { TimeUnitSelect };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { Locale } from '@oanda/mono-i18n';
|
|
1
2
|
import { Theme } from '@oanda/labs-widget-common';
|
|
2
3
|
import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
|
|
3
4
|
export interface CurrencyPowerBalanceConfig {
|
|
4
5
|
graphqlUrl: string;
|
|
6
|
+
locale: Locale;
|
|
5
7
|
theme?: Theme;
|
|
6
8
|
}
|
|
7
9
|
export interface CurrencyPowerBalanceWrapperConfig extends CurrencyPowerBalanceConfig {
|
|
8
10
|
renderElementId: string;
|
|
11
|
+
locale: Locale;
|
|
9
12
|
}
|
|
10
13
|
export interface ChartWithDataProps {
|
|
11
14
|
timeUnit: CurrencyPowerBalanceTimeUnit;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const defaultTranslations: {
|
|
2
|
+
'1_month': string;
|
|
3
|
+
'1_week': string;
|
|
4
|
+
'1m': string;
|
|
5
|
+
'1w': string;
|
|
6
|
+
'24_hours': string;
|
|
7
|
+
'24h': string;
|
|
8
|
+
'3_months': string;
|
|
9
|
+
'3m': string;
|
|
10
|
+
'4_hours': string;
|
|
11
|
+
'4h': string;
|
|
12
|
+
'8_hours': string;
|
|
13
|
+
'8h': string;
|
|
14
|
+
current_business_day: string;
|
|
15
|
+
data_unavailable: string;
|
|
16
|
+
pagination_entries_range: string;
|
|
17
|
+
previous_business_day: string;
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"projectId": "19607517615e88022ba782.45168463",
|
|
3
|
+
"outputDir": "src/translations/sources",
|
|
4
|
+
"esModuleTranslations": "src/translations/translations.ts",
|
|
5
|
+
"messagesFormat": "esModule",
|
|
6
|
+
"esModuleConstName": "defaultTranslations",
|
|
7
|
+
"includeEmptyTranslations": true,
|
|
8
|
+
"downloadOptions": {
|
|
9
|
+
"format": "json",
|
|
10
|
+
"add_newline_eof": true,
|
|
11
|
+
"placeholder_format": "i18n",
|
|
12
|
+
"indentation": "2sp",
|
|
13
|
+
"plural_format": "i18next",
|
|
14
|
+
"export_empty_as": "skip",
|
|
15
|
+
"include_tags": ["common_widgets", "currency_balance_widget"],
|
|
16
|
+
"filter_langs": ["en", "zh_TW"]
|
|
17
|
+
}
|
|
18
|
+
}
|
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.4",
|
|
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,8 @@
|
|
|
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.65",
|
|
17
|
+
"@oanda/mono-i18n": "9.0.0",
|
|
17
18
|
"echarts": "5.4.3",
|
|
18
19
|
"echarts-for-react": "3.0.2",
|
|
19
20
|
"graphql": "16.7.1",
|
|
@@ -23,5 +24,5 @@
|
|
|
23
24
|
"@graphql-codegen/cli": "5.0.0",
|
|
24
25
|
"@graphql-codegen/client-preset": "4.1.0"
|
|
25
26
|
},
|
|
26
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "4be4ccea8e93a40760854205e53b3fbafff28d72"
|
|
27
28
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
3
|
-
import { ThemeProvider } from '@oanda/labs-widget-common';
|
|
3
|
+
import { ThemeProvider, getLocale } from '@oanda/labs-widget-common';
|
|
4
|
+
import { LocaleProvider } from '@oanda/mono-i18n';
|
|
4
5
|
import { Main } from './Main';
|
|
5
6
|
import { CurrencyPowerBalanceConfig } from './types';
|
|
7
|
+
import { translations } from '../translations';
|
|
6
8
|
|
|
7
9
|
const CurrencyPowerBalance = ({
|
|
8
|
-
graphqlUrl, theme,
|
|
10
|
+
graphqlUrl, theme, locale,
|
|
9
11
|
}: CurrencyPowerBalanceConfig) => {
|
|
10
12
|
const client = new ApolloClient({
|
|
11
13
|
uri: graphqlUrl,
|
|
@@ -14,9 +16,11 @@ const CurrencyPowerBalance = ({
|
|
|
14
16
|
|
|
15
17
|
return (
|
|
16
18
|
<ThemeProvider theme={theme}>
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
|
|
19
|
+
<LocaleProvider locale={getLocale(locale)} translations={translations}>
|
|
20
|
+
<ApolloProvider client={client}>
|
|
21
|
+
<Main />
|
|
22
|
+
</ApolloProvider>
|
|
23
|
+
</LocaleProvider>
|
|
20
24
|
</ThemeProvider>
|
|
21
25
|
);
|
|
22
26
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
+
import { useLocale } from '@oanda/mono-i18n';
|
|
2
3
|
import { timeUnitConfig } from './config';
|
|
3
4
|
import { TimeUnitSwitch } from './components/TimeUnitSwitch';
|
|
4
5
|
import { ChartWithData } from './ChartWithData';
|
|
@@ -6,16 +7,18 @@ import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
|
|
|
6
7
|
|
|
7
8
|
const Tool = () => {
|
|
8
9
|
const [selectedTimeUnit, setSelectedTimeUnit] = useState(CurrencyPowerBalanceTimeUnit.CurrentDay);
|
|
10
|
+
const { lang } = useLocale();
|
|
9
11
|
|
|
10
12
|
return (
|
|
11
13
|
<div
|
|
12
14
|
data-testid="currency-power-balance-wrapper"
|
|
13
|
-
className="lw-flex lw-flex-col lw-
|
|
15
|
+
className="lw-flex lw-flex-col lw-text-sm lw-tracking-normal"
|
|
14
16
|
>
|
|
15
17
|
<TimeUnitSwitch
|
|
16
18
|
selected={selectedTimeUnit}
|
|
17
19
|
callback={setSelectedTimeUnit}
|
|
18
20
|
options={timeUnitConfig}
|
|
21
|
+
labelCallback={lang}
|
|
19
22
|
/>
|
|
20
23
|
<ChartWithData
|
|
21
24
|
timeUnit={selectedTimeUnit}
|
|
@@ -35,7 +35,7 @@ const tooltipFormatter = (values: TooltipFormatterParams[]) => {
|
|
|
35
35
|
</div>`);
|
|
36
36
|
|
|
37
37
|
return `<div style="display:flex; flex-direction:column;">
|
|
38
|
-
<
|
|
38
|
+
<span style="margin-bottom:5px;">${date}</span>
|
|
39
39
|
${row.join('\n')}
|
|
40
40
|
</div>`;
|
|
41
41
|
};
|
|
@@ -4,10 +4,13 @@ import { TimeUnitSwitchProps } from './types';
|
|
|
4
4
|
import { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
|
|
5
5
|
|
|
6
6
|
const TimeUnitSelect = ({
|
|
7
|
-
selected, options, callback,
|
|
7
|
+
selected, options, callback, labelCallback,
|
|
8
8
|
}: TimeUnitSwitchProps) => {
|
|
9
9
|
const selectOptions = options
|
|
10
|
-
.map(({ value: id, label, tooltip }) => ({
|
|
10
|
+
.map(({ value: id, label, tooltip }) => ({
|
|
11
|
+
id,
|
|
12
|
+
label: labelCallback ? labelCallback(tooltip || label) : tooltip || label,
|
|
13
|
+
}));
|
|
11
14
|
const [{ label: selectedLabel }] = selectOptions.filter(({ id }) => id === selected);
|
|
12
15
|
|
|
13
16
|
return (
|
|
@@ -19,12 +19,12 @@ const timeUnitConfig = [
|
|
|
19
19
|
{
|
|
20
20
|
value: CurrencyPowerBalanceTimeUnit.H24,
|
|
21
21
|
label: '24h',
|
|
22
|
-
tooltip: '
|
|
22
|
+
tooltip: '24_hours',
|
|
23
23
|
},
|
|
24
24
|
{ value: CurrencyPowerBalanceTimeUnit.H8, label: '8h', tooltip: '8_hours' },
|
|
25
25
|
{ value: CurrencyPowerBalanceTimeUnit.H4, label: '4h', tooltip: '4_hours' },
|
|
26
|
-
{ value: CurrencyPowerBalanceTimeUnit.PreviousDay, label: '
|
|
27
|
-
{ value: CurrencyPowerBalanceTimeUnit.CurrentDay, label: '
|
|
26
|
+
{ value: CurrencyPowerBalanceTimeUnit.PreviousDay, label: 'previous_business_day' },
|
|
27
|
+
{ value: CurrencyPowerBalanceTimeUnit.CurrentDay, label: 'current_business_day' },
|
|
28
28
|
];
|
|
29
29
|
|
|
30
30
|
export { timeUnitConfig };
|