@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
|
@@ -6,6 +6,7 @@ import { CurrencyPowerBalance } from './CurrencyPowerBalance';
|
|
|
6
6
|
const {
|
|
7
7
|
graphqlUrl: configGraphQl,
|
|
8
8
|
renderElementId: configRenderElementId,
|
|
9
|
+
locale: configLocale,
|
|
9
10
|
} = window.currencyPowerBalanceWidgetConfig || {};
|
|
10
11
|
|
|
11
12
|
const {
|
|
@@ -16,11 +17,14 @@ const currencyPowerBalanceParamsElements = document.querySelectorAll('div[data-c
|
|
|
16
17
|
|
|
17
18
|
if (currencyPowerBalanceParamsElements.length > 0) {
|
|
18
19
|
currencyPowerBalanceParamsElements.forEach((element) => {
|
|
20
|
+
const params = element.getAttribute('data-currency-power-balance-params');
|
|
19
21
|
const mode = element.getAttribute('data-mode');
|
|
22
|
+
const { locale } = JSON.parse(params as string);
|
|
20
23
|
|
|
21
24
|
render(
|
|
22
25
|
<CurrencyPowerBalance
|
|
23
26
|
graphqlUrl={graphqlUrl}
|
|
27
|
+
locale={locale}
|
|
24
28
|
theme={mode as Theme}
|
|
25
29
|
/>,
|
|
26
30
|
element,
|
|
@@ -29,6 +33,7 @@ if (currencyPowerBalanceParamsElements.length > 0) {
|
|
|
29
33
|
} else {
|
|
30
34
|
render(
|
|
31
35
|
<CurrencyPowerBalance
|
|
36
|
+
locale={configLocale}
|
|
32
37
|
graphqlUrl={configGraphQl}
|
|
33
38
|
/>,
|
|
34
39
|
document.getElementById(configRenderElementId),
|
|
@@ -1,13 +1,16 @@
|
|
|
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
|
|
|
4
5
|
export interface CurrencyPowerBalanceConfig {
|
|
5
6
|
graphqlUrl: string;
|
|
7
|
+
locale: Locale;
|
|
6
8
|
theme?: Theme;
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export interface CurrencyPowerBalanceWrapperConfig extends CurrencyPowerBalanceConfig {
|
|
10
12
|
renderElementId: string;
|
|
13
|
+
locale: Locale;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export interface ChartWithDataProps {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Locale, Translations } from '@oanda/mono-i18n';
|
|
2
|
+
|
|
3
|
+
import en from './sources/en.json';
|
|
4
|
+
import zhTW from './sources/zh_TW.json';
|
|
5
|
+
|
|
6
|
+
import { defaultTranslations } from './translations';
|
|
7
|
+
|
|
8
|
+
export type TranslationKey = keyof typeof defaultTranslations;
|
|
9
|
+
|
|
10
|
+
export const translations: Translations = {
|
|
11
|
+
[Locale.en]: { translation: en },
|
|
12
|
+
[Locale.zhTW]: { translation: zhTW },
|
|
13
|
+
};
|
|
@@ -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,18 @@
|
|
|
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
|
+
};
|
|
@@ -20,11 +20,11 @@ describe('tooltipFormatter', () => {
|
|
|
20
20
|
const element = document.createElement('div');
|
|
21
21
|
element.innerHTML = tooltipFormatter(values);
|
|
22
22
|
|
|
23
|
-
expect(element.querySelector('
|
|
24
|
-
expect(element.querySelectorAll('span')[
|
|
25
|
-
expect(element.querySelectorAll('span')[
|
|
26
|
-
expect(element.querySelectorAll('span')[
|
|
27
|
-
expect(element.querySelectorAll('span')[
|
|
23
|
+
expect(element.querySelector('span')).toContainHTML('<span style="margin-bottom:5px;">10/27/2023, 14:00 UTC</span>');
|
|
24
|
+
expect(element.querySelectorAll('span')[1]).toContainHTML('<span>Marker 2</span>');
|
|
25
|
+
expect(element.querySelectorAll('span')[3]).toContainHTML('<span>-20.23</span>');
|
|
26
|
+
expect(element.querySelectorAll('span')[4]).toContainHTML('<span>Marker 1</span>');
|
|
27
|
+
expect(element.querySelectorAll('span')[6]).toContainHTML('<span>-30.91</span>');
|
|
28
28
|
});
|
|
29
29
|
});
|
|
30
30
|
|