@oanda/labs-live-rates-table-widget 1.0.49 → 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.
- package/CHANGELOG.md +204 -0
- package/dist/main/LiveRatesTableWidget/Main.js +26 -33
- package/dist/main/LiveRatesTableWidget/Main.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/config.js +12 -7
- package/dist/main/LiveRatesTableWidget/config.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/constant.js +2 -2
- package/dist/main/LiveRatesTableWidget/constant.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/types.js +0 -10
- package/dist/main/LiveRatesTableWidget/types.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/utils.js +8 -49
- package/dist/main/LiveRatesTableWidget/utils.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/Main.js +28 -35
- package/dist/module/LiveRatesTableWidget/Main.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/config.js +13 -9
- package/dist/module/LiveRatesTableWidget/config.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/constant.js +2 -2
- package/dist/module/LiveRatesTableWidget/constant.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/types.js +0 -9
- package/dist/module/LiveRatesTableWidget/types.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/utils.js +8 -47
- package/dist/module/LiveRatesTableWidget/utils.js.map +1 -1
- package/dist/types/LiveRatesTableWidget/config.d.ts +9 -28
- package/dist/types/LiveRatesTableWidget/constant.d.ts +2 -2
- package/dist/types/LiveRatesTableWidget/types.d.ts +6 -47
- package/dist/types/LiveRatesTableWidget/utils.d.ts +4 -15
- package/package.json +3 -3
- package/src/LiveRatesTableWidget/Main.tsx +44 -51
- package/src/LiveRatesTableWidget/config.ts +27 -10
- package/src/LiveRatesTableWidget/constant.ts +6 -6
- package/src/LiveRatesTableWidget/types.tsx +11 -53
- package/src/LiveRatesTableWidget/utils.ts +21 -65
- package/test/mocks.ts +1 -16
- package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js +0 -96
- package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/CardWithData/index.js +0 -17
- package/dist/main/LiveRatesTableWidget/components/CardWithData/index.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js +0 -37
- package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/Cards/index.js +0 -17
- package/dist/main/LiveRatesTableWidget/components/Cards/index.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/Cards/types.js +0 -6
- package/dist/main/LiveRatesTableWidget/components/Cards/types.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +0 -46
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/index.js +0 -17
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/index.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js +0 -6
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js +0 -20
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js +0 -104
- package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/RowWithData/index.js +0 -17
- package/dist/main/LiveRatesTableWidget/components/RowWithData/index.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/index.js +0 -50
- package/dist/main/LiveRatesTableWidget/components/index.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js +0 -89
- package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/CardWithData/index.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/CardWithData/index.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js +0 -30
- package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/Cards/index.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/Cards/index.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/Cards/types.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/Cards/types.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +0 -39
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/index.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/index.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js +0 -13
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js +0 -97
- package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/RowWithData/index.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/RowWithData/index.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/index.js +0 -5
- package/dist/module/LiveRatesTableWidget/components/index.js.map +0 -1
- package/dist/types/LiveRatesTableWidget/components/CardWithData/CardWithData.d.ts +0 -4
- package/dist/types/LiveRatesTableWidget/components/CardWithData/index.d.ts +0 -1
- package/dist/types/LiveRatesTableWidget/components/Cards/Cards.d.ts +0 -4
- package/dist/types/LiveRatesTableWidget/components/Cards/index.d.ts +0 -1
- package/dist/types/LiveRatesTableWidget/components/Cards/types.d.ts +0 -12
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.d.ts +0 -4
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/index.d.ts +0 -1
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/types.d.ts +0 -11
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/utils.d.ts +0 -1
- package/dist/types/LiveRatesTableWidget/components/RowWithData/RowWithData.d.ts +0 -4
- package/dist/types/LiveRatesTableWidget/components/RowWithData/index.d.ts +0 -1
- package/dist/types/LiveRatesTableWidget/components/index.d.ts +0 -4
- package/src/LiveRatesTableWidget/components/CardWithData/CardWithData.tsx +0 -133
- package/src/LiveRatesTableWidget/components/CardWithData/index.ts +0 -1
- package/src/LiveRatesTableWidget/components/Cards/Cards.tsx +0 -44
- package/src/LiveRatesTableWidget/components/Cards/index.ts +0 -1
- package/src/LiveRatesTableWidget/components/Cards/types.tsx +0 -13
- package/src/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.tsx +0 -53
- package/src/LiveRatesTableWidget/components/LineChartWithData/index.ts +0 -1
- package/src/LiveRatesTableWidget/components/LineChartWithData/types.tsx +0 -13
- package/src/LiveRatesTableWidget/components/LineChartWithData/utils.ts +0 -14
- package/src/LiveRatesTableWidget/components/RowWithData/RowWithData.tsx +0 -150
- package/src/LiveRatesTableWidget/components/RowWithData/index.ts +0 -1
- package/src/LiveRatesTableWidget/components/index.ts +0 -4
- package/test/CardWithData.test.tsx +0 -74
- package/test/Cards.test.tsx +0 -130
- package/test/LineChartWithData.test.tsx +0 -263
- package/test/RowWithData.test.tsx +0 -81
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Main.js","names":["
|
|
1
|
+
{"version":3,"file":"Main.js","names":["Size","TableWidget","useFetchCombinedDataRecords","useLayoutProvider","useLiveRatesQuery","React","useEffect","useState","getInstrumentsChart","validateInstruments","getHeaderConfig","DEFAULT_COLUMNS","INSTRUMENT_TOOLTIP_ID","getRecords","Main","_ref","instruments","division","columns","size","isDesktop","DESKTOP","target","setQuery","records","setRecords","Array","length","fill","data","loading","error","mainQuery","mainVariables","batchQuery","getBatchVariables","mainData","intrumentsByDivision","mapInstrumentNames","filter","i","displayName","map","undefined","merge","chartData","fetchPolicy","instrumentsNames","_ref2","instrument","showError","createElement","activeColumns","count","hasError","headerColumns","isLoading","pageNumber","testId","toolTipId"],"sources":["../../../src/LiveRatesTableWidget/Main.tsx"],"sourcesContent":["import type { DataRecord } from '@oanda/labs-widget-common';\nimport {\n Size,\n TableWidget,\n useFetchCombinedDataRecords,\n useLayoutProvider,\n useLiveRatesQuery,\n} from '@oanda/labs-widget-common';\nimport React, { useEffect, useState } from 'react';\n\nimport { getInstrumentsChart } from '../gql/getInstrumentsChart';\nimport type {\n GetInstrumentsChartQuery,\n GetInstrumentsChartQueryVariables,\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables,\n} from '../gql/types/graphql';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { getHeaderConfig } from './config';\nimport { DEFAULT_COLUMNS, INSTRUMENT_TOOLTIP_ID } from './constant';\nimport type { MainProps, ValidateInstrumentsData } from './types';\nimport { getRecords } from './utils';\n\nconst Main = ({\n instruments,\n division,\n columns = DEFAULT_COLUMNS,\n}: MainProps) => {\n const { size } = useLayoutProvider();\n const isDesktop = size === Size.DESKTOP;\n const { target, setQuery } = useLiveRatesQuery();\n\n const [records, setRecords] = useState<DataRecord[]>(\n new Array(instruments.length).fill({})\n );\n\n const { data, loading, error } = useFetchCombinedDataRecords<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables,\n GetInstrumentsChartQuery,\n GetInstrumentsChartQueryVariables,\n ValidateInstrumentsData\n >({\n mainQuery: validateInstruments,\n mainVariables: {\n instruments,\n division,\n },\n batchQuery: getInstrumentsChart,\n getBatchVariables: (mainData) => {\n const intrumentsByDivision = mainData?.mapInstrumentNames\n ?.filter(\n (i): i is { displayName: string; name: string } => !!i?.displayName\n )\n ?.map((i) => i.displayName);\n\n return intrumentsByDivision?.length\n ? { instruments: intrumentsByDivision, division }\n : undefined;\n },\n merge: (mainData, chartData) => getRecords(mainData, chartData),\n fetchPolicy: 'network-only',\n });\n\n useEffect(() => {\n if (!loading && data) {\n setRecords(data.records ?? []);\n }\n }, [loading, data]);\n\n const instrumentsNames = records.map(({ instrument }) => instrument);\n\n useEffect(() => {\n if (instrumentsNames[0]) {\n setQuery({ instruments: instrumentsNames });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [records, isDesktop]);\n\n const showError = (!loading && !!error) || (!loading && !data);\n\n return (\n <TableWidget\n activeColumns={columns}\n count={0}\n hasError={showError}\n headerColumns={getHeaderConfig(columns)}\n isLoading={loading}\n pageNumber={0}\n records={records}\n target={target}\n testId=\"live-rates-table-wrapper\"\n toolTipId={INSTRUMENT_TOOLTIP_ID}\n />\n );\n};\n\nexport { Main };\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
import { Size } from '@oanda/labs-widget-common';
|
|
2
|
-
import {
|
|
1
|
+
import { DataRecordType, Size } from '@oanda/labs-widget-common';
|
|
2
|
+
import { View } from './types';
|
|
3
3
|
const headerConfig = {
|
|
4
|
-
[
|
|
4
|
+
[DataRecordType.INSTRUMENT]: {
|
|
5
5
|
displayName: 'instrument',
|
|
6
6
|
additionalStyles: 'lw-text-left lw-min-w-[130px]'
|
|
7
7
|
},
|
|
8
|
-
[
|
|
8
|
+
[DataRecordType.SELL]: {
|
|
9
9
|
displayName: 'sell',
|
|
10
10
|
additionalStyles: 'lw-text-right lw-min-w-[75px] lw-pr-4'
|
|
11
11
|
},
|
|
12
|
-
[
|
|
12
|
+
[DataRecordType.BUY]: {
|
|
13
13
|
displayName: 'buy',
|
|
14
14
|
additionalStyles: 'lw-text-right lw-min-w-[75px] lw-pr-4'
|
|
15
15
|
},
|
|
16
|
-
[
|
|
16
|
+
[DataRecordType.DAILY_CHANGE]: {
|
|
17
17
|
displayName: 'daily_percent_change',
|
|
18
18
|
additionalStyles: 'lw-text-right lw-min-w-[80px]'
|
|
19
19
|
},
|
|
20
|
-
[
|
|
20
|
+
[DataRecordType.CHART]: {
|
|
21
21
|
displayName: '24h_chart',
|
|
22
22
|
additionalStyles: 'lw-text-center lw-min-w-[100px]'
|
|
23
23
|
},
|
|
24
|
-
[
|
|
24
|
+
[DataRecordType.SPREAD]: {
|
|
25
25
|
displayName: 'spread',
|
|
26
26
|
additionalStyles: 'lw-text-right lw-min-w-[50px]'
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
+
const getHeaderConfig = activeColumns => {
|
|
30
|
+
const columns = [DataRecordType.INSTRUMENT, ...activeColumns].filter(item => item !== DataRecordType.SENTIMENT);
|
|
31
|
+
return columns.map(item => headerConfig[item]);
|
|
32
|
+
};
|
|
29
33
|
const sizeConfig = {
|
|
30
34
|
[View.CARDS]: Size.MOBILE,
|
|
31
35
|
[View.TABLE]: Size.DESKTOP
|
|
32
36
|
};
|
|
33
|
-
export { headerConfig, sizeConfig };
|
|
37
|
+
export { getHeaderConfig, headerConfig, sizeConfig };
|
|
34
38
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["
|
|
1
|
+
{"version":3,"file":"config.js","names":["DataRecordType","Size","View","headerConfig","INSTRUMENT","displayName","additionalStyles","SELL","BUY","DAILY_CHANGE","CHART","SPREAD","getHeaderConfig","activeColumns","columns","filter","item","SENTIMENT","map","sizeConfig","CARDS","MOBILE","TABLE","DESKTOP"],"sources":["../../../src/LiveRatesTableWidget/config.ts"],"sourcesContent":["import type { HeaderColumns } from '@oanda/labs-widget-common';\nimport { DataRecordType, Size } from '@oanda/labs-widget-common';\n\nimport { View } from './types';\n\ntype HeaderRecordType = Exclude<DataRecordType, DataRecordType.SENTIMENT>;\n\nconst headerConfig: Record<\n HeaderRecordType,\n { displayName: string; additionalStyles: string }\n> = {\n [DataRecordType.INSTRUMENT]: {\n displayName: 'instrument',\n additionalStyles: 'lw-text-left lw-min-w-[130px]',\n },\n [DataRecordType.SELL]: {\n displayName: 'sell',\n additionalStyles: 'lw-text-right lw-min-w-[75px] lw-pr-4',\n },\n [DataRecordType.BUY]: {\n displayName: 'buy',\n additionalStyles: 'lw-text-right lw-min-w-[75px] lw-pr-4',\n },\n [DataRecordType.DAILY_CHANGE]: {\n displayName: 'daily_percent_change',\n additionalStyles: 'lw-text-right lw-min-w-[80px]',\n },\n [DataRecordType.CHART]: {\n displayName: '24h_chart',\n additionalStyles: 'lw-text-center lw-min-w-[100px]',\n },\n [DataRecordType.SPREAD]: {\n displayName: 'spread',\n additionalStyles: 'lw-text-right lw-min-w-[50px]',\n },\n};\n\nconst getHeaderConfig = (activeColumns: DataRecordType[]): HeaderColumns[] => {\n const columns: HeaderRecordType[] = [\n DataRecordType.INSTRUMENT,\n ...activeColumns,\n ].filter(\n (item): item is HeaderRecordType => item !== DataRecordType.SENTIMENT\n );\n\n return columns.map((item) => headerConfig[item]);\n};\n\nconst sizeConfig = {\n [View.CARDS]: Size.MOBILE,\n [View.TABLE]: Size.DESKTOP,\n};\n\nexport { getHeaderConfig, headerConfig, sizeConfig };\n"],"mappings":"AACA,SAASA,cAAc,EAAEC,IAAI,QAAQ,2BAA2B;AAEhE,SAASC,IAAI,QAAQ,SAAS;AAI9B,MAAMC,YAGL,GAAG;EACF,CAACH,cAAc,CAACI,UAAU,GAAG;IAC3BC,WAAW,EAAE,YAAY;IACzBC,gBAAgB,EAAE;EACpB,CAAC;EACD,CAACN,cAAc,CAACO,IAAI,GAAG;IACrBF,WAAW,EAAE,MAAM;IACnBC,gBAAgB,EAAE;EACpB,CAAC;EACD,CAACN,cAAc,CAACQ,GAAG,GAAG;IACpBH,WAAW,EAAE,KAAK;IAClBC,gBAAgB,EAAE;EACpB,CAAC;EACD,CAACN,cAAc,CAACS,YAAY,GAAG;IAC7BJ,WAAW,EAAE,sBAAsB;IACnCC,gBAAgB,EAAE;EACpB,CAAC;EACD,CAACN,cAAc,CAACU,KAAK,GAAG;IACtBL,WAAW,EAAE,WAAW;IACxBC,gBAAgB,EAAE;EACpB,CAAC;EACD,CAACN,cAAc,CAACW,MAAM,GAAG;IACvBN,WAAW,EAAE,QAAQ;IACrBC,gBAAgB,EAAE;EACpB;AACF,CAAC;AAED,MAAMM,eAAe,GAAIC,aAA+B,IAAsB;EAC5E,MAAMC,OAA2B,GAAG,CAClCd,cAAc,CAACI,UAAU,EACzB,GAAGS,aAAa,CACjB,CAACE,MAAM,CACLC,IAAI,IAA+BA,IAAI,KAAKhB,cAAc,CAACiB,SAC9D,CAAC;EAED,OAAOH,OAAO,CAACI,GAAG,CAAEF,IAAI,IAAKb,YAAY,CAACa,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,MAAMG,UAAU,GAAG;EACjB,CAACjB,IAAI,CAACkB,KAAK,GAAGnB,IAAI,CAACoB,MAAM;EACzB,CAACnB,IAAI,CAACoB,KAAK,GAAGrB,IAAI,CAACsB;AACrB,CAAC;AAED,SAASX,eAAe,EAAET,YAAY,EAAEgB,UAAU","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataRecordType } from '@oanda/labs-widget-common';
|
|
2
2
|
const DEFAULT_COUNT = 10;
|
|
3
3
|
const DEFAULT_TOTAL_COUNT = 50;
|
|
4
|
-
const DEFAULT_COLUMNS = [
|
|
4
|
+
const DEFAULT_COLUMNS = [DataRecordType.SELL, DataRecordType.BUY, DataRecordType.DAILY_CHANGE, DataRecordType.CHART, DataRecordType.SPREAD];
|
|
5
5
|
const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';
|
|
6
6
|
export { DEFAULT_COLUMNS, DEFAULT_COUNT, DEFAULT_TOTAL_COUNT, INSTRUMENT_TOOLTIP_ID };
|
|
7
7
|
//# sourceMappingURL=constant.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","names":["
|
|
1
|
+
{"version":3,"file":"constant.js","names":["DataRecordType","DEFAULT_COUNT","DEFAULT_TOTAL_COUNT","DEFAULT_COLUMNS","SELL","BUY","DAILY_CHANGE","CHART","SPREAD","INSTRUMENT_TOOLTIP_ID"],"sources":["../../../src/LiveRatesTableWidget/constant.ts"],"sourcesContent":["import { DataRecordType } from '@oanda/labs-widget-common';\n\nconst DEFAULT_COUNT = 10;\n\nconst DEFAULT_TOTAL_COUNT = 50;\n\nconst DEFAULT_COLUMNS = [\n DataRecordType.SELL,\n DataRecordType.BUY,\n DataRecordType.DAILY_CHANGE,\n DataRecordType.CHART,\n DataRecordType.SPREAD,\n];\n\nconst INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';\n\nexport {\n DEFAULT_COLUMNS,\n DEFAULT_COUNT,\n DEFAULT_TOTAL_COUNT,\n INSTRUMENT_TOOLTIP_ID,\n};\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,2BAA2B;AAE1D,MAAMC,aAAa,GAAG,EAAE;AAExB,MAAMC,mBAAmB,GAAG,EAAE;AAE9B,MAAMC,eAAe,GAAG,CACtBH,cAAc,CAACI,IAAI,EACnBJ,cAAc,CAACK,GAAG,EAClBL,cAAc,CAACM,YAAY,EAC3BN,cAAc,CAACO,KAAK,EACpBP,cAAc,CAACQ,MAAM,CACtB;AAED,MAAMC,qBAAqB,GAAG,uBAAuB;AAErD,SACEN,eAAe,EACfF,aAAa,EACbC,mBAAmB,EACnBO,qBAAqB","ignoreList":[]}
|
|
@@ -5,13 +5,4 @@ export let View = function (View) {
|
|
|
5
5
|
View["CARDS"] = "cards";
|
|
6
6
|
return View;
|
|
7
7
|
}({});
|
|
8
|
-
export let ColumnsNames = function (ColumnsNames) {
|
|
9
|
-
ColumnsNames["INSTRUMENT"] = "instrument";
|
|
10
|
-
ColumnsNames["SELL"] = "sell";
|
|
11
|
-
ColumnsNames["BUY"] = "buy";
|
|
12
|
-
ColumnsNames["DAILY_CHANGE"] = "dailyChange";
|
|
13
|
-
ColumnsNames["CHART"] = "chart";
|
|
14
|
-
ColumnsNames["SPREAD"] = "spread";
|
|
15
|
-
return ColumnsNames;
|
|
16
|
-
}({});
|
|
17
8
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["Division","Locale","View"
|
|
1
|
+
{"version":3,"file":"types.js","names":["Division","Locale","View"],"sources":["../../../src/LiveRatesTableWidget/types.tsx"],"sourcesContent":["import type {\n DataRecord,\n DataRecordType,\n WidgetConfig,\n} from '@oanda/labs-widget-common';\n\nimport type { Division } from '../gql/types/graphql';\n\nexport { Division } from '../gql/types/graphql';\nexport { Locale } from '@oanda/mono-i18n';\n\nexport enum View {\n TABLE = 'table',\n CARDS = 'cards',\n}\n\nexport interface ValidateInstrumentsData {\n records?: DataRecord[];\n}\n\nexport interface LiveRatesTableConfig extends WidgetConfig {\n division: Division;\n liveRatesUrl: string;\n instruments: string[];\n columns?: DataRecordType[];\n removePadding?: boolean;\n view?: View;\n}\n\nexport interface MainProps {\n instruments: string[];\n division: Division;\n columns?: DataRecordType[];\n}\n"],"mappings":"AAQA,SAASA,QAAQ,QAAQ,sBAAsB;AAC/C,SAASC,MAAM,QAAQ,kBAAkB;AAEzC,WAAYC,IAAI,aAAJA,IAAI;EAAJA,IAAI;EAAJA,IAAI;EAAA,OAAJA,IAAI;AAAA","ignoreList":[]}
|
|
@@ -1,48 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}));
|
|
10
|
-
const getHeaderConfig = activeColumns => [ColumnsNames.INSTRUMENT, ...activeColumns].map(item => headerConfig[item]);
|
|
11
|
-
const useRecords = (record, target) => {
|
|
12
|
-
const [updatedRecord, setUpdatedRecord] = useState({
|
|
13
|
-
displayName: record.displayName,
|
|
14
|
-
instrument: record.instrument,
|
|
15
|
-
sentiment: record.sentiment
|
|
16
|
-
});
|
|
17
|
-
const [error, setError] = useState(null);
|
|
18
|
-
const entry = useIntersectionObserver();
|
|
19
|
-
const isVisible = !!entry?.isIntersecting;
|
|
20
|
-
const {
|
|
21
|
-
update,
|
|
22
|
-
error: liveRatesError
|
|
23
|
-
} = useLiveRatesMessage(record.instrument, target);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (isVisible) {
|
|
26
|
-
setUpdatedRecord({
|
|
27
|
-
displayName: record.displayName,
|
|
28
|
-
instrument: record.instrument,
|
|
29
|
-
sentiment: record.sentiment,
|
|
30
|
-
buy: update?.ask,
|
|
31
|
-
sell: update?.bid,
|
|
32
|
-
sellPriceMovement: update?.bidPriceMovement,
|
|
33
|
-
buyPriceMovement: update?.askPriceMovement,
|
|
34
|
-
dailyPercentChange: update?.dailyPercentChangeFromOpen,
|
|
35
|
-
spread: update?.spread,
|
|
36
|
-
displayPrecision: update?.displayPrecision
|
|
37
|
-
});
|
|
38
|
-
setError(liveRatesError);
|
|
39
|
-
}
|
|
40
|
-
}, [update, record, isVisible, liveRatesError]);
|
|
41
|
-
return {
|
|
42
|
-
updatedRecord,
|
|
43
|
-
error,
|
|
44
|
-
ref: entry.ref
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export { getHeaderConfig, getRecords, useRecords };
|
|
1
|
+
const getRecords = (data, chart) => ({
|
|
2
|
+
records: data?.mapInstrumentNames?.map(item => ({
|
|
3
|
+
instrument: item?.name || '',
|
|
4
|
+
displayName: item?.displayName || '',
|
|
5
|
+
chart: chart?.topicalInstrumentsCharts?.find(ti => ti.name === item?.displayName)?.chart || []
|
|
6
|
+
})) ?? []
|
|
7
|
+
});
|
|
8
|
+
export { getRecords };
|
|
48
9
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["
|
|
1
|
+
{"version":3,"file":"utils.js","names":["getRecords","data","chart","records","mapInstrumentNames","map","item","instrument","name","displayName","topicalInstrumentsCharts","find","ti"],"sources":["../../../src/LiveRatesTableWidget/utils.ts"],"sourcesContent":["import type {\n GetInstrumentsChartQuery,\n ValidateInstrumentsQuery,\n} from '../gql/types/graphql';\nimport type { ValidateInstrumentsData } from './types';\n\nconst getRecords = (\n data: ValidateInstrumentsQuery,\n chart?: GetInstrumentsChartQuery\n): ValidateInstrumentsData => ({\n records:\n data?.mapInstrumentNames?.map((item) => ({\n instrument: item?.name || '',\n displayName: item?.displayName || '',\n chart:\n chart?.topicalInstrumentsCharts?.find(\n (ti) => ti.name === item?.displayName\n )?.chart || [],\n })) ?? [],\n});\n\nexport { getRecords };\n"],"mappings":"AAMA,MAAMA,UAAU,GAAGA,CACjBC,IAA8B,EAC9BC,KAAgC,MACH;EAC7BC,OAAO,EACLF,IAAI,EAAEG,kBAAkB,EAAEC,GAAG,CAAEC,IAAI,KAAM;IACvCC,UAAU,EAAED,IAAI,EAAEE,IAAI,IAAI,EAAE;IAC5BC,WAAW,EAAEH,IAAI,EAAEG,WAAW,IAAI,EAAE;IACpCP,KAAK,EACHA,KAAK,EAAEQ,wBAAwB,EAAEC,IAAI,CAClCC,EAAE,IAAKA,EAAE,CAACJ,IAAI,KAAKF,IAAI,EAAEG,WAC5B,CAAC,EAAEP,KAAK,IAAI;EAChB,CAAC,CAAC,CAAC,IAAI;AACX,CAAC,CAAC;AAEF,SAASF,UAAU","ignoreList":[]}
|
|
@@ -1,32 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
additionalStyles: string;
|
|
10
|
-
};
|
|
11
|
-
buy: {
|
|
12
|
-
displayName: string;
|
|
13
|
-
additionalStyles: string;
|
|
14
|
-
};
|
|
15
|
-
dailyChange: {
|
|
16
|
-
displayName: string;
|
|
17
|
-
additionalStyles: string;
|
|
18
|
-
};
|
|
19
|
-
chart: {
|
|
20
|
-
displayName: string;
|
|
21
|
-
additionalStyles: string;
|
|
22
|
-
};
|
|
23
|
-
spread: {
|
|
24
|
-
displayName: string;
|
|
25
|
-
additionalStyles: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
1
|
+
import type { HeaderColumns } from '@oanda/labs-widget-common';
|
|
2
|
+
import { DataRecordType, Size } from '@oanda/labs-widget-common';
|
|
3
|
+
type HeaderRecordType = Exclude<DataRecordType, DataRecordType.SENTIMENT>;
|
|
4
|
+
declare const headerConfig: Record<HeaderRecordType, {
|
|
5
|
+
displayName: string;
|
|
6
|
+
additionalStyles: string;
|
|
7
|
+
}>;
|
|
8
|
+
declare const getHeaderConfig: (activeColumns: DataRecordType[]) => HeaderColumns[];
|
|
28
9
|
declare const sizeConfig: {
|
|
29
10
|
cards: Size;
|
|
30
11
|
table: Size;
|
|
31
12
|
};
|
|
32
|
-
export { headerConfig, sizeConfig };
|
|
13
|
+
export { getHeaderConfig, headerConfig, sizeConfig };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataRecordType } from '@oanda/labs-widget-common';
|
|
2
2
|
declare const DEFAULT_COUNT = 10;
|
|
3
3
|
declare const DEFAULT_TOTAL_COUNT = 50;
|
|
4
|
-
declare const DEFAULT_COLUMNS:
|
|
4
|
+
declare const DEFAULT_COLUMNS: DataRecordType[];
|
|
5
5
|
declare const INSTRUMENT_TOOLTIP_ID = "instrument_tooltip_id";
|
|
6
6
|
export { DEFAULT_COLUMNS, DEFAULT_COUNT, DEFAULT_TOTAL_COUNT, INSTRUMENT_TOOLTIP_ID, };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WidgetConfig } from '@oanda/labs-widget-common';
|
|
1
|
+
import type { DataRecord, DataRecordType, WidgetConfig } from '@oanda/labs-widget-common';
|
|
2
2
|
import type { Division } from '../gql/types/graphql';
|
|
3
3
|
export { Division } from '../gql/types/graphql';
|
|
4
4
|
export { Locale } from '@oanda/mono-i18n';
|
|
@@ -6,60 +6,19 @@ export declare enum View {
|
|
|
6
6
|
TABLE = "table",
|
|
7
7
|
CARDS = "cards"
|
|
8
8
|
}
|
|
9
|
+
export interface ValidateInstrumentsData {
|
|
10
|
+
records?: DataRecord[];
|
|
11
|
+
}
|
|
9
12
|
export interface LiveRatesTableConfig extends WidgetConfig {
|
|
10
13
|
division: Division;
|
|
11
14
|
liveRatesUrl: string;
|
|
12
15
|
instruments: string[];
|
|
13
|
-
columns?:
|
|
16
|
+
columns?: DataRecordType[];
|
|
14
17
|
removePadding?: boolean;
|
|
15
18
|
view?: View;
|
|
16
19
|
}
|
|
17
|
-
export declare enum ColumnsNames {
|
|
18
|
-
INSTRUMENT = "instrument",
|
|
19
|
-
SELL = "sell",
|
|
20
|
-
BUY = "buy",
|
|
21
|
-
DAILY_CHANGE = "dailyChange",
|
|
22
|
-
CHART = "chart",
|
|
23
|
-
SPREAD = "spread"
|
|
24
|
-
}
|
|
25
20
|
export interface MainProps {
|
|
26
21
|
instruments: string[];
|
|
27
22
|
division: Division;
|
|
28
|
-
columns?:
|
|
29
|
-
}
|
|
30
|
-
export interface Sentiment {
|
|
31
|
-
shortPercent: number;
|
|
32
|
-
longPercent: number;
|
|
33
|
-
}
|
|
34
|
-
export type EmptyRecord = Record<string, never>;
|
|
35
|
-
export interface DataRecord {
|
|
36
|
-
[key: string]: string | number | undefined;
|
|
37
|
-
instrument: string;
|
|
38
|
-
displayName: string;
|
|
39
|
-
buy?: number;
|
|
40
|
-
sell?: number;
|
|
41
|
-
spread?: number;
|
|
42
|
-
sellPriceMovement?: number;
|
|
43
|
-
buyPriceMovement?: number;
|
|
44
|
-
dailyPercentChange?: string;
|
|
45
|
-
displayPrecision?: number;
|
|
46
|
-
}
|
|
47
|
-
export interface RowWithDataProps {
|
|
48
|
-
loading: boolean;
|
|
49
|
-
record: DataRecord;
|
|
50
|
-
hasBackgroundColor: boolean;
|
|
51
|
-
target: EventTarget | null;
|
|
52
|
-
activeColumns: ColumnsNames[];
|
|
53
|
-
division: Division;
|
|
54
|
-
isScrolled?: boolean;
|
|
55
|
-
}
|
|
56
|
-
export interface CardWithDataProps {
|
|
57
|
-
index: number;
|
|
58
|
-
isLoading?: boolean;
|
|
59
|
-
isError?: boolean;
|
|
60
|
-
record: DataRecord;
|
|
61
|
-
target: EventTarget | null;
|
|
62
|
-
activeColumns: ColumnsNames[];
|
|
63
|
-
division: Division;
|
|
64
|
-
isLast?: boolean;
|
|
23
|
+
columns?: DataRecordType[];
|
|
65
24
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare const getRecords: (data: ValidateInstrumentsQuery) => {
|
|
6
|
-
instrument: string;
|
|
7
|
-
displayName: string;
|
|
8
|
-
}[] | undefined;
|
|
9
|
-
declare const getHeaderConfig: (activeColumns: ColumnsNames[]) => HeaderColumns[];
|
|
10
|
-
declare const useRecords: (record: DataRecord | EmptyRecord, target: EventTarget | null) => {
|
|
11
|
-
updatedRecord: DataRecord;
|
|
12
|
-
error: LiveRatesErrorMessage | null;
|
|
13
|
-
ref: (node?: Element | null) => void;
|
|
14
|
-
};
|
|
15
|
-
export { getHeaderConfig, getRecords, useRecords };
|
|
1
|
+
import type { GetInstrumentsChartQuery, ValidateInstrumentsQuery } from '../gql/types/graphql';
|
|
2
|
+
import type { ValidateInstrumentsData } from './types';
|
|
3
|
+
declare const getRecords: (data: ValidateInstrumentsQuery, chart?: GetInstrumentsChartQuery) => ValidateInstrumentsData;
|
|
4
|
+
export { getRecords };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oanda/labs-live-rates-table-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.50",
|
|
4
4
|
"description": "Labs Live Rates Table Widget",
|
|
5
5
|
"main": "dist/main/index.js",
|
|
6
6
|
"module": "dist/module/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"author": "OANDA",
|
|
13
13
|
"license": "UNLICENSED",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@oanda/labs-widget-common": "^1.0.
|
|
15
|
+
"@oanda/labs-widget-common": "^1.0.184",
|
|
16
16
|
"@oanda/mono-i18n": "10.0.1",
|
|
17
17
|
"graphql": "16.8.1"
|
|
18
18
|
},
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"@graphql-codegen/cli": "5.0.0",
|
|
21
21
|
"@graphql-codegen/client-preset": "4.1.0"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "17da254f84365ded339ad48cb6fb9efba1c1f2cc"
|
|
24
24
|
}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DataRecord } from '@oanda/labs-widget-common';
|
|
2
2
|
import {
|
|
3
3
|
Size,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
TableWidget,
|
|
5
|
+
useFetchCombinedDataRecords,
|
|
6
6
|
useLayoutProvider,
|
|
7
7
|
useLiveRatesQuery,
|
|
8
8
|
} from '@oanda/labs-widget-common';
|
|
9
9
|
import React, { useEffect, useState } from 'react';
|
|
10
10
|
|
|
11
|
+
import { getInstrumentsChart } from '../gql/getInstrumentsChart';
|
|
11
12
|
import type {
|
|
13
|
+
GetInstrumentsChartQuery,
|
|
14
|
+
GetInstrumentsChartQueryVariables,
|
|
12
15
|
ValidateInstrumentsQuery,
|
|
13
16
|
ValidateInstrumentsQueryVariables,
|
|
14
17
|
} from '../gql/types/graphql';
|
|
15
18
|
import { validateInstruments } from '../gql/validateInstruments';
|
|
16
|
-
import {
|
|
19
|
+
import { getHeaderConfig } from './config';
|
|
17
20
|
import { DEFAULT_COLUMNS, INSTRUMENT_TOOLTIP_ID } from './constant';
|
|
18
|
-
import type {
|
|
19
|
-
import {
|
|
21
|
+
import type { MainProps, ValidateInstrumentsData } from './types';
|
|
22
|
+
import { getRecords } from './utils';
|
|
20
23
|
|
|
21
24
|
const Main = ({
|
|
22
25
|
instruments,
|
|
@@ -26,24 +29,42 @@ const Main = ({
|
|
|
26
29
|
const { size } = useLayoutProvider();
|
|
27
30
|
const isDesktop = size === Size.DESKTOP;
|
|
28
31
|
const { target, setQuery } = useLiveRatesQuery();
|
|
32
|
+
|
|
29
33
|
const [records, setRecords] = useState<DataRecord[]>(
|
|
30
34
|
new Array(instruments.length).fill({})
|
|
31
35
|
);
|
|
32
36
|
|
|
33
|
-
const {
|
|
37
|
+
const { data, loading, error } = useFetchCombinedDataRecords<
|
|
34
38
|
ValidateInstrumentsQuery,
|
|
35
|
-
ValidateInstrumentsQueryVariables
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
ValidateInstrumentsQueryVariables,
|
|
40
|
+
GetInstrumentsChartQuery,
|
|
41
|
+
GetInstrumentsChartQueryVariables,
|
|
42
|
+
ValidateInstrumentsData
|
|
43
|
+
>({
|
|
44
|
+
mainQuery: validateInstruments,
|
|
45
|
+
mainVariables: {
|
|
38
46
|
instruments,
|
|
39
47
|
division,
|
|
40
48
|
},
|
|
49
|
+
batchQuery: getInstrumentsChart,
|
|
50
|
+
getBatchVariables: (mainData) => {
|
|
51
|
+
const intrumentsByDivision = mainData?.mapInstrumentNames
|
|
52
|
+
?.filter(
|
|
53
|
+
(i): i is { displayName: string; name: string } => !!i?.displayName
|
|
54
|
+
)
|
|
55
|
+
?.map((i) => i.displayName);
|
|
56
|
+
|
|
57
|
+
return intrumentsByDivision?.length
|
|
58
|
+
? { instruments: intrumentsByDivision, division }
|
|
59
|
+
: undefined;
|
|
60
|
+
},
|
|
61
|
+
merge: (mainData, chartData) => getRecords(mainData, chartData),
|
|
41
62
|
fetchPolicy: 'network-only',
|
|
42
63
|
});
|
|
43
64
|
|
|
44
65
|
useEffect(() => {
|
|
45
66
|
if (!loading && data) {
|
|
46
|
-
setRecords(
|
|
67
|
+
setRecords(data.records ?? []);
|
|
47
68
|
}
|
|
48
69
|
}, [loading, data]);
|
|
49
70
|
|
|
@@ -59,46 +80,18 @@ const Main = ({
|
|
|
59
80
|
const showError = (!loading && !!error) || (!loading && !data);
|
|
60
81
|
|
|
61
82
|
return (
|
|
62
|
-
|
|
63
|
-
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
renderRow={(record, index, isScrolled) => (
|
|
75
|
-
<RowWithData
|
|
76
|
-
key={`row_${index}`}
|
|
77
|
-
activeColumns={columns}
|
|
78
|
-
division={division}
|
|
79
|
-
hasBackgroundColor={index % 2 === 0}
|
|
80
|
-
isScrolled={isScrolled}
|
|
81
|
-
loading={loading}
|
|
82
|
-
record={record}
|
|
83
|
-
target={target}
|
|
84
|
-
/>
|
|
85
|
-
)}
|
|
86
|
-
/>
|
|
87
|
-
</div>
|
|
88
|
-
) : (
|
|
89
|
-
<Cards
|
|
90
|
-
columns={columns}
|
|
91
|
-
division={division}
|
|
92
|
-
isError={showError}
|
|
93
|
-
isLoading={loading}
|
|
94
|
-
records={records}
|
|
95
|
-
target={target}
|
|
96
|
-
/>
|
|
97
|
-
)}
|
|
98
|
-
<Tooltip id={INSTRUMENT_TOOLTIP_ID} />
|
|
99
|
-
</div>
|
|
100
|
-
)}
|
|
101
|
-
</>
|
|
83
|
+
<TableWidget
|
|
84
|
+
activeColumns={columns}
|
|
85
|
+
count={0}
|
|
86
|
+
hasError={showError}
|
|
87
|
+
headerColumns={getHeaderConfig(columns)}
|
|
88
|
+
isLoading={loading}
|
|
89
|
+
pageNumber={0}
|
|
90
|
+
records={records}
|
|
91
|
+
target={target}
|
|
92
|
+
testId="live-rates-table-wrapper"
|
|
93
|
+
toolTipId={INSTRUMENT_TOOLTIP_ID}
|
|
94
|
+
/>
|
|
102
95
|
);
|
|
103
96
|
};
|
|
104
97
|
|
|
@@ -1,37 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { HeaderColumns } from '@oanda/labs-widget-common';
|
|
2
|
+
import { DataRecordType, Size } from '@oanda/labs-widget-common';
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import { View } from './types';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
type HeaderRecordType = Exclude<DataRecordType, DataRecordType.SENTIMENT>;
|
|
7
|
+
|
|
8
|
+
const headerConfig: Record<
|
|
9
|
+
HeaderRecordType,
|
|
10
|
+
{ displayName: string; additionalStyles: string }
|
|
11
|
+
> = {
|
|
12
|
+
[DataRecordType.INSTRUMENT]: {
|
|
7
13
|
displayName: 'instrument',
|
|
8
14
|
additionalStyles: 'lw-text-left lw-min-w-[130px]',
|
|
9
15
|
},
|
|
10
|
-
[
|
|
16
|
+
[DataRecordType.SELL]: {
|
|
11
17
|
displayName: 'sell',
|
|
12
18
|
additionalStyles: 'lw-text-right lw-min-w-[75px] lw-pr-4',
|
|
13
19
|
},
|
|
14
|
-
[
|
|
20
|
+
[DataRecordType.BUY]: {
|
|
15
21
|
displayName: 'buy',
|
|
16
22
|
additionalStyles: 'lw-text-right lw-min-w-[75px] lw-pr-4',
|
|
17
23
|
},
|
|
18
|
-
[
|
|
24
|
+
[DataRecordType.DAILY_CHANGE]: {
|
|
19
25
|
displayName: 'daily_percent_change',
|
|
20
26
|
additionalStyles: 'lw-text-right lw-min-w-[80px]',
|
|
21
27
|
},
|
|
22
|
-
[
|
|
28
|
+
[DataRecordType.CHART]: {
|
|
23
29
|
displayName: '24h_chart',
|
|
24
30
|
additionalStyles: 'lw-text-center lw-min-w-[100px]',
|
|
25
31
|
},
|
|
26
|
-
[
|
|
32
|
+
[DataRecordType.SPREAD]: {
|
|
27
33
|
displayName: 'spread',
|
|
28
34
|
additionalStyles: 'lw-text-right lw-min-w-[50px]',
|
|
29
35
|
},
|
|
30
36
|
};
|
|
31
37
|
|
|
38
|
+
const getHeaderConfig = (activeColumns: DataRecordType[]): HeaderColumns[] => {
|
|
39
|
+
const columns: HeaderRecordType[] = [
|
|
40
|
+
DataRecordType.INSTRUMENT,
|
|
41
|
+
...activeColumns,
|
|
42
|
+
].filter(
|
|
43
|
+
(item): item is HeaderRecordType => item !== DataRecordType.SENTIMENT
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return columns.map((item) => headerConfig[item]);
|
|
47
|
+
};
|
|
48
|
+
|
|
32
49
|
const sizeConfig = {
|
|
33
50
|
[View.CARDS]: Size.MOBILE,
|
|
34
51
|
[View.TABLE]: Size.DESKTOP,
|
|
35
52
|
};
|
|
36
53
|
|
|
37
|
-
export { headerConfig, sizeConfig };
|
|
54
|
+
export { getHeaderConfig, headerConfig, sizeConfig };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataRecordType } from '@oanda/labs-widget-common';
|
|
2
2
|
|
|
3
3
|
const DEFAULT_COUNT = 10;
|
|
4
4
|
|
|
5
5
|
const DEFAULT_TOTAL_COUNT = 50;
|
|
6
6
|
|
|
7
7
|
const DEFAULT_COLUMNS = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
DataRecordType.SELL,
|
|
9
|
+
DataRecordType.BUY,
|
|
10
|
+
DataRecordType.DAILY_CHANGE,
|
|
11
|
+
DataRecordType.CHART,
|
|
12
|
+
DataRecordType.SPREAD,
|
|
13
13
|
];
|
|
14
14
|
|
|
15
15
|
const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';
|