@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,159 +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
|
-
/**
|
|
3
|
-
* Simplified context bridge utilities for React Native.
|
|
4
|
-
* Adapted from its-fine to enable context sharing across React renderers
|
|
5
|
-
* https://github.com/pmndrs/its-fine/blob/598b81f02778c22ed21121c2b1a786bdefb14e23/src/index.tsx
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import * as React from 'react';
|
|
9
|
-
import { ThemeContext } from '@coinbase/cds-mobile/system/ThemeProvider';
|
|
10
|
-
import { ScrubberContext } from './utils/context';
|
|
11
|
-
import { CartesianChartContext } from './ChartProvider';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Whitelist of contexts that should be bridged to the Skia canvas.
|
|
15
|
-
* Only these contexts will be made available inside the chart's Skia tree.
|
|
16
|
-
* This improves performance by avoiding the overhead of rendering every bridged context.
|
|
17
|
-
*/
|
|
18
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
-
const BRIDGED_CONTEXTS = [ThemeContext, CartesianChartContext, ScrubberContext];
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Represents a react-internal tree node.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Represents a tree node selector for traversal.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Traverses up or down a React tree, return `true` to stop and select a node.
|
|
31
|
-
*/
|
|
32
|
-
function traverseTreeNode(node, ascending, selector) {
|
|
33
|
-
if (!node) return;
|
|
34
|
-
if (selector(node) === true) return node;
|
|
35
|
-
let child = ascending ? node.return : node.child;
|
|
36
|
-
while (child) {
|
|
37
|
-
const match = traverseTreeNode(child, ascending, selector);
|
|
38
|
-
if (match) return match;
|
|
39
|
-
child = ascending ? null : child.sibling;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Wraps context to hide React development warnings about using contexts between renderers.
|
|
45
|
-
*/
|
|
46
|
-
function wrapContext(context) {
|
|
47
|
-
try {
|
|
48
|
-
return Object.defineProperties(context, {
|
|
49
|
-
_currentRenderer: {
|
|
50
|
-
get() {
|
|
51
|
-
return null;
|
|
52
|
-
},
|
|
53
|
-
set() {}
|
|
54
|
-
},
|
|
55
|
-
_currentRenderer2: {
|
|
56
|
-
get() {
|
|
57
|
-
return null;
|
|
58
|
-
},
|
|
59
|
-
set() {}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
} catch (_) {
|
|
63
|
-
return context;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// In development, React will warn about using contexts between renderers.
|
|
68
|
-
// Suppress the warning because our context bridge fixes this issue
|
|
69
|
-
const error = console.error;
|
|
70
|
-
console.error = function () {
|
|
71
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
72
|
-
args[_key] = arguments[_key];
|
|
73
|
-
}
|
|
74
|
-
const message = args.join('');
|
|
75
|
-
if (message != null && message.startsWith('Warning:') && message.includes('useContext')) {
|
|
76
|
-
console.error = error;
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
return error.apply(this, args);
|
|
80
|
-
};
|
|
81
|
-
const TreeNodeContext = wrapContext(/*#__PURE__*/React.createContext(null));
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* A react-internal tree node provider that binds React children to the React tree for chart context bridging.
|
|
85
|
-
*/
|
|
86
|
-
export class ChartBridgeProvider extends React.Component {
|
|
87
|
-
render() {
|
|
88
|
-
return /*#__PURE__*/_jsx(TreeNodeContext.Provider, {
|
|
89
|
-
value: this._reactInternals,
|
|
90
|
-
children: this.props.children
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Returns the current react-internal tree node.
|
|
97
|
-
*/
|
|
98
|
-
function useTreeNode() {
|
|
99
|
-
const root = React.useContext(TreeNodeContext);
|
|
100
|
-
if (root === null) throw new Error('useTreeNode must be called within a <ChartBridgeProvider />!');
|
|
101
|
-
const id = React.useId();
|
|
102
|
-
const treeNode = React.useMemo(() => {
|
|
103
|
-
for (const maybeNode of [root, root == null ? void 0 : root.alternate]) {
|
|
104
|
-
if (!maybeNode) continue;
|
|
105
|
-
const node = traverseTreeNode(maybeNode, false, node => {
|
|
106
|
-
let state = node.memoizedState;
|
|
107
|
-
while (state) {
|
|
108
|
-
if (state.memoizedState === id) return true;
|
|
109
|
-
state = state.next;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
if (node) return node;
|
|
113
|
-
}
|
|
114
|
-
}, [root, id]);
|
|
115
|
-
return treeNode;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Returns a map of whitelisted contexts and their values.
|
|
119
|
-
*/
|
|
120
|
-
function useContextMap() {
|
|
121
|
-
const treeNode = useTreeNode();
|
|
122
|
-
const [contextMap] = React.useState(() => new Map());
|
|
123
|
-
|
|
124
|
-
// Collect live context
|
|
125
|
-
contextMap.clear();
|
|
126
|
-
let node = treeNode;
|
|
127
|
-
while (node) {
|
|
128
|
-
if (node.type && typeof node.type === 'object') {
|
|
129
|
-
// https://github.com/facebook/react/pull/28226
|
|
130
|
-
const enableRenderableContext = node.type._context === undefined && node.type.Provider === node.type;
|
|
131
|
-
const context = enableRenderableContext ? node.type : node.type._context;
|
|
132
|
-
if (context && context !== TreeNodeContext && BRIDGED_CONTEXTS.includes(context) && !contextMap.has(context)) {
|
|
133
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
134
|
-
contextMap.set(context, React.useContext(wrapContext(context)));
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
node = node.return;
|
|
138
|
-
}
|
|
139
|
-
return contextMap;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Represents a chart context bridge provider component.
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Returns a ChartContextBridge of live context providers to pierce Context across renderers.
|
|
148
|
-
* Pass ChartContextBridge as a component to a secondary renderer (e.g., Skia Canvas) to enable context-sharing in charts.
|
|
149
|
-
*/
|
|
150
|
-
export function useChartContextBridge() {
|
|
151
|
-
const contextMap = useContextMap();
|
|
152
|
-
|
|
153
|
-
// Flatten context and their memoized values into a `ChartContextBridge` provider
|
|
154
|
-
return React.useMemo(() => Array.from(contextMap.keys()).reduce((Prev, context) => props => /*#__PURE__*/_jsx(Prev, {
|
|
155
|
-
children: /*#__PURE__*/_jsx(context.Provider, _extends({}, props, {
|
|
156
|
-
value: contextMap.get(context)
|
|
157
|
-
}))
|
|
158
|
-
}), props => /*#__PURE__*/_jsx(ChartBridgeProvider, _extends({}, props))), [contextMap]);
|
|
159
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
export const CartesianChartContext = /*#__PURE__*/createContext(undefined);
|
|
3
|
-
export const useCartesianChartContext = () => {
|
|
4
|
-
const context = useContext(CartesianChartContext);
|
|
5
|
-
if (!context) {
|
|
6
|
-
throw new Error('useCartesianChartContext must be used within a CartesianChart component. See https://cds.coinbase.com/components/charts/CartesianChart.');
|
|
7
|
-
}
|
|
8
|
-
return context;
|
|
9
|
-
};
|
|
10
|
-
export const CartesianChartProvider = CartesianChartContext.Provider;
|
package/esm/chart/Path.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
const _excluded = ["d", "initialPath", "fill", "fillOpacity", "stroke", "strokeOpacity", "strokeWidth", "strokeCap", "strokeJoin", "children", "transitions"],
|
|
2
|
-
_excluded2 = ["animate", "clipRect", "clipPath", "clipOffset", "d", "initialPath", "fill", "fillOpacity", "stroke", "strokeOpacity", "strokeWidth", "strokeCap", "strokeJoin", "children", "transitions", "transition"];
|
|
3
|
-
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); }
|
|
4
|
-
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; }
|
|
5
|
-
import { memo, useEffect, useMemo, useRef } from 'react';
|
|
6
|
-
import { useDerivedValue, useSharedValue } from 'react-native-reanimated';
|
|
7
|
-
import { Group, Path as SkiaPath, Skia, usePathInterpolation } from '@shopify/react-native-skia';
|
|
8
|
-
import { defaultPathEnterTransition } from './utils/path';
|
|
9
|
-
import { buildTransition, defaultTransition, getTransition, usePathTransition } from './utils/transition';
|
|
10
|
-
import { useCartesianChartContext } from './ChartProvider';
|
|
11
|
-
import { unwrapAnimatedValue } from './utils';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Duration in milliseconds for path enter transition.
|
|
15
|
-
*/
|
|
16
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
export const pathEnterTransitionDuration = 500;
|
|
18
|
-
const AnimatedPath = /*#__PURE__*/memo(_ref => {
|
|
19
|
-
let {
|
|
20
|
-
d = '',
|
|
21
|
-
initialPath,
|
|
22
|
-
fill,
|
|
23
|
-
fillOpacity,
|
|
24
|
-
stroke,
|
|
25
|
-
strokeOpacity,
|
|
26
|
-
strokeWidth,
|
|
27
|
-
strokeCap,
|
|
28
|
-
strokeJoin,
|
|
29
|
-
children,
|
|
30
|
-
transitions
|
|
31
|
-
} = _ref,
|
|
32
|
-
pathProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
33
|
-
const isDAnimated = typeof d !== 'string';
|
|
34
|
-
const animatedPath = usePathTransition({
|
|
35
|
-
currentPath: isDAnimated ? '' : d,
|
|
36
|
-
initialPath,
|
|
37
|
-
transitions
|
|
38
|
-
});
|
|
39
|
-
const isFilled = fill !== undefined && fill !== 'none';
|
|
40
|
-
const isStroked = stroke !== undefined && stroke !== 'none';
|
|
41
|
-
const activePath = useDerivedValue(() => {
|
|
42
|
-
if (isDAnimated) {
|
|
43
|
-
var _d$value;
|
|
44
|
-
return (_d$value = d.value) != null ? _d$value : Skia.Path.Make();
|
|
45
|
-
}
|
|
46
|
-
return animatedPath.value;
|
|
47
|
-
});
|
|
48
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
49
|
-
children: [isFilled && /*#__PURE__*/_jsx(SkiaPath, _extends({
|
|
50
|
-
color: fill,
|
|
51
|
-
opacity: fillOpacity,
|
|
52
|
-
path: activePath,
|
|
53
|
-
style: "fill"
|
|
54
|
-
}, pathProps, {
|
|
55
|
-
children: children
|
|
56
|
-
})), isStroked && /*#__PURE__*/_jsx(SkiaPath, _extends({
|
|
57
|
-
color: stroke,
|
|
58
|
-
opacity: strokeOpacity,
|
|
59
|
-
path: activePath,
|
|
60
|
-
strokeCap: strokeCap,
|
|
61
|
-
strokeJoin: strokeJoin,
|
|
62
|
-
strokeWidth: strokeWidth,
|
|
63
|
-
style: "stroke"
|
|
64
|
-
}, pathProps, {
|
|
65
|
-
children: children
|
|
66
|
-
}))]
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
export const Path = /*#__PURE__*/memo(props => {
|
|
70
|
-
const {
|
|
71
|
-
animate: animateProp,
|
|
72
|
-
clipRect,
|
|
73
|
-
clipPath: clipPathProp,
|
|
74
|
-
clipOffset = 0,
|
|
75
|
-
d = '',
|
|
76
|
-
initialPath,
|
|
77
|
-
fill,
|
|
78
|
-
fillOpacity,
|
|
79
|
-
stroke,
|
|
80
|
-
strokeOpacity,
|
|
81
|
-
strokeWidth,
|
|
82
|
-
strokeCap,
|
|
83
|
-
strokeJoin,
|
|
84
|
-
children,
|
|
85
|
-
transitions,
|
|
86
|
-
transition
|
|
87
|
-
} = props,
|
|
88
|
-
pathProps = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
89
|
-
const context = useCartesianChartContext();
|
|
90
|
-
const rect = clipRect != null ? clipRect : context.drawingArea;
|
|
91
|
-
const animate = animateProp != null ? animateProp : context.animate;
|
|
92
|
-
const isReady = !!context.getXScale();
|
|
93
|
-
const enterTransition = useMemo(() => getTransition(transitions == null ? void 0 : transitions.enter, animate, defaultPathEnterTransition), [animate, transitions == null ? void 0 : transitions.enter]);
|
|
94
|
-
const updateTransition = useMemo(() => getTransition((transitions == null ? void 0 : transitions.update) !== undefined ? transitions.update : transition, animate, defaultTransition), [animate, transitions == null ? void 0 : transitions.update, transition]);
|
|
95
|
-
const enterOpacityTransition = useMemo(() => {
|
|
96
|
-
if (!animate) return null;
|
|
97
|
-
return transitions == null ? void 0 : transitions.enterOpacity;
|
|
98
|
-
}, [animate, transitions == null ? void 0 : transitions.enterOpacity]);
|
|
99
|
-
const animateEnterOpacity = Boolean(enterOpacityTransition);
|
|
100
|
-
const enterOpacity = useSharedValue(animateEnterOpacity ? 0 : 1);
|
|
101
|
-
const hasAnimatedEnterOpacity = useRef(false);
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
if (hasAnimatedEnterOpacity.current) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (!animateEnterOpacity) {
|
|
107
|
-
hasAnimatedEnterOpacity.current = true;
|
|
108
|
-
enterOpacity.value = 1;
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (!isReady) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (enterOpacityTransition === undefined || enterOpacityTransition === null) {
|
|
115
|
-
enterOpacity.value = 1;
|
|
116
|
-
hasAnimatedEnterOpacity.current = true;
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
hasAnimatedEnterOpacity.current = true;
|
|
120
|
-
enterOpacity.value = buildTransition(1, enterOpacityTransition);
|
|
121
|
-
}, [animateEnterOpacity, isReady, enterOpacityTransition, enterOpacity]);
|
|
122
|
-
const animateClip = animate && enterTransition !== null;
|
|
123
|
-
|
|
124
|
-
// The clip offset provides extra padding to prevent path from being cut off
|
|
125
|
-
// Area charts typically use offset=0 for exact clipping, while lines use offset=2 for breathing room
|
|
126
|
-
const totalOffset = clipOffset * 2; // Applied on both sides
|
|
127
|
-
|
|
128
|
-
// Animation progress for clip path reveal
|
|
129
|
-
const clipProgress = useSharedValue(animateClip ? 0 : 1);
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
if (animateClip && isReady) {
|
|
132
|
-
clipProgress.value = buildTransition(1, enterTransition);
|
|
133
|
-
}
|
|
134
|
-
}, [animateClip, isReady, clipProgress, enterTransition]);
|
|
135
|
-
|
|
136
|
-
// Create initial and target clip paths for animation
|
|
137
|
-
const {
|
|
138
|
-
initialClipPath,
|
|
139
|
-
targetClipPath
|
|
140
|
-
} = useMemo(() => {
|
|
141
|
-
if (!rect) return {
|
|
142
|
-
initialClipPath: null,
|
|
143
|
-
targetClipPath: null
|
|
144
|
-
};
|
|
145
|
-
const categoryAxisIsX = context.layout !== 'horizontal';
|
|
146
|
-
const fullWidth = rect.width + totalOffset;
|
|
147
|
-
const fullHeight = rect.height + totalOffset;
|
|
148
|
-
|
|
149
|
-
// Initial clip path starts collapsed on the category axis.
|
|
150
|
-
const initial = Skia.Path.Make();
|
|
151
|
-
initial.addRect({
|
|
152
|
-
x: rect.x - clipOffset,
|
|
153
|
-
y: rect.y - clipOffset,
|
|
154
|
-
width: categoryAxisIsX ? 0 : fullWidth,
|
|
155
|
-
height: categoryAxisIsX ? fullHeight : 0
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
// Target clip path is fully expanded.
|
|
159
|
-
const target = Skia.Path.Make();
|
|
160
|
-
target.addRect({
|
|
161
|
-
x: rect.x - clipOffset,
|
|
162
|
-
y: rect.y - clipOffset,
|
|
163
|
-
width: fullWidth,
|
|
164
|
-
height: fullHeight
|
|
165
|
-
});
|
|
166
|
-
return {
|
|
167
|
-
initialClipPath: initial,
|
|
168
|
-
targetClipPath: target
|
|
169
|
-
};
|
|
170
|
-
}, [rect, clipOffset, totalOffset, context.layout]);
|
|
171
|
-
|
|
172
|
-
// Use usePathInterpolation for animated clip path
|
|
173
|
-
const animatedClipPath = usePathInterpolation(clipProgress, [0, 1], animateClip && initialClipPath && targetClipPath ? [initialClipPath, targetClipPath] : targetClipPath ? [targetClipPath, targetClipPath] : [Skia.Path.Make(), Skia.Path.Make()]);
|
|
174
|
-
|
|
175
|
-
// Resolve the final clip path:
|
|
176
|
-
// 1. If clipPath prop was explicitly provided, use it (even if null = no clipping)
|
|
177
|
-
// 2. If animating, use the interpolated clip path
|
|
178
|
-
// 3. Otherwise, use static target clip path
|
|
179
|
-
const resolvedClipPath = useMemo(() => {
|
|
180
|
-
// If clipPath was explicitly provided (null or string), use it directly
|
|
181
|
-
if (clipPathProp !== undefined) {
|
|
182
|
-
return clipPathProp;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// If not animating or paths are null, return target clip path
|
|
186
|
-
if (!animateClip || !targetClipPath) {
|
|
187
|
-
return targetClipPath;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Return undefined here since we'll use animatedClipPath directly
|
|
191
|
-
return undefined;
|
|
192
|
-
}, [clipPathProp, animateClip, targetClipPath]);
|
|
193
|
-
|
|
194
|
-
// Convert SVG path string to SkPath for static rendering
|
|
195
|
-
const staticPath = useDerivedValue(() => {
|
|
196
|
-
var _Skia$Path$MakeFromSV;
|
|
197
|
-
const dValue = unwrapAnimatedValue(d);
|
|
198
|
-
if (!dValue) return Skia.Path.Make();
|
|
199
|
-
return (_Skia$Path$MakeFromSV = Skia.Path.MakeFromSVGString(dValue)) != null ? _Skia$Path$MakeFromSV : Skia.Path.Make();
|
|
200
|
-
}, [d]);
|
|
201
|
-
const isFilled = fill !== undefined && fill !== 'none';
|
|
202
|
-
const isStroked = stroke !== undefined && stroke !== 'none';
|
|
203
|
-
const content = !animate ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
204
|
-
children: [isFilled && /*#__PURE__*/_jsx(SkiaPath, _extends({
|
|
205
|
-
color: fill,
|
|
206
|
-
opacity: fillOpacity,
|
|
207
|
-
path: staticPath,
|
|
208
|
-
style: "fill"
|
|
209
|
-
}, pathProps, {
|
|
210
|
-
children: children
|
|
211
|
-
})), isStroked && /*#__PURE__*/_jsx(SkiaPath, _extends({
|
|
212
|
-
color: stroke,
|
|
213
|
-
opacity: strokeOpacity,
|
|
214
|
-
path: staticPath,
|
|
215
|
-
strokeCap: strokeCap,
|
|
216
|
-
strokeJoin: strokeJoin,
|
|
217
|
-
strokeWidth: strokeWidth,
|
|
218
|
-
style: "stroke"
|
|
219
|
-
}, pathProps, {
|
|
220
|
-
children: children
|
|
221
|
-
}))]
|
|
222
|
-
}) : /*#__PURE__*/_jsx(AnimatedPath, {
|
|
223
|
-
d: d,
|
|
224
|
-
fill: fill,
|
|
225
|
-
fillOpacity: fillOpacity,
|
|
226
|
-
initialPath: initialPath,
|
|
227
|
-
stroke: stroke,
|
|
228
|
-
strokeCap: strokeCap,
|
|
229
|
-
strokeJoin: strokeJoin,
|
|
230
|
-
strokeOpacity: strokeOpacity,
|
|
231
|
-
strokeWidth: strokeWidth,
|
|
232
|
-
transitions: {
|
|
233
|
-
enter: enterTransition,
|
|
234
|
-
enterOpacity: enterOpacityTransition,
|
|
235
|
-
update: updateTransition
|
|
236
|
-
},
|
|
237
|
-
children: children
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// Determine which clip path to use
|
|
241
|
-
const finalClipPath = animateClip && resolvedClipPath === undefined ? animatedClipPath : resolvedClipPath;
|
|
242
|
-
|
|
243
|
-
// If finalClipPath is null, render without clipping
|
|
244
|
-
if (finalClipPath === null) {
|
|
245
|
-
return /*#__PURE__*/_jsx(Group, {
|
|
246
|
-
opacity: animateEnterOpacity ? enterOpacity : undefined,
|
|
247
|
-
children: content
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
return /*#__PURE__*/_jsx(Group, {
|
|
251
|
-
clip: finalClipPath,
|
|
252
|
-
opacity: animateEnterOpacity ? enterOpacity : undefined,
|
|
253
|
-
children: content
|
|
254
|
-
});
|
|
255
|
-
});
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
const _excluded = ["color", "label", "font", "hideDot", "style"],
|
|
2
|
-
_excluded2 = ["background", "activeBackground", "activeColor", "width", "justifyContent", "TabComponent", "TabsActiveIndicatorComponent"];
|
|
3
|
-
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); }
|
|
4
|
-
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; }
|
|
5
|
-
import React, { forwardRef, memo, useMemo } from 'react';
|
|
6
|
-
import { StyleSheet, View } from 'react-native';
|
|
7
|
-
import Animated, { useAnimatedStyle, useSharedValue, withSpring } from 'react-native-reanimated';
|
|
8
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
9
|
-
import { SegmentedTabs } from '@coinbase/cds-mobile/tabs';
|
|
10
|
-
import { SegmentedTab } from '@coinbase/cds-mobile/tabs/SegmentedTab';
|
|
11
|
-
import { tabsSpringConfig } from '@coinbase/cds-mobile/tabs/Tabs';
|
|
12
|
-
import { Text } from '@coinbase/cds-mobile/typography';
|
|
13
|
-
|
|
14
|
-
// Animated active indicator to support smooth transition of background color
|
|
15
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
export const PeriodSelectorActiveIndicator = _ref => {
|
|
17
|
-
let {
|
|
18
|
-
activeTabRect,
|
|
19
|
-
background = 'bgPrimaryWash',
|
|
20
|
-
position = 'absolute',
|
|
21
|
-
borderRadius = 1000
|
|
22
|
-
} = _ref;
|
|
23
|
-
const theme = useTheme();
|
|
24
|
-
const {
|
|
25
|
-
width,
|
|
26
|
-
height,
|
|
27
|
-
x,
|
|
28
|
-
y
|
|
29
|
-
} = activeTabRect;
|
|
30
|
-
|
|
31
|
-
// Get the target background color
|
|
32
|
-
const backgroundColorKey = background;
|
|
33
|
-
const targetColor = theme.color[backgroundColorKey] || background;
|
|
34
|
-
|
|
35
|
-
// Track previous values for first render detection
|
|
36
|
-
const previousActiveTabRect = React.useRef(activeTabRect);
|
|
37
|
-
const previousColor = React.useRef(targetColor);
|
|
38
|
-
|
|
39
|
-
// Combined animated value for position, size, and color
|
|
40
|
-
const newAnimatedValues = {
|
|
41
|
-
x,
|
|
42
|
-
y,
|
|
43
|
-
width,
|
|
44
|
-
backgroundColor: targetColor
|
|
45
|
-
};
|
|
46
|
-
const animatedValues = useSharedValue(newAnimatedValues);
|
|
47
|
-
const isFirstRenderWithWidth = previousActiveTabRect.current.width === 0 && activeTabRect.width > 0;
|
|
48
|
-
if (previousActiveTabRect.current !== activeTabRect || previousColor.current !== targetColor) {
|
|
49
|
-
previousActiveTabRect.current = activeTabRect;
|
|
50
|
-
previousColor.current = targetColor;
|
|
51
|
-
animatedValues.value = isFirstRenderWithWidth ? newAnimatedValues : withSpring(newAnimatedValues, tabsSpringConfig);
|
|
52
|
-
}
|
|
53
|
-
const animatedStyles = useAnimatedStyle(() => ({
|
|
54
|
-
transform: [{
|
|
55
|
-
translateX: animatedValues.value.x
|
|
56
|
-
}, {
|
|
57
|
-
translateY: animatedValues.value.y
|
|
58
|
-
}],
|
|
59
|
-
width: animatedValues.value.width,
|
|
60
|
-
backgroundColor: animatedValues.value.backgroundColor
|
|
61
|
-
}), [animatedValues]);
|
|
62
|
-
if (!width) return;
|
|
63
|
-
return /*#__PURE__*/_jsx(Animated.View, {
|
|
64
|
-
style: [{
|
|
65
|
-
position: position,
|
|
66
|
-
height,
|
|
67
|
-
borderRadius
|
|
68
|
-
}, animatedStyles],
|
|
69
|
-
testID: "period-selector-active-indicator"
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
const styles = StyleSheet.create({
|
|
73
|
-
liveContainer: {
|
|
74
|
-
flexDirection: 'row',
|
|
75
|
-
alignItems: 'center'
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
export const LiveTabLabel = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
79
|
-
let {
|
|
80
|
-
color = 'fgNegative',
|
|
81
|
-
label = 'LIVE',
|
|
82
|
-
font = 'label1',
|
|
83
|
-
hideDot,
|
|
84
|
-
style
|
|
85
|
-
} = _ref2,
|
|
86
|
-
props = _objectWithoutPropertiesLoose(_ref2, _excluded);
|
|
87
|
-
const theme = useTheme();
|
|
88
|
-
const colorKey = color;
|
|
89
|
-
const textColor = theme.color[colorKey] || color;
|
|
90
|
-
const dotStyle = useMemo(() => ({
|
|
91
|
-
width: theme.space[1],
|
|
92
|
-
height: theme.space[1],
|
|
93
|
-
borderRadius: 1000,
|
|
94
|
-
marginRight: theme.space[0.75],
|
|
95
|
-
backgroundColor: textColor
|
|
96
|
-
}), [theme.space, textColor]);
|
|
97
|
-
return /*#__PURE__*/_jsxs(View, {
|
|
98
|
-
ref: ref,
|
|
99
|
-
style: [styles.liveContainer, style],
|
|
100
|
-
children: [!hideDot && /*#__PURE__*/_jsx(View, {
|
|
101
|
-
style: dotStyle
|
|
102
|
-
}), /*#__PURE__*/_jsx(Text, _extends({
|
|
103
|
-
color: color,
|
|
104
|
-
font: font
|
|
105
|
-
}, props, {
|
|
106
|
-
children: label
|
|
107
|
-
}))]
|
|
108
|
-
});
|
|
109
|
-
}));
|
|
110
|
-
const PeriodSelectorTab = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/_jsx(SegmentedTab, _extends({
|
|
111
|
-
ref: ref,
|
|
112
|
-
font: "label1"
|
|
113
|
-
}, props))));
|
|
114
|
-
/**
|
|
115
|
-
* PeriodSelector is a specialized version of SegmentedTabs optimized for chart period selection.
|
|
116
|
-
* It provides transparent background, primary wash active state, and full-width layout by default.
|
|
117
|
-
*/
|
|
118
|
-
export const PeriodSelector = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref3, ref) => {
|
|
119
|
-
let {
|
|
120
|
-
background = 'transparent',
|
|
121
|
-
activeBackground = 'bgPrimaryWash',
|
|
122
|
-
activeColor = 'fgPrimary',
|
|
123
|
-
width = '100%',
|
|
124
|
-
justifyContent = 'space-between',
|
|
125
|
-
TabComponent = PeriodSelectorTab,
|
|
126
|
-
TabsActiveIndicatorComponent = PeriodSelectorActiveIndicator
|
|
127
|
-
} = _ref3,
|
|
128
|
-
props = _objectWithoutPropertiesLoose(_ref3, _excluded2);
|
|
129
|
-
return /*#__PURE__*/_jsx(SegmentedTabs, _extends({
|
|
130
|
-
ref: ref,
|
|
131
|
-
TabComponent: TabComponent,
|
|
132
|
-
TabsActiveIndicatorComponent: TabsActiveIndicatorComponent,
|
|
133
|
-
activeBackground: activeBackground,
|
|
134
|
-
activeColor: activeColor,
|
|
135
|
-
background: background,
|
|
136
|
-
justifyContent: justifyContent,
|
|
137
|
-
width: width
|
|
138
|
-
}, props));
|
|
139
|
-
}));
|