@oanda/labs-instrument-live-rate-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 (155) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/codegen.ts +15 -0
  3. package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +56 -0
  4. package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -0
  5. package/dist/main/InstrumentLiveRateWidget/Main.js +77 -0
  6. package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -0
  7. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +83 -0
  8. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +1 -0
  9. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js +28 -0
  10. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +1 -0
  11. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js +25 -0
  12. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +1 -0
  13. package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +44 -0
  14. package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -0
  15. package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/index.js +17 -0
  16. package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/index.js.map +1 -0
  17. package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js +6 -0
  18. package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -0
  19. package/dist/main/InstrumentLiveRateWidget/components/index.js +17 -0
  20. package/dist/main/InstrumentLiveRateWidget/components/index.js.map +1 -0
  21. package/dist/main/InstrumentLiveRateWidget/constant.js +8 -0
  22. package/dist/main/InstrumentLiveRateWidget/constant.js.map +1 -0
  23. package/dist/main/InstrumentLiveRateWidget/render.js +51 -0
  24. package/dist/main/InstrumentLiveRateWidget/render.js.map +1 -0
  25. package/dist/main/InstrumentLiveRateWidget/types.js +20 -0
  26. package/dist/main/InstrumentLiveRateWidget/types.js.map +1 -0
  27. package/dist/main/InstrumentLiveRateWidget/utils.js +43 -0
  28. package/dist/main/InstrumentLiveRateWidget/utils.js.map +1 -0
  29. package/dist/main/gql/getInstrumentsChart.js +16 -0
  30. package/dist/main/gql/getInstrumentsChart.js.map +1 -0
  31. package/dist/main/gql/types/fragment-masking.js +23 -0
  32. package/dist/main/gql/types/fragment-masking.js.map +1 -0
  33. package/dist/main/gql/types/gql.js +17 -0
  34. package/dist/main/gql/types/gql.js.map +1 -0
  35. package/dist/main/gql/types/graphql.js +326 -0
  36. package/dist/main/gql/types/graphql.js.map +1 -0
  37. package/dist/main/gql/types/index.js +28 -0
  38. package/dist/main/gql/types/index.js.map +1 -0
  39. package/dist/main/gql/validateInstruments.js +16 -0
  40. package/dist/main/gql/validateInstruments.js.map +1 -0
  41. package/dist/main/index.js +28 -0
  42. package/dist/main/index.js.map +1 -0
  43. package/dist/main/translations/index.js +27 -0
  44. package/dist/main/translations/index.js.map +1 -0
  45. package/dist/main/translations/sources/en.json +4 -0
  46. package/dist/main/translations/sources/es.json +4 -0
  47. package/dist/main/translations/sources/th.json +4 -0
  48. package/dist/main/translations/sources/zh_TW.json +4 -0
  49. package/dist/main/translations/translations.js +11 -0
  50. package/dist/main/translations/translations.js.map +1 -0
  51. package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +49 -0
  52. package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -0
  53. package/dist/module/InstrumentLiveRateWidget/Main.js +69 -0
  54. package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -0
  55. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +74 -0
  56. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +1 -0
  57. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js +3 -0
  58. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +1 -0
  59. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js +18 -0
  60. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +1 -0
  61. package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +37 -0
  62. package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -0
  63. package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/index.js +2 -0
  64. package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/index.js.map +1 -0
  65. package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js +2 -0
  66. package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -0
  67. package/dist/module/InstrumentLiveRateWidget/components/index.js +2 -0
  68. package/dist/module/InstrumentLiveRateWidget/components/index.js.map +1 -0
  69. package/dist/module/InstrumentLiveRateWidget/constant.js +3 -0
  70. package/dist/module/InstrumentLiveRateWidget/constant.js.map +1 -0
  71. package/dist/module/InstrumentLiveRateWidget/render.js +48 -0
  72. package/dist/module/InstrumentLiveRateWidget/render.js.map +1 -0
  73. package/dist/module/InstrumentLiveRateWidget/types.js +3 -0
  74. package/dist/module/InstrumentLiveRateWidget/types.js.map +1 -0
  75. package/dist/module/InstrumentLiveRateWidget/utils.js +36 -0
  76. package/dist/module/InstrumentLiveRateWidget/utils.js.map +1 -0
  77. package/dist/module/gql/getInstrumentsChart.js +10 -0
  78. package/dist/module/gql/getInstrumentsChart.js.map +1 -0
  79. package/dist/module/gql/types/fragment-masking.js +15 -0
  80. package/dist/module/gql/types/fragment-masking.js.map +1 -0
  81. package/dist/module/gql/types/gql.js +9 -0
  82. package/dist/module/gql/types/gql.js.map +1 -0
  83. package/dist/module/gql/types/graphql.js +320 -0
  84. package/dist/module/gql/types/graphql.js.map +1 -0
  85. package/dist/module/gql/types/index.js +3 -0
  86. package/dist/module/gql/types/index.js.map +1 -0
  87. package/dist/module/gql/validateInstruments.js +10 -0
  88. package/dist/module/gql/validateInstruments.js.map +1 -0
  89. package/dist/module/index.js +3 -0
  90. package/dist/module/index.js.map +1 -0
  91. package/dist/module/translations/index.js +20 -0
  92. package/dist/module/translations/index.js.map +1 -0
  93. package/dist/module/translations/sources/en.json +4 -0
  94. package/dist/module/translations/sources/es.json +4 -0
  95. package/dist/module/translations/sources/th.json +4 -0
  96. package/dist/module/translations/sources/zh_TW.json +4 -0
  97. package/dist/module/translations/translations.js +5 -0
  98. package/dist/module/translations/translations.js.map +1 -0
  99. package/dist/types/InstrumentLiveRateWidget/InstrumentLiveRateWidget.d.ts +4 -0
  100. package/dist/types/InstrumentLiveRateWidget/Main.d.ts +4 -0
  101. package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.d.ts +4 -0
  102. package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.d.ts +2 -0
  103. package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.d.ts +3 -0
  104. package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.d.ts +4 -0
  105. package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/index.d.ts +1 -0
  106. package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/types.d.ts +11 -0
  107. package/dist/types/InstrumentLiveRateWidget/components/index.d.ts +1 -0
  108. package/dist/types/InstrumentLiveRateWidget/constant.d.ts +2 -0
  109. package/dist/types/InstrumentLiveRateWidget/render.d.ts +1 -0
  110. package/dist/types/InstrumentLiveRateWidget/types.d.ts +43 -0
  111. package/dist/types/InstrumentLiveRateWidget/utils.d.ts +12 -0
  112. package/dist/types/gql/getInstrumentsChart.d.ts +1 -0
  113. package/dist/types/gql/types/fragment-masking.d.ts +15 -0
  114. package/dist/types/gql/types/gql.d.ts +45 -0
  115. package/dist/types/gql/types/graphql.d.ts +397 -0
  116. package/dist/types/gql/types/index.d.ts +2 -0
  117. package/dist/types/gql/validateInstruments.d.ts +1 -0
  118. package/dist/types/index.d.ts +2 -0
  119. package/dist/types/translations/index.d.ts +4 -0
  120. package/dist/types/translations/translations.d.ts +4 -0
  121. package/index.ts +1 -0
  122. package/lokalise.config.json +18 -0
  123. package/package.json +25 -0
  124. package/src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx +57 -0
  125. package/src/InstrumentLiveRateWidget/Main.tsx +82 -0
  126. package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.tsx +92 -0
  127. package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.ts +2 -0
  128. package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.ts +25 -0
  129. package/src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx +48 -0
  130. package/src/InstrumentLiveRateWidget/components/LineChartWithData/index.ts +1 -0
  131. package/src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx +12 -0
  132. package/src/InstrumentLiveRateWidget/components/index.ts +1 -0
  133. package/src/InstrumentLiveRateWidget/constant.ts +5 -0
  134. package/src/InstrumentLiveRateWidget/render.tsx +48 -0
  135. package/src/InstrumentLiveRateWidget/types.tsx +50 -0
  136. package/src/InstrumentLiveRateWidget/utils.ts +49 -0
  137. package/src/gql/getInstrumentsChart.ts +10 -0
  138. package/src/gql/types/fragment-masking.ts +66 -0
  139. package/src/gql/types/gql.ts +47 -0
  140. package/src/gql/types/graphql.ts +432 -0
  141. package/src/gql/types/index.ts +2 -0
  142. package/src/gql/validateInstruments.ts +10 -0
  143. package/src/index.ts +2 -0
  144. package/src/translations/index.ts +17 -0
  145. package/src/translations/sources/en.json +4 -0
  146. package/src/translations/sources/es.json +4 -0
  147. package/src/translations/sources/th.json +4 -0
  148. package/src/translations/sources/zh_TW.json +4 -0
  149. package/src/translations/translations.ts +4 -0
  150. package/test/LineChartWithData.test.tsx +164 -0
  151. package/test/Main.test.tsx +27 -0
  152. package/test/components/InstrumentRateWithData.test.tsx +62 -0
  153. package/test/components/utils.test.ts +13 -0
  154. package/test/mocks.ts +52 -0
  155. package/tsconfig.types.json +12 -0
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
3
+ import { LocaleProvider } from '@oanda/mono-i18n';
4
+ import { ChartError, LiveRatesProvider, ThemeProvider, getLocale } from '@oanda/labs-widget-common';
5
+ import { translations } from '../translations';
6
+ import { Main } from './Main';
7
+ import { Division } from './types';
8
+ const InstrumentLiveRateWidget = _ref => {
9
+ let {
10
+ graphqlUrl,
11
+ liveRatesUrl,
12
+ instrument,
13
+ division,
14
+ locale,
15
+ theme,
16
+ isParamError,
17
+ removePadding,
18
+ size
19
+ } = _ref;
20
+ const client = new ApolloClient({
21
+ uri: graphqlUrl,
22
+ cache: new InMemoryCache()
23
+ });
24
+ const divisionCode = division === Division.Opt ? Division.Ogm : division;
25
+ const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';
26
+ return React.createElement(ThemeProvider, {
27
+ removePadding: removePadding,
28
+ theme: theme
29
+ }, React.createElement(LocaleProvider, {
30
+ locale: getLocale(locale),
31
+ translations: translations
32
+ }, React.createElement(LiveRatesProvider, {
33
+ url: liveRatesUrl,
34
+ options: {
35
+ divisionCode,
36
+ dataSource
37
+ }
38
+ }, React.createElement(ApolloProvider, {
39
+ client: client
40
+ }, isParamError ? React.createElement("div", {
41
+ className: "lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
42
+ }, React.createElement(ChartError, null)) : React.createElement(Main, {
43
+ size: size,
44
+ instrument: instrument,
45
+ division: division
46
+ })))));
47
+ };
48
+ export { InstrumentLiveRateWidget };
49
+ //# sourceMappingURL=InstrumentLiveRateWidget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InstrumentLiveRateWidget.js","names":["React","ApolloClient","InMemoryCache","ApolloProvider","LocaleProvider","ChartError","LiveRatesProvider","ThemeProvider","getLocale","translations","Main","Division","InstrumentLiveRateWidget","_ref","graphqlUrl","liveRatesUrl","instrument","division","locale","theme","isParamError","removePadding","size","client","uri","cache","divisionCode","Opt","Ogm","dataSource","createElement","url","options","className"],"sources":["../../../src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx"],"sourcesContent":["import React from 'react';\nimport { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';\nimport { LocaleProvider } from '@oanda/mono-i18n';\nimport {\n ChartError, LiveRatesProvider, ThemeProvider, getLocale,\n} from '@oanda/labs-widget-common';\nimport { translations } from '../translations';\nimport { Main } from './Main';\nimport { Division, InstrumentLiveRateConfig } from './types';\n\nconst InstrumentLiveRateWidget = ({\n graphqlUrl,\n liveRatesUrl,\n instrument,\n division,\n locale,\n theme,\n isParamError,\n removePadding,\n size,\n}: InstrumentLiveRateConfig) => {\n const client = new ApolloClient({\n uri: graphqlUrl,\n cache: new InMemoryCache(),\n });\n\n const divisionCode = division === Division.Opt ? Division.Ogm : division;\n const dataSource = divisionCode === Division.Ogm ? 'MT5' : 'V20';\n\n return (\n <ThemeProvider removePadding={removePadding} theme={theme}>\n <LocaleProvider locale={getLocale(locale)} translations={translations}>\n <LiveRatesProvider\n url={liveRatesUrl}\n options={{ divisionCode, dataSource }}\n >\n <ApolloProvider client={client}>\n {isParamError ? (\n <div className=\"lw-flex lw-h-[425px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )\n : (\n <Main\n size={size}\n instrument={instrument}\n division={division}\n />\n )}\n </ApolloProvider>\n </LiveRatesProvider>\n </LocaleProvider>\n </ThemeProvider>\n );\n};\n\nexport { InstrumentLiveRateWidget };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,YAAY,EAAEC,aAAa,EAA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A8B,aAAA,CAACzB,UAAU,MAAE,CACV,CAAC,GAGJL,KAAA,CAAA8B,aAAA,CAACpB,IAAI;IACHY,IAAI,EAAEA,IAAK;IACXN,UAAU,EAAEA,UAAW;IACvBC,QAAQ,EAAEA;EAAS,CACpB,CAES,CACC,CACL,CACH,CAAC;AAEpB,CAAC;AAED,SAASL,wBAAwB","ignoreList":[]}
@@ -0,0 +1,69 @@
1
+ import React, { useEffect, useState, useContext } from 'react';
2
+ import { useQuery } from '@apollo/client';
3
+ import { ChartError, Size, ThemeContext, Tooltip, useLiveRatesQuery } from '@oanda/labs-widget-common';
4
+ import { getRecords } from './utils';
5
+ import { INSTRUMENT_TOOLTIP_ID } from './constant';
6
+ import { validateInstruments } from '../gql/validateInstruments';
7
+ import { InstrumentRateWithData } from './components/InstrumentRateWithData';
8
+ const Main = _ref => {
9
+ let {
10
+ instrument,
11
+ division,
12
+ size: widgetSize
13
+ } = _ref;
14
+ const {
15
+ size
16
+ } = useContext(ThemeContext);
17
+ const isDesktop = size === Size.DESKTOP;
18
+ const {
19
+ target,
20
+ setQuery
21
+ } = useLiveRatesQuery();
22
+ const [records, setRecords] = useState([]);
23
+ const {
24
+ loading,
25
+ data,
26
+ error
27
+ } = useQuery(validateInstruments, {
28
+ variables: {
29
+ instruments: [instrument],
30
+ division
31
+ },
32
+ fetchPolicy: 'network-only'
33
+ });
34
+ useEffect(() => {
35
+ if (!loading && data) {
36
+ setRecords(getRecords(data));
37
+ }
38
+ }, [loading, data]);
39
+ const instrumentsNames = records.map(_ref2 => {
40
+ let {
41
+ instrument: instrumentName
42
+ } = _ref2;
43
+ return instrumentName;
44
+ });
45
+ useEffect(() => {
46
+ if (instrumentsNames[0]) {
47
+ setQuery({
48
+ instruments: instrumentsNames
49
+ });
50
+ }
51
+ }, [records, isDesktop]);
52
+ const showError = !!error;
53
+ return React.createElement(React.Fragment, null, records.length > 0 && React.createElement("div", {
54
+ "data-testid": "instrument-live-rate-wrapper",
55
+ className: "lw-relative lw-border lw-border-solid lw-border-border-primary lw-text-sm lw-tracking-normal lw-text-text-primary"
56
+ }, React.createElement(InstrumentRateWithData, {
57
+ loading: loading,
58
+ record: records[0],
59
+ target: target,
60
+ division: division,
61
+ size: widgetSize
62
+ }), React.createElement(Tooltip, {
63
+ id: INSTRUMENT_TOOLTIP_ID
64
+ })), !loading && showError && React.createElement("div", {
65
+ className: "lw-flex lw-h-[150px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary"
66
+ }, React.createElement(ChartError, null)));
67
+ };
68
+ export { Main };
69
+ //# sourceMappingURL=Main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Main.js","names":["React","useEffect","useState","useContext","useQuery","ChartError","Size","ThemeContext","Tooltip","useLiveRatesQuery","getRecords","INSTRUMENT_TOOLTIP_ID","validateInstruments","InstrumentRateWithData","Main","_ref","instrument","division","size","widgetSize","isDesktop","DESKTOP","target","setQuery","records","setRecords","loading","data","error","variables","instruments","fetchPolicy","instrumentsNames","map","_ref2","instrumentName","showError","createElement","Fragment","length","className","record","id"],"sources":["../../../src/InstrumentLiveRateWidget/Main.tsx"],"sourcesContent":["import React, { useEffect, useState, useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n ChartError,\n Size,\n ThemeContext,\n Tooltip,\n useLiveRatesQuery,\n} from '@oanda/labs-widget-common';\nimport { getRecords } from './utils';\nimport { DataRecord, MainProps } from './types';\nimport { INSTRUMENT_TOOLTIP_ID } from './constant';\nimport { validateInstruments } from '../gql/validateInstruments';\nimport { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';\nimport { InstrumentRateWithData } from './components/InstrumentRateWithData';\n\nconst Main = ({\n instrument,\n division,\n size: widgetSize,\n}: MainProps) => {\n const { size } = useContext(ThemeContext);\n const isDesktop = size === Size.DESKTOP;\n const { target, setQuery } = useLiveRatesQuery();\n const [records, setRecords] = useState<DataRecord[]>([]);\n\n const { loading, data, error } = useQuery<\n ValidateInstrumentsQuery,\n ValidateInstrumentsQueryVariables\n >(validateInstruments, {\n variables: {\n instruments: [instrument],\n division,\n },\n fetchPolicy: 'network-only',\n });\n\n useEffect(() => {\n if (!loading && data) {\n setRecords(getRecords(data)!);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [loading, data]);\n\n const instrumentsNames = records.map(({ instrument: instrumentName }) => instrumentName);\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 = !!error;\n\n return (\n <>\n {records.length > 0 && (\n <div\n data-testid=\"instrument-live-rate-wrapper\"\n className=\"lw-relative lw-border lw-border-solid lw-border-border-primary lw-text-sm lw-tracking-normal lw-text-text-primary\"\n >\n <InstrumentRateWithData\n loading={loading}\n record={records[0]}\n target={target}\n division={division}\n size={widgetSize}\n />\n <Tooltip id={INSTRUMENT_TOOLTIP_ID} />\n </div>\n )}\n {!loading && showError && (\n <div className=\"lw-flex lw-h-[150px] lw-w-full lw-items-center lw-border lw-border-solid lw-border-border-primary\">\n <ChartError />\n </div>\n )}\n </>\n );\n};\n\nexport { Main };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,EAAEC,UAAU,QAAQ,OAAO;AAC9D,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SACEC,UAAU,EACVC,IAAI,EACJC,YAAY,EACZC,OAAO,EACPC,iBAAiB,QACZ,2BAA2B;AAClC,SAASC,UAAU,QAAQ,SAAS;AAEpC,SAASC,qBAAqB,QAAQ,YAAY;AAClD,SAASC,mBAAmB,QAAQ,4BAA4B;AAEhE,SAASC,sBAAsB,QAAQ,qCAAqC;AAE5E,MAAMC,IAAI,GAAGC,IAAA,IAII;EAAA,IAJH;IACZC,UAAU;IACVC,QAAQ;IACRC,IAAI,EAAEC;EACG,CAAC,GAAAJ,IAAA;EACV,MAAM;IAAEG;EAAK,CAAC,GAAGf,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B;IACrBa,OAAO,EAAEA,OAAQ;IACjBe,MAAM,EAAEjB,OAAO,CAAC,CAAC,CAAE;IACnBF,MAAM,EAAEA,MAAO;IACfL,QAAQ,EAAEA,QAAS;IACnBC,IAAI,EAAEC;EAAW,CAClB,CAAC,EACFnB,KAAA,CAAAqC,aAAA,CAAC7B,OAAO;IAACkC,EAAE,EAAE/B;EAAsB,CAAE,CAClC,CACN,EACA,CAACe,OAAO,IAAIU,SAAS,IACpBpC,KAAA,CAAAqC,aAAA;IAAKG,SAAS,EAAC;EAAmG,GAChHxC,KAAA,CAAAqC,aAAA,CAAChC,UAAU,MAAE,CACV,CAEP,CAAC;AAEP,CAAC;AAED,SAASS,IAAI","ignoreList":[]}
@@ -0,0 +1,74 @@
1
+ import React, { useContext } from 'react';
2
+ import { LabelWrapper, Price, ThemeContext, Truncate } from '@oanda/labs-widget-common';
3
+ import classNames from 'classnames';
4
+ import { LineChartWithData } from '../LineChartWithData';
5
+ import { useRecords } from '../../utils';
6
+ import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
7
+ import { getChartColor, getColorIndicator } from './utils';
8
+ const InstrumentRateWithData = _ref => {
9
+ let {
10
+ loading,
11
+ record,
12
+ target,
13
+ division,
14
+ size = 'fullWithChart'
15
+ } = _ref;
16
+ const {
17
+ isDark
18
+ } = useContext(ThemeContext);
19
+ const {
20
+ updatedRecord,
21
+ error
22
+ } = useRecords(record, record.instrument ? target : null);
23
+ const checkLoading = id => loading || !error && updatedRecord?.[id] === undefined;
24
+ const indicator = getColorIndicator(updatedRecord.dailyPercentChange);
25
+ return React.createElement("div", {
26
+ className: "lw-flex lw-flex-col lw-px-4 lw-pb-1 lw-pt-2"
27
+ }, React.createElement("div", {
28
+ className: "lw-flex lw-items-center lw-gap-x-2"
29
+ }, React.createElement(LabelWrapper, {
30
+ isLoading: checkLoading('instrument'),
31
+ isError: !!error
32
+ }, React.createElement("span", {
33
+ className: "lw-text-xl lw-font-bold"
34
+ }, React.createElement(Truncate, {
35
+ maxWidth: 130,
36
+ text: record.displayName,
37
+ tooltipId: INSTRUMENT_TOOLTIP_ID
38
+ }))), React.createElement(LabelWrapper, {
39
+ isLoading: checkLoading('buy'),
40
+ isError: !!error
41
+ }, React.createElement("div", {
42
+ className: "lw-text-xl lw-font-bold"
43
+ }, React.createElement(Price, {
44
+ priceMovement: updatedRecord.buyPriceMovement,
45
+ withoutArrow: true
46
+ }, React.createElement("span", null, updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)))))), size !== 'compact' && React.createElement("div", {
47
+ className: "lw-mt-1 lw-flex lw-items-center lw-gap-x-2"
48
+ }, React.createElement(LabelWrapper, {
49
+ isLoading: checkLoading('dailyPercentChange'),
50
+ isError: !!error
51
+ }, React.createElement("span", {
52
+ className: classNames('lw-font-bold', {
53
+ 'lw-text-text-ok': indicator > 0,
54
+ 'lw-text-text-danger': indicator < 0,
55
+ 'lw-text-text-disabled': indicator === 0
56
+ })
57
+ }, updatedRecord.dailyPercentChange)), React.createElement(LabelWrapper, {
58
+ isLoading: checkLoading('dailyPipsChange'),
59
+ isError: !!error
60
+ }, React.createElement("span", {
61
+ className: classNames('lw-font-bold', {
62
+ 'lw-text-text-ok': indicator > 0,
63
+ 'lw-text-text-danger': indicator < 0,
64
+ 'lw-text-text-disabled': indicator === 0
65
+ })
66
+ }, `(${updatedRecord.dailyPipsChange})`)), size === 'fullWithChart' && React.createElement(LineChartWithData, {
67
+ record: updatedRecord,
68
+ isLoading: checkLoading('instrument'),
69
+ division: division,
70
+ color: getChartColor(indicator, isDark)
71
+ })));
72
+ };
73
+ export { InstrumentRateWithData };
74
+ //# sourceMappingURL=InstrumentRateWithData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InstrumentRateWithData.js","names":["React","useContext","LabelWrapper","Price","ThemeContext","Truncate","classNames","LineChartWithData","useRecords","INSTRUMENT_TOOLTIP_ID","getChartColor","getColorIndicator","InstrumentRateWithData","_ref","loading","record","target","division","size","isDark","updatedRecord","error","instrument","checkLoading","id","undefined","indicator","dailyPercentChange","createElement","className","isLoading","isError","maxWidth","text","displayName","tooltipId","priceMovement","buyPriceMovement","withoutArrow","buy","toFixed","displayPrecision","dailyPipsChange","color"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport {\n LabelWrapper, Price, ThemeContext, Truncate,\n} from '@oanda/labs-widget-common';\nimport classNames from 'classnames';\nimport { InstrumentRateWithDataProps } from '../../types';\nimport { LineChartWithData } from '../LineChartWithData';\nimport { useRecords } from '../../utils';\nimport { INSTRUMENT_TOOLTIP_ID } from '../../constant';\nimport { getChartColor, getColorIndicator } from './utils';\n\nconst InstrumentRateWithData = ({\n loading,\n record,\n target,\n division,\n size = 'fullWithChart',\n}: InstrumentRateWithDataProps) => {\n const { isDark } = useContext(ThemeContext);\n const { updatedRecord, error } = useRecords(record, record.instrument ? target : null);\n\n const checkLoading = (id: string) => loading || (!error && updatedRecord?.[id] === undefined);\n\n const indicator = getColorIndicator(updatedRecord.dailyPercentChange);\n\n return (\n <div className=\"lw-flex lw-flex-col lw-px-4 lw-pb-1 lw-pt-2\">\n <div className=\"lw-flex lw-items-center lw-gap-x-2\">\n <LabelWrapper\n isLoading={checkLoading('instrument')}\n isError={!!error}\n >\n <span className=\"lw-text-xl lw-font-bold\">\n <Truncate maxWidth={130} text={record.displayName} tooltipId={INSTRUMENT_TOOLTIP_ID} />\n </span>\n </LabelWrapper>\n <LabelWrapper\n isLoading={checkLoading('buy')}\n isError={!!error}\n >\n <div className=\"lw-text-xl lw-font-bold\">\n <Price priceMovement={updatedRecord.buyPriceMovement} withoutArrow>\n <span>{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}</span>\n </Price>\n </div>\n </LabelWrapper>\n </div>\n {size !== 'compact'\n && (\n <div className=\"lw-mt-1 lw-flex lw-items-center lw-gap-x-2\">\n <LabelWrapper\n isLoading={checkLoading('dailyPercentChange')}\n isError={!!error}\n >\n <span className={classNames('lw-font-bold', {\n 'lw-text-text-ok': indicator > 0,\n 'lw-text-text-danger': indicator < 0,\n 'lw-text-text-disabled': indicator === 0,\n })}\n >\n {updatedRecord.dailyPercentChange}\n </span>\n\n </LabelWrapper>\n <LabelWrapper\n isLoading={checkLoading('dailyPipsChange')}\n isError={!!error}\n >\n <span className={classNames('lw-font-bold', {\n 'lw-text-text-ok': indicator > 0,\n 'lw-text-text-danger': indicator < 0,\n 'lw-text-text-disabled': indicator === 0,\n })}\n >\n {`(${updatedRecord.dailyPipsChange})`}\n </span>\n </LabelWrapper>\n {size === 'fullWithChart' && (\n <LineChartWithData\n record={updatedRecord}\n isLoading={checkLoading('instrument')}\n division={division}\n color={getChartColor(indicator, isDark)}\n />\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport { InstrumentRateWithData };\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SACEC,YAAY,EAAEC,KAAK,EAAEC,YAAY,EAAEC,QAAQ,QACtC,2BAA2B;AAClC,OAAOC,UAAU,MAAM,YAAY;AAEnC,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,UAAU,QAAQ,aAAa;AACxC,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,SAAS;AAE1D,MAAMC,sBAAsB,GAAGC,IAAA,IAMI;EAAA,IANH;IAC9BC,OAAO;IACPC,MAAM;IACNC,MAAM;IACNC,QAAQ;IACRC,IAAI,GAAG;EACoB,CAAC,GAAAL,IAAA;EAC5B,MAAM;IAAEM;EAAO,CAAC,GAAGlB,UAAU,CAACG,YAAY,CAAC;EAC3C,MAAM;IAAEgB,aAAa;IAAEC;EAAM,CAAC,GAAGb,UAAU,CAACO,MAAM,EAAEA,MAAM,CAACO,UAAU,GAAGN,MAAM,GAAG,IAAI,CAAC;EAEtF,MAAMO,YAAY,GAAIC,EAAU,IAAKV,OAAO,IAAK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AAA4B,aAAA;IAAMC,SAAS,EAAEvB,UAAU,CAAC,cAAc,EAAE;MAC1C,iBAAiB,EAAEoB,SAAS,GAAG,CAAC;MAChC,qBAAqB,EAAEA,SAAS,GAAG,CAAC;MACpC,uBAAuB,EAAEA,SAAS,KAAK;IACzC,CAAC;EAAE,GAEAN,aAAa,CAACO,kBACX,CAEM,CAAC,EACf3B,KAAA,CAAA4B,aAAA,CAAC1B,YAAY;IACX4B,SAAS,EAAEP,YAAY,CAAC,iBAAiB,CAAE;IAC3CQ,OAAO,EAAE,CAAC,CAACV;EAAM,GAEjBrB,KAAA,CAAA4B,aAAA;IAAMC,SAAS,EAAEvB,UAAU,CAAC,cAAc,EAAE;MAC1C,iBAAiB,EAAEoB,SAAS,GAAG,CAAC;MAChC,qBAAqB,EAAEA,SAAS,GAAG,CAAC;MACpC,uBAAuB,EAAEA,SAAS,KAAK;IACzC,CAAC;EAAE,GAEA,IAAIN,aAAa,CAACsB,eAAe,GAC9B,CACM,CAAC,EACdxB,IAAI,KAAK,eAAe,IACzBlB,KAAA,CAAA4B,aAAA,CAACrB,iBAAiB;IAChBQ,MAAM,EAAEK,aAAc;IACtBU,SAAS,EAAEP,YAAY,CAAC,YAAY,CAAE;IACtCN,QAAQ,EAAEA,QAAS;IACnB0B,KAAK,EAAEjC,aAAa,CAACgB,SAAS,EAAEP,MAAM;EAAE,CACzC,CAEE,CAEJ,CAAC;AAEV,CAAC;AAED,SAASP,sBAAsB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export * from './InstrumentRateWithData';
2
+ export * from './utils';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.ts"],"sourcesContent":["export * from './InstrumentRateWithData';\nexport * from './utils';\n"],"mappings":"AAAA,cAAc,0BAA0B;AACxC,cAAc,SAAS","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ import { lightTheme, darkTheme } from '@oanda/labs-widget-common';
2
+ const getColorIndicator = dailyChange => {
3
+ const numberValue = Number(dailyChange?.substring(0, dailyChange.length - 1));
4
+ return Math.sign(numberValue);
5
+ };
6
+ const getChartColor = (indicator, isDarkMode) => {
7
+ const theme = isDarkMode ? darkTheme : lightTheme;
8
+ switch (indicator) {
9
+ case 1:
10
+ return theme.textOk;
11
+ case -1:
12
+ return theme.textDanger;
13
+ default:
14
+ return theme.textDisabled;
15
+ }
16
+ };
17
+ export { getColorIndicator, getChartColor };
18
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["lightTheme","darkTheme","getColorIndicator","dailyChange","numberValue","Number","substring","length","Math","sign","getChartColor","indicator","isDarkMode","theme","textOk","textDanger","textDisabled"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.ts"],"sourcesContent":["import { lightTheme, darkTheme } from '@oanda/labs-widget-common';\n\nconst getColorIndicator = (dailyChange?: string) => {\n const numberValue = Number(dailyChange?.substring(0, dailyChange.length - 1));\n\n return Math.sign(numberValue);\n};\n\nconst getChartColor = (indicator?: number, isDarkMode?: boolean) => {\n const theme = isDarkMode ? darkTheme : lightTheme;\n\n switch (indicator) {\n case 1:\n return theme.textOk;\n case -1:\n return theme.textDanger;\n default:\n return theme.textDisabled;\n }\n};\n\nexport {\n getColorIndicator,\n getChartColor,\n};\n"],"mappings":"AAAA,SAASA,UAAU,EAAEC,SAAS,QAAQ,2BAA2B;AAEjE,MAAMC,iBAAiB,GAAIC,WAAoB,IAAK;EAClD,MAAMC,WAAW,GAAGC,MAAM,CAACF,WAAW,EAAEG,SAAS,CAAC,CAAC,EAAEH,WAAW,CAACI,MAAM,GAAG,CAAC,CAAC,CAAC;EAE7E,OAAOC,IAAI,CAACC,IAAI,CAACL,WAAW,CAAC;AAC/B,CAAC;AAED,MAAMM,aAAa,GAAGA,CAACC,SAAkB,EAAEC,UAAoB,KAAK;EAClE,MAAMC,KAAK,GAAGD,UAAU,GAAGX,SAAS,GAAGD,UAAU;EAEjD,QAAQW,SAAS;IACf,KAAK,CAAC;MACJ,OAAOE,KAAK,CAACC,MAAM;IACrB,KAAK,CAAC,CAAC;MACL,OAAOD,KAAK,CAACE,UAAU;IACzB;MACE,OAAOF,KAAK,CAACG,YAAY;EAC7B;AACF,CAAC;AAED,SACEd,iBAAiB,EACjBQ,aAAa","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { useQuery } from '@apollo/client';
3
+ import { LineChart, Loader, LoaderSize } from '@oanda/labs-widget-common';
4
+ import { getInstrumentsChart } from '../../../gql/getInstrumentsChart';
5
+ const LineChartWithData = _ref => {
6
+ let {
7
+ padding,
8
+ record,
9
+ size,
10
+ isLoading,
11
+ division,
12
+ color
13
+ } = _ref;
14
+ const {
15
+ loading,
16
+ data
17
+ } = useQuery(getInstrumentsChart, {
18
+ variables: {
19
+ instruments: [record.instrument],
20
+ division
21
+ },
22
+ fetchPolicy: 'network-only',
23
+ skip: !record.instrument
24
+ });
25
+ const showLoader = isLoading || loading;
26
+ const chart = data?.topicalInstrumentsCharts?.[0].chart || [];
27
+ return React.createElement(React.Fragment, null, showLoader && React.createElement(Loader, {
28
+ size: LoaderSize.md
29
+ }), !showLoader && React.createElement(LineChart, {
30
+ padding: padding,
31
+ size: size,
32
+ color: color,
33
+ data: chart
34
+ }));
35
+ };
36
+ export { LineChartWithData };
37
+ //# sourceMappingURL=LineChartWithData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LineChartWithData.js","names":["React","useQuery","LineChart","Loader","LoaderSize","getInstrumentsChart","LineChartWithData","_ref","padding","record","size","isLoading","division","color","loading","data","variables","instruments","instrument","fetchPolicy","skip","showLoader","chart","topicalInstrumentsCharts","createElement","Fragment","md"],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx"],"sourcesContent":["import React from 'react';\nimport { useQuery } from '@apollo/client';\nimport {\n LineChart, Loader, LoaderSize,\n} from '@oanda/labs-widget-common';\nimport { LineChartWithDataProps } from './types';\nimport { getInstrumentsChart } from '../../../gql/getInstrumentsChart';\nimport { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../../../gql/types/graphql';\n\nconst LineChartWithData = ({\n padding,\n record,\n size,\n isLoading,\n division,\n color,\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 return (\n <>\n {showLoader && <Loader size={LoaderSize.md} />}\n {!showLoader && (\n <LineChart\n padding={padding}\n size={size}\n color={color}\n data={chart}\n />\n )}\n </>\n );\n};\n\nexport { LineChartWithData };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SACEC,SAAS,EAAEC,MAAM,EAAEC,UAAU,QACxB,2BAA2B;AAElC,SAASC,mBAAmB,QAAQ,kCAAkC;AAGtE,MAAMC,iBAAiB,GAAGC,IAAA,IAOI;EAAA,IAPH;IACzBC,OAAO;IACPC,MAAM;IACNC,IAAI;IACJC,SAAS;IACTC,QAAQ;IACRC;EACsB,CAAC,GAAAN,IAAA;EACvB,MAAM;IAAEO,OAAO;IAAEC;EAAK,CAAC,GAAGd,QAAQ,CAGhCI,mBAAmB,EAAE;IACrBW,SAAS,EAAE;MACTC,WAAW,EAAE,CAACR,MAAM,CAACS,UAAU,CAAC;MAChCN;IACF,CAAC;IACDO,WAAW,EAAE,cAAc;IAC3BC,IAAI,EAAE,CAACX,MAAM,CAACS;EAChB,CAAC,CAAC;EAEF,MAAMG,UAAU,GAAGV,SAAS,IAAIG,OAAO;EACvC,MAAMQ,KAAK,GAAGP,IAAI,EAAEQ,wBAAwB,GAAG,CAAC,CAAC,CAACD,KAAK,IAAI,EAAE;EAE7D,OACEtB,KAAA,CAAAwB,aAAA,CAAAxB,KAAA,CAAAyB,QAAA,QACGJ,UAAU,IAAIrB,KAAA,CAAAwB,aAAA,CAACrB,MAAM;IAACO,IAAI,EAAEN,UAAU,CAACsB;EAAG,CAAE,CAAC,EAC7C,CAACL,UAAU,IACVrB,KAAA,CAAAwB,aAAA,CAACtB,SAAS;IACRM,OAAO,EAAEA,OAAQ;IACjBE,IAAI,EAAEA,IAAK;IACXG,KAAK,EAAEA,KAAM;IACbE,IAAI,EAAEO;EAAM,CACb,CAEH,CAAC;AAEP,CAAC;AAED,SAAShB,iBAAiB","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from './LineChartWithData';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/index.ts"],"sourcesContent":["export * from './LineChartWithData';\n"],"mappings":"AAAA,cAAc,qBAAqB","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx"],"sourcesContent":["import { LineChartSize } from '@oanda/labs-widget-common';\nimport { DataRecord } from '../../types';\nimport { Division } from '../../../gql/types/graphql';\n\nexport interface LineChartWithDataProps {\n padding?: number;\n record: DataRecord;\n size?: LineChartSize;\n isLoading: boolean;\n division: Division;\n color: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from './LineChartWithData';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../src/InstrumentLiveRateWidget/components/index.ts"],"sourcesContent":["export * from './LineChartWithData';\n"],"mappings":"AAAA,cAAc,qBAAqB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';
2
+ export { INSTRUMENT_TOOLTIP_ID };
3
+ //# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.js","names":["INSTRUMENT_TOOLTIP_ID"],"sources":["../../../src/InstrumentLiveRateWidget/constant.ts"],"sourcesContent":["const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';\n\nexport {\n INSTRUMENT_TOOLTIP_ID,\n};\n"],"mappings":"AAAA,MAAMA,qBAAqB,GAAG,uBAAuB;AAErD,SACEA,qBAAqB","ignoreList":[]}
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import { validateLocale, validateToolParams } from '@oanda/labs-widget-common';
4
+ import { InstrumentLiveRateWidget } from './InstrumentLiveRateWidget';
5
+ import { Division } from '../gql/types/graphql';
6
+ const {
7
+ graphqlUrl,
8
+ liveRatesUrl
9
+ } = window.widgetsConfig || {};
10
+ const instrumentLiveRateElements = document.querySelectorAll('div[data-instrument-live-rate-params]');
11
+ instrumentLiveRateElements.forEach(element => {
12
+ const root = createRoot(element);
13
+ const params = element.getAttribute('data-instrument-live-rate-params');
14
+ const mode = element.getAttribute('data-mode');
15
+ const {
16
+ instrument,
17
+ division,
18
+ locale,
19
+ size
20
+ } = JSON.parse(params);
21
+ const isParamError = validateToolParams({
22
+ division,
23
+ locale,
24
+ graphqlUrl,
25
+ liveRatesUrl
26
+ }, [{
27
+ name: 'locale',
28
+ valueCheck: value => validateLocale(value)
29
+ }, {
30
+ name: 'division',
31
+ valueCheck: value => Object.values(Division).includes(value)
32
+ }, {
33
+ name: 'graphqlUrl'
34
+ }, {
35
+ name: 'liveRatesUrl'
36
+ }]);
37
+ root.render(React.createElement(InstrumentLiveRateWidget, {
38
+ graphqlUrl: graphqlUrl,
39
+ liveRatesUrl: liveRatesUrl,
40
+ division: division,
41
+ instrument: instrument,
42
+ locale: locale,
43
+ theme: mode,
44
+ isParamError: isParamError,
45
+ size: size
46
+ }));
47
+ });
48
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","names":["React","createRoot","validateLocale","validateToolParams","InstrumentLiveRateWidget","Division","graphqlUrl","liveRatesUrl","window","widgetsConfig","instrumentLiveRateElements","document","querySelectorAll","forEach","element","root","params","getAttribute","mode","instrument","division","locale","size","JSON","parse","isParamError","name","valueCheck","value","Object","values","includes","render","createElement","theme"],"sources":["../../../src/InstrumentLiveRateWidget/render.tsx"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';\nimport { InstrumentLiveRateWidget } from './InstrumentLiveRateWidget';\nimport { Division } from '../gql/types/graphql';\n\nconst {\n graphqlUrl,\n liveRatesUrl,\n} = window.widgetsConfig || {};\n\nconst instrumentLiveRateElements = document.querySelectorAll('div[data-instrument-live-rate-params]');\n\ninstrumentLiveRateElements.forEach((element) => {\n const root = createRoot(element);\n const params = element.getAttribute('data-instrument-live-rate-params');\n const mode = element.getAttribute('data-mode');\n const {\n instrument, division, locale, size,\n } = JSON.parse(params as string);\n\n const isParamError = validateToolParams({\n division, locale, graphqlUrl, liveRatesUrl,\n }, [{\n name: 'locale',\n valueCheck: (value) => validateLocale(value),\n }, {\n name: 'division',\n valueCheck: (value) => Object.values(Division).includes(value),\n }, {\n name: 'graphqlUrl',\n }, {\n name: 'liveRatesUrl',\n }]);\n\n root.render(\n <InstrumentLiveRateWidget\n graphqlUrl={graphqlUrl}\n liveRatesUrl={liveRatesUrl}\n division={division}\n instrument={instrument}\n locale={locale}\n theme={mode as Theme}\n isParamError={isParamError}\n size={size}\n />,\n );\n});\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAAgBC,cAAc,EAAEC,kBAAkB,QAAQ,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,EAAEhB,IAAc;IACrBO,YAAY,EAAEA,YAAa;IAC3BH,IAAI,EAAEA;EAAK,CACZ,CACH,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export { Locale } from '@oanda/mono-i18n';
2
+ export { Division } from '../gql/types/graphql';
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","names":["Locale","Division"],"sources":["../../../src/InstrumentLiveRateWidget/types.tsx"],"sourcesContent":["import { Locale } from '@oanda/mono-i18n';\nimport { Theme } from '@oanda/labs-widget-common';\nimport { Division } from '../gql/types/graphql';\n\nexport { Locale } from '@oanda/mono-i18n';\nexport { Division } from '../gql/types/graphql';\n\nexport interface InstrumentLiveRateConfig {\n graphqlUrl: string;\n division: Division;\n liveRatesUrl: string;\n instrument: string;\n locale: Locale;\n theme?: Theme;\n isParamError?: boolean;\n removePadding?: boolean;\n size?: 'compact' | 'full' | 'fullWithChart';\n}\n\nexport interface MainProps {\n instrument: string;\n division: Division;\n size?: 'compact' | 'full' | 'fullWithChart'\n}\n\nexport interface Sentiment {\n shortPercent: number;\n longPercent: number;\n}\n\nexport type EmptyRecord = Record<any, never>;\n\nexport interface DataRecord {\n [key: string]: string | number | undefined;\n instrument: string;\n displayName: string;\n buy?: number;\n buyPriceMovement?: number;\n dailyPercentChange?: string;\n dailyPipsChange?: number;\n displayPrecision?: number;\n}\n\nexport interface InstrumentRateWithDataProps {\n loading: boolean;\n record: DataRecord;\n target: EventTarget | null;\n division: Division;\n size?: 'compact' | 'full' | 'fullWithChart'\n}\n"],"mappings":"AAIA,SAASA,MAAM,QAAQ,kBAAkB;AACzC,SAASC,QAAQ,QAAQ,sBAAsB","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { useLiveRatesMessage } from '@oanda/labs-widget-common';
3
+ const getRecords = data => data?.mapInstrumentNames?.map(item => ({
4
+ instrument: item?.name || '',
5
+ displayName: item?.displayName || ''
6
+ }));
7
+ const useRecords = (record, target) => {
8
+ const [updatedRecord, setUpdatedRecord] = useState({
9
+ displayName: record.displayName,
10
+ instrument: record.instrument,
11
+ sentiment: record.sentiment
12
+ });
13
+ const [error, setError] = useState(null);
14
+ const {
15
+ update,
16
+ error: liveRatesError
17
+ } = useLiveRatesMessage(record.instrument, target);
18
+ useEffect(() => {
19
+ setUpdatedRecord({
20
+ displayName: record.displayName,
21
+ instrument: record.instrument,
22
+ buy: update?.bid,
23
+ buyPriceMovement: update?.bidPriceMovement,
24
+ dailyPercentChange: update?.dailyPercentChangeFromOpen,
25
+ dailyPipsChange: update?.dailyPipsChangeFromOpen,
26
+ displayPrecision: update?.displayPrecision
27
+ });
28
+ setError(liveRatesError);
29
+ }, [update, record, liveRatesError]);
30
+ return {
31
+ updatedRecord,
32
+ error
33
+ };
34
+ };
35
+ export { getRecords, useRecords };
36
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["useState","useEffect","useLiveRatesMessage","getRecords","data","mapInstrumentNames","map","item","instrument","name","displayName","useRecords","record","target","updatedRecord","setUpdatedRecord","sentiment","error","setError","update","liveRatesError","buy","bid","buyPriceMovement","bidPriceMovement","dailyPercentChange","dailyPercentChangeFromOpen","dailyPipsChange","dailyPipsChangeFromOpen","displayPrecision"],"sources":["../../../src/InstrumentLiveRateWidget/utils.ts"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { LiveRatesErrorMessage, useLiveRatesMessage } from '@oanda/labs-widget-common';\nimport { DataRecord, EmptyRecord } from './types';\nimport { ValidateInstrumentsQuery } from '../gql/types/graphql';\n\nconst getRecords = (data: ValidateInstrumentsQuery) => data?.mapInstrumentNames?.map((item) => ({\n instrument: item?.name || '',\n displayName: item?.displayName || '',\n}));\n\nconst useRecords = (\n record: DataRecord | EmptyRecord,\n target: EventTarget | null,\n) => {\n const [updatedRecord, setUpdatedRecord] = useState<DataRecord>({\n displayName: record.displayName,\n instrument: record.instrument,\n sentiment: record.sentiment,\n });\n const [error, setError] = useState<LiveRatesErrorMessage | null>(null);\n\n const { update, error: liveRatesError } = useLiveRatesMessage(\n record.instrument,\n target,\n );\n\n useEffect(() => {\n setUpdatedRecord({\n displayName: record.displayName,\n instrument: record.instrument,\n buy: update?.bid,\n buyPriceMovement: update?.bidPriceMovement,\n dailyPercentChange: update?.dailyPercentChangeFromOpen,\n dailyPipsChange: update?.dailyPipsChangeFromOpen,\n displayPrecision: update?.displayPrecision,\n });\n setError(liveRatesError);\n }, [update, record, liveRatesError]);\n\n return {\n updatedRecord,\n error,\n };\n};\n\nexport {\n getRecords,\n useRecords,\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAC3C,SAAgCC,mBAAmB,QAAQ,2BAA2B;AAItF,MAAMC,UAAU,GAAIC,IAA8B,IAAKA,IAAI,EAAEC,kBAAkB,EAAEC,GAAG,CAAEC,IAAI,KAAM;EAC9FC,UAAU,EAAED,IAAI,EAAEE,IAAI,IAAI,EAAE;EAC5BC,WAAW,EAAEH,IAAI,EAAEG,WAAW,IAAI;AACpC,CAAC,CAAC,CAAC;AAEH,MAAMC,UAAU,GAAGA,CACjBC,MAAgC,EAChCC,MAA0B,KACvB;EACH,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGf,QAAQ,CAAa;IAC7DU,WAAW,EAAEE,MAAM,CAACF,WAAW;IAC/BF,UAAU,EAAEI,MAAM,CAACJ,UAAU;IAC7BQ,SAAS,EAAEJ,MAAM,CAACI;EACpB,CAAC,CAAC;EACF,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGlB,QAAQ,CAA+B,IAAI,CAAC;EAEtE,MAAM;IAAEmB,MAAM;IAAEF,KAAK,EAAEG;EAAe,CAAC,GAAGlB,mBAAmB,CAC3DU,MAAM,CAACJ,UAAU,EACjBK,MACF,CAAC;EAEDZ,SAAS,CAAC,MAAM;IACdc,gBAAgB,CAAC;MACfL,WAAW,EAAEE,MAAM,CAACF,WAAW;MAC/BF,UAAU,EAAEI,MAAM,CAACJ,UAAU;MAC7Ba,GAAG,EAAEF,MAAM,EAAEG,GAAG;MAChBC,gBAAgB,EAAEJ,MAAM,EAAEK,gBAAgB;MAC1CC,kBAAkB,EAAEN,MAAM,EAAEO,0BAA0B;MACtDC,eAAe,EAAER,MAAM,EAAES,uBAAuB;MAChDC,gBAAgB,EAAEV,MAAM,EAAEU;IAC5B,CAAC,CAAC;IACFX,QAAQ,CAACE,cAAc,CAAC;EAC1B,CAAC,EAAE,CAACD,MAAM,EAAEP,MAAM,EAAEQ,cAAc,CAAC,CAAC;EAEpC,OAAO;IACLN,aAAa;IACbG;EACF,CAAC;AACH,CAAC;AAED,SACEd,UAAU,EACVQ,UAAU","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import { gql } from '@apollo/client';
2
+ export const getInstrumentsChart = gql`
3
+ query GetInstrumentsChart($instruments: [String!], $division: Division) {
4
+ topicalInstrumentsCharts(instruments: $instruments, division: $division) {
5
+ name
6
+ chart
7
+ }
8
+ }
9
+ `;
10
+ //# sourceMappingURL=getInstrumentsChart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getInstrumentsChart.js","names":["gql","getInstrumentsChart"],"sources":["../../../src/gql/getInstrumentsChart.ts"],"sourcesContent":["import { gql } from '@apollo/client';\n\nexport const getInstrumentsChart = gql`\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n`;\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AAEpC,OAAO,MAAMC,mBAAmB,GAAGD,GAAG;AACtC;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ export function useFragment(_documentNode, fragmentType) {
2
+ return fragmentType;
3
+ }
4
+ export function makeFragmentData(data, _fragment) {
5
+ return data;
6
+ }
7
+ export function isFragmentReady(queryNode, fragmentNode, data) {
8
+ const deferredFields = queryNode.__meta__?.deferredFields;
9
+ if (!deferredFields) return true;
10
+ const fragDef = fragmentNode.definitions[0];
11
+ const fragName = fragDef?.name?.value;
12
+ const fields = fragName && deferredFields[fragName] || [];
13
+ return fields.length > 0 && fields.every(field => data && field in data);
14
+ }
15
+ //# sourceMappingURL=fragment-masking.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fragment-masking.js","names":["useFragment","_documentNode","fragmentType","makeFragmentData","data","_fragment","isFragmentReady","queryNode","fragmentNode","deferredFields","__meta__","fragDef","definitions","fragName","name","value","fields","length","every","field"],"sources":["../../../../src/gql/types/fragment-masking.ts"],"sourcesContent":["import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';\nimport { FragmentDefinitionNode } from 'graphql';\nimport { Incremental } from './graphql';\n\n\nexport type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<\n infer TType,\n any\n>\n ? [TType] extends [{ ' $fragmentName'?: infer TKey }]\n ? TKey extends string\n ? { ' $fragmentRefs'?: { [key in TKey]: TType } }\n : never\n : never\n : never;\n\n// return non-nullable if `fragmentType` is non-nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: FragmentType<DocumentTypeDecoration<TType, any>>\n): TType;\n// return nullable if `fragmentType` is nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined\n): TType | null | undefined;\n// return array of non-nullable if `fragmentType` is array of non-nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>\n): ReadonlyArray<TType>;\n// return array of nullable if `fragmentType` is array of nullable\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined\n): ReadonlyArray<TType> | null | undefined;\nexport function useFragment<TType>(\n _documentNode: DocumentTypeDecoration<TType, any>,\n fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined\n): TType | ReadonlyArray<TType> | null | undefined {\n return fragmentType as any;\n}\n\n\nexport function makeFragmentData<\n F extends DocumentTypeDecoration<any, any>,\n FT extends ResultOf<F>\n>(data: FT, _fragment: F): FragmentType<F> {\n return data as FragmentType<F>;\n}\nexport function isFragmentReady<TQuery, TFrag>(\n queryNode: DocumentTypeDecoration<TQuery, any>,\n fragmentNode: TypedDocumentNode<TFrag>,\n data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined\n): data is FragmentType<typeof fragmentNode> {\n const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__\n ?.deferredFields;\n\n if (!deferredFields) return true;\n\n const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined;\n const fragName = fragDef?.name?.value;\n\n const fields = (fragName && deferredFields[fragName]) || [];\n return fields.length > 0 && fields.every(field => data && field in data);\n}\n"],"mappings":"AAoCA,OAAO,SAASA,WAAWA,CACzBC,aAAiD,EACjDC,YAAmJ,EAClG;EACjD,OAAOA,YAAY;AACrB;AAGA,OAAO,SAASC,gBAAgBA,CAG9BC,IAAQ,EAAEC,SAAY,EAAmB;EACzC,OAAOD,IAAI;AACb;AACA,OAAO,SAASE,eAAeA,CAC7BC,SAA8C,EAC9CC,YAAsC,EACtCJ,IAAiF,EACtC;EAC3C,MAAMK,cAAc,GAAIF,SAAS,CAAwEG,QAAQ,EAC7GD,cAAc;EAElB,IAAI,CAACA,cAAc,EAAE,OAAO,IAAI;EAEhC,MAAME,OAAO,GAAGH,YAAY,CAACI,WAAW,CAAC,CAAC,CAAuC;EACjF,MAAMC,QAAQ,GAAGF,OAAO,EAAEG,IAAI,EAAEC,KAAK;EAErC,MAAMC,MAAM,GAAIH,QAAQ,IAAIJ,cAAc,CAACI,QAAQ,CAAC,IAAK,EAAE;EAC3D,OAAOG,MAAM,CAACC,MAAM,GAAG,CAAC,IAAID,MAAM,CAACE,KAAK,CAACC,KAAK,IAAIf,IAAI,IAAIe,KAAK,IAAIf,IAAI,CAAC;AAC1E","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import * as types from './graphql';
2
+ const documents = {
3
+ "\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n": types.GetInstrumentsChartDocument,
4
+ "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n": types.ValidateInstrumentsDocument
5
+ };
6
+ export function graphql(source) {
7
+ return documents[source] ?? {};
8
+ }
9
+ //# sourceMappingURL=gql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gql.js","names":["types","documents","GetInstrumentsChartDocument","ValidateInstrumentsDocument","graphql","source"],"sources":["../../../../src/gql/types/gql.ts"],"sourcesContent":["/* eslint-disable */\nimport * as types from './graphql';\nimport { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';\n\n/**\n * Map of all GraphQL operations in the project.\n *\n * This map has several performance disadvantages:\n * 1. It is not tree-shakeable, so it will include all operations in the project.\n * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.\n * 3. It does not support dead code elimination, so it will add unused operations.\n *\n * Therefore it is highly recommended to use the babel or swc plugin for production.\n */\nconst documents = {\n \"\\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\\n name\\n chart\\n }\\n }\\n\": types.GetInstrumentsChartDocument,\n \"\\n query validateInstruments($instruments: [String]!, $division: Division) {\\n mapInstrumentNames(instruments: $instruments, division: $division) {\\n name\\n displayName\\n }\\n }\\n\": types.ValidateInstrumentsDocument,\n};\n\n/**\n * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n *\n *\n * @example\n * ```ts\n * const query = graphql(`query GetUser($id: ID!) { user(id: $id) { name } }`);\n * ```\n *\n * The query argument is unknown!\n * Please regenerate the types.\n */\nexport function graphql(source: string): unknown;\n\n/**\n * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n */\nexport function graphql(source: \"\\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\\n name\\n chart\\n }\\n }\\n\"): (typeof documents)[\"\\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\\n name\\n chart\\n }\\n }\\n\"];\n/**\n * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.\n */\nexport function graphql(source: \"\\n query validateInstruments($instruments: [String]!, $division: Division) {\\n mapInstrumentNames(instruments: $instruments, division: $division) {\\n name\\n displayName\\n }\\n }\\n\"): (typeof documents)[\"\\n query validateInstruments($instruments: [String]!, $division: Division) {\\n mapInstrumentNames(instruments: $instruments, division: $division) {\\n name\\n displayName\\n }\\n }\\n\"];\n\nexport function graphql(source: string) {\n return (documents as any)[source] ?? {};\n}\n\nexport type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;"],"mappings":"AACA,OAAO,KAAKA,KAAK,MAAM,WAAW;AAalC,MAAMC,SAAS,GAAG;EACd,sMAAsM,EAAED,KAAK,CAACE,2BAA2B;EACzO,sMAAsM,EAAEF,KAAK,CAACG;AAClN,CAAC;AAyBD,OAAO,SAASC,OAAOA,CAACC,MAAc,EAAE;EACtC,OAAQJ,SAAS,CAASI,MAAM,CAAC,IAAI,CAAC,CAAC;AACzC","ignoreList":[]}