@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.
Files changed (150) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/codegen.ts +18 -0
  3. package/dist/main/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js +40 -0
  4. package/dist/main/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js.map +1 -0
  5. package/dist/main/InstrumentsPriceChartWidget/Main.js +52 -0
  6. package/dist/main/InstrumentsPriceChartWidget/Main.js.map +1 -0
  7. package/dist/main/InstrumentsPriceChartWidget/components/Chart.js +39 -0
  8. package/dist/main/InstrumentsPriceChartWidget/components/Chart.js.map +1 -0
  9. package/dist/main/InstrumentsPriceChartWidget/components/constants.js +12 -0
  10. package/dist/main/InstrumentsPriceChartWidget/components/constants.js.map +1 -0
  11. package/dist/main/InstrumentsPriceChartWidget/components/formatters.js +15 -0
  12. package/dist/main/InstrumentsPriceChartWidget/components/formatters.js.map +1 -0
  13. package/dist/main/InstrumentsPriceChartWidget/components/getOption.js +119 -0
  14. package/dist/main/InstrumentsPriceChartWidget/components/getOption.js.map +1 -0
  15. package/dist/main/InstrumentsPriceChartWidget/components/types.js +6 -0
  16. package/dist/main/InstrumentsPriceChartWidget/components/types.js.map +1 -0
  17. package/dist/main/InstrumentsPriceChartWidget/config.js +44 -0
  18. package/dist/main/InstrumentsPriceChartWidget/config.js.map +1 -0
  19. package/dist/main/InstrumentsPriceChartWidget/index.js +28 -0
  20. package/dist/main/InstrumentsPriceChartWidget/index.js.map +1 -0
  21. package/dist/main/InstrumentsPriceChartWidget/render.js +42 -0
  22. package/dist/main/InstrumentsPriceChartWidget/render.js.map +1 -0
  23. package/dist/main/InstrumentsPriceChartWidget/types.js +16 -0
  24. package/dist/main/InstrumentsPriceChartWidget/types.js.map +1 -0
  25. package/dist/main/gql/mock/getPriceCandles.js +30 -0
  26. package/dist/main/gql/mock/getPriceCandles.js.map +1 -0
  27. package/dist/main/gql/mock/handlers.js +62 -0
  28. package/dist/main/gql/mock/handlers.js.map +1 -0
  29. package/dist/main/gql/mock/schema.graphqls +59 -0
  30. package/dist/main/gql/types/fragment-masking.js +23 -0
  31. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  32. package/dist/main/gql/types/gql.js +17 -0
  33. package/dist/main/gql/types/gql.js.map +1 -0
  34. package/dist/main/gql/types/graphql.js +438 -0
  35. package/dist/main/gql/types/graphql.js.map +1 -0
  36. package/dist/main/gql/types/index.js +28 -0
  37. package/dist/main/gql/types/index.js.map +1 -0
  38. package/dist/main/gql/validateInstruments.js +16 -0
  39. package/dist/main/gql/validateInstruments.js.map +1 -0
  40. package/dist/main/index.js +17 -0
  41. package/dist/main/index.js.map +1 -0
  42. package/dist/main/translations/index.js +27 -0
  43. package/dist/main/translations/index.js.map +1 -0
  44. package/dist/main/translations/sources/en.json +2 -0
  45. package/dist/main/translations/sources/es.json +2 -0
  46. package/dist/main/translations/sources/th.json +2 -0
  47. package/dist/main/translations/sources/zh_TW.json +2 -0
  48. package/dist/main/translations/translations.js +8 -0
  49. package/dist/main/translations/translations.js.map +1 -0
  50. package/dist/module/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js +33 -0
  51. package/dist/module/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.js.map +1 -0
  52. package/dist/module/InstrumentsPriceChartWidget/Main.js +44 -0
  53. package/dist/module/InstrumentsPriceChartWidget/Main.js.map +1 -0
  54. package/dist/module/InstrumentsPriceChartWidget/components/Chart.js +29 -0
  55. package/dist/module/InstrumentsPriceChartWidget/components/Chart.js.map +1 -0
  56. package/dist/module/InstrumentsPriceChartWidget/components/constants.js +6 -0
  57. package/dist/module/InstrumentsPriceChartWidget/components/constants.js.map +1 -0
  58. package/dist/module/InstrumentsPriceChartWidget/components/formatters.js +8 -0
  59. package/dist/module/InstrumentsPriceChartWidget/components/formatters.js.map +1 -0
  60. package/dist/module/InstrumentsPriceChartWidget/components/getOption.js +112 -0
  61. package/dist/module/InstrumentsPriceChartWidget/components/getOption.js.map +1 -0
  62. package/dist/module/InstrumentsPriceChartWidget/components/types.js +2 -0
  63. package/dist/module/InstrumentsPriceChartWidget/components/types.js.map +1 -0
  64. package/dist/module/InstrumentsPriceChartWidget/config.js +39 -0
  65. package/dist/module/InstrumentsPriceChartWidget/config.js.map +1 -0
  66. package/dist/module/InstrumentsPriceChartWidget/index.js +3 -0
  67. package/dist/module/InstrumentsPriceChartWidget/index.js.map +1 -0
  68. package/dist/module/InstrumentsPriceChartWidget/render.js +39 -0
  69. package/dist/module/InstrumentsPriceChartWidget/render.js.map +1 -0
  70. package/dist/module/InstrumentsPriceChartWidget/types.js +10 -0
  71. package/dist/module/InstrumentsPriceChartWidget/types.js.map +1 -0
  72. package/dist/module/gql/mock/getPriceCandles.js +25 -0
  73. package/dist/module/gql/mock/getPriceCandles.js.map +1 -0
  74. package/dist/module/gql/mock/handlers.js +56 -0
  75. package/dist/module/gql/mock/handlers.js.map +1 -0
  76. package/dist/module/gql/mock/schema.graphqls +59 -0
  77. package/dist/module/gql/types/fragment-masking.js +15 -0
  78. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  79. package/dist/module/gql/types/gql.js +9 -0
  80. package/dist/module/gql/types/gql.js.map +1 -0
  81. package/dist/module/gql/types/graphql.js +432 -0
  82. package/dist/module/gql/types/graphql.js.map +1 -0
  83. package/dist/module/gql/types/index.js +3 -0
  84. package/dist/module/gql/types/index.js.map +1 -0
  85. package/dist/module/gql/validateInstruments.js +10 -0
  86. package/dist/module/gql/validateInstruments.js.map +1 -0
  87. package/dist/module/index.js +2 -0
  88. package/dist/module/index.js.map +1 -0
  89. package/dist/module/translations/index.js +20 -0
  90. package/dist/module/translations/index.js.map +1 -0
  91. package/dist/module/translations/sources/en.json +2 -0
  92. package/dist/module/translations/sources/es.json +2 -0
  93. package/dist/module/translations/sources/th.json +2 -0
  94. package/dist/module/translations/sources/zh_TW.json +2 -0
  95. package/dist/module/translations/translations.js +2 -0
  96. package/dist/module/translations/translations.js.map +1 -0
  97. package/dist/types/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.d.ts +4 -0
  98. package/dist/types/InstrumentsPriceChartWidget/Main.d.ts +4 -0
  99. package/dist/types/InstrumentsPriceChartWidget/components/Chart.d.ts +3 -0
  100. package/dist/types/InstrumentsPriceChartWidget/components/constants.d.ts +5 -0
  101. package/dist/types/InstrumentsPriceChartWidget/components/formatters.d.ts +1 -0
  102. package/dist/types/InstrumentsPriceChartWidget/components/getOption.d.ts +2 -0
  103. package/dist/types/InstrumentsPriceChartWidget/components/types.d.ts +14 -0
  104. package/dist/types/InstrumentsPriceChartWidget/config.d.ts +10 -0
  105. package/dist/types/InstrumentsPriceChartWidget/index.d.ts +2 -0
  106. package/dist/types/InstrumentsPriceChartWidget/render.d.ts +1 -0
  107. package/dist/types/InstrumentsPriceChartWidget/types.d.ts +15 -0
  108. package/dist/types/gql/mock/getPriceCandles.d.ts +2 -0
  109. package/dist/types/gql/mock/handlers.d.ts +1 -0
  110. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  111. package/dist/types/gql/types/gql.d.ts +47 -0
  112. package/dist/types/gql/types/graphql.d.ts +468 -0
  113. package/dist/types/gql/types/index.d.ts +2 -0
  114. package/dist/types/gql/validateInstruments.d.ts +1 -0
  115. package/dist/types/index.d.ts +1 -0
  116. package/dist/types/translations/index.d.ts +4 -0
  117. package/dist/types/translations/translations.d.ts +1 -0
  118. package/index.ts +1 -0
  119. package/lokalise.config.json +18 -0
  120. package/package.json +24 -0
  121. package/src/InstrumentsPriceChartWidget/InstrumentsPriceChartWidget.tsx +40 -0
  122. package/src/InstrumentsPriceChartWidget/Main.tsx +59 -0
  123. package/src/InstrumentsPriceChartWidget/components/Chart.tsx +47 -0
  124. package/src/InstrumentsPriceChartWidget/components/constants.ts +5 -0
  125. package/src/InstrumentsPriceChartWidget/components/formatters.ts +7 -0
  126. package/src/InstrumentsPriceChartWidget/components/getOption.ts +127 -0
  127. package/src/InstrumentsPriceChartWidget/components/types.ts +19 -0
  128. package/src/InstrumentsPriceChartWidget/config.ts +47 -0
  129. package/src/InstrumentsPriceChartWidget/index.ts +2 -0
  130. package/src/InstrumentsPriceChartWidget/render.tsx +52 -0
  131. package/src/InstrumentsPriceChartWidget/types.ts +20 -0
  132. package/src/gql/mock/getPriceCandles.ts +26 -0
  133. package/src/gql/mock/handlers.ts +66 -0
  134. package/src/gql/mock/schema.graphqls +59 -0
  135. package/src/gql/types/fragment-masking.ts +86 -0
  136. package/src/gql/types/gql.ts +54 -0
  137. package/src/gql/types/graphql.ts +723 -0
  138. package/src/gql/types/index.ts +2 -0
  139. package/src/gql/validateInstruments.ts +10 -0
  140. package/src/index.ts +1 -0
  141. package/src/translations/index.ts +17 -0
  142. package/src/translations/sources/en.json +2 -0
  143. package/src/translations/sources/es.json +2 -0
  144. package/src/translations/sources/th.json +2 -0
  145. package/src/translations/sources/zh_TW.json +2 -0
  146. package/src/translations/translations.ts +1 -0
  147. package/test/Main.test.tsx +26 -0
  148. package/test/mocks/chartMock.ts +52 -0
  149. package/test/mocks/index.ts +1 -0
  150. package/tsconfig.types.json +12 -0
@@ -0,0 +1,2 @@
1
+ export * from './fragment-masking';
2
+ export * from './gql';
@@ -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,2 @@
1
+ {
2
+ }
@@ -0,0 +1,2 @@
1
+ {
2
+ }
@@ -0,0 +1,2 @@
1
+ {
2
+ }
@@ -0,0 +1,2 @@
1
+ {
2
+ }
@@ -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';
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig.types.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "outDir": "./dist",
6
+ "declarationDir": "./dist/types"
7
+ },
8
+ "include": [
9
+ "./src/**/*",
10
+ "../../types/**/*"
11
+ ]
12
+ }