@oanda/labs-spread-cost-calculator-widget 1.0.85 → 1.0.86

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 (40) hide show
  1. package/CHANGELOG.md +552 -7838
  2. package/dist/module/SpreadCostCalculatorWidget/Main.js +33 -26
  3. package/dist/module/SpreadCostCalculatorWidget/Main.js.map +1 -1
  4. package/dist/module/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js +22 -15
  5. package/dist/module/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.js.map +1 -1
  6. package/dist/module/SpreadCostCalculatorWidget/ValidationWrapper.js +17 -10
  7. package/dist/module/SpreadCostCalculatorWidget/ValidationWrapper.js.map +1 -1
  8. package/dist/module/SpreadCostCalculatorWidget/constant.js +8 -2
  9. package/dist/module/SpreadCostCalculatorWidget/constant.js.map +1 -1
  10. package/dist/module/SpreadCostCalculatorWidget/index.js +27 -2
  11. package/dist/module/SpreadCostCalculatorWidget/index.js.map +1 -1
  12. package/dist/module/SpreadCostCalculatorWidget/render.js +11 -8
  13. package/dist/module/SpreadCostCalculatorWidget/render.js.map +1 -1
  14. package/dist/module/SpreadCostCalculatorWidget/types.js +12 -1
  15. package/dist/module/SpreadCostCalculatorWidget/types.js.map +1 -1
  16. package/dist/module/SpreadCostCalculatorWidget/useCalculateSpread.js +16 -9
  17. package/dist/module/SpreadCostCalculatorWidget/useCalculateSpread.js.map +1 -1
  18. package/dist/module/SpreadCostCalculatorWidget/useInstrumentChange.js +21 -14
  19. package/dist/module/SpreadCostCalculatorWidget/useInstrumentChange.js.map +1 -1
  20. package/dist/module/SpreadCostCalculatorWidget/utils.js +9 -2
  21. package/dist/module/SpreadCostCalculatorWidget/utils.js.map +1 -1
  22. package/dist/module/gql/types/fragment-masking.js +11 -3
  23. package/dist/module/gql/types/fragment-masking.js.map +1 -1
  24. package/dist/module/gql/types/gql.js +9 -2
  25. package/dist/module/gql/types/gql.js.map +1 -1
  26. package/dist/module/gql/types/graphql.js +21 -15
  27. package/dist/module/gql/types/graphql.js.map +1 -1
  28. package/dist/module/gql/types/index.js +27 -2
  29. package/dist/module/gql/types/index.js.map +1 -1
  30. package/dist/module/gql/validateInstruments.js +8 -2
  31. package/dist/module/gql/validateInstruments.js.map +1 -1
  32. package/dist/module/index.js +27 -2
  33. package/dist/module/index.js.map +1 -1
  34. package/dist/module/translations/index.js +21 -14
  35. package/dist/module/translations/index.js.map +1 -1
  36. package/dist/module/translations/translations.js +7 -1
  37. package/dist/module/translations/translations.js.map +1 -1
  38. package/dist/types/gql/validateInstruments.d.ts +1 -1
  39. package/package.json +8 -4
  40. package/tsconfig.types.json +2 -4
@@ -1,16 +1,23 @@
1
- import { ChartError, cn, Label, NumberInput, Select, Size, useLayoutProvider, useNumberFormat } from '@oanda/labs-widget-common';
2
- import { useLocale } from '@oanda/mono-i18n';
3
- import React, { useEffect } from 'react';
4
- import { useCalculateSpread } from './useCalculateSpread';
5
- import { useInstrumentChange } from './useInstrumentChange';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Main = void 0;
7
+ var _labsWidgetCommon = require("@oanda/labs-widget-common");
8
+ var _monoI18n = require("@oanda/mono-i18n");
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _useCalculateSpread = require("./useCalculateSpread");
11
+ var _useInstrumentChange = require("./useInstrumentChange");
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
6
13
  const Main = _ref => {
7
14
  let {
8
15
  instruments
9
16
  } = _ref;
10
17
  const {
11
18
  size
12
- } = useLayoutProvider();
13
- const isDesktop = size === Size.DESKTOP;
19
+ } = (0, _labsWidgetCommon.useLayoutProvider)();
20
+ const isDesktop = size === _labsWidgetCommon.Size.DESKTOP;
14
21
  const selectOptions = instruments.map(instrument => ({
15
22
  id: instrument.name,
16
23
  label: instrument.displayName
@@ -20,13 +27,13 @@ const Main = _ref => {
20
27
  handleValueChange: onUnitChange,
21
28
  increment: incrementTradedUnits,
22
29
  decrement: decrementTradedUnits
23
- } = useNumberFormat({});
30
+ } = (0, _labsWidgetCommon.useNumberFormat)({});
24
31
  const {
25
32
  value: spread,
26
33
  handleValueChange: onSpreadChange,
27
34
  increment: incrementSpread,
28
35
  decrement: decrementSpread
29
- } = useNumberFormat({
36
+ } = (0, _labsWidgetCommon.useNumberFormat)({
30
37
  step: 0.1
31
38
  });
32
39
  const {
@@ -37,13 +44,13 @@ const Main = _ref => {
37
44
  loading,
38
45
  error,
39
46
  currency
40
- } = useInstrumentChange({
47
+ } = (0, _useInstrumentChange.useInstrumentChange)({
41
48
  initialInstrument: {
42
49
  id: instruments[0].name,
43
50
  label: instruments[0].displayName
44
51
  }
45
52
  });
46
- useEffect(() => {
53
+ (0, _react.useEffect)(() => {
47
54
  onSpreadChange({
48
55
  floatValue: initialSpread,
49
56
  formattedValue: initialSpread?.toString() || '',
@@ -52,35 +59,35 @@ const Main = _ref => {
52
59
  }, [initialSpread]);
53
60
  const {
54
61
  lang
55
- } = useLocale();
56
- const spreadCost = useCalculateSpread({
62
+ } = (0, _monoI18n.useLocale)();
63
+ const spreadCost = (0, _useCalculateSpread.useCalculateSpread)({
57
64
  spread,
58
65
  unitsTraded,
59
66
  pipLocation,
60
67
  currency
61
68
  });
62
- return React.createElement(React.Fragment, null, error ? React.createElement("div", {
69
+ return _react.default.createElement(_react.default.Fragment, null, error ? _react.default.createElement("div", {
63
70
  className: "lw-flex lw-h-[300px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
64
- }, React.createElement(ChartError, null)) : React.createElement("div", {
71
+ }, _react.default.createElement(_labsWidgetCommon.ChartError, null)) : _react.default.createElement("div", {
65
72
  className: "lw-mx-auto lw-flex lw-w-full lw-max-w-full lw-flex-col lw-content-center lw-justify-center lw-gap-8 lw-p-4",
66
73
  "data-testid": "spread-cost-calculator"
67
- }, React.createElement("div", {
74
+ }, _react.default.createElement("div", {
68
75
  className: "lw-flex lw-flex-col lw-gap-2"
69
- }, React.createElement(Label, {
76
+ }, _react.default.createElement(_labsWidgetCommon.Label, {
70
77
  className: "lw-text-text-primary",
71
78
  htmlFor: lang('instrument')
72
- }, lang('instrument')), React.createElement(Select, {
79
+ }, lang('instrument')), _react.default.createElement(_labsWidgetCommon.Select, {
73
80
  className: "lw-grow-0",
74
81
  maxHeight: isDesktop ? 190 : 220,
75
82
  options: selectOptions,
76
83
  searchPlaceholder: lang('search'),
77
84
  selectedOption: selectedInstrument,
78
85
  setSelectedOption: setSelectedInstrument
79
- })), React.createElement("div", {
86
+ })), _react.default.createElement("div", {
80
87
  className: "lw-flex lw-max-w-full lw-flex-col lw-content-center lw-justify-center lw-gap-3"
81
- }, React.createElement("div", {
82
- className: cn('lw-flex lw-max-w-full lw-flex-row lw-gap-3', !isDesktop && 'lw-flex-col lw-gap-8')
83
- }, React.createElement(NumberInput, {
88
+ }, _react.default.createElement("div", {
89
+ className: (0, _labsWidgetCommon.cn)('lw-flex lw-max-w-full lw-flex-row lw-gap-3', !isDesktop && 'lw-flex-col lw-gap-8')
90
+ }, _react.default.createElement(_labsWidgetCommon.NumberInput, {
84
91
  withoutArrows: true,
85
92
  disabled: loading,
86
93
  label: lang('units_traded'),
@@ -89,7 +96,7 @@ const Main = _ref => {
89
96
  onDecrement: decrementTradedUnits,
90
97
  onIncrement: incrementTradedUnits,
91
98
  onValueChange: onUnitChange
92
- }), React.createElement(NumberInput, {
99
+ }), _react.default.createElement(_labsWidgetCommon.NumberInput, {
93
100
  disabled: loading,
94
101
  label: lang('spread'),
95
102
  placeholder: lang('pips'),
@@ -97,11 +104,11 @@ const Main = _ref => {
97
104
  onDecrement: decrementSpread,
98
105
  onIncrement: incrementSpread,
99
106
  onValueChange: onSpreadChange
100
- })), React.createElement("div", {
107
+ })), _react.default.createElement("div", {
101
108
  className: "lw-pt-4 lw-text-text-primary"
102
- }, React.createElement("div", null, lang('absolute_spread_cost')), React.createElement("div", {
109
+ }, _react.default.createElement("div", null, lang('absolute_spread_cost')), _react.default.createElement("div", {
103
110
  className: "lw-pt-2 lw-text-3xl lw-font-bold"
104
111
  }, spreadCost)))));
105
112
  };
106
- export { Main };
113
+ exports.Main = Main;
107
114
  //# sourceMappingURL=Main.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Main.js","names":["ChartError","cn","Label","NumberInput","Select","Size","useLayoutProvider","useNumberFormat","useLocale","React","useEffect","useCalculateSpread","useInstrumentChange","Main","_ref","instruments","size","isDesktop","DESKTOP","selectOptions","map","instrument","id","name","label","displayName","value","unitsTraded","handleValueChange","onUnitChange","increment","incrementTradedUnits","decrement","decrementTradedUnits","spread","onSpreadChange","incrementSpread","decrementSpread","step","selectedInstrument","setSelectedInstrument","pipLocation","initialSpread","loading","error","currency","initialInstrument","floatValue","formattedValue","toString","lang","spreadCost","createElement","Fragment","className","htmlFor","maxHeight","options","searchPlaceholder","selectedOption","setSelectedOption","withoutArrows","disabled","placeholder","onDecrement","onIncrement","onValueChange"],"sources":["../../../src/SpreadCostCalculatorWidget/Main.tsx"],"sourcesContent":["import {\n ChartError,\n cn,\n Label,\n NumberInput,\n Select,\n Size,\n useLayoutProvider,\n useNumberFormat,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport type { FC } from 'react';\nimport React, { useEffect } from 'react';\n\nimport type { MainProps } from './types';\nimport { useCalculateSpread } from './useCalculateSpread';\nimport { useInstrumentChange } from './useInstrumentChange';\n\nconst Main: FC<MainProps> = ({ instruments }) => {\n const { size } = useLayoutProvider();\n const isDesktop = size === Size.DESKTOP;\n\n const selectOptions = instruments.map((instrument) => ({\n id: instrument.name,\n label: instrument.displayName,\n }));\n\n const {\n value: unitsTraded,\n handleValueChange: onUnitChange,\n increment: incrementTradedUnits,\n decrement: decrementTradedUnits,\n } = useNumberFormat({});\n\n const {\n value: spread,\n handleValueChange: onSpreadChange,\n increment: incrementSpread,\n decrement: decrementSpread,\n } = useNumberFormat({\n step: 0.1,\n });\n\n const {\n selectedInstrument,\n setSelectedInstrument,\n pipLocation,\n initialSpread,\n loading,\n error,\n currency,\n } = useInstrumentChange({\n initialInstrument: {\n id: instruments[0].name,\n label: instruments[0].displayName,\n },\n });\n\n useEffect(() => {\n onSpreadChange({\n floatValue: initialSpread,\n formattedValue: initialSpread?.toString() || '',\n value: initialSpread?.toString() || '',\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [initialSpread]);\n\n const { lang } = useLocale();\n\n const spreadCost = useCalculateSpread({\n spread,\n unitsTraded,\n pipLocation,\n currency,\n });\n\n return (\n <>\n {error ? (\n <div className=\"lw-flex lw-h-[300px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : (\n <div\n className=\"lw-mx-auto lw-flex lw-w-full lw-max-w-full lw-flex-col lw-content-center lw-justify-center lw-gap-8 lw-p-4\"\n data-testid=\"spread-cost-calculator\"\n >\n <div className=\"lw-flex lw-flex-col lw-gap-2\">\n <Label\n className=\"lw-text-text-primary\"\n htmlFor={lang('instrument')}\n >\n {lang('instrument')}\n </Label>\n <Select\n className=\"lw-grow-0\"\n maxHeight={isDesktop ? 190 : 220}\n options={selectOptions}\n searchPlaceholder={lang('search')}\n selectedOption={selectedInstrument}\n setSelectedOption={setSelectedInstrument}\n />\n </div>\n <div className=\"lw-flex lw-max-w-full lw-flex-col lw-content-center lw-justify-center lw-gap-3\">\n <div\n className={cn(\n 'lw-flex lw-max-w-full lw-flex-row lw-gap-3',\n !isDesktop && 'lw-flex-col lw-gap-8'\n )}\n >\n <NumberInput\n withoutArrows\n disabled={loading}\n label={lang('units_traded')}\n placeholder={lang('volume')}\n value={unitsTraded}\n onDecrement={decrementTradedUnits}\n onIncrement={incrementTradedUnits}\n onValueChange={onUnitChange}\n />\n <NumberInput\n disabled={loading}\n label={lang('spread')}\n placeholder={lang('pips')}\n value={spread}\n onDecrement={decrementSpread}\n onIncrement={incrementSpread}\n onValueChange={onSpreadChange}\n />\n </div>\n <div className=\"lw-pt-4 lw-text-text-primary\">\n <div>{lang('absolute_spread_cost')}</div>\n <div className=\"lw-pt-2 lw-text-3xl lw-font-bold\">\n {spreadCost}\n </div>\n </div>\n </div>\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,SACEA,UAAU,EACVC,EAAE,EACFC,KAAK,EACLC,WAAW,EACXC,MAAM,EACNC,IAAI,EACJC,iBAAiB,EACjBC,eAAe,QACV,2BAA2B;AAClC,SAASC,SAAS,QAAQ,kBAAkB;AAE5C,OAAOC,KAAK,IAAIC,SAAS,QAAQ,OAAO;AAGxC,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,mBAAmB,QAAQ,uBAAuB;AAE3D,MAAMC,IAAmB,GAAGC,IAAA,IAAqB;EAAA,IAApB;IAAEC;EAAY,CAAC,GAAAD,IAAA;EAC1C,MAAM;IAAEE;EAAK,CAAC,GAAGV,iBAAiB,CAAC,CAAC;EACpC,MAAMW,SAAS,GAAGD,IAAI,KAAKX,IAAI,CAACa,OAAO;EAEvC,MAAMC,aAAa,GAAGJ,WAAW,CAACK,GAAG,CAAEC,UAAU,KAAM;IACrDC,EAAE,EAAED,UAAU,CAACE,IAAI;IACnBC,KAAK,EAAEH,UAAU,CAACI;EACpB,CAAC,CAAC,CAAC;EAEH,MAAM;IACJC,KAAK,EAAEC,WAAW;IAClBC,iBAAiB,EAAEC,YAAY;IAC/BC,SAAS,EAAEC,oBAAoB;IAC/BC,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B,CACE,CAAC,EACN1B,KAAA,CAAA2C,aAAA;IAAKE,SAAS,EAAC;EAA8B,GAC3C7C,KAAA,CAAA2C,aAAA,cAAMF,IAAI,CAAC,sBAAsB,CAAO,CAAC,EACzCzC,KAAA,CAAA2C,aAAA;IAAKE,SAAS,EAAC;EAAkC,GAC9CH,UACE,CACF,CACF,CACF,CAEP,CAAC;AAEP,CAAC;AAED,SAAStC,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"Main.js","names":["_labsWidgetCommon","require","_monoI18n","_react","_interopRequireWildcard","_useCalculateSpread","_useInstrumentChange","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Main","_ref","instruments","size","useLayoutProvider","isDesktop","Size","DESKTOP","selectOptions","map","instrument","id","name","label","displayName","value","unitsTraded","handleValueChange","onUnitChange","increment","incrementTradedUnits","decrement","decrementTradedUnits","useNumberFormat","spread","onSpreadChange","incrementSpread","decrementSpread","step","selectedInstrument","setSelectedInstrument","pipLocation","initialSpread","loading","error","currency","useInstrumentChange","initialInstrument","useEffect","floatValue","formattedValue","toString","lang","useLocale","spreadCost","useCalculateSpread","createElement","Fragment","className","ChartError","Label","htmlFor","Select","maxHeight","options","searchPlaceholder","selectedOption","setSelectedOption","cn","NumberInput","withoutArrows","disabled","placeholder","onDecrement","onIncrement","onValueChange","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/Main.tsx"],"sourcesContent":["import {\n ChartError,\n cn,\n Label,\n NumberInput,\n Select,\n Size,\n useLayoutProvider,\n useNumberFormat,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport type { FC } from 'react';\nimport React, { useEffect } from 'react';\n\nimport type { MainProps } from './types';\nimport { useCalculateSpread } from './useCalculateSpread';\nimport { useInstrumentChange } from './useInstrumentChange';\n\nconst Main: FC<MainProps> = ({ instruments }) => {\n const { size } = useLayoutProvider();\n const isDesktop = size === Size.DESKTOP;\n\n const selectOptions = instruments.map((instrument) => ({\n id: instrument.name,\n label: instrument.displayName,\n }));\n\n const {\n value: unitsTraded,\n handleValueChange: onUnitChange,\n increment: incrementTradedUnits,\n decrement: decrementTradedUnits,\n } = useNumberFormat({});\n\n const {\n value: spread,\n handleValueChange: onSpreadChange,\n increment: incrementSpread,\n decrement: decrementSpread,\n } = useNumberFormat({\n step: 0.1,\n });\n\n const {\n selectedInstrument,\n setSelectedInstrument,\n pipLocation,\n initialSpread,\n loading,\n error,\n currency,\n } = useInstrumentChange({\n initialInstrument: {\n id: instruments[0].name,\n label: instruments[0].displayName,\n },\n });\n\n useEffect(() => {\n onSpreadChange({\n floatValue: initialSpread,\n formattedValue: initialSpread?.toString() || '',\n value: initialSpread?.toString() || '',\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [initialSpread]);\n\n const { lang } = useLocale();\n\n const spreadCost = useCalculateSpread({\n spread,\n unitsTraded,\n pipLocation,\n currency,\n });\n\n return (\n <>\n {error ? (\n <div className=\"lw-flex lw-h-[300px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : (\n <div\n className=\"lw-mx-auto lw-flex lw-w-full lw-max-w-full lw-flex-col lw-content-center lw-justify-center lw-gap-8 lw-p-4\"\n data-testid=\"spread-cost-calculator\"\n >\n <div className=\"lw-flex lw-flex-col lw-gap-2\">\n <Label\n className=\"lw-text-text-primary\"\n htmlFor={lang('instrument')}\n >\n {lang('instrument')}\n </Label>\n <Select\n className=\"lw-grow-0\"\n maxHeight={isDesktop ? 190 : 220}\n options={selectOptions}\n searchPlaceholder={lang('search')}\n selectedOption={selectedInstrument}\n setSelectedOption={setSelectedInstrument}\n />\n </div>\n <div className=\"lw-flex lw-max-w-full lw-flex-col lw-content-center lw-justify-center lw-gap-3\">\n <div\n className={cn(\n 'lw-flex lw-max-w-full lw-flex-row lw-gap-3',\n !isDesktop && 'lw-flex-col lw-gap-8'\n )}\n >\n <NumberInput\n withoutArrows\n disabled={loading}\n label={lang('units_traded')}\n placeholder={lang('volume')}\n value={unitsTraded}\n onDecrement={decrementTradedUnits}\n onIncrement={incrementTradedUnits}\n onValueChange={onUnitChange}\n />\n <NumberInput\n disabled={loading}\n label={lang('spread')}\n placeholder={lang('pips')}\n value={spread}\n onDecrement={decrementSpread}\n onIncrement={incrementSpread}\n onValueChange={onSpreadChange}\n />\n </div>\n <div className=\"lw-pt-4 lw-text-text-primary\">\n <div>{lang('absolute_spread_cost')}</div>\n <div className=\"lw-pt-2 lw-text-3xl lw-font-bold\">\n {spreadCost}\n </div>\n </div>\n </div>\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAUA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAC,uBAAA,CAAAH,OAAA;AAGA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AAA4D,SAAAG,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IA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,CAAO,CAAC,EACzCjE,MAAA,CAAAc,OAAA,CAAAuD,aAAA;IAAKE,SAAS,EAAC;EAAkC,GAC9CJ,UACE,CACF,CACF,CACF,CAEP,CAAC;AAEP,CAAC;AAACsB,OAAA,CAAAlE,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -1,9 +1,16 @@
1
- import { ApolloClient, InMemoryCache } from '@apollo/client';
2
- import { Division } from '@oanda/labs-live-rates-table-widget';
3
- import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
4
- import React from 'react';
5
- import { translations } from '../translations';
6
- import { ValidationWrapper } from './ValidationWrapper';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SpreadCostCalculatorWidget = void 0;
7
+ var _client = require("@apollo/client");
8
+ var _labsLiveRatesTableWidget = require("@oanda/labs-live-rates-table-widget");
9
+ var _labsWidgetCommon = require("@oanda/labs-widget-common");
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _translations = require("../translations");
12
+ var _ValidationWrapper = require("./ValidationWrapper");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
14
  const SpreadCostCalculatorWidget = _ref => {
8
15
  let {
9
16
  graphqlUrl,
@@ -17,13 +24,13 @@ const SpreadCostCalculatorWidget = _ref => {
17
24
  logoLink,
18
25
  brandingSpace
19
26
  } = _ref;
20
- const client = new ApolloClient({
27
+ const client = new _client.ApolloClient({
21
28
  uri: graphqlUrl,
22
- cache: new InMemoryCache()
29
+ cache: new _client.InMemoryCache()
23
30
  });
24
- const divisionCode = division === Division.Opt ? Division.Ogm : division;
25
- const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';
26
- return React.createElement(WidgetProvider, {
31
+ const divisionCode = division === _labsLiveRatesTableWidget.Division.Opt ? _labsLiveRatesTableWidget.Division.Ogm : division;
32
+ const dataSource = divisionCode === _labsLiveRatesTableWidget.Division.Ogm ? 'MT5' : 'V20';
33
+ return _react.default.createElement(_labsWidgetCommon.WidgetProvider, {
27
34
  withSuspense: true,
28
35
  client: client,
29
36
  liveRates: {
@@ -38,16 +45,16 @@ const SpreadCostCalculatorWidget = _ref => {
38
45
  removePadding
39
46
  },
40
47
  theme: theme,
41
- translations: translations
42
- }, React.createElement(WidgetWrapper, {
48
+ translations: _translations.translations
49
+ }, _react.default.createElement(_labsWidgetCommon.WidgetWrapper, {
43
50
  brandingSpace: brandingSpace,
44
51
  linkArea: "logo",
45
52
  logoLink: logoLink
46
- }, React.createElement(ValidationWrapper, {
53
+ }, _react.default.createElement(_ValidationWrapper.ValidationWrapper, {
47
54
  division: division,
48
55
  instruments: instruments,
49
56
  isParamError: isParamError
50
57
  })));
51
58
  };
52
- export { SpreadCostCalculatorWidget };
59
+ exports.SpreadCostCalculatorWidget = SpreadCostCalculatorWidget;
53
60
  //# sourceMappingURL=SpreadCostCalculatorWidget.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SpreadCostCalculatorWidget.js","names":["ApolloClient","InMemoryCache","Division","WidgetProvider","WidgetWrapper","React","translations","ValidationWrapper","SpreadCostCalculatorWidget","_ref","graphqlUrl","liveRatesUrl","theme","locale","isParamError","removePadding","division","instruments","logoLink","brandingSpace","client","uri","cache","divisionCode","Opt","Ogm","dataSource","createElement","withSuspense","liveRates","url","options","styling","linkArea"],"sources":["../../../src/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.tsx"],"sourcesContent":["import { ApolloClient, InMemoryCache } from '@apollo/client';\nimport { Division } from '@oanda/labs-live-rates-table-widget';\nimport { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';\nimport type { FC } from 'react';\nimport React from 'react';\n\nimport { translations } from '../translations';\nimport type { SpreadCostCalculatorWidgetConfig } from './types';\nimport { ValidationWrapper } from './ValidationWrapper';\n\nconst SpreadCostCalculatorWidget: FC<SpreadCostCalculatorWidgetConfig> = ({\n graphqlUrl,\n liveRatesUrl,\n theme,\n locale,\n isParamError,\n removePadding,\n division,\n instruments,\n logoLink,\n brandingSpace,\n}) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n const divisionCode = division === Division.Opt ? Division.Ogm : division;\n const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';\n\n return (\n <WidgetProvider\n withSuspense\n client={client}\n liveRates={{\n url: liveRatesUrl,\n options: { divisionCode, dataSource },\n }}\n locale={locale}\n styling={{\n removePadding,\n }}\n theme={theme}\n translations={translations}\n >\n <WidgetWrapper\n brandingSpace={brandingSpace}\n linkArea=\"logo\"\n logoLink={logoLink}\n >\n <ValidationWrapper\n division={division}\n instruments={instruments}\n isParamError={isParamError}\n />\n </WidgetWrapper>\n </WidgetProvider>\n );\n};\n\nexport { SpreadCostCalculatorWidget };\n"],"mappings":"AAAA,SAASA,YAAY,EAAEC,aAAa,QAAQ,gBAAgB;AAC5D,SAASC,QAAQ,QAAQ,qCAAqC;AAC9D,SAASC,cAAc,EAAEC,aAAa,QAAQ,2BAA2B;AAEzE,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,YAAY,QAAQ,iBAAiB;AAE9C,SAASC,iBAAiB,QAAQ,qBAAqB;AAEvD,MAAMC,0BAAgE,GAAGC,IAAA,IAWnE;EAAA,IAXoE;IACxEC,UAAU;IACVC,YAAY;IACZC,KAAK;IACLC,MAAM;IACNC,YAAY;IACZC,aAAa;IACbC,QAAQ;IACRC,WAAW;IACXC,QAAQ;IACRC;EACF,CAAC,GAAAV,IAAA;EACC,MAAMW,MAAM,GAAG,IAAIpB,YAAY,CAAC;IAC9BqB,GAAG,EAAEX,UAAU;IACfY,KAAK,EAAE,IAAIrB,aAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMsB,YAAY,GAAGP,QAAQ,KAAKd,QAAQ,CAACsB,GAAG,GAAGtB,QAAQ,CAACuB,GAAG,GAAGT,QAAQ;EACxE,MAAMU,UAAU,GAAGH,YAAY,KAAKrB,QAAQ,CAACuB,GAAG,GAAG,KAAK,GAAG,KAAK;EAEhE,OACEpB,KAAA,CAAAsB,aAAA,CAACxB,cAAc;IACbyB,YAAY;IACZR,MAAM,EAAEA,MAAO;IACfS,SAAS,EAAE;MACTC,GAAG,EAAEnB,YAAY;MACjBoB,OAAO,EAAE;QAAER,YAAY;QAAEG;MAAW;IACtC,CAAE;IACFb,MAAM,EAAEA,MAAO;IACfmB,OAAO,EAAE;MACPjB;IACF,CAAE;IACFH,KAAK,EAAEA,KAAM;IACbN,YAAY,EAAEA;EAAa,GAE3BD,KAAA,CAAAsB,aAAA,CAACvB,aAAa;IACZe,aAAa,EAAEA,aAAc;IAC7Bc,QAAQ,EAAC,MAAM;IACff,QAAQ,EAAEA;EAAS,GAEnBb,KAAA,CAAAsB,aAAA,CAACpB,iBAAiB;IAChBS,QAAQ,EAAEA,QAAS;IACnBC,WAAW,EAAEA,WAAY;IACzBH,YAAY,EAAEA;EAAa,CAC5B,CACY,CACD,CAAC;AAErB,CAAC;AAED,SAASN,0BAA0B","ignoreList":[]}
1
+ {"version":3,"file":"SpreadCostCalculatorWidget.js","names":["_client","require","_labsLiveRatesTableWidget","_labsWidgetCommon","_react","_interopRequireDefault","_translations","_ValidationWrapper","e","__esModule","default","SpreadCostCalculatorWidget","_ref","graphqlUrl","liveRatesUrl","theme","locale","isParamError","removePadding","division","instruments","logoLink","brandingSpace","client","ApolloClient","uri","cache","InMemoryCache","divisionCode","Division","Opt","Ogm","dataSource","createElement","WidgetProvider","withSuspense","liveRates","url","options","styling","translations","WidgetWrapper","linkArea","ValidationWrapper","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/SpreadCostCalculatorWidget.tsx"],"sourcesContent":["import { ApolloClient, InMemoryCache } from '@apollo/client';\nimport { Division } from '@oanda/labs-live-rates-table-widget';\nimport { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';\nimport type { FC } from 'react';\nimport React from 'react';\n\nimport { translations } from '../translations';\nimport type { SpreadCostCalculatorWidgetConfig } from './types';\nimport { ValidationWrapper } from './ValidationWrapper';\n\nconst SpreadCostCalculatorWidget: FC<SpreadCostCalculatorWidgetConfig> = ({\n graphqlUrl,\n liveRatesUrl,\n theme,\n locale,\n isParamError,\n removePadding,\n division,\n instruments,\n logoLink,\n brandingSpace,\n}) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n const divisionCode = division === Division.Opt ? Division.Ogm : division;\n const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';\n\n return (\n <WidgetProvider\n withSuspense\n client={client}\n liveRates={{\n url: liveRatesUrl,\n options: { divisionCode, dataSource },\n }}\n locale={locale}\n styling={{\n removePadding,\n }}\n theme={theme}\n translations={translations}\n >\n <WidgetWrapper\n brandingSpace={brandingSpace}\n linkArea=\"logo\"\n logoLink={logoLink}\n >\n <ValidationWrapper\n division={division}\n instruments={instruments}\n isParamError={isParamError}\n />\n </WidgetWrapper>\n </WidgetProvider>\n );\n};\n\nexport { SpreadCostCalculatorWidget };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,yBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAEA,IAAAK,aAAA,GAAAL,OAAA;AAEA,IAAAM,kBAAA,GAAAN,OAAA;AAAwD,SAAAI,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExD,MAAMG,0BAAgE,GAAGC,IAAA,IAWnE;EAAA,IAXoE;IACxEC,UAAU;IACVC,YAAY;IACZC,KAAK;IACLC,MAAM;IACNC,YAAY;IACZC,aAAa;IACbC,QAAQ;IACRC,WAAW;IACXC,QAAQ;IACRC;EACF,CAAC,GAAAV,IAAA;EACC,MAAMW,MAAM,GAAG,IAAIC,oBAAY,CAAC;IAC9BC,GAAG,EAAEZ,UAAU;IACfa,KAAK,EAAE,IAAIC,qBAAa,CAAC;EAC3B,CAAC,CAAC;EAEF,MAAMC,YAAY,GAAGT,QAAQ,KAAKU,kCAAQ,CAACC,GAAG,GAAGD,kCAAQ,CAACE,GAAG,GAAGZ,QAAQ;EACxE,MAAMa,UAAU,GAAGJ,YAAY,KAAKC,kCAAQ,CAACE,GAAG,GAAG,KAAK,GAAG,KAAK;EAEhE,OACE3B,MAAA,CAAAM,OAAA,CAAAuB,aAAA,CAAC9B,iBAAA,CAAA+B,cAAc;IACbC,YAAY;IACZZ,MAAM,EAAEA,MAAO;IACfa,SAAS,EAAE;MACTC,GAAG,EAAEvB,YAAY;MACjBwB,OAAO,EAAE;QAAEV,YAAY;QAAEI;MAAW;IACtC,CAAE;IACFhB,MAAM,EAAEA,MAAO;IACfuB,OAAO,EAAE;MACPrB;IACF,CAAE;IACFH,KAAK,EAAEA,KAAM;IACbyB,YAAY,EAAEA;EAAa,GAE3BpC,MAAA,CAAAM,OAAA,CAAAuB,aAAA,CAAC9B,iBAAA,CAAAsC,aAAa;IACZnB,aAAa,EAAEA,aAAc;IAC7BoB,QAAQ,EAAC,MAAM;IACfrB,QAAQ,EAAEA;EAAS,GAEnBjB,MAAA,CAAAM,OAAA,CAAAuB,aAAA,CAAC1B,kBAAA,CAAAoC,iBAAiB;IAChBxB,QAAQ,EAAEA,QAAS;IACnBC,WAAW,EAAEA,WAAY;IACzBH,YAAY,EAAEA;EAAa,CAC5B,CACY,CACD,CAAC;AAErB,CAAC;AAAC2B,OAAA,CAAAjC,0BAAA,GAAAA,0BAAA","ignoreList":[]}
@@ -1,8 +1,15 @@
1
- import { useSuspenseQuery } from '@apollo/client';
2
- import { ChartError, useLayoutProvider } from '@oanda/labs-widget-common';
3
- import React from 'react';
4
- import { validateInstruments } from '../gql/validateInstruments';
5
- import { Main } from './Main';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ValidationWrapper = void 0;
7
+ var _client = require("@apollo/client");
8
+ var _labsWidgetCommon = require("@oanda/labs-widget-common");
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _validateInstruments = require("../gql/validateInstruments");
11
+ var _Main = require("./Main");
12
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
6
13
  const ValidationWrapper = _ref => {
7
14
  let {
8
15
  division,
@@ -11,11 +18,11 @@ const ValidationWrapper = _ref => {
11
18
  } = _ref;
12
19
  const {
13
20
  size
14
- } = useLayoutProvider();
21
+ } = (0, _labsWidgetCommon.useLayoutProvider)();
15
22
  const {
16
23
  data,
17
24
  error
18
- } = useSuspenseQuery(validateInstruments, {
25
+ } = (0, _client.useSuspenseQuery)(_validateInstruments.validateInstruments, {
19
26
  variables: {
20
27
  instruments,
21
28
  division
@@ -28,11 +35,11 @@ const ValidationWrapper = _ref => {
28
35
  displayName: instrument.displayName
29
36
  })) || [];
30
37
  const showError = !!error || isParamError;
31
- return React.createElement(React.Fragment, null, size && React.createElement(React.Fragment, null, showError ? React.createElement("div", {
38
+ return _react.default.createElement(_react.default.Fragment, null, size && _react.default.createElement(_react.default.Fragment, null, showError ? _react.default.createElement("div", {
32
39
  className: "lw-flex lw-h-[300px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
33
- }, React.createElement(ChartError, null)) : React.createElement(Main, {
40
+ }, _react.default.createElement(_labsWidgetCommon.ChartError, null)) : _react.default.createElement(_Main.Main, {
34
41
  instruments: instrumentsData
35
42
  })));
36
43
  };
37
- export { ValidationWrapper };
44
+ exports.ValidationWrapper = ValidationWrapper;
38
45
  //# sourceMappingURL=ValidationWrapper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationWrapper.js","names":["useSuspenseQuery","ChartError","useLayoutProvider","React","validateInstruments","Main","ValidationWrapper","_ref","division","instruments","isParamError","size","data","error","variables","fetchPolicy","errorPolicy","instrumentsData","mapInstrumentNames","map","instrument","name","displayName","showError","createElement","Fragment","className"],"sources":["../../../src/SpreadCostCalculatorWidget/ValidationWrapper.tsx"],"sourcesContent":["import { useSuspenseQuery } from '@apollo/client';\nimport { ChartError, useLayoutProvider } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport type {\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables,\n} from '../gql/types/graphql';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { Main } from './Main';\nimport type { ValidationWrapperProps } from './types';\n\nconst ValidationWrapper = ({\n division,\n instruments,\n isParamError,\n}: ValidationWrapperProps) => {\n const { size } = useLayoutProvider();\n const { data, error } = useSuspenseQuery<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables\n >(validateInstruments, {\n variables: {\n instruments,\n division,\n },\n fetchPolicy: 'network-only',\n errorPolicy: 'all',\n });\n\n const instrumentsData =\n data?.mapInstrumentNames?.map((instrument) => ({\n name: instrument!.name,\n displayName: instrument!.displayName,\n })) || [];\n\n const showError = !!error || isParamError;\n\n return (\n <>\n {size && (\n <>\n {showError ? (\n <div className=\"lw-flex lw-h-[300px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : (\n <Main instruments={instrumentsData} />\n )}\n </>\n )}\n </>\n );\n};\n\nexport { ValidationWrapper };\n"],"mappings":"AAAA,SAASA,gBAAgB,QAAQ,gBAAgB;AACjD,SAASC,UAAU,EAAEC,iBAAiB,QAAQ,2BAA2B;AACzE,OAAOC,KAAK,MAAM,OAAO;AAMzB,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,IAAI,QAAQ,QAAQ;AAG7B,MAAMC,iBAAiB,GAAGC,IAAA,IAII;EAAA,IAJH;IACzBC,QAAQ;IACRC,WAAW;IACXC;EACsB,CAAC,GAAAH,IAAA;EACvB,MAAM;IAAEI;EAAK,CAAC,GAAGT,iBAAiB,CAAC,CAAC;EACpC,MAAM;IAAEU,IAAI;IAAEC;EAAM,CAAC,GAAGb,gBAAgB,CAGtCI,mBAAmB,EAAE;IACrBU,SAAS,EAAE;MACTL,WAAW;MACXD;IACF,CAAC;IACDO,WAAW,EAAE,cAAc;IAC3BC,WAAW,EAAE;EACf,CAAC,CAAC;EAEF,MAAMC,eAAe,GACnBL,IAAI,EAAEM,kBAAkB,EAAEC,GAAG,CAAEC,UAAU,KAAM;IAC7CC,IAAI,EAAED,UAAU,CAAEC,IAAI;IACtBC,WAAW,EAAEF,UAAU,CAAEE;EAC3B,CAAC,CAAC,CAAC,IAAI,EAAE;EAEX,MAAMC,SAAS,GAAG,CAAC,CAACV,KAAK,IAAIH,YAAY;EAEzC,OACEP,KAAA,CAAAqB,aAAA,CAAArB,KAAA,CAAAsB,QAAA,QACGd,IAAI,IACHR,KAAA,CAAAqB,aAAA,CAAArB,KAAA,CAAAsB,QAAA,QACGF,SAAS,GACRpB,KAAA,CAAAqB,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChHvB,KAAA,CAAAqB,aAAA,CAACvB,UAAU,MAAE,CACV,CAAC,GAENE,KAAA,CAAAqB,aAAA,CAACnB,IAAI;IAACI,WAAW,EAAEQ;EAAgB,CAAE,CAEvC,CAEJ,CAAC;AAEP,CAAC;AAED,SAASX,iBAAiB","ignoreList":[]}
1
+ {"version":3,"file":"ValidationWrapper.js","names":["_client","require","_labsWidgetCommon","_react","_interopRequireDefault","_validateInstruments","_Main","e","__esModule","default","ValidationWrapper","_ref","division","instruments","isParamError","size","useLayoutProvider","data","error","useSuspenseQuery","validateInstruments","variables","fetchPolicy","errorPolicy","instrumentsData","mapInstrumentNames","map","instrument","name","displayName","showError","createElement","Fragment","className","ChartError","Main","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/ValidationWrapper.tsx"],"sourcesContent":["import { useSuspenseQuery } from '@apollo/client';\nimport { ChartError, useLayoutProvider } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport type {\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables,\n} from '../gql/types/graphql';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { Main } from './Main';\nimport type { ValidationWrapperProps } from './types';\n\nconst ValidationWrapper = ({\n division,\n instruments,\n isParamError,\n}: ValidationWrapperProps) => {\n const { size } = useLayoutProvider();\n const { data, error } = useSuspenseQuery<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables\n >(validateInstruments, {\n variables: {\n instruments,\n division,\n },\n fetchPolicy: 'network-only',\n errorPolicy: 'all',\n });\n\n const instrumentsData =\n data?.mapInstrumentNames?.map((instrument) => ({\n name: instrument!.name,\n displayName: instrument!.displayName,\n })) || [];\n\n const showError = !!error || isParamError;\n\n return (\n <>\n {size && (\n <>\n {showError ? (\n <div className=\"lw-flex lw-h-[300px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n ) : (\n <Main instruments={instrumentsData} />\n )}\n </>\n )}\n </>\n );\n};\n\nexport { ValidationWrapper };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAMA,IAAAI,oBAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAA8B,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG9B,MAAMG,iBAAiB,GAAGC,IAAA,IAII;EAAA,IAJH;IACzBC,QAAQ;IACRC,WAAW;IACXC;EACsB,CAAC,GAAAH,IAAA;EACvB,MAAM;IAAEI;EAAK,CAAC,GAAG,IAAAC,mCAAiB,EAAC,CAAC;EACpC,MAAM;IAAEC,IAAI;IAAEC;EAAM,CAAC,GAAG,IAAAC,wBAAgB,EAGtCC,wCAAmB,EAAE;IACrBC,SAAS,EAAE;MACTR,WAAW;MACXD;IACF,CAAC;IACDU,WAAW,EAAE,cAAc;IAC3BC,WAAW,EAAE;EACf,CAAC,CAAC;EAEF,MAAMC,eAAe,GACnBP,IAAI,EAAEQ,kBAAkB,EAAEC,GAAG,CAAEC,UAAU,KAAM;IAC7CC,IAAI,EAAED,UAAU,CAAEC,IAAI;IACtBC,WAAW,EAAEF,UAAU,CAAEE;EAC3B,CAAC,CAAC,CAAC,IAAI,EAAE;EAEX,MAAMC,SAAS,GAAG,CAAC,CAACZ,KAAK,IAAIJ,YAAY;EAEzC,OACEX,MAAA,CAAAM,OAAA,CAAAsB,aAAA,CAAA5B,MAAA,CAAAM,OAAA,CAAAuB,QAAA,QACGjB,IAAI,IACHZ,MAAA,CAAAM,OAAA,CAAAsB,aAAA,CAAA5B,MAAA,CAAAM,OAAA,CAAAuB,QAAA,QACGF,SAAS,GACR3B,MAAA,CAAAM,OAAA,CAAAsB,aAAA;IAAKE,SAAS,EAAC;EAAmG,GAChH9B,MAAA,CAAAM,OAAA,CAAAsB,aAAA,CAAC7B,iBAAA,CAAAgC,UAAU,MAAE,CACV,CAAC,GAEN/B,MAAA,CAAAM,OAAA,CAAAsB,aAAA,CAACzB,KAAA,CAAA6B,IAAI;IAACtB,WAAW,EAAEW;EAAgB,CAAE,CAEvC,CAEJ,CAAC;AAEP,CAAC;AAACY,OAAA,CAAA1B,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -1,3 +1,9 @@
1
- export const CELL_EMPTY_VALUE = '\u2014';
2
- export const DEFAULT_CURRENCY = 'USD';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DEFAULT_CURRENCY = exports.CELL_EMPTY_VALUE = void 0;
7
+ const CELL_EMPTY_VALUE = exports.CELL_EMPTY_VALUE = '\u2014';
8
+ const DEFAULT_CURRENCY = exports.DEFAULT_CURRENCY = 'USD';
3
9
  //# sourceMappingURL=constant.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constant.js","names":["CELL_EMPTY_VALUE","DEFAULT_CURRENCY"],"sources":["../../../src/SpreadCostCalculatorWidget/constant.ts"],"sourcesContent":["export const CELL_EMPTY_VALUE = '\\u2014';\nexport const DEFAULT_CURRENCY = 'USD';\n"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,GAAG,QAAQ;AACxC,OAAO,MAAMC,gBAAgB,GAAG,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"constant.js","names":["CELL_EMPTY_VALUE","exports","DEFAULT_CURRENCY"],"sources":["../../../src/SpreadCostCalculatorWidget/constant.ts"],"sourcesContent":["export const CELL_EMPTY_VALUE = '\\u2014';\nexport const DEFAULT_CURRENCY = 'USD';\n"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,QAAQ;AACjC,MAAME,gBAAgB,GAAAD,OAAA,CAAAC,gBAAA,GAAG,KAAK","ignoreList":[]}
@@ -1,3 +1,28 @@
1
- export * from './Main';
2
- export * from './types';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _Main = require("./Main");
7
+ Object.keys(_Main).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _Main[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _Main[key];
14
+ }
15
+ });
16
+ });
17
+ var _types = require("./types");
18
+ Object.keys(_types).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _types[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _types[key];
25
+ }
26
+ });
27
+ });
3
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/SpreadCostCalculatorWidget/index.ts"],"sourcesContent":["export * from './Main';\nexport * from './types';\n"],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_Main","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_types"],"sources":["../../../src/SpreadCostCalculatorWidget/index.ts"],"sourcesContent":["export * from './Main';\nexport * from './types';\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -1,14 +1,17 @@
1
- import { validateLocale, validateToolParams } from '@oanda/labs-widget-common';
2
- import React from 'react';
3
- import { createRoot } from 'react-dom/client';
4
- import { SpreadCostCalculatorWidget } from './SpreadCostCalculatorWidget';
1
+ "use strict";
2
+
3
+ var _labsWidgetCommon = require("@oanda/labs-widget-common");
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _client = require("react-dom/client");
6
+ var _SpreadCostCalculatorWidget = require("./SpreadCostCalculatorWidget");
7
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
5
8
  const {
6
9
  graphqlUrl,
7
10
  liveRatesUrl
8
11
  } = window.widgetsConfig || {};
9
12
  const spreadCostCalculatorParamsElements = document.querySelectorAll('div[data-spread-cost-calculator-params]');
10
13
  spreadCostCalculatorParamsElements.forEach(element => {
11
- const root = createRoot(element);
14
+ const root = (0, _client.createRoot)(element);
12
15
  const params = element.getAttribute('data-spread-cost-calculator-params');
13
16
  const mode = element.getAttribute('data-mode');
14
17
  const {
@@ -17,7 +20,7 @@ spreadCostCalculatorParamsElements.forEach(element => {
17
20
  division,
18
21
  logoLink
19
22
  } = JSON.parse(params);
20
- const isParamError = validateToolParams({
23
+ const isParamError = (0, _labsWidgetCommon.validateToolParams)({
21
24
  locale,
22
25
  graphqlUrl,
23
26
  instruments,
@@ -25,7 +28,7 @@ spreadCostCalculatorParamsElements.forEach(element => {
25
28
  liveRatesUrl
26
29
  }, [{
27
30
  name: 'locale',
28
- valueCheck: value => validateLocale(value)
31
+ valueCheck: value => (0, _labsWidgetCommon.validateLocale)(value)
29
32
  }, {
30
33
  name: 'graphqlUrl'
31
34
  }, {
@@ -36,7 +39,7 @@ spreadCostCalculatorParamsElements.forEach(element => {
36
39
  name: 'instruments',
37
40
  valueCheck: value => value.length > 0 && value.length <= 10
38
41
  }]);
39
- root.render(React.createElement(SpreadCostCalculatorWidget, {
42
+ root.render(_react.default.createElement(_SpreadCostCalculatorWidget.SpreadCostCalculatorWidget, {
40
43
  division: division,
41
44
  graphqlUrl: graphqlUrl,
42
45
  instruments: instruments,
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["validateLocale","validateToolParams","React","createRoot","SpreadCostCalculatorWidget","graphqlUrl","liveRatesUrl","window","widgetsConfig","spreadCostCalculatorParamsElements","document","querySelectorAll","forEach","element","root","params","getAttribute","mode","locale","instruments","division","logoLink","JSON","parse","isParamError","name","valueCheck","value","length","render","createElement","theme"],"sources":["../../../src/SpreadCostCalculatorWidget/render.tsx"],"sourcesContent":["import type { Theme } from '@oanda/labs-widget-common';\nimport { validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { SpreadCostCalculatorWidget } from './SpreadCostCalculatorWidget';\n\nconst { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};\nconst spreadCostCalculatorParamsElements = document.querySelectorAll(\n 'div[data-spread-cost-calculator-params]'\n);\n\nspreadCostCalculatorParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-spread-cost-calculator-params');\n const mode = element.getAttribute('data-mode');\n const { locale, instruments, division, logoLink } = JSON.parse(\n params as string\n );\n\n const isParamError = validateToolParams(\n {\n locale,\n graphqlUrl,\n instruments,\n division,\n liveRatesUrl,\n },\n [\n {\n name: 'locale',\n valueCheck: (value: string | undefined) => validateLocale(value),\n },\n {\n name: 'graphqlUrl',\n },\n {\n name: 'liveRatesUrl',\n },\n {\n name: 'division',\n },\n {\n name: 'instruments',\n valueCheck: (value) =>\n (value as string[]).length > 0 && (value as string[]).length <= 10,\n },\n ]\n );\n\n root.render(\n <SpreadCostCalculatorWidget\n division={division}\n graphqlUrl={graphqlUrl}\n instruments={instruments}\n isParamError={isParamError}\n liveRatesUrl={liveRatesUrl}\n locale={locale}\n logoLink={logoLink}\n theme={mode as Theme}\n />\n );\n});\n"],"mappings":"AACA,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,2BAA2B;AAC9E,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,SAASC,0BAA0B,QAAQ,8BAA8B;AAEzE,MAAM;EAAEC,UAAU;EAAEC;AAAa,CAAC,GAAGC,MAAM,CAACC,aAAa,IAAI,CAAC,CAAC;AAC/D,MAAMC,kCAAkC,GAAGC,QAAQ,CAACC,gBAAgB,CAClE,yCACF,CAAC;AAEDF,kCAAkC,CAACG,OAAO,CAAEC,OAAO,IAAK;EACtD,MAAMC,IAAI,GAAGX,UAAU,CAACU,OAAO,CAAC;EAChC,MAAME,MAAM,GAAGF,OAAO,CAACG,YAAY,CAAC,oCAAoC,CAAC;EACzE,MAAMC,IAAI,GAAGJ,OAAO,CAACG,YAAY,CAAC,WAAW,CAAC;EAC9C,MAAM;IAAEE,MAAM;IAAEC,WAAW;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAGC,IAAI,CAACC,KAAK,CAC5DR,MACF,CAAC;EAED,MAAMS,YAAY,GAAGvB,kBAAkB,CACrC;IACEiB,MAAM;IACNb,UAAU;IACVc,WAAW;IACXC,QAAQ;IACRd;EACF,CAAC,EACD,CACE;IACEmB,IAAI,EAAE,QAAQ;IACdC,UAAU,EAAGC,KAAyB,IAAK3B,cAAc,CAAC2B,KAAK;EACjE,CAAC,EACD;IACEF,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE;EACR,CAAC,EACD;IACEA,IAAI,EAAE,aAAa;IACnBC,UAAU,EAAGC,KAAK,IACfA,KAAK,CAAcC,MAAM,GAAG,CAAC,IAAKD,KAAK,CAAcC,MAAM,IAAI;EACpE,CAAC,CAEL,CAAC;EAEDd,IAAI,CAACe,MAAM,CACT3B,KAAA,CAAA4B,aAAA,CAAC1B,0BAA0B;IACzBgB,QAAQ,EAAEA,QAAS;IACnBf,UAAU,EAAEA,UAAW;IACvBc,WAAW,EAAEA,WAAY;IACzBK,YAAY,EAAEA,YAAa;IAC3BlB,YAAY,EAAEA,YAAa;IAC3BY,MAAM,EAAEA,MAAO;IACfG,QAAQ,EAAEA,QAAS;IACnBU,KAAK,EAAEd;EAAc,CACtB,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"render.js","names":["_labsWidgetCommon","require","_react","_interopRequireDefault","_client","_SpreadCostCalculatorWidget","e","__esModule","default","graphqlUrl","liveRatesUrl","window","widgetsConfig","spreadCostCalculatorParamsElements","document","querySelectorAll","forEach","element","root","createRoot","params","getAttribute","mode","locale","instruments","division","logoLink","JSON","parse","isParamError","validateToolParams","name","valueCheck","value","validateLocale","length","render","createElement","SpreadCostCalculatorWidget","theme"],"sources":["../../../src/SpreadCostCalculatorWidget/render.tsx"],"sourcesContent":["import type { Theme } from '@oanda/labs-widget-common';\nimport { validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\n\nimport { SpreadCostCalculatorWidget } from './SpreadCostCalculatorWidget';\n\nconst { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};\nconst spreadCostCalculatorParamsElements = document.querySelectorAll(\n 'div[data-spread-cost-calculator-params]'\n);\n\nspreadCostCalculatorParamsElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-spread-cost-calculator-params');\n const mode = element.getAttribute('data-mode');\n const { locale, instruments, division, logoLink } = JSON.parse(\n params as string\n );\n\n const isParamError = validateToolParams(\n {\n locale,\n graphqlUrl,\n instruments,\n division,\n liveRatesUrl,\n },\n [\n {\n name: 'locale',\n valueCheck: (value: string | undefined) => validateLocale(value),\n },\n {\n name: 'graphqlUrl',\n },\n {\n name: 'liveRatesUrl',\n },\n {\n name: 'division',\n },\n {\n name: 'instruments',\n valueCheck: (value) =>\n (value as string[]).length > 0 && (value as string[]).length <= 10,\n },\n ]\n );\n\n root.render(\n <SpreadCostCalculatorWidget\n division={division}\n graphqlUrl={graphqlUrl}\n instruments={instruments}\n isParamError={isParamError}\n liveRatesUrl={liveRatesUrl}\n locale={locale}\n logoLink={logoLink}\n theme={mode as Theme}\n />\n );\n});\n"],"mappings":";;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,2BAAA,GAAAJ,OAAA;AAA0E,SAAAE,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1E,MAAM;EAAEG,UAAU;EAAEC;AAAa,CAAC,GAAGC,MAA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jB;EAAc,CACtB,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -1,2 +1,13 @@
1
- export { Locale } from '@oanda/mono-i18n';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Locale", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _monoI18n.Locale;
10
+ }
11
+ });
12
+ var _monoI18n = require("@oanda/mono-i18n");
2
13
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":["Locale"],"sources":["../../../src/SpreadCostCalculatorWidget/types.ts"],"sourcesContent":["import type { WidgetConfig } from '@oanda/labs-widget-common';\n\nimport type { Division } from '../gql/types/graphql';\n\nexport { Locale } from '@oanda/mono-i18n';\n\nexport type SpreadCostCalculatorWidgetConfig = WidgetConfig & {\n liveRatesUrl: string;\n division: Division;\n instruments: string[];\n};\n\nexport interface InstrumentResponse {\n name: string;\n displayName: string;\n}\n\nexport interface MainProps {\n instruments: InstrumentResponse[];\n}\n\nexport interface ValidationWrapperProps {\n division: Division;\n instruments: string[];\n isParamError?: boolean;\n}\n"],"mappings":"AAIA,SAASA,MAAM,QAAQ,kBAAkB","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":["_monoI18n","require"],"sources":["../../../src/SpreadCostCalculatorWidget/types.ts"],"sourcesContent":["import type { WidgetConfig } from '@oanda/labs-widget-common';\n\nimport type { Division } from '../gql/types/graphql';\n\nexport { Locale } from '@oanda/mono-i18n';\n\nexport type SpreadCostCalculatorWidgetConfig = WidgetConfig & {\n liveRatesUrl: string;\n division: Division;\n instruments: string[];\n};\n\nexport interface InstrumentResponse {\n name: string;\n displayName: string;\n}\n\nexport interface MainProps {\n instruments: InstrumentResponse[];\n}\n\nexport interface ValidationWrapperProps {\n division: Division;\n instruments: string[];\n isParamError?: boolean;\n}\n"],"mappings":";;;;;;;;;;;AAIA,IAAAA,SAAA,GAAAC,OAAA","ignoreList":[]}
@@ -1,9 +1,15 @@
1
- import { useEffect } from 'react';
2
- import { numericFormatter } from 'react-number-format';
3
- import { useDebounceValue } from 'usehooks-ts';
4
- import { CELL_EMPTY_VALUE } from './constant';
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useCalculateSpread = void 0;
7
+ var _react = require("react");
8
+ var _reactNumberFormat = require("react-number-format");
9
+ var _usehooksTs = require("usehooks-ts");
10
+ var _constant = require("./constant");
5
11
  const calculateAbsoluteSpreadCost = (unitsTraded, spread, pipLocation) => unitsTraded !== undefined && spread !== undefined && pipLocation !== undefined ? Math.ceil(unitsTraded * spread * Number((10 ** pipLocation).toFixed(Math.abs(pipLocation))) / 2 * 10000) / 10000 : undefined;
6
- export const useCalculateSpread = _ref => {
12
+ const useCalculateSpread = _ref => {
7
13
  let {
8
14
  spread,
9
15
  unitsTraded,
@@ -11,13 +17,14 @@ export const useCalculateSpread = _ref => {
11
17
  delay = 350,
12
18
  currency
13
19
  } = _ref;
14
- const [debouncedValue, setValue] = useDebounceValue(CELL_EMPTY_VALUE, delay);
15
- useEffect(() => {
20
+ const [debouncedValue, setValue] = (0, _usehooksTs.useDebounceValue)(_constant.CELL_EMPTY_VALUE, delay);
21
+ (0, _react.useEffect)(() => {
16
22
  const calculatedSpread = calculateAbsoluteSpreadCost(unitsTraded, spread, pipLocation);
17
- setValue(calculatedSpread ? `${numericFormatter(calculatedSpread.toString(), {
23
+ setValue(calculatedSpread ? `${(0, _reactNumberFormat.numericFormatter)(calculatedSpread.toString(), {
18
24
  thousandSeparator: ','
19
- })} ${currency}` : CELL_EMPTY_VALUE);
25
+ })} ${currency}` : _constant.CELL_EMPTY_VALUE);
20
26
  }, [spread, unitsTraded, pipLocation, setValue]);
21
27
  return debouncedValue;
22
28
  };
29
+ exports.useCalculateSpread = useCalculateSpread;
23
30
  //# sourceMappingURL=useCalculateSpread.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCalculateSpread.js","names":["useEffect","numericFormatter","useDebounceValue","CELL_EMPTY_VALUE","calculateAbsoluteSpreadCost","unitsTraded","spread","pipLocation","undefined","Math","ceil","Number","toFixed","abs","useCalculateSpread","_ref","delay","currency","debouncedValue","setValue","calculatedSpread","toString","thousandSeparator"],"sources":["../../../src/SpreadCostCalculatorWidget/useCalculateSpread.ts"],"sourcesContent":["import type { Voidable } from '@oanda/labs-widget-common';\nimport { useEffect } from 'react';\nimport { numericFormatter } from 'react-number-format';\nimport { useDebounceValue } from 'usehooks-ts';\n\nimport { CELL_EMPTY_VALUE } from './constant';\n\nexport interface UseCalculateSpreadInput {\n spread: Voidable<number>;\n unitsTraded: Voidable<number>;\n pipLocation: Voidable<number>;\n delay?: number;\n currency: string;\n}\n\nconst calculateAbsoluteSpreadCost = (\n unitsTraded?: number,\n spread?: number,\n pipLocation?: number\n): number | undefined =>\n unitsTraded !== undefined && spread !== undefined && pipLocation !== undefined\n ? Math.ceil(\n ((unitsTraded *\n spread *\n Number((10 ** pipLocation).toFixed(Math.abs(pipLocation)))) /\n 2) *\n 10000\n ) / 10000\n : undefined;\n\nexport const useCalculateSpread = ({\n spread,\n unitsTraded,\n pipLocation,\n delay = 350,\n currency,\n}: UseCalculateSpreadInput) => {\n const [debouncedValue, setValue] = useDebounceValue(CELL_EMPTY_VALUE, delay);\n\n useEffect(() => {\n const calculatedSpread = calculateAbsoluteSpreadCost(\n unitsTraded,\n spread,\n pipLocation\n );\n setValue(\n calculatedSpread\n ? `${numericFormatter(calculatedSpread.toString(), {\n thousandSeparator: ',',\n })} ${currency}`\n : CELL_EMPTY_VALUE\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [spread, unitsTraded, pipLocation, setValue]);\n\n return debouncedValue;\n};\n"],"mappings":"AACA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,gBAAgB,QAAQ,aAAa;AAE9C,SAASC,gBAAgB,QAAQ,YAAY;AAU7C,MAAMC,2BAA2B,GAAGA,CAClCC,WAAoB,EACpBC,MAAe,EACfC,WAAoB,KAEpBF,WAAW,KAAKG,SAAS,IAAIF,MAAM,KAAKE,SAAS,IAAID,WAAW,KAAKC,SAAS,GAC1EC,IAAI,CAACC,IAAI,CACLL,WAAW,GACXC,MAAM,GACNK,MAAM,CAAC,CAAC,EAAE,IAAIJ,WAAW,EAAEK,OAAO,CAACH,IAAI,CAACI,GAAG,CAACN,WAAW,CAAC,CAAC,CAAC,GAC1D,CAAC,GACD,KACJ,CAAC,GAAG,KAAK,GACTC,SAAS;AAEf,OAAO,MAAMM,kBAAkB,GAAGC,IAAA,IAMH;EAAA,IANI;IACjCT,MAAM;IACND,WAAW;IACXE,WAAW;IACXS,KAAK,GAAG,GAAG;IACXC;EACuB,CAAC,GAAAF,IAAA;EACxB,MAAM,CAACG,cAAc,EAAEC,QAAQ,CAAC,GAAGjB,gBAAgB,CAACC,gBAAgB,EAAEa,KAAK,CAAC;EAE5EhB,SAAS,CAAC,MAAM;IACd,MAAMoB,gBAAgB,GAAGhB,2BAA2B,CAClDC,WAAW,EACXC,MAAM,EACNC,WACF,CAAC;IACDY,QAAQ,CACNC,gBAAgB,GACZ,GAAGnB,gBAAgB,CAACmB,gBAAgB,CAACC,QAAQ,CAAC,CAAC,EAAE;MAC/CC,iBAAiB,EAAE;IACrB,CAAC,CAAC,IAAIL,QAAQ,EAAE,GAChBd,gBACN,CAAC;EAEH,CAAC,EAAE,CAACG,MAAM,EAAED,WAAW,EAAEE,WAAW,EAAEY,QAAQ,CAAC,CAAC;EAEhD,OAAOD,cAAc;AACvB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useCalculateSpread.js","names":["_react","require","_reactNumberFormat","_usehooksTs","_constant","calculateAbsoluteSpreadCost","unitsTraded","spread","pipLocation","undefined","Math","ceil","Number","toFixed","abs","useCalculateSpread","_ref","delay","currency","debouncedValue","setValue","useDebounceValue","CELL_EMPTY_VALUE","useEffect","calculatedSpread","numericFormatter","toString","thousandSeparator","exports"],"sources":["../../../src/SpreadCostCalculatorWidget/useCalculateSpread.ts"],"sourcesContent":["import type { Voidable } from '@oanda/labs-widget-common';\nimport { useEffect } from 'react';\nimport { numericFormatter } from 'react-number-format';\nimport { useDebounceValue } from 'usehooks-ts';\n\nimport { CELL_EMPTY_VALUE } from './constant';\n\nexport interface UseCalculateSpreadInput {\n spread: Voidable<number>;\n unitsTraded: Voidable<number>;\n pipLocation: Voidable<number>;\n delay?: number;\n currency: string;\n}\n\nconst calculateAbsoluteSpreadCost = (\n unitsTraded?: number,\n spread?: number,\n pipLocation?: number\n): number | undefined =>\n unitsTraded !== undefined && spread !== undefined && pipLocation !== undefined\n ? Math.ceil(\n ((unitsTraded *\n spread *\n Number((10 ** pipLocation).toFixed(Math.abs(pipLocation)))) /\n 2) *\n 10000\n ) / 10000\n : undefined;\n\nexport const useCalculateSpread = ({\n spread,\n unitsTraded,\n pipLocation,\n delay = 350,\n currency,\n}: UseCalculateSpreadInput) => {\n const [debouncedValue, setValue] = useDebounceValue(CELL_EMPTY_VALUE, delay);\n\n useEffect(() => {\n const calculatedSpread = calculateAbsoluteSpreadCost(\n unitsTraded,\n spread,\n pipLocation\n );\n setValue(\n calculatedSpread\n ? `${numericFormatter(calculatedSpread.toString(), {\n thousandSeparator: ',',\n })} ${currency}`\n : CELL_EMPTY_VALUE\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [spread, unitsTraded, pipLocation, setValue]);\n\n return debouncedValue;\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AAUA,MAAMI,2BAA2B,GAAGA,CAClCC,WAAoB,EACpBC,MAAe,EACfC,WAAoB,KAEpBF,WAAW,KAAKG,SAAS,IAAIF,MAAM,KAAKE,SAAS,IAAID,WAAW,KAAKC,SAAS,G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