@oanda/labs-instruments-price-chart-widget 1.0.1
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 +8 -0
- package/codegen.ts +18 -0
- package/dist/main/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js +40 -0
- package/dist/main/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/Main.js +52 -0
- package/dist/main/InstrumentsPriceChartWidget/Main.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/Chart.js +39 -0
- package/dist/main/InstrumentsPriceChartWidget/components/Chart.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/constants.js +12 -0
- package/dist/main/InstrumentsPriceChartWidget/components/constants.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/formatters.js +15 -0
- package/dist/main/InstrumentsPriceChartWidget/components/formatters.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/getOption.js +119 -0
- package/dist/main/InstrumentsPriceChartWidget/components/getOption.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/components/types.js +6 -0
- package/dist/main/InstrumentsPriceChartWidget/components/types.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/config.js +44 -0
- package/dist/main/InstrumentsPriceChartWidget/config.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/index.js +28 -0
- package/dist/main/InstrumentsPriceChartWidget/index.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/render.js +42 -0
- package/dist/main/InstrumentsPriceChartWidget/render.js.map +1 -0
- package/dist/main/InstrumentsPriceChartWidget/types.js +16 -0
- package/dist/main/InstrumentsPriceChartWidget/types.js.map +1 -0
- package/dist/main/gql/mock/getPriceCandles.js +30 -0
- package/dist/main/gql/mock/getPriceCandles.js.map +1 -0
- package/dist/main/gql/mock/handlers.js +62 -0
- package/dist/main/gql/mock/handlers.js.map +1 -0
- package/dist/main/gql/mock/schema.graphqls +59 -0
- package/dist/main/gql/types/fragment-masking.js +23 -0
- package/dist/main/gql/types/fragment-masking.js.map +1 -0
- package/dist/main/gql/types/gql.js +17 -0
- package/dist/main/gql/types/gql.js.map +1 -0
- package/dist/main/gql/types/graphql.js +438 -0
- package/dist/main/gql/types/graphql.js.map +1 -0
- package/dist/main/gql/types/index.js +28 -0
- package/dist/main/gql/types/index.js.map +1 -0
- package/dist/main/gql/validateInstruments.js +16 -0
- package/dist/main/gql/validateInstruments.js.map +1 -0
- package/dist/main/index.js +17 -0
- package/dist/main/index.js.map +1 -0
- package/dist/main/translations/index.js +27 -0
- package/dist/main/translations/index.js.map +1 -0
- package/dist/main/translations/sources/en.json +2 -0
- package/dist/main/translations/sources/es.json +2 -0
- package/dist/main/translations/sources/th.json +2 -0
- package/dist/main/translations/sources/zh_TW.json +2 -0
- package/dist/main/translations/translations.js +8 -0
- package/dist/main/translations/translations.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js +33 -0
- package/dist/module/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/Main.js +44 -0
- package/dist/module/InstrumentsPriceChartWidget/Main.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/Chart.js +29 -0
- package/dist/module/InstrumentsPriceChartWidget/components/Chart.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/constants.js +6 -0
- package/dist/module/InstrumentsPriceChartWidget/components/constants.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/formatters.js +8 -0
- package/dist/module/InstrumentsPriceChartWidget/components/formatters.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/getOption.js +112 -0
- package/dist/module/InstrumentsPriceChartWidget/components/getOption.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/components/types.js +2 -0
- package/dist/module/InstrumentsPriceChartWidget/components/types.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/config.js +39 -0
- package/dist/module/InstrumentsPriceChartWidget/config.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/index.js +3 -0
- package/dist/module/InstrumentsPriceChartWidget/index.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/render.js +39 -0
- package/dist/module/InstrumentsPriceChartWidget/render.js.map +1 -0
- package/dist/module/InstrumentsPriceChartWidget/types.js +10 -0
- package/dist/module/InstrumentsPriceChartWidget/types.js.map +1 -0
- package/dist/module/gql/mock/getPriceCandles.js +25 -0
- package/dist/module/gql/mock/getPriceCandles.js.map +1 -0
- package/dist/module/gql/mock/handlers.js +56 -0
- package/dist/module/gql/mock/handlers.js.map +1 -0
- package/dist/module/gql/mock/schema.graphqls +59 -0
- package/dist/module/gql/types/fragment-masking.js +15 -0
- package/dist/module/gql/types/fragment-masking.js.map +1 -0
- package/dist/module/gql/types/gql.js +9 -0
- package/dist/module/gql/types/gql.js.map +1 -0
- package/dist/module/gql/types/graphql.js +432 -0
- package/dist/module/gql/types/graphql.js.map +1 -0
- package/dist/module/gql/types/index.js +3 -0
- package/dist/module/gql/types/index.js.map +1 -0
- package/dist/module/gql/validateInstruments.js +10 -0
- package/dist/module/gql/validateInstruments.js.map +1 -0
- package/dist/module/index.js +2 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/translations/index.js +20 -0
- package/dist/module/translations/index.js.map +1 -0
- package/dist/module/translations/sources/en.json +2 -0
- package/dist/module/translations/sources/es.json +2 -0
- package/dist/module/translations/sources/th.json +2 -0
- package/dist/module/translations/sources/zh_TW.json +2 -0
- package/dist/module/translations/translations.js +2 -0
- package/dist/module/translations/translations.js.map +1 -0
- package/dist/types/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.d.ts +4 -0
- package/dist/types/InstrumentsPriceChartWidget/Main.d.ts +4 -0
- package/dist/types/InstrumentsPriceChartWidget/components/Chart.d.ts +3 -0
- package/dist/types/InstrumentsPriceChartWidget/components/constants.d.ts +5 -0
- package/dist/types/InstrumentsPriceChartWidget/components/formatters.d.ts +1 -0
- package/dist/types/InstrumentsPriceChartWidget/components/getOption.d.ts +2 -0
- package/dist/types/InstrumentsPriceChartWidget/components/types.d.ts +14 -0
- package/dist/types/InstrumentsPriceChartWidget/config.d.ts +10 -0
- package/dist/types/InstrumentsPriceChartWidget/index.d.ts +2 -0
- package/dist/types/InstrumentsPriceChartWidget/render.d.ts +1 -0
- package/dist/types/InstrumentsPriceChartWidget/types.d.ts +15 -0
- package/dist/types/gql/mock/getPriceCandles.d.ts +2 -0
- package/dist/types/gql/mock/handlers.d.ts +1 -0
- package/dist/types/gql/types/fragment-masking.d.ts +15 -0
- package/dist/types/gql/types/gql.d.ts +47 -0
- package/dist/types/gql/types/graphql.d.ts +468 -0
- package/dist/types/gql/types/index.d.ts +2 -0
- package/dist/types/gql/validateInstruments.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/translations/index.d.ts +4 -0
- package/dist/types/translations/translations.d.ts +1 -0
- package/index.ts +1 -0
- package/lokalise.config.json +18 -0
- package/package.json +24 -0
- package/src/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.tsx +40 -0
- package/src/InstrumentsPriceChartWidget/Main.tsx +59 -0
- package/src/InstrumentsPriceChartWidget/components/Chart.tsx +47 -0
- package/src/InstrumentsPriceChartWidget/components/constants.ts +5 -0
- package/src/InstrumentsPriceChartWidget/components/formatters.ts +7 -0
- package/src/InstrumentsPriceChartWidget/components/getOption.ts +127 -0
- package/src/InstrumentsPriceChartWidget/components/types.ts +19 -0
- package/src/InstrumentsPriceChartWidget/config.ts +47 -0
- package/src/InstrumentsPriceChartWidget/index.ts +2 -0
- package/src/InstrumentsPriceChartWidget/render.tsx +52 -0
- package/src/InstrumentsPriceChartWidget/types.ts +20 -0
- package/src/gql/mock/getPriceCandles.ts +26 -0
- package/src/gql/mock/handlers.ts +66 -0
- package/src/gql/mock/schema.graphqls +59 -0
- package/src/gql/types/fragment-masking.ts +86 -0
- package/src/gql/types/gql.ts +54 -0
- package/src/gql/types/graphql.ts +723 -0
- package/src/gql/types/index.ts +2 -0
- package/src/gql/validateInstruments.ts +10 -0
- package/src/index.ts +1 -0
- package/src/translations/index.ts +17 -0
- package/src/translations/sources/en.json +2 -0
- package/src/translations/sources/es.json +2 -0
- package/src/translations/sources/th.json +2 -0
- package/src/translations/sources/zh_TW.json +2 -0
- package/src/translations/translations.ts +1 -0
- package/test/Main.test.tsx +26 -0
- package/test/mocks/chartMock.ts +52 -0
- package/test/mocks/index.ts +1 -0
- package/tsconfig.types.json +12 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
export const validateInstruments = gql`
|
|
4
|
+
query validateInstruments($instruments: [String]!, $division: Division) {
|
|
5
|
+
mapInstrumentNames(instruments: $instruments, division: $division) {
|
|
6
|
+
name
|
|
7
|
+
displayName
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
`;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InstrumentsPriceChartWidget';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Translations } from '@oanda/mono-i18n';
|
|
2
|
+
import { Locale } from '@oanda/mono-i18n';
|
|
3
|
+
|
|
4
|
+
import en from './sources/en.json';
|
|
5
|
+
import es from './sources/es.json';
|
|
6
|
+
import th from './sources/th.json';
|
|
7
|
+
import zhTW from './sources/zh_TW.json';
|
|
8
|
+
import type { defaultTranslations } from './translations';
|
|
9
|
+
|
|
10
|
+
export type TranslationKey = keyof typeof defaultTranslations;
|
|
11
|
+
|
|
12
|
+
export const translations: Translations = {
|
|
13
|
+
[Locale.en]: { translation: en },
|
|
14
|
+
[Locale.zhTW]: { translation: zhTW },
|
|
15
|
+
[Locale.es]: { translation: es },
|
|
16
|
+
[Locale.th]: { translation: th },
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultTranslations = {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
5
|
+
import { MockLayoutProvider } from '@oanda/labs-widget-common';
|
|
6
|
+
import { render } from '@testing-library/react';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
import { Division } from '../src/gql/types/graphql';
|
|
10
|
+
import { Main } from '../src/InstrumentsPriceChartWidget/Main';
|
|
11
|
+
import { chartMock } from './mocks';
|
|
12
|
+
|
|
13
|
+
describe('Main component', () => {
|
|
14
|
+
it('should render widget', async () => {
|
|
15
|
+
const { findByTestId } = render(
|
|
16
|
+
<MockedProvider mocks={chartMock}>
|
|
17
|
+
<MockLayoutProvider>
|
|
18
|
+
<Main division={Division.Oc} />
|
|
19
|
+
</MockLayoutProvider>
|
|
20
|
+
</MockedProvider>
|
|
21
|
+
);
|
|
22
|
+
expect(
|
|
23
|
+
await findByTestId('instruments-price-chart-wrapper')
|
|
24
|
+
).toBeInTheDocument();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getPriceCandles } from '../../src/gql/mock/getPriceCandles';
|
|
2
|
+
|
|
3
|
+
export const chartMock = [
|
|
4
|
+
{
|
|
5
|
+
request: {
|
|
6
|
+
query: getPriceCandles,
|
|
7
|
+
variables: {
|
|
8
|
+
instrument: 'EUR_USD',
|
|
9
|
+
granularity: 'DAY_1',
|
|
10
|
+
timeSpan: 'MONTH_1',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
result: {
|
|
14
|
+
data: {
|
|
15
|
+
getPriceCandles: [
|
|
16
|
+
{
|
|
17
|
+
__typename: 'CandlesData',
|
|
18
|
+
time: '2025-07-10T01:11:33.362Z',
|
|
19
|
+
unixTime: 1752109893,
|
|
20
|
+
candle: {
|
|
21
|
+
__typename: 'Candle',
|
|
22
|
+
high: 1.045922851017596,
|
|
23
|
+
low: 1.0453528401938712,
|
|
24
|
+
open: 1.045734906133081,
|
|
25
|
+
close: 1.0456884271571287,
|
|
26
|
+
},
|
|
27
|
+
instrument: {
|
|
28
|
+
__typename: 'Instrument',
|
|
29
|
+
displayName: 'EUR/USD',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
__typename: 'CandlesData',
|
|
34
|
+
time: '2025-07-10T01:41:33.362Z',
|
|
35
|
+
unixTime: 1752111693,
|
|
36
|
+
candle: {
|
|
37
|
+
__typename: 'Candle',
|
|
38
|
+
high: 1.0470140546917646,
|
|
39
|
+
low: 1.0461029062975133,
|
|
40
|
+
open: 1.0462692841559467,
|
|
41
|
+
close: 1.0462351419425193,
|
|
42
|
+
},
|
|
43
|
+
instrument: {
|
|
44
|
+
__typename: 'Instrument',
|
|
45
|
+
displayName: 'EUR/USD',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './chartMock';
|