@oanda/labs-live-rates-table-widget 1.0.48 → 1.0.50

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 (108) hide show
  1. package/CHANGELOG.md +404 -0
  2. package/dist/main/LiveRatesTableWidget/Main.js +26 -33
  3. package/dist/main/LiveRatesTableWidget/Main.js.map +1 -1
  4. package/dist/main/LiveRatesTableWidget/config.js +12 -7
  5. package/dist/main/LiveRatesTableWidget/config.js.map +1 -1
  6. package/dist/main/LiveRatesTableWidget/constant.js +2 -2
  7. package/dist/main/LiveRatesTableWidget/constant.js.map +1 -1
  8. package/dist/main/LiveRatesTableWidget/types.js +0 -10
  9. package/dist/main/LiveRatesTableWidget/types.js.map +1 -1
  10. package/dist/main/LiveRatesTableWidget/utils.js +8 -49
  11. package/dist/main/LiveRatesTableWidget/utils.js.map +1 -1
  12. package/dist/module/LiveRatesTableWidget/Main.js +28 -35
  13. package/dist/module/LiveRatesTableWidget/Main.js.map +1 -1
  14. package/dist/module/LiveRatesTableWidget/config.js +13 -9
  15. package/dist/module/LiveRatesTableWidget/config.js.map +1 -1
  16. package/dist/module/LiveRatesTableWidget/constant.js +2 -2
  17. package/dist/module/LiveRatesTableWidget/constant.js.map +1 -1
  18. package/dist/module/LiveRatesTableWidget/types.js +0 -9
  19. package/dist/module/LiveRatesTableWidget/types.js.map +1 -1
  20. package/dist/module/LiveRatesTableWidget/utils.js +8 -47
  21. package/dist/module/LiveRatesTableWidget/utils.js.map +1 -1
  22. package/dist/types/LiveRatesTableWidget/config.d.ts +9 -28
  23. package/dist/types/LiveRatesTableWidget/constant.d.ts +2 -2
  24. package/dist/types/LiveRatesTableWidget/types.d.ts +6 -47
  25. package/dist/types/LiveRatesTableWidget/utils.d.ts +4 -15
  26. package/package.json +3 -3
  27. package/src/LiveRatesTableWidget/Main.tsx +44 -51
  28. package/src/LiveRatesTableWidget/config.ts +27 -10
  29. package/src/LiveRatesTableWidget/constant.ts +6 -6
  30. package/src/LiveRatesTableWidget/types.tsx +11 -53
  31. package/src/LiveRatesTableWidget/utils.ts +21 -65
  32. package/test/mocks.ts +1 -16
  33. package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js +0 -96
  34. package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +0 -1
  35. package/dist/main/LiveRatesTableWidget/components/CardWithData/index.js +0 -17
  36. package/dist/main/LiveRatesTableWidget/components/CardWithData/index.js.map +0 -1
  37. package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js +0 -37
  38. package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js.map +0 -1
  39. package/dist/main/LiveRatesTableWidget/components/Cards/index.js +0 -17
  40. package/dist/main/LiveRatesTableWidget/components/Cards/index.js.map +0 -1
  41. package/dist/main/LiveRatesTableWidget/components/Cards/types.js +0 -6
  42. package/dist/main/LiveRatesTableWidget/components/Cards/types.js.map +0 -1
  43. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +0 -46
  44. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
  45. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/index.js +0 -17
  46. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/index.js.map +0 -1
  47. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js +0 -6
  48. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js.map +0 -1
  49. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js +0 -20
  50. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +0 -1
  51. package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js +0 -104
  52. package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +0 -1
  53. package/dist/main/LiveRatesTableWidget/components/RowWithData/index.js +0 -17
  54. package/dist/main/LiveRatesTableWidget/components/RowWithData/index.js.map +0 -1
  55. package/dist/main/LiveRatesTableWidget/components/index.js +0 -50
  56. package/dist/main/LiveRatesTableWidget/components/index.js.map +0 -1
  57. package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js +0 -89
  58. package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +0 -1
  59. package/dist/module/LiveRatesTableWidget/components/CardWithData/index.js +0 -2
  60. package/dist/module/LiveRatesTableWidget/components/CardWithData/index.js.map +0 -1
  61. package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js +0 -30
  62. package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js.map +0 -1
  63. package/dist/module/LiveRatesTableWidget/components/Cards/index.js +0 -2
  64. package/dist/module/LiveRatesTableWidget/components/Cards/index.js.map +0 -1
  65. package/dist/module/LiveRatesTableWidget/components/Cards/types.js +0 -2
  66. package/dist/module/LiveRatesTableWidget/components/Cards/types.js.map +0 -1
  67. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +0 -39
  68. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
  69. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/index.js +0 -2
  70. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/index.js.map +0 -1
  71. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js +0 -2
  72. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js.map +0 -1
  73. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js +0 -13
  74. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +0 -1
  75. package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js +0 -97
  76. package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +0 -1
  77. package/dist/module/LiveRatesTableWidget/components/RowWithData/index.js +0 -2
  78. package/dist/module/LiveRatesTableWidget/components/RowWithData/index.js.map +0 -1
  79. package/dist/module/LiveRatesTableWidget/components/index.js +0 -5
  80. package/dist/module/LiveRatesTableWidget/components/index.js.map +0 -1
  81. package/dist/types/LiveRatesTableWidget/components/CardWithData/CardWithData.d.ts +0 -4
  82. package/dist/types/LiveRatesTableWidget/components/CardWithData/index.d.ts +0 -1
  83. package/dist/types/LiveRatesTableWidget/components/Cards/Cards.d.ts +0 -4
  84. package/dist/types/LiveRatesTableWidget/components/Cards/index.d.ts +0 -1
  85. package/dist/types/LiveRatesTableWidget/components/Cards/types.d.ts +0 -12
  86. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.d.ts +0 -4
  87. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/index.d.ts +0 -1
  88. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/types.d.ts +0 -11
  89. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/utils.d.ts +0 -1
  90. package/dist/types/LiveRatesTableWidget/components/RowWithData/RowWithData.d.ts +0 -4
  91. package/dist/types/LiveRatesTableWidget/components/RowWithData/index.d.ts +0 -1
  92. package/dist/types/LiveRatesTableWidget/components/index.d.ts +0 -4
  93. package/src/LiveRatesTableWidget/components/CardWithData/CardWithData.tsx +0 -133
  94. package/src/LiveRatesTableWidget/components/CardWithData/index.ts +0 -1
  95. package/src/LiveRatesTableWidget/components/Cards/Cards.tsx +0 -44
  96. package/src/LiveRatesTableWidget/components/Cards/index.ts +0 -1
  97. package/src/LiveRatesTableWidget/components/Cards/types.tsx +0 -13
  98. package/src/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.tsx +0 -53
  99. package/src/LiveRatesTableWidget/components/LineChartWithData/index.ts +0 -1
  100. package/src/LiveRatesTableWidget/components/LineChartWithData/types.tsx +0 -13
  101. package/src/LiveRatesTableWidget/components/LineChartWithData/utils.ts +0 -14
  102. package/src/LiveRatesTableWidget/components/RowWithData/RowWithData.tsx +0 -150
  103. package/src/LiveRatesTableWidget/components/RowWithData/index.ts +0 -1
  104. package/src/LiveRatesTableWidget/components/index.ts +0 -4
  105. package/test/CardWithData.test.tsx +0 -74
  106. package/test/Cards.test.tsx +0 -130
  107. package/test/LineChartWithData.test.tsx +0 -263
  108. package/test/RowWithData.test.tsx +0 -81
@@ -1,97 +0,0 @@
1
- import { LoaderSize, Price, TableCell, TableRow, Truncate, useLayoutProvider } from '@oanda/labs-widget-common';
2
- import classnames from 'classnames';
3
- import React from 'react';
4
- import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
5
- import { ColumnsNames } from '../../types';
6
- import { useRecords } from '../../utils';
7
- import { LineChartWithData } from '../LineChartWithData';
8
- const RowWithData = _ref => {
9
- let {
10
- loading,
11
- record,
12
- hasBackgroundColor,
13
- target,
14
- activeColumns,
15
- division,
16
- isScrolled
17
- } = _ref;
18
- const {
19
- isDark
20
- } = useLayoutProvider();
21
- const {
22
- updatedRecord,
23
- error,
24
- ref
25
- } = useRecords(record, record.instrument ? target : null);
26
- const checkLoading = id => loading || !error && updatedRecord?.[id] === undefined;
27
- return React.createElement(TableRow, {
28
- ref: ref,
29
- hasBackgroundColor: hasBackgroundColor,
30
- isScrolled: isScrolled
31
- }, React.createElement(React.Fragment, null, React.createElement(TableCell, {
32
- key: ColumnsNames.INSTRUMENT,
33
- classNames: classnames('lw-font-bold', {
34
- '[&>*:first-child]:lw-border-r [&>*:first-child]:lw-border-border-primary': isDark && isScrolled
35
- }),
36
- isLoading: checkLoading(ColumnsNames.INSTRUMENT),
37
- type: "text"
38
- }, React.createElement(Truncate, {
39
- maxWidth: 130,
40
- text: record.displayName,
41
- tooltipId: INSTRUMENT_TOOLTIP_ID
42
- })), activeColumns.map(item => {
43
- if (item === ColumnsNames.SELL) {
44
- return React.createElement(TableCell, {
45
- key: ColumnsNames.SELL,
46
- additionalPaddingRight: true,
47
- isError: !!error,
48
- isLoading: checkLoading(ColumnsNames.SELL)
49
- }, React.createElement(Price, {
50
- movementIndicator: "arrow",
51
- priceMovement: updatedRecord.sellPriceMovement
52
- }, React.createElement("span", null, updatedRecord.sell?.toFixed(updatedRecord.displayPrecision))));
53
- }
54
- if (item === ColumnsNames.BUY) {
55
- return React.createElement(TableCell, {
56
- key: ColumnsNames.BUY,
57
- additionalPaddingRight: true,
58
- isError: !!error,
59
- isLoading: checkLoading(ColumnsNames.BUY)
60
- }, React.createElement(Price, {
61
- movementIndicator: "arrow",
62
- priceMovement: updatedRecord.buyPriceMovement
63
- }, React.createElement("span", null, updatedRecord.buy?.toFixed(updatedRecord.displayPrecision))));
64
- }
65
- if (item === ColumnsNames.DAILY_CHANGE) {
66
- return React.createElement(TableCell, {
67
- key: ColumnsNames.DAILY_CHANGE,
68
- isError: !!error,
69
- isLoading: checkLoading('dailyPercentChange')
70
- }, React.createElement("span", null, updatedRecord.dailyPercentChange));
71
- }
72
- if (item === ColumnsNames.CHART) {
73
- return React.createElement("td", {
74
- key: ColumnsNames.CHART,
75
- className: "lw-relative lw-px-3 lw-py-0 lw-text-right",
76
- "data-testid": "chart-table-cell"
77
- }, React.createElement("div", {
78
- className: "lw-flex lw-justify-center"
79
- }, React.createElement(LineChartWithData, {
80
- division: division,
81
- isLoading: checkLoading('instrument'),
82
- record: updatedRecord
83
- })));
84
- }
85
- if (item === ColumnsNames.SPREAD) {
86
- return React.createElement(TableCell, {
87
- key: ColumnsNames.SPREAD,
88
- isError: !!error,
89
- isLoading: checkLoading(ColumnsNames.SPREAD),
90
- loaderSize: LoaderSize.sm
91
- }, React.createElement("span", null, updatedRecord.spread));
92
- }
93
- return null;
94
- })));
95
- };
96
- export { RowWithData };
97
- //# sourceMappingURL=RowWithData.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RowWithData.js","names":["LoaderSize","Price","TableCell","TableRow","Truncate","useLayoutProvider","classnames","React","INSTRUMENT_TOOLTIP_ID","ColumnsNames","useRecords","LineChartWithData","RowWithData","_ref","loading","record","hasBackgroundColor","target","activeColumns","division","isScrolled","isDark","updatedRecord","error","ref","instrument","checkLoading","id","undefined","createElement","Fragment","key","INSTRUMENT","classNames","isLoading","type","maxWidth","text","displayName","tooltipId","map","item","SELL","additionalPaddingRight","isError","movementIndicator","priceMovement","sellPriceMovement","sell","toFixed","displayPrecision","BUY","buyPriceMovement","buy","DAILY_CHANGE","dailyPercentChange","CHART","className","SPREAD","loaderSize","sm","spread"],"sources":["../../../../../src/LiveRatesTableWidget/components/RowWithData/RowWithData.tsx"],"sourcesContent":["import {\n LoaderSize,\n Price,\n TableCell,\n TableRow,\n Truncate,\n useLayoutProvider,\n} from '@oanda/labs-widget-common';\nimport classnames from 'classnames';\nimport React from 'react';\n\nimport { INSTRUMENT_TOOLTIP_ID } from '../../constant';\nimport type { RowWithDataProps } from '../../types';\nimport { ColumnsNames } from '../../types';\nimport { useRecords } from '../../utils';\nimport { LineChartWithData } from '../LineChartWithData';\n\nconst RowWithData = ({\n loading,\n record,\n hasBackgroundColor,\n target,\n activeColumns,\n division,\n isScrolled,\n}: RowWithDataProps) => {\n const { isDark } = useLayoutProvider();\n const { updatedRecord, error, ref } = useRecords(\n record,\n record.instrument ? target : null\n );\n\n const checkLoading = (id: string) =>\n loading || (!error && updatedRecord?.[id] === undefined);\n\n return (\n <TableRow\n ref={ref}\n hasBackgroundColor={hasBackgroundColor}\n isScrolled={isScrolled}\n >\n <>\n <TableCell\n key={ColumnsNames.INSTRUMENT}\n classNames={classnames('lw-font-bold', {\n '[&>*:first-child]:lw-border-r [&>*:first-child]:lw-border-border-primary':\n isDark && isScrolled,\n })}\n isLoading={checkLoading(ColumnsNames.INSTRUMENT)}\n type=\"text\"\n >\n <Truncate\n maxWidth={130}\n text={record.displayName}\n tooltipId={INSTRUMENT_TOOLTIP_ID}\n />\n </TableCell>\n {activeColumns.map((item) => {\n if (item === ColumnsNames.SELL) {\n return (\n <TableCell\n key={ColumnsNames.SELL}\n additionalPaddingRight\n isError={!!error}\n isLoading={checkLoading(ColumnsNames.SELL)}\n >\n <Price\n movementIndicator=\"arrow\"\n priceMovement={updatedRecord.sellPriceMovement}\n >\n <span>\n {updatedRecord.sell?.toFixed(\n updatedRecord.displayPrecision\n )}\n </span>\n </Price>\n </TableCell>\n );\n }\n\n if (item === ColumnsNames.BUY) {\n return (\n <TableCell\n key={ColumnsNames.BUY}\n additionalPaddingRight\n isError={!!error}\n isLoading={checkLoading(ColumnsNames.BUY)}\n >\n <Price\n movementIndicator=\"arrow\"\n priceMovement={updatedRecord.buyPriceMovement}\n >\n <span>\n {updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}\n </span>\n </Price>\n </TableCell>\n );\n }\n\n if (item === ColumnsNames.DAILY_CHANGE) {\n return (\n <TableCell\n key={ColumnsNames.DAILY_CHANGE}\n isError={!!error}\n isLoading={checkLoading('dailyPercentChange')}\n >\n <span>{updatedRecord.dailyPercentChange}</span>\n </TableCell>\n );\n }\n\n if (item === ColumnsNames.CHART) {\n return (\n <td\n key={ColumnsNames.CHART}\n className=\"lw-relative lw-px-3 lw-py-0 lw-text-right\"\n data-testid=\"chart-table-cell\"\n >\n <div className=\"lw-flex lw-justify-center\">\n <LineChartWithData\n division={division}\n isLoading={checkLoading('instrument')}\n record={updatedRecord}\n />\n </div>\n </td>\n );\n }\n\n if (item === ColumnsNames.SPREAD) {\n return (\n <TableCell\n key={ColumnsNames.SPREAD}\n isError={!!error}\n isLoading={checkLoading(ColumnsNames.SPREAD)}\n loaderSize={LoaderSize.sm}\n >\n <span>{updatedRecord.spread}</span>\n </TableCell>\n );\n }\n return null;\n })}\n </>\n </TableRow>\n );\n};\n\nexport { RowWithData };\n"],"mappings":"AAAA,SACEA,UAAU,EACVC,KAAK,EACLC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,iBAAiB,QACZ,2BAA2B;AAClC,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,qBAAqB,QAAQ,gBAAgB;AAEtD,SAASC,YAAY,QAAQ,aAAa;AAC1C,SAASC,UAAU,QAAQ,aAAa;AACxC,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,MAAMC,WAAW,GAAGC,IAAA,IAQI;EAAA,IARH;IACnBC,OAA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A;QACEE,GAAG,EAAEtB,YAAY,CAAC+C,KAAM;QACxBC,SAAS,EAAC,2CAA2C;QACrD,eAAY;MAAkB,GAE9BlD,KAAA,CAAAsB,aAAA;QAAK4B,SAAS,EAAC;MAA2B,GACxClD,KAAA,CAAAsB,aAAA,CAAClB,iBAAiB;QAChBQ,QAAQ,EAAEA,QAAS;QACnBe,SAAS,EAAER,YAAY,CAAC,YAAY,CAAE;QACtCX,MAAM,EAAEO;MAAc,CACvB,CACE,CACH,CAAC;IAET;IAEA,IAAImB,IAAI,KAAKhC,YAAY,CAACiD,MAAM,EAAE;MAChC,OACEnD,KAAA,CAAAsB,aAAA,CAAC3B,SAAS;QACR6B,GAAG,EAAEtB,YAAY,CAACiD,MAAO;QACzBd,OAAO,EAAE,CAAC,CAACrB,KAAM;QACjBW,SAAS,EAAER,YAAY,CAACjB,YAAY,CAACiD,MAAM,CAAE;QAC7CC,UAAU,EAAE3D,UAAU,CAAC4D;MAAG,GAE1BrD,KAAA,CAAAsB,aAAA,eAAOP,aAAa,CAACuC,MAAa,CACzB,CAAC;IAEhB;IACA,OAAO,IAAI;EACb,CAAC,CACD,CACM,CAAC;AAEf,CAAC;AAED,SAASjD,WAAW","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export * from './RowWithData';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/LiveRatesTableWidget/components/RowWithData/index.ts"],"sourcesContent":["export * from './RowWithData';\n"],"mappings":"AAAA,cAAc,eAAe","ignoreList":[]}
@@ -1,5 +0,0 @@
1
- export * from './Cards';
2
- export * from './CardWithData';
3
- export * from './LineChartWithData';
4
- export * from './RowWithData';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../../src/LiveRatesTableWidget/components/index.ts"],"sourcesContent":["export * from './Cards';\nexport * from './CardWithData';\nexport * from './LineChartWithData';\nexport * from './RowWithData';\n"],"mappings":"AAAA,cAAc,SAAS;AACvB,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,eAAe","ignoreList":[]}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { CardWithDataProps } from '../../types';
3
- declare const CardWithData: ({ isLoading, record, target, activeColumns, index, division, isLast, }: CardWithDataProps) => React.JSX.Element;
4
- export { CardWithData };
@@ -1 +0,0 @@
1
- export * from './CardWithData';
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { CardsProps } from './types';
3
- declare const Cards: ({ records, target, columns, isError, isLoading, division, startIndex, }: CardsProps) => React.JSX.Element;
4
- export { Cards };
@@ -1 +0,0 @@
1
- export * from './Cards';
@@ -1,12 +0,0 @@
1
- import type { Division } from '../../../gql/types/graphql';
2
- import type { ColumnsNames, DataRecord } from '../../types';
3
- export interface CardsProps {
4
- startIndex?: number;
5
- emptyCardsCount?: number;
6
- isLoading?: boolean;
7
- isError?: boolean;
8
- records: DataRecord[];
9
- target: EventTarget | null;
10
- columns: ColumnsNames[];
11
- division: Division;
12
- }
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { LineChartWithDataProps } from './types';
3
- declare const LineChartWithData: ({ padding, record, size, isLoading, division, isDarkMode, }: LineChartWithDataProps) => React.JSX.Element;
4
- export { LineChartWithData };
@@ -1 +0,0 @@
1
- export * from './LineChartWithData';
@@ -1,11 +0,0 @@
1
- import type { LineChartSize } from '@oanda/labs-widget-common';
2
- import type { Division } from '../../../gql/types/graphql';
3
- import type { DataRecord } from '../../types';
4
- export interface LineChartWithDataProps {
5
- padding?: number;
6
- record: DataRecord;
7
- size?: LineChartSize;
8
- isLoading: boolean;
9
- division: Division;
10
- isDarkMode?: boolean;
11
- }
@@ -1 +0,0 @@
1
- export declare const getChartColor: (dailyChange?: string, isDarkMode?: boolean) => string;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { RowWithDataProps } from '../../types';
3
- declare const RowWithData: ({ loading, record, hasBackgroundColor, target, activeColumns, division, isScrolled, }: RowWithDataProps) => React.JSX.Element;
4
- export { RowWithData };
@@ -1 +0,0 @@
1
- export * from './RowWithData';
@@ -1,4 +0,0 @@
1
- export * from './Cards';
2
- export * from './CardWithData';
3
- export * from './LineChartWithData';
4
- export * from './RowWithData';
@@ -1,133 +0,0 @@
1
- import {
2
- ArrowPosition,
3
- Card,
4
- CardHeader,
5
- CardRow,
6
- LineChartSize,
7
- Price,
8
- Truncate,
9
- } from '@oanda/labs-widget-common';
10
- import { useLocale } from '@oanda/mono-i18n';
11
- import React from 'react';
12
-
13
- import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
14
- import type { CardWithDataProps } from '../../types';
15
- import { ColumnsNames } from '../../types';
16
- import { useRecords } from '../../utils';
17
- import { LineChartWithData } from '../LineChartWithData';
18
-
19
- const CardWithData = ({
20
- isLoading,
21
- record,
22
- target,
23
- activeColumns,
24
- index,
25
- division,
26
- isLast,
27
- }: CardWithDataProps) => {
28
- const { updatedRecord, error, ref } = useRecords(
29
- record,
30
- record.instrument ? target : null
31
- );
32
- const { lang } = useLocale();
33
-
34
- const checkLoading = (id: string) =>
35
- isLoading || (!error && updatedRecord?.[id] === undefined);
36
-
37
- return (
38
- <Card ref={ref} data-testid="card" withoutBottomBorder={!isLast}>
39
- <CardHeader
40
- isLoading={isLoading}
41
- number={index}
42
- title={
43
- <Truncate
44
- text={record.displayName}
45
- tooltipId={INSTRUMENT_TOOLTIP_ID}
46
- />
47
- }
48
- >
49
- {activeColumns.includes(ColumnsNames.CHART) && (
50
- <LineChartWithData
51
- division={division}
52
- isLoading={checkLoading('instrument')}
53
- padding={4}
54
- record={updatedRecord}
55
- size={LineChartSize.xs}
56
- />
57
- )}
58
- </CardHeader>
59
- {activeColumns.map((item) => {
60
- if (item === ColumnsNames.SELL) {
61
- return (
62
- <CardRow
63
- key={ColumnsNames.SELL}
64
- isError={!!error}
65
- isLoading={checkLoading(ColumnsNames.SELL)}
66
- label={lang('sell_price')}
67
- >
68
- <Price
69
- arrowPosition={ArrowPosition.left}
70
- movementIndicator="arrow"
71
- priceMovement={updatedRecord.sellPriceMovement}
72
- >
73
- <span>
74
- {updatedRecord.sell?.toFixed(updatedRecord.displayPrecision)}
75
- </span>
76
- </Price>
77
- </CardRow>
78
- );
79
- }
80
-
81
- if (item === ColumnsNames.BUY) {
82
- return (
83
- <CardRow
84
- key={ColumnsNames.BUY}
85
- isError={!!error}
86
- isLoading={checkLoading(ColumnsNames.BUY)}
87
- label={lang('buy_price')}
88
- >
89
- <Price
90
- arrowPosition={ArrowPosition.left}
91
- movementIndicator="arrow"
92
- priceMovement={updatedRecord.buyPriceMovement}
93
- >
94
- <span>
95
- {updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}
96
- </span>
97
- </Price>
98
- </CardRow>
99
- );
100
- }
101
-
102
- if (item === ColumnsNames.DAILY_CHANGE) {
103
- return (
104
- <CardRow
105
- key={ColumnsNames.DAILY_CHANGE}
106
- isError={!!error}
107
- isLoading={checkLoading('dailyPercentChange')}
108
- label={lang('daily_percent_change')}
109
- >
110
- <span>{updatedRecord.dailyPercentChange}</span>
111
- </CardRow>
112
- );
113
- }
114
-
115
- if (item === ColumnsNames.SPREAD) {
116
- return (
117
- <CardRow
118
- key={ColumnsNames.SPREAD}
119
- isError={!!error}
120
- isLoading={checkLoading(ColumnsNames.SPREAD)}
121
- label={lang('spread')}
122
- >
123
- <span>{updatedRecord.spread}</span>
124
- </CardRow>
125
- );
126
- }
127
- return null;
128
- })}
129
- </Card>
130
- );
131
- };
132
-
133
- export { CardWithData };
@@ -1 +0,0 @@
1
- export * from './CardWithData';
@@ -1,44 +0,0 @@
1
- import { Card, ChartError } from '@oanda/labs-widget-common';
2
- import React from 'react';
3
-
4
- import { CardWithData } from '../CardWithData/CardWithData';
5
- import type { CardsProps } from './types';
6
-
7
- const Cards = ({
8
- records,
9
- target,
10
- columns,
11
- isError,
12
- isLoading,
13
- division,
14
- startIndex = 0,
15
- }: CardsProps) => (
16
- <>
17
- {isError ? (
18
- <Card>
19
- <div className="lw-flex lw-h-[150px] lw-w-full lw-items-center lw-justify-center">
20
- <ChartError />
21
- </div>
22
- </Card>
23
- ) : (
24
- <>
25
- {records.map((record, index) => (
26
- <div key={`card_${startIndex + index}`}>
27
- <CardWithData
28
- activeColumns={columns}
29
- division={division}
30
- index={startIndex + index + 1}
31
- isError={isError}
32
- isLast={index + 1 === records.length}
33
- isLoading={isLoading}
34
- record={record}
35
- target={target}
36
- />
37
- </div>
38
- ))}
39
- </>
40
- )}
41
- </>
42
- );
43
-
44
- export { Cards };
@@ -1 +0,0 @@
1
- export * from './Cards';
@@ -1,13 +0,0 @@
1
- import type { Division } from '../../../gql/types/graphql';
2
- import type { ColumnsNames, DataRecord } from '../../types';
3
-
4
- export interface CardsProps {
5
- startIndex?: number;
6
- emptyCardsCount?: number;
7
- isLoading?: boolean;
8
- isError?: boolean;
9
- records: DataRecord[];
10
- target: EventTarget | null;
11
- columns: ColumnsNames[];
12
- division: Division;
13
- }
@@ -1,53 +0,0 @@
1
- import { useQuery } from '@apollo/client';
2
- import { LineChart, Loader, LoaderSize } from '@oanda/labs-widget-common';
3
- import React from 'react';
4
-
5
- import { getInstrumentsChart } from '../../../gql/getInstrumentsChart';
6
- import type {
7
- GetInstrumentsChartQuery,
8
- GetInstrumentsChartQueryVariables,
9
- } from '../../../gql/types/graphql';
10
- import type { LineChartWithDataProps } from './types';
11
- import { getChartColor } from './utils';
12
-
13
- const LineChartWithData = ({
14
- padding,
15
- record,
16
- size,
17
- isLoading,
18
- division,
19
- isDarkMode = false,
20
- }: LineChartWithDataProps) => {
21
- const { loading, data } = useQuery<
22
- GetInstrumentsChartQuery,
23
- GetInstrumentsChartQueryVariables
24
- >(getInstrumentsChart, {
25
- variables: {
26
- instruments: [record.instrument],
27
- division,
28
- },
29
- fetchPolicy: 'network-only',
30
- skip: !record.instrument,
31
- });
32
-
33
- const showLoader = isLoading || loading;
34
- const chart = data?.topicalInstrumentsCharts?.[0].chart || [];
35
-
36
- const chartColor = getChartColor(record.dailyPercentChange, isDarkMode);
37
-
38
- return (
39
- <>
40
- {showLoader && <Loader size={LoaderSize.md} />}
41
- {!showLoader && (
42
- <LineChart
43
- color={chartColor}
44
- data={chart}
45
- padding={padding}
46
- size={size}
47
- />
48
- )}
49
- </>
50
- );
51
- };
52
-
53
- export { LineChartWithData };
@@ -1 +0,0 @@
1
- export * from './LineChartWithData';
@@ -1,13 +0,0 @@
1
- import type { LineChartSize } from '@oanda/labs-widget-common';
2
-
3
- import type { Division } from '../../../gql/types/graphql';
4
- import type { DataRecord } from '../../types';
5
-
6
- export interface LineChartWithDataProps {
7
- padding?: number;
8
- record: DataRecord;
9
- size?: LineChartSize;
10
- isLoading: boolean;
11
- division: Division;
12
- isDarkMode?: boolean;
13
- }
@@ -1,14 +0,0 @@
1
- import { Theme, themeColors } from '@oanda/labs-widget-common';
2
-
3
- export const getChartColor = (dailyChange?: string, isDarkMode?: boolean) => {
4
- const theme = isDarkMode ? Theme.Dark : Theme.Light;
5
-
6
- switch (dailyChange?.charAt(0)) {
7
- case '+':
8
- return themeColors.ok[theme];
9
- case '-':
10
- return themeColors.danger[theme];
11
- default:
12
- return themeColors.borderDisabled[theme];
13
- }
14
- };
@@ -1,150 +0,0 @@
1
- import {
2
- LoaderSize,
3
- Price,
4
- TableCell,
5
- TableRow,
6
- Truncate,
7
- useLayoutProvider,
8
- } from '@oanda/labs-widget-common';
9
- import classnames from 'classnames';
10
- import React from 'react';
11
-
12
- import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
13
- import type { RowWithDataProps } from '../../types';
14
- import { ColumnsNames } from '../../types';
15
- import { useRecords } from '../../utils';
16
- import { LineChartWithData } from '../LineChartWithData';
17
-
18
- const RowWithData = ({
19
- loading,
20
- record,
21
- hasBackgroundColor,
22
- target,
23
- activeColumns,
24
- division,
25
- isScrolled,
26
- }: RowWithDataProps) => {
27
- const { isDark } = useLayoutProvider();
28
- const { updatedRecord, error, ref } = useRecords(
29
- record,
30
- record.instrument ? target : null
31
- );
32
-
33
- const checkLoading = (id: string) =>
34
- loading || (!error && updatedRecord?.[id] === undefined);
35
-
36
- return (
37
- <TableRow
38
- ref={ref}
39
- hasBackgroundColor={hasBackgroundColor}
40
- isScrolled={isScrolled}
41
- >
42
- <>
43
- <TableCell
44
- key={ColumnsNames.INSTRUMENT}
45
- classNames={classnames('lw-font-bold', {
46
- '[&>*:first-child]:lw-border-r [&>*:first-child]:lw-border-border-primary':
47
- isDark && isScrolled,
48
- })}
49
- isLoading={checkLoading(ColumnsNames.INSTRUMENT)}
50
- type="text"
51
- >
52
- <Truncate
53
- maxWidth={130}
54
- text={record.displayName}
55
- tooltipId={INSTRUMENT_TOOLTIP_ID}
56
- />
57
- </TableCell>
58
- {activeColumns.map((item) => {
59
- if (item === ColumnsNames.SELL) {
60
- return (
61
- <TableCell
62
- key={ColumnsNames.SELL}
63
- additionalPaddingRight
64
- isError={!!error}
65
- isLoading={checkLoading(ColumnsNames.SELL)}
66
- >
67
- <Price
68
- movementIndicator="arrow"
69
- priceMovement={updatedRecord.sellPriceMovement}
70
- >
71
- <span>
72
- {updatedRecord.sell?.toFixed(
73
- updatedRecord.displayPrecision
74
- )}
75
- </span>
76
- </Price>
77
- </TableCell>
78
- );
79
- }
80
-
81
- if (item === ColumnsNames.BUY) {
82
- return (
83
- <TableCell
84
- key={ColumnsNames.BUY}
85
- additionalPaddingRight
86
- isError={!!error}
87
- isLoading={checkLoading(ColumnsNames.BUY)}
88
- >
89
- <Price
90
- movementIndicator="arrow"
91
- priceMovement={updatedRecord.buyPriceMovement}
92
- >
93
- <span>
94
- {updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}
95
- </span>
96
- </Price>
97
- </TableCell>
98
- );
99
- }
100
-
101
- if (item === ColumnsNames.DAILY_CHANGE) {
102
- return (
103
- <TableCell
104
- key={ColumnsNames.DAILY_CHANGE}
105
- isError={!!error}
106
- isLoading={checkLoading('dailyPercentChange')}
107
- >
108
- <span>{updatedRecord.dailyPercentChange}</span>
109
- </TableCell>
110
- );
111
- }
112
-
113
- if (item === ColumnsNames.CHART) {
114
- return (
115
- <td
116
- key={ColumnsNames.CHART}
117
- className="lw-relative lw-px-3 lw-py-0 lw-text-right"
118
- data-testid="chart-table-cell"
119
- >
120
- <div className="lw-flex lw-justify-center">
121
- <LineChartWithData
122
- division={division}
123
- isLoading={checkLoading('instrument')}
124
- record={updatedRecord}
125
- />
126
- </div>
127
- </td>
128
- );
129
- }
130
-
131
- if (item === ColumnsNames.SPREAD) {
132
- return (
133
- <TableCell
134
- key={ColumnsNames.SPREAD}
135
- isError={!!error}
136
- isLoading={checkLoading(ColumnsNames.SPREAD)}
137
- loaderSize={LoaderSize.sm}
138
- >
139
- <span>{updatedRecord.spread}</span>
140
- </TableCell>
141
- );
142
- }
143
- return null;
144
- })}
145
- </>
146
- </TableRow>
147
- );
148
- };
149
-
150
- export { RowWithData };
@@ -1 +0,0 @@
1
- export * from './RowWithData';
@@ -1,4 +0,0 @@
1
- export * from './Cards';
2
- export * from './CardWithData';
3
- export * from './LineChartWithData';
4
- export * from './RowWithData';