@oanda/labs-currency-cross-table 1.0.1 → 1.0.2

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 (29) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/main/CurrencyCrossTableWidget/Main.js +12 -6
  3. package/dist/main/CurrencyCrossTableWidget/Main.js.map +1 -1
  4. package/dist/main/CurrencyCrossTableWidget/components/Cell.js +9 -3
  5. package/dist/main/CurrencyCrossTableWidget/components/Cell.js.map +1 -1
  6. package/dist/main/CurrencyCrossTableWidget/components/CellWithData.js +23 -4
  7. package/dist/main/CurrencyCrossTableWidget/components/CellWithData.js.map +1 -1
  8. package/dist/main/CurrencyCrossTableWidget/components/TextCell.js +4 -2
  9. package/dist/main/CurrencyCrossTableWidget/components/TextCell.js.map +1 -1
  10. package/dist/main/CurrencyCrossTableWidget/components/types.js.map +1 -1
  11. package/dist/module/CurrencyCrossTableWidget/Main.js +13 -7
  12. package/dist/module/CurrencyCrossTableWidget/Main.js.map +1 -1
  13. package/dist/module/CurrencyCrossTableWidget/components/Cell.js +9 -3
  14. package/dist/module/CurrencyCrossTableWidget/components/Cell.js.map +1 -1
  15. package/dist/module/CurrencyCrossTableWidget/components/CellWithData.js +21 -3
  16. package/dist/module/CurrencyCrossTableWidget/components/CellWithData.js.map +1 -1
  17. package/dist/module/CurrencyCrossTableWidget/components/TextCell.js +4 -2
  18. package/dist/module/CurrencyCrossTableWidget/components/TextCell.js.map +1 -1
  19. package/dist/module/CurrencyCrossTableWidget/components/types.js.map +1 -1
  20. package/dist/types/CurrencyCrossTableWidget/components/Cell.d.ts +1 -1
  21. package/dist/types/CurrencyCrossTableWidget/components/CellWithData.d.ts +1 -1
  22. package/dist/types/CurrencyCrossTableWidget/components/TextCell.d.ts +1 -1
  23. package/dist/types/CurrencyCrossTableWidget/components/types.d.ts +6 -0
  24. package/package.json +3 -3
  25. package/src/CurrencyCrossTableWidget/Main.tsx +15 -4
  26. package/src/CurrencyCrossTableWidget/components/Cell.tsx +14 -4
  27. package/src/CurrencyCrossTableWidget/components/CellWithData.tsx +24 -1
  28. package/src/CurrencyCrossTableWidget/components/TextCell.tsx +2 -0
  29. package/src/CurrencyCrossTableWidget/components/types.ts +6 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.0.2 (2024-08-20)
7
+
8
+
9
+
10
+ ## 1.0.150 (2024-08-19)
11
+
12
+ **Note:** Version bump only for package @oanda/labs-currency-cross-table
13
+
14
+
15
+
16
+
17
+
6
18
  ## 1.0.1 (2024-08-19)
7
19
 
8
20
  **Note:** Version bump only for package @oanda/labs-currency-cross-table
@@ -14,6 +14,8 @@ const Main = _ref => {
14
14
  instruments,
15
15
  currencies
16
16
  } = _ref;
17
+ const [selectedCurrency, setSelectedCurrency] = (0, _react.useState)('');
18
+ const [selectedPair, setSelectedPair] = (0, _react.useState)('');
17
19
  const hasInstruments = instruments.length > 0;
18
20
  const {
19
21
  target,
@@ -31,15 +33,17 @@ const Main = _ref => {
31
33
  className: "lw-w-full"
32
34
  }, _react.default.createElement("div", {
33
35
  className: "lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary"
34
- }, _react.default.createElement(_components.TextCell, null), currencies.map(currency => _react.default.createElement(_components.TextCell, {
35
- key: currency,
36
- label: currency
36
+ }, _react.default.createElement(_components.TextCell, null), currencies.map(pair => _react.default.createElement(_components.TextCell, {
37
+ key: pair,
38
+ label: pair,
39
+ hovered: pair === selectedPair
37
40
  }))), currencies.map((currency, index, arr) => _react.default.createElement("div", {
38
41
  key: currency,
39
42
  className: "lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary"
40
43
  }, _react.default.createElement(_components.TextCell, {
41
- label: `${currency}`,
42
- additionalBorderBottom: index === arr.length - 1
44
+ label: currency,
45
+ additionalBorderBottom: index === arr.length - 1,
46
+ hovered: currency === selectedCurrency
43
47
  }), arr.map(pair => _react.default.createElement(_react.Fragment, {
44
48
  key: `${currency}_${pair}`
45
49
  }, currency !== pair ? _react.default.createElement(_components.CellWithData, {
@@ -49,7 +53,9 @@ const Main = _ref => {
49
53
  displayName: `${currency}/${pair}`
50
54
  },
51
55
  target: target,
52
- additionalBorderBottom: index === arr.length - 1
56
+ additionalBorderBottom: index === arr.length - 1,
57
+ setSelectedCurrency: setSelectedCurrency,
58
+ setSelectedPair: setSelectedPair
53
59
  }) : _react.default.createElement(_components.TextCell, {
54
60
  additionalBorderBottom: index === arr.length - 1,
55
61
  emptyIndicator: true
@@ -1 +1 @@
1
- {"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_labsWidgetCommon","_components","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","instruments","currencies","hasInstruments","length","target","setQuery","useLiveRatesQuery","useEffect","createElement","className","TextCell","map","currency","key","label","index","arr","additionalBorderBottom","pair","Fragment","CellWithData","loading","record","instrument","displayName","emptyIndicator","exports"],"sources":["../../../src/CurrencyCrossTableWidget/Main.tsx"],"sourcesContent":["import React, { Fragment, useEffect } from 'react';\nimport { useLiveRatesQuery } from '@oanda/labs-widget-common';\nimport { MainProps } from './types';\nimport { CellWithData, TextCell } from './components';\n\nconst Main = ({\n instruments,\n currencies,\n}: MainProps) => {\n const hasInstruments = instruments.length > 0;\n\n const { target, setQuery } = useLiveRatesQuery();\n\n useEffect(() => {\n if (hasInstruments) {\n setQuery({ instruments });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, instruments);\n\n return (\n <div data-testid=\"currency-cross-table-wrapper\" className=\"lw-w-full\">\n <div className=\"lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary\">\n <TextCell />\n {currencies.map(((currency) => <TextCell key={currency} label={currency} />\n ))}\n </div>\n {currencies.map(((currency, index, arr) => (\n <div\n key={currency}\n className=\"lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary\"\n >\n <TextCell\n label={`${currency}`}\n additionalBorderBottom={index === arr.length - 1}\n />\n {arr.map((pair) => (\n <Fragment key={`${currency}_${pair}`}>\n {currency !== pair ? (\n <CellWithData\n loading={false}\n record={{\n instrument: `${currency}_${pair}`,\n displayName: `${currency}/${pair}`,\n }}\n target={target}\n additionalBorderBottom={index === arr.length - 1}\n />\n ) : (\n <TextCell\n additionalBorderBottom={index === arr.length - 1}\n emptyIndicator\n />\n )}\n </Fragment>\n ))}\n </div>\n )))}\n </div>\n );\n};\n\nexport { Main };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAAsD,SAAAG,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,SAAAL,wBAAAK,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,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAA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,KAAK,EAAEC,GAAG,KACpC3C,MAAA,CAAAW,OAAA,CAAAwB,aAAA;IACEK,GAAG,EAAED,QAAS;IACdH,SAAS,EAAC;EAA0E,GAEpFpC,MAAA,CAAAW,OAAA,CAAAwB,aAAA,CAAC/B,WAAA,CAAAiC,QAAQ;IACPI,KAAK,EAAE,GAAGF,QAAQ,EAAG;IACrBK,sBAAsB,EAAEF,KAAK,KAAKC,GAAG,CAACb,MAAM,GAAG;EAAE,CAClD,CAAC,EACDa,GAAG,CAACL,GAAG,CAAEO,IAAI,IACZ7C,MAAA,CAAAW,OAAA,CAAAwB,aAAA,CAACnC,MAAA,CAAA8C,QAAQ;IAACN,GAAG,EAAE,GAAGD,QAAQ,IAAIM,IAAI;EAAG,GAClCN,QAAQ,KAAKM,IAAI,GAChB7C,MAAA,CAAAW,OAAA,CAAAwB,aAAA,CAAC/B,WAAA,CAAA2C,YAAY;IACXC,OAAO,EAAE,KAAM;IACfC,MAAM,EAAE;MACNC,UAAU,EAAE,GAAGX,QAAQ,IAAIM,IAAI,EAAE;MACjCM,WAAW,EAAE,GAAGZ,QAAQ,IAAIM,IAAI;IAClC,CAAE;IACFd,MAAM,EAAEA,MAAO;IACfa,sBAAsB,EAAEF,KAAK,KAAKC,GAAG,CAACb,MAAM,GAAG;EAAE,CAClD,CAAC,GAEF9B,MAAA,CAAAW,OAAA,CAAAwB,aAAA,CAAC/B,WAAA,CAAAiC,QAAQ;IACPO,sBAAsB,EAAEF,KAAK,KAAKC,GAAG,CAACb,MAAM,GAAG,CAAE;IACjDsB,cAAc;EAAA,CACf,CAEK,CACX,CACE,CACL,CACC,CAAC;AAEV,CAAC;AAACC,OAAA,CAAA5B,IAAA,GAAAA,IAAA","ignoreList":[]}
1
+ {"version":3,"file":"Main.js","names":["_react","_interopRequireWildcard","require","_labsWidgetCommon","_components","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","Main","_ref","instruments","currencies","selectedCurrency","setSelectedCurrency","useState","selectedPair","setSelectedPair","hasInstruments","length","target","setQuery","useLiveRatesQuery","useEffect","createElement","className","TextCell","map","pair","key","label","hovered","currency","index","arr","additionalBorderBottom","Fragment","CellWithData","loading","record","instrument","displayName","emptyIndicator","exports"],"sources":["../../../src/CurrencyCrossTableWidget/Main.tsx"],"sourcesContent":["import React, { Fragment, useEffect, useState } from 'react';\nimport { useLiveRatesQuery } from '@oanda/labs-widget-common';\nimport { MainProps } from './types';\nimport { CellWithData, TextCell } from './components';\n\nconst Main = ({\n instruments,\n currencies,\n}: MainProps) => {\n const [selectedCurrency, setSelectedCurrency] = useState('');\n const [selectedPair, setSelectedPair] = useState('');\n\n const hasInstruments = instruments.length > 0;\n\n const { target, setQuery } = useLiveRatesQuery();\n\n useEffect(() => {\n if (hasInstruments) {\n setQuery({ instruments });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, instruments);\n\n return (\n <div data-testid=\"currency-cross-table-wrapper\" className=\"lw-w-full\">\n <div className=\"lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary\">\n <TextCell />\n {currencies.map(((pair) => (\n <TextCell\n key={pair}\n label={pair}\n hovered={pair === selectedPair}\n />\n )))}\n </div>\n {currencies.map(((currency, index, arr) => (\n <div\n key={currency}\n className=\"lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary\"\n >\n <TextCell\n label={currency}\n additionalBorderBottom={index === arr.length - 1}\n hovered={currency === selectedCurrency}\n />\n {arr.map((pair) => (\n <Fragment key={`${currency}_${pair}`}>\n {currency !== pair ? (\n <CellWithData\n loading={false}\n record={{\n instrument: `${currency}_${pair}`,\n displayName: `${currency}/${pair}`,\n }}\n target={target}\n additionalBorderBottom={index === arr.length - 1}\n setSelectedCurrency={setSelectedCurrency}\n setSelectedPair={setSelectedPair}\n />\n ) : (\n <TextCell\n additionalBorderBottom={index === arr.length - 1}\n emptyIndicator\n />\n )}\n </Fragment>\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,WAAA,CAAAsC,QAAQ;IACPI,KAAK,EAAEE,QAAS;IAChBG,sBAAsB,EAAEF,KAAK,KAAKC,GAAG,CAACf,MAAM,GAAG,CAAE;IACjDY,OAAO,EAAEC,QAAQ,KAAKnB;EAAiB,CACxC,CAAC,EACDqB,GAAG,CAACP,GAAG,CAAEC,IAAI,IACZ5C,MAAA,CAAAW,OAAA,CAAA6B,aAAA,CAACxC,MAAA,CAAAoD,QAAQ;IAACP,GAAG,EAAE,GAAGG,QAAQ,IAAIJ,IAAI;EAAG,GAClCI,QAAQ,KAAKJ,IAAI,GAChB5C,MAAA,CAAAW,OAAA,CAAA6B,aAAA,CAACpC,WAAA,CAAAiD,YAAY;IACXC,OAAO,EAAE,KAAM;IACfC,MAAM,EAAE;MACNC,UAAU,EAAE,GAAGR,QAAQ,IAAIJ,IAAI,EAAE;MACjCa,WAAW,EAAE,GAAGT,QAAQ,IAAIJ,IAAI;IAClC,CAAE;IACFR,MAAM,EAAEA,MAAO;IACfe,sBAAsB,EAAEF,KAAK,KAAKC,GAAG,CAACf,MAAM,GAAG,CAAE;IACjDL,mBAAmB,EAAEA,mBAAoB;IACzCG,eAAe,EAAEA;EAAgB,CAClC,CAAC,GAEFjC,MAAA,CAAAW,OAAA,CAAA6B,aAAA,CAACpC,WAAA,CAAAsC,QAAQ;IACPS,sBAAsB,EAAEF,KAAK,KAAKC,GAAG,CAACf,MAAM,GAAG,CAAE;IACjDuB,cAAc;EAAA,CACf,CAEK,CACX,CACE,CACL,CACC,CAAC;AAEV,CAAC;AAACC,OAAA,CAAAlC,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -13,12 +13,18 @@ const Cell = _ref => {
13
13
  children,
14
14
  isError,
15
15
  isLoading,
16
- additionalBorderBottom
16
+ additionalBorderBottom,
17
+ hovered,
18
+ mouseEnterHandler,
19
+ mouseLeaveHandler
17
20
  } = _ref;
18
21
  return _react.default.createElement("div", {
19
22
  className: (0, _classnames.default)('lw-flex lw-h-[inherit] lw-flex-1 lw-items-center lw-justify-center lw-border-r lw-border-solid lw-border-border-primary', {
20
- 'lw-border-b': additionalBorderBottom
21
- })
23
+ 'lw-border-b': additionalBorderBottom,
24
+ 'lw-font-semibold': hovered
25
+ }),
26
+ onMouseEnter: mouseEnterHandler,
27
+ onMouseLeave: mouseLeaveHandler
22
28
  }, isLoading && _react.default.createElement("div", {
23
29
  className: "lw-px-3 lw-py-3.5"
24
30
  }, _constant.CELL_LOADING_VALUE), !isLoading && !isError && children, !isLoading && isError && _react.default.createElement("span", null, _constant.CELL_EMPTY_VALUE));
@@ -1 +1 @@
1
- {"version":3,"file":"Cell.js","names":["_react","_interopRequireDefault","require","_classnames","_constant","e","__esModule","default","Cell","_ref","children","isError","isLoading","additionalBorderBottom","createElement","className","classnames","CELL_LOADING_VALUE","CELL_EMPTY_VALUE","exports"],"sources":["../../../../src/CurrencyCrossTableWidget/components/Cell.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { CellProps } from './types';\nimport { CELL_EMPTY_VALUE, CELL_LOADING_VALUE } from '../constant';\n\nconst Cell = ({\n children, isError, isLoading, additionalBorderBottom,\n}: CellProps) => (\n <div className={classnames('lw-flex lw-h-[inherit] lw-flex-1 lw-items-center lw-justify-center lw-border-r lw-border-solid lw-border-border-primary', {\n 'lw-border-b': additionalBorderBottom,\n })}\n >\n {isLoading && <div className=\"lw-px-3 lw-py-3.5\">{CELL_LOADING_VALUE}</div>}\n {!isLoading && !isError && children}\n {!isLoading && isError && (\n <span>{CELL_EMPTY_VALUE}</span>\n )}\n </div>\n);\n\nexport { Cell };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAAmE,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnE,MAAMG,IAAI,GAAGC,IAAA;EAAA,IAAC;IACZC,QAAQ;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EACrB,CAAC,GAAAJ,IAAA;EAAA,OACVT,MAAA,CAAAO,OAAA,CAAAO,aAAA;IAAKC,SAAS,EAAE,IAAAC,mBAAU,EAAC,yHAAyH,EAAE;MACpJ,aAAa,EAAEH;IACjB,CAAC;EAAE,GAEAD,SAAS,IAAIZ,MAAA,CAAAO,OAAA,CAAAO,aAAA;IAAKC,SAAS,EAAC;EAAmB,GAAEE,4BAAwB,CAAC,EAC1E,CAACL,SAAS,IAAI,CAACD,OAAO,IAAID,QAAQ,EAClC,CAACE,SAAS,IAAID,OAAO,IACpBX,MAAA,CAAAO,OAAA,CAAAO,aAAA,eAAOI,0BAAuB,CAE7B,CAAC;AAAA,CACP;AAACC,OAAA,CAAAX,IAAA,GAAAA,IAAA","ignoreList":[]}
1
+ {"version":3,"file":"Cell.js","names":["_react","_interopRequireDefault","require","_classnames","_constant","e","__esModule","default","Cell","_ref","children","isError","isLoading","additionalBorderBottom","hovered","mouseEnterHandler","mouseLeaveHandler","createElement","className","classnames","onMouseEnter","onMouseLeave","CELL_LOADING_VALUE","CELL_EMPTY_VALUE","exports"],"sources":["../../../../src/CurrencyCrossTableWidget/components/Cell.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { CellProps } from './types';\nimport { CELL_EMPTY_VALUE, CELL_LOADING_VALUE } from '../constant';\n\nconst Cell = ({\n children,\n isError,\n isLoading,\n additionalBorderBottom,\n hovered,\n mouseEnterHandler,\n mouseLeaveHandler,\n}: CellProps) => (\n <div\n className={classnames('lw-flex lw-h-[inherit] lw-flex-1 lw-items-center lw-justify-center lw-border-r lw-border-solid lw-border-border-primary', {\n 'lw-border-b': additionalBorderBottom,\n 'lw-font-semibold': hovered,\n })}\n onMouseEnter={mouseEnterHandler}\n onMouseLeave={mouseLeaveHandler}\n >\n {isLoading && <div className=\"lw-px-3 lw-py-3.5\">{CELL_LOADING_VALUE}</div>}\n {!isLoading && !isError && children}\n {!isLoading && isError && (\n <span>{CELL_EMPTY_VALUE}</span>\n )}\n </div>\n);\n\nexport { Cell };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAAmE,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnE,MAAMG,IAAI,GAAGC,IAAA;EAAA,IAAC;IACZC,QAAQ;IACRC,OAAO;IACPC,SAAS;IACTC,sBAAsB;IACtBC,OAAO;IACPC,iBAAiB;IACjBC;EACS,CAAC,GAAAP,IAAA;EAAA,OACVT,MAAA,CAAAO,OAAA,CAAAU,aAAA;IACEC,SAAS,EAAE,IAAAC,mBAAU,EAAC,yHAAyH,EAAE;MAC/I,aAAa,EAAEN,sBAAsB;MACrC,kBAAkB,EAAEC;IACtB,CAAC,CAAE;IACHM,YAAY,EAAEL,iBAAkB;IAChCM,YAAY,EAAEL;EAAkB,GAE/BJ,SAAS,IAAIZ,MAAA,CAAAO,OAAA,CAAAU,aAAA;IAAKC,SAAS,EAAC;EAAmB,GAAEI,4BAAwB,CAAC,EAC1E,CAACV,SAAS,IAAI,CAACD,OAAO,IAAID,QAAQ,EAClC,CAACE,SAAS,IAAID,OAAO,IACpBX,MAAA,CAAAO,OAAA,CAAAU,aAAA,eAAOM,0BAAuB,CAE7B,CAAC;AAAA,CACP;AAACC,OAAA,CAAAhB,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -4,27 +4,46 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.CellWithData = void 0;
7
- var _react = _interopRequireDefault(require("react"));
7
+ var _react = _interopRequireWildcard(require("react"));
8
8
  var _labsWidgetCommon = require("@oanda/labs-widget-common");
9
9
  var _utils = require("../utils");
10
10
  var _Cell = require("./Cell");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ 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); }
12
+ 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; }
12
13
  const CellWithData = _ref => {
13
14
  let {
14
15
  loading,
15
16
  record,
16
17
  target,
17
- additionalBorderBottom
18
+ additionalBorderBottom,
19
+ setSelectedCurrency,
20
+ setSelectedPair
18
21
  } = _ref;
22
+ const [hovered, setHovered] = (0, _react.useState)(false);
19
23
  const {
20
24
  updatedRecord,
21
25
  error
22
26
  } = (0, _utils.useRecords)(record, record.instrument ? target : null);
23
27
  const checkLoading = id => loading || !error && updatedRecord?.[id] === undefined;
28
+ const handleMouseEnter = () => {
29
+ setHovered(true);
30
+ const currency = record.instrument.substring(0, 3);
31
+ const pair = record.instrument.substring(record.instrument.length - 3);
32
+ setSelectedCurrency(currency);
33
+ setSelectedPair(pair);
34
+ };
35
+ const handleMouseLeave = () => {
36
+ setHovered(false);
37
+ setSelectedCurrency('');
38
+ setSelectedPair('');
39
+ };
24
40
  return _react.default.createElement(_Cell.Cell, {
25
41
  isLoading: checkLoading('buy'),
26
42
  isError: !!error,
27
- additionalBorderBottom: additionalBorderBottom
43
+ additionalBorderBottom: additionalBorderBottom,
44
+ hovered: hovered,
45
+ mouseEnterHandler: handleMouseEnter,
46
+ mouseLeaveHandler: handleMouseLeave
28
47
  }, _react.default.createElement(_labsWidgetCommon.Price, {
29
48
  priceMovement: updatedRecord.buyPriceMovement,
30
49
  movementIndicator: "background"
@@ -1 +1 @@
1
- {"version":3,"file":"CellWithData.js","names":["_react","_interopRequireDefault","require","_labsWidgetCommon","_utils","_Cell","e","__esModule","default","CellWithData","_ref","loading","record","target","additionalBorderBottom","updatedRecord","error","useRecords","instrument","checkLoading","id","undefined","createElement","Cell","isLoading","isError","Price","priceMovement","buyPriceMovement","movementIndicator","buy","toFixed","displayPrecision","exports"],"sources":["../../../../src/CurrencyCrossTableWidget/components/CellWithData.tsx"],"sourcesContent":["import React from 'react';\nimport { Price } from '@oanda/labs-widget-common';\nimport { useRecords } from '../utils';\nimport { CellWithDataProps } from './types';\nimport { Cell } from './Cell';\n\nconst CellWithData = ({\n loading,\n record,\n target,\n additionalBorderBottom,\n}: CellWithDataProps) => {\n const { updatedRecord, error } = useRecords(record, record.instrument ? target : null);\n\n const checkLoading = (id: string) => loading || (!error && updatedRecord?.[id] === undefined);\n\n return (\n <Cell\n isLoading={checkLoading('buy')}\n isError={!!error}\n additionalBorderBottom={additionalBorderBottom}\n >\n <Price priceMovement={updatedRecord.buyPriceMovement} movementIndicator=\"background\">\n <span>{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}</span>\n </Price>\n </Cell>\n );\n};\n\nexport { CellWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AAA8B,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9B,MAAMG,YAAY,GAAGC,IAAA,IAKI;EAAA,IALH;IACpBC,OAAO;IACPC,MAAM;IACNC,MAAM;IACNC;EACiB,CAAC,GAAAJ,IAAA;EAClB,MAAM;IAAEK,aAAa;IAAEC;EAAM,CAAC,GAAG,IAAAC,iBAAU,EAACL,MAAM,EAAEA,MAAM,CAACM,UAAU,GAAGL,MAAM,GAAG,IAAI,CAAC;EAEtF,MAAMM,YAAY,GAAIC,EAAU,IAAKT,OAAO,IAAK,CAACK,KAAK,IAAID,aAAa,GAAGK,EAAE,CAAC,KAAKC,SAAU;EAE7F,OACErB,MAAA,CAAAQ,OAAA,CAAAc,aAAA,CAACjB,KAAA,CAAAkB,IAAI;IACHC,SAAS,EAAEL,YAAY,CAAC,KAAK,CAAE;IAC/BM,OAAO,EAAE,CAAC,CAACT,KAAM;IACjBF,sBAAsB,EAAEA;EAAuB,GAE/Cd,MAAA,CAAAQ,OAAA,CAAAc,aAAA,CAACnB,iBAAA,CAAAuB,KAAK;IAACC,aAAa,EAAEZ,aAAa,CAACa,gBAAiB;IAACC,iBAAiB,EAAC;EAAY,GAClF7B,MAAA,CAAAQ,OAAA,CAAAc,aAAA,eAAOP,aAAa,CAACe,GAAG,EAAEC,OAAO,CAAChB,aAAa,CAACiB,gBAAgB,CAAQ,CACnE,CACH,CAAC;AAEX,CAAC;AAACC,OAAA,CAAAxB,YAAA,GAAAA,YAAA","ignoreList":[]}
1
+ {"version":3,"file":"CellWithData.js","names":["_react","_interopRequireWildcard","require","_labsWidgetCommon","_utils","_Cell","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","CellWithData","_ref","loading","record","target","additionalBorderBottom","setSelectedCurrency","setSelectedPair","hovered","setHovered","useState","updatedRecord","error","useRecords","instrument","checkLoading","id","undefined","handleMouseEnter","currency","substring","pair","length","handleMouseLeave","createElement","Cell","isLoading","isError","mouseEnterHandler","mouseLeaveHandler","Price","priceMovement","buyPriceMovement","movementIndicator","buy","toFixed","displayPrecision","exports"],"sources":["../../../../src/CurrencyCrossTableWidget/components/CellWithData.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Price } from '@oanda/labs-widget-common';\nimport { useRecords } from '../utils';\nimport { CellWithDataProps } from './types';\nimport { Cell } from './Cell';\n\nconst CellWithData = ({\n loading,\n record,\n target,\n additionalBorderBottom,\n setSelectedCurrency,\n setSelectedPair,\n}: CellWithDataProps) => {\n const [hovered, setHovered] = useState(false);\n const { updatedRecord, error } = useRecords(record, record.instrument ? target : null);\n\n const checkLoading = (id: string) => loading || (!error && updatedRecord?.[id] === undefined);\n\n const handleMouseEnter = () => {\n setHovered(true);\n\n const currency = record.instrument.substring(0, 3);\n const pair = record.instrument.substring(record.instrument.length - 3);\n\n setSelectedCurrency(currency);\n setSelectedPair(pair);\n };\n\n const handleMouseLeave = () => {\n setHovered(false);\n\n setSelectedCurrency('');\n setSelectedPair('');\n };\n\n return (\n <Cell\n isLoading={checkLoading('buy')}\n isError={!!error}\n additionalBorderBottom={additionalBorderBottom}\n hovered={hovered}\n mouseEnterHandler={handleMouseEnter}\n mouseLeaveHandler={handleMouseLeave}\n >\n <Price priceMovement={updatedRecord.buyPriceMovement} movementIndicator=\"background\">\n <span>{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}</span>\n </Price>\n </Cell>\n );\n};\n\nexport { CellWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,KAAA,GAAAH,OAAA;AAA8B,SAAAI,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,IA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
11
  let {
12
12
  label,
13
13
  emptyIndicator,
14
- additionalBorderBottom
14
+ additionalBorderBottom,
15
+ hovered
15
16
  } = _ref;
16
17
  return _react.default.createElement("span", {
17
18
  className: (0, _classnames.default)('lw-flex-1 lw-border-r lw-border-solid lw-border-border-primary lw-py-3.5 lw-text-center', {
18
19
  'lw-border-b': additionalBorderBottom,
19
- 'lw-bg-border-primary': emptyIndicator
20
+ 'lw-bg-border-primary': emptyIndicator,
21
+ 'lw-font-semibold': hovered
20
22
  })
21
23
  }, label);
22
24
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TextCell.js","names":["_react","_interopRequireDefault","require","_classnames","e","__esModule","default","TextCell","_ref","label","emptyIndicator","additionalBorderBottom","createElement","className","classnames","exports"],"sources":["../../../../src/CurrencyCrossTableWidget/components/TextCell.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { TextCellProps } from './types';\n\nconst TextCell = ({\n label,\n emptyIndicator,\n additionalBorderBottom,\n}: TextCellProps) => (\n <span className={classnames('lw-flex-1 lw-border-r lw-border-solid lw-border-border-primary lw-py-3.5 lw-text-center', {\n 'lw-border-b': additionalBorderBottom,\n 'lw-bg-border-primary': emptyIndicator,\n })}\n >\n {label}\n </span>\n);\n\nexport { TextCell };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGpC,MAAMG,QAAQ,GAAGC,IAAA;EAAA,IAAC;IAChBC,KAAK;IACLC,cAAc;IACdC;EACa,CAAC,GAAAH,IAAA;EAAA,OACdR,MAAA,CAAAM,OAAA,CAAAM,aAAA;IAAMC,SAAS,EAAE,IAAAC,mBAAU,EAAC,yFAAyF,EAAE;MACrH,aAAa,EAAEH,sBAAsB;MACrC,sBAAsB,EAAED;IAC1B,CAAC;EAAE,GAEAD,KACG,CAAC;AAAA,CACR;AAACM,OAAA,CAAAR,QAAA,GAAAA,QAAA","ignoreList":[]}
1
+ {"version":3,"file":"TextCell.js","names":["_react","_interopRequireDefault","require","_classnames","e","__esModule","default","TextCell","_ref","label","emptyIndicator","additionalBorderBottom","hovered","createElement","className","classnames","exports"],"sources":["../../../../src/CurrencyCrossTableWidget/components/TextCell.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { TextCellProps } from './types';\n\nconst TextCell = ({\n label,\n emptyIndicator,\n additionalBorderBottom,\n hovered,\n}: TextCellProps) => (\n <span className={classnames('lw-flex-1 lw-border-r lw-border-solid lw-border-border-primary lw-py-3.5 lw-text-center', {\n 'lw-border-b': additionalBorderBottom,\n 'lw-bg-border-primary': emptyIndicator,\n 'lw-font-semibold': hovered,\n })}\n >\n {label}\n </span>\n);\n\nexport { TextCell };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGpC,MAAMG,QAAQ,GAAGC,IAAA;EAAA,IAAC;IAChBC,KAAK;IACLC,cAAc;IACdC,sBAAsB;IACtBC;EACa,CAAC,GAAAJ,IAAA;EAAA,OACdR,MAAA,CAAAM,OAAA,CAAAO,aAAA;IAAMC,SAAS,EAAE,IAAAC,mBAAU,EAAC,yFAAyF,EAAE;MACrH,aAAa,EAAEJ,sBAAsB;MACrC,sBAAsB,EAAED,cAAc;MACtC,kBAAkB,EAAEE;IACtB,CAAC;EAAE,GAEAH,KACG,CAAC;AAAA,CACR;AAACO,OAAA,CAAAT,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/CurrencyCrossTableWidget/components/types.ts"],"sourcesContent":["import { DataRecord, LoaderSize } from '@oanda/labs-widget-common';\n\nexport interface CellWithDataProps {\n loading: boolean;\n record: DataRecord;\n target: EventTarget | null;\n additionalBorderBottom? : boolean;\n}\n\nexport interface CellProps {\n children: React.ReactNode;\n isLoading?: boolean;\n isError?: boolean;\n loaderSize?: LoaderSize;\n additionalBorderBottom? : boolean;\n}\n\nexport interface TextCellProps {\n label?: string;\n emptyIndicator?: boolean;\n additionalBorderBottom? : boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/CurrencyCrossTableWidget/components/types.ts"],"sourcesContent":["import { DataRecord, LoaderSize } from '@oanda/labs-widget-common';\n\nexport interface CellWithDataProps {\n loading: boolean;\n record: DataRecord;\n target: EventTarget | null;\n additionalBorderBottom? : boolean;\n setSelectedCurrency: React.Dispatch<React.SetStateAction<string>>;\n setSelectedPair: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport interface CellProps {\n children: React.ReactNode;\n isLoading?: boolean;\n isError?: boolean;\n loaderSize?: LoaderSize;\n additionalBorderBottom? : boolean;\n hovered: boolean;\n mouseEnterHandler: () => void;\n mouseLeaveHandler: () => void;\n}\n\nexport interface TextCellProps {\n label?: string;\n emptyIndicator?: boolean;\n additionalBorderBottom? : boolean;\n hovered?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useEffect } from 'react';
1
+ import React, { Fragment, useEffect, useState } from 'react';
2
2
  import { useLiveRatesQuery } from '@oanda/labs-widget-common';
3
3
  import { CellWithData, TextCell } from './components';
4
4
  const Main = _ref => {
@@ -6,6 +6,8 @@ const Main = _ref => {
6
6
  instruments,
7
7
  currencies
8
8
  } = _ref;
9
+ const [selectedCurrency, setSelectedCurrency] = useState('');
10
+ const [selectedPair, setSelectedPair] = useState('');
9
11
  const hasInstruments = instruments.length > 0;
10
12
  const {
11
13
  target,
@@ -23,15 +25,17 @@ const Main = _ref => {
23
25
  className: "lw-w-full"
24
26
  }, React.createElement("div", {
25
27
  className: "lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary"
26
- }, React.createElement(TextCell, null), currencies.map(currency => React.createElement(TextCell, {
27
- key: currency,
28
- label: currency
28
+ }, React.createElement(TextCell, null), currencies.map(pair => React.createElement(TextCell, {
29
+ key: pair,
30
+ label: pair,
31
+ hovered: pair === selectedPair
29
32
  }))), currencies.map((currency, index, arr) => React.createElement("div", {
30
33
  key: currency,
31
34
  className: "lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary"
32
35
  }, React.createElement(TextCell, {
33
- label: `${currency}`,
34
- additionalBorderBottom: index === arr.length - 1
36
+ label: currency,
37
+ additionalBorderBottom: index === arr.length - 1,
38
+ hovered: currency === selectedCurrency
35
39
  }), arr.map(pair => React.createElement(Fragment, {
36
40
  key: `${currency}_${pair}`
37
41
  }, currency !== pair ? React.createElement(CellWithData, {
@@ -41,7 +45,9 @@ const Main = _ref => {
41
45
  displayName: `${currency}/${pair}`
42
46
  },
43
47
  target: target,
44
- additionalBorderBottom: index === arr.length - 1
48
+ additionalBorderBottom: index === arr.length - 1,
49
+ setSelectedCurrency: setSelectedCurrency,
50
+ setSelectedPair: setSelectedPair
45
51
  }) : React.createElement(TextCell, {
46
52
  additionalBorderBottom: index === arr.length - 1,
47
53
  emptyIndicator: true
@@ -1 +1 @@
1
- {"version":3,"file":"Main.js","names":["React","Fragment","useEffect","useLiveRatesQuery","CellWithData","TextCell","Main","_ref","instruments","currencies","hasInstruments","length","target","setQuery","createElement","className","map","currency","key","label","index","arr","additionalBorderBottom","pair","loading","record","instrument","displayName","emptyIndicator"],"sources":["../../../src/CurrencyCrossTableWidget/Main.tsx"],"sourcesContent":["import React, { Fragment, useEffect } from 'react';\nimport { useLiveRatesQuery } from '@oanda/labs-widget-common';\nimport { MainProps } from './types';\nimport { CellWithData, TextCell } from './components';\n\nconst Main = ({\n instruments,\n currencies,\n}: MainProps) => {\n const hasInstruments = instruments.length > 0;\n\n const { target, setQuery } = useLiveRatesQuery();\n\n useEffect(() => {\n if (hasInstruments) {\n setQuery({ instruments });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, instruments);\n\n return (\n <div data-testid=\"currency-cross-table-wrapper\" className=\"lw-w-full\">\n <div className=\"lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary\">\n <TextCell />\n {currencies.map(((currency) => <TextCell key={currency} label={currency} />\n ))}\n </div>\n {currencies.map(((currency, index, arr) => (\n <div\n key={currency}\n className=\"lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary\"\n >\n <TextCell\n label={`${currency}`}\n additionalBorderBottom={index === arr.length - 1}\n />\n {arr.map((pair) => (\n <Fragment key={`${currency}_${pair}`}>\n {currency !== pair ? (\n <CellWithData\n loading={false}\n record={{\n instrument: `${currency}_${pair}`,\n displayName: `${currency}/${pair}`,\n }}\n target={target}\n additionalBorderBottom={index === arr.length - 1}\n />\n ) : (\n <TextCell\n additionalBorderBottom={index === arr.length - 1}\n emptyIndicator\n />\n )}\n </Fragment>\n ))}\n </div>\n )))}\n </div>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,SAASC,iBAAiB,QAAQ,2BAA2B;AAE7D,SAASC,YAAY,EAAEC,QAAQ,QAAQ,cAAc;AAErD,MAAMC,IAAI,GAAGC,IAAA,IAGI;EAAA,IAHH;IACZC,WAAW;IACXC;EACS,CAAC,GAAAF,IAAA;EACV,MAAMG,cAAc,GAAGF,WAAW,CAACG,MAAM,GAAG,CAAC;EAE7C,MAAM;IAAEC,MAAM;IAAEC;EAAS,CAAC,GAAGV,iBAAiB,CAAC,CAAC;EAEhDD,SAAS,CAAC,MAAM;IACd,IAAIQ,cAAc,EAAE;MAClBG,QAAQ,CAAC;QAAEL;MAAY,CAA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AG,CAAE;IACjDiB,cAAc;EAAA,CACf,CAEK,CACX,CACE,CACL,CACC,CAAC;AAEV,CAAC;AAED,SAAStB,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"Main.js","names":["React","Fragment","useEffect","useState","useLiveRatesQuery","CellWithData","TextCell","Main","_ref","instruments","currencies","selectedCurrency","setSelectedCurrency","selectedPair","setSelectedPair","hasInstruments","length","target","setQuery","createElement","className","map","pair","key","label","hovered","currency","index","arr","additionalBorderBottom","loading","record","instrument","displayName","emptyIndicator"],"sources":["../../../src/CurrencyCrossTableWidget/Main.tsx"],"sourcesContent":["import React, { Fragment, useEffect, useState } from 'react';\nimport { useLiveRatesQuery } from '@oanda/labs-widget-common';\nimport { MainProps } from './types';\nimport { CellWithData, TextCell } from './components';\n\nconst Main = ({\n instruments,\n currencies,\n}: MainProps) => {\n const [selectedCurrency, setSelectedCurrency] = useState('');\n const [selectedPair, setSelectedPair] = useState('');\n\n const hasInstruments = instruments.length > 0;\n\n const { target, setQuery } = useLiveRatesQuery();\n\n useEffect(() => {\n if (hasInstruments) {\n setQuery({ instruments });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, instruments);\n\n return (\n <div data-testid=\"currency-cross-table-wrapper\" className=\"lw-w-full\">\n <div className=\"lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary\">\n <TextCell />\n {currencies.map(((pair) => (\n <TextCell\n key={pair}\n label={pair}\n hovered={pair === selectedPair}\n />\n )))}\n </div>\n {currencies.map(((currency, index, arr) => (\n <div\n key={currency}\n className=\"lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary\"\n >\n <TextCell\n label={currency}\n additionalBorderBottom={index === arr.length - 1}\n hovered={currency === selectedCurrency}\n />\n {arr.map((pair) => (\n <Fragment key={`${currency}_${pair}`}>\n {currency !== pair ? (\n <CellWithData\n loading={false}\n record={{\n instrument: `${currency}_${pair}`,\n displayName: `${currency}/${pair}`,\n }}\n target={target}\n additionalBorderBottom={index === arr.length - 1}\n setSelectedCurrency={setSelectedCurrency}\n setSelectedPair={setSelectedPair}\n />\n ) : (\n <TextCell\n additionalBorderBottom={index === arr.length - 1}\n emptyIndicator\n />\n )}\n </Fragment>\n ))}\n </div>\n )))}\n </div>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,SAASC,iBAAiB,QAAQ,2BAA2B;AAE7D,SAASC,YAAY,EAAEC,QAAQ,QAAQ,cAAc;AAErD,MAAMC,IAAI,GAAGC,IAAA,IAGI;EAAA,IAHH;IACZC,WAAW;IACXC;EACS,CAAC,GAAAF,IAAA;EACV,MAAM,CAACG,gBAAgB,EAAEC,mBAAmB,CAAC,GAAGT,QAAQ,CAAC,EAAE,CAAC;EAC5D,MAAM,CAACU,YAAY,EAAEC,eAAe,CAAC,GAAGX,QAAQ,CAAC,EAAE,CAAC;EAEpD,MAAMY,cAAc,GAAGN,WAAW,CAACO,MAAM,GAAG,CAAC;EAE7C,MAAM;IAAEC,MAAM;IAAEC;EAAS,CAAC,GAAGd,iBAAiB,CAAC,CAAC;EAEhDF,SAAS,CAAC,MAAM;IACd,IAAIa,cAAc,EAAE;MAClBG,QAAQ,CAAC;QAAET;MAAY,CAAC,CAAC;IAC3B;EAEF,CAAC,EAAEA,WAAW,CAAC;EAEf,OACET,KAAA,CAAAmB,aAAA;IAAK,eAAY,8BAA8B;IAACC,SAAS,EAAC;EAAW,GACnEpB,KAAA,CAAAmB,aAAA;IAAKC,SAAS,EAAC;EAA0E,GACvFpB,KAAA,CAAAmB,aAAA,CAACb,QAAQ,MAAE,CAAC,EACXI,UAAU,CAACW,GAAG,CAAGC,IAAI,IACpBtB,KAAA,CAAAmB,aAAA,CAACb,QAAQ;IACPiB,GAAG,EAAED,IAAK;IACVE,KAAK,EAAEF,IAAK;IACZG,OAAO,EAAEH,IAAI,KAAKT;EAAa,CAChC,CACD,CACC,CAAC,EACLH,UAAU,CAACW,GAAG,CAAE,CAACK,QAAQ,EAAEC,KAAK,EAAEC,GAAG,KACpC5B,KAAA,CAAAmB,aAAA;IACEI,GAAG,EAAEG,QAAS;IACdN,SAAS,EAAC;EAA0E,GAEpFpB,KAAA,CAAAmB,aAAA,CAACb,QAAQ;IACPkB,KAAK,EAAEE,QAAS;IAChBG,sBAAsB,EAAEF,KAAK,KAAKC,GAAG,CAACZ,MAAM,GAAG,CAAE;IACjDS,OAAO,EAAEC,QAAQ,KAAKf;EAAiB,CACxC,CAAC,EACDiB,GAAG,CAACP,GAAG,CAAEC,IAAI,IACZtB,KAAA,CAAAmB,aAAA,CAAClB,QAAQ;IAACsB,GAAG,EAAE,GAAGG,QAAQ,IAAIJ,IAAI;EAAG,GAClCI,QAAQ,KAAKJ,IAAI,GAChBtB,KAAA,CAAAmB,aAAA,CAACd,YAAY;IACXyB,OAAO,EAAE,KAAM;IACfC,MAAM,EAAE;MACNC,UAAU,EAAE,GAAGN,QAAQ,IAAIJ,IAAI,EAAE;MACjCW,WAAW,EAAE,GAAGP,QAAQ,IAAIJ,IAAI;IAClC,CAAE;IACFL,MAAM,EAAEA,MAAO;IACfY,sBAAsB,EAAEF,KAAK,KAAKC,GAAG,CAACZ,MAAM,GAAG,CAAE;IACjDJ,mBAAmB,EAAEA,mBAAoB;IACzCE,eAAe,EAAEA;EAAgB,CAClC,CAAC,GAEFd,KAAA,CAAAmB,aAAA,CAACb,QAAQ;IACPuB,sBAAsB,EAAEF,KAAK,KAAKC,GAAG,CAACZ,MAAM,GAAG,CAAE;IACjDkB,cAAc;EAAA,CACf,CAEK,CACX,CACE,CACL,CACC,CAAC;AAEV,CAAC;AAED,SAAS3B,IAAI","ignoreList":[]}
@@ -6,12 +6,18 @@ const Cell = _ref => {
6
6
  children,
7
7
  isError,
8
8
  isLoading,
9
- additionalBorderBottom
9
+ additionalBorderBottom,
10
+ hovered,
11
+ mouseEnterHandler,
12
+ mouseLeaveHandler
10
13
  } = _ref;
11
14
  return React.createElement("div", {
12
15
  className: classnames('lw-flex lw-h-[inherit] lw-flex-1 lw-items-center lw-justify-center lw-border-r lw-border-solid lw-border-border-primary', {
13
- 'lw-border-b': additionalBorderBottom
14
- })
16
+ 'lw-border-b': additionalBorderBottom,
17
+ 'lw-font-semibold': hovered
18
+ }),
19
+ onMouseEnter: mouseEnterHandler,
20
+ onMouseLeave: mouseLeaveHandler
15
21
  }, isLoading && React.createElement("div", {
16
22
  className: "lw-px-3 lw-py-3.5"
17
23
  }, CELL_LOADING_VALUE), !isLoading && !isError && children, !isLoading && isError && React.createElement("span", null, CELL_EMPTY_VALUE));
@@ -1 +1 @@
1
- {"version":3,"file":"Cell.js","names":["React","classnames","CELL_EMPTY_VALUE","CELL_LOADING_VALUE","Cell","_ref","children","isError","isLoading","additionalBorderBottom","createElement","className"],"sources":["../../../../src/CurrencyCrossTableWidget/components/Cell.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { CellProps } from './types';\nimport { CELL_EMPTY_VALUE, CELL_LOADING_VALUE } from '../constant';\n\nconst Cell = ({\n children, isError, isLoading, additionalBorderBottom,\n}: CellProps) => (\n <div className={classnames('lw-flex lw-h-[inherit] lw-flex-1 lw-items-center lw-justify-center lw-border-r lw-border-solid lw-border-border-primary', {\n 'lw-border-b': additionalBorderBottom,\n })}\n >\n {isLoading && <div className=\"lw-px-3 lw-py-3.5\">{CELL_LOADING_VALUE}</div>}\n {!isLoading && !isError && children}\n {!isLoading && isError && (\n <span>{CELL_EMPTY_VALUE}</span>\n )}\n </div>\n);\n\nexport { Cell };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,aAAa;AAElE,MAAMC,IAAI,GAAGC,IAAA;EAAA,IAAC;IACZC,QAAQ;IAAEC,OAAO;IAAEC,SAAS;IAAEC;EACrB,CAAC,GAAAJ,IAAA;EAAA,OACVL,KAAA,CAAAU,aAAA;IAAKC,SAAS,EAAEV,UAAU,CAAC,yHAAyH,EAAE;MACpJ,aAAa,EAAEQ;IACjB,CAAC;EAAE,GAEAD,SAAS,IAAIR,KAAA,CAAAU,aAAA;IAAKC,SAAS,EAAC;EAAmB,GAAER,kBAAwB,CAAC,EAC1E,CAACK,SAAS,IAAI,CAACD,OAAO,IAAID,QAAQ,EAClC,CAACE,SAAS,IAAID,OAAO,IACpBP,KAAA,CAAAU,aAAA,eAAOR,gBAAuB,CAE7B,CAAC;AAAA,CACP;AAED,SAASE,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"Cell.js","names":["React","classnames","CELL_EMPTY_VALUE","CELL_LOADING_VALUE","Cell","_ref","children","isError","isLoading","additionalBorderBottom","hovered","mouseEnterHandler","mouseLeaveHandler","createElement","className","onMouseEnter","onMouseLeave"],"sources":["../../../../src/CurrencyCrossTableWidget/components/Cell.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { CellProps } from './types';\nimport { CELL_EMPTY_VALUE, CELL_LOADING_VALUE } from '../constant';\n\nconst Cell = ({\n children,\n isError,\n isLoading,\n additionalBorderBottom,\n hovered,\n mouseEnterHandler,\n mouseLeaveHandler,\n}: CellProps) => (\n <div\n className={classnames('lw-flex lw-h-[inherit] lw-flex-1 lw-items-center lw-justify-center lw-border-r lw-border-solid lw-border-border-primary', {\n 'lw-border-b': additionalBorderBottom,\n 'lw-font-semibold': hovered,\n })}\n onMouseEnter={mouseEnterHandler}\n onMouseLeave={mouseLeaveHandler}\n >\n {isLoading && <div className=\"lw-px-3 lw-py-3.5\">{CELL_LOADING_VALUE}</div>}\n {!isLoading && !isError && children}\n {!isLoading && isError && (\n <span>{CELL_EMPTY_VALUE}</span>\n )}\n </div>\n);\n\nexport { Cell };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,aAAa;AAElE,MAAMC,IAAI,GAAGC,IAAA;EAAA,IAAC;IACZC,QAAQ;IACRC,OAAO;IACPC,SAAS;IACTC,sBAAsB;IACtBC,OAAO;IACPC,iBAAiB;IACjBC;EACS,CAAC,GAAAP,IAAA;EAAA,OACVL,KAAA,CAAAa,aAAA;IACEC,SAAS,EAAEb,UAAU,CAAC,yHAAyH,EAAE;MAC/I,aAAa,EAAEQ,sBAAsB;MACrC,kBAAkB,EAAEC;IACtB,CAAC,CAAE;IACHK,YAAY,EAAEJ,iBAAkB;IAChCK,YAAY,EAAEJ;EAAkB,GAE/BJ,SAAS,IAAIR,KAAA,CAAAa,aAAA;IAAKC,SAAS,EAAC;EAAmB,GAAEX,kBAAwB,CAAC,EAC1E,CAACK,SAAS,IAAI,CAACD,OAAO,IAAID,QAAQ,EAClC,CAACE,SAAS,IAAID,OAAO,IACpBP,KAAA,CAAAa,aAAA,eAAOX,gBAAuB,CAE7B,CAAC;AAAA,CACP;AAED,SAASE,IAAI","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { Price } from '@oanda/labs-widget-common';
3
3
  import { useRecords } from '../utils';
4
4
  import { Cell } from './Cell';
@@ -7,17 +7,35 @@ const CellWithData = _ref => {
7
7
  loading,
8
8
  record,
9
9
  target,
10
- additionalBorderBottom
10
+ additionalBorderBottom,
11
+ setSelectedCurrency,
12
+ setSelectedPair
11
13
  } = _ref;
14
+ const [hovered, setHovered] = useState(false);
12
15
  const {
13
16
  updatedRecord,
14
17
  error
15
18
  } = useRecords(record, record.instrument ? target : null);
16
19
  const checkLoading = id => loading || !error && updatedRecord?.[id] === undefined;
20
+ const handleMouseEnter = () => {
21
+ setHovered(true);
22
+ const currency = record.instrument.substring(0, 3);
23
+ const pair = record.instrument.substring(record.instrument.length - 3);
24
+ setSelectedCurrency(currency);
25
+ setSelectedPair(pair);
26
+ };
27
+ const handleMouseLeave = () => {
28
+ setHovered(false);
29
+ setSelectedCurrency('');
30
+ setSelectedPair('');
31
+ };
17
32
  return React.createElement(Cell, {
18
33
  isLoading: checkLoading('buy'),
19
34
  isError: !!error,
20
- additionalBorderBottom: additionalBorderBottom
35
+ additionalBorderBottom: additionalBorderBottom,
36
+ hovered: hovered,
37
+ mouseEnterHandler: handleMouseEnter,
38
+ mouseLeaveHandler: handleMouseLeave
21
39
  }, React.createElement(Price, {
22
40
  priceMovement: updatedRecord.buyPriceMovement,
23
41
  movementIndicator: "background"
@@ -1 +1 @@
1
- {"version":3,"file":"CellWithData.js","names":["React","Price","useRecords","Cell","CellWithData","_ref","loading","record","target","additionalBorderBottom","updatedRecord","error","instrument","checkLoading","id","undefined","createElement","isLoading","isError","priceMovement","buyPriceMovement","movementIndicator","buy","toFixed","displayPrecision"],"sources":["../../../../src/CurrencyCrossTableWidget/components/CellWithData.tsx"],"sourcesContent":["import React from 'react';\nimport { Price } from '@oanda/labs-widget-common';\nimport { useRecords } from '../utils';\nimport { CellWithDataProps } from './types';\nimport { Cell } from './Cell';\n\nconst CellWithData = ({\n loading,\n record,\n target,\n additionalBorderBottom,\n}: CellWithDataProps) => {\n const { updatedRecord, error } = useRecords(record, record.instrument ? target : null);\n\n const checkLoading = (id: string) => loading || (!error && updatedRecord?.[id] === undefined);\n\n return (\n <Cell\n isLoading={checkLoading('buy')}\n isError={!!error}\n additionalBorderBottom={additionalBorderBottom}\n >\n <Price priceMovement={updatedRecord.buyPriceMovement} movementIndicator=\"background\">\n <span>{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}</span>\n </Price>\n </Cell>\n );\n};\n\nexport { CellWithData };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,IAAI,QAAQ,QAAQ;AAE7B,MAAMC,YAAY,GAAGC,IAAA,IAKI;EAAA,IALH;IACpBC,OAAO;IACPC,MAAM;IACNC,MAAM;IACNC;EACiB,CAAC,GAAAJ,IAAA;EAClB,MAAM;IAAEK,aAAa;IAAEC;EAAM,CAAC,GAAGT,UAAU,CAACK,MAAM,EAAEA,MAAM,CAACK,UAAU,GAAGJ,MAAM,GAAG,IAAI,CAAC;EAEtF,MAAMK,YAAY,GAAIC,EAAU,IAAKR,OAAO,IAAK,CAACK,KAAK,IAAID,aAAa,GAAGI,EAAE,CAAC,KAAKC,SAAU;EAE7F,OACEf,KAAA,CAAAgB,aAAA,CAACb,IAAI;IACHc,SAAS,EAAEJ,YAAY,CAAC,KAAK,CAAE;IAC/BK,OAAO,EAAE,CAAC,CAACP,KAAM;IACjBF,sBAAsB,EAAEA;EAAuB,GAE/CT,KAAA,CAAAgB,aAAA,CAACf,KAAK;IAACkB,aAAa,EAAET,aAAa,CAACU,gBAAiB;IAACC,iBAAiB,EAAC;EAAY,GAClFrB,KAAA,CAAAgB,aAAA,eAAON,aAAa,CAACY,GAAG,EAAEC,OAAO,CAACb,aAAa,CAACc,gBAAgB,CAAQ,CACnE,CACH,CAAC;AAEX,CAAC;AAED,SAASpB,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"CellWithData.js","names":["React","useState","Price","useRecords","Cell","CellWithData","_ref","loading","record","target","additionalBorderBottom","setSelectedCurrency","setSelectedPair","hovered","setHovered","updatedRecord","error","instrument","checkLoading","id","undefined","handleMouseEnter","currency","substring","pair","length","handleMouseLeave","createElement","isLoading","isError","mouseEnterHandler","mouseLeaveHandler","priceMovement","buyPriceMovement","movementIndicator","buy","toFixed","displayPrecision"],"sources":["../../../../src/CurrencyCrossTableWidget/components/CellWithData.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport { Price } from '@oanda/labs-widget-common';\nimport { useRecords } from '../utils';\nimport { CellWithDataProps } from './types';\nimport { Cell } from './Cell';\n\nconst CellWithData = ({\n loading,\n record,\n target,\n additionalBorderBottom,\n setSelectedCurrency,\n setSelectedPair,\n}: CellWithDataProps) => {\n const [hovered, setHovered] = useState(false);\n const { updatedRecord, error } = useRecords(record, record.instrument ? target : null);\n\n const checkLoading = (id: string) => loading || (!error && updatedRecord?.[id] === undefined);\n\n const handleMouseEnter = () => {\n setHovered(true);\n\n const currency = record.instrument.substring(0, 3);\n const pair = record.instrument.substring(record.instrument.length - 3);\n\n setSelectedCurrency(currency);\n setSelectedPair(pair);\n };\n\n const handleMouseLeave = () => {\n setHovered(false);\n\n setSelectedCurrency('');\n setSelectedPair('');\n };\n\n return (\n <Cell\n isLoading={checkLoading('buy')}\n isError={!!error}\n additionalBorderBottom={additionalBorderBottom}\n hovered={hovered}\n mouseEnterHandler={handleMouseEnter}\n mouseLeaveHandler={handleMouseLeave}\n >\n <Price priceMovement={updatedRecord.buyPriceMovement} movementIndicator=\"background\">\n <span>{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}</span>\n </Price>\n </Cell>\n );\n};\n\nexport { CellWithData };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,IAAI,QAAQ,QAAQ;AAE7B,MAAMC,YAAY,GAAGC,IAAA,IAOI;EAAA,IAPH;IACpBC,OAAO;IACPC,MAAM;IACNC,MAAM;IACNC,sBAAsB;IACtBC,mBAAmB;IACnBC;EACiB,CAAC,GAAAN,IAAA;EAClB,MAAM,CAACO,OAAO,EAAEC,UAAU,CAAC,GAAGb,QAAQ,CAAC,KAAK,CAAC;EAC7C,MAAM;IAAEc,aAAa;IAAEC;EAAM,CAAC,GAAGb,UAAU,CAACK,MAAM,EAAEA,MAAM,CAACS,UAAU,GAAGR,MAAM,GAAG,IAAI,CAAC;EAEtF,MAAMS,YAAY,GAAIC,EAAU,IAAKZ,OAAO,IAAK,CAACS,KAAK,IAAID,aAAa,GAAGI,EAAE,CAAC,KAAKC,SAAU;EAE7F,MAAMC,gBAAgB,GAAGA,CAAA,KAAM;IAC7BP,UAAU,CAAC,IAAI,CAAC;IAEhB,MAAMQ,QAAQ,GAAGd,MAAM,CAACS,UAAU,CAACM,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IAClD,MAAMC,IAAI,GAAGhB,MAAM,CAACS,UAAU,CAACM,SAAS,CAACf,MAAM,CAACS,UAAU,CAACQ,MAAM,GAAG,CAAC,CAAC;IAEtEd,mBAAmB,CAACW,QAAQ,CAAC;IAC7BV,eAAe,CAACY,IAAI,CAAC;EACvB,CAAC;EAED,MAAME,gBAAgB,GAAGA,CAAA,KAAM;IAC7BZ,UAAU,CAAC,KAAK,CAAC;IAEjBH,mBAAmB,CAAC,EAAE,CAAC;IACvBC,eAAe,CAAC,EAAE,CAAC;EACrB,CAAC;EAED,OACEZ,KAAA,CAAA2B,aAAA,CAACvB,IAAI;IACHwB,SAAS,EAAEV,YAAY,CAAC,KAAK,CAAE;IAC/BW,OAAO,EAAE,CAAC,CAACb,KAAM;IACjBN,sBAAsB,EAAEA,sBAAuB;IAC/CG,OAAO,EAAEA,OAAQ;IACjBiB,iBAAiB,EAAET,gBAAiB;IACpCU,iBAAiB,EAAEL;EAAiB,GAEpC1B,KAAA,CAAA2B,aAAA,CAACzB,KAAK;IAAC8B,aAAa,EAAEjB,aAAa,CAACkB,gBAAiB;IAACC,iBAAiB,EAAC;EAAY,GAClFlC,KAAA,CAAA2B,aAAA,eAAOZ,aAAa,CAACoB,GAAG,EAAEC,OAAO,CAACrB,aAAa,CAACsB,gBAAgB,CAAQ,CACnE,CACH,CAAC;AAEX,CAAC;AAED,SAAShC,YAAY","ignoreList":[]}
@@ -4,12 +4,14 @@ const TextCell = _ref => {
4
4
  let {
5
5
  label,
6
6
  emptyIndicator,
7
- additionalBorderBottom
7
+ additionalBorderBottom,
8
+ hovered
8
9
  } = _ref;
9
10
  return React.createElement("span", {
10
11
  className: classnames('lw-flex-1 lw-border-r lw-border-solid lw-border-border-primary lw-py-3.5 lw-text-center', {
11
12
  'lw-border-b': additionalBorderBottom,
12
- 'lw-bg-border-primary': emptyIndicator
13
+ 'lw-bg-border-primary': emptyIndicator,
14
+ 'lw-font-semibold': hovered
13
15
  })
14
16
  }, label);
15
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"TextCell.js","names":["React","classnames","TextCell","_ref","label","emptyIndicator","additionalBorderBottom","createElement","className"],"sources":["../../../../src/CurrencyCrossTableWidget/components/TextCell.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { TextCellProps } from './types';\n\nconst TextCell = ({\n label,\n emptyIndicator,\n additionalBorderBottom,\n}: TextCellProps) => (\n <span className={classnames('lw-flex-1 lw-border-r lw-border-solid lw-border-border-primary lw-py-3.5 lw-text-center', {\n 'lw-border-b': additionalBorderBottom,\n 'lw-bg-border-primary': emptyIndicator,\n })}\n >\n {label}\n </span>\n);\n\nexport { TextCell };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,MAAMC,QAAQ,GAAGC,IAAA;EAAA,IAAC;IAChBC,KAAK;IACLC,cAAc;IACdC;EACa,CAAC,GAAAH,IAAA;EAAA,OACdH,KAAA,CAAAO,aAAA;IAAMC,SAAS,EAAEP,UAAU,CAAC,yFAAyF,EAAE;MACrH,aAAa,EAAEK,sBAAsB;MACrC,sBAAsB,EAAED;IAC1B,CAAC;EAAE,GAEAD,KACG,CAAC;AAAA,CACR;AAED,SAASF,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"TextCell.js","names":["React","classnames","TextCell","_ref","label","emptyIndicator","additionalBorderBottom","hovered","createElement","className"],"sources":["../../../../src/CurrencyCrossTableWidget/components/TextCell.tsx"],"sourcesContent":["import React from 'react';\nimport classnames from 'classnames';\nimport { TextCellProps } from './types';\n\nconst TextCell = ({\n label,\n emptyIndicator,\n additionalBorderBottom,\n hovered,\n}: TextCellProps) => (\n <span className={classnames('lw-flex-1 lw-border-r lw-border-solid lw-border-border-primary lw-py-3.5 lw-text-center', {\n 'lw-border-b': additionalBorderBottom,\n 'lw-bg-border-primary': emptyIndicator,\n 'lw-font-semibold': hovered,\n })}\n >\n {label}\n </span>\n);\n\nexport { TextCell };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,UAAU,MAAM,YAAY;AAGnC,MAAMC,QAAQ,GAAGC,IAAA;EAAA,IAAC;IAChBC,KAAK;IACLC,cAAc;IACdC,sBAAsB;IACtBC;EACa,CAAC,GAAAJ,IAAA;EAAA,OACdH,KAAA,CAAAQ,aAAA;IAAMC,SAAS,EAAER,UAAU,CAAC,yFAAyF,EAAE;MACrH,aAAa,EAAEK,sBAAsB;MACrC,sBAAsB,EAAED,cAAc;MACtC,kBAAkB,EAAEE;IACtB,CAAC;EAAE,GAEAH,KACG,CAAC;AAAA,CACR;AAED,SAASF,QAAQ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../src/CurrencyCrossTableWidget/components/types.ts"],"sourcesContent":["import { DataRecord, LoaderSize } from '@oanda/labs-widget-common';\n\nexport interface CellWithDataProps {\n loading: boolean;\n record: DataRecord;\n target: EventTarget | null;\n additionalBorderBottom? : boolean;\n}\n\nexport interface CellProps {\n children: React.ReactNode;\n isLoading?: boolean;\n isError?: boolean;\n loaderSize?: LoaderSize;\n additionalBorderBottom? : boolean;\n}\n\nexport interface TextCellProps {\n label?: string;\n emptyIndicator?: boolean;\n additionalBorderBottom? : boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../src/CurrencyCrossTableWidget/components/types.ts"],"sourcesContent":["import { DataRecord, LoaderSize } from '@oanda/labs-widget-common';\n\nexport interface CellWithDataProps {\n loading: boolean;\n record: DataRecord;\n target: EventTarget | null;\n additionalBorderBottom? : boolean;\n setSelectedCurrency: React.Dispatch<React.SetStateAction<string>>;\n setSelectedPair: React.Dispatch<React.SetStateAction<string>>;\n}\n\nexport interface CellProps {\n children: React.ReactNode;\n isLoading?: boolean;\n isError?: boolean;\n loaderSize?: LoaderSize;\n additionalBorderBottom? : boolean;\n hovered: boolean;\n mouseEnterHandler: () => void;\n mouseLeaveHandler: () => void;\n}\n\nexport interface TextCellProps {\n label?: string;\n emptyIndicator?: boolean;\n additionalBorderBottom? : boolean;\n hovered?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CellProps } from './types';
3
- declare const Cell: ({ children, isError, isLoading, additionalBorderBottom, }: CellProps) => React.JSX.Element;
3
+ declare const Cell: ({ children, isError, isLoading, additionalBorderBottom, hovered, mouseEnterHandler, mouseLeaveHandler, }: CellProps) => React.JSX.Element;
4
4
  export { Cell };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { CellWithDataProps } from './types';
3
- declare const CellWithData: ({ loading, record, target, additionalBorderBottom, }: CellWithDataProps) => React.JSX.Element;
3
+ declare const CellWithData: ({ loading, record, target, additionalBorderBottom, setSelectedCurrency, setSelectedPair, }: CellWithDataProps) => React.JSX.Element;
4
4
  export { CellWithData };
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import { TextCellProps } from './types';
3
- declare const TextCell: ({ label, emptyIndicator, additionalBorderBottom, }: TextCellProps) => React.JSX.Element;
3
+ declare const TextCell: ({ label, emptyIndicator, additionalBorderBottom, hovered, }: TextCellProps) => React.JSX.Element;
4
4
  export { TextCell };
@@ -4,6 +4,8 @@ export interface CellWithDataProps {
4
4
  record: DataRecord;
5
5
  target: EventTarget | null;
6
6
  additionalBorderBottom?: boolean;
7
+ setSelectedCurrency: React.Dispatch<React.SetStateAction<string>>;
8
+ setSelectedPair: React.Dispatch<React.SetStateAction<string>>;
7
9
  }
8
10
  export interface CellProps {
9
11
  children: React.ReactNode;
@@ -11,9 +13,13 @@ export interface CellProps {
11
13
  isError?: boolean;
12
14
  loaderSize?: LoaderSize;
13
15
  additionalBorderBottom?: boolean;
16
+ hovered: boolean;
17
+ mouseEnterHandler: () => void;
18
+ mouseLeaveHandler: () => void;
14
19
  }
15
20
  export interface TextCellProps {
16
21
  label?: string;
17
22
  emptyIndicator?: boolean;
18
23
  additionalBorderBottom?: boolean;
24
+ hovered?: boolean;
19
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-currency-cross-table",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Labs Currency Cross Table",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
@@ -9,8 +9,8 @@
9
9
  "author": "OANDA",
10
10
  "license": "UNLICENSED",
11
11
  "dependencies": {
12
- "@oanda/labs-widget-common": "^1.0.150",
12
+ "@oanda/labs-widget-common": "^1.0.151",
13
13
  "@oanda/mono-i18n": "10.0.1"
14
14
  },
15
- "gitHead": "bc89a81b65b183de5f94a884b9d338b4b06e582a"
15
+ "gitHead": "539c35bc4096ba9f6cc3ce08d803ca2551a02616"
16
16
  }
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useEffect } from 'react';
1
+ import React, { Fragment, useEffect, useState } from 'react';
2
2
  import { useLiveRatesQuery } from '@oanda/labs-widget-common';
3
3
  import { MainProps } from './types';
4
4
  import { CellWithData, TextCell } from './components';
@@ -7,6 +7,9 @@ const Main = ({
7
7
  instruments,
8
8
  currencies,
9
9
  }: MainProps) => {
10
+ const [selectedCurrency, setSelectedCurrency] = useState('');
11
+ const [selectedPair, setSelectedPair] = useState('');
12
+
10
13
  const hasInstruments = instruments.length > 0;
11
14
 
12
15
  const { target, setQuery } = useLiveRatesQuery();
@@ -22,8 +25,13 @@ const Main = ({
22
25
  <div data-testid="currency-cross-table-wrapper" className="lw-w-full">
23
26
  <div className="lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary">
24
27
  <TextCell />
25
- {currencies.map(((currency) => <TextCell key={currency} label={currency} />
26
- ))}
28
+ {currencies.map(((pair) => (
29
+ <TextCell
30
+ key={pair}
31
+ label={pair}
32
+ hovered={pair === selectedPair}
33
+ />
34
+ )))}
27
35
  </div>
28
36
  {currencies.map(((currency, index, arr) => (
29
37
  <div
@@ -31,8 +39,9 @@ const Main = ({
31
39
  className="lw-flex lw-border-l lw-border-t lw-border-solid lw-border-border-primary"
32
40
  >
33
41
  <TextCell
34
- label={`${currency}`}
42
+ label={currency}
35
43
  additionalBorderBottom={index === arr.length - 1}
44
+ hovered={currency === selectedCurrency}
36
45
  />
37
46
  {arr.map((pair) => (
38
47
  <Fragment key={`${currency}_${pair}`}>
@@ -45,6 +54,8 @@ const Main = ({
45
54
  }}
46
55
  target={target}
47
56
  additionalBorderBottom={index === arr.length - 1}
57
+ setSelectedCurrency={setSelectedCurrency}
58
+ setSelectedPair={setSelectedPair}
48
59
  />
49
60
  ) : (
50
61
  <TextCell
@@ -4,11 +4,21 @@ import { CellProps } from './types';
4
4
  import { CELL_EMPTY_VALUE, CELL_LOADING_VALUE } from '../constant';
5
5
 
6
6
  const Cell = ({
7
- children, isError, isLoading, additionalBorderBottom,
7
+ children,
8
+ isError,
9
+ isLoading,
10
+ additionalBorderBottom,
11
+ hovered,
12
+ mouseEnterHandler,
13
+ mouseLeaveHandler,
8
14
  }: CellProps) => (
9
- <div className={classnames('lw-flex lw-h-[inherit] lw-flex-1 lw-items-center lw-justify-center lw-border-r lw-border-solid lw-border-border-primary', {
10
- 'lw-border-b': additionalBorderBottom,
11
- })}
15
+ <div
16
+ className={classnames('lw-flex lw-h-[inherit] lw-flex-1 lw-items-center lw-justify-center lw-border-r lw-border-solid lw-border-border-primary', {
17
+ 'lw-border-b': additionalBorderBottom,
18
+ 'lw-font-semibold': hovered,
19
+ })}
20
+ onMouseEnter={mouseEnterHandler}
21
+ onMouseLeave={mouseLeaveHandler}
12
22
  >
13
23
  {isLoading && <div className="lw-px-3 lw-py-3.5">{CELL_LOADING_VALUE}</div>}
14
24
  {!isLoading && !isError && children}
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { Price } from '@oanda/labs-widget-common';
3
3
  import { useRecords } from '../utils';
4
4
  import { CellWithDataProps } from './types';
@@ -9,16 +9,39 @@ const CellWithData = ({
9
9
  record,
10
10
  target,
11
11
  additionalBorderBottom,
12
+ setSelectedCurrency,
13
+ setSelectedPair,
12
14
  }: CellWithDataProps) => {
15
+ const [hovered, setHovered] = useState(false);
13
16
  const { updatedRecord, error } = useRecords(record, record.instrument ? target : null);
14
17
 
15
18
  const checkLoading = (id: string) => loading || (!error && updatedRecord?.[id] === undefined);
16
19
 
20
+ const handleMouseEnter = () => {
21
+ setHovered(true);
22
+
23
+ const currency = record.instrument.substring(0, 3);
24
+ const pair = record.instrument.substring(record.instrument.length - 3);
25
+
26
+ setSelectedCurrency(currency);
27
+ setSelectedPair(pair);
28
+ };
29
+
30
+ const handleMouseLeave = () => {
31
+ setHovered(false);
32
+
33
+ setSelectedCurrency('');
34
+ setSelectedPair('');
35
+ };
36
+
17
37
  return (
18
38
  <Cell
19
39
  isLoading={checkLoading('buy')}
20
40
  isError={!!error}
21
41
  additionalBorderBottom={additionalBorderBottom}
42
+ hovered={hovered}
43
+ mouseEnterHandler={handleMouseEnter}
44
+ mouseLeaveHandler={handleMouseLeave}
22
45
  >
23
46
  <Price priceMovement={updatedRecord.buyPriceMovement} movementIndicator="background">
24
47
  <span>{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}</span>
@@ -6,10 +6,12 @@ const TextCell = ({
6
6
  label,
7
7
  emptyIndicator,
8
8
  additionalBorderBottom,
9
+ hovered,
9
10
  }: TextCellProps) => (
10
11
  <span className={classnames('lw-flex-1 lw-border-r lw-border-solid lw-border-border-primary lw-py-3.5 lw-text-center', {
11
12
  'lw-border-b': additionalBorderBottom,
12
13
  'lw-bg-border-primary': emptyIndicator,
14
+ 'lw-font-semibold': hovered,
13
15
  })}
14
16
  >
15
17
  {label}
@@ -5,6 +5,8 @@ export interface CellWithDataProps {
5
5
  record: DataRecord;
6
6
  target: EventTarget | null;
7
7
  additionalBorderBottom? : boolean;
8
+ setSelectedCurrency: React.Dispatch<React.SetStateAction<string>>;
9
+ setSelectedPair: React.Dispatch<React.SetStateAction<string>>;
8
10
  }
9
11
 
10
12
  export interface CellProps {
@@ -13,10 +15,14 @@ export interface CellProps {
13
15
  isError?: boolean;
14
16
  loaderSize?: LoaderSize;
15
17
  additionalBorderBottom? : boolean;
18
+ hovered: boolean;
19
+ mouseEnterHandler: () => void;
20
+ mouseLeaveHandler: () => void;
16
21
  }
17
22
 
18
23
  export interface TextCellProps {
19
24
  label?: string;
20
25
  emptyIndicator?: boolean;
21
26
  additionalBorderBottom? : boolean;
27
+ hovered?: boolean;
22
28
  }