@oanda/labs-live-rates-table-widget 1.0.39 → 1.0.41

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 (133) hide show
  1. package/CHANGELOG.md +332 -0
  2. package/dist/main/LiveRatesTableWidget/LiveRatesTableWidget.js +14 -14
  3. package/dist/main/LiveRatesTableWidget/LiveRatesTableWidget.js.map +1 -1
  4. package/dist/main/LiveRatesTableWidget/Main.js +15 -15
  5. package/dist/main/LiveRatesTableWidget/Main.js.map +1 -1
  6. package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js +22 -20
  7. package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +1 -1
  8. package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js +7 -7
  9. package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js.map +1 -1
  10. package/dist/main/LiveRatesTableWidget/components/Cards/types.js.map +1 -1
  11. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +6 -5
  12. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
  13. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js.map +1 -1
  14. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js +1 -1
  15. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +1 -1
  16. package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js +29 -27
  17. package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +1 -1
  18. package/dist/main/LiveRatesTableWidget/components/index.js +12 -12
  19. package/dist/main/LiveRatesTableWidget/components/index.js.map +1 -1
  20. package/dist/main/LiveRatesTableWidget/config.js.map +1 -1
  21. package/dist/main/LiveRatesTableWidget/constant.js.map +1 -1
  22. package/dist/main/LiveRatesTableWidget/render.js +6 -6
  23. package/dist/main/LiveRatesTableWidget/render.js.map +1 -1
  24. package/dist/main/LiveRatesTableWidget/types.js +1 -1
  25. package/dist/main/LiveRatesTableWidget/types.js.map +1 -1
  26. package/dist/main/LiveRatesTableWidget/utils.js +17 -14
  27. package/dist/main/LiveRatesTableWidget/utils.js.map +1 -1
  28. package/dist/main/gql/getInstrumentsChart.js +3 -8
  29. package/dist/main/gql/getInstrumentsChart.js.map +1 -1
  30. package/dist/main/gql/types/fragment-masking.js +3 -2
  31. package/dist/main/gql/types/fragment-masking.js.map +1 -1
  32. package/dist/main/gql/types/gql.js +4 -3
  33. package/dist/main/gql/types/gql.js.map +1 -1
  34. package/dist/main/gql/types/graphql.js +142 -142
  35. package/dist/main/gql/types/graphql.js.map +1 -1
  36. package/dist/main/gql/types/index.js.map +1 -1
  37. package/dist/main/gql/validateInstruments.js +3 -8
  38. package/dist/main/gql/validateInstruments.js.map +1 -1
  39. package/dist/main/index.js +8 -8
  40. package/dist/main/index.js.map +1 -1
  41. package/dist/main/translations/index.js +1 -1
  42. package/dist/main/translations/index.js.map +1 -1
  43. package/dist/main/translations/translations.js.map +1 -1
  44. package/dist/module/LiveRatesTableWidget/LiveRatesTableWidget.js +14 -14
  45. package/dist/module/LiveRatesTableWidget/LiveRatesTableWidget.js.map +1 -1
  46. package/dist/module/LiveRatesTableWidget/Main.js +17 -17
  47. package/dist/module/LiveRatesTableWidget/Main.js.map +1 -1
  48. package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js +23 -21
  49. package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +1 -1
  50. package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js +7 -7
  51. package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js.map +1 -1
  52. package/dist/module/LiveRatesTableWidget/components/Cards/types.js.map +1 -1
  53. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +6 -5
  54. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
  55. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js.map +1 -1
  56. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js +2 -2
  57. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +1 -1
  58. package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js +29 -27
  59. package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +1 -1
  60. package/dist/module/LiveRatesTableWidget/components/index.js +2 -2
  61. package/dist/module/LiveRatesTableWidget/components/index.js.map +1 -1
  62. package/dist/module/LiveRatesTableWidget/config.js.map +1 -1
  63. package/dist/module/LiveRatesTableWidget/constant.js +1 -1
  64. package/dist/module/LiveRatesTableWidget/constant.js.map +1 -1
  65. package/dist/module/LiveRatesTableWidget/render.js +6 -6
  66. package/dist/module/LiveRatesTableWidget/render.js.map +1 -1
  67. package/dist/module/LiveRatesTableWidget/types.js +1 -1
  68. package/dist/module/LiveRatesTableWidget/types.js.map +1 -1
  69. package/dist/module/LiveRatesTableWidget/utils.js +18 -15
  70. package/dist/module/LiveRatesTableWidget/utils.js.map +1 -1
  71. package/dist/module/gql/getInstrumentsChart.js +3 -8
  72. package/dist/module/gql/getInstrumentsChart.js.map +1 -1
  73. package/dist/module/gql/types/fragment-masking.js +3 -2
  74. package/dist/module/gql/types/fragment-masking.js.map +1 -1
  75. package/dist/module/gql/types/gql.js +4 -3
  76. package/dist/module/gql/types/gql.js.map +1 -1
  77. package/dist/module/gql/types/graphql.js +142 -142
  78. package/dist/module/gql/types/graphql.js.map +1 -1
  79. package/dist/module/gql/types/index.js +2 -2
  80. package/dist/module/gql/types/index.js.map +1 -1
  81. package/dist/module/gql/validateInstruments.js +3 -8
  82. package/dist/module/gql/validateInstruments.js.map +1 -1
  83. package/dist/module/index.js +1 -1
  84. package/dist/module/index.js.map +1 -1
  85. package/dist/module/translations/index.js +1 -1
  86. package/dist/module/translations/index.js.map +1 -1
  87. package/dist/module/translations/translations.js.map +1 -1
  88. package/dist/types/LiveRatesTableWidget/LiveRatesTableWidget.d.ts +1 -1
  89. package/dist/types/LiveRatesTableWidget/Main.d.ts +1 -1
  90. package/dist/types/LiveRatesTableWidget/components/CardWithData/CardWithData.d.ts +1 -1
  91. package/dist/types/LiveRatesTableWidget/components/Cards/Cards.d.ts +1 -1
  92. package/dist/types/LiveRatesTableWidget/components/Cards/types.d.ts +2 -2
  93. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.d.ts +1 -1
  94. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/types.d.ts +3 -3
  95. package/dist/types/LiveRatesTableWidget/components/RowWithData/RowWithData.d.ts +1 -1
  96. package/dist/types/LiveRatesTableWidget/components/index.d.ts +2 -2
  97. package/dist/types/LiveRatesTableWidget/config.d.ts +1 -1
  98. package/dist/types/LiveRatesTableWidget/constant.d.ts +1 -1
  99. package/dist/types/LiveRatesTableWidget/types.d.ts +4 -4
  100. package/dist/types/LiveRatesTableWidget/utils.d.ts +5 -4
  101. package/dist/types/gql/types/gql.d.ts +4 -4
  102. package/dist/types/gql/types/index.d.ts +2 -2
  103. package/dist/types/index.d.ts +1 -1
  104. package/dist/types/translations/index.d.ts +2 -2
  105. package/package.json +3 -3
  106. package/src/LiveRatesTableWidget/LiveRatesTableWidget.tsx +14 -17
  107. package/src/LiveRatesTableWidget/Main.tsx +49 -43
  108. package/src/LiveRatesTableWidget/components/CardWithData/CardWithData.tsx +43 -28
  109. package/src/LiveRatesTableWidget/components/Cards/Cards.tsx +15 -8
  110. package/src/LiveRatesTableWidget/components/Cards/types.tsx +2 -2
  111. package/src/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.tsx +12 -10
  112. package/src/LiveRatesTableWidget/components/LineChartWithData/types.tsx +4 -3
  113. package/src/LiveRatesTableWidget/components/LineChartWithData/utils.ts +1 -1
  114. package/src/LiveRatesTableWidget/components/RowWithData/RowWithData.tsx +63 -30
  115. package/src/LiveRatesTableWidget/components/index.ts +2 -2
  116. package/src/LiveRatesTableWidget/config.ts +2 -4
  117. package/src/LiveRatesTableWidget/constant.ts +4 -1
  118. package/src/LiveRatesTableWidget/render.tsx +52 -34
  119. package/src/LiveRatesTableWidget/types.tsx +5 -4
  120. package/src/LiveRatesTableWidget/utils.ts +20 -17
  121. package/src/gql/types/fragment-masking.ts +41 -21
  122. package/src/gql/types/gql.ts +12 -5
  123. package/src/gql/types/graphql.ts +214 -49
  124. package/src/gql/types/index.ts +2 -2
  125. package/src/index.ts +1 -1
  126. package/src/translations/index.ts +4 -4
  127. package/src/translations/translations.ts +2 -1
  128. package/test/CardWithData.test.tsx +8 -7
  129. package/test/Cards.test.tsx +32 -29
  130. package/test/LineChartWithData.test.tsx +77 -32
  131. package/test/Main.test.tsx +10 -9
  132. package/test/RowWithData.test.tsx +9 -8
  133. package/test/mocks.ts +1 -3
@@ -1,12 +1,19 @@
1
- import React from 'react';
2
- import classnames from 'classnames';
3
1
  import {
4
- TableCell, TableRow, Price, LoaderSize, Truncate, useLayoutProvider,
2
+ LoaderSize,
3
+ Price,
4
+ TableCell,
5
+ TableRow,
6
+ Truncate,
7
+ useLayoutProvider,
5
8
  } from '@oanda/labs-widget-common';
6
- import { ColumnsNames, RowWithDataProps } from '../../types';
7
- import { LineChartWithData } from '../LineChartWithData';
8
- import { useRecords } from '../../utils';
9
+ import classnames from 'classnames';
10
+ import React from 'react';
11
+
9
12
  import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
13
+ import type { RowWithDataProps } from '../../types';
14
+ import { ColumnsNames } from '../../types';
15
+ import { useRecords } from '../../utils';
16
+ import { LineChartWithData } from '../LineChartWithData';
10
17
 
11
18
  const RowWithData = ({
12
19
  loading,
@@ -18,37 +25,54 @@ const RowWithData = ({
18
25
  isScrolled,
19
26
  }: RowWithDataProps) => {
20
27
  const { isDark } = useLayoutProvider();
21
- const { updatedRecord, error, ref } = useRecords(record, record.instrument ? target : null);
28
+ const { updatedRecord, error, ref } = useRecords(
29
+ record,
30
+ record.instrument ? target : null
31
+ );
22
32
 
23
- const checkLoading = (id: string) => loading || (!error && updatedRecord?.[id] === undefined);
33
+ const checkLoading = (id: string) =>
34
+ loading || (!error && updatedRecord?.[id] === undefined);
24
35
 
25
36
  return (
26
- <TableRow ref={ref} isScrolled={isScrolled} hasBackgroundColor={hasBackgroundColor}>
37
+ <TableRow
38
+ ref={ref}
39
+ hasBackgroundColor={hasBackgroundColor}
40
+ isScrolled={isScrolled}
41
+ >
27
42
  <>
28
43
  <TableCell
29
- type="text"
30
- classNames={classnames(
31
- 'lw-font-bold',
32
- {
33
- '[&>*:first-child]:lw-border-r [&>*:first-child]:lw-border-border-primary': isDark && isScrolled,
34
- },
35
- )}
36
44
  key={ColumnsNames.INSTRUMENT}
45
+ classNames={classnames('lw-font-bold', {
46
+ '[&>*:first-child]:lw-border-r [&>*:first-child]:lw-border-border-primary':
47
+ isDark && isScrolled,
48
+ })}
37
49
  isLoading={checkLoading(ColumnsNames.INSTRUMENT)}
50
+ type="text"
38
51
  >
39
- <Truncate maxWidth={130} text={record.displayName} tooltipId={INSTRUMENT_TOOLTIP_ID} />
52
+ <Truncate
53
+ maxWidth={130}
54
+ text={record.displayName}
55
+ tooltipId={INSTRUMENT_TOOLTIP_ID}
56
+ />
40
57
  </TableCell>
41
58
  {activeColumns.map((item) => {
42
59
  if (item === ColumnsNames.SELL) {
43
60
  return (
44
61
  <TableCell
45
62
  key={ColumnsNames.SELL}
46
- isLoading={checkLoading(ColumnsNames.SELL)}
47
- isError={!!error}
48
63
  additionalPaddingRight
64
+ isError={!!error}
65
+ isLoading={checkLoading(ColumnsNames.SELL)}
49
66
  >
50
- <Price priceMovement={updatedRecord.sellPriceMovement} movementIndicator="arrow">
51
- <span>{updatedRecord.sell?.toFixed(updatedRecord.displayPrecision)}</span>
67
+ <Price
68
+ movementIndicator="arrow"
69
+ priceMovement={updatedRecord.sellPriceMovement}
70
+ >
71
+ <span>
72
+ {updatedRecord.sell?.toFixed(
73
+ updatedRecord.displayPrecision
74
+ )}
75
+ </span>
52
76
  </Price>
53
77
  </TableCell>
54
78
  );
@@ -58,12 +82,17 @@ const RowWithData = ({
58
82
  return (
59
83
  <TableCell
60
84
  key={ColumnsNames.BUY}
61
- isLoading={checkLoading(ColumnsNames.BUY)}
62
- isError={!!error}
63
85
  additionalPaddingRight
86
+ isError={!!error}
87
+ isLoading={checkLoading(ColumnsNames.BUY)}
64
88
  >
65
- <Price priceMovement={updatedRecord.buyPriceMovement} movementIndicator="arrow">
66
- <span>{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}</span>
89
+ <Price
90
+ movementIndicator="arrow"
91
+ priceMovement={updatedRecord.buyPriceMovement}
92
+ >
93
+ <span>
94
+ {updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}
95
+ </span>
67
96
  </Price>
68
97
  </TableCell>
69
98
  );
@@ -73,8 +102,8 @@ const RowWithData = ({
73
102
  return (
74
103
  <TableCell
75
104
  key={ColumnsNames.DAILY_CHANGE}
76
- isLoading={checkLoading('dailyPercentChange')}
77
105
  isError={!!error}
106
+ isLoading={checkLoading('dailyPercentChange')}
78
107
  >
79
108
  <span>{updatedRecord.dailyPercentChange}</span>
80
109
  </TableCell>
@@ -83,12 +112,16 @@ const RowWithData = ({
83
112
 
84
113
  if (item === ColumnsNames.CHART) {
85
114
  return (
86
- <td data-testid="chart-table-cell" className="lw-relative lw-px-3 lw-py-0 lw-text-right" key={ColumnsNames.CHART}>
115
+ <td
116
+ key={ColumnsNames.CHART}
117
+ className="lw-relative lw-px-3 lw-py-0 lw-text-right"
118
+ data-testid="chart-table-cell"
119
+ >
87
120
  <div className="lw-flex lw-justify-center">
88
121
  <LineChartWithData
89
- record={updatedRecord}
90
- isLoading={checkLoading('instrument')}
91
122
  division={division}
123
+ isLoading={checkLoading('instrument')}
124
+ record={updatedRecord}
92
125
  />
93
126
  </div>
94
127
  </td>
@@ -99,8 +132,8 @@ const RowWithData = ({
99
132
  return (
100
133
  <TableCell
101
134
  key={ColumnsNames.SPREAD}
102
- isLoading={checkLoading(ColumnsNames.SPREAD)}
103
135
  isError={!!error}
136
+ isLoading={checkLoading(ColumnsNames.SPREAD)}
104
137
  loaderSize={LoaderSize.sm}
105
138
  >
106
139
  <span>{updatedRecord.spread}</span>
@@ -1,4 +1,4 @@
1
+ export * from './Cards';
1
2
  export * from './CardWithData';
2
- export * from './RowWithData';
3
3
  export * from './LineChartWithData';
4
- export * from './Cards';
4
+ export * from './RowWithData';
@@ -1,4 +1,5 @@
1
1
  import { Size } from '@oanda/labs-widget-common';
2
+
2
3
  import { ColumnsNames, View } from './types';
3
4
 
4
5
  const headerConfig = {
@@ -33,7 +34,4 @@ const sizeConfig = {
33
34
  [View.TABLE]: Size.DESKTOP,
34
35
  };
35
36
 
36
- export {
37
- headerConfig,
38
- sizeConfig,
39
- };
37
+ export { headerConfig, sizeConfig };
@@ -15,5 +15,8 @@ const DEFAULT_COLUMNS = [
15
15
  const INSTRUMENT_TOOLTIP_ID = 'instrument_tooltip_id';
16
16
 
17
17
  export {
18
- DEFAULT_COUNT, DEFAULT_COLUMNS, DEFAULT_TOTAL_COUNT, INSTRUMENT_TOOLTIP_ID,
18
+ DEFAULT_COLUMNS,
19
+ DEFAULT_COUNT,
20
+ DEFAULT_TOTAL_COUNT,
21
+ INSTRUMENT_TOOLTIP_ID,
19
22
  };
@@ -1,55 +1,73 @@
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 { LiveRatesTableWidget } from './LiveRatesTableWidget';
5
+
5
6
  import { Division } from '../gql/types/graphql';
7
+ import { LiveRatesTableWidget } from './LiveRatesTableWidget';
6
8
 
7
- const {
8
- graphqlUrl,
9
- liveRatesUrl,
10
- } = window.widgetsConfig || {};
9
+ const { graphqlUrl, liveRatesUrl } = window.widgetsConfig || {};
11
10
 
12
- const liveRatesTableParamsElements = document.querySelectorAll('div[data-live-rates-table-params]');
11
+ const liveRatesTableParamsElements = document.querySelectorAll(
12
+ 'div[data-live-rates-table-params]'
13
+ );
13
14
 
14
15
  liveRatesTableParamsElements.forEach((element) => {
15
16
  const root = createRoot(element);
16
17
  const params = element.getAttribute('data-live-rates-table-params');
17
18
  const mode = element.getAttribute('data-mode');
18
- const {
19
- instruments, columns, division, locale, view,
20
- } = JSON.parse(params as string);
19
+ const { instruments, columns, division, locale, view } = JSON.parse(
20
+ params as string
21
+ );
21
22
 
22
- const isParamError = validateToolParams({
23
- division, locale, graphqlUrl, liveRatesUrl, instruments, columns,
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 as string[]).length > 0 && (value as string[]).length <= 10,
33
- }, {
34
- name: 'columns',
35
- valueCheck: (value) => (value as string[]).length > 0,
36
- }, {
37
- name: 'graphqlUrl',
38
- }, {
39
- name: 'liveRatesUrl',
40
- }]);
23
+ const isParamError = validateToolParams(
24
+ {
25
+ division,
26
+ locale,
27
+ graphqlUrl,
28
+ liveRatesUrl,
29
+ instruments,
30
+ columns,
31
+ },
32
+ [
33
+ {
34
+ name: 'locale',
35
+ valueCheck: (value: string | undefined) => validateLocale(value),
36
+ },
37
+ {
38
+ name: 'division',
39
+ valueCheck: (value: Division) =>
40
+ Object.values(Division).includes(value),
41
+ },
42
+ {
43
+ name: 'instruments',
44
+ valueCheck: (value) =>
45
+ (value as string[]).length > 0 && (value as string[]).length <= 10,
46
+ },
47
+ {
48
+ name: 'columns',
49
+ valueCheck: (value) => (value as string[]).length > 0,
50
+ },
51
+ {
52
+ name: 'graphqlUrl',
53
+ },
54
+ {
55
+ name: 'liveRatesUrl',
56
+ },
57
+ ]
58
+ );
41
59
 
42
60
  root.render(
43
61
  <LiveRatesTableWidget
44
- graphqlUrl={graphqlUrl}
45
- liveRatesUrl={liveRatesUrl}
62
+ columns={columns}
46
63
  division={division}
64
+ graphqlUrl={graphqlUrl}
47
65
  instruments={instruments}
48
- columns={columns}
66
+ isParamError={isParamError}
67
+ liveRatesUrl={liveRatesUrl}
49
68
  locale={locale}
50
69
  theme={mode as Theme}
51
- isParamError={isParamError}
52
70
  view={view}
53
- />,
71
+ />
54
72
  );
55
73
  });
@@ -1,8 +1,9 @@
1
- import { WidgetConfig } from '@oanda/labs-widget-common';
2
- import { Division } from '../gql/types/graphql';
1
+ import type { WidgetConfig } from '@oanda/labs-widget-common';
2
+
3
+ import type { Division } from '../gql/types/graphql';
3
4
 
4
- export { Locale } from '@oanda/mono-i18n';
5
5
  export { Division } from '../gql/types/graphql';
6
+ export { Locale } from '@oanda/mono-i18n';
6
7
 
7
8
  export enum View {
8
9
  TABLE = 'table',
@@ -38,7 +39,7 @@ export interface Sentiment {
38
39
  longPercent: number;
39
40
  }
40
41
 
41
- export type EmptyRecord = Record<any, never>;
42
+ export type EmptyRecord = Record<string, never>;
42
43
 
43
44
  export interface DataRecord {
44
45
  [key: string]: string | number | undefined;
@@ -1,21 +1,28 @@
1
- import { useState, useEffect } from 'react';
2
- import { HeaderColumns, LiveRatesErrorMessage, useLiveRatesMessage } from '@oanda/labs-widget-common';
1
+ import type {
2
+ HeaderColumns,
3
+ LiveRatesErrorMessage,
4
+ } from '@oanda/labs-widget-common';
5
+ import { useLiveRatesMessage } from '@oanda/labs-widget-common';
6
+ import { useEffect, useState } from 'react';
3
7
  import { useIntersectionObserver } from 'usehooks-ts';
4
- import { ColumnsNames, DataRecord, EmptyRecord } from './types';
8
+
9
+ import type { ValidateInstrumentsQuery } from '../gql/types/graphql';
5
10
  import { headerConfig } from './config';
6
- import { ValidateInstrumentsQuery } from '../gql/types/graphql';
11
+ import type { DataRecord, EmptyRecord } from './types';
12
+ import { ColumnsNames } from './types';
7
13
 
8
- const getRecords = (data: ValidateInstrumentsQuery) => data?.mapInstrumentNames?.map((item) => ({
9
- instrument: item?.name || '',
10
- displayName: item?.displayName || '',
11
- }));
14
+ const getRecords = (data: ValidateInstrumentsQuery) =>
15
+ data?.mapInstrumentNames?.map((item) => ({
16
+ instrument: item?.name || '',
17
+ displayName: item?.displayName || '',
18
+ }));
12
19
 
13
- // eslint-disable-next-line max-len
14
- const getHeaderConfig = (activeColumns: ColumnsNames[]): HeaderColumns[] => [ColumnsNames.INSTRUMENT, ...activeColumns].map((item) => headerConfig[item]);
20
+ const getHeaderConfig = (activeColumns: ColumnsNames[]): HeaderColumns[] =>
21
+ [ColumnsNames.INSTRUMENT, ...activeColumns].map((item) => headerConfig[item]);
15
22
 
16
23
  const useRecords = (
17
24
  record: DataRecord | EmptyRecord,
18
- target: EventTarget | null,
25
+ target: EventTarget | null
19
26
  ) => {
20
27
  const [updatedRecord, setUpdatedRecord] = useState<DataRecord>({
21
28
  displayName: record.displayName,
@@ -28,7 +35,7 @@ const useRecords = (
28
35
 
29
36
  const { update, error: liveRatesError } = useLiveRatesMessage(
30
37
  record.instrument,
31
- target,
38
+ target
32
39
  );
33
40
 
34
41
  useEffect(() => {
@@ -56,8 +63,4 @@ const useRecords = (
56
63
  };
57
64
  };
58
65
 
59
- export {
60
- getRecords,
61
- getHeaderConfig,
62
- useRecords,
63
- };
66
+ export { getHeaderConfig, 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;