@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,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
DataRecord,
|
|
3
|
+
DataRecordType,
|
|
4
|
+
WidgetConfig,
|
|
5
|
+
} from '@oanda/labs-widget-common';
|
|
2
6
|
|
|
3
7
|
import type { Division } from '../gql/types/graphql';
|
|
4
8
|
|
|
@@ -10,67 +14,21 @@ export enum View {
|
|
|
10
14
|
CARDS = 'cards',
|
|
11
15
|
}
|
|
12
16
|
|
|
17
|
+
export interface ValidateInstrumentsData {
|
|
18
|
+
records?: DataRecord[];
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
export interface LiveRatesTableConfig extends WidgetConfig {
|
|
14
22
|
division: Division;
|
|
15
23
|
liveRatesUrl: string;
|
|
16
24
|
instruments: string[];
|
|
17
|
-
columns?:
|
|
25
|
+
columns?: DataRecordType[];
|
|
18
26
|
removePadding?: boolean;
|
|
19
27
|
view?: View;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
|
-
export enum ColumnsNames {
|
|
23
|
-
INSTRUMENT = 'instrument',
|
|
24
|
-
SELL = 'sell',
|
|
25
|
-
BUY = 'buy',
|
|
26
|
-
DAILY_CHANGE = 'dailyChange',
|
|
27
|
-
CHART = 'chart',
|
|
28
|
-
SPREAD = 'spread',
|
|
29
|
-
}
|
|
30
|
-
|
|
31
30
|
export interface MainProps {
|
|
32
31
|
instruments: string[];
|
|
33
32
|
division: Division;
|
|
34
|
-
columns?:
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface Sentiment {
|
|
38
|
-
shortPercent: number;
|
|
39
|
-
longPercent: number;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type EmptyRecord = Record<string, never>;
|
|
43
|
-
|
|
44
|
-
export interface DataRecord {
|
|
45
|
-
[key: string]: string | number | undefined;
|
|
46
|
-
instrument: string;
|
|
47
|
-
displayName: string;
|
|
48
|
-
buy?: number;
|
|
49
|
-
sell?: number;
|
|
50
|
-
spread?: number;
|
|
51
|
-
sellPriceMovement?: number;
|
|
52
|
-
buyPriceMovement?: number;
|
|
53
|
-
dailyPercentChange?: string;
|
|
54
|
-
displayPrecision?: number;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface RowWithDataProps {
|
|
58
|
-
loading: boolean;
|
|
59
|
-
record: DataRecord;
|
|
60
|
-
hasBackgroundColor: boolean;
|
|
61
|
-
target: EventTarget | null;
|
|
62
|
-
activeColumns: ColumnsNames[];
|
|
63
|
-
division: Division;
|
|
64
|
-
isScrolled?: boolean;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface CardWithDataProps {
|
|
68
|
-
index: number;
|
|
69
|
-
isLoading?: boolean;
|
|
70
|
-
isError?: boolean;
|
|
71
|
-
record: DataRecord;
|
|
72
|
-
target: EventTarget | null;
|
|
73
|
-
activeColumns: ColumnsNames[];
|
|
74
|
-
division: Division;
|
|
75
|
-
isLast?: boolean;
|
|
33
|
+
columns?: DataRecordType[];
|
|
76
34
|
}
|
|
@@ -1,66 +1,22 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from '
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const useRecords = (
|
|
24
|
-
record: DataRecord | EmptyRecord,
|
|
25
|
-
target: EventTarget | null
|
|
26
|
-
) => {
|
|
27
|
-
const [updatedRecord, setUpdatedRecord] = useState<DataRecord>({
|
|
28
|
-
displayName: record.displayName,
|
|
29
|
-
instrument: record.instrument,
|
|
30
|
-
sentiment: record.sentiment,
|
|
31
|
-
});
|
|
32
|
-
const [error, setError] = useState<LiveRatesErrorMessage | null>(null);
|
|
33
|
-
const entry = useIntersectionObserver();
|
|
34
|
-
const isVisible = !!entry?.isIntersecting;
|
|
35
|
-
|
|
36
|
-
const { update, error: liveRatesError } = useLiveRatesMessage(
|
|
37
|
-
record.instrument,
|
|
38
|
-
target
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (isVisible) {
|
|
43
|
-
setUpdatedRecord({
|
|
44
|
-
displayName: record.displayName,
|
|
45
|
-
instrument: record.instrument,
|
|
46
|
-
sentiment: record.sentiment,
|
|
47
|
-
buy: update?.ask,
|
|
48
|
-
sell: update?.bid,
|
|
49
|
-
sellPriceMovement: update?.bidPriceMovement,
|
|
50
|
-
buyPriceMovement: update?.askPriceMovement,
|
|
51
|
-
dailyPercentChange: update?.dailyPercentChangeFromOpen,
|
|
52
|
-
spread: update?.spread,
|
|
53
|
-
displayPrecision: update?.displayPrecision,
|
|
54
|
-
});
|
|
55
|
-
setError(liveRatesError);
|
|
56
|
-
}
|
|
57
|
-
}, [update, record, isVisible, liveRatesError]);
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
updatedRecord,
|
|
61
|
-
error,
|
|
62
|
-
ref: entry.ref,
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
export { getHeaderConfig, getRecords, useRecords };
|
|
2
|
+
GetInstrumentsChartQuery,
|
|
3
|
+
ValidateInstrumentsQuery,
|
|
4
|
+
} from '../gql/types/graphql';
|
|
5
|
+
import type { ValidateInstrumentsData } from './types';
|
|
6
|
+
|
|
7
|
+
const getRecords = (
|
|
8
|
+
data: ValidateInstrumentsQuery,
|
|
9
|
+
chart?: GetInstrumentsChartQuery
|
|
10
|
+
): ValidateInstrumentsData => ({
|
|
11
|
+
records:
|
|
12
|
+
data?.mapInstrumentNames?.map((item) => ({
|
|
13
|
+
instrument: item?.name || '',
|
|
14
|
+
displayName: item?.displayName || '',
|
|
15
|
+
chart:
|
|
16
|
+
chart?.topicalInstrumentsCharts?.find(
|
|
17
|
+
(ti) => ti.name === item?.displayName
|
|
18
|
+
)?.chart || [],
|
|
19
|
+
})) ?? [],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export { getRecords };
|
package/test/mocks.ts
CHANGED
|
@@ -29,7 +29,7 @@ const widgetMocks = [
|
|
|
29
29
|
request: {
|
|
30
30
|
query: getInstrumentsChart,
|
|
31
31
|
variables: {
|
|
32
|
-
instruments: ['
|
|
32
|
+
instruments: ['EUR/USD', 'GBP/USD'],
|
|
33
33
|
division: 'OC',
|
|
34
34
|
},
|
|
35
35
|
},
|
|
@@ -45,21 +45,6 @@ const widgetMocks = [
|
|
|
45
45
|
1.05556,
|
|
46
46
|
],
|
|
47
47
|
},
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
request: {
|
|
54
|
-
query: getInstrumentsChart,
|
|
55
|
-
variables: {
|
|
56
|
-
instruments: ['GBP_USD'],
|
|
57
|
-
division: 'OC',
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
result: {
|
|
61
|
-
data: {
|
|
62
|
-
topicalInstrumentsCharts: [
|
|
63
48
|
{
|
|
64
49
|
name: 'GBP_USD',
|
|
65
50
|
displayName: 'GBP/USD',
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CardWithData = void 0;
|
|
7
|
-
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
8
|
-
var _monoI18n = require("@oanda/mono-i18n");
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _constant = require("../../constant");
|
|
11
|
-
var _types = require("../../types");
|
|
12
|
-
var _utils = require("../../utils");
|
|
13
|
-
var _LineChartWithData = require("../LineChartWithData");
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
const CardWithData = _ref => {
|
|
16
|
-
let {
|
|
17
|
-
isLoading,
|
|
18
|
-
record,
|
|
19
|
-
target,
|
|
20
|
-
activeColumns,
|
|
21
|
-
index,
|
|
22
|
-
division,
|
|
23
|
-
isLast
|
|
24
|
-
} = _ref;
|
|
25
|
-
const {
|
|
26
|
-
updatedRecord,
|
|
27
|
-
error,
|
|
28
|
-
ref
|
|
29
|
-
} = (0, _utils.useRecords)(record, record.instrument ? target : null);
|
|
30
|
-
const {
|
|
31
|
-
lang
|
|
32
|
-
} = (0, _monoI18n.useLocale)();
|
|
33
|
-
const checkLoading = id => isLoading || !error && updatedRecord?.[id] === undefined;
|
|
34
|
-
return _react.default.createElement(_labsWidgetCommon.Card, {
|
|
35
|
-
ref: ref,
|
|
36
|
-
"data-testid": "card",
|
|
37
|
-
withoutBottomBorder: !isLast
|
|
38
|
-
}, _react.default.createElement(_labsWidgetCommon.CardHeader, {
|
|
39
|
-
isLoading: isLoading,
|
|
40
|
-
number: index,
|
|
41
|
-
title: _react.default.createElement(_labsWidgetCommon.Truncate, {
|
|
42
|
-
text: record.displayName,
|
|
43
|
-
tooltipId: _constant.INSTRUMENT_TOOLTIP_ID
|
|
44
|
-
})
|
|
45
|
-
}, activeColumns.includes(_types.ColumnsNames.CHART) && _react.default.createElement(_LineChartWithData.LineChartWithData, {
|
|
46
|
-
division: division,
|
|
47
|
-
isLoading: checkLoading('instrument'),
|
|
48
|
-
padding: 4,
|
|
49
|
-
record: updatedRecord,
|
|
50
|
-
size: _labsWidgetCommon.LineChartSize.xs
|
|
51
|
-
})), activeColumns.map(item => {
|
|
52
|
-
if (item === _types.ColumnsNames.SELL) {
|
|
53
|
-
return _react.default.createElement(_labsWidgetCommon.CardRow, {
|
|
54
|
-
key: _types.ColumnsNames.SELL,
|
|
55
|
-
isError: !!error,
|
|
56
|
-
isLoading: checkLoading(_types.ColumnsNames.SELL),
|
|
57
|
-
label: lang('sell_price')
|
|
58
|
-
}, _react.default.createElement(_labsWidgetCommon.Price, {
|
|
59
|
-
arrowPosition: _labsWidgetCommon.ArrowPosition.left,
|
|
60
|
-
movementIndicator: "arrow",
|
|
61
|
-
priceMovement: updatedRecord.sellPriceMovement
|
|
62
|
-
}, _react.default.createElement("span", null, updatedRecord.sell?.toFixed(updatedRecord.displayPrecision))));
|
|
63
|
-
}
|
|
64
|
-
if (item === _types.ColumnsNames.BUY) {
|
|
65
|
-
return _react.default.createElement(_labsWidgetCommon.CardRow, {
|
|
66
|
-
key: _types.ColumnsNames.BUY,
|
|
67
|
-
isError: !!error,
|
|
68
|
-
isLoading: checkLoading(_types.ColumnsNames.BUY),
|
|
69
|
-
label: lang('buy_price')
|
|
70
|
-
}, _react.default.createElement(_labsWidgetCommon.Price, {
|
|
71
|
-
arrowPosition: _labsWidgetCommon.ArrowPosition.left,
|
|
72
|
-
movementIndicator: "arrow",
|
|
73
|
-
priceMovement: updatedRecord.buyPriceMovement
|
|
74
|
-
}, _react.default.createElement("span", null, updatedRecord.buy?.toFixed(updatedRecord.displayPrecision))));
|
|
75
|
-
}
|
|
76
|
-
if (item === _types.ColumnsNames.DAILY_CHANGE) {
|
|
77
|
-
return _react.default.createElement(_labsWidgetCommon.CardRow, {
|
|
78
|
-
key: _types.ColumnsNames.DAILY_CHANGE,
|
|
79
|
-
isError: !!error,
|
|
80
|
-
isLoading: checkLoading('dailyPercentChange'),
|
|
81
|
-
label: lang('daily_percent_change')
|
|
82
|
-
}, _react.default.createElement("span", null, updatedRecord.dailyPercentChange));
|
|
83
|
-
}
|
|
84
|
-
if (item === _types.ColumnsNames.SPREAD) {
|
|
85
|
-
return _react.default.createElement(_labsWidgetCommon.CardRow, {
|
|
86
|
-
key: _types.ColumnsNames.SPREAD,
|
|
87
|
-
isError: !!error,
|
|
88
|
-
isLoading: checkLoading(_types.ColumnsNames.SPREAD),
|
|
89
|
-
label: lang('spread')
|
|
90
|
-
}, _react.default.createElement("span", null, updatedRecord.spread));
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
}));
|
|
94
|
-
};
|
|
95
|
-
exports.CardWithData = CardWithData;
|
|
96
|
-
//# sourceMappingURL=CardWithData.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CardWithData.js","names":["_labsWidgetCommon","require","_monoI18n","_react","_interopRequireDefault","_constant","_types","_utils","_LineChartWithData","e","__esModule","default","CardWithData","_ref","isLoading","record","target","activeColumns","index","division","isLast","updatedRecord","error","ref","useRecords","instrument","lang","useLocale","checkLoading","id","undefined","createElement","Card","withoutBottomBorder","CardHeader","number","title","Truncate","text","displayName","tooltipId","INSTRUMENT_TOOLTIP_ID","includes","ColumnsNames","CHART","LineChartWithData","padding","size","LineChartSize","xs","map","item","SELL","CardRow","key","isError","label","Price","arrowPosition","ArrowPosition","left","movementIndicator","priceMovement","sellPriceMovement","sell","toFixed","displayPrecision","BUY","buyPriceMovement","buy","DAILY_CHANGE","dailyPercentChange","SPREAD","spread","exports"],"sources":["../../../../../src/LiveRatesTableWidget/components/CardWithData/CardWithData.tsx"],"sourcesContent":["import {\n ArrowPosition,\n Card,\n CardHeader,\n CardRow,\n LineChartSize,\n Price,\n Truncate,\n} from '@oanda/labs-widget-common';\nimport { useLocale } from '@oanda/mono-i18n';\nimport React from 'react';\n\nimport { INSTRUMENT_TOOLTIP_ID } from '../../constant';\nimport type { CardWithDataProps } from '../../types';\nimport { ColumnsNames } from '../../types';\nimport { useRecords } from '../../utils';\nimport { LineChartWithData } from '../LineChartWithData';\n\nconst CardWithData = ({\n isLoading,\n record,\n target,\n activeColumns,\n index,\n division,\n isLast,\n}: CardWithDataProps) => {\n const { updatedRecord, error, ref } = useRecords(\n record,\n record.instrument ? target : null\n );\n const { lang } = useLocale();\n\n const checkLoading = (id: string) =>\n isLoading || (!error && updatedRecord?.[id] === undefined);\n\n return (\n <Card ref={ref} data-testid=\"card\" withoutBottomBorder={!isLast}>\n <CardHeader\n isLoading={isLoading}\n number={index}\n title={\n <Truncate\n text={record.displayName}\n tooltipId={INSTRUMENT_TOOLTIP_ID}\n />\n }\n >\n {activeColumns.includes(ColumnsNames.CHART) && (\n <LineChartWithData\n division={division}\n isLoading={checkLoading('instrument')}\n padding={4}\n record={updatedRecord}\n size={LineChartSize.xs}\n />\n )}\n </CardHeader>\n {activeColumns.map((item) => {\n if (item === ColumnsNames.SELL) {\n return (\n <CardRow\n key={ColumnsNames.SELL}\n isError={!!error}\n isLoading={checkLoading(ColumnsNames.SELL)}\n label={lang('sell_price')}\n >\n <Price\n arrowPosition={ArrowPosition.left}\n movementIndicator=\"arrow\"\n priceMovement={updatedRecord.sellPriceMovement}\n >\n <span>\n {updatedRecord.sell?.toFixed(updatedRecord.displayPrecision)}\n </span>\n </Price>\n </CardRow>\n );\n }\n\n if (item === ColumnsNames.BUY) {\n return (\n <CardRow\n key={ColumnsNames.BUY}\n isError={!!error}\n isLoading={checkLoading(ColumnsNames.BUY)}\n label={lang('buy_price')}\n >\n <Price\n arrowPosition={ArrowPosition.left}\n movementIndicator=\"arrow\"\n priceMovement={updatedRecord.buyPriceMovement}\n >\n <span>\n {updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}\n </span>\n </Price>\n </CardRow>\n );\n }\n\n if (item === ColumnsNames.DAILY_CHANGE) {\n return (\n <CardRow\n key={ColumnsNames.DAILY_CHANGE}\n isError={!!error}\n isLoading={checkLoading('dailyPercentChange')}\n label={lang('daily_percent_change')}\n >\n <span>{updatedRecord.dailyPercentChange}</span>\n </CardRow>\n );\n }\n\n if (item === ColumnsNames.SPREAD) {\n return (\n <CardRow\n key={ColumnsNames.SPREAD}\n isError={!!error}\n isLoading={checkLoading(ColumnsNames.SPREAD)}\n label={lang('spread')}\n >\n <span>{updatedRecord.spread}</span>\n </CardRow>\n );\n }\n return null;\n })}\n </Card>\n );\n};\n\nexport { CardWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AASA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,SAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AAAyD,SAAAG,uBAAAK,CAAA,WAAAA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
-
});
|
|
6
|
-
var _CardWithData = require("./CardWithData");
|
|
7
|
-
Object.keys(_CardWithData).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _CardWithData[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _CardWithData[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_CardWithData","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../../../src/LiveRatesTableWidget/components/CardWithData/index.ts"],"sourcesContent":["export * from './CardWithData';\n"],"mappings":";;;;;AAAA,IAAAA,aAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,aAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,aAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,aAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Cards = void 0;
|
|
7
|
-
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var _CardWithData = require("../CardWithData/CardWithData");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
const Cards = _ref => {
|
|
12
|
-
let {
|
|
13
|
-
records,
|
|
14
|
-
target,
|
|
15
|
-
columns,
|
|
16
|
-
isError,
|
|
17
|
-
isLoading,
|
|
18
|
-
division,
|
|
19
|
-
startIndex = 0
|
|
20
|
-
} = _ref;
|
|
21
|
-
return _react.default.createElement(_react.default.Fragment, null, isError ? _react.default.createElement(_labsWidgetCommon.Card, null, _react.default.createElement("div", {
|
|
22
|
-
className: "lw-flex lw-h-[150px] lw-w-full lw-items-center lw-justify-center"
|
|
23
|
-
}, _react.default.createElement(_labsWidgetCommon.ChartError, null))) : _react.default.createElement(_react.default.Fragment, null, records.map((record, index) => _react.default.createElement("div", {
|
|
24
|
-
key: `card_${startIndex + index}`
|
|
25
|
-
}, _react.default.createElement(_CardWithData.CardWithData, {
|
|
26
|
-
activeColumns: columns,
|
|
27
|
-
division: division,
|
|
28
|
-
index: startIndex + index + 1,
|
|
29
|
-
isError: isError,
|
|
30
|
-
isLast: index + 1 === records.length,
|
|
31
|
-
isLoading: isLoading,
|
|
32
|
-
record: record,
|
|
33
|
-
target: target
|
|
34
|
-
})))));
|
|
35
|
-
};
|
|
36
|
-
exports.Cards = Cards;
|
|
37
|
-
//# sourceMappingURL=Cards.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Cards.js","names":["_labsWidgetCommon","require","_react","_interopRequireDefault","_CardWithData","e","__esModule","default","Cards","_ref","records","target","columns","isError","isLoading","division","startIndex","createElement","Fragment","Card","className","ChartError","map","record","index","key","CardWithData","activeColumns","isLast","length","exports"],"sources":["../../../../../src/LiveRatesTableWidget/components/Cards/Cards.tsx"],"sourcesContent":["import { Card, ChartError } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport { CardWithData } from '../CardWithData/CardWithData';\nimport type { CardsProps } from './types';\n\nconst Cards = ({\n records,\n target,\n columns,\n isError,\n isLoading,\n division,\n startIndex = 0,\n}: CardsProps) => (\n <>\n {isError ? (\n <Card>\n <div className=\"lw-flex lw-h-[150px] lw-w-full lw-items-center lw-justify-center\">\n <ChartError />\n </div>\n </Card>\n ) : (\n <>\n {records.map((record, index) => (\n <div key={`card_${startIndex + index}`}>\n <CardWithData\n activeColumns={columns}\n division={division}\n index={startIndex + index + 1}\n isError={isError}\n isLast={index + 1 === records.length}\n isLoading={isLoading}\n record={record}\n target={target}\n />\n </div>\n ))}\n </>\n )}\n </>\n);\n\nexport { Cards };\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,aAAA,GAAAH,OAAA;AAA4D,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG5D,MAAMG,KAAK,GAAGC,IAAA;EAAA,IAAC;IACbC,OAAO;IACPC,MAAM;IACNC,OAAO;IACPC,OAAO;IACPC,SAAS;IACTC,QAAQ;IACRC,UAAU,GAAG;EACH,CAAC,GAAAP,IAAA;EAAA,OACXP,MAAA,CAAAK,OAAA,CAAAU,aAAA,CAAAf,MAAA,CAAAK,OAAA,CAAAW,QAAA,QACGL,OAAO,GACNX,MAAA,CAAAK,OAAA,CAAAU,aAAA,CAACjB,iBAAA,CAAAmB,IAAI,QACHjB,MAAA,CAAAK,OAAA,CAAAU,aAAA;IAAKG,SAAS,EAAC;EAAkE,GAC/ElB,MAAA,CAAAK,OAAA,CAAAU,aAAA,CAACjB,iBAAA,CAAAqB,UAAU,MAAE,CACV,CACD,CAAC,GAEPnB,MAAA,CAAAK,OAAA,CAAAU,aAAA,CAAAf,MAAA,CAAAK,OAAA,CAAAW,QAAA,QACGR,OAAO,CAACY,GAAG,CAAC,CAACC,MAAM,EAAEC,KAAK,KACzBtB,MAAA,CAAAK,OAAA,CAAAU,aAAA;IAAKQ,GAAG,EAAE,QAAQT,UAAU,GAAGQ,KAAK;EAAG,GACrCtB,MAAA,CAAAK,OAAA,CAAAU,aAAA,CAACb,aAAA,CAAAsB,YAAY;IACXC,aAAa,EAAEf,OAAQ;IACvBG,QAAQ,EAAEA,QAAS;IACnBS,KAAK,EAAER,UAAU,GAAGQ,KAAK,GAAG,CAAE;IAC9BX,OAAO,EAAEA,OAAQ;IACjBe,MAAM,EAAEJ,KAAK,GAAG,CAAC,KAAKd,OAAO,CAACmB,MAAO;IACrCf,SAAS,EAAEA,SAAU;IACrBS,MAAM,EAAEA,MAAO;IACfZ,MAAM,EAAEA;EAAO,CAChB,CACE,CACN,CACD,CAEJ,CAAC;AAAA,CACJ;AAACmB,OAAA,CAAAtB,KAAA,GAAAA,KAAA","ignoreList":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _Cards = require("./Cards");
|
|
7
|
-
Object.keys(_Cards).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _Cards[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _Cards[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Cards","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../../../src/LiveRatesTableWidget/components/Cards/index.ts"],"sourcesContent":["export * from './Cards';\n"],"mappings":";;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/LiveRatesTableWidget/components/Cards/types.tsx"],"sourcesContent":["import type { Division } from '../../../gql/types/graphql';\nimport type { ColumnsNames, DataRecord } from '../../types';\n\nexport interface CardsProps {\n startIndex?: number;\n emptyCardsCount?: number;\n isLoading?: boolean;\n isError?: boolean;\n records: DataRecord[];\n target: EventTarget | null;\n columns: ColumnsNames[];\n division: Division;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.LineChartWithData = void 0;
|
|
7
|
-
var _client = require("@apollo/client");
|
|
8
|
-
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _getInstrumentsChart = require("../../../gql/getInstrumentsChart");
|
|
11
|
-
var _utils = require("./utils");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
const LineChartWithData = _ref => {
|
|
14
|
-
let {
|
|
15
|
-
padding,
|
|
16
|
-
record,
|
|
17
|
-
size,
|
|
18
|
-
isLoading,
|
|
19
|
-
division,
|
|
20
|
-
isDarkMode = false
|
|
21
|
-
} = _ref;
|
|
22
|
-
const {
|
|
23
|
-
loading,
|
|
24
|
-
data
|
|
25
|
-
} = (0, _client.useQuery)(_getInstrumentsChart.getInstrumentsChart, {
|
|
26
|
-
variables: {
|
|
27
|
-
instruments: [record.instrument],
|
|
28
|
-
division
|
|
29
|
-
},
|
|
30
|
-
fetchPolicy: 'network-only',
|
|
31
|
-
skip: !record.instrument
|
|
32
|
-
});
|
|
33
|
-
const showLoader = isLoading || loading;
|
|
34
|
-
const chart = data?.topicalInstrumentsCharts?.[0].chart || [];
|
|
35
|
-
const chartColor = (0, _utils.getChartColor)(record.dailyPercentChange, isDarkMode);
|
|
36
|
-
return _react.default.createElement(_react.default.Fragment, null, showLoader && _react.default.createElement(_labsWidgetCommon.Loader, {
|
|
37
|
-
size: _labsWidgetCommon.LoaderSize.md
|
|
38
|
-
}), !showLoader && _react.default.createElement(_labsWidgetCommon.LineChart, {
|
|
39
|
-
color: chartColor,
|
|
40
|
-
data: chart,
|
|
41
|
-
padding: padding,
|
|
42
|
-
size: size
|
|
43
|
-
}));
|
|
44
|
-
};
|
|
45
|
-
exports.LineChartWithData = LineChartWithData;
|
|
46
|
-
//# sourceMappingURL=LineChartWithData.js.map
|
package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LineChartWithData.js","names":["_client","require","_labsWidgetCommon","_react","_interopRequireDefault","_getInstrumentsChart","_utils","e","__esModule","default","LineChartWithData","_ref","padding","record","size","isLoading","division","isDarkMode","loading","data","useQuery","getInstrumentsChart","variables","instruments","instrument","fetchPolicy","skip","showLoader","chart","topicalInstrumentsCharts","chartColor","getChartColor","dailyPercentChange","createElement","Fragment","Loader","LoaderSize","md","LineChart","color","exports"],"sources":["../../../../../src/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.tsx"],"sourcesContent":["import { useQuery } from '@apollo/client';\nimport { LineChart, Loader, LoaderSize } from '@oanda/labs-widget-common';\nimport React from 'react';\n\nimport { getInstrumentsChart } from '../../../gql/getInstrumentsChart';\nimport type {\n GetInstrumentsChartQuery,\n GetInstrumentsChartQueryVariables,\n} from '../../../gql/types/graphql';\nimport type { LineChartWithDataProps } from './types';\nimport { getChartColor } from './utils';\n\nconst LineChartWithData = ({\n padding,\n record,\n size,\n isLoading,\n division,\n isDarkMode = false,\n}: LineChartWithDataProps) => {\n const { loading, data } = useQuery<\n GetInstrumentsChartQuery,\n GetInstrumentsChartQueryVariables\n >(getInstrumentsChart, {\n variables: {\n instruments: [record.instrument],\n division,\n },\n fetchPolicy: 'network-only',\n skip: !record.instrument,\n });\n\n const showLoader = isLoading || loading;\n const chart = data?.topicalInstrumentsCharts?.[0].chart || [];\n\n const chartColor = getChartColor(record.dailyPercentChange, isDarkMode);\n\n return (\n <>\n {showLoader && <Loader size={LoaderSize.md} />}\n {!showLoader && (\n <LineChart\n color={chartColor}\n data={chart}\n padding={padding}\n size={size}\n />\n )}\n </>\n );\n};\n\nexport { LineChartWithData };\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,oBAAA,GAAAJ,OAAA;AAMA,IAAAK,MAAA,GAAAL,OAAA;AAAwC,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExC,MAAMG,iBAAiB,GAAGC,IAAA,IAOI;EAAA,IAPH;IACzBC,OAAO;IACPC,MAAM;IACNC,IAAI;IACJC,SAAS;IACTC,QAAQ;IACRC,UAAU,GAAG;EACS,CAAC,GAAAN,IAAA;EACvB,MAAM;IAAEO,OAAO;IAAEC;EAAK,CAAC,GAAG,IAAAC,gBAAQ,EAGhCC,wCAAmB,EAAE;IACrBC,SAAS,EAAE;MACTC,WAAW,EAAE,CAACV,MAAM,CAACW,UAAU,CAAC;MAChCR;IACF,CAAC;IACDS,WAAW,EAAE,cAAc;IAC3BC,IAAI,EAAE,CAACb,MAAM,CAACW;EAChB,CAAC,CAAC;EAEF,MAAMG,UAAU,GAAGZ,SAAS,IAAIG,OAAO;EACvC,MAAMU,KAAK,GAAGT,IAAI,EAAEU,wBAAwB,GAAG,CAAC,CAAC,CAACD,KAAK,IAAI,EAAE;EAE7D,MAAME,UAAU,GAAG,IAAAC,oBAAa,EAAClB,MAAM,CAACmB,kBAAkB,EAAEf,UAAU,CAAC;EAEvE,OACEd,MAAA,CAAAM,OAAA,CAAAwB,aAAA,CAAA9B,MAAA,CAAAM,OAAA,CAAAyB,QAAA,QACGP,UAAU,IAAIxB,MAAA,CAAAM,OAAA,CAAAwB,aAAA,CAAC/B,iBAAA,CAAAiC,MAAM;IAACrB,IAAI,EAAEsB,4BAAU,CAACC;EAAG,CAAE,CAAC,EAC7C,CAACV,UAAU,IACVxB,MAAA,CAAAM,OAAA,CAAAwB,aAAA,CAAC/B,iBAAA,CAAAoC,SAAS;IACRC,KAAK,EAAET,UAAW;IAClBX,IAAI,EAAES,KAAM;IACZhB,OAAO,EAAEA,OAAQ;IACjBE,IAAI,EAAEA;EAAK,CACZ,CAEH,CAAC;AAEP,CAAC;AAAC0B,OAAA,CAAA9B,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _LineChartWithData = require("./LineChartWithData");
|
|
7
|
-
Object.keys(_LineChartWithData).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _LineChartWithData[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _LineChartWithData[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_LineChartWithData","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../../../src/LiveRatesTableWidget/components/LineChartWithData/index.ts"],"sourcesContent":["export * from './LineChartWithData';\n"],"mappings":";;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,kBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,kBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,kBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../../../src/LiveRatesTableWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import type { LineChartSize } from '@oanda/labs-widget-common';\n\nimport type { Division } from '../../../gql/types/graphql';\nimport type { DataRecord } from '../../types';\n\nexport interface LineChartWithDataProps {\n padding?: number;\n record: DataRecord;\n size?: LineChartSize;\n isLoading: boolean;\n division: Division;\n isDarkMode?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getChartColor = void 0;
|
|
7
|
-
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
8
|
-
const getChartColor = (dailyChange, isDarkMode) => {
|
|
9
|
-
const theme = isDarkMode ? _labsWidgetCommon.Theme.Dark : _labsWidgetCommon.Theme.Light;
|
|
10
|
-
switch (dailyChange?.charAt(0)) {
|
|
11
|
-
case '+':
|
|
12
|
-
return _labsWidgetCommon.themeColors.ok[theme];
|
|
13
|
-
case '-':
|
|
14
|
-
return _labsWidgetCommon.themeColors.danger[theme];
|
|
15
|
-
default:
|
|
16
|
-
return _labsWidgetCommon.themeColors.borderDisabled[theme];
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
exports.getChartColor = getChartColor;
|
|
20
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":["_labsWidgetCommon","require","getChartColor","dailyChange","isDarkMode","theme","Theme","Dark","Light","charAt","themeColors","ok","danger","borderDisabled","exports"],"sources":["../../../../../src/LiveRatesTableWidget/components/LineChartWithData/utils.ts"],"sourcesContent":["import { Theme, themeColors } from '@oanda/labs-widget-common';\n\nexport const getChartColor = (dailyChange?: string, isDarkMode?: boolean) => {\n const theme = isDarkMode ? Theme.Dark : Theme.Light;\n\n switch (dailyChange?.charAt(0)) {\n case '+':\n return themeColors.ok[theme];\n case '-':\n return themeColors.danger[theme];\n default:\n return themeColors.borderDisabled[theme];\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEO,MAAMC,aAAa,GAAGA,CAACC,WAAoB,EAAEC,UAAoB,KAAK;EAC3E,MAAMC,KAAK,GAAGD,UAAU,GAAGE,uBAAK,CAACC,IAAI,GAAGD,uBAAK,CAACE,KAAK;EAEnD,QAAQL,WAAW,EAAEM,MAAM,CAAC,CAAC,CAAC;IAC5B,KAAK,GAAG;MACN,OAAOC,6BAAW,CAACC,EAAE,CAACN,KAAK,CAAC;IAC9B,KAAK,GAAG;MACN,OAAOK,6BAAW,CAACE,MAAM,CAACP,KAAK,CAAC;IAClC;MACE,OAAOK,6BAAW,CAACG,cAAc,CAACR,KAAK,CAAC;EAC5C;AACF,CAAC;AAACS,OAAA,CAAAZ,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.RowWithData = void 0;
|
|
7
|
-
var _labsWidgetCommon = require("@oanda/labs-widget-common");
|
|
8
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _constant = require("../../constant");
|
|
11
|
-
var _types = require("../../types");
|
|
12
|
-
var _utils = require("../../utils");
|
|
13
|
-
var _LineChartWithData = require("../LineChartWithData");
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
const RowWithData = _ref => {
|
|
16
|
-
let {
|
|
17
|
-
loading,
|
|
18
|
-
record,
|
|
19
|
-
hasBackgroundColor,
|
|
20
|
-
target,
|
|
21
|
-
activeColumns,
|
|
22
|
-
division,
|
|
23
|
-
isScrolled
|
|
24
|
-
} = _ref;
|
|
25
|
-
const {
|
|
26
|
-
isDark
|
|
27
|
-
} = (0, _labsWidgetCommon.useLayoutProvider)();
|
|
28
|
-
const {
|
|
29
|
-
updatedRecord,
|
|
30
|
-
error,
|
|
31
|
-
ref
|
|
32
|
-
} = (0, _utils.useRecords)(record, record.instrument ? target : null);
|
|
33
|
-
const checkLoading = id => loading || !error && updatedRecord?.[id] === undefined;
|
|
34
|
-
return _react.default.createElement(_labsWidgetCommon.TableRow, {
|
|
35
|
-
ref: ref,
|
|
36
|
-
hasBackgroundColor: hasBackgroundColor,
|
|
37
|
-
isScrolled: isScrolled
|
|
38
|
-
}, _react.default.createElement(_react.default.Fragment, null, _react.default.createElement(_labsWidgetCommon.TableCell, {
|
|
39
|
-
key: _types.ColumnsNames.INSTRUMENT,
|
|
40
|
-
classNames: (0, _classnames.default)('lw-font-bold', {
|
|
41
|
-
'[&>*:first-child]:lw-border-r [&>*:first-child]:lw-border-border-primary': isDark && isScrolled
|
|
42
|
-
}),
|
|
43
|
-
isLoading: checkLoading(_types.ColumnsNames.INSTRUMENT),
|
|
44
|
-
type: "text"
|
|
45
|
-
}, _react.default.createElement(_labsWidgetCommon.Truncate, {
|
|
46
|
-
maxWidth: 130,
|
|
47
|
-
text: record.displayName,
|
|
48
|
-
tooltipId: _constant.INSTRUMENT_TOOLTIP_ID
|
|
49
|
-
})), activeColumns.map(item => {
|
|
50
|
-
if (item === _types.ColumnsNames.SELL) {
|
|
51
|
-
return _react.default.createElement(_labsWidgetCommon.TableCell, {
|
|
52
|
-
key: _types.ColumnsNames.SELL,
|
|
53
|
-
additionalPaddingRight: true,
|
|
54
|
-
isError: !!error,
|
|
55
|
-
isLoading: checkLoading(_types.ColumnsNames.SELL)
|
|
56
|
-
}, _react.default.createElement(_labsWidgetCommon.Price, {
|
|
57
|
-
movementIndicator: "arrow",
|
|
58
|
-
priceMovement: updatedRecord.sellPriceMovement
|
|
59
|
-
}, _react.default.createElement("span", null, updatedRecord.sell?.toFixed(updatedRecord.displayPrecision))));
|
|
60
|
-
}
|
|
61
|
-
if (item === _types.ColumnsNames.BUY) {
|
|
62
|
-
return _react.default.createElement(_labsWidgetCommon.TableCell, {
|
|
63
|
-
key: _types.ColumnsNames.BUY,
|
|
64
|
-
additionalPaddingRight: true,
|
|
65
|
-
isError: !!error,
|
|
66
|
-
isLoading: checkLoading(_types.ColumnsNames.BUY)
|
|
67
|
-
}, _react.default.createElement(_labsWidgetCommon.Price, {
|
|
68
|
-
movementIndicator: "arrow",
|
|
69
|
-
priceMovement: updatedRecord.buyPriceMovement
|
|
70
|
-
}, _react.default.createElement("span", null, updatedRecord.buy?.toFixed(updatedRecord.displayPrecision))));
|
|
71
|
-
}
|
|
72
|
-
if (item === _types.ColumnsNames.DAILY_CHANGE) {
|
|
73
|
-
return _react.default.createElement(_labsWidgetCommon.TableCell, {
|
|
74
|
-
key: _types.ColumnsNames.DAILY_CHANGE,
|
|
75
|
-
isError: !!error,
|
|
76
|
-
isLoading: checkLoading('dailyPercentChange')
|
|
77
|
-
}, _react.default.createElement("span", null, updatedRecord.dailyPercentChange));
|
|
78
|
-
}
|
|
79
|
-
if (item === _types.ColumnsNames.CHART) {
|
|
80
|
-
return _react.default.createElement("td", {
|
|
81
|
-
key: _types.ColumnsNames.CHART,
|
|
82
|
-
className: "lw-relative lw-px-3 lw-py-0 lw-text-right",
|
|
83
|
-
"data-testid": "chart-table-cell"
|
|
84
|
-
}, _react.default.createElement("div", {
|
|
85
|
-
className: "lw-flex lw-justify-center"
|
|
86
|
-
}, _react.default.createElement(_LineChartWithData.LineChartWithData, {
|
|
87
|
-
division: division,
|
|
88
|
-
isLoading: checkLoading('instrument'),
|
|
89
|
-
record: updatedRecord
|
|
90
|
-
})));
|
|
91
|
-
}
|
|
92
|
-
if (item === _types.ColumnsNames.SPREAD) {
|
|
93
|
-
return _react.default.createElement(_labsWidgetCommon.TableCell, {
|
|
94
|
-
key: _types.ColumnsNames.SPREAD,
|
|
95
|
-
isError: !!error,
|
|
96
|
-
isLoading: checkLoading(_types.ColumnsNames.SPREAD),
|
|
97
|
-
loaderSize: _labsWidgetCommon.LoaderSize.sm
|
|
98
|
-
}, _react.default.createElement("span", null, updatedRecord.spread));
|
|
99
|
-
}
|
|
100
|
-
return null;
|
|
101
|
-
})));
|
|
102
|
-
};
|
|
103
|
-
exports.RowWithData = RowWithData;
|
|
104
|
-
//# sourceMappingURL=RowWithData.js.map
|