@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,44 +0,0 @@
|
|
|
1
|
-
const _excluded = ["dx", "dy"];
|
|
2
|
-
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); }
|
|
3
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
-
import { memo, useMemo } from 'react';
|
|
5
|
-
import { useCartesianChartContext } from '../ChartProvider';
|
|
6
|
-
import { DefaultReferenceLineLabel } from '../line';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
/**
|
|
9
|
-
* DefaultScrubberLabel is the default label component for the scrubber line.
|
|
10
|
-
* It will automatically add padding around the label when elevated to fit within chart bounds to prevent shadow from being cutoff.
|
|
11
|
-
* In vertical layout, it positions the label above the scrubber line.
|
|
12
|
-
* In horizontal layout, it centers the label in the chart's right inset.
|
|
13
|
-
*/
|
|
14
|
-
export const DefaultScrubberLabel = /*#__PURE__*/memo(_ref => {
|
|
15
|
-
let {
|
|
16
|
-
dx: dxProp,
|
|
17
|
-
dy: dyProp
|
|
18
|
-
} = _ref,
|
|
19
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
20
|
-
const {
|
|
21
|
-
drawingArea,
|
|
22
|
-
layout,
|
|
23
|
-
width: chartWidth
|
|
24
|
-
} = useCartesianChartContext();
|
|
25
|
-
const isHorizontalLayout = layout === 'horizontal';
|
|
26
|
-
const dx = useMemo(() => {
|
|
27
|
-
if (dxProp !== undefined) return dxProp;
|
|
28
|
-
if (isHorizontalLayout) {
|
|
29
|
-
const drawingAreaEnd = drawingArea.x + drawingArea.width;
|
|
30
|
-
const rightOffset = chartWidth - drawingAreaEnd;
|
|
31
|
-
return rightOffset / 2;
|
|
32
|
-
}
|
|
33
|
-
return 0;
|
|
34
|
-
}, [drawingArea.width, drawingArea.x, dxProp, isHorizontalLayout, chartWidth]);
|
|
35
|
-
const dy = useMemo(() => {
|
|
36
|
-
if (dyProp !== undefined) return dyProp;
|
|
37
|
-
if (isHorizontalLayout) return 0;
|
|
38
|
-
return -0.5 * drawingArea.y;
|
|
39
|
-
}, [dyProp, isHorizontalLayout, drawingArea.y]);
|
|
40
|
-
return /*#__PURE__*/_jsx(DefaultReferenceLineLabel, _extends({
|
|
41
|
-
dx: dx,
|
|
42
|
-
dy: dy
|
|
43
|
-
}, props));
|
|
44
|
-
});
|
|
@@ -1,198 +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, { forwardRef, memo, useCallback, useEffect, useImperativeHandle, useMemo } from 'react';
|
|
3
|
-
import { runOnJS, useAnimatedReaction, useDerivedValue, useSharedValue } from 'react-native-reanimated';
|
|
4
|
-
import { useTheme } from '@coinbase/cds-mobile';
|
|
5
|
-
import { Group, Rect } from '@shopify/react-native-skia';
|
|
6
|
-
import { useCartesianChartContext } from '../ChartProvider';
|
|
7
|
-
import { ReferenceLine } from '../line';
|
|
8
|
-
import { defaultAccessoryEnterTransition, getPointOnSerializableScale, getTransition, useScrubberContext } from '../utils';
|
|
9
|
-
import { buildTransition } from '../utils/transition';
|
|
10
|
-
import { DefaultScrubberBeacon } from './DefaultScrubberBeacon';
|
|
11
|
-
import { DefaultScrubberLabel } from './DefaultScrubberLabel';
|
|
12
|
-
import { ScrubberBeaconGroup } from './ScrubberBeaconGroup';
|
|
13
|
-
import { ScrubberBeaconLabelGroup } from './ScrubberBeaconLabelGroup';
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
/**
|
|
16
|
-
* Unified component that manages all scrubber elements (beacons, line, labels).
|
|
17
|
-
*/
|
|
18
|
-
export const Scrubber = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref, ref) => {
|
|
19
|
-
let {
|
|
20
|
-
seriesIds,
|
|
21
|
-
hideBeaconLabels,
|
|
22
|
-
hideLine,
|
|
23
|
-
label,
|
|
24
|
-
lineStroke,
|
|
25
|
-
BeaconComponent = DefaultScrubberBeacon,
|
|
26
|
-
BeaconLabelComponent,
|
|
27
|
-
LineComponent,
|
|
28
|
-
LabelComponent = DefaultScrubberLabel,
|
|
29
|
-
labelElevated,
|
|
30
|
-
hideOverlay,
|
|
31
|
-
overlayOffset = 2,
|
|
32
|
-
beaconLabelMinGap,
|
|
33
|
-
beaconLabelHorizontalOffset,
|
|
34
|
-
beaconLabelPreferredSide,
|
|
35
|
-
labelFont,
|
|
36
|
-
labelBoundsInset,
|
|
37
|
-
beaconLabelFont,
|
|
38
|
-
idlePulse,
|
|
39
|
-
beaconTransitions,
|
|
40
|
-
transitions = beaconTransitions,
|
|
41
|
-
beaconStroke
|
|
42
|
-
} = _ref;
|
|
43
|
-
const theme = useTheme();
|
|
44
|
-
const beaconGroupRef = React.useRef(null);
|
|
45
|
-
const {
|
|
46
|
-
scrubberPosition
|
|
47
|
-
} = useScrubberContext();
|
|
48
|
-
const {
|
|
49
|
-
layout,
|
|
50
|
-
getXSerializableScale,
|
|
51
|
-
getYSerializableScale,
|
|
52
|
-
getXAxis,
|
|
53
|
-
getYAxis,
|
|
54
|
-
series,
|
|
55
|
-
drawingArea,
|
|
56
|
-
animate,
|
|
57
|
-
dataLength
|
|
58
|
-
} = useCartesianChartContext();
|
|
59
|
-
const categoryAxisIsX = useMemo(() => layout !== 'horizontal', [layout]);
|
|
60
|
-
const indexAxis = useMemo(() => categoryAxisIsX ? getXAxis() : getYAxis(), [categoryAxisIsX, getXAxis, getYAxis]);
|
|
61
|
-
const indexScale = useMemo(() => categoryAxisIsX ? getXSerializableScale() : getYSerializableScale(), [categoryAxisIsX, getXSerializableScale, getYSerializableScale]);
|
|
62
|
-
|
|
63
|
-
// Animation state for delayed scrubber rendering (matches web timing)
|
|
64
|
-
const scrubberOpacity = useSharedValue(animate ? 0 : 1);
|
|
65
|
-
|
|
66
|
-
// Expose imperative handle with pulse method
|
|
67
|
-
useImperativeHandle(ref, () => ({
|
|
68
|
-
pulse: () => {
|
|
69
|
-
var _beaconGroupRef$curre;
|
|
70
|
-
(_beaconGroupRef$curre = beaconGroupRef.current) == null || _beaconGroupRef$curre.pulse();
|
|
71
|
-
}
|
|
72
|
-
}));
|
|
73
|
-
const filteredSeriesIds = useMemo(() => {
|
|
74
|
-
if (seriesIds === undefined) {
|
|
75
|
-
var _series$map;
|
|
76
|
-
return (_series$map = series == null ? void 0 : series.map(s => s.id)) != null ? _series$map : [];
|
|
77
|
-
}
|
|
78
|
-
return seriesIds;
|
|
79
|
-
}, [series, seriesIds]);
|
|
80
|
-
const dataIndex = useDerivedValue(() => {
|
|
81
|
-
var _scrubberPosition$val;
|
|
82
|
-
return (_scrubberPosition$val = scrubberPosition.value) != null ? _scrubberPosition$val : Math.max(0, dataLength - 1);
|
|
83
|
-
}, [scrubberPosition, dataLength]);
|
|
84
|
-
const dataValue = useDerivedValue(() => {
|
|
85
|
-
if (indexAxis != null && indexAxis.data && Array.isArray(indexAxis.data) && indexAxis.data[dataIndex.value] !== undefined) {
|
|
86
|
-
const axisValue = indexAxis.data[dataIndex.value];
|
|
87
|
-
return typeof axisValue === 'string' ? dataIndex.value : axisValue;
|
|
88
|
-
}
|
|
89
|
-
return dataIndex.value;
|
|
90
|
-
}, [indexAxis, dataIndex]);
|
|
91
|
-
const lineOpacity = useDerivedValue(() => {
|
|
92
|
-
return scrubberPosition.value !== undefined ? 1 : 0;
|
|
93
|
-
}, [scrubberPosition]);
|
|
94
|
-
const overlayOpacity = useDerivedValue(() => {
|
|
95
|
-
return scrubberPosition.value !== undefined ? 0.8 : 0;
|
|
96
|
-
}, [scrubberPosition]);
|
|
97
|
-
const pixelPosition = useDerivedValue(() => {
|
|
98
|
-
if (dataValue.value === undefined || !indexScale) return undefined;
|
|
99
|
-
return getPointOnSerializableScale(dataValue.value, indexScale);
|
|
100
|
-
}, [dataValue, indexScale]);
|
|
101
|
-
const overlayWidth = useDerivedValue(() => {
|
|
102
|
-
var _pixelPosition$value;
|
|
103
|
-
const pixel = (_pixelPosition$value = pixelPosition.value) != null ? _pixelPosition$value : 0;
|
|
104
|
-
return categoryAxisIsX ? drawingArea.x + drawingArea.width - pixel + overlayOffset : drawingArea.width + overlayOffset * 2;
|
|
105
|
-
}, [pixelPosition, categoryAxisIsX, drawingArea, overlayOffset]);
|
|
106
|
-
const overlayHeight = useDerivedValue(() => {
|
|
107
|
-
var _pixelPosition$value2;
|
|
108
|
-
const pixel = (_pixelPosition$value2 = pixelPosition.value) != null ? _pixelPosition$value2 : 0;
|
|
109
|
-
return categoryAxisIsX ? drawingArea.height + overlayOffset * 2 : drawingArea.y + drawingArea.height - pixel + overlayOffset;
|
|
110
|
-
}, [pixelPosition, categoryAxisIsX, drawingArea, overlayOffset]);
|
|
111
|
-
const overlayX = useDerivedValue(() => {
|
|
112
|
-
var _pixelPosition$value3;
|
|
113
|
-
const pixel = (_pixelPosition$value3 = pixelPosition.value) != null ? _pixelPosition$value3 : 0;
|
|
114
|
-
return categoryAxisIsX ? pixel : drawingArea.x - overlayOffset;
|
|
115
|
-
}, [pixelPosition, categoryAxisIsX, drawingArea, overlayOffset]);
|
|
116
|
-
const overlayY = useDerivedValue(() => {
|
|
117
|
-
var _pixelPosition$value4;
|
|
118
|
-
const pixel = (_pixelPosition$value4 = pixelPosition.value) != null ? _pixelPosition$value4 : 0;
|
|
119
|
-
return categoryAxisIsX ? drawingArea.y - overlayOffset : pixel;
|
|
120
|
-
}, [pixelPosition, categoryAxisIsX, drawingArea, overlayOffset]);
|
|
121
|
-
const resolvedLabelValue = useSharedValue('');
|
|
122
|
-
const updateResolvedLabel = useCallback(index => {
|
|
123
|
-
if (!label) {
|
|
124
|
-
resolvedLabelValue.value = '';
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (typeof label === 'function') {
|
|
128
|
-
const result = label(index);
|
|
129
|
-
resolvedLabelValue.value = result != null ? result : '';
|
|
130
|
-
} else if (typeof label === 'string') {
|
|
131
|
-
resolvedLabelValue.value = label;
|
|
132
|
-
}
|
|
133
|
-
}, [label, resolvedLabelValue]);
|
|
134
|
-
|
|
135
|
-
// Update resolved label when dataIndex changes
|
|
136
|
-
useAnimatedReaction(() => dataIndex.value, currentIndex => {
|
|
137
|
-
'worklet';
|
|
138
|
-
|
|
139
|
-
runOnJS(updateResolvedLabel)(currentIndex);
|
|
140
|
-
}, [updateResolvedLabel]);
|
|
141
|
-
const beaconLabels = useMemo(() => {
|
|
142
|
-
var _series$filter$filter;
|
|
143
|
-
return (_series$filter$filter = series == null ? void 0 : series.filter(s => filteredSeriesIds.includes(s.id)).filter(s => s.label !== undefined && s.label.length > 0).map(s => ({
|
|
144
|
-
seriesId: s.id,
|
|
145
|
-
label: s.label,
|
|
146
|
-
color: s.color
|
|
147
|
-
}))) != null ? _series$filter$filter : [];
|
|
148
|
-
}, [series, filteredSeriesIds]);
|
|
149
|
-
const showBeaconLabels = !hideBeaconLabels && categoryAxisIsX && beaconLabels.length > 0;
|
|
150
|
-
const isReady = !!indexScale;
|
|
151
|
-
const groupEnterTransition = useMemo(() => getTransition(transitions == null ? void 0 : transitions.enter, animate, defaultAccessoryEnterTransition), [transitions == null ? void 0 : transitions.enter, animate]);
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
if (animate && isReady) {
|
|
154
|
-
scrubberOpacity.value = buildTransition(1, groupEnterTransition);
|
|
155
|
-
}
|
|
156
|
-
}, [animate, isReady, scrubberOpacity, groupEnterTransition]);
|
|
157
|
-
if (!isReady) return;
|
|
158
|
-
return /*#__PURE__*/_jsxs(Group, {
|
|
159
|
-
opacity: scrubberOpacity,
|
|
160
|
-
children: [!hideOverlay && /*#__PURE__*/_jsx(Rect, {
|
|
161
|
-
color: theme.color.bg,
|
|
162
|
-
height: overlayHeight,
|
|
163
|
-
opacity: overlayOpacity,
|
|
164
|
-
width: overlayWidth,
|
|
165
|
-
x: overlayX,
|
|
166
|
-
y: overlayY
|
|
167
|
-
}), !hideLine && /*#__PURE__*/_jsx(ReferenceLine, _extends({
|
|
168
|
-
LabelComponent: LabelComponent,
|
|
169
|
-
LineComponent: LineComponent
|
|
170
|
-
}, categoryAxisIsX ? {
|
|
171
|
-
dataX: dataValue
|
|
172
|
-
} : {
|
|
173
|
-
dataY: dataValue
|
|
174
|
-
}, {
|
|
175
|
-
label: resolvedLabelValue,
|
|
176
|
-
labelBoundsInset: labelBoundsInset,
|
|
177
|
-
labelElevated: labelElevated,
|
|
178
|
-
labelFont: labelFont,
|
|
179
|
-
opacity: lineOpacity,
|
|
180
|
-
stroke: lineStroke
|
|
181
|
-
})), /*#__PURE__*/_jsx(ScrubberBeaconGroup, {
|
|
182
|
-
ref: beaconGroupRef,
|
|
183
|
-
BeaconComponent: BeaconComponent,
|
|
184
|
-
idlePulse: idlePulse,
|
|
185
|
-
seriesIds: filteredSeriesIds,
|
|
186
|
-
stroke: beaconStroke,
|
|
187
|
-
transitions: transitions
|
|
188
|
-
}), showBeaconLabels && /*#__PURE__*/_jsx(ScrubberBeaconLabelGroup, {
|
|
189
|
-
BeaconLabelComponent: BeaconLabelComponent,
|
|
190
|
-
labelFont: beaconLabelFont,
|
|
191
|
-
labelHorizontalOffset: beaconLabelHorizontalOffset,
|
|
192
|
-
labelMinGap: beaconLabelMinGap,
|
|
193
|
-
labelPreferredSide: beaconLabelPreferredSide,
|
|
194
|
-
labels: beaconLabels,
|
|
195
|
-
transitions: transitions
|
|
196
|
-
})]
|
|
197
|
-
});
|
|
198
|
-
}));
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import React, { memo, useCallback, useMemo } from 'react';
|
|
2
|
-
import { Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
-
import { useScreenReaderStatus } from '@coinbase/cds-mobile/hooks/useScreenReaderStatus';
|
|
4
|
-
import { useCartesianChartContext } from '../ChartProvider';
|
|
5
|
-
import { useScrubberContext } from '../utils';
|
|
6
|
-
import { getPointOnSerializableScale } from '../utils/point';
|
|
7
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
-
const normalizeScrubberAccessibilityStep = function (step, defaultStep) {
|
|
9
|
-
if (defaultStep === void 0) {
|
|
10
|
-
defaultStep = 1;
|
|
11
|
-
}
|
|
12
|
-
const resolvedDefaultStep = Number.isFinite(defaultStep) ? Math.max(1, Math.floor(defaultStep)) : 1;
|
|
13
|
-
if (step === undefined || !Number.isFinite(step)) {
|
|
14
|
-
return resolvedDefaultStep;
|
|
15
|
-
}
|
|
16
|
-
return Math.max(1, Math.floor(step));
|
|
17
|
-
};
|
|
18
|
-
const getScrubberSampledIndices = (dataLength, step) => {
|
|
19
|
-
if (dataLength <= 0) return [];
|
|
20
|
-
const lastIndex = dataLength - 1;
|
|
21
|
-
if (lastIndex === 0) return [0];
|
|
22
|
-
const normalizedStep = Math.max(1, Math.floor(step));
|
|
23
|
-
const sampledIndices = [0];
|
|
24
|
-
for (let dataIndex = normalizedStep; dataIndex < lastIndex; dataIndex += normalizedStep) {
|
|
25
|
-
sampledIndices.push(dataIndex);
|
|
26
|
-
}
|
|
27
|
-
sampledIndices.push(lastIndex);
|
|
28
|
-
return sampledIndices;
|
|
29
|
-
};
|
|
30
|
-
const getCategoryValueForIndex = (index, scale, axis) => {
|
|
31
|
-
if (scale.type === 'band') {
|
|
32
|
-
return index;
|
|
33
|
-
}
|
|
34
|
-
const axisData = axis == null ? void 0 : axis.data;
|
|
35
|
-
if (axisData && Array.isArray(axisData) && typeof axisData[0] === 'number') {
|
|
36
|
-
var _numericData$index;
|
|
37
|
-
const numericData = axisData;
|
|
38
|
-
return (_numericData$index = numericData[index]) != null ? _numericData$index : index;
|
|
39
|
-
}
|
|
40
|
-
return index;
|
|
41
|
-
};
|
|
42
|
-
const getScrubberSegmentWeights = function (sampledIndices, dataLength, categoryScale, categoryAxis, drawingArea, orientation) {
|
|
43
|
-
if (orientation === void 0) {
|
|
44
|
-
orientation = 'horizontal';
|
|
45
|
-
}
|
|
46
|
-
const dimensionSize = orientation === 'horizontal' ? drawingArea.width : drawingArea.height;
|
|
47
|
-
const dimensionStart = orientation === 'horizontal' ? drawingArea.x : drawingArea.y;
|
|
48
|
-
const dimensionEnd = dimensionStart + dimensionSize;
|
|
49
|
-
if (sampledIndices.length === 0 || !categoryScale || !categoryAxis || dimensionSize <= 0) {
|
|
50
|
-
const segmentWeights = sampledIndices.map((index, position) => {
|
|
51
|
-
var _sampledIndices;
|
|
52
|
-
const nextIndex = (_sampledIndices = sampledIndices[position + 1]) != null ? _sampledIndices : dataLength;
|
|
53
|
-
return Math.max(1, nextIndex - index);
|
|
54
|
-
});
|
|
55
|
-
return {
|
|
56
|
-
leading: 0,
|
|
57
|
-
segmentWeights,
|
|
58
|
-
trailing: 0
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
if (categoryScale.type === 'band') {
|
|
62
|
-
const bandScale = categoryScale;
|
|
63
|
-
const segmentWeights = [];
|
|
64
|
-
let leading = 0;
|
|
65
|
-
let trailing = 0;
|
|
66
|
-
for (let i = 0; i < sampledIndices.length; i++) {
|
|
67
|
-
const categoryValue = getCategoryValueForIndex(sampledIndices[i], categoryScale, categoryAxis);
|
|
68
|
-
const posStart = getPointOnSerializableScale(categoryValue, bandScale, 'stepStart');
|
|
69
|
-
const posEnd = getPointOnSerializableScale(categoryValue, bandScale, 'stepEnd');
|
|
70
|
-
segmentWeights.push(Math.max(1, Math.abs(posEnd - posStart)));
|
|
71
|
-
if (i === 0) {
|
|
72
|
-
leading = Math.max(0, Math.min(posStart, posEnd) - dimensionStart);
|
|
73
|
-
}
|
|
74
|
-
if (i === sampledIndices.length - 1) {
|
|
75
|
-
trailing = Math.max(0, dimensionEnd - Math.max(posStart, posEnd));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return {
|
|
79
|
-
leading,
|
|
80
|
-
segmentWeights,
|
|
81
|
-
trailing
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
const segmentWeights = sampledIndices.map((index, position) => {
|
|
85
|
-
const prevIndex = position > 0 ? sampledIndices[position - 1] : -1;
|
|
86
|
-
const categoryValue = getCategoryValueForIndex(index, categoryScale, categoryAxis);
|
|
87
|
-
const posEnd = getPointOnSerializableScale(categoryValue, categoryScale);
|
|
88
|
-
const posStart = prevIndex < 0 ? dimensionStart : getPointOnSerializableScale(getCategoryValueForIndex(prevIndex, categoryScale, categoryAxis), categoryScale);
|
|
89
|
-
return Math.max(1, Math.abs(posEnd - posStart));
|
|
90
|
-
});
|
|
91
|
-
return {
|
|
92
|
-
leading: 0,
|
|
93
|
-
segmentWeights,
|
|
94
|
-
trailing: 0
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
const styles = StyleSheet.create({
|
|
98
|
-
container: {
|
|
99
|
-
position: 'absolute'
|
|
100
|
-
},
|
|
101
|
-
segments: {
|
|
102
|
-
flex: 1
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
export const ScrubberAccessibilityView = /*#__PURE__*/memo(_ref => {
|
|
106
|
-
let {
|
|
107
|
-
accessibilityLabel,
|
|
108
|
-
accessibilityStep
|
|
109
|
-
} = _ref;
|
|
110
|
-
const isScreenReaderEnabled = useScreenReaderStatus();
|
|
111
|
-
const {
|
|
112
|
-
dataLength,
|
|
113
|
-
drawingArea,
|
|
114
|
-
layout,
|
|
115
|
-
getXAxis,
|
|
116
|
-
getYAxis,
|
|
117
|
-
getXSerializableScale,
|
|
118
|
-
getYSerializableScale
|
|
119
|
-
} = useCartesianChartContext();
|
|
120
|
-
const {
|
|
121
|
-
enableScrubbing
|
|
122
|
-
} = useScrubberContext();
|
|
123
|
-
const isHorizontalLayout = layout === 'horizontal';
|
|
124
|
-
const categoryAxis = useMemo(() => isHorizontalLayout ? getYAxis() : getXAxis(), [isHorizontalLayout, getXAxis, getYAxis]);
|
|
125
|
-
const categoryScale = useMemo(() => isHorizontalLayout ? getYSerializableScale() : getXSerializableScale(), [isHorizontalLayout, getXSerializableScale, getYSerializableScale]);
|
|
126
|
-
const resolvedStep = useMemo(() => normalizeScrubberAccessibilityStep(accessibilityStep), [accessibilityStep]);
|
|
127
|
-
const sampledIndices = useMemo(() => getScrubberSampledIndices(dataLength, resolvedStep), [dataLength, resolvedStep]);
|
|
128
|
-
const segmentOrientation = isHorizontalLayout ? 'vertical' : 'horizontal';
|
|
129
|
-
const {
|
|
130
|
-
leading,
|
|
131
|
-
segmentWeights,
|
|
132
|
-
trailing
|
|
133
|
-
} = useMemo(() => getScrubberSegmentWeights(sampledIndices, dataLength, categoryScale, categoryAxis, drawingArea, segmentOrientation), [sampledIndices, dataLength, categoryScale, categoryAxis, drawingArea, segmentOrientation]);
|
|
134
|
-
const sampledSegments = useMemo(() => {
|
|
135
|
-
if (accessibilityLabel === undefined) return [];
|
|
136
|
-
return sampledIndices.map((index, position) => {
|
|
137
|
-
var _segmentWeights$posit;
|
|
138
|
-
const weight = (_segmentWeights$posit = segmentWeights[position]) != null ? _segmentWeights$posit : 1;
|
|
139
|
-
const pointLabel = accessibilityLabel(index);
|
|
140
|
-
return {
|
|
141
|
-
index,
|
|
142
|
-
weight,
|
|
143
|
-
accessibilityLabel: pointLabel || "Data point " + (index + 1)
|
|
144
|
-
};
|
|
145
|
-
});
|
|
146
|
-
}, [accessibilityLabel, sampledIndices, segmentWeights]);
|
|
147
|
-
const getSegmentStyle = useCallback(weight => ({
|
|
148
|
-
flex: weight
|
|
149
|
-
}), []);
|
|
150
|
-
const overlayStyle = useMemo(() => ({
|
|
151
|
-
left: drawingArea.x,
|
|
152
|
-
top: drawingArea.y,
|
|
153
|
-
width: drawingArea.width,
|
|
154
|
-
height: drawingArea.height
|
|
155
|
-
}), [drawingArea.x, drawingArea.y, drawingArea.width, drawingArea.height]);
|
|
156
|
-
const shouldHide = useMemo(() => !isScreenReaderEnabled || !enableScrubbing || !accessibilityLabel || dataLength <= 0 || drawingArea.width <= 0 || drawingArea.height <= 0 || sampledSegments.length === 0, [isScreenReaderEnabled, enableScrubbing, accessibilityLabel, dataLength, drawingArea.width, drawingArea.height, sampledSegments.length]);
|
|
157
|
-
if (shouldHide) return;
|
|
158
|
-
const segmentsFlexDirection = isHorizontalLayout ? 'column' : 'row';
|
|
159
|
-
return /*#__PURE__*/_jsx(View, {
|
|
160
|
-
pointerEvents: "box-none",
|
|
161
|
-
style: [styles.container, overlayStyle],
|
|
162
|
-
children: /*#__PURE__*/_jsxs(View, {
|
|
163
|
-
style: [styles.segments, {
|
|
164
|
-
flexDirection: segmentsFlexDirection
|
|
165
|
-
}],
|
|
166
|
-
children: [leading > 0 && /*#__PURE__*/_jsx(View, {
|
|
167
|
-
style: getSegmentStyle(leading)
|
|
168
|
-
}), sampledSegments.map(segment => /*#__PURE__*/_jsx(Pressable, {
|
|
169
|
-
accessible: true,
|
|
170
|
-
accessibilityLabel: segment.accessibilityLabel,
|
|
171
|
-
style: getSegmentStyle(segment.weight)
|
|
172
|
-
}, segment.index)), trailing > 0 && /*#__PURE__*/_jsx(View, {
|
|
173
|
-
style: getSegmentStyle(trailing)
|
|
174
|
-
})]
|
|
175
|
-
})
|
|
176
|
-
});
|
|
177
|
-
});
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { forwardRef, memo, useCallback, useImperativeHandle, useMemo } from 'react';
|
|
2
|
-
import { useDerivedValue } from 'react-native-reanimated';
|
|
3
|
-
import { useRefMap } from '@coinbase/cds-common/hooks/useRefMap';
|
|
4
|
-
import { useTheme } from '@coinbase/cds-mobile';
|
|
5
|
-
import { useCartesianChartContext } from '../ChartProvider';
|
|
6
|
-
import { evaluateGradientAtValue, getGradientStops, useScrubberContext } from '../utils';
|
|
7
|
-
import { convertToSerializableScale } from '../utils/scale';
|
|
8
|
-
import { DefaultScrubberBeacon } from './DefaultScrubberBeacon';
|
|
9
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
// Helper component to calculate beacon data for a specific series
|
|
11
|
-
const BeaconWithData = /*#__PURE__*/memo(_ref => {
|
|
12
|
-
let {
|
|
13
|
-
seriesId,
|
|
14
|
-
dataIndex,
|
|
15
|
-
dataIndexValue,
|
|
16
|
-
isIdle,
|
|
17
|
-
BeaconComponent,
|
|
18
|
-
idlePulse,
|
|
19
|
-
animate,
|
|
20
|
-
transitions,
|
|
21
|
-
beaconRef,
|
|
22
|
-
stroke
|
|
23
|
-
} = _ref;
|
|
24
|
-
const {
|
|
25
|
-
layout,
|
|
26
|
-
getSeries,
|
|
27
|
-
getSeriesData,
|
|
28
|
-
getXScale,
|
|
29
|
-
getYScale
|
|
30
|
-
} = useCartesianChartContext();
|
|
31
|
-
const theme = useTheme();
|
|
32
|
-
const series = useMemo(() => getSeries(seriesId), [getSeries, seriesId]);
|
|
33
|
-
const sourceData = useMemo(() => getSeriesData(seriesId), [getSeriesData, seriesId]);
|
|
34
|
-
const gradient = series == null ? void 0 : series.gradient;
|
|
35
|
-
const dataY = useDerivedValue(() => {
|
|
36
|
-
if (sourceData && dataIndex.value !== undefined && dataIndex.value >= 0 && dataIndex.value < sourceData.length) {
|
|
37
|
-
const dataValue = sourceData[dataIndex.value];
|
|
38
|
-
if (typeof dataValue === 'number') {
|
|
39
|
-
return dataValue;
|
|
40
|
-
} else if (Array.isArray(dataValue)) {
|
|
41
|
-
const validValues = dataValue.filter(val => val !== null);
|
|
42
|
-
if (validValues.length >= 1) {
|
|
43
|
-
return validValues[validValues.length - 1];
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return 0;
|
|
48
|
-
}, [sourceData, dataIndex]);
|
|
49
|
-
|
|
50
|
-
// Get scales for gradient evaluation
|
|
51
|
-
const gradientScale = useMemo(() => {
|
|
52
|
-
if (!gradient) return undefined;
|
|
53
|
-
const scale = gradient.axis === 'x' ? getXScale(series == null ? void 0 : series.xAxisId) : getYScale(series == null ? void 0 : series.yAxisId);
|
|
54
|
-
if (!scale) return undefined;
|
|
55
|
-
return convertToSerializableScale(scale);
|
|
56
|
-
}, [gradient, getXScale, getYScale, series == null ? void 0 : series.xAxisId, series == null ? void 0 : series.yAxisId]);
|
|
57
|
-
const gradientStops = useMemo(() => {
|
|
58
|
-
if (!gradient || !gradientScale) return undefined;
|
|
59
|
-
const domain = {
|
|
60
|
-
min: gradientScale.domain[0],
|
|
61
|
-
max: gradientScale.domain[1]
|
|
62
|
-
};
|
|
63
|
-
return getGradientStops(gradient.stops, domain);
|
|
64
|
-
}, [gradient, gradientScale]);
|
|
65
|
-
|
|
66
|
-
// Evaluate gradient color on UI thread
|
|
67
|
-
const color = useDerivedValue(() => {
|
|
68
|
-
'worklet';
|
|
69
|
-
|
|
70
|
-
// Evaluate gradient if present
|
|
71
|
-
var _series$color;
|
|
72
|
-
if (gradient && gradientScale && gradientStops) {
|
|
73
|
-
var _gradient$axis;
|
|
74
|
-
const categoryAxisIsX = layout !== 'horizontal';
|
|
75
|
-
const gradientAxis = (_gradient$axis = gradient.axis) != null ? _gradient$axis : 'y';
|
|
76
|
-
const valueForAxis = gradientAxis === 'x' ? categoryAxisIsX ? dataIndexValue.value : dataY.value : categoryAxisIsX ? dataY.value : dataIndexValue.value;
|
|
77
|
-
const evaluatedColor = evaluateGradientAtValue(gradientStops, valueForAxis, gradientScale);
|
|
78
|
-
if (evaluatedColor) {
|
|
79
|
-
return evaluatedColor;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Fallback to series color
|
|
84
|
-
return (_series$color = series == null ? void 0 : series.color) != null ? _series$color : theme.color.fgPrimary;
|
|
85
|
-
}, [gradient, gradientScale, gradientStops, dataIndexValue, dataY, series == null ? void 0 : series.color, theme.color.fgPrimary, layout]);
|
|
86
|
-
const categoryAxisIsX = layout !== 'horizontal';
|
|
87
|
-
return /*#__PURE__*/_jsx(BeaconComponent, {
|
|
88
|
-
ref: beaconRef,
|
|
89
|
-
animate: animate,
|
|
90
|
-
color: color,
|
|
91
|
-
dataX: categoryAxisIsX ? dataIndexValue : dataY,
|
|
92
|
-
dataY: categoryAxisIsX ? dataY : dataIndexValue,
|
|
93
|
-
idlePulse: idlePulse,
|
|
94
|
-
isIdle: isIdle,
|
|
95
|
-
seriesId: seriesId,
|
|
96
|
-
stroke: stroke,
|
|
97
|
-
transitions: transitions
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
export const ScrubberBeaconGroup = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
101
|
-
let {
|
|
102
|
-
seriesIds,
|
|
103
|
-
idlePulse,
|
|
104
|
-
transitions,
|
|
105
|
-
BeaconComponent = DefaultScrubberBeacon,
|
|
106
|
-
stroke
|
|
107
|
-
} = _ref2;
|
|
108
|
-
const ScrubberBeaconRefs = useRefMap();
|
|
109
|
-
const {
|
|
110
|
-
scrubberPosition
|
|
111
|
-
} = useScrubberContext();
|
|
112
|
-
const {
|
|
113
|
-
layout,
|
|
114
|
-
getXAxis,
|
|
115
|
-
getYAxis,
|
|
116
|
-
series,
|
|
117
|
-
dataLength,
|
|
118
|
-
animate
|
|
119
|
-
} = useCartesianChartContext();
|
|
120
|
-
const categoryAxisIsX = useMemo(() => layout !== 'horizontal', [layout]);
|
|
121
|
-
const indexAxis = useMemo(() => categoryAxisIsX ? getXAxis() : getYAxis(), [categoryAxisIsX, getXAxis, getYAxis]);
|
|
122
|
-
|
|
123
|
-
// Expose imperative handle with pulse method
|
|
124
|
-
useImperativeHandle(ref, () => ({
|
|
125
|
-
pulse: () => {
|
|
126
|
-
Object.values(ScrubberBeaconRefs.refs).forEach(beaconRef => {
|
|
127
|
-
beaconRef == null || beaconRef.pulse();
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}));
|
|
131
|
-
const filteredSeries = useMemo(() => {
|
|
132
|
-
var _series$filter;
|
|
133
|
-
return (_series$filter = series == null ? void 0 : series.filter(s => seriesIds.includes(s.id))) != null ? _series$filter : [];
|
|
134
|
-
}, [series, seriesIds]);
|
|
135
|
-
const dataIndex = useDerivedValue(() => {
|
|
136
|
-
var _scrubberPosition$val;
|
|
137
|
-
return (_scrubberPosition$val = scrubberPosition.value) != null ? _scrubberPosition$val : Math.max(0, dataLength - 1);
|
|
138
|
-
}, [scrubberPosition, dataLength]);
|
|
139
|
-
const dataIndexValue = useDerivedValue(() => {
|
|
140
|
-
// Convert index to actual category-axis value if axis has data.
|
|
141
|
-
if (indexAxis != null && indexAxis.data && Array.isArray(indexAxis.data) && indexAxis.data[dataIndex.value] !== undefined) {
|
|
142
|
-
const dataValue = indexAxis.data[dataIndex.value];
|
|
143
|
-
return typeof dataValue === 'string' ? dataIndex.value : dataValue;
|
|
144
|
-
}
|
|
145
|
-
return dataIndex.value;
|
|
146
|
-
}, [indexAxis, dataIndex]);
|
|
147
|
-
const isIdle = useDerivedValue(() => {
|
|
148
|
-
return scrubberPosition.value === undefined;
|
|
149
|
-
}, [scrubberPosition]);
|
|
150
|
-
const createBeaconRef = useCallback(seriesId => {
|
|
151
|
-
return beaconRef => {
|
|
152
|
-
if (beaconRef) {
|
|
153
|
-
ScrubberBeaconRefs.registerRef(seriesId, beaconRef);
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
}, [ScrubberBeaconRefs]);
|
|
157
|
-
return filteredSeries.map(s => /*#__PURE__*/_jsx(BeaconWithData, {
|
|
158
|
-
BeaconComponent: BeaconComponent,
|
|
159
|
-
animate: animate,
|
|
160
|
-
beaconRef: createBeaconRef(s.id),
|
|
161
|
-
dataIndex: dataIndex,
|
|
162
|
-
dataIndexValue: dataIndexValue,
|
|
163
|
-
idlePulse: idlePulse,
|
|
164
|
-
isIdle: isIdle,
|
|
165
|
-
seriesId: s.id,
|
|
166
|
-
stroke: stroke,
|
|
167
|
-
transitions: transitions
|
|
168
|
-
}, s.id));
|
|
169
|
-
}));
|