@oanda/labs-instrument-live-rate-widget 1.0.1 → 1.0.3

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 (69) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/main/InstrumentLiveRateWidget/Main.js +4 -4
  3. package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -1
  4. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +46 -0
  5. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -0
  6. package/dist/main/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/index.js +4 -4
  7. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js.map +1 -0
  8. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js +6 -0
  9. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js.map +1 -0
  10. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js.map +1 -0
  11. package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +7 -5
  12. package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
  13. package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -1
  14. package/dist/main/InstrumentLiveRateWidget/components/index.js +11 -0
  15. package/dist/main/InstrumentLiveRateWidget/components/index.js.map +1 -1
  16. package/dist/main/InstrumentLiveRateWidget/types.js.map +1 -1
  17. package/dist/main/InstrumentLiveRateWidget/utils.js.map +1 -1
  18. package/dist/module/InstrumentLiveRateWidget/Main.js +4 -4
  19. package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -1
  20. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +38 -0
  21. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -0
  22. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js +3 -0
  23. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js.map +1 -0
  24. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js +2 -0
  25. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js.map +1 -0
  26. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js.map +1 -0
  27. package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +8 -6
  28. package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
  29. package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -1
  30. package/dist/module/InstrumentLiveRateWidget/components/index.js +1 -0
  31. package/dist/module/InstrumentLiveRateWidget/components/index.js.map +1 -1
  32. package/dist/module/InstrumentLiveRateWidget/types.js.map +1 -1
  33. package/dist/module/InstrumentLiveRateWidget/utils.js.map +1 -1
  34. package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.d.ts +4 -0
  35. package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.d.ts +2 -0
  36. package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.d.ts +9 -0
  37. package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/types.d.ts +1 -2
  38. package/dist/types/InstrumentLiveRateWidget/components/index.d.ts +1 -0
  39. package/dist/types/InstrumentLiveRateWidget/types.d.ts +0 -22
  40. package/dist/types/InstrumentLiveRateWidget/utils.d.ts +2 -3
  41. package/package.json +3 -3
  42. package/src/InstrumentLiveRateWidget/Main.tsx +6 -5
  43. package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx +43 -0
  44. package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.ts +2 -0
  45. package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.ts +10 -0
  46. package/src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx +14 -15
  47. package/src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx +1 -2
  48. package/src/InstrumentLiveRateWidget/components/index.ts +1 -0
  49. package/src/InstrumentLiveRateWidget/types.tsx +0 -26
  50. package/src/InstrumentLiveRateWidget/utils.ts +2 -3
  51. package/test/components/{InstrumentRateWithData.test.tsx → InstrumentRateWithChart.test.tsx} +7 -7
  52. package/test/components/utils.test.ts +1 -1
  53. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +0 -83
  54. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +0 -1
  55. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +0 -1
  56. package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +0 -1
  57. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +0 -74
  58. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +0 -1
  59. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js +0 -3
  60. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +0 -1
  61. package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +0 -1
  62. package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.d.ts +0 -4
  63. package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.d.ts +0 -2
  64. package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.tsx +0 -92
  65. package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.ts +0 -2
  66. /package/dist/main/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.js +0 -0
  67. /package/dist/module/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.js +0 -0
  68. /package/dist/types/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.d.ts +0 -0
  69. /package/src/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.ts +0 -0
@@ -1,92 +0,0 @@
1
- import React, { useContext } from 'react';
2
- import {
3
- LabelWrapper, Price, ThemeContext, Truncate,
4
- } from '@oanda/labs-widget-common';
5
- import classNames from 'classnames';
6
- import { InstrumentRateWithDataProps } from '../../types';
7
- import { LineChartWithData } from '../LineChartWithData';
8
- import { useRecords } from '../../utils';
9
- import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
10
- import { getChartColor, getColorIndicator } from './utils';
11
-
12
- const InstrumentRateWithData = ({
13
- loading,
14
- record,
15
- target,
16
- division,
17
- size = 'fullWithChart',
18
- }: InstrumentRateWithDataProps) => {
19
- const { isDark } = useContext(ThemeContext);
20
- const { updatedRecord, error } = useRecords(record, record.instrument ? target : null);
21
-
22
- const checkLoading = (id: string) => loading || (!error && updatedRecord?.[id] === undefined);
23
-
24
- const indicator = getColorIndicator(updatedRecord.dailyPercentChange);
25
-
26
- return (
27
- <div className="lw-flex lw-flex-col lw-px-4 lw-pb-1 lw-pt-2">
28
- <div className="lw-flex lw-items-center lw-gap-x-2">
29
- <LabelWrapper
30
- isLoading={checkLoading('instrument')}
31
- isError={!!error}
32
- >
33
- <span className="lw-text-xl lw-font-bold">
34
- <Truncate maxWidth={130} text={record.displayName} tooltipId={INSTRUMENT_TOOLTIP_ID} />
35
- </span>
36
- </LabelWrapper>
37
- <LabelWrapper
38
- isLoading={checkLoading('buy')}
39
- isError={!!error}
40
- >
41
- <div className="lw-text-xl lw-font-bold">
42
- <Price priceMovement={updatedRecord.buyPriceMovement} withoutArrow>
43
- <span>{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}</span>
44
- </Price>
45
- </div>
46
- </LabelWrapper>
47
- </div>
48
- {size !== 'compact'
49
- && (
50
- <div className="lw-mt-1 lw-flex lw-items-center lw-gap-x-2">
51
- <LabelWrapper
52
- isLoading={checkLoading('dailyPercentChange')}
53
- isError={!!error}
54
- >
55
- <span className={classNames('lw-font-bold', {
56
- 'lw-text-text-ok': indicator > 0,
57
- 'lw-text-text-danger': indicator < 0,
58
- 'lw-text-text-disabled': indicator === 0,
59
- })}
60
- >
61
- {updatedRecord.dailyPercentChange}
62
- </span>
63
-
64
- </LabelWrapper>
65
- <LabelWrapper
66
- isLoading={checkLoading('dailyPipsChange')}
67
- isError={!!error}
68
- >
69
- <span className={classNames('lw-font-bold', {
70
- 'lw-text-text-ok': indicator > 0,
71
- 'lw-text-text-danger': indicator < 0,
72
- 'lw-text-text-disabled': indicator === 0,
73
- })}
74
- >
75
- {`(${updatedRecord.dailyPipsChange})`}
76
- </span>
77
- </LabelWrapper>
78
- {size === 'fullWithChart' && (
79
- <LineChartWithData
80
- record={updatedRecord}
81
- isLoading={checkLoading('instrument')}
82
- division={division}
83
- color={getChartColor(indicator, isDark)}
84
- />
85
- )}
86
- </div>
87
- )}
88
- </div>
89
- );
90
- };
91
-
92
- export { InstrumentRateWithData };
@@ -1,2 +0,0 @@
1
- export * from './InstrumentRateWithData';
2
- export * from './utils';