@oanda/labs-ticker-tape-widget 1.0.29 → 1.0.30

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 (93) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/dist/main/TickerTapeWidget/Main.js +11 -11
  3. package/dist/main/TickerTapeWidget/Main.js.map +1 -1
  4. package/dist/main/TickerTapeWidget/TickerTapeWidget.js +15 -15
  5. package/dist/main/TickerTapeWidget/TickerTapeWidget.js.map +1 -1
  6. package/dist/main/TickerTapeWidget/ValidationWrapper.js +4 -4
  7. package/dist/main/TickerTapeWidget/ValidationWrapper.js.map +1 -1
  8. package/dist/main/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +5 -5
  9. package/dist/main/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +1 -1
  10. package/dist/main/TickerTapeWidget/components/InstrumentRateWithData/types.js.map +1 -1
  11. package/dist/main/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.js +1 -1
  12. package/dist/main/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.js.map +1 -1
  13. package/dist/main/TickerTapeWidget/constant.js.map +1 -1
  14. package/dist/main/TickerTapeWidget/index.js +8 -8
  15. package/dist/main/TickerTapeWidget/index.js.map +1 -1
  16. package/dist/main/TickerTapeWidget/render.js +7 -7
  17. package/dist/main/TickerTapeWidget/render.js.map +1 -1
  18. package/dist/main/TickerTapeWidget/types.js +1 -1
  19. package/dist/main/TickerTapeWidget/types.js.map +1 -1
  20. package/dist/main/TickerTapeWidget/utils.js +1 -1
  21. package/dist/main/TickerTapeWidget/utils.js.map +1 -1
  22. package/dist/main/gql/types/fragment-masking.js.map +1 -1
  23. package/dist/main/gql/types/gql.js +2 -2
  24. package/dist/main/gql/types/gql.js.map +1 -1
  25. package/dist/main/gql/types/graphql.js +142 -142
  26. package/dist/main/gql/types/graphql.js.map +1 -1
  27. package/dist/main/gql/types/index.js.map +1 -1
  28. package/dist/main/translations/index.js +1 -1
  29. package/dist/main/translations/index.js.map +1 -1
  30. package/dist/main/translations/translations.js.map +1 -1
  31. package/dist/module/TickerTapeWidget/Main.js +10 -10
  32. package/dist/module/TickerTapeWidget/Main.js.map +1 -1
  33. package/dist/module/TickerTapeWidget/TickerTapeWidget.js +15 -15
  34. package/dist/module/TickerTapeWidget/TickerTapeWidget.js.map +1 -1
  35. package/dist/module/TickerTapeWidget/ValidationWrapper.js +4 -4
  36. package/dist/module/TickerTapeWidget/ValidationWrapper.js.map +1 -1
  37. package/dist/module/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +5 -5
  38. package/dist/module/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +1 -1
  39. package/dist/module/TickerTapeWidget/components/InstrumentRateWithData/types.js.map +1 -1
  40. package/dist/module/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.js +1 -1
  41. package/dist/module/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.js.map +1 -1
  42. package/dist/module/TickerTapeWidget/constant.js.map +1 -1
  43. package/dist/module/TickerTapeWidget/index.js +1 -1
  44. package/dist/module/TickerTapeWidget/index.js.map +1 -1
  45. package/dist/module/TickerTapeWidget/render.js +7 -7
  46. package/dist/module/TickerTapeWidget/render.js.map +1 -1
  47. package/dist/module/TickerTapeWidget/types.js +1 -1
  48. package/dist/module/TickerTapeWidget/types.js.map +1 -1
  49. package/dist/module/TickerTapeWidget/utils.js +1 -1
  50. package/dist/module/TickerTapeWidget/utils.js.map +1 -1
  51. package/dist/module/gql/types/fragment-masking.js.map +1 -1
  52. package/dist/module/gql/types/gql.js +2 -2
  53. package/dist/module/gql/types/gql.js.map +1 -1
  54. package/dist/module/gql/types/graphql.js +142 -142
  55. package/dist/module/gql/types/graphql.js.map +1 -1
  56. package/dist/module/gql/types/index.js +2 -2
  57. package/dist/module/gql/types/index.js.map +1 -1
  58. package/dist/module/translations/index.js +1 -1
  59. package/dist/module/translations/index.js.map +1 -1
  60. package/dist/module/translations/translations.js.map +1 -1
  61. package/dist/types/TickerTapeWidget/Main.d.ts +1 -1
  62. package/dist/types/TickerTapeWidget/TickerTapeWidget.d.ts +1 -1
  63. package/dist/types/TickerTapeWidget/ValidationWrapper.d.ts +1 -1
  64. package/dist/types/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.d.ts +1 -1
  65. package/dist/types/TickerTapeWidget/components/InstrumentRateWithData/types.d.ts +2 -2
  66. package/dist/types/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.d.ts +1 -1
  67. package/dist/types/TickerTapeWidget/constant.d.ts +1 -1
  68. package/dist/types/TickerTapeWidget/index.d.ts +1 -1
  69. package/dist/types/TickerTapeWidget/types.d.ts +3 -3
  70. package/dist/types/TickerTapeWidget/utils.d.ts +3 -3
  71. package/dist/types/gql/types/gql.d.ts +4 -4
  72. package/dist/types/gql/types/index.d.ts +2 -2
  73. package/dist/types/translations/index.d.ts +2 -2
  74. package/package.json +3 -3
  75. package/src/TickerTapeWidget/Main.tsx +23 -14
  76. package/src/TickerTapeWidget/TickerTapeWidget.tsx +16 -14
  77. package/src/TickerTapeWidget/ValidationWrapper.tsx +23 -15
  78. package/src/TickerTapeWidget/components/InstrumentRateWithData/InstrumentRateWithData.tsx +12 -8
  79. package/src/TickerTapeWidget/components/InstrumentRateWithData/types.ts +4 -3
  80. package/src/TickerTapeWidget/components/MarqueeWrapper/MarqueeWrapper.tsx +6 -8
  81. package/src/TickerTapeWidget/constant.ts +1 -3
  82. package/src/TickerTapeWidget/index.ts +1 -1
  83. package/src/TickerTapeWidget/render.tsx +47 -32
  84. package/src/TickerTapeWidget/types.ts +8 -3
  85. package/src/TickerTapeWidget/utils.ts +16 -16
  86. package/src/gql/types/fragment-masking.ts +41 -21
  87. package/src/gql/types/gql.ts +12 -5
  88. package/src/gql/types/graphql.ts +214 -50
  89. package/src/gql/types/index.ts +2 -2
  90. package/src/translations/index.ts +4 -4
  91. package/src/translations/translations.ts +2 -1
  92. package/test/Main.test.tsx +15 -9
  93. package/test/mocks.ts +1 -3
@@ -1,2 +1,2 @@
1
- export * from "./fragment-masking";
2
- export * from "./gql";
1
+ export * from './fragment-masking';
2
+ export * from './gql';
@@ -1,4 +1,4 @@
1
- import { Translations } from '@oanda/mono-i18n';
2
- import { defaultTranslations } from './translations';
1
+ import type { Translations } from '@oanda/mono-i18n';
2
+ import type { defaultTranslations } from './translations';
3
3
  export type TranslationKey = keyof typeof defaultTranslations;
4
4
  export declare const translations: Translations;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oanda/labs-ticker-tape-widget",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "description": "Labs Ticker Tape Widget",
5
5
  "main": "dist/main/index.js",
6
6
  "module": "dist/module/index.js",
@@ -12,7 +12,7 @@
12
12
  "author": "OANDA",
13
13
  "license": "UNLICENSED",
14
14
  "dependencies": {
15
- "@oanda/labs-widget-common": "^1.0.173",
15
+ "@oanda/labs-widget-common": "^1.0.174",
16
16
  "@oanda/mono-i18n": "10.0.1",
17
17
  "graphql": "16.8.1",
18
18
  "react-fast-marquee": "1.6.5"
@@ -21,5 +21,5 @@
21
21
  "@graphql-codegen/cli": "5.0.0",
22
22
  "@graphql-codegen/client-preset": "4.1.0"
23
23
  },
24
- "gitHead": "67a7801f99f0bab94dd6067a102761f51de786c1"
24
+ "gitHead": "4c5d84b00c7fbf3acd7ef27634fbd2a9ef0afd6b"
25
25
  }
@@ -1,10 +1,11 @@
1
- import React, { useEffect } from 'react';
2
- import classnames from 'classnames';
3
1
  import { Tooltip, useLiveRatesQuery } from '@oanda/labs-widget-common';
4
- import { MainProps } from './types';
5
- import { INSTRUMENT_TOOLTIP_ID } from './constant';
2
+ import classnames from 'classnames';
3
+ import React, { useEffect } from 'react';
4
+
6
5
  import { InstrumentRateWithData } from './components/InstrumentRateWithData';
7
6
  import { MarqueeWrapper } from './components/MarqueeWrapper';
7
+ import { INSTRUMENT_TOOLTIP_ID } from './constant';
8
+ import type { MainProps } from './types';
8
9
 
9
10
  const Main = ({
10
11
  records,
@@ -14,7 +15,9 @@ const Main = ({
14
15
  }: MainProps) => {
15
16
  const { target, setQuery } = useLiveRatesQuery();
16
17
 
17
- const instrumentsNames = records.map(({ instrument: instrumentName }) => instrumentName);
18
+ const instrumentsNames = records.map(
19
+ ({ instrument: instrumentName }) => instrumentName
20
+ );
18
21
 
19
22
  useEffect(() => {
20
23
  if (instrumentsNames[0]) {
@@ -24,22 +27,28 @@ const Main = ({
24
27
  }, [records]);
25
28
 
26
29
  return (
27
- <div data-testid="ticker-tape-wrapper" className="lw-flex">
28
- <MarqueeWrapper shouldPlay={records.length > 0} isStatic={motion === 'none'}>
30
+ <div className="lw-flex" data-testid="ticker-tape-wrapper">
31
+ <MarqueeWrapper
32
+ isStatic={motion === 'none'}
33
+ shouldPlay={records.length > 0}
34
+ >
29
35
  {records.map((record) => (
30
36
  <div
31
37
  key={record.instrument}
32
- className={classnames('lw-flex lw-border lw-border-r-0 lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary', {
33
- 'lw-h-[82px]': widgetSize !== 'compact',
34
- 'lw-h-[54px]': widgetSize === 'compact',
35
- 'lw-w-fit last:lw-border-r': motion === 'none',
36
- })}
38
+ className={classnames(
39
+ 'lw-flex lw-border lw-border-r-0 lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary',
40
+ {
41
+ 'lw-h-[82px]': widgetSize !== 'compact',
42
+ 'lw-h-[54px]': widgetSize === 'compact',
43
+ 'lw-w-fit last:lw-border-r': motion === 'none',
44
+ }
45
+ )}
37
46
  >
38
47
  <InstrumentRateWithData
39
- record={record}
40
- target={target}
41
48
  division={division}
49
+ record={record}
42
50
  size={widgetSize}
51
+ target={target}
43
52
  />
44
53
  </div>
45
54
  ))}
@@ -1,8 +1,10 @@
1
- import React from 'react';
2
1
  import { ApolloClient, InMemoryCache } from '@apollo/client';
3
2
  import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
3
+ import React from 'react';
4
+
4
5
  import { translations } from '../translations';
5
- import { Division, TickerTapeConfig } from './types';
6
+ import type { TickerTapeConfig } from './types';
7
+ import { Division } from './types';
6
8
  import { ValidationWrapper } from './ValidationWrapper';
7
9
 
8
10
  const TickerTapeWidget = ({
@@ -29,30 +31,30 @@ const TickerTapeWidget = ({
29
31
  return (
30
32
  <WidgetProvider
31
33
  withSuspense
32
- locale={locale}
33
- translations={translations}
34
34
  client={client}
35
- theme={theme}
36
- styling={{
37
- removePadding,
38
- fitContent: motion === 'none',
39
- }}
40
35
  liveRates={{
41
36
  url: liveRatesUrl,
42
37
  options: { divisionCode, dataSource },
43
38
  }}
39
+ locale={locale}
40
+ styling={{
41
+ removePadding,
42
+ fitContent: motion === 'none',
43
+ }}
44
+ theme={theme}
45
+ translations={translations}
44
46
  >
45
47
  <WidgetWrapper
46
- logoLink={logoLink}
47
- linkArea="full"
48
48
  isParamError={isParamError}
49
+ linkArea="full"
50
+ logoLink={logoLink}
49
51
  >
50
52
  <ValidationWrapper
51
- size={size}
52
- motion={motion}
53
- instruments={instruments}
54
53
  division={division}
54
+ instruments={instruments}
55
55
  isParamError={isParamError}
56
+ motion={motion}
57
+ size={size}
56
58
  />
57
59
  </WidgetWrapper>
58
60
  </WidgetProvider>
@@ -1,12 +1,16 @@
1
- import React from 'react';
2
1
  import { useSuspenseQuery } from '@apollo/client';
3
- import classnames from 'classnames';
4
2
  import { Error, useLayoutProvider } from '@oanda/labs-widget-common';
3
+ import classnames from 'classnames';
4
+ import React from 'react';
5
+
6
+ import type {
7
+ ValidateInstrumentsQuery,
8
+ ValidateInstrumentsQueryVariables,
9
+ } from '../gql/types/graphql';
5
10
  import { validateInstruments } from '../gql/validateInstruments';
6
- import { ValidateInstrumentsQuery, ValidateInstrumentsQueryVariables } from '../gql/types/graphql';
7
11
  import { Main } from './Main';
12
+ import type { ValidationWrapperProps } from './types';
8
13
  import { getRecords } from './utils';
9
- import { ValidationWrapperProps } from './types';
10
14
 
11
15
  const ValidationWrapper = ({
12
16
  instruments,
@@ -17,8 +21,8 @@ const ValidationWrapper = ({
17
21
  }: ValidationWrapperProps) => {
18
22
  const { size } = useLayoutProvider();
19
23
  const { data, error } = useSuspenseQuery<
20
- ValidateInstrumentsQuery,
21
- ValidateInstrumentsQueryVariables
24
+ ValidateInstrumentsQuery,
25
+ ValidateInstrumentsQueryVariables
22
26
  >(validateInstruments, {
23
27
  variables: {
24
28
  instruments,
@@ -34,20 +38,24 @@ const ValidationWrapper = ({
34
38
  <>
35
39
  {!showError && size && (
36
40
  <Main
37
- size={widgetSize}
38
41
  division={division}
39
- records={getRecords(data!)!}
40
42
  motion={motion}
43
+ records={getRecords(data!)!}
44
+ size={widgetSize}
41
45
  />
42
46
  )}
43
47
  {showError && (
44
- <div className={classnames('lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary', {
45
- 'lw-h-[82px]': widgetSize !== 'compact',
46
- 'lw-h-[54px]': widgetSize === 'compact',
47
- })}
48
- >
49
- <Error />
50
- </div>
48
+ <div
49
+ className={classnames(
50
+ 'lw-flex lw-border lw-border-solid lw-border-border-primary lw-px-4 lw-text-sm lw-tracking-normal lw-text-text-primary',
51
+ {
52
+ 'lw-h-[82px]': widgetSize !== 'compact',
53
+ 'lw-h-[54px]': widgetSize === 'compact',
54
+ }
55
+ )}
56
+ >
57
+ <Error />
58
+ </div>
51
59
  )}
52
60
  </>
53
61
  );
@@ -1,10 +1,14 @@
1
- import React from 'react';
2
1
  import { useBackgroundQuery } from '@apollo/client';
3
2
  import { InstrumentRateWithChart } from '@oanda/labs-widget-common';
4
- import { InstrumentRateWithDataProps } from './types';
5
- import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
3
+ import React from 'react';
4
+
6
5
  import { getInstrumentsChart } from '../../../gql/getInstrumentsChart';
7
- import { GetInstrumentsChartQuery, GetInstrumentsChartQueryVariables } from '../../../gql/types/graphql';
6
+ import type {
7
+ GetInstrumentsChartQuery,
8
+ GetInstrumentsChartQueryVariables,
9
+ } from '../../../gql/types/graphql';
10
+ import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
11
+ import type { InstrumentRateWithDataProps } from './types';
8
12
 
9
13
  const InstrumentRateWithData = ({
10
14
  record,
@@ -15,8 +19,8 @@ const InstrumentRateWithData = ({
15
19
  const hasInstrument = !!record.instrument;
16
20
 
17
21
  const [queryRef] = useBackgroundQuery<
18
- GetInstrumentsChartQuery,
19
- GetInstrumentsChartQueryVariables
22
+ GetInstrumentsChartQuery,
23
+ GetInstrumentsChartQueryVariables
20
24
  >(getInstrumentsChart, {
21
25
  variables: {
22
26
  instruments: [record.instrument],
@@ -28,11 +32,11 @@ const InstrumentRateWithData = ({
28
32
 
29
33
  return (
30
34
  <InstrumentRateWithChart<GetInstrumentsChartQuery>
35
+ queryRef={queryRef}
31
36
  record={record}
32
- target={target}
33
37
  size={size}
38
+ target={target}
34
39
  tooltipId={INSTRUMENT_TOOLTIP_ID}
35
- queryRef={queryRef}
36
40
  />
37
41
  );
38
42
  };
@@ -1,9 +1,10 @@
1
- import { DataRecord, WidgetSize } from '@oanda/labs-widget-common';
2
- import { Division } from '../../types';
1
+ import type { DataRecord, WidgetSize } from '@oanda/labs-widget-common';
2
+
3
+ import type { Division } from '../../types';
3
4
 
4
5
  export interface InstrumentRateWithDataProps {
5
6
  record: DataRecord;
6
7
  target: EventTarget | null;
7
8
  division: Division;
8
- size?: WidgetSize
9
+ size?: WidgetSize;
9
10
  }
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import Marquee from 'react-fast-marquee';
3
- import { MarqueeWrapperProps } from './types';
3
+
4
+ import type { MarqueeWrapperProps } from './types';
4
5
 
5
6
  const MarqueeWrapper = ({
6
7
  children,
@@ -9,15 +10,12 @@ const MarqueeWrapper = ({
9
10
  }: MarqueeWrapperProps) => (
10
11
  <>
11
12
  {!isStatic ? (
12
- <Marquee
13
- play={shouldPlay}
14
- autoFill
15
- pauseOnHover
16
- speed={60}
17
- >
13
+ <Marquee autoFill pauseOnHover play={shouldPlay} speed={60}>
18
14
  {children}
19
15
  </Marquee>
20
- ) : children}
16
+ ) : (
17
+ children
18
+ )}
21
19
  </>
22
20
  );
23
21
 
@@ -1,5 +1,3 @@
1
1
  const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';
2
2
 
3
- export {
4
- INSTRUMENT_TOOLTIP_ID,
5
- };
3
+ export { INSTRUMENT_TOOLTIP_ID };
@@ -1,2 +1,2 @@
1
- export * from './types';
2
1
  export * from './TickerTapeWidget';
2
+ export * from './types';
@@ -1,52 +1,67 @@
1
+ import type { Theme } from '@oanda/labs-widget-common';
2
+ import { validateLocale, validateToolParams } from '@oanda/labs-widget-common';
1
3
  import React from 'react';
2
4
  import { createRoot } from 'react-dom/client';
3
- import { Theme, validateLocale, validateToolParams } from '@oanda/labs-widget-common';
4
- import { TickerTapeWidget } from './TickerTapeWidget';
5
+
5
6
  import { Division } from '../gql/types/graphql';
7
+ import { TickerTapeWidget } from './TickerTapeWidget';
6
8
 
7
- const {
8
- graphqlUrl,
9
- liveRatesUrl,
10
- } = window.widgetsConfig || {};
9
+ const { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};
11
10
 
12
- const dataTickerTapeParamsElements = document.querySelectorAll('div[data-ticker-tape-params]');
11
+ const dataTickerTapeParamsElements = document.querySelectorAll(
12
+ 'div[data-ticker-tape-params]'
13
+ );
13
14
 
14
15
  dataTickerTapeParamsElements.forEach((element) => {
15
16
  const root = createRoot(element);
16
17
  const params = element.getAttribute('data-ticker-tape-params');
17
18
  const mode = element.getAttribute('data-mode');
18
- const {
19
- instruments, division, locale, size, motion,
20
- } = JSON.parse(params as string);
19
+ const { instruments, division, locale, size, motion } = JSON.parse(
20
+ params as string
21
+ );
21
22
 
22
- const isParamError = validateToolParams({
23
- division, locale, graphqlUrl, liveRatesUrl, instruments,
24
- }, [{
25
- name: 'locale',
26
- valueCheck: (value) => validateLocale(value),
27
- }, {
28
- name: 'division',
29
- valueCheck: (value) => Object.values(Division).includes(value),
30
- }, {
31
- name: 'instruments',
32
- valueCheck: (value) => value.length > 0 && value.length <= 10,
33
- }, {
34
- name: 'graphqlUrl',
35
- }, {
36
- name: 'liveRatesUrl',
37
- }]);
23
+ const isParamError = validateToolParams(
24
+ {
25
+ division,
26
+ locale,
27
+ graphqlUrl,
28
+ liveRatesUrl,
29
+ instruments,
30
+ },
31
+ [
32
+ {
33
+ name: 'locale',
34
+ valueCheck: (value: string | undefined) => validateLocale(value),
35
+ },
36
+ {
37
+ name: 'division',
38
+ valueCheck: (value: Division) =>
39
+ Object.values(Division).includes(value),
40
+ },
41
+ {
42
+ name: 'instruments',
43
+ valueCheck: (value) => value.length > 0 && value.length <= 10,
44
+ },
45
+ {
46
+ name: 'graphqlUrl',
47
+ },
48
+ {
49
+ name: 'liveRatesUrl',
50
+ },
51
+ ]
52
+ );
38
53
 
39
54
  root.render(
40
55
  <TickerTapeWidget
41
- graphqlUrl={graphqlUrl}
42
- liveRatesUrl={liveRatesUrl}
43
56
  division={division}
57
+ graphqlUrl={graphqlUrl}
44
58
  instruments={instruments}
45
- locale={locale}
46
- theme={mode as Theme}
47
59
  isParamError={isParamError}
48
- size={size}
60
+ liveRatesUrl={liveRatesUrl}
61
+ locale={locale}
49
62
  motion={motion}
50
- />,
63
+ size={size}
64
+ theme={mode as Theme}
65
+ />
51
66
  );
52
67
  });
@@ -1,8 +1,13 @@
1
- import { DataRecord, WidgetConfig, WidgetSize } from '@oanda/labs-widget-common';
2
- import { Division } from '../gql/types/graphql';
1
+ import type {
2
+ DataRecord,
3
+ WidgetConfig,
4
+ WidgetSize,
5
+ } from '@oanda/labs-widget-common';
6
+
7
+ import type { Division } from '../gql/types/graphql';
3
8
 
4
- export { Locale } from '@oanda/mono-i18n';
5
9
  export { Division } from '../gql/types/graphql';
10
+ export { Locale } from '@oanda/mono-i18n';
6
11
 
7
12
  export interface TickerTapeConfig extends WidgetConfig {
8
13
  division: Division;
@@ -1,16 +1,19 @@
1
- import { useState, useEffect } from 'react';
2
- import { DataRecord, LiveRatesErrorMessage, useLiveRatesMessage } from '@oanda/labs-widget-common';
3
- import { ValidateInstrumentsQuery } from '../gql/types/graphql';
1
+ import type {
2
+ DataRecord,
3
+ LiveRatesErrorMessage,
4
+ } from '@oanda/labs-widget-common';
5
+ import { useLiveRatesMessage } from '@oanda/labs-widget-common';
6
+ import { useEffect, useState } from 'react';
4
7
 
5
- const getRecords = (data: ValidateInstrumentsQuery) => data?.mapInstrumentNames?.map((item) => ({
6
- instrument: item?.name || '',
7
- displayName: item?.displayName || '',
8
- }));
8
+ import type { ValidateInstrumentsQuery } from '../gql/types/graphql';
9
9
 
10
- const useRecords = (
11
- record: DataRecord,
12
- target: EventTarget | null,
13
- ) => {
10
+ const getRecords = (data: ValidateInstrumentsQuery) =>
11
+ data?.mapInstrumentNames?.map((item) => ({
12
+ instrument: item?.name || '',
13
+ displayName: item?.displayName || '',
14
+ }));
15
+
16
+ const useRecords = (record: DataRecord, target: EventTarget | null) => {
14
17
  const [updatedRecord, setUpdatedRecord] = useState<DataRecord>({
15
18
  displayName: record.displayName,
16
19
  instrument: record.instrument,
@@ -20,7 +23,7 @@ const useRecords = (
20
23
 
21
24
  const { update, error: liveRatesError } = useLiveRatesMessage(
22
25
  record.instrument,
23
- target,
26
+ target
24
27
  );
25
28
 
26
29
  useEffect(() => {
@@ -42,7 +45,4 @@ const useRecords = (
42
45
  };
43
46
  };
44
47
 
45
- export {
46
- getRecords,
47
- useRecords,
48
- };
48
+ export { getRecords, useRecords };
@@ -1,18 +1,21 @@
1
- import { ResultOf, DocumentTypeDecoration, TypedDocumentNode } from '@graphql-typed-document-node/core';
1
+ import {
2
+ ResultOf,
3
+ DocumentTypeDecoration,
4
+ TypedDocumentNode,
5
+ } from '@graphql-typed-document-node/core';
2
6
  import { FragmentDefinitionNode } from 'graphql';
3
7
  import { Incremental } from './graphql';
4
8
 
5
-
6
- export type FragmentType<TDocumentType extends DocumentTypeDecoration<any, any>> = TDocumentType extends DocumentTypeDecoration<
7
- infer TType,
8
- any
9
- >
10
- ? [TType] extends [{ ' $fragmentName'?: infer TKey }]
11
- ? TKey extends string
12
- ? { ' $fragmentRefs'?: { [key in TKey]: TType } }
9
+ export type FragmentType<
10
+ TDocumentType extends DocumentTypeDecoration<any, any>,
11
+ > =
12
+ TDocumentType extends DocumentTypeDecoration<infer TType, any>
13
+ ? [TType] extends [{ ' $fragmentName'?: infer TKey }]
14
+ ? TKey extends string
15
+ ? { ' $fragmentRefs'?: { [key in TKey]: TType } }
16
+ : never
13
17
  : never
14
- : never
15
- : never;
18
+ : never;
16
19
 
17
20
  // return non-nullable if `fragmentType` is non-nullable
18
21
  export function useFragment<TType>(
@@ -22,7 +25,10 @@ export function useFragment<TType>(
22
25
  // return nullable if `fragmentType` is nullable
23
26
  export function useFragment<TType>(
24
27
  _documentNode: DocumentTypeDecoration<TType, any>,
25
- fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | null | undefined
28
+ fragmentType:
29
+ | FragmentType<DocumentTypeDecoration<TType, any>>
30
+ | null
31
+ | undefined
26
32
  ): TType | null | undefined;
27
33
  // return array of non-nullable if `fragmentType` is array of non-nullable
28
34
  export function useFragment<TType>(
@@ -32,35 +38,49 @@ export function useFragment<TType>(
32
38
  // return array of nullable if `fragmentType` is array of nullable
33
39
  export function useFragment<TType>(
34
40
  _documentNode: DocumentTypeDecoration<TType, any>,
35
- fragmentType: ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
41
+ fragmentType:
42
+ | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
43
+ | null
44
+ | undefined
36
45
  ): ReadonlyArray<TType> | null | undefined;
37
46
  export function useFragment<TType>(
38
47
  _documentNode: DocumentTypeDecoration<TType, any>,
39
- fragmentType: FragmentType<DocumentTypeDecoration<TType, any>> | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>> | null | undefined
48
+ fragmentType:
49
+ | FragmentType<DocumentTypeDecoration<TType, any>>
50
+ | ReadonlyArray<FragmentType<DocumentTypeDecoration<TType, any>>>
51
+ | null
52
+ | undefined
40
53
  ): TType | ReadonlyArray<TType> | null | undefined {
41
54
  return fragmentType as any;
42
55
  }
43
56
 
44
-
45
57
  export function makeFragmentData<
46
58
  F extends DocumentTypeDecoration<any, any>,
47
- FT extends ResultOf<F>
59
+ FT extends ResultOf<F>,
48
60
  >(data: FT, _fragment: F): FragmentType<F> {
49
61
  return data as FragmentType<F>;
50
62
  }
51
63
  export function isFragmentReady<TQuery, TFrag>(
52
64
  queryNode: DocumentTypeDecoration<TQuery, any>,
53
65
  fragmentNode: TypedDocumentNode<TFrag>,
54
- data: FragmentType<TypedDocumentNode<Incremental<TFrag>, any>> | null | undefined
66
+ data:
67
+ | FragmentType<TypedDocumentNode<Incremental<TFrag>, any>>
68
+ | null
69
+ | undefined
55
70
  ): data is FragmentType<typeof fragmentNode> {
56
- const deferredFields = (queryNode as { __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> } }).__meta__
57
- ?.deferredFields;
71
+ const deferredFields = (
72
+ queryNode as {
73
+ __meta__?: { deferredFields: Record<string, (keyof TFrag)[]> };
74
+ }
75
+ ).__meta__?.deferredFields;
58
76
 
59
77
  if (!deferredFields) return true;
60
78
 
61
- const fragDef = fragmentNode.definitions[0] as FragmentDefinitionNode | undefined;
79
+ const fragDef = fragmentNode.definitions[0] as
80
+ | FragmentDefinitionNode
81
+ | undefined;
62
82
  const fragName = fragDef?.name?.value;
63
83
 
64
84
  const fields = (fragName && deferredFields[fragName]) || [];
65
- return fields.length > 0 && fields.every(field => data && field in data);
85
+ return fields.length > 0 && fields.every((field) => data && field in data);
66
86
  }
@@ -13,8 +13,10 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
13
13
  * Therefore it is highly recommended to use the babel or swc plugin for production.
14
14
  */
15
15
  const documents = {
16
- "\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n": types.GetInstrumentsChartDocument,
17
- "\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n": types.ValidateInstrumentsDocument,
16
+ '\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n':
17
+ types.GetInstrumentsChartDocument,
18
+ '\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n':
19
+ types.ValidateInstrumentsDocument,
18
20
  };
19
21
 
20
22
  /**
@@ -34,14 +36,19 @@ export function graphql(source: string): unknown;
34
36
  /**
35
37
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
36
38
  */
37
- export 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"];
39
+ export function graphql(
40
+ source: '\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n'
41
+ ): (typeof documents)['\n query GetInstrumentsChart($instruments: [String!], $division: Division) {\n topicalInstrumentsCharts(instruments: $instruments, division: $division) {\n name\n chart\n }\n }\n'];
38
42
  /**
39
43
  * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
40
44
  */
41
- export 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"];
45
+ export function graphql(
46
+ source: '\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n'
47
+ ): (typeof documents)['\n query validateInstruments($instruments: [String]!, $division: Division) {\n mapInstrumentNames(instruments: $instruments, division: $division) {\n name\n displayName\n }\n }\n'];
42
48
 
43
49
  export function graphql(source: string) {
44
50
  return (documents as any)[source] ?? {};
45
51
  }
46
52
 
47
- export type DocumentType<TDocumentNode extends DocumentNode<any, any>> = TDocumentNode extends DocumentNode< infer TType, any> ? TType : never;
53
+ export type DocumentType<TDocumentNode extends DocumentNode<any, any>> =
54
+ TDocumentNode extends DocumentNode<infer TType, any> ? TType : never;