@oanda/labs-currency-power-balance-widget 1.0.111 → 1.0.113
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 +908 -0
- package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +9 -10
- package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +14 -19
- package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/Main.js +11 -11
- package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +12 -12
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +4 -4
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +11 -12
- 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.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/constants.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/render.js +8 -8
- package/dist/main/CurrencyPowerBalanceWidget/render.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/types.js.map +1 -1
- package/dist/main/gql/types/fragment-masking.js.map +1 -1
- package/dist/main/gql/types/gql.js +1 -1
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +64 -64
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/main/gql/types/index.js.map +1 -1
- package/dist/main/translations/index.js +1 -1
- package/dist/main/translations/index.js.map +1 -1
- package/dist/main/translations/translations.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +8 -8
- package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +15 -20
- package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/Main.js +12 -12
- package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +11 -11
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +2 -2
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +2 -2
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +4 -4
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +11 -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.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/constants.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/render.js +8 -8
- package/dist/module/CurrencyPowerBalanceWidget/render.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/types.js.map +1 -1
- package/dist/module/gql/types/fragment-masking.js.map +1 -1
- package/dist/module/gql/types/gql.js +1 -1
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +64 -64
- package/dist/module/gql/types/graphql.js.map +1 -1
- package/dist/module/gql/types/index.js +2 -2
- package/dist/module/gql/types/index.js.map +1 -1
- package/dist/module/translations/index.js +1 -1
- package/dist/module/translations/index.js.map +1 -1
- package/dist/module/translations/translations.js.map +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/ChartWithData.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/CurrencyPowerBalance.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/Main.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/Chart.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/formatters.d.ts +4 -3
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +2 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/utils.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/types.d.ts +1 -1
- 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 +3 -3
- package/dist/types/CurrencyPowerBalanceWidget/types.d.ts +2 -2
- package/dist/types/gql/types/gql.d.ts +2 -2
- package/dist/types/gql/types/index.d.ts +2 -2
- package/dist/types/translations/index.d.ts +2 -2
- package/package.json +3 -3
- package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +32 -18
- package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +26 -23
- package/src/CurrencyPowerBalanceWidget/Main.tsx +20 -11
- package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +26 -21
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/constants.ts +11 -10
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +42 -22
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +59 -44
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts +7 -4
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/types.ts +1 -1
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts +10 -9
- package/src/CurrencyPowerBalanceWidget/components/Chart/types.ts +4 -1
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +21 -15
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +48 -38
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts +3 -3
- package/src/CurrencyPowerBalanceWidget/config.ts +8 -2
- package/src/CurrencyPowerBalanceWidget/constants.ts +2 -1
- package/src/CurrencyPowerBalanceWidget/render.tsx +24 -20
- package/src/CurrencyPowerBalanceWidget/types.ts +5 -3
- package/src/gql/types/fragment-masking.ts +41 -21
- package/src/gql/types/gql.ts +7 -3
- package/src/gql/types/graphql.ts +117 -44
- package/src/gql/types/index.ts +2 -2
- package/src/translations/index.ts +4 -4
- package/src/translations/translations.ts +2 -1
- package/test/Main.test.tsx +39 -25
- package/test/chartFormatters.test.ts +84 -24
- package/test/responsesMocks.ts +254 -255
- package/test/utils.test.ts +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
1
|
import { useQuery } from '@apollo/client';
|
|
2
|
+
import { ChartError, LastUpdated, Size, Spinner, SpinnerSize, Tooltip, useLayoutProvider } from '@oanda/labs-widget-common';
|
|
3
3
|
import { useLocale } from '@oanda/mono-i18n';
|
|
4
|
-
import
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';
|
|
5
6
|
import { Chart } from './components/Chart';
|
|
6
7
|
import { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';
|
|
7
|
-
import { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';
|
|
8
8
|
const ChartWithData = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
timeUnit,
|
|
@@ -12,7 +12,7 @@ const ChartWithData = _ref => {
|
|
|
12
12
|
} = _ref;
|
|
13
13
|
const {
|
|
14
14
|
size
|
|
15
|
-
} =
|
|
15
|
+
} = useLayoutProvider();
|
|
16
16
|
const isDesktop = size === Size.DESKTOP;
|
|
17
17
|
const {
|
|
18
18
|
lang
|
|
@@ -33,9 +33,9 @@ const ChartWithData = _ref => {
|
|
|
33
33
|
}, React.createElement(Spinner, {
|
|
34
34
|
size: SpinnerSize.lg
|
|
35
35
|
})), !loading && !showError && React.createElement(Chart, {
|
|
36
|
-
|
|
36
|
+
currencies: currencies,
|
|
37
37
|
timeUnit: timeUnit,
|
|
38
|
-
|
|
38
|
+
values: data?.currencyPowerBalance
|
|
39
39
|
}), !loading && showError && React.createElement("div", {
|
|
40
40
|
className: "lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
|
|
41
41
|
}, React.createElement(ChartError, null)), isDesktop && React.createElement(Tooltip, {
|
|
@@ -43,8 +43,8 @@ const ChartWithData = _ref => {
|
|
|
43
43
|
}), React.createElement("div", {
|
|
44
44
|
className: "lw-mt-2 lw-h-8"
|
|
45
45
|
}, !loading && !showError && React.createElement(LastUpdated, {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
labelCallback: lang,
|
|
47
|
+
timestamp: data?.currencyPowerBalance[0]?.updatedAt
|
|
48
48
|
})));
|
|
49
49
|
};
|
|
50
50
|
export { ChartWithData };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartWithData.js","names":["
|
|
1
|
+
{"version":3,"file":"ChartWithData.js","names":["useQuery","ChartError","LastUpdated","Size","Spinner","SpinnerSize","Tooltip","useLayoutProvider","useLocale","React","getCurrencyPowerBalance","Chart","CURRENCY_POWER_BALANCE_TOOLTIP_ID","ChartWithData","_ref","timeUnit","currencies","size","isDesktop","DESKTOP","lang","loading","data","error","variables","fetchPolicy","showError","currencyPowerBalance","length","createElement","Fragment","className","lg","values","id","labelCallback","timestamp","updatedAt"],"sources":["../../../src/CurrencyPowerBalanceWidget/ChartWithData.tsx"],"sourcesContent":["import { useQuery } from '@apollo/client';\nimport {\n ChartError,\n LastUpdated,\n Size,\n Spinner,\n SpinnerSize,\n Tooltip,\n useLayoutProvider,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport React from 'react';\n\nimport { getCurrencyPowerBalance } from '../gql/getCurrencyPowerBalance';\nimport type {\n GetCurrencyPowerBalanceQuery,\n GetCurrencyPowerBalanceQueryVariables,\n} from '../gql/types/graphql';\nimport { Chart } from './components/Chart';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';\nimport type { ChartWithDataProps } from './types';\n\nconst ChartWithData = ({ timeUnit, currencies }: ChartWithDataProps) => {\n const { size } = useLayoutProvider();\n const isDesktop = size === Size.DESKTOP;\n const { lang } = useLocale();\n const { loading, data, error } = useQuery<\n GetCurrencyPowerBalanceQuery,\n GetCurrencyPowerBalanceQueryVariables\n >(getCurrencyPowerBalance, {\n variables: {\n timeUnit,\n },\n fetchPolicy: 'cache-and-network',\n });\n\n const showError =\n data?.currencyPowerBalance?.length === 0 ||\n error ||\n (currencies && (currencies.length === 0 || currencies.length === 1));\n\n return (\n <>\n {loading && (\n <div className=\"lw-mb-[50px] lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <Spinner size={SpinnerSize.lg} />\n </div>\n )}\n {!loading && !showError && (\n <Chart\n currencies={currencies}\n timeUnit={timeUnit}\n values={data?.currencyPowerBalance!}\n />\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[375px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n {isDesktop && <Tooltip id={CURRENCY_POWER_BALANCE_TOOLTIP_ID} />}\n <div className=\"lw-mt-2 lw-h-8\">\n {!loading && !showError && (\n <LastUpdated\n labelCallback={lang}\n timestamp={data?.currencyPowerBalance![0]?.updatedAt}\n />\n )}\n </div>\n </>\n );\n};\n\nexport { ChartWithData };\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SACEC,UAAU,EACVC,WAAW,EACXC,IAAI,EACJC,OAAO,EACPC,WAAW,EACXC,OAAO,EACPC,iBAAiB,QACZ,2BAA2B;AAClC,SAASC,SAAS,QAAQ,kBAAkB;A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aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChHtB,KAAA,CAAAoB,aAAA,CAAC5B,UAAU,MAAE,CACV,CACN,EACAiB,SAAS,IAAIT,KAAA,CAAAoB,aAAA,CAACvB,OAAO;IAAC4B,EAAE,EAAEtB;EAAkC,CAAE,CAAC,EAChEH,KAAA,CAAAoB,aAAA;IAAKE,SAAS,EAAC;EAAgB,GAC5B,CAACV,OAAO,IAAI,CAACK,SAAS,IACrBjB,KAAA,CAAAoB,aAAA,CAAC3B,WAAW;IACViC,aAAa,EAAEf,IAAK;IACpBgB,SAAS,EAAEd,IAAI,EAAEK,oBAAoB,CAAE,CAAC,CAAC,EAAEU;EAAU,CACtD,CAEA,CACL,CAAC;AAEP,CAAC;AAED,SAASxB,aAAa","ignoreList":[]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
|
2
|
+
import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
|
|
1
3
|
import React from 'react';
|
|
2
|
-
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
|
3
|
-
import { ChartError, ThemeProvider, getLocale, renderComponent } from '@oanda/labs-widget-common';
|
|
4
|
-
import { LocaleProvider } from '@oanda/mono-i18n';
|
|
5
|
-
import { Main } from './Main';
|
|
6
4
|
import { translations } from '../translations';
|
|
5
|
+
import { Main } from './Main';
|
|
7
6
|
const CurrencyPowerBalance = _ref => {
|
|
8
7
|
let {
|
|
9
8
|
graphqlUrl,
|
|
@@ -18,23 +17,19 @@ const CurrencyPowerBalance = _ref => {
|
|
|
18
17
|
uri: graphqlUrl,
|
|
19
18
|
cache: new InMemoryCache()
|
|
20
19
|
});
|
|
21
|
-
return React.createElement(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
return React.createElement(WidgetProvider, {
|
|
21
|
+
client: client,
|
|
22
|
+
locale: locale,
|
|
23
|
+
theme: theme,
|
|
25
24
|
translations: translations
|
|
26
|
-
}, React.createElement(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}, React.createElement(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}),
|
|
35
|
-
logoLink,
|
|
36
|
-
linkArea: 'logo'
|
|
37
|
-
}))));
|
|
25
|
+
}, React.createElement(WidgetWrapper, {
|
|
26
|
+
isParamError: isParamError,
|
|
27
|
+
linkArea: "logo",
|
|
28
|
+
logoLink: logoLink
|
|
29
|
+
}, React.createElement(Main, {
|
|
30
|
+
currencies: currencies,
|
|
31
|
+
timeUnit: timeUnit
|
|
32
|
+
})));
|
|
38
33
|
};
|
|
39
34
|
export { CurrencyPowerBalance };
|
|
40
35
|
//# sourceMappingURL=CurrencyPowerBalance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurrencyPowerBalance.js","names":["
|
|
1
|
+
{"version":3,"file":"CurrencyPowerBalance.js","names":["ApolloClient","InMemoryCache","WidgetProvider","WidgetWrapper","React","translations","Main","CurrencyPowerBalance","_ref","graphqlUrl","theme","locale","timeUnit","currencies","isParamError","logoLink","client","uri","cache","createElement","linkArea"],"sources":["../../../src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx"],"sourcesContent":["import { ApolloClient, InMemoryCache } from '@apollo/client';\nimport { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport { translations } from '../translations';\nimport { Main } from './Main';\nimport type { CurrencyPowerBalanceConfig } from './types';\n\nconst CurrencyPowerBalance = ({\n graphqlUrl,\n theme,\n locale,\n timeUnit,\n currencies,\n isParamError,\n logoLink,\n}: CurrencyPowerBalanceConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n return (\n <WidgetProvider\n client={client}\n locale={locale}\n theme={theme}\n translations={translations}\n >\n <WidgetWrapper\n isParamError={isParamError}\n linkArea=\"logo\"\n logoLink={logoLink}\n >\n <Main currencies={currencies} timeUnit={timeUnit} />\n </WidgetWrapper>\n </WidgetProvider>\n );\n};\n\nexport { CurrencyPowerBalance };\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,aAAa,QAAQ,gBAAgB;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,2BAA2B;AACzE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,IAAI,QAAQ,QAAQ;AAG7B,MAAMC,oBAAoB,GAAGC,IAAA,IAQK;EAAA,IARJ;IAC5BC,UAAU;IACVC,KAAK;IACLC,MAAM;IACNC,QAAQ;IACRC,UAAU;IACVC,YAAY;IACZC;EAC0B,CAAC,GAAAP,IAAA;EAC3B,MAAMQ,MAAM,GAAG,IAAIhB,YAAY,CAAC;IAC9BiB,GAAG,EAAER,UAAU;IACfS,KAAK,EAAE,IAAIjB,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,OACEG,KAAA,CAAAe,aAAA,CAACjB,cAAc;IACbc,MAAM,EAAEA,MAAO;IACfL,MAAM,EAAEA,MAAO;IACfD,KAAK,EAAEA,KAAM;IACbL,YAAY,EAAEA;EAAa,GAE3BD,KAAA,CAAAe,aAAA,CAAChB,aAAa;IACZW,YAAY,EAAEA,YAAa;IAC3BM,QAAQ,EAAC,MAAM;IACfL,QAAQ,EAAEA;EAAS,GAEnBX,KAAA,CAAAe,aAAA,CAACb,IAAI;IAACO,UAAU,EAAEA,UAAW;IAACD,QAAQ,EAAEA;EAAS,CAAE,CACtC,CACD,CAAC;AAErB,CAAC;AAED,SAASL,oBAAoB","ignoreList":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ThemeContext } from '@oanda/labs-widget-common';
|
|
1
|
+
import { useLayoutProvider } from '@oanda/labs-widget-common';
|
|
3
2
|
import { useLocale } from '@oanda/mono-i18n';
|
|
3
|
+
import React, { useState } from 'react';
|
|
4
4
|
import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
|
|
5
|
+
import { ChartWithData } from './ChartWithData';
|
|
5
6
|
import { TimeUnitSwitch } from './components/TimeUnitSwitch';
|
|
6
7
|
import { timeUnitConfig } from './config';
|
|
7
|
-
import { ChartWithData } from './ChartWithData';
|
|
8
8
|
const Main = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
timeUnit,
|
|
@@ -12,14 +12,14 @@ const Main = _ref => {
|
|
|
12
12
|
} = _ref;
|
|
13
13
|
const {
|
|
14
14
|
size
|
|
15
|
-
} =
|
|
15
|
+
} = useLayoutProvider();
|
|
16
16
|
const {
|
|
17
17
|
lang
|
|
18
18
|
} = useLocale();
|
|
19
19
|
const [selectedTimeUnit, setSelectedTimeUnit] = useState(timeUnit || CurrencyPowerBalanceTimeUnit.CurrentDay);
|
|
20
20
|
return React.createElement(React.Fragment, null, size && React.createElement("div", {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
className: "lw-flex lw-flex-col lw-text-sm lw-tracking-normal",
|
|
22
|
+
"data-testid": "currency-power-balance-wrapper"
|
|
23
23
|
}, timeUnit && currencies ? React.createElement(React.Fragment, null, timeUnitConfig.filter(_ref2 => {
|
|
24
24
|
let {
|
|
25
25
|
value
|
|
@@ -31,19 +31,19 @@ const Main = _ref => {
|
|
|
31
31
|
label
|
|
32
32
|
} = _ref3;
|
|
33
33
|
return React.createElement("div", {
|
|
34
|
-
"data-testid": "time-unit-label",
|
|
35
34
|
key: label,
|
|
36
|
-
className: "lw-mb-6 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold"
|
|
35
|
+
className: "lw-mb-6 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold",
|
|
36
|
+
"data-testid": "time-unit-label"
|
|
37
37
|
}, tooltipLabel ? React.createElement("span", null, `${lang(tooltipLabel.translationKey, {
|
|
38
38
|
count: tooltipLabel.count
|
|
39
39
|
})}`) : React.createElement("span", null, `${lang(label)}`));
|
|
40
40
|
})) : React.createElement(TimeUnitSwitch, {
|
|
41
|
-
selected: selectedTimeUnit,
|
|
42
41
|
callback: setSelectedTimeUnit,
|
|
43
|
-
options: timeUnitConfig
|
|
42
|
+
options: timeUnitConfig,
|
|
43
|
+
selected: selectedTimeUnit
|
|
44
44
|
}), React.createElement(ChartWithData, {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
currencies: timeUnit && currencies,
|
|
46
|
+
timeUnit: selectedTimeUnit
|
|
47
47
|
})));
|
|
48
48
|
};
|
|
49
49
|
export { Main };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["
|
|
1
|
+
{"version":3,"file":"Main.js","names":["useLayoutProvider","useLocale","React","useState","CurrencyPowerBalanceTimeUnit","ChartWithData","TimeUnitSwitch","timeUnitConfig","Main","_ref","timeUnit","currencies","size","lang","selectedTimeUnit","setSelectedTimeUnit","CurrentDay","createElement","Fragment","className","filter","_ref2","value","map","_ref3","tooltipLabel","label","key","translationKey","count","callback","options","selected"],"sources":["../../../src/CurrencyPowerBalanceWidget/Main.tsx"],"sourcesContent":["import { useLayoutProvider } from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport React, { useState } from 'react';\n\nimport { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';\nimport { ChartWithData } from './ChartWithData';\nimport { TimeUnitSwitch } from './components/TimeUnitSwitch';\nimport { timeUnitConfig } from './config';\nimport type { MainProps } from './types';\n\nconst Main = ({ timeUnit, currencies }: MainProps) => {\n const { size } = useLayoutProvider();\n const { lang } = useLocale();\n const [selectedTimeUnit, setSelectedTimeUnit] = useState(\n timeUnit || CurrencyPowerBalanceTimeUnit.CurrentDay\n );\n return (\n <>\n {size && (\n <div\n className=\"lw-flex lw-flex-col lw-text-sm lw-tracking-normal\"\n data-testid=\"currency-power-balance-wrapper\"\n >\n {timeUnit && currencies ? (\n <>\n {timeUnitConfig\n .filter(({ value }) => value === selectedTimeUnit)\n .map(({ tooltipLabel, label }) => (\n <div\n key={label}\n className=\"lw-mb-6 lw-flex lw-justify-center lw-font-sans lw-text-lg lw-font-bold\"\n data-testid=\"time-unit-label\"\n >\n {tooltipLabel ? (\n <span>{`${lang(tooltipLabel!.translationKey, { count: tooltipLabel!.count })}`}</span>\n ) : (\n <span>{`${lang(label)}`}</span>\n )}\n </div>\n ))}\n </>\n ) : (\n <TimeUnitSwitch\n callback={setSelectedTimeUnit}\n options={timeUnitConfig}\n selected={selectedTimeUnit}\n />\n )}\n <ChartWithData\n currencies={timeUnit && currencies}\n timeUnit={selectedTimeUnit}\n />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,2BAA2B;AAC7D,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AAEvC,SAASC,4BAA4B,QAAQ,sBAAsB;AACnE,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,cAAc,QAAQ,UAAU;AAGzC,MAAMC,IAAI,GAAGC,IAAA,IAAyC;EAAA,IAAxC;IAAEC,QAAQ;IAAEC;EAAsB,CAAC,GAAAF,IAAA;EAC/C,MAAM;IAAEG;EAAK,CAAC,GAAGZ,iBAAiB,CAAC,CAAC;EACpC,MAAM;IAAEa;EAAK,CAAC,GAAGZ,SAAS,CAAC,CAAC;EAC5B,MAAM,CAACa,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGZ,QAAQ,CACtDO,QAAQ,IAAIN,4BAA4B,CAACY,UAC3C,CAAC;EACD,OACEd,KAAA,CAAAe,aAAA,CAAAf,KAAA,CAAAgB,QAAA,QACGN,IAAI,IACHV,KAAA,CAAAe,aAAA;IACEE,SAAS,EAAC,mDAAmD;IAC7D,eAAY;EAAgC,GAE3CT,QAAQ,IAAIC,UAAU,GACrBT,KAAA,CAAAe,aAAA,CAAAf,KAAA,CAAAgB,QAAA,QACGX,cAAc,CACZa,MAAM,CAACC,KAAA;IAAA,IAAC;MAAEC;IAAM,CAAC,GAAAD,KAAA;IAAA,OAAKC,KAAK,KAAKR,gBAAgB;EAAA,EAAC,CACjDS,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,YAAY;MAAEC;IAAM,CAAC,GAAAF,KAAA;IAAA,OAC3BtB,KAAA,CAAAe,aAAA;MACEU,GAAG,EAAED,KAAM;MACXP,SAAS,EAAC,wEAAwE;MAClF,eAAY;IAAiB,GAE5BM,YAAY,GACXvB,KAAA,CAAAe,aAAA,eAAO,GAAGJ,IAAI,CAACY,YAAY,CAAEG,cAAc,EAAE;MAAEC,KAAK,EAAEJ,YAAY,CAAEI;IAAM,CAAC,CAAC,EAAS,CAAC,GAEtF3B,KAAA,CAAAe,aAAA,eAAO,GAAGJ,IAAI,CAACa,KAAK,CAAC,EAAS,CAE7B,CAAC;EAAA,CACP,CACH,CAAC,GAEHxB,KAAA,CAAAe,aAAA,CAACX,cAAc;IACbwB,QAAQ,EAAEf,mBAAoB;IAC9BgB,OAAO,EAAExB,cAAe;IACxByB,QAAQ,EAAElB;EAAiB,CAC5B,CACF,EACDZ,KAAA,CAAAe,aAAA,CAACZ,aAAa;IACZM,UAAU,EAAED,QAAQ,IAAIC,UAAW;IACnCD,QAAQ,EAAEI;EAAiB,CAC5B,CACE,CAEP,CAAC;AAEP,CAAC;AAED,SAASN,IAAI","ignoreList":[]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import * as echarts from 'echarts/core';
|
|
1
|
+
import { getChartTheme, Size, Theme, useLayoutProvider } from '@oanda/labs-widget-common';
|
|
2
|
+
import { useLocale } from '@oanda/mono-i18n';
|
|
4
3
|
import { LineChart } from 'echarts/charts';
|
|
4
|
+
import { GraphicComponent, GridSimpleComponent, LegendPlainComponent, MarkLineComponent, TooltipComponent } from 'echarts/components';
|
|
5
|
+
import * as echarts from 'echarts/core';
|
|
5
6
|
import { CanvasRenderer } from 'echarts/renderers';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
7
|
+
import ReactEChartsCore from 'echarts-for-react/lib/core';
|
|
8
|
+
import React, { useEffect, useRef } from 'react';
|
|
9
|
+
import { getOption, getResponsiveOption } from './options';
|
|
9
10
|
import { CHART_HEIGHT } from './options/constants';
|
|
10
|
-
import { getResponsiveOption, getOption } from './options';
|
|
11
11
|
echarts.use([GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent, LineChart, CanvasRenderer, MarkLineComponent]);
|
|
12
12
|
echarts.registerTheme('dark_theme', getChartTheme(Theme.Dark));
|
|
13
13
|
echarts.registerTheme('light_theme', getChartTheme(Theme.Light));
|
|
@@ -23,7 +23,7 @@ const Chart = _ref => {
|
|
|
23
23
|
const {
|
|
24
24
|
isDark,
|
|
25
25
|
size
|
|
26
|
-
} =
|
|
26
|
+
} = useLayoutProvider();
|
|
27
27
|
const isDesktop = size === Size.DESKTOP;
|
|
28
28
|
const isMobile = size === Size.MOBILE;
|
|
29
29
|
const echartRef = useRef(null);
|
|
@@ -40,14 +40,14 @@ const Chart = _ref => {
|
|
|
40
40
|
}
|
|
41
41
|
}, [echartRef, isDesktop, isMobile, isDark]);
|
|
42
42
|
return React.createElement(ReactEChartsCore, {
|
|
43
|
-
echarts: echarts,
|
|
44
43
|
ref: echartRef,
|
|
45
|
-
|
|
44
|
+
echarts: echarts,
|
|
45
|
+
option: getOption(chartData, timeUnit, isDark, lang),
|
|
46
46
|
style: {
|
|
47
47
|
height: `${CHART_HEIGHT}px`,
|
|
48
48
|
width: '100%'
|
|
49
49
|
},
|
|
50
|
-
|
|
50
|
+
theme: isDark ? 'dark_theme' : 'light_theme'
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
53
|
export { Chart };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.js","names":["
|
|
1
|
+
{"version":3,"file":"Chart.js","names":["getChartTheme","Size","Theme","useLayoutProvider","useLocale","LineChart","GraphicComponent","GridSimpleComponent","LegendPlainComponent","MarkLineComponent","TooltipComponent","echarts","CanvasRenderer","ReactEChartsCore","React","useEffect","useRef","getOption","getResponsiveOption","CHART_HEIGHT","use","registerTheme","Dark","Light","Chart","_ref","values","timeUnit","currencies","lang","isDark","size","isDesktop","DESKTOP","isMobile","MOBILE","echartRef","chartData","filter","_ref2","currency","includes","current","echartInstance","getEchartsInstance","setOption","createElement","ref","option","style","height","width","theme"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx"],"sourcesContent":["import {\n getChartTheme,\n Size,\n Theme,\n useLayoutProvider,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport { LineChart } from 'echarts/charts';\nimport {\n GraphicComponent,\n GridSimpleComponent,\n LegendPlainComponent,\n MarkLineComponent,\n TooltipComponent,\n} from 'echarts/components';\nimport * as echarts from 'echarts/core';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport ReactEChartsCore from 'echarts-for-react/lib/core';\nimport React, { useEffect, useRef } from 'react';\n\nimport { getOption, getResponsiveOption } from './options';\nimport { CHART_HEIGHT } from './options/constants';\nimport type { ChartProps } from './types';\n\necharts.use([\n GridSimpleComponent,\n GraphicComponent,\n TooltipComponent,\n LegendPlainComponent,\n LineChart,\n CanvasRenderer,\n MarkLineComponent,\n]);\n\necharts.registerTheme('dark_theme', getChartTheme(Theme.Dark));\necharts.registerTheme('light_theme', getChartTheme(Theme.Light));\n\nconst Chart = ({ values, timeUnit, currencies }: ChartProps) => {\n const { lang } = useLocale();\n const { isDark, size } = useLayoutProvider();\n const isDesktop = size === Size.DESKTOP;\n const isMobile = size === Size.MOBILE;\n\n const echartRef = useRef<ReactEChartsCore | null>(null);\n\n const chartData = currencies\n ? values.filter(({ currency }) => currencies.includes(currency))\n : values;\n\n useEffect(() => {\n if (echartRef.current) {\n const echartInstance = echartRef.current.getEchartsInstance();\n\n echartInstance.setOption(\n getResponsiveOption(isDesktop, isMobile, isDark)\n );\n }\n }, [echartRef, isDesktop, isMobile, isDark]);\n\n return (\n <ReactEChartsCore\n ref={echartRef}\n echarts={echarts}\n option={getOption(chartData, timeUnit, isDark, lang)}\n style={{\n height: `${CHART_HEIGHT}px`,\n width: '100%',\n }}\n theme={isDark ? 'dark_theme' : 'light_theme'}\n />\n );\n};\n\nexport { Chart };\n"],"mappings":"AAAA,SACEA,aAAa,EACbC,IAAI,EACJC,KAAK,EACLC,iBAAiB,QACZ,2BAA2B;AAClC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SACEC,gBAAgB,EAChBC,mBAAmB,EACnBC,oBAAoB,EACpBC,iBAAiB,EACjBC,gBAAgB,QACX,oBAAoB;AAC3B,OAAO,KAAKC,OAAO,MAAM,cAAc;AACvC,SAASC,cAAc,QAAQ,mBAAmB;AAClD,OAAOC,gBAAgB,MAAM,4BAA4B;AACzD,OAAOC,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEhD,SAASC,SAAS,EAAEC,mBAAmB,QAAQ,WAAW;AAC1D,SAASC,YAAY,QAAQ,qBAAqB;AAGlDR,OAAO,CAACS,GAAG,CAAC,CACVb,mBAAmB,EACnBD,gBAAgB,EAChBI,gBAAgB,EAChBF,oBAAoB,EACpBH,SAAS,EACTO,cAAc,EACdH,iBAAiB,CAClB,CAAC;AAEFE,OAAO,CAACU,aAAa,CAAC,YAAY,EAAErB,aAAa,CAACE,KAAK,CAACoB,IAAI,CAAC,CAAC;AAC9DX,OAAO,CAACU,aAAa,CAAC,aAAa,EAAErB,aAAa,CAACE,KAAK,CAACqB,KAAK,CAAC,CAAC;AAEhE,MAAMC,KAAK,GAAGC,IAAA,IAAkD;EAAA,IAAjD;IAAEC,MAAM;IAAEC,QAAQ;IAAEC;EAAuB,CAAC,GAAAH,IAAA;EACzD,MAAM;IAAEI;EAAK,CAAC,GAAGzB,SAAS,CAAC,CAAC;EAC5B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orange,
|
|
28
28
|
LIGHT: colorPalette.bottleGreenDark
|
|
29
29
|
};
|
|
30
|
-
export {
|
|
30
|
+
export { CANDLE_MINUTE, CANDLE_NUMBER_HOUR, CHART_HEIGHT, CHART_WIDTH, COLOR_CONFIG, CURRENCIES_ORDER, LEGEND_HEIGHT, LEGEND_HEIGHT_MOBILE, TOOLTIP_LINE_COLOR_CONFIG, VERTICAL_LINE_COUNT, WEEKEND_DURATION, X_LABEL_SIZE, X_LABEL_SIZE_MOBILE, Y_LABEL_SIZE, Y_LABEL_SIZE_MOBILE };
|
|
31
31
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["colorPalette","CurrencyName","WEEKEND_DURATION","X_LABEL_SIZE","X_LABEL_SIZE_MOBILE","Y_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","CHART_WIDTH","CHART_HEIGHT","LEGEND_HEIGHT","LEGEND_HEIGHT_MOBILE","VERTICAL_LINE_COUNT","CANDLE_NUMBER_HOUR","CANDLE_MINUTE","CURRENCIES_ORDER","Usd","Eur","Gbp","Cad","Aud","Chf","Jpy","Nzd","COLOR_CONFIG","USD","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreenLight75","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\nimport { CurrencyName } from '../../../../gql/types/graphql';\n\nconst WEEKEND_DURATION = 172800000;\n\nconst X_LABEL_SIZE = 90;\nconst X_LABEL_SIZE_MOBILE = 110;\nconst Y_LABEL_SIZE_MOBILE = 35;\nconst Y_LABEL_SIZE = 45;\nconst CHART_WIDTH = 9999;\nconst CHART_HEIGHT = 425;\nconst LEGEND_HEIGHT = 50;\nconst LEGEND_HEIGHT_MOBILE = 70;\nconst VERTICAL_LINE_COUNT = 10;\nconst CANDLE_NUMBER_HOUR = 12;\nconst CANDLE_MINUTE = 5;\n\nconst CURRENCIES_ORDER: CurrencyName[] = [\n CurrencyName.Usd,\n CurrencyName.Eur,\n CurrencyName.Gbp,\n CurrencyName.Cad,\n CurrencyName.Aud,\n CurrencyName.Chf,\n CurrencyName.Jpy,\n CurrencyName.Nzd,\n];\n\nconst COLOR_CONFIG = {\n USD: colorPalette.greenLight,\n EUR: colorPalette.turquoiseLight,\n GBP: colorPalette.violetLight,\n JPY: colorPalette.raspberryLight,\n CHF: colorPalette.bottleGreenLight75,\n AUD: colorPalette.orange,\n CAD: colorPalette.midnight75Lighter,\n NZD: colorPalette.gold,\n};\n\nconst TOOLTIP_LINE_COLOR_CONFIG = {\n DARK: colorPalette.orange,\n LIGHT: colorPalette.bottleGreenDark,\n};\n\nexport {\n
|
|
1
|
+
{"version":3,"file":"constants.js","names":["colorPalette","CurrencyName","WEEKEND_DURATION","X_LABEL_SIZE","X_LABEL_SIZE_MOBILE","Y_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","CHART_WIDTH","CHART_HEIGHT","LEGEND_HEIGHT","LEGEND_HEIGHT_MOBILE","VERTICAL_LINE_COUNT","CANDLE_NUMBER_HOUR","CANDLE_MINUTE","CURRENCIES_ORDER","Usd","Eur","Gbp","Cad","Aud","Chf","Jpy","Nzd","COLOR_CONFIG","USD","greenLight","EUR","turquoiseLight","GBP","violetLight","JPY","raspberryLight","CHF","bottleGreenLight75","AUD","orange","CAD","midnight75Lighter","NZD","gold","TOOLTIP_LINE_COLOR_CONFIG","DARK","LIGHT","bottleGreenDark"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/constants.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\n\nimport { CurrencyName } from '../../../../gql/types/graphql';\n\nconst WEEKEND_DURATION = 172800000;\n\nconst X_LABEL_SIZE = 90;\nconst X_LABEL_SIZE_MOBILE = 110;\nconst Y_LABEL_SIZE_MOBILE = 35;\nconst Y_LABEL_SIZE = 45;\nconst CHART_WIDTH = 9999;\nconst CHART_HEIGHT = 425;\nconst LEGEND_HEIGHT = 50;\nconst LEGEND_HEIGHT_MOBILE = 70;\nconst VERTICAL_LINE_COUNT = 10;\nconst CANDLE_NUMBER_HOUR = 12;\nconst CANDLE_MINUTE = 5;\n\nconst CURRENCIES_ORDER: CurrencyName[] = [\n CurrencyName.Usd,\n CurrencyName.Eur,\n CurrencyName.Gbp,\n CurrencyName.Cad,\n CurrencyName.Aud,\n CurrencyName.Chf,\n CurrencyName.Jpy,\n CurrencyName.Nzd,\n];\n\nconst COLOR_CONFIG = {\n USD: colorPalette.greenLight,\n EUR: colorPalette.turquoiseLight,\n GBP: colorPalette.violetLight,\n JPY: colorPalette.raspberryLight,\n CHF: colorPalette.bottleGreenLight75,\n AUD: colorPalette.orange,\n CAD: colorPalette.midnight75Lighter,\n NZD: colorPalette.gold,\n};\n\nconst TOOLTIP_LINE_COLOR_CONFIG = {\n DARK: colorPalette.orange,\n LIGHT: colorPalette.bottleGreenDark,\n};\n\nexport {\n CANDLE_MINUTE,\n CANDLE_NUMBER_HOUR,\n CHART_HEIGHT,\n CHART_WIDTH,\n COLOR_CONFIG,\n CURRENCIES_ORDER,\n LEGEND_HEIGHT,\n LEGEND_HEIGHT_MOBILE,\n TOOLTIP_LINE_COLOR_CONFIG,\n VERTICAL_LINE_COUNT,\n WEEKEND_DURATION,\n X_LABEL_SIZE,\n X_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE,\n Y_LABEL_SIZE_MOBILE,\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AAExD,SAASC,YAAY,QAAQ,+BAA+B;AAE5D,MAAMC,gBAAgB,GAAG,SAAS;AAElC,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,mBAAmB,GAAG,GAAG;AAC/B,MAAMC,mBAAmB,GAAG,EAAE;AAC9B,MAA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5 @@
|
|
|
1
1
|
import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
|
|
2
|
-
import {
|
|
2
|
+
import { COLOR_CONFIG, CURRENCIES_ORDER, VERTICAL_LINE_COUNT } from './constants';
|
|
3
3
|
const getDateAndTime = param => {
|
|
4
4
|
const dateAndTime = param.split('T');
|
|
5
5
|
return {
|
|
@@ -76,5 +76,5 @@ const formatLegendData = values => {
|
|
|
76
76
|
}
|
|
77
77
|
}));
|
|
78
78
|
};
|
|
79
|
-
export {
|
|
79
|
+
export { formatLegendData, intervalFormatter, isMonthWeek, tooltipFormatter, xAxisLabelFormatter };
|
|
80
80
|
//# sourceMappingURL=formatters.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","names":["CurrencyPowerBalanceTimeUnit","
|
|
1
|
+
{"version":3,"file":"formatters.js","names":["CurrencyPowerBalanceTimeUnit","COLOR_CONFIG","CURRENCIES_ORDER","VERTICAL_LINE_COUNT","getDateAndTime","param","dateAndTime","split","date","time","substring","dateFormat","Date","toLocaleDateString","undefined","month","day","dateTimeFormat","_ref","year","isMonthWeek","timeUnit","M3","M1","W1","xAxisLabelFormatter","label","isDateFormat","intervalFormatter","dataLength","Math","round","tooltipFormatter","values","value","row","sort","_ref2","_ref3","valueA","valueB","Number","map","_ref4","marker","seriesName","join","formatLegendData","dataCurrencies","_ref5","currency","list","length","filter","includes","name","itemStyle","color"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts"],"sourcesContent":["import type { CurrencyPowerBalance } from '../../../../gql/types/graphql';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport {\n COLOR_CONFIG,\n CURRENCIES_ORDER,\n VERTICAL_LINE_COUNT,\n} from './constants';\nimport type { 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) =>\n `${new Date(date).toLocaleDateString(undefined, { month: 'numeric', day: 'numeric' })}`;\n\nconst dateTimeFormat = ({ date, time }: { date: string; time: string }) =>\n `${new Date(date).toLocaleDateString(undefined, { year: 'numeric', month: 'numeric', day: 'numeric' })}, ${time} UTC`;\n\nconst isMonthWeek = (timeUnit: CurrencyPowerBalanceTimeUnit) =>\n timeUnit === CurrencyPowerBalanceTimeUnit.M3 ||\n timeUnit === CurrencyPowerBalanceTimeUnit.M1 ||\n timeUnit === CurrencyPowerBalanceTimeUnit.W1;\n\nconst xAxisLabelFormatter = (\n label: string,\n timeUnit: CurrencyPowerBalanceTimeUnit\n) => {\n const { date, time } = getDateAndTime(label);\n const isDateFormat = isMonthWeek(timeUnit) || time === '00:00';\n\n return isDateFormat ? dateFormat(date) : time;\n};\n\nconst intervalFormatter = (dataLength: number) =>\n Math.round(dataLength / VERTICAL_LINE_COUNT);\n\nconst tooltipFormatter = (values: TooltipFormatterParams[]) => {\n const date = dateTimeFormat(getDateAndTime(values[0].value[0]));\n\n const row = values\n .sort(\n ({ value: valueA }, { value: valueB }) =>\n Number(valueB[1]) - Number(valueA[1])\n )\n .map(\n ({\n marker,\n seriesName,\n value,\n }) => `<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\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\nconst formatLegendData = (values: CurrencyPowerBalance[]) => {\n const dataCurrencies = values.map(({ currency }) => currency);\n\n const list =\n dataCurrencies.length === CURRENCIES_ORDER.length\n ? CURRENCIES_ORDER\n : CURRENCIES_ORDER.filter((currency) =>\n dataCurrencies.includes(currency)\n );\n\n return list.map((currency) => ({\n name: currency,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n }));\n};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C;EAE7D,MAAMC,IAAI,GACRH,cAAc,CAACI,MAAM,KAAKlD,gBAAgB,CAACkD,MAAM,GAC7ClD,gBAAgB,GAChBA,gBAAgB,CAACmD,MAAM,CAAEH,QAAQ,IAC/BF,cAAc,CAACM,QAAQ,CAACJ,QAAQ,CAClC,CAAC;EAEP,OAAOC,IAAI,CAACT,GAAG,CAAEQ,QAAQ,KAAM;IAC7BK,IAAI,EAAEL,QAAQ;IACdM,SAAS,EAAE;MACTC,KAAK,EAAExD,YAAY,CAACiD,QAAQ;IAC9B;EACF,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SACEH,gBAAgB,EAChBnB,iBAAiB,EACjBR,WAAW,EACXY,gBAAgB,EAChBP,mBAAmB","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { darkTheme, lightTheme } from '@oanda/labs-widget-common';
|
|
2
|
-
import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';
|
|
3
|
-
import { intervalFormatter, tooltipFormatter, xAxisLabelFormatter, formatLegendData } from './formatters';
|
|
4
2
|
import { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';
|
|
3
|
+
import { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';
|
|
4
|
+
import { formatLegendData, intervalFormatter, tooltipFormatter, xAxisLabelFormatter } from './formatters';
|
|
5
5
|
import { findLastIndexesBeforeWeekend } from './utils';
|
|
6
6
|
const getOption = (chartData, timeUnit, isDark, lang) => {
|
|
7
7
|
const currentTheme = isDark ? darkTheme : lightTheme;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOption.js","names":["darkTheme","lightTheme","
|
|
1
|
+
{"version":3,"file":"getOption.js","names":["darkTheme","lightTheme","CurrencyPowerBalanceTimeUnit","COLOR_CONFIG","TOOLTIP_LINE_COLOR_CONFIG","formatLegendData","intervalFormatter","tooltipFormatter","xAxisLabelFormatter","findLastIndexesBeforeWeekend","getOption","chartData","timeUnit","isDark","lang","currentTheme","dataTimestamps","power","map","x","Date","point","getTime","weekendsIndexes","disableWeekendsIndicator","CurrentDay","PreviousDay","M3","includes","length","weekendsMarks","item","xAxis","label","formatter","seriesData","_ref","index","currency","name","type","symbol","showSymbol","itemStyle","color","data","_ref2","price","markLine","show","position","align","distance","padding","fontSize","shadowBlur","shadowOffsetX","shadowOffsetY","borderWidth","textPrimary","shadowColor","borderRadius","backgroundColor","borderPrimary","backgroundSecondary","emphasis","lineStyle","width","opacity","undefined","legendData","animation","legend","bottom","icon","tooltip","trigger","axisPointer","axis","z","DARK","LIGHT","extraCssText","axisTick","axisLine","splitLine","axisLabel","margin","rotate","interval","yAxis","splitNumber","boundaryGap","showMaxLabel","showMinLabel","series"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts"],"sourcesContent":["import { darkTheme, lightTheme } from '@oanda/labs-widget-common';\n\nimport type { CurrencyPowerBalance } from '../../../../gql/types/graphql';\nimport { CurrencyPowerBalanceTimeUnit } from '../../../../gql/types/graphql';\nimport { COLOR_CONFIG, TOOLTIP_LINE_COLOR_CONFIG } from './constants';\nimport {\n formatLegendData,\n intervalFormatter,\n tooltipFormatter,\n xAxisLabelFormatter,\n} from './formatters';\nimport { findLastIndexesBeforeWeekend } from './utils';\n\nconst getOption = (\n chartData: CurrencyPowerBalance[],\n timeUnit: CurrencyPowerBalanceTimeUnit,\n isDark: boolean,\n lang: (key: string) => string\n) => {\n const currentTheme = isDark ? darkTheme : lightTheme;\n const dataTimestamps = chartData[0].power.map((x) =>\n new Date(x.point).getTime()\n );\n const weekendsIndexes = findLastIndexesBeforeWeekend(dataTimestamps);\n const disableWeekendsIndicator =\n [\n CurrencyPowerBalanceTimeUnit.CurrentDay,\n CurrencyPowerBalanceTimeUnit.PreviousDay,\n CurrencyPowerBalanceTimeUnit.M3,\n ].includes(timeUnit) || weekendsIndexes.length === 0;\n\n const weekendsMarks = weekendsIndexes.map((item) => ({\n xAxis: item,\n label: {\n formatter: () => lang('market_closed'),\n },\n }));\n\n const seriesData = chartData.map(({ currency, power }, index) => ({\n name: currency,\n type: 'line',\n symbol: 'circle',\n showSymbol: false,\n itemStyle: {\n color: COLOR_CONFIG[currency],\n },\n data: power.map(({ point, price }) => [point, price]),\n markLine:\n index === chartData.length - 1 && !disableWeekendsIndicator\n ? {\n label: {\n show: false,\n position: 'end',\n align: 'center',\n distance: -32,\n padding: [8, 8],\n fontSize: 12,\n shadowBlur: 24,\n shadowOffsetX: 0,\n shadowOffsetY: 6,\n borderWidth: 0,\n color: currentTheme.textPrimary,\n shadowColor: 'rgba(0,0,0,0.1)',\n borderRadius: 4,\n backgroundColor: isDark\n ? currentTheme.borderPrimary\n : currentTheme.backgroundSecondary,\n },\n show: false,\n emphasis: {\n label: {\n show: true,\n },\n lineStyle: {\n width: 1,\n opacity: 0,\n color: currentTheme.borderPrimary,\n },\n },\n symbol: ['none', 'none'],\n itemStyle: {\n color: currentTheme.borderPrimary,\n },\n data: weekendsMarks,\n }\n : undefined,\n }));\n\n const legendData = formatLegendData(chartData);\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\n ? TOOLTIP_LINE_COLOR_CONFIG.DARK\n : 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 padding: [0, 0, 0, 4],\n align: 'left',\n margin: 10,\n rotate: -45,\n interval: intervalFormatter(seriesData[0].data.length),\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,SAAS,EAAEC,UAAU,QAAQ,2BAA2B;AAGjE,SAASC,4BAA4B,QAAQ,+BAA+B;AAC5E,SAASC,YAAY,EAAEC,yBAAyB,QAAQ,aAAa;AACrE,SACEC,gBAAgB,EAChBC,iBAAiB,EACjBC,gBAAgB,EAChBC,mBAAmB,QACd,cAAc;AACrB,SAASC,4BAA4B,QAAQ,SAAS;AAEtD,MAAMC,SAAS,GAAGA,CAChBC,SAAiC,EACjCC,QAAsC,EACtCC,MAAe,EACfC,IAA6B,KAC1B;EACH,MAAMC,YAAY,GAAGF,MAAM,GAAGb,SAAS,GAAGC,UAAU;EACpD,MAAMe,cAAc,GAAGL,SAAS,CAAC,CAAC,CAAC,CAACM,KAAK,CAACC,GAAG,CAAEC,CAAC,IAC9C,IAAIC,IAAI,CAACD,CAAC,CAACE,KAAK,CAAC,CAACC,OAAO,CAAC,CAC5B,CAAC;EACD,MAAMC,eAAe,GAAGd,4BAA4B,CAACO,cAAc,CAAC;EACpE,MAAMQ,wBAAwB,GAC5B,CACEtB,4BAA4B,CAACuB,UAAU,EACvCvB,4BAA4B,CAACwB,WAAW,EACxCxB,4BAA4B,CAACyB,EAAE,CAChC,CAACC,QAAQ,CAAChB,QAAQ,CAAC,IAAIW,eAAe,CAACM,MAAM,KAAK,CAAC;EAEtD,MAAMC,aAAa,GAAGP,eAAe,CAACL,GAAG,CAAEa,IAAI,KAAM;IACnDC,KAAK,EAAED,IAAI;IACXE,KAAK,EAAE;MACLC,SAAS,EAAEA,CAAA,KAAMpB,IAAI,CAAC,eAAe;IACvC;EACF,CAAC,CAAC,CAAC;EAEH,MAAMqB,UAAU,GAAGxB,SAAS,CAACO,GAAG,CAAC,CAAAkB,IAAA,EAAsBC,KAAK;IAAA,IAA1B;MAAEC,QAAQ;MAAErB;IAAM,CAAC,GAAAmB,IAAA;I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AQ,EAAE;QAAEnC,IAAI,EAAE;MAAM,CAAC;MACzBkC,QAAQ,EAAE;QAAElC,IAAI,EAAE;MAAM,CAAC;MACzB2C,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;MAC3BN,SAAS,EAAE;QACTO,YAAY,EAAE,KAAK;QACnBC,YAAY,EAAE;MAChB;IACF,CAAC;IACDC,MAAM,EAAE5D;EACV,CAAC;AACH,CAAC;AAED,SAASzB,SAAS","ignoreList":[]}
|
package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getResponsiveOption.js","names":["getGridLines","CHART_HEIGHT","CHART_WIDTH","LEGEND_HEIGHT","LEGEND_HEIGHT_MOBILE","X_LABEL_SIZE","X_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","Y_LABEL_SIZE_MOBILE","getResponsiveOption","isDesktop","isMobile","isDark","baseGridLines","chartWidth","chartHeight","xLabelsSize","yLabelSize","bottomLeftBox","marginBottom","yAxis","axisLabel","margin","grid","name","top","left","right","bottom","graphic"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts"],"sourcesContent":["import { getGridLines } from '@oanda/labs-widget-common';\nimport {\n CHART_HEIGHT,\n CHART_WIDTH,\n LEGEND_HEIGHT,\n LEGEND_HEIGHT_MOBILE,\n X_LABEL_SIZE,\n X_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE,\n Y_LABEL_SIZE_MOBILE,\n} from './constants';\n\nconst getResponsiveOption = (isDesktop: boolean
|
|
1
|
+
{"version":3,"file":"getResponsiveOption.js","names":["getGridLines","CHART_HEIGHT","CHART_WIDTH","LEGEND_HEIGHT","LEGEND_HEIGHT_MOBILE","X_LABEL_SIZE","X_LABEL_SIZE_MOBILE","Y_LABEL_SIZE","Y_LABEL_SIZE_MOBILE","getResponsiveOption","isDesktop","isMobile","isDark","baseGridLines","chartWidth","chartHeight","xLabelsSize","yLabelSize","bottomLeftBox","marginBottom","yAxis","axisLabel","margin","grid","name","top","left","right","bottom","graphic"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts"],"sourcesContent":["import { getGridLines } from '@oanda/labs-widget-common';\n\nimport {\n CHART_HEIGHT,\n CHART_WIDTH,\n LEGEND_HEIGHT,\n LEGEND_HEIGHT_MOBILE,\n X_LABEL_SIZE,\n X_LABEL_SIZE_MOBILE,\n Y_LABEL_SIZE,\n Y_LABEL_SIZE_MOBILE,\n} from './constants';\n\nconst getResponsiveOption = (\n isDesktop: boolean,\n isMobile: boolean,\n isDark: boolean\n) => {\n const baseGridLines = getGridLines({\n isDark,\n chartWidth: CHART_WIDTH,\n chartHeight: CHART_HEIGHT,\n xLabelsSize: isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE,\n yLabelSize: isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE,\n bottomLeftBox: false,\n marginBottom: isMobile ? LEGEND_HEIGHT_MOBILE : LEGEND_HEIGHT,\n });\n\n return {\n yAxis: {\n axisLabel: {\n margin: isDesktop ? 8 : 6,\n },\n },\n grid: [\n {\n name: 'main-grid',\n top: '0px',\n left: '0px',\n right: `${isMobile ? Y_LABEL_SIZE_MOBILE : Y_LABEL_SIZE}px`,\n bottom: `${isMobile ? X_LABEL_SIZE_MOBILE : X_LABEL_SIZE}px`,\n },\n ],\n graphic: [...baseGridLines],\n };\n};\n\nexport { getResponsiveOption };\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AAExD,SACEC,YAAY,EACZC,WAAW,EACXC,aAAa,EACbC,oBAAoB,EACpBC,YAAY,EACZC,mBAAmB,EACnBC,YAAY,EACZC,mBAAmB,QACd,aAAa;AAEpB,MAAMC,mBAAmB,GAAGA,CAC1BC,SAAkB,EAClBC,QAAiB,EACjBC,MAAe,KACZ;EACH,MAAMC,aAAa,GAAGb,YAAY,CAAC;IACjCY,MAAM;IACNE,UAAU,EAAEZ,WAAW;IACvBa,WAAW,EAAEd,YAAY;IACzBe,WAAW,EAAEL,QAAQ,GAAGL,mBAAmB,GAAGD,YAAY;IAC1DY,UAAU,EAAEN,QAAQ,GAAGH,mBAAmB,GAAGD,YAAY;IACzDW,aAAa,EAAE,KAAK;IACpBC,YAAY,EAAER,QAAQ,GAAGP,oBAAoB,GAAGD;EAClD,CAAC,CAAC;EAEF,OAAO;IACLiB,KAAK,EAAE;MACLC,SAAS,EAAE;QACTC,MAAM,EAAEZ,SAAS,GAAG,CAAC,GAAG;MAC1B;IACF,CAAC;IACDa,IAAI,EAAE,CACJ;MACEC,IAAI,EAAE,WAAW;MACjBC,GAAG,EAAE,KAAK;MACVC,IAAI,EAAE,KAAK;MACXC,KAAK,EAAE,GAAGhB,QAAQ,GAAGH,mBAAmB,GAAGD,YAAY,IAAI;MAC3DqB,MAAM,EAAE,GAAGjB,QAAQ,GAAGL,mBAAmB,GAAGD,YAAY;IAC1D,CAAC,CACF;IACDwB,OAAO,EAAE,CAAC,GAAGhB,aAAa;EAC5B,CAAC;AACH,CAAC;AAED,SAASJ,mBAAmB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/types.ts"],"sourcesContent":["export interface TooltipFormatterParams {\n marker: string;\n seriesName: string;\n value: string[]
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/types.ts"],"sourcesContent":["export interface TooltipFormatterParams {\n marker: string;\n seriesName: string;\n value: string[];\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["WEEKEND_DURATION","findLastIndexesBeforeWeekend","timestamps","reduce","acc","timestamp","index","length"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts"],"sourcesContent":["import { WEEKEND_DURATION } from './constants';\n\nconst findLastIndexesBeforeWeekend = (timestamps: number[])
|
|
1
|
+
{"version":3,"file":"utils.js","names":["WEEKEND_DURATION","findLastIndexesBeforeWeekend","timestamps","reduce","acc","timestamp","index","length"],"sources":["../../../../../../src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts"],"sourcesContent":["import { WEEKEND_DURATION } from './constants';\n\nconst findLastIndexesBeforeWeekend = (timestamps: number[]) =>\n timestamps.reduce(\n (acc, timestamp, index) =>\n timestamps.length - 1 !== index &&\n timestamps[index + 1] - timestamp >= WEEKEND_DURATION\n ? [...acc, index]\n : acc,\n [] as number[]\n );\n\nexport { findLastIndexesBeforeWeekend };\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,aAAa;AAE9C,MAAMC,4BAA4B,GAAIC,UAAoB,IACxDA,UAAU,CAACC,MAAM,CACf,CAACC,GAAG,EAAEC,SAAS,EAAEC,KAAK,KACpBJ,UAAU,CAACK,MAAM,GAAG,CAAC,KAAKD,KAAK,IAC/BJ,UAAU,CAACI,KAAK,GAAG,CAAC,CAAC,GAAGD,SAAS,IAAIL,gBAAgB,GACjD,CAAC,GAAGI,GAAG,EAAEE,KAAK,CAAC,GACfF,GAAG,EACT,EACF,CAAC;AAEH,SAASH,4BAA4B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/types.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/Chart/types.ts"],"sourcesContent":["import type {\n CurrencyPowerBalance,\n CurrencyPowerBalanceTimeUnit,\n} from '../../../gql/types/graphql';\n\nexport interface ChartProps {\n values: CurrencyPowerBalance[];\n timeUnit: CurrencyPowerBalanceTimeUnit;\n currencies?: string[];\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { Select } from '@oanda/labs-widget-common';
|
|
3
2
|
import { useLocale } from '@oanda/mono-i18n';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
const TimeUnitSelect = _ref => {
|
|
5
5
|
let {
|
|
6
6
|
selected,
|
|
@@ -32,11 +32,11 @@ const TimeUnitSelect = _ref => {
|
|
|
32
32
|
return id === selected;
|
|
33
33
|
});
|
|
34
34
|
return React.createElement("div", {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
className: "lw-mb-6 lw-w-full",
|
|
36
|
+
"data-testid": "time-unit-select"
|
|
37
37
|
}, React.createElement(Select, {
|
|
38
|
-
searchPlaceholder: lang('search'),
|
|
39
38
|
options: selectOptions,
|
|
39
|
+
searchPlaceholder: lang('search'),
|
|
40
40
|
selectedOption: {
|
|
41
41
|
id: selected,
|
|
42
42
|
label: selectedLabel
|
package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeUnitSelect.js","names":["
|
|
1
|
+
{"version":3,"file":"TimeUnitSelect.js","names":["Select","useLocale","React","TimeUnitSelect","_ref","selected","options","callback","lang","selectOptions","map","_ref2","value","id","label","tooltipLabel","translationKey","count","selectedLabel","filter","_ref3","createElement","className","searchPlaceholder","selectedOption","setSelectedOption","_ref4"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx"],"sourcesContent":["import { Select } from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport React from 'react';\n\nimport type { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\nimport type { TimeUnitSwitchProps } from './types';\n\nconst TimeUnitSelect = ({\n selected,\n options,\n callback,\n}: TimeUnitSwitchProps) => {\n const { lang } = useLocale();\n const selectOptions = options.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(\n ({ id }) => id === selected\n );\n\n return (\n <div className=\"lw-mb-6 lw-w-full\" data-testid=\"time-unit-select\">\n <Select\n options={selectOptions}\n searchPlaceholder={lang('search')}\n selectedOption={{ id: selected, label: selectedLabel }}\n setSelectedOption={({ id }) =>\n callback(id as CurrencyPowerBalanceTimeUnit)\n }\n />\n </div>\n );\n};\n\nexport { TimeUnitSelect };\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,2BAA2B;AAClD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,KAAK,MAAM,OAAO;AAKzB,MAAMC,cAAc,GAAGC,IAAA,IAII;EAAA,IAJH;IACtBC,QAAQ;IACRC,OAAO;IACPC;EACmB,CAAC,GAAAH,IAAA;EACpB,MAAM;IAAEI;EAAK,CAAC,GAAGP,SAAS,CAAC,CAAC;EAC5B,MAAMQ,aAAa,GAAGH,OAAO,CAACI,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,KAAK,EAAEC,EAAE;MAAEC,KAAK;MAAEC;IAAa,CAAC,GAAAJ,KAAA;IAAA,OAAM;MACzEE,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;EACH,MAAM,CAAC;IAAEA,KAAK,EAAEI;EAAc,CAAC,CAAC,GAAGT,aAAa,CAACU,MAAM,CACrDC,KAAA;IAAA,IAAC;MAAEP;IAAG,CAAC,GAAAO,KAAA;IAAA,OAAKP,EAAE,KAAKR,QAAQ;EAAA,CAC7B,CAAC;EAED,OACEH,KAAA,CAAAmB,aAAA;IAAKC,SAAS,EAAC,mBAAmB;IAAC,eAAY;EAAkB,GAC/DpB,KAAA,CAA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