@oanda/labs-currency-power-balance-widget 1.0.143 → 1.0.145

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +1164 -0
  2. package/dist/main/CurrencyPowerBalanceWidget/Main.js +4 -3
  3. package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  4. package/dist/module/CurrencyPowerBalanceWidget/Main.js +4 -3
  5. package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  6. package/package.json +3 -3
  7. package/src/CurrencyPowerBalanceWidget/Main.tsx +4 -3
  8. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +0 -60
  9. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +0 -1
  10. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +0 -58
  11. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +0 -1
  12. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js +0 -17
  13. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js.map +0 -1
  14. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js +0 -6
  15. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +0 -1
  16. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +0 -53
  17. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +0 -1
  18. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +0 -51
  19. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +0 -1
  20. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js +0 -2
  21. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.js.map +0 -1
  22. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js +0 -2
  23. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +0 -1
  24. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.d.ts +0 -4
  25. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.d.ts +0 -4
  26. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.d.ts +0 -1
  27. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.d.ts +0 -16
  28. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +0 -38
  29. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +0 -72
  30. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.ts +0 -1
  31. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts +0 -18
@@ -9,8 +9,8 @@ var _monoI18n = require("@oanda/mono-i18n");
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _graphql = require("../gql/types/graphql");
11
11
  var _ChartWithData = require("./ChartWithData");
12
- var _TimeUnitSwitch = require("./components/TimeUnitSwitch");
13
12
  var _config = require("./config");
13
+ var _constants = require("./constants");
14
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
16
  const Main = _ref => {
@@ -45,10 +45,11 @@ const Main = _ref => {
45
45
  }, tooltipLabel ? _react.default.createElement("span", null, `${lang(tooltipLabel.translationKey, {
46
46
  count: tooltipLabel.count
47
47
  })}`) : _react.default.createElement("span", null, `${lang(label)}`));
48
- })) : _react.default.createElement(_TimeUnitSwitch.TimeUnitSwitch, {
48
+ })) : _react.default.createElement(_labsWidgetCommon.TimeUnitSwitch, {
49
49
  callback: setSelectedTimeUnit,
50
50
  options: _config.timeUnitConfig,
51
- selected: selectedTimeUnit
51
+ selected: selectedTimeUnit,
52
+ tooltipId: _constants.CURRENCY_POWER_BALANCE_TOOLTIP_ID
52
53
  }), _react.default.createElement(_ChartWithData.ChartWithData, {
53
54
  currencies: timeUnit && currencies,
54
55
  timeUnit: selectedTimeUnit
@@ -1 +1 @@
1
- {"version":3,"file":"Main.js","names":["_labsWidgetCommon","require","_monoI18n","_react","_interopRequireWildcard","_graphql","_ChartWithData","_TimeUnitSwitch","_config","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","timeUnit","currencies","size","useLayoutProvider","lang","useLocale","selectedTimeUnit","setSelectedTimeUnit","useState","CurrencyPowerBalanceTimeUnit","CurrentDay","createElement","Fragment","className","timeUnitConfig","filter","_ref2","value","map","_ref3","tooltipLabel","label","key","translationKey","count","TimeUnitSwitch","callback","options","selected","ChartWithData","exports"],"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,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAA0C,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,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IAAIC,UAAW;IACnCD,QAAQ,EAAEM;EAAiB,CAC5B,CACE,CAEP,CAAC;AAEP,CAAC;AAACwB,OAAA,CAAAhC,IAAA,GAAAA,IAAA","ignoreList":[]}
1
+ {"version":3,"file":"Main.js","names":["_labsWidgetCommon","require","_monoI18n","_react","_interopRequireWildcard","_graphql","_ChartWithData","_config","_constants","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","timeUnit","currencies","size","useLayoutProvider","lang","useLocale","selectedTimeUnit","setSelectedTimeUnit","useState","CurrencyPowerBalanceTimeUnit","CurrentDay","createElement","Fragment","className","timeUnitConfig","filter","_ref2","value","map","_ref3","tooltipLabel","label","key","translationKey","count","TimeUnitSwitch","callback","options","selected","tooltipId","CURRENCY_POWER_BALANCE_TOOLTIP_ID","ChartWithData","exports"],"sources":["../../../src/CurrencyPowerBalanceWidget/Main.tsx"],"sourcesContent":["import { TimeUnitSwitch, 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 { timeUnitConfig } from './config';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';\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<CurrencyPowerBalanceTimeUnit>\n callback={setSelectedTimeUnit}\n options={timeUnitConfig}\n selected={selectedTimeUnit}\n tooltipId={CURRENCY_POWER_BALANCE_TOOLTIP_ID}\n />\n )}\n <ChartWithData\n currencies={timeUnit && currencies}\n timeUnit={selectedTimeUnit}\n />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AAAgE,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,G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,IAAC;MAAEC;IAAM,CAAC,GAAAD,KAAA;IAAA,OAAKC,KAAK,KAAKX,gBAAgB;EAAA,EAAC,CACjDY,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC,YAAY;MAAEC;IAAM,CAAC,GAAAF,KAAA;IAAA,OAC3B/C,MAAA,CAAAY,OAAA,CAAA2B,aAAA;MACEW,GAAG,EAAED,KAAM;MACXR,SAAS,EAAC,wEAAwE;MAClF,eAAY;IAAiB,GAE5BO,YAAY,GACXhD,MAAA,CAAAY,OAAA,CAAA2B,aAAA,eAAO,GAAGP,IAAI,CAACgB,YAAY,CAAEG,cAAc,EAAE;MAAEC,KAAK,EAAEJ,YAAY,CAAEI;IAAM,CAAC,CAAC,EAAS,CAAC,GAEtFpD,MAAA,CAAAY,OAAA,CAAA2B,aAAA,eAAO,GAAGP,IAAI,CAACiB,KAAK,CAAC,EAAS,CAE7B,CAAC;EAAA,CACP,CACH,CAAC,GAEHjD,MAAA,CAAAY,OAAA,CAAA2B,aAAA,CAAC1C,iBAAA,CAAAwD,cAAc;IACbC,QAAQ,EAAEnB,mBAAoB;IAC9BoB,OAAO,EAAEb,sBAAe;IACxBc,QAAQ,EAAEtB,gBAAiB;IAC3BuB,SAAS,EAAEC;EAAkC,CAC9C,CACF,EACD1D,MAAA,CAAAY,OAAA,CAAA2B,aAAA,CAACpC,cAAA,CAAAwD,aAAa;IACZ9B,UAAU,EAAED,QAAQ,IAAIC,UAAW;IACnCD,QAAQ,EAAEM;EAAiB,CAC5B,CACE,CAEP,CAAC;AAEP,CAAC;AAAC0B,OAAA,CAAAlC,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -1,10 +1,10 @@
1
- import { useLayoutProvider } from '@oanda/labs-widget-common';
1
+ import { TimeUnitSwitch, useLayoutProvider } from '@oanda/labs-widget-common';
2
2
  import { useLocale } from '@oanda/mono-i18n';
3
3
  import React, { useState } from 'react';
4
4
  import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
5
5
  import { ChartWithData } from './ChartWithData';
6
- import { TimeUnitSwitch } from './components/TimeUnitSwitch';
7
6
  import { timeUnitConfig } from './config';
7
+ import { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';
8
8
  const Main = _ref => {
9
9
  let {
10
10
  timeUnit,
@@ -40,7 +40,8 @@ const Main = _ref => {
40
40
  })) : React.createElement(TimeUnitSwitch, {
41
41
  callback: setSelectedTimeUnit,
42
42
  options: timeUnitConfig,
43
- selected: selectedTimeUnit
43
+ selected: selectedTimeUnit,
44
+ tooltipId: CURRENCY_POWER_BALANCE_TOOLTIP_ID
44
45
  }), React.createElement(ChartWithData, {
45
46
  currencies: timeUnit && currencies,
46
47
  timeUnit: selectedTimeUnit
@@ -1 +1 @@
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
+ {"version":3,"file":"Main.js","names":["TimeUnitSwitch","useLayoutProvider","useLocale","React","useState","CurrencyPowerBalanceTimeUnit","ChartWithData","timeUnitConfig","CURRENCY_POWER_BALANCE_TOOLTIP_ID","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","tooltipId"],"sources":["../../../src/CurrencyPowerBalanceWidget/Main.tsx"],"sourcesContent":["import { TimeUnitSwitch, 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 { timeUnitConfig } from './config';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';\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<CurrencyPowerBalanceTimeUnit>\n callback={setSelectedTimeUnit}\n options={timeUnitConfig}\n selected={selectedTimeUnit}\n tooltipId={CURRENCY_POWER_BALANCE_TOOLTIP_ID}\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,cAAc,EAAEC,iBAAiB,QAAQ,2BAA2B;AAC7E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,KAAK,IAAIC,QAAQ,QAAQ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ACa,KAAK,CAAC,EAAS,CAE7B,CAAC;EAAA,CACP,CACH,CAAC,GAEHxB,KAAA,CAAAe,aAAA,CAAClB,cAAc;IACb+B,QAAQ,EAAEf,mBAAoB;IAC9BgB,OAAO,EAAEzB,cAAe;IACxB0B,QAAQ,EAAElB,gBAAiB;IAC3BmB,SAAS,EAAE1B;EAAkC,CAC9C,CACF,EACDL,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":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-currency-power-balance-widget",
3
- "version": "1.0.143",
3
+ "version": "1.0.145",
4
4
  "description": "Labs Currency Power Balance Widget",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
@@ -12,7 +12,7 @@
12
12
  "author": "OANDA",
13
13
  "license": "UNLICENSED",
14
14
  "dependencies": {
15
- "@oanda/labs-widget-common": "^1.0.204",
15
+ "@oanda/labs-widget-common": "^1.0.206",
16
16
  "@oanda/mono-i18n": "10.0.1",
17
17
  "echarts": "5.5.0",
18
18
  "echarts-for-react": "3.0.2",
@@ -22,5 +22,5 @@
22
22
  "@graphql-codegen/cli": "5.0.0",
23
23
  "@graphql-codegen/client-preset": "4.1.0"
24
24
  },
25
- "gitHead": "e3e898cc881ea7c1abb62c6cde48191d4f0c385b"
25
+ "gitHead": "8e9089b3a4cc94275dd2223e7fed7aae070fe454"
26
26
  }
@@ -1,11 +1,11 @@
1
- import { useLayoutProvider } from '@oanda/labs-widget-common';
1
+ import { TimeUnitSwitch, useLayoutProvider } from '@oanda/labs-widget-common';
2
2
  import { useLocale } from '@oanda/mono-i18n';
3
3
  import React, { useState } from 'react';
4
4
 
5
5
  import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
6
6
  import { ChartWithData } from './ChartWithData';
7
- import { TimeUnitSwitch } from './components/TimeUnitSwitch';
8
7
  import { timeUnitConfig } from './config';
8
+ import { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from './constants';
9
9
  import type { MainProps } from './types';
10
10
 
11
11
  const Main = ({ timeUnit, currencies }: MainProps) => {
@@ -40,10 +40,11 @@ const Main = ({ timeUnit, currencies }: MainProps) => {
40
40
  ))}
41
41
  </>
42
42
  ) : (
43
- <TimeUnitSwitch
43
+ <TimeUnitSwitch<CurrencyPowerBalanceTimeUnit>
44
44
  callback={setSelectedTimeUnit}
45
45
  options={timeUnitConfig}
46
46
  selected={selectedTimeUnit}
47
+ tooltipId={CURRENCY_POWER_BALANCE_TOOLTIP_ID}
47
48
  />
48
49
  )}
49
50
  <ChartWithData
@@ -1,60 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TimeUnitSelect = void 0;
7
- var _labsWidgetCommon = require("@oanda/labs-widget-common");
8
- var _monoI18n = require("@oanda/mono-i18n");
9
- var _react = _interopRequireDefault(require("react"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const TimeUnitSelect = _ref => {
12
- let {
13
- selected,
14
- options,
15
- callback
16
- } = _ref;
17
- const {
18
- lang
19
- } = (0, _monoI18n.useLocale)();
20
- const selectOptions = options.map(_ref2 => {
21
- let {
22
- value: id,
23
- label,
24
- tooltipLabel
25
- } = _ref2;
26
- return {
27
- id,
28
- label: tooltipLabel ? lang(tooltipLabel.translationKey, {
29
- count: tooltipLabel.count
30
- }) : lang(label)
31
- };
32
- });
33
- const [{
34
- label: selectedLabel
35
- }] = selectOptions.filter(_ref3 => {
36
- let {
37
- id
38
- } = _ref3;
39
- return id === selected;
40
- });
41
- return _react.default.createElement("div", {
42
- className: "lw-mb-6 lw-w-full",
43
- "data-testid": "time-unit-select"
44
- }, _react.default.createElement(_labsWidgetCommon.Select, {
45
- options: selectOptions,
46
- searchPlaceholder: lang('search'),
47
- selectedOption: {
48
- id: selected,
49
- label: selectedLabel
50
- },
51
- setSelectedOption: _ref4 => {
52
- let {
53
- id
54
- } = _ref4;
55
- return callback(id);
56
- }
57
- }));
58
- };
59
- exports.TimeUnitSelect = TimeUnitSelect;
60
- //# sourceMappingURL=TimeUnitSelect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TimeUnitSelect.js","names":["_labsWidgetCommon","require","_monoI18n","_react","_interopRequireDefault","e","__esModule","default","TimeUnitSelect","_ref","selected","options","callback","lang","useLocale","selectOptions","map","_ref2","value","id","label","tooltipLabel","translationKey","count","selectedLabel","filter","_ref3","createElement","className","Select","searchPlaceholder","selectedOption","setSelectedOption","_ref4","exports"],"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,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,G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KAAA;MAAA,OACxBrB,QAAQ,CAACO,EAAkC,CAAC;IAAA;EAC7C,CACF,CACE,CAAC;AAEV,CAAC;AAACe,OAAA,CAAA1B,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TimeUnitSwitch = void 0;
7
- var _labsWidgetCommon = require("@oanda/labs-widget-common");
8
- var _monoI18n = require("@oanda/mono-i18n");
9
- var _react = _interopRequireDefault(require("react"));
10
- var _constants = require("../../constants");
11
- var _TimeUnitSelect = require("./TimeUnitSelect");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
- const TimeUnitSwitch = _ref => {
14
- let {
15
- selected,
16
- options,
17
- callback
18
- } = _ref;
19
- const {
20
- lang
21
- } = (0, _monoI18n.useLocale)();
22
- const {
23
- size
24
- } = (0, _labsWidgetCommon.useLayoutProvider)();
25
- const isDesktop = size === _labsWidgetCommon.Size.DESKTOP;
26
- const handleButtonClick = e => {
27
- callback(e.currentTarget.value);
28
- };
29
- return _react.default.createElement(_react.default.Fragment, null, isDesktop ? _react.default.createElement("div", {
30
- className: "lw-mb-6 lw-flex lw-gap-1 lw-self-end",
31
- "data-testid": "time-unit-switch"
32
- }, options.map(_ref2 => {
33
- let {
34
- value,
35
- label,
36
- tooltipLabel
37
- } = _ref2;
38
- const tooltip = tooltipLabel ? lang(tooltipLabel.translationKey, {
39
- count: tooltipLabel.count
40
- }) : tooltipLabel;
41
- const buttonLabel = lang(label);
42
- return _react.default.createElement(_labsWidgetCommon.Button, {
43
- key: value,
44
- "data-tooltip-content": tooltip,
45
- "data-tooltip-id": _constants.CURRENCY_POWER_BALANCE_TOOLTIP_ID,
46
- size: _labsWidgetCommon.ButtonSize.full,
47
- value: value,
48
- variant: selected === value ? _labsWidgetCommon.ButtonVariant.primary : _labsWidgetCommon.ButtonVariant.secondary,
49
- onClick: handleButtonClick
50
- }, buttonLabel);
51
- })) : _react.default.createElement(_TimeUnitSelect.TimeUnitSelect, {
52
- callback: callback,
53
- options: options,
54
- selected: selected
55
- }));
56
- };
57
- exports.TimeUnitSwitch = TimeUnitSwitch;
58
- //# sourceMappingURL=TimeUnitSwitch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TimeUnitSwitch.js","names":["_labsWidgetCommon","require","_monoI18n","_react","_interopRequireDefault","_constants","_TimeUnitSelect","e","__esModule","default","TimeUnitSwitch","_ref","selected","options","callback","lang","useLocale","size","useLayoutProvider","isDesktop","Size","DESKTOP","handleButtonClick","currentTarget","value","createElement","Fragment","className","map","_ref2","label","tooltipLabel","tooltip","translationKey","count","buttonLabel","Button","key","CURRENCY_POWER_BALANCE_TOOLTIP_ID","ButtonSize","full","variant","ButtonVariant","primary","secondary","onClick","TimeUnitSelect","exports"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx"],"sourcesContent":["import {\n Button,\n ButtonSize,\n ButtonVariant,\n Size,\n useLayoutProvider,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport React from 'react';\n\nimport type { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from '../../constants';\nimport { TimeUnitSelect } from './TimeUnitSelect';\nimport type { TimeUnitSwitchProps } from './types';\n\nconst TimeUnitSwitch = ({\n selected,\n options,\n callback,\n}: TimeUnitSwitchProps) => {\n const { lang } = useLocale();\n const { size } = useLayoutProvider();\n const isDesktop = size === Size.DESKTOP;\n\n const handleButtonClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {\n callback(e.currentTarget.value as CurrencyPowerBalanceTimeUnit);\n };\n\n return (\n <>\n {isDesktop ? (\n <div\n className=\"lw-mb-6 lw-flex lw-gap-1 lw-self-end\"\n data-testid=\"time-unit-switch\"\n >\n {options.map(({ value, label, tooltipLabel }) => {\n const tooltip = tooltipLabel\n ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })\n : tooltipLabel;\n const buttonLabel = lang(label);\n\n return (\n <Button\n key={value}\n data-tooltip-content={tooltip}\n data-tooltip-id={CURRENCY_POWER_BALANCE_TOOLTIP_ID}\n size={ButtonSize.full}\n value={value}\n variant={\n selected === value\n ? ButtonVariant.primary\n : ButtonVariant.secondary\n }\n onClick={handleButtonClick}\n >\n {buttonLabel}\n </Button>\n );\n })}\n </div>\n ) : (\n <TimeUnitSelect\n callback={callback}\n options={options}\n selected={selected}\n />\n )}\n </>\n );\n};\n\nexport { TimeUnitSwitch };\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAGA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AAAkD,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGlD,MAAMG,cAAc,GAAGC,IAAA,IAII;EAAA,IAJH;IACtBC,QAAQ;IACRC,OAAO;IACPC;EACmB,CAAC,GAAAH,IAAA;EACpB,MAAM;IAAEI;EAAK,CAAC,GAAG,IAAAC,mBAAS,EAAC,CAAC;EAC5B,MAAM;IAAEC;EAAK,CAAC,GAAG,IAAAC,mCAAiB,EAAC,CAAC;EACpC,MAAMC,SAAS,GAAGF,IAAI,KAAKG,sBAAI,CAACC,OAAO;EAEvC,MAAMC,iBAAiB,GAAIf,CAA0C,IAAK;IACxEO,QAAQ,CAACP,CAAC,CAACgB,aAAa,CAACC,KAAqC,CAAC;EACjE,CAAC;EAED,OACErB,MAAA,CAAAM,OAAA,CAAAgB,aAAA,CAAAtB,MAAA,CAAAM,OAAA,CAAAiB,QAAA,QACGP,SAAS,GACRhB,MAAA,CAAAM,OAAA,CAAAgB,aAAA;IACEE,SAAS,EAAC,sCAAsC;IAChD,eAAY;EAAkB,GAE7Bd,OAAO,CAACe,GAAG,CAACC,KAAA,IAAoC;IAAA,IAAnC;MAAEL,KAAK;MAAEM,KAAK;MAAEC;IAAa,CAAC,GAAAF,KAAA;IAC1C,MAAMG,OAAO,GAAGD,YAAY,GACxBhB,IAAI,CAACgB,YAAY,CAACE,cAAc,EAAE;MAAEC,KAAK,EAAEH,YAAY,CAACG;IAAM,CAAC,CAAC,GAChEH,YAAY;IAChB,MAAMI,WAAW,GAAGpB,IAAI,CAACe,KAAK,CAAC;IAE/B,OACE3B,MAAA,CAAAM,OAAA,CAAAgB,aAAA,CAACzB,iBAAA,CAAAoC,MAAM;MACLC,GAAG,EAAEb,KAAM;MACX,wBAAsBQ,OAAQ;MAC9B,mBAAiBM,4CAAkC;MACnDrB,IAAI,EAAEsB,4BAAU,CAACC,IAAK;MACtBhB,KAAK,EAAEA,KAAM;MACbiB,OAAO,EACL7B,QAAQ,KAAKY,KAAK,GACdkB,+BAAa,CAACC,OAAO,GACrBD,+BAAa,CAACE,SACnB;MACDC,OAAO,EAAEvB;IAAkB,GAE1Ba,WACK,CAAC;EAEb,CAAC,CACE,CAAC,GAENhC,MAAA,CAAAM,OAAA,CAAAgB,aAAA,CAACnB,eAAA,CAAAwC,cAAc;IACbhC,QAAQ,EAAEA,QAAS;IACnBD,OAAO,EAAEA,OAAQ;IACjBD,QAAQ,EAAEA;EAAS,CACpB,CAEH,CAAC;AAEP,CAAC;AAACmC,OAAA,CAAArC,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1,17 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _TimeUnitSwitch = require("./TimeUnitSwitch");
7
- Object.keys(_TimeUnitSwitch).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _TimeUnitSwitch[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _TimeUnitSwitch[key];
14
- }
15
- });
16
- });
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["_TimeUnitSwitch","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.ts"],"sourcesContent":["export * from './TimeUnitSwitch';\n"],"mappings":";;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,eAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,eAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,eAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -1,6 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts"],"sourcesContent":["import type { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nexport interface TimeUnitOption {\n value: CurrencyPowerBalanceTimeUnit;\n label: string;\n tooltipLabel?: TooltipLabel;\n}\n\nexport interface TimeUnitSwitchProps {\n selected: CurrencyPowerBalanceTimeUnit;\n options: TimeUnitOption[];\n callback: (value: CurrencyPowerBalanceTimeUnit) => void;\n}\n\ninterface TooltipLabel {\n translationKey: string;\n count: number;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,53 +0,0 @@
1
- import { Select } from '@oanda/labs-widget-common';
2
- import { useLocale } from '@oanda/mono-i18n';
3
- import React from 'react';
4
- const TimeUnitSelect = _ref => {
5
- let {
6
- selected,
7
- options,
8
- callback
9
- } = _ref;
10
- const {
11
- lang
12
- } = useLocale();
13
- const selectOptions = options.map(_ref2 => {
14
- let {
15
- value: id,
16
- label,
17
- tooltipLabel
18
- } = _ref2;
19
- return {
20
- id,
21
- label: tooltipLabel ? lang(tooltipLabel.translationKey, {
22
- count: tooltipLabel.count
23
- }) : lang(label)
24
- };
25
- });
26
- const [{
27
- label: selectedLabel
28
- }] = selectOptions.filter(_ref3 => {
29
- let {
30
- id
31
- } = _ref3;
32
- return id === selected;
33
- });
34
- return React.createElement("div", {
35
- className: "lw-mb-6 lw-w-full",
36
- "data-testid": "time-unit-select"
37
- }, React.createElement(Select, {
38
- options: selectOptions,
39
- searchPlaceholder: lang('search'),
40
- selectedOption: {
41
- id: selected,
42
- label: selectedLabel
43
- },
44
- setSelectedOption: _ref4 => {
45
- let {
46
- id
47
- } = _ref4;
48
- return callback(id);
49
- }
50
- }));
51
- };
52
- export { TimeUnitSelect };
53
- //# sourceMappingURL=TimeUnitSelect.js.map
@@ -1 +0,0 @@
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,CAAAmB,aAAA,CAACrB,MAAM;IACLM,OAAO,EAAEG,aAAc;IACvBc,iBAAiB,EAAEf,IAAI,CAAC,QAAQ,CAAE;IAClCgB,cAAc,EAAE;MAAEX,EAAE,EAAER,QAAQ;MAAES,KAAK,EAAEI;IAAc,CAAE;IACvDO,iBAAiB,EAAEC,KAAA;MAAA,IAAC;QAAEb;MAAG,CAAC,GAAAa,KAAA;MAAA,OACxBnB,QAAQ,CAACM,EAAkC,CAAC;IAAA;EAC7C,CACF,CACE,CAAC;AAEV,CAAC;AAED,SAASV,cAAc","ignoreList":[]}
@@ -1,51 +0,0 @@
1
- import { Button, ButtonSize, ButtonVariant, Size, useLayoutProvider } from '@oanda/labs-widget-common';
2
- import { useLocale } from '@oanda/mono-i18n';
3
- import React from 'react';
4
- import { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from '../../constants';
5
- import { TimeUnitSelect } from './TimeUnitSelect';
6
- const TimeUnitSwitch = _ref => {
7
- let {
8
- selected,
9
- options,
10
- callback
11
- } = _ref;
12
- const {
13
- lang
14
- } = useLocale();
15
- const {
16
- size
17
- } = useLayoutProvider();
18
- const isDesktop = size === Size.DESKTOP;
19
- const handleButtonClick = e => {
20
- callback(e.currentTarget.value);
21
- };
22
- return React.createElement(React.Fragment, null, isDesktop ? React.createElement("div", {
23
- className: "lw-mb-6 lw-flex lw-gap-1 lw-self-end",
24
- "data-testid": "time-unit-switch"
25
- }, options.map(_ref2 => {
26
- let {
27
- value,
28
- label,
29
- tooltipLabel
30
- } = _ref2;
31
- const tooltip = tooltipLabel ? lang(tooltipLabel.translationKey, {
32
- count: tooltipLabel.count
33
- }) : tooltipLabel;
34
- const buttonLabel = lang(label);
35
- return React.createElement(Button, {
36
- key: value,
37
- "data-tooltip-content": tooltip,
38
- "data-tooltip-id": CURRENCY_POWER_BALANCE_TOOLTIP_ID,
39
- size: ButtonSize.full,
40
- value: value,
41
- variant: selected === value ? ButtonVariant.primary : ButtonVariant.secondary,
42
- onClick: handleButtonClick
43
- }, buttonLabel);
44
- })) : React.createElement(TimeUnitSelect, {
45
- callback: callback,
46
- options: options,
47
- selected: selected
48
- }));
49
- };
50
- export { TimeUnitSwitch };
51
- //# sourceMappingURL=TimeUnitSwitch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TimeUnitSwitch.js","names":["Button","ButtonSize","ButtonVariant","Size","useLayoutProvider","useLocale","React","CURRENCY_POWER_BALANCE_TOOLTIP_ID","TimeUnitSelect","TimeUnitSwitch","_ref","selected","options","callback","lang","size","isDesktop","DESKTOP","handleButtonClick","e","currentTarget","value","createElement","Fragment","className","map","_ref2","label","tooltipLabel","tooltip","translationKey","count","buttonLabel","key","full","variant","primary","secondary","onClick"],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx"],"sourcesContent":["import {\n Button,\n ButtonSize,\n ButtonVariant,\n Size,\n useLayoutProvider,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport React from 'react';\n\nimport type { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\nimport { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from '../../constants';\nimport { TimeUnitSelect } from './TimeUnitSelect';\nimport type { TimeUnitSwitchProps } from './types';\n\nconst TimeUnitSwitch = ({\n selected,\n options,\n callback,\n}: TimeUnitSwitchProps) => {\n const { lang } = useLocale();\n const { size } = useLayoutProvider();\n const isDesktop = size === Size.DESKTOP;\n\n const handleButtonClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {\n callback(e.currentTarget.value as CurrencyPowerBalanceTimeUnit);\n };\n\n return (\n <>\n {isDesktop ? (\n <div\n className=\"lw-mb-6 lw-flex lw-gap-1 lw-self-end\"\n data-testid=\"time-unit-switch\"\n >\n {options.map(({ value, label, tooltipLabel }) => {\n const tooltip = tooltipLabel\n ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })\n : tooltipLabel;\n const buttonLabel = lang(label);\n\n return (\n <Button\n key={value}\n data-tooltip-content={tooltip}\n data-tooltip-id={CURRENCY_POWER_BALANCE_TOOLTIP_ID}\n size={ButtonSize.full}\n value={value}\n variant={\n selected === value\n ? ButtonVariant.primary\n : ButtonVariant.secondary\n }\n onClick={handleButtonClick}\n >\n {buttonLabel}\n </Button>\n );\n })}\n </div>\n ) : (\n <TimeUnitSelect\n callback={callback}\n options={options}\n selected={selected}\n />\n )}\n </>\n );\n};\n\nexport { TimeUnitSwitch };\n"],"mappings":"AAAA,SACEA,MAAM,EACNC,UAAU,EACVC,aAAa,EACbC,IAAI,EACJC,iBAAiB,QACZ,2BAA2B;AAClC,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,KAAK,MAAM,OAAO;AAGzB,SAASC,iCAAiC,QAAQ,iBAAiB;AACnE,SAASC,cAAc,QAAQ,kBAAkB;AAGjD,MAAMC,cAAc,GAAGC,IAAA,IAII;EAAA,IAJH;IACtBC,QAAQ;IACRC,OAAO;IACPC;EACmB,CAAC,GAAAH,IAAA;EACpB,MAAM;IAAEI;EAAK,CAAC,GAAGT,SAAS,CAAC,CAAC;EAC5B,MAAM;IAAEU;EAAK,CAAC,GAAGX,iBAAiB,CAAC,CAAC;EACpC,MAAMY,SAAS,GAAGD,IAAI,KAAKZ,IAAI,CAACc,OAAO;EAEvC,MAAMC,iBAAiB,GAAIC,CAA0C,IAAK;IACxEN,QAAQ,CAACM,CAAC,CAACC,aAAa,CAACC,KAAqC,CAAC;EACjE,CAAC;EAED,OACEf,KAAA,CAAAgB,aAAA,CAAAhB,KAAA,CAAAiB,QAAA,QACGP,SAAS,GACRV,KAAA,CAAAgB,aAAA;IACEE,SAAS,EAAC,sCAAsC;IAChD,eAAY;EAAkB,GAE7BZ,OAAO,CAACa,GAAG,CAACC,KAAA,IAAoC;IAAA,IAAnC;MAAEL,KAAK;MAAEM,KAAK;MAAEC;IAAa,CAAC,GAAAF,KAAA;IAC1C,MAAMG,OAAO,GAAGD,YAAY,GACxBd,IAAI,CAACc,YAAY,CAACE,cAAc,EAAE;MAAEC,KAAK,EAAEH,YAAY,CAACG;IAAM,CAAC,CAAC,GAChEH,YAAY;IAChB,MAAMI,WAAW,GAAGlB,IAAI,CAACa,KAAK,CAAC;IAE/B,OACErB,KAAA,CAAAgB,aAAA,CAACtB,MAAM;MACLiC,GAAG,EAAEZ,KAAM;MACX,wBAAsBQ,OAAQ;MAC9B,mBAAiBtB,iCAAkC;MACnDQ,IAAI,EAAEd,UAAU,CAACiC,IAAK;MACtBb,KAAK,EAAEA,KAAM;MACbc,OAAO,EACLxB,QAAQ,KAAKU,KAAK,GACdnB,aAAa,CAACkC,OAAO,GACrBlC,aAAa,CAACmC,SACnB;MACDC,OAAO,EAAEpB;IAAkB,GAE1Bc,WACK,CAAC;EAEb,CAAC,CACE,CAAC,GAEN1B,KAAA,CAAAgB,aAAA,CAACd,cAAc;IACbK,QAAQ,EAAEA,QAAS;IACnBD,OAAO,EAAEA,OAAQ;IACjBD,QAAQ,EAAEA;EAAS,CACpB,CAEH,CAAC;AAEP,CAAC;AAED,SAASF,cAAc","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export * from './TimeUnitSwitch';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/index.ts"],"sourcesContent":["export * from './TimeUnitSwitch';\n"],"mappings":"AAAA,cAAc,kBAAkB","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts"],"sourcesContent":["import type { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';\n\nexport interface TimeUnitOption {\n value: CurrencyPowerBalanceTimeUnit;\n label: string;\n tooltipLabel?: TooltipLabel;\n}\n\nexport interface TimeUnitSwitchProps {\n selected: CurrencyPowerBalanceTimeUnit;\n options: TimeUnitOption[];\n callback: (value: CurrencyPowerBalanceTimeUnit) => void;\n}\n\ninterface TooltipLabel {\n translationKey: string;\n count: number;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { TimeUnitSwitchProps } from './types';
3
- declare const TimeUnitSelect: ({ selected, options, callback, }: TimeUnitSwitchProps) => React.JSX.Element;
4
- export { TimeUnitSelect };
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { TimeUnitSwitchProps } from './types';
3
- declare const TimeUnitSwitch: ({ selected, options, callback, }: TimeUnitSwitchProps) => React.JSX.Element;
4
- export { TimeUnitSwitch };
@@ -1 +0,0 @@
1
- export * from './TimeUnitSwitch';
@@ -1,16 +0,0 @@
1
- import type { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
2
- export interface TimeUnitOption {
3
- value: CurrencyPowerBalanceTimeUnit;
4
- label: string;
5
- tooltipLabel?: TooltipLabel;
6
- }
7
- export interface TimeUnitSwitchProps {
8
- selected: CurrencyPowerBalanceTimeUnit;
9
- options: TimeUnitOption[];
10
- callback: (value: CurrencyPowerBalanceTimeUnit) => void;
11
- }
12
- interface TooltipLabel {
13
- translationKey: string;
14
- count: number;
15
- }
16
- export {};
@@ -1,38 +0,0 @@
1
- import { Select } from '@oanda/labs-widget-common';
2
- import { useLocale } from '@oanda/mono-i18n';
3
- import React from 'react';
4
-
5
- import type { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
6
- import type { TimeUnitSwitchProps } from './types';
7
-
8
- const TimeUnitSelect = ({
9
- selected,
10
- options,
11
- callback,
12
- }: TimeUnitSwitchProps) => {
13
- const { lang } = useLocale();
14
- const selectOptions = options.map(({ value: id, label, tooltipLabel }) => ({
15
- id,
16
- label: tooltipLabel
17
- ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })
18
- : lang(label),
19
- }));
20
- const [{ label: selectedLabel }] = selectOptions.filter(
21
- ({ id }) => id === selected
22
- );
23
-
24
- return (
25
- <div className="lw-mb-6 lw-w-full" data-testid="time-unit-select">
26
- <Select
27
- options={selectOptions}
28
- searchPlaceholder={lang('search')}
29
- selectedOption={{ id: selected, label: selectedLabel }}
30
- setSelectedOption={({ id }) =>
31
- callback(id as CurrencyPowerBalanceTimeUnit)
32
- }
33
- />
34
- </div>
35
- );
36
- };
37
-
38
- export { TimeUnitSelect };
@@ -1,72 +0,0 @@
1
- import {
2
- Button,
3
- ButtonSize,
4
- ButtonVariant,
5
- Size,
6
- useLayoutProvider,
7
- } from '@oanda/labs-widget-common';
8
- import { useLocale } from '@oanda/mono-i18n';
9
- import React from 'react';
10
-
11
- import type { CurrencyPowerBalanceTimeUnit } from '../../../gql/types/graphql';
12
- import { CURRENCY_POWER_BALANCE_TOOLTIP_ID } from '../../constants';
13
- import { TimeUnitSelect } from './TimeUnitSelect';
14
- import type { TimeUnitSwitchProps } from './types';
15
-
16
- const TimeUnitSwitch = ({
17
- selected,
18
- options,
19
- callback,
20
- }: TimeUnitSwitchProps) => {
21
- const { lang } = useLocale();
22
- const { size } = useLayoutProvider();
23
- const isDesktop = size === Size.DESKTOP;
24
-
25
- const handleButtonClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {
26
- callback(e.currentTarget.value as CurrencyPowerBalanceTimeUnit);
27
- };
28
-
29
- return (
30
- <>
31
- {isDesktop ? (
32
- <div
33
- className="lw-mb-6 lw-flex lw-gap-1 lw-self-end"
34
- data-testid="time-unit-switch"
35
- >
36
- {options.map(({ value, label, tooltipLabel }) => {
37
- const tooltip = tooltipLabel
38
- ? lang(tooltipLabel.translationKey, { count: tooltipLabel.count })
39
- : tooltipLabel;
40
- const buttonLabel = lang(label);
41
-
42
- return (
43
- <Button
44
- key={value}
45
- data-tooltip-content={tooltip}
46
- data-tooltip-id={CURRENCY_POWER_BALANCE_TOOLTIP_ID}
47
- size={ButtonSize.full}
48
- value={value}
49
- variant={
50
- selected === value
51
- ? ButtonVariant.primary
52
- : ButtonVariant.secondary
53
- }
54
- onClick={handleButtonClick}
55
- >
56
- {buttonLabel}
57
- </Button>
58
- );
59
- })}
60
- </div>
61
- ) : (
62
- <TimeUnitSelect
63
- callback={callback}
64
- options={options}
65
- selected={selected}
66
- />
67
- )}
68
- </>
69
- );
70
- };
71
-
72
- export { TimeUnitSwitch };
@@ -1 +0,0 @@
1
- export * from './TimeUnitSwitch';