@coinbase/cds-mobile-visualization 3.8.1 → 4.0.0
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.
- package/CHANGELOG.md +8 -0
- package/dts/chart/index.d.ts +1 -15
- package/dts/chart/index.d.ts.map +1 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/sparkline/index.d.ts +1 -5
- package/dts/sparkline/index.d.ts.map +1 -1
- package/esm/chart/index.js +1 -17
- package/esm/index.js +1 -3
- package/esm/sparkline/index.js +1 -5
- package/package.json +26 -20
- package/dts/chart/CartesianChart.d.ts +0 -206
- package/dts/chart/CartesianChart.d.ts.map +0 -1
- package/dts/chart/ChartContextBridge.d.ts +0 -28
- package/dts/chart/ChartContextBridge.d.ts.map +0 -1
- package/dts/chart/ChartProvider.d.ts +0 -9
- package/dts/chart/ChartProvider.d.ts.map +0 -1
- package/dts/chart/Path.d.ts +0 -121
- package/dts/chart/Path.d.ts.map +0 -1
- package/dts/chart/PeriodSelector.d.ts +0 -100
- package/dts/chart/PeriodSelector.d.ts.map +0 -1
- package/dts/chart/area/Area.d.ts +0 -83
- package/dts/chart/area/Area.d.ts.map +0 -1
- package/dts/chart/area/AreaChart.d.ts +0 -155
- package/dts/chart/area/AreaChart.d.ts.map +0 -1
- package/dts/chart/area/DottedArea.d.ts +0 -46
- package/dts/chart/area/DottedArea.d.ts.map +0 -1
- package/dts/chart/area/GradientArea.d.ts +0 -36
- package/dts/chart/area/GradientArea.d.ts.map +0 -1
- package/dts/chart/area/SolidArea.d.ts +0 -23
- package/dts/chart/area/SolidArea.d.ts.map +0 -1
- package/dts/chart/area/index.d.ts +0 -6
- package/dts/chart/area/index.d.ts.map +0 -1
- package/dts/chart/axis/Axis.d.ts +0 -174
- package/dts/chart/axis/Axis.d.ts.map +0 -1
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts +0 -8
- package/dts/chart/axis/DefaultAxisTickLabel.d.ts.map +0 -1
- package/dts/chart/axis/XAxis.d.ts +0 -22
- package/dts/chart/axis/XAxis.d.ts.map +0 -1
- package/dts/chart/axis/YAxis.d.ts +0 -22
- package/dts/chart/axis/YAxis.d.ts.map +0 -1
- package/dts/chart/axis/index.d.ts +0 -5
- package/dts/chart/axis/index.d.ts.map +0 -1
- package/dts/chart/bar/Bar.d.ts +0 -100
- package/dts/chart/bar/Bar.d.ts.map +0 -1
- package/dts/chart/bar/BarChart.d.ts +0 -158
- package/dts/chart/bar/BarChart.d.ts.map +0 -1
- package/dts/chart/bar/BarPlot.d.ts +0 -31
- package/dts/chart/bar/BarPlot.d.ts.map +0 -1
- package/dts/chart/bar/BarStack.d.ts +0 -127
- package/dts/chart/bar/BarStack.d.ts.map +0 -1
- package/dts/chart/bar/BarStackGroup.d.ts +0 -37
- package/dts/chart/bar/BarStackGroup.d.ts.map +0 -1
- package/dts/chart/bar/DefaultBar.d.ts +0 -7
- package/dts/chart/bar/DefaultBar.d.ts.map +0 -1
- package/dts/chart/bar/DefaultBarStack.d.ts +0 -7
- package/dts/chart/bar/DefaultBarStack.d.ts.map +0 -1
- package/dts/chart/bar/PercentageBarChart.d.ts +0 -106
- package/dts/chart/bar/PercentageBarChart.d.ts.map +0 -1
- package/dts/chart/bar/index.d.ts +0 -9
- package/dts/chart/bar/index.d.ts.map +0 -1
- package/dts/chart/gradient/Gradient.d.ts +0 -41
- package/dts/chart/gradient/Gradient.d.ts.map +0 -1
- package/dts/chart/gradient/index.d.ts +0 -2
- package/dts/chart/gradient/index.d.ts.map +0 -1
- package/dts/chart/legend/DefaultLegendEntry.d.ts +0 -5
- package/dts/chart/legend/DefaultLegendEntry.d.ts.map +0 -1
- package/dts/chart/legend/DefaultLegendShape.d.ts +0 -5
- package/dts/chart/legend/DefaultLegendShape.d.ts.map +0 -1
- package/dts/chart/legend/Legend.d.ts +0 -168
- package/dts/chart/legend/Legend.d.ts.map +0 -1
- package/dts/chart/legend/index.d.ts +0 -4
- package/dts/chart/legend/index.d.ts.map +0 -1
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts +0 -9
- package/dts/chart/line/DefaultReferenceLineLabel.d.ts.map +0 -1
- package/dts/chart/line/DottedLine.d.ts +0 -20
- package/dts/chart/line/DottedLine.d.ts.map +0 -1
- package/dts/chart/line/Line.d.ts +0 -122
- package/dts/chart/line/Line.d.ts.map +0 -1
- package/dts/chart/line/LineChart.d.ts +0 -135
- package/dts/chart/line/LineChart.d.ts.map +0 -1
- package/dts/chart/line/ReferenceLine.d.ts +0 -140
- package/dts/chart/line/ReferenceLine.d.ts.map +0 -1
- package/dts/chart/line/SolidLine.d.ts +0 -15
- package/dts/chart/line/SolidLine.d.ts.map +0 -1
- package/dts/chart/line/index.d.ts +0 -7
- package/dts/chart/line/index.d.ts.map +0 -1
- package/dts/chart/point/DefaultPointLabel.d.ts +0 -10
- package/dts/chart/point/DefaultPointLabel.d.ts.map +0 -1
- package/dts/chart/point/Point.d.ts +0 -144
- package/dts/chart/point/Point.d.ts.map +0 -1
- package/dts/chart/point/index.d.ts +0 -3
- package/dts/chart/point/index.d.ts.map +0 -1
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts +0 -38
- package/dts/chart/scrubber/DefaultScrubberBeacon.d.ts.map +0 -1
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts +0 -12
- package/dts/chart/scrubber/DefaultScrubberBeaconLabel.d.ts.map +0 -1
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts +0 -12
- package/dts/chart/scrubber/DefaultScrubberLabel.d.ts.map +0 -1
- package/dts/chart/scrubber/Scrubber.d.ts +0 -302
- package/dts/chart/scrubber/Scrubber.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts +0 -12
- package/dts/chart/scrubber/ScrubberAccessibilityView.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts +0 -54
- package/dts/chart/scrubber/ScrubberBeaconGroup.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts +0 -46
- package/dts/chart/scrubber/ScrubberBeaconLabelGroup.d.ts.map +0 -1
- package/dts/chart/scrubber/ScrubberProvider.d.ts +0 -20
- package/dts/chart/scrubber/ScrubberProvider.d.ts.map +0 -1
- package/dts/chart/scrubber/index.d.ts +0 -5
- package/dts/chart/scrubber/index.d.ts.map +0 -1
- package/dts/chart/text/ChartText.d.ts +0 -164
- package/dts/chart/text/ChartText.d.ts.map +0 -1
- package/dts/chart/text/ChartTextGroup.d.ts +0 -61
- package/dts/chart/text/ChartTextGroup.d.ts.map +0 -1
- package/dts/chart/text/index.d.ts +0 -3
- package/dts/chart/text/index.d.ts.map +0 -1
- package/dts/chart/utils/axis.d.ts +0 -387
- package/dts/chart/utils/axis.d.ts.map +0 -1
- package/dts/chart/utils/bar.d.ts +0 -225
- package/dts/chart/utils/bar.d.ts.map +0 -1
- package/dts/chart/utils/chart.d.ts +0 -165
- package/dts/chart/utils/chart.d.ts.map +0 -1
- package/dts/chart/utils/context.d.ts +0 -131
- package/dts/chart/utils/context.d.ts.map +0 -1
- package/dts/chart/utils/gradient.d.ts +0 -129
- package/dts/chart/utils/gradient.d.ts.map +0 -1
- package/dts/chart/utils/index.d.ts +0 -11
- package/dts/chart/utils/index.d.ts.map +0 -1
- package/dts/chart/utils/path.d.ts +0 -186
- package/dts/chart/utils/path.d.ts.map +0 -1
- package/dts/chart/utils/point.d.ts +0 -146
- package/dts/chart/utils/point.d.ts.map +0 -1
- package/dts/chart/utils/scale.d.ts +0 -145
- package/dts/chart/utils/scale.d.ts.map +0 -1
- package/dts/chart/utils/scrubber.d.ts +0 -40
- package/dts/chart/utils/scrubber.d.ts.map +0 -1
- package/dts/chart/utils/transition.d.ts +0 -181
- package/dts/chart/utils/transition.d.ts.map +0 -1
- package/dts/sparkline/Counter.d.ts +0 -8
- package/dts/sparkline/Counter.d.ts.map +0 -1
- package/dts/sparkline/Sparkline.d.ts +0 -74
- package/dts/sparkline/Sparkline.d.ts.map +0 -1
- package/dts/sparkline/SparklineArea.d.ts +0 -15
- package/dts/sparkline/SparklineArea.d.ts.map +0 -1
- package/dts/sparkline/SparklineAreaPattern.d.ts +0 -14
- package/dts/sparkline/SparklineAreaPattern.d.ts.map +0 -1
- package/dts/sparkline/SparklineGradient.d.ts +0 -24
- package/dts/sparkline/SparklineGradient.d.ts.map +0 -1
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts +0 -2
- package/dts/sparkline/__figma__/Sparkline.figma.d.ts.map +0 -1
- package/dts/sparkline/generateSparklineWithId.d.ts +0 -11
- package/dts/sparkline/generateSparklineWithId.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts +0 -23
- package/dts/sparkline/sparkline-interactive/SparklineAccessibleView.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts +0 -185
- package/dts/sparkline/sparkline-interactive/SparklineInteractive.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts +0 -25
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts +0 -28
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts +0 -13
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts +0 -17
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts +0 -11
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveMinMax.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts +0 -26
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts +0 -25
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePaths.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts +0 -25
- package/dts/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts +0 -39
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveProvider.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts +0 -31
- package/dts/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts +0 -13
- package/dts/sparkline/sparkline-interactive/useInterruptiblePathAnimation.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts +0 -16
- package/dts/sparkline/sparkline-interactive/useMinMaxTransform.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts +0 -6
- package/dts/sparkline/sparkline-interactive/useOpacityAnimation.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts +0 -22
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveConstants.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts +0 -34
- package/dts/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts +0 -118
- package/dts/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts +0 -2
- package/dts/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.d.ts.map +0 -1
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts +0 -29
- package/dts/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.d.ts.map +0 -1
- package/esm/chart/CartesianChart.js +0 -431
- package/esm/chart/ChartContextBridge.js +0 -159
- package/esm/chart/ChartProvider.js +0 -10
- package/esm/chart/Path.js +0 -255
- package/esm/chart/PeriodSelector.js +0 -139
- package/esm/chart/__stories__/CartesianChart.stories.js +0 -659
- package/esm/chart/__stories__/ChartAccessibility.stories.js +0 -721
- package/esm/chart/__stories__/ChartTransitions.stories.js +0 -693
- package/esm/chart/__stories__/PeriodSelector.stories.js +0 -420
- package/esm/chart/area/Area.js +0 -85
- package/esm/chart/area/AreaChart.js +0 -152
- package/esm/chart/area/DottedArea.js +0 -92
- package/esm/chart/area/GradientArea.js +0 -63
- package/esm/chart/area/SolidArea.js +0 -45
- package/esm/chart/area/__stories__/AreaChart.stories.js +0 -370
- package/esm/chart/area/index.js +0 -7
- package/esm/chart/axis/Axis.js +0 -9
- package/esm/chart/axis/DefaultAxisTickLabel.js +0 -11
- package/esm/chart/axis/XAxis.js +0 -256
- package/esm/chart/axis/YAxis.js +0 -255
- package/esm/chart/axis/__stories__/Axis.stories.js +0 -552
- package/esm/chart/axis/index.js +0 -6
- package/esm/chart/bar/Bar.js +0 -71
- package/esm/chart/bar/BarChart.js +0 -122
- package/esm/chart/bar/BarPlot.js +0 -106
- package/esm/chart/bar/BarStack.js +0 -173
- package/esm/chart/bar/BarStackGroup.js +0 -89
- package/esm/chart/bar/DefaultBar.js +0 -79
- package/esm/chart/bar/DefaultBarStack.js +0 -68
- package/esm/chart/bar/PercentageBarChart.js +0 -99
- package/esm/chart/bar/__stories__/BarChart.stories.js +0 -1417
- package/esm/chart/bar/__stories__/PercentageBarChart.stories.js +0 -833
- package/esm/chart/bar/index.js +0 -10
- package/esm/chart/gradient/Gradient.js +0 -156
- package/esm/chart/gradient/index.js +0 -1
- package/esm/chart/legend/DefaultLegendEntry.js +0 -42
- package/esm/chart/legend/DefaultLegendShape.js +0 -64
- package/esm/chart/legend/Legend.js +0 -59
- package/esm/chart/legend/__stories__/Legend.stories.js +0 -574
- package/esm/chart/legend/index.js +0 -3
- package/esm/chart/line/DefaultReferenceLineLabel.js +0 -66
- package/esm/chart/line/DottedLine.js +0 -57
- package/esm/chart/line/Line.js +0 -180
- package/esm/chart/line/LineChart.js +0 -149
- package/esm/chart/line/ReferenceLine.js +0 -132
- package/esm/chart/line/SolidLine.js +0 -53
- package/esm/chart/line/__stories__/LineChart.stories.js +0 -2018
- package/esm/chart/line/__stories__/ReferenceLine.stories.js +0 -226
- package/esm/chart/line/index.js +0 -8
- package/esm/chart/point/DefaultPointLabel.js +0 -39
- package/esm/chart/point/Point.js +0 -187
- package/esm/chart/point/index.js +0 -2
- package/esm/chart/scrubber/DefaultScrubberBeacon.js +0 -182
- package/esm/chart/scrubber/DefaultScrubberBeaconLabel.js +0 -43
- package/esm/chart/scrubber/DefaultScrubberLabel.js +0 -44
- package/esm/chart/scrubber/Scrubber.js +0 -198
- package/esm/chart/scrubber/ScrubberAccessibilityView.js +0 -177
- package/esm/chart/scrubber/ScrubberBeaconGroup.js +0 -169
- package/esm/chart/scrubber/ScrubberBeaconLabelGroup.js +0 -212
- package/esm/chart/scrubber/ScrubberProvider.js +0 -140
- package/esm/chart/scrubber/__stories__/Scrubber.stories.js +0 -946
- package/esm/chart/scrubber/index.js +0 -4
- package/esm/chart/text/ChartText.js +0 -305
- package/esm/chart/text/ChartTextGroup.js +0 -211
- package/esm/chart/text/index.js +0 -4
- package/esm/chart/utils/axis.js +0 -664
- package/esm/chart/utils/bar.js +0 -906
- package/esm/chart/utils/chart.js +0 -329
- package/esm/chart/utils/context.js +0 -22
- package/esm/chart/utils/gradient.js +0 -319
- package/esm/chart/utils/index.js +0 -12
- package/esm/chart/utils/path.js +0 -304
- package/esm/chart/utils/point.js +0 -282
- package/esm/chart/utils/scale.js +0 -288
- package/esm/chart/utils/scrubber.js +0 -146
- package/esm/chart/utils/transition.js +0 -241
- package/esm/sparkline/Counter.js +0 -45
- package/esm/sparkline/Sparkline.js +0 -165
- package/esm/sparkline/SparklineArea.js +0 -20
- package/esm/sparkline/SparklineAreaPattern.js +0 -38
- package/esm/sparkline/SparklineGradient.js +0 -77
- package/esm/sparkline/__figma__/Sparkline.figma.js +0 -22
- package/esm/sparkline/__stories__/Sparkline.stories.js +0 -124
- package/esm/sparkline/__stories__/SparklineGradient.stories.js +0 -126
- package/esm/sparkline/generateSparklineWithId.js +0 -7
- package/esm/sparkline/sparkline-interactive/SparklineAccessibleView.js +0 -75
- package/esm/sparkline/sparkline-interactive/SparklineInteractive.js +0 -308
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveAnimatedPath.js +0 -116
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveHoverDate.js +0 -131
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveLineVertical.js +0 -99
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMarkerDates.js +0 -82
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveMinMax.js +0 -103
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePanGestureHandler.js +0 -104
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePaths.js +0 -57
- package/esm/sparkline/sparkline-interactive/SparklineInteractivePeriodSelector.js +0 -124
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveProvider.js +0 -80
- package/esm/sparkline/sparkline-interactive/SparklineInteractiveTimeseriesPaths.js +0 -109
- package/esm/sparkline/sparkline-interactive/__figma__/SparklineInteractive.figma.js +0 -85
- package/esm/sparkline/sparkline-interactive/__stories__/SparklineInteractive.stories.js +0 -526
- package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.js +0 -58
- package/esm/sparkline/sparkline-interactive/useInterruptiblePathAnimation.test.disable.js +0 -37
- package/esm/sparkline/sparkline-interactive/useMinMaxTransform.js +0 -56
- package/esm/sparkline/sparkline-interactive/useOpacityAnimation.js +0 -23
- package/esm/sparkline/sparkline-interactive/useSparklineInteractiveConstants.js +0 -47
- package/esm/sparkline/sparkline-interactive/useSparklineInteractiveLineStyles.js +0 -34
- package/esm/sparkline/sparkline-interactive-header/SparklineInteractiveHeader.js +0 -233
- package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js +0 -104
- package/esm/sparkline/sparkline-interactive-header/__stories__/SparklineInteractiveHeader.stories.js +0 -565
- package/esm/sparkline/sparkline-interactive-header/useSparklineInteractiveHeaderStyles.js +0 -117
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { memo, useMemo } from 'react';
|
|
3
|
-
import { Animated as RNAnimated, StyleSheet } from 'react-native';
|
|
4
|
-
import Animated, { useAnimatedStyle } from 'react-native-reanimated';
|
|
5
|
-
import { Line, Svg } from 'react-native-svg';
|
|
6
|
-
import { maskOpacity } from '@coinbase/cds-common/tokens/sparkline';
|
|
7
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
8
|
-
import { useSparklineInteractiveContext } from './SparklineInteractiveProvider';
|
|
9
|
-
import { useSparklineInteractiveConstants } from './useSparklineInteractiveConstants';
|
|
10
|
-
import { useSparklineInteractiveLineStyles } from './useSparklineInteractiveLineStyles';
|
|
11
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
const styles = StyleSheet.create({
|
|
13
|
-
wrapper: _extends({}, StyleSheet.absoluteFillObject, {
|
|
14
|
-
zIndex: 2
|
|
15
|
-
})
|
|
16
|
-
});
|
|
17
|
-
const SparklineInteractiveDottedLine = /*#__PURE__*/memo(_ref => {
|
|
18
|
-
let {
|
|
19
|
-
color,
|
|
20
|
-
showHoverDate
|
|
21
|
-
} = _ref;
|
|
22
|
-
const theme = useTheme();
|
|
23
|
-
const {
|
|
24
|
-
markerXPosition,
|
|
25
|
-
compact
|
|
26
|
-
} = useSparklineInteractiveContext();
|
|
27
|
-
const {
|
|
28
|
-
lineProps
|
|
29
|
-
} = useSparklineInteractiveLineStyles();
|
|
30
|
-
const {
|
|
31
|
-
chartHeight,
|
|
32
|
-
SparklineInteractiveMinMaxLabelHeight,
|
|
33
|
-
chartVerticalLineWidth,
|
|
34
|
-
chartWidth
|
|
35
|
-
} = useSparklineInteractiveConstants({
|
|
36
|
-
compact
|
|
37
|
-
});
|
|
38
|
-
const dottedLineHeight = chartHeight + SparklineInteractiveMinMaxLabelHeight * (showHoverDate ? 1 : 2);
|
|
39
|
-
const lineStyles = useMemo(() => {
|
|
40
|
-
return {
|
|
41
|
-
width: chartVerticalLineWidth,
|
|
42
|
-
height: dottedLineHeight,
|
|
43
|
-
top: showHoverDate ? 0 : -SparklineInteractiveMinMaxLabelHeight,
|
|
44
|
-
zIndex: 2
|
|
45
|
-
};
|
|
46
|
-
}, [SparklineInteractiveMinMaxLabelHeight, chartVerticalLineWidth, dottedLineHeight, showHoverDate]);
|
|
47
|
-
const animatedTranslateX = useAnimatedStyle(() => ({
|
|
48
|
-
transform: [{
|
|
49
|
-
translateX: markerXPosition.value
|
|
50
|
-
}]
|
|
51
|
-
}));
|
|
52
|
-
const dottedLinePositionStyles = useMemo(() => [lineStyles, animatedTranslateX], [lineStyles, animatedTranslateX]);
|
|
53
|
-
const maskStyles = useMemo(() => {
|
|
54
|
-
return _extends({}, StyleSheet.absoluteFillObject, {
|
|
55
|
-
height: dottedLineHeight,
|
|
56
|
-
width: chartWidth,
|
|
57
|
-
top: showHoverDate ? 0 : -SparklineInteractiveMinMaxLabelHeight,
|
|
58
|
-
backgroundColor: theme.color.bg,
|
|
59
|
-
opacity: maskOpacity,
|
|
60
|
-
zIndex: 1
|
|
61
|
-
});
|
|
62
|
-
}, [SparklineInteractiveMinMaxLabelHeight, chartWidth, dottedLineHeight, showHoverDate, theme.color.bg]);
|
|
63
|
-
const maskPositionStyles = useMemo(() => [maskStyles, animatedTranslateX], [maskStyles, animatedTranslateX]);
|
|
64
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
65
|
-
children: [/*#__PURE__*/_jsx(Animated.View, {
|
|
66
|
-
style: dottedLinePositionStyles,
|
|
67
|
-
children: /*#__PURE__*/_jsx(Svg, {
|
|
68
|
-
children: /*#__PURE__*/_jsx(Line, _extends({}, lineProps, {
|
|
69
|
-
stroke: color,
|
|
70
|
-
y2: dottedLineHeight
|
|
71
|
-
}))
|
|
72
|
-
})
|
|
73
|
-
}), /*#__PURE__*/_jsx(Animated.View, {
|
|
74
|
-
style: maskPositionStyles
|
|
75
|
-
})]
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
export const SparklineInteractiveLineVertical = /*#__PURE__*/memo(_ref2 => {
|
|
79
|
-
let {
|
|
80
|
-
color,
|
|
81
|
-
showHoverDate
|
|
82
|
-
} = _ref2;
|
|
83
|
-
const {
|
|
84
|
-
markerOpacity
|
|
85
|
-
} = useSparklineInteractiveContext();
|
|
86
|
-
const rootStyle = useMemo(() => {
|
|
87
|
-
return _extends({}, styles.wrapper, {
|
|
88
|
-
opacity: markerOpacity
|
|
89
|
-
});
|
|
90
|
-
}, [markerOpacity]);
|
|
91
|
-
return /*#__PURE__*/_jsx(RNAnimated.View, {
|
|
92
|
-
pointerEvents: "none",
|
|
93
|
-
style: rootStyle,
|
|
94
|
-
children: /*#__PURE__*/_jsx(SparklineInteractiveDottedLine, {
|
|
95
|
-
color: color,
|
|
96
|
-
showHoverDate: showHoverDate
|
|
97
|
-
})
|
|
98
|
-
});
|
|
99
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { memo, useMemo } from 'react';
|
|
3
|
-
import { Animated, StyleSheet } from 'react-native';
|
|
4
|
-
import { useDateLookup } from '@coinbase/cds-common/visualizations/useDateLookup';
|
|
5
|
-
import { useLayout } from '@coinbase/cds-mobile/hooks/useLayout';
|
|
6
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
7
|
-
import { TextLabel2 } from '@coinbase/cds-mobile/typography';
|
|
8
|
-
import times from 'lodash/times';
|
|
9
|
-
import { useSparklineInteractiveContext } from './SparklineInteractiveProvider';
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
const numberOfLabels = 5;
|
|
12
|
-
const styles = StyleSheet.create({
|
|
13
|
-
wrapper: {
|
|
14
|
-
flexDirection: 'row',
|
|
15
|
-
justifyContent: 'space-between',
|
|
16
|
-
position: 'absolute',
|
|
17
|
-
top: 0,
|
|
18
|
-
left: 0,
|
|
19
|
-
right: 0,
|
|
20
|
-
zIndex: 1
|
|
21
|
-
},
|
|
22
|
-
label: {
|
|
23
|
-
width: 100 / numberOfLabels + "%"
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const SparklineInteractiveMarkerDate = /*#__PURE__*/memo(_ref => {
|
|
27
|
-
let {
|
|
28
|
-
getFormattedDate
|
|
29
|
-
} = _ref;
|
|
30
|
-
const [label, onLayout] = useLayout();
|
|
31
|
-
const x = useMemo(() => {
|
|
32
|
-
return label.x + label.width / 2;
|
|
33
|
-
}, [label.width, label.x]);
|
|
34
|
-
return /*#__PURE__*/_jsx(TextLabel2, {
|
|
35
|
-
align: "center",
|
|
36
|
-
color: "fgMuted",
|
|
37
|
-
onLayout: onLayout,
|
|
38
|
-
paddingTop: 3,
|
|
39
|
-
style: styles.label,
|
|
40
|
-
children: getFormattedDate(x)
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
function SparklineInteractiveMarkerDatesWithGeneric(_ref2) {
|
|
44
|
-
let {
|
|
45
|
-
formatDate,
|
|
46
|
-
selectedPeriod,
|
|
47
|
-
getMarker,
|
|
48
|
-
timePeriodGutter
|
|
49
|
-
} = _ref2;
|
|
50
|
-
const {
|
|
51
|
-
markerOpacity
|
|
52
|
-
} = useSparklineInteractiveContext();
|
|
53
|
-
const theme = useTheme();
|
|
54
|
-
const getFormattedDate = useDateLookup({
|
|
55
|
-
getMarker,
|
|
56
|
-
formatDate,
|
|
57
|
-
selectedPeriod
|
|
58
|
-
});
|
|
59
|
-
const paddingHorizontalStyle = useMemo(() => {
|
|
60
|
-
const localStyle = {};
|
|
61
|
-
if (timePeriodGutter) {
|
|
62
|
-
localStyle.paddingHorizontal = theme.space[timePeriodGutter];
|
|
63
|
-
}
|
|
64
|
-
return localStyle;
|
|
65
|
-
}, [theme.space, timePeriodGutter]);
|
|
66
|
-
const rootStyle = useMemo(() => {
|
|
67
|
-
return _extends({}, styles.wrapper, {
|
|
68
|
-
opacity: markerOpacity,
|
|
69
|
-
backgroundColor: theme.color.bg
|
|
70
|
-
}, paddingHorizontalStyle);
|
|
71
|
-
}, [markerOpacity, paddingHorizontalStyle, theme.color.bg]);
|
|
72
|
-
return /*#__PURE__*/_jsx(Animated.View, {
|
|
73
|
-
pointerEvents: "none",
|
|
74
|
-
style: rootStyle,
|
|
75
|
-
children: times(numberOfLabels).map((_, i) => {
|
|
76
|
-
return /*#__PURE__*/_jsx(SparklineInteractiveMarkerDate, {
|
|
77
|
-
getFormattedDate: getFormattedDate
|
|
78
|
-
}, i);
|
|
79
|
-
})
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
export const SparklineInteractiveMarkerDates = /*#__PURE__*/memo(SparklineInteractiveMarkerDatesWithGeneric);
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
-
import React, { memo, useCallback, useMemo, useRef } from 'react';
|
|
3
|
-
import { Animated, StyleSheet } from 'react-native';
|
|
4
|
-
import { useLayout } from '@coinbase/cds-mobile/hooks/useLayout';
|
|
5
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
6
|
-
import { TextLabel2 } from '@coinbase/cds-mobile/typography';
|
|
7
|
-
import { useSparklineInteractiveContext } from './SparklineInteractiveProvider';
|
|
8
|
-
import { useMinMaxTransform } from './useMinMaxTransform';
|
|
9
|
-
import { useSparklineInteractiveConstants } from './useSparklineInteractiveConstants';
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
const styles = StyleSheet.create({
|
|
12
|
-
outer: {
|
|
13
|
-
width: '100%',
|
|
14
|
-
alignItems: 'center'
|
|
15
|
-
},
|
|
16
|
-
caption: {
|
|
17
|
-
position: 'absolute',
|
|
18
|
-
left: 0,
|
|
19
|
-
top: 0
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const SparklineInteractiveMinMaxContent = /*#__PURE__*/memo(_ref => {
|
|
23
|
-
let {
|
|
24
|
-
x,
|
|
25
|
-
children
|
|
26
|
-
} = _ref;
|
|
27
|
-
const theme = useTheme();
|
|
28
|
-
const [minMaxLayout, onMinMaxLayout] = useLayout();
|
|
29
|
-
const opacity = useRef(new Animated.Value(0)).current;
|
|
30
|
-
const transform = useRef(new Animated.ValueXY({
|
|
31
|
-
x: 0,
|
|
32
|
-
y: 0
|
|
33
|
-
})).current;
|
|
34
|
-
useMinMaxTransform({
|
|
35
|
-
minMaxLayout,
|
|
36
|
-
x,
|
|
37
|
-
transform,
|
|
38
|
-
opacity
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Only do the layout if there is a new child.
|
|
42
|
-
// This prevents jitter in the case where children is
|
|
43
|
-
// set to undefined, then returned to the previous value,
|
|
44
|
-
// as is the case for privacy mode (where we hide the value)
|
|
45
|
-
const onLayout = useCallback(event => {
|
|
46
|
-
if (!children) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
return onMinMaxLayout(event);
|
|
50
|
-
}, [onMinMaxLayout, children]);
|
|
51
|
-
const rootStyle = useMemo(() => {
|
|
52
|
-
return _extends({}, styles.caption, {
|
|
53
|
-
height: theme.lineHeight.label2,
|
|
54
|
-
opacity,
|
|
55
|
-
transform: transform.getTranslateTransform()
|
|
56
|
-
});
|
|
57
|
-
}, [opacity, theme.lineHeight.label2, transform]);
|
|
58
|
-
const textLabelStyle = useMemo(() => {
|
|
59
|
-
return _extends({}, styles.caption, {
|
|
60
|
-
backgroundColor: theme.color.bg
|
|
61
|
-
});
|
|
62
|
-
}, [theme.color.bg]);
|
|
63
|
-
return /*#__PURE__*/_jsx(Animated.View, {
|
|
64
|
-
pointerEvents: "none",
|
|
65
|
-
style: rootStyle,
|
|
66
|
-
children: /*#__PURE__*/_jsx(TextLabel2, {
|
|
67
|
-
color: "fgMuted",
|
|
68
|
-
onLayout: onLayout,
|
|
69
|
-
padding: 0,
|
|
70
|
-
style: textLabelStyle,
|
|
71
|
-
children: children
|
|
72
|
-
})
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
export const SparklineInteractiveMinMax = /*#__PURE__*/memo(_ref2 => {
|
|
76
|
-
let {
|
|
77
|
-
formatMinMaxLabel,
|
|
78
|
-
dataPoint,
|
|
79
|
-
xFunction
|
|
80
|
-
} = _ref2;
|
|
81
|
-
const theme = useTheme();
|
|
82
|
-
const {
|
|
83
|
-
minMaxOpacity
|
|
84
|
-
} = useSparklineInteractiveContext();
|
|
85
|
-
const {
|
|
86
|
-
SparklineInteractiveMinMaxLabelHeight
|
|
87
|
-
} = useSparklineInteractiveConstants({});
|
|
88
|
-
const rootStyle = useMemo(() => {
|
|
89
|
-
return _extends({}, styles.outer, {
|
|
90
|
-
opacity: minMaxOpacity,
|
|
91
|
-
backgroundColor: theme.color.bg,
|
|
92
|
-
height: SparklineInteractiveMinMaxLabelHeight
|
|
93
|
-
});
|
|
94
|
-
}, [SparklineInteractiveMinMaxLabelHeight, minMaxOpacity, theme.color.bg]);
|
|
95
|
-
return /*#__PURE__*/_jsx(Animated.View, {
|
|
96
|
-
pointerEvents: "none",
|
|
97
|
-
style: rootStyle,
|
|
98
|
-
children: !!dataPoint && /*#__PURE__*/_jsx(SparklineInteractiveMinMaxContent, {
|
|
99
|
-
x: xFunction(dataPoint.date),
|
|
100
|
-
children: formatMinMaxLabel(dataPoint.value)
|
|
101
|
-
})
|
|
102
|
-
});
|
|
103
|
-
});
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
2
|
-
import { Animated as RNAnimated, Platform, View } from 'react-native';
|
|
3
|
-
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
|
|
4
|
-
import Animated, { runOnJS } from 'react-native-reanimated';
|
|
5
|
-
import { Haptics } from '@coinbase/cds-mobile/utils/haptics';
|
|
6
|
-
import { noop } from '@coinbase/cds-utils';
|
|
7
|
-
import { useSparklineInteractiveContext } from './SparklineInteractiveProvider';
|
|
8
|
-
import { useSparklineInteractiveConstants } from './useSparklineInteractiveConstants';
|
|
9
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
const {
|
|
11
|
-
lightImpact
|
|
12
|
-
} = Haptics;
|
|
13
|
-
// Generics do not work with React.memo or forwardRef
|
|
14
|
-
// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref/58473012
|
|
15
|
-
export const SparklineInteractivePanGestureHandler = function SparklineInteractivePanGestureHandler(_ref) {
|
|
16
|
-
let {
|
|
17
|
-
onScrubEnd = noop,
|
|
18
|
-
onScrubStart = noop,
|
|
19
|
-
onScrub = noop,
|
|
20
|
-
getMarker,
|
|
21
|
-
selectedPeriod,
|
|
22
|
-
children,
|
|
23
|
-
disabled,
|
|
24
|
-
allowOverflowGestures
|
|
25
|
-
} = _ref;
|
|
26
|
-
const {
|
|
27
|
-
markerXPosition,
|
|
28
|
-
markerGestureState,
|
|
29
|
-
animateMarkerIn,
|
|
30
|
-
animateMarkerOut,
|
|
31
|
-
animateMinMaxIn,
|
|
32
|
-
animateMinxMaxOut,
|
|
33
|
-
animateHoverDateIn,
|
|
34
|
-
animateHoverDateOut
|
|
35
|
-
} = useSparklineInteractiveContext();
|
|
36
|
-
const {
|
|
37
|
-
chartVerticalLineWidth,
|
|
38
|
-
endX,
|
|
39
|
-
startX
|
|
40
|
-
} = useSparklineInteractiveConstants({});
|
|
41
|
-
const handleOnStartJsThread = useCallback(() => {
|
|
42
|
-
void lightImpact();
|
|
43
|
-
onScrubStart();
|
|
44
|
-
RNAnimated.parallel([animateMarkerIn, animateMinxMaxOut, animateHoverDateIn]).start();
|
|
45
|
-
}, [animateHoverDateIn, animateMarkerIn, animateMinxMaxOut, onScrubStart]);
|
|
46
|
-
const handleOnUpdateJsThread = useCallback(() => {
|
|
47
|
-
const dataPoint = getMarker(markerXPosition.value);
|
|
48
|
-
if (dataPoint) {
|
|
49
|
-
onScrub({
|
|
50
|
-
point: dataPoint,
|
|
51
|
-
period: selectedPeriod
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}, [getMarker, markerXPosition.value, onScrub, selectedPeriod]);
|
|
55
|
-
const handleOnEndOrCancelledJsThread = useCallback(() => {
|
|
56
|
-
onScrubEnd();
|
|
57
|
-
RNAnimated.parallel([animateMarkerOut, animateMinMaxIn, animateHoverDateOut]).start(_ref2 => {
|
|
58
|
-
let {
|
|
59
|
-
finished
|
|
60
|
-
} = _ref2;
|
|
61
|
-
if (finished) {
|
|
62
|
-
markerXPosition.value = -1;
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
}, [animateHoverDateOut, animateMarkerOut, animateMinMaxIn, markerXPosition, onScrubEnd]);
|
|
66
|
-
const handleOnEndJsThread = useCallback(() => {
|
|
67
|
-
void Haptics.lightImpact();
|
|
68
|
-
handleOnEndOrCancelledJsThread();
|
|
69
|
-
}, [handleOnEndOrCancelledJsThread]);
|
|
70
|
-
if (disabled) {
|
|
71
|
-
return /*#__PURE__*/_jsx(View, {
|
|
72
|
-
children: children
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const longPressGesture = Gesture.Pan().activateAfterLongPress(110).shouldCancelWhenOutside(!allowOverflowGestures).onStart(function onStart(event) {
|
|
76
|
-
runOnJS(handleOnStartJsThread)();
|
|
77
|
-
markerGestureState.value = 1;
|
|
78
|
-
|
|
79
|
-
// Android does not trigger onUpdate when the gesture starts. This achieves consistent behavior across both iOS and Android
|
|
80
|
-
if (Platform.OS === 'android') {
|
|
81
|
-
const newMarkerXPosition = Math.min(endX, Math.max(startX, event.x - chartVerticalLineWidth / 2));
|
|
82
|
-
markerXPosition.value = newMarkerXPosition;
|
|
83
|
-
runOnJS(handleOnUpdateJsThread)();
|
|
84
|
-
}
|
|
85
|
-
}).onUpdate(function onUpdate(event) {
|
|
86
|
-
const newMarkerXPosition = Math.min(endX, Math.max(startX, event.x - chartVerticalLineWidth / 2));
|
|
87
|
-
markerXPosition.value = newMarkerXPosition;
|
|
88
|
-
if (markerGestureState.value === 1) {
|
|
89
|
-
runOnJS(handleOnUpdateJsThread)();
|
|
90
|
-
}
|
|
91
|
-
}).onEnd(function onEnd() {
|
|
92
|
-
markerGestureState.value = 0;
|
|
93
|
-
runOnJS(handleOnEndJsThread)();
|
|
94
|
-
}).onTouchesCancelled(function onTouchesCancelled() {
|
|
95
|
-
markerGestureState.value = 0;
|
|
96
|
-
runOnJS(handleOnEndOrCancelledJsThread)();
|
|
97
|
-
});
|
|
98
|
-
return /*#__PURE__*/_jsx(GestureDetector, {
|
|
99
|
-
gesture: longPressGesture,
|
|
100
|
-
children: /*#__PURE__*/_jsx(Animated.View, {
|
|
101
|
-
children: children
|
|
102
|
-
})
|
|
103
|
-
});
|
|
104
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React, { memo, useCallback, useRef } from 'react';
|
|
2
|
-
import { SparklineInteractiveAnimatedPath } from './SparklineInteractiveAnimatedPath';
|
|
3
|
-
import { SparklineInteractiveTimeseriesPaths } from './SparklineInteractiveTimeseriesPaths';
|
|
4
|
-
import { useSparklineInteractiveConstants } from './useSparklineInteractiveConstants';
|
|
5
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
function SparklineInteractivePathsWithGeneric(_ref) {
|
|
7
|
-
let {
|
|
8
|
-
showHoverData,
|
|
9
|
-
fill,
|
|
10
|
-
fillType = 'gradient',
|
|
11
|
-
path,
|
|
12
|
-
area,
|
|
13
|
-
selectedPeriod,
|
|
14
|
-
yAxisScalingFactor,
|
|
15
|
-
strokeColor,
|
|
16
|
-
hoverData,
|
|
17
|
-
compact
|
|
18
|
-
} = _ref;
|
|
19
|
-
// Map 'dotted' to 'gradientDotted' for Sparkline
|
|
20
|
-
const sparklineFillType = fillType === 'dotted' ? 'gradientDotted' : 'gradient';
|
|
21
|
-
const hoverPathRef = useRef(undefined);
|
|
22
|
-
const hoverAreaRef = useRef(undefined);
|
|
23
|
-
const shouldShowFill = !!fill;
|
|
24
|
-
const {
|
|
25
|
-
chartWidth,
|
|
26
|
-
chartHeight
|
|
27
|
-
} = useSparklineInteractiveConstants({
|
|
28
|
-
compact
|
|
29
|
-
});
|
|
30
|
-
const handleMultiTimeseriesRender = useCallback(_ref2 => {
|
|
31
|
-
let {
|
|
32
|
-
area: timeseriesArea,
|
|
33
|
-
path: timeseriesPath
|
|
34
|
-
} = _ref2;
|
|
35
|
-
hoverPathRef.current = timeseriesPath;
|
|
36
|
-
hoverAreaRef.current = timeseriesArea;
|
|
37
|
-
}, []);
|
|
38
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
39
|
-
children: [!showHoverData && /*#__PURE__*/_jsx(SparklineInteractiveAnimatedPath, {
|
|
40
|
-
area: shouldShowFill ? area : undefined,
|
|
41
|
-
color: strokeColor,
|
|
42
|
-
d: path,
|
|
43
|
-
fillType: sparklineFillType,
|
|
44
|
-
initialArea: hoverAreaRef.current,
|
|
45
|
-
initialPath: hoverPathRef.current,
|
|
46
|
-
selectedPeriod: selectedPeriod,
|
|
47
|
-
yAxisScalingFactor: yAxisScalingFactor
|
|
48
|
-
}), !!showHoverData && /*#__PURE__*/_jsx(SparklineInteractiveTimeseriesPaths, {
|
|
49
|
-
data: hoverData == null ? void 0 : hoverData[selectedPeriod],
|
|
50
|
-
height: chartHeight,
|
|
51
|
-
initialPath: path,
|
|
52
|
-
onRender: handleMultiTimeseriesRender,
|
|
53
|
-
width: chartWidth
|
|
54
|
-
})]
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
export const SparklineInteractivePaths = /*#__PURE__*/memo(SparklineInteractivePathsWithGeneric);
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import React, { memo, useCallback, useMemo } from 'react';
|
|
2
|
-
import { ScrollView, StyleSheet } from 'react-native';
|
|
3
|
-
import { periodLabelMap } from '@coinbase/cds-common/tokens/sparkline';
|
|
4
|
-
import { getAccessibleColor } from '@coinbase/cds-common/utils/getAccessibleColor';
|
|
5
|
-
import { useHorizontallyScrollingPressables } from '@coinbase/cds-mobile/hooks/useHorizontallyScrollingPressables';
|
|
6
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
7
|
-
import { Box } from '@coinbase/cds-mobile/layout/Box';
|
|
8
|
-
import { HStack } from '@coinbase/cds-mobile/layout/HStack';
|
|
9
|
-
import { OverflowGradient } from '@coinbase/cds-mobile/layout/OverflowGradient';
|
|
10
|
-
import { Pressable } from '@coinbase/cds-mobile/system/Pressable';
|
|
11
|
-
import { TextLabel1 } from '@coinbase/cds-mobile/typography';
|
|
12
|
-
import { Haptics } from '@coinbase/cds-mobile/utils/haptics';
|
|
13
|
-
import { useSparklineInteractiveContext } from './SparklineInteractiveProvider';
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
function SparklineInteractivePeriodWithGeneric(_ref) {
|
|
16
|
-
var _periodLabelMap$perio;
|
|
17
|
-
let {
|
|
18
|
-
period,
|
|
19
|
-
selectedPeriod,
|
|
20
|
-
setSelectedPeriod,
|
|
21
|
-
getLayoutHandler,
|
|
22
|
-
color
|
|
23
|
-
} = _ref;
|
|
24
|
-
const isSelected = period.value === selectedPeriod;
|
|
25
|
-
const periodLabel = (_periodLabelMap$perio = periodLabelMap[period.label]) != null ? _periodLabelMap$perio : period.label;
|
|
26
|
-
const periodHint = useMemo(() => isSelected ? "Currently showing data for the " + periodLabel + " timeframe" : "Show data for the " + periodLabel + " timeframe", [isSelected, periodLabel]);
|
|
27
|
-
const handleOnPress = useCallback(() => {
|
|
28
|
-
void Haptics.lightImpact();
|
|
29
|
-
setSelectedPeriod(period.value);
|
|
30
|
-
}, [period, setSelectedPeriod]);
|
|
31
|
-
const theme = useTheme();
|
|
32
|
-
const textStyle = useMemo(() => ({
|
|
33
|
-
color: isSelected ? color : theme.color.fgMuted
|
|
34
|
-
}), [color, isSelected, theme.color.fgMuted]);
|
|
35
|
-
const accessibilityState = useMemo(() => ({
|
|
36
|
-
selected: isSelected
|
|
37
|
-
}), [isSelected]);
|
|
38
|
-
return /*#__PURE__*/_jsx(Box, {
|
|
39
|
-
alignItems: "center",
|
|
40
|
-
justifyContent: "center",
|
|
41
|
-
onLayout: getLayoutHandler(period.value),
|
|
42
|
-
paddingY: 2,
|
|
43
|
-
children: /*#__PURE__*/_jsx(Pressable, {
|
|
44
|
-
accessibilityHint: periodHint,
|
|
45
|
-
accessibilityLabel: periodLabel,
|
|
46
|
-
accessibilityState: accessibilityState,
|
|
47
|
-
background: isSelected ? 'bgPrimaryWash' : 'bg',
|
|
48
|
-
borderColor: "transparent",
|
|
49
|
-
borderRadius: 1000,
|
|
50
|
-
onPress: handleOnPress,
|
|
51
|
-
children: /*#__PURE__*/_jsx(TextLabel1, {
|
|
52
|
-
paddingX: 2,
|
|
53
|
-
paddingY: 1,
|
|
54
|
-
style: textStyle,
|
|
55
|
-
children: period.label
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
}, period.value);
|
|
59
|
-
}
|
|
60
|
-
const periodSelectorStyles = StyleSheet.create({
|
|
61
|
-
scrollViewContainer: {
|
|
62
|
-
flexGrow: 1
|
|
63
|
-
},
|
|
64
|
-
hStackContainer: {
|
|
65
|
-
flex: 1
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
const SparklineInteractivePeriod = /*#__PURE__*/memo(SparklineInteractivePeriodWithGeneric);
|
|
69
|
-
export const SparklineInteractivePeriodSelector = _ref2 => {
|
|
70
|
-
let {
|
|
71
|
-
selectedPeriod,
|
|
72
|
-
setSelectedPeriod,
|
|
73
|
-
periods,
|
|
74
|
-
color
|
|
75
|
-
} = _ref2;
|
|
76
|
-
const theme = useTheme();
|
|
77
|
-
const accessibleForeground = color !== 'auto' ? color : getAccessibleColor({
|
|
78
|
-
background: theme.color.bg,
|
|
79
|
-
foreground: 'auto'
|
|
80
|
-
});
|
|
81
|
-
const {
|
|
82
|
-
markerOpacity
|
|
83
|
-
} = useSparklineInteractiveContext();
|
|
84
|
-
const {
|
|
85
|
-
scrollRef,
|
|
86
|
-
isScrollContentOverflowing,
|
|
87
|
-
isScrollContentOffscreenRight,
|
|
88
|
-
handleScroll,
|
|
89
|
-
handleScrollContainerLayout,
|
|
90
|
-
handleScrollContentSizeChange,
|
|
91
|
-
getPressableLayoutHandler
|
|
92
|
-
} = useHorizontallyScrollingPressables(selectedPeriod);
|
|
93
|
-
const opacity = markerOpacity.interpolate({
|
|
94
|
-
inputRange: [0, 1],
|
|
95
|
-
outputRange: [1, 0]
|
|
96
|
-
});
|
|
97
|
-
return /*#__PURE__*/_jsxs(Box, {
|
|
98
|
-
animated: true,
|
|
99
|
-
background: "bg",
|
|
100
|
-
opacity: opacity,
|
|
101
|
-
children: [/*#__PURE__*/_jsx(ScrollView, {
|
|
102
|
-
ref: scrollRef,
|
|
103
|
-
horizontal: true,
|
|
104
|
-
contentContainerStyle: periodSelectorStyles.scrollViewContainer,
|
|
105
|
-
onContentSizeChange: handleScrollContentSizeChange,
|
|
106
|
-
onLayout: handleScrollContainerLayout,
|
|
107
|
-
onScroll: handleScroll,
|
|
108
|
-
scrollEventThrottle: 1,
|
|
109
|
-
showsHorizontalScrollIndicator: false,
|
|
110
|
-
children: /*#__PURE__*/_jsx(HStack, {
|
|
111
|
-
justifyContent: "space-between",
|
|
112
|
-
padding: 0,
|
|
113
|
-
style: periodSelectorStyles.hStackContainer,
|
|
114
|
-
children: periods.map(period => /*#__PURE__*/_jsx(SparklineInteractivePeriod, {
|
|
115
|
-
color: accessibleForeground,
|
|
116
|
-
getLayoutHandler: getPressableLayoutHandler,
|
|
117
|
-
period: period,
|
|
118
|
-
selectedPeriod: selectedPeriod,
|
|
119
|
-
setSelectedPeriod: setSelectedPeriod
|
|
120
|
-
}, period.value))
|
|
121
|
-
})
|
|
122
|
-
}), isScrollContentOverflowing && isScrollContentOffscreenRight && /*#__PURE__*/_jsx(OverflowGradient, {})]
|
|
123
|
-
});
|
|
124
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import React, { createContext, memo, useCallback, useContext, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { Animated } from 'react-native';
|
|
3
|
-
import { makeMutable, useSharedValue } from 'react-native-reanimated';
|
|
4
|
-
import { gutter } from '@coinbase/cds-common/tokens/sizing';
|
|
5
|
-
import { noop } from '@coinbase/cds-utils';
|
|
6
|
-
import { useOpacityAnimation } from './useOpacityAnimation';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
const SparklineInteractiveContext = /*#__PURE__*/createContext({
|
|
9
|
-
isFallbackVisible: true,
|
|
10
|
-
markerXPosition: makeMutable(0),
|
|
11
|
-
markerGestureState: makeMutable(0),
|
|
12
|
-
showFallback: noop,
|
|
13
|
-
hideFallback: noop,
|
|
14
|
-
chartOpacity: new Animated.Value(0),
|
|
15
|
-
animateChartIn: noop,
|
|
16
|
-
markerOpacity: new Animated.Value(0),
|
|
17
|
-
animateMarkerIn: noop,
|
|
18
|
-
animateMarkerOut: noop,
|
|
19
|
-
minMaxOpacity: new Animated.Value(0),
|
|
20
|
-
animateMinMaxIn: noop,
|
|
21
|
-
animateMinxMaxOut: noop,
|
|
22
|
-
hoverDateOpacity: new Animated.Value(0),
|
|
23
|
-
animateHoverDateIn: noop,
|
|
24
|
-
animateHoverDateOut: noop,
|
|
25
|
-
compact: false,
|
|
26
|
-
gutter
|
|
27
|
-
});
|
|
28
|
-
export const SparklineInteractiveProvider = /*#__PURE__*/memo(_ref => {
|
|
29
|
-
let {
|
|
30
|
-
children,
|
|
31
|
-
compact = false,
|
|
32
|
-
gutter: propGutter
|
|
33
|
-
} = _ref;
|
|
34
|
-
const [isFallbackVisible, setIsFallbackVisible] = useState(true);
|
|
35
|
-
const markerXPosition = useSharedValue(-1);
|
|
36
|
-
const markerGestureState = useSharedValue(0);
|
|
37
|
-
const [chartOpacity, animateChartIn, animateChartOut] = useOpacityAnimation();
|
|
38
|
-
const [markerOpacity, animateMarkerIn, animateMarkerOut] = useOpacityAnimation();
|
|
39
|
-
const [minMaxOpacity, animateMinMaxIn, animateMinxMaxOut] = useOpacityAnimation();
|
|
40
|
-
const [hoverDateOpacity, animateHoverDateIn, animateHoverDateOut] = useOpacityAnimation();
|
|
41
|
-
const chartGutter = useRef(propGutter != null ? propGutter : gutter).current;
|
|
42
|
-
const showFallback = useCallback(() => {
|
|
43
|
-
animateChartOut.start();
|
|
44
|
-
setIsFallbackVisible(true);
|
|
45
|
-
}, [animateChartOut]);
|
|
46
|
-
const hideFallback = useCallback(() => {
|
|
47
|
-
animateChartIn.start();
|
|
48
|
-
animateMinMaxIn.start();
|
|
49
|
-
setIsFallbackVisible(false);
|
|
50
|
-
}, [animateChartIn, animateMinMaxIn]);
|
|
51
|
-
const sparklineProviderVal = useMemo(() => {
|
|
52
|
-
return {
|
|
53
|
-
isFallbackVisible,
|
|
54
|
-
markerXPosition,
|
|
55
|
-
markerGestureState,
|
|
56
|
-
showFallback,
|
|
57
|
-
hideFallback,
|
|
58
|
-
chartOpacity,
|
|
59
|
-
animateChartIn,
|
|
60
|
-
markerOpacity,
|
|
61
|
-
animateMarkerIn,
|
|
62
|
-
animateMarkerOut,
|
|
63
|
-
minMaxOpacity,
|
|
64
|
-
animateMinMaxIn,
|
|
65
|
-
animateMinxMaxOut,
|
|
66
|
-
hoverDateOpacity,
|
|
67
|
-
animateHoverDateIn,
|
|
68
|
-
animateHoverDateOut,
|
|
69
|
-
compact,
|
|
70
|
-
gutter: chartGutter
|
|
71
|
-
};
|
|
72
|
-
}, [animateChartIn, animateHoverDateIn, animateHoverDateOut, animateMarkerIn, animateMarkerOut, animateMinMaxIn, animateMinxMaxOut, chartOpacity, compact, hideFallback, hoverDateOpacity, isFallbackVisible, markerGestureState, markerOpacity, markerXPosition, minMaxOpacity, showFallback, chartGutter]);
|
|
73
|
-
return /*#__PURE__*/_jsx(SparklineInteractiveContext.Provider, {
|
|
74
|
-
value: sparklineProviderVal,
|
|
75
|
-
children: children
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
export function useSparklineInteractiveContext() {
|
|
79
|
-
return useContext(SparklineInteractiveContext);
|
|
80
|
-
}
|