@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,47 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { useWindowDimensions } from 'react-native';
|
|
3
|
-
import { borderWidth, chartCompactHeight, chartHeight as chartHeightToken } from '@coinbase/cds-common/tokens/sparkline';
|
|
4
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
5
|
-
import { useSparklineInteractiveContext } from './SparklineInteractiveProvider';
|
|
6
|
-
export function useSparklineInteractiveConstants(_ref) {
|
|
7
|
-
let {
|
|
8
|
-
compact = false
|
|
9
|
-
} = _ref;
|
|
10
|
-
const theme = useTheme();
|
|
11
|
-
const {
|
|
12
|
-
width: screenWidth
|
|
13
|
-
} = useWindowDimensions();
|
|
14
|
-
const {
|
|
15
|
-
gutter
|
|
16
|
-
} = useSparklineInteractiveContext();
|
|
17
|
-
return useMemo(() => {
|
|
18
|
-
const chartHorizontalGutter = theme.space[gutter];
|
|
19
|
-
const chartWidth = screenWidth - chartHorizontalGutter * 2;
|
|
20
|
-
const chartHeight = compact ? chartCompactHeight : chartHeightToken;
|
|
21
|
-
const chartMarkerSize = theme.space[2];
|
|
22
|
-
const SparklineInteractiveMinMaxLabelHeight = theme.space[3];
|
|
23
|
-
const SparklineInteractiveMinMaxVerticalGutter = theme.space[0.5];
|
|
24
|
-
const chartVerticalLineWidth = borderWidth;
|
|
25
|
-
const xRange = [borderWidth, chartWidth - borderWidth];
|
|
26
|
-
const yRange = [chartHeight - borderWidth, borderWidth];
|
|
27
|
-
const startX = 0;
|
|
28
|
-
const endX = xRange[1];
|
|
29
|
-
return {
|
|
30
|
-
chartHorizontalGutter,
|
|
31
|
-
chartWidth,
|
|
32
|
-
chartHeight,
|
|
33
|
-
chartDimensionStyles: {
|
|
34
|
-
height: chartHeight,
|
|
35
|
-
width: chartWidth
|
|
36
|
-
},
|
|
37
|
-
chartMarkerSize,
|
|
38
|
-
SparklineInteractiveMinMaxLabelHeight,
|
|
39
|
-
SparklineInteractiveMinMaxVerticalGutter,
|
|
40
|
-
chartVerticalLineWidth,
|
|
41
|
-
xRange,
|
|
42
|
-
yRange,
|
|
43
|
-
startX,
|
|
44
|
-
endX
|
|
45
|
-
};
|
|
46
|
-
}, [compact, gutter, screenWidth, theme.space]);
|
|
47
|
-
}
|
|
@@ -1,34 +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 { useMemo } from 'react';
|
|
3
|
-
import { borderWidth, lineDashArray, lineOpacity } from '@coinbase/cds-common/tokens/sparkline';
|
|
4
|
-
import { useTheme } from '@coinbase/cds-mobile/hooks/useTheme';
|
|
5
|
-
const staticLineProps = {
|
|
6
|
-
x1: 0,
|
|
7
|
-
x2: 0,
|
|
8
|
-
y1: 0,
|
|
9
|
-
y2: 0,
|
|
10
|
-
strokeDasharray: lineDashArray
|
|
11
|
-
};
|
|
12
|
-
export function useSparklineInteractiveLineStyles() {
|
|
13
|
-
const theme = useTheme();
|
|
14
|
-
return useMemo(() => {
|
|
15
|
-
const chartLineSize = theme.space[0.5];
|
|
16
|
-
return {
|
|
17
|
-
dotStyle: [{
|
|
18
|
-
backgroundColor: theme.color.fgMuted
|
|
19
|
-
}, {
|
|
20
|
-
position: 'absolute',
|
|
21
|
-
top: -chartLineSize / 2,
|
|
22
|
-
left: -chartLineSize / 2,
|
|
23
|
-
height: chartLineSize,
|
|
24
|
-
width: chartLineSize,
|
|
25
|
-
borderRadius: chartLineSize / 2,
|
|
26
|
-
opacity: lineOpacity
|
|
27
|
-
}],
|
|
28
|
-
lineProps: _extends({}, staticLineProps, {
|
|
29
|
-
strokeWidth: borderWidth,
|
|
30
|
-
stroke: theme.color.fgMuted
|
|
31
|
-
})
|
|
32
|
-
};
|
|
33
|
-
}, [theme.color.fgMuted, theme.space]);
|
|
34
|
-
}
|
|
@@ -1,233 +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, useImperativeHandle, useRef } from 'react';
|
|
3
|
-
import { TextInput, View } from 'react-native';
|
|
4
|
-
import { subheadIconSignMap } from '@coinbase/cds-common/tokens/sparkline';
|
|
5
|
-
import { HStack, VStack } from '@coinbase/cds-mobile/layout';
|
|
6
|
-
import { useSparklineInteractiveHeaderStyles } from './useSparklineInteractiveHeaderStyles';
|
|
7
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
|
-
export * from '@coinbase/cds-common/types/SparklineInteractiveHeaderBaseProps';
|
|
9
|
-
export const interpolateSubHeadText = subHead => {
|
|
10
|
-
if (subHead.priceChange && subHead.percent) {
|
|
11
|
-
return subHead.priceChange + " (" + subHead.percent + ")";
|
|
12
|
-
}
|
|
13
|
-
if (subHead.priceChange) {
|
|
14
|
-
return subHead.priceChange;
|
|
15
|
-
}
|
|
16
|
-
return '';
|
|
17
|
-
};
|
|
18
|
-
const Trailing = _ref => {
|
|
19
|
-
let {
|
|
20
|
-
children
|
|
21
|
-
} = _ref;
|
|
22
|
-
if (children) {
|
|
23
|
-
return /*#__PURE__*/_jsx(VStack, {
|
|
24
|
-
alignItems: "center",
|
|
25
|
-
flexShrink: 0,
|
|
26
|
-
justifyContent: "center",
|
|
27
|
-
paddingStart: 2,
|
|
28
|
-
children: children
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
};
|
|
33
|
-
const SparklineInteractiveHeaderStable = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref2, forwardedRef) => {
|
|
34
|
-
let {
|
|
35
|
-
defaultLabel,
|
|
36
|
-
defaultTitle,
|
|
37
|
-
defaultSubHead,
|
|
38
|
-
testID,
|
|
39
|
-
trailing,
|
|
40
|
-
labelNode
|
|
41
|
-
} = _ref2;
|
|
42
|
-
const labelRef = useRef(null);
|
|
43
|
-
const titleRef = useRef(null);
|
|
44
|
-
const subHeadRef = useRef(null);
|
|
45
|
-
const subHeadIconRef = useRef(null);
|
|
46
|
-
const subHeadAccessoryRef = useRef(null);
|
|
47
|
-
const valuesRef = useRef({
|
|
48
|
-
title: defaultTitle,
|
|
49
|
-
label: defaultLabel,
|
|
50
|
-
subHead: defaultSubHead
|
|
51
|
-
});
|
|
52
|
-
const styles = useSparklineInteractiveHeaderStyles();
|
|
53
|
-
const updateLabel = useCallback(label => {
|
|
54
|
-
var _valuesRef$current;
|
|
55
|
-
const prevLabel = (_valuesRef$current = valuesRef.current) == null ? void 0 : _valuesRef$current.label;
|
|
56
|
-
if (prevLabel !== label) {
|
|
57
|
-
var _labelRef$current;
|
|
58
|
-
// BAD: We only disabled this lint rule to enable eslint upgrade after this component was implemented. These apis should never be used.
|
|
59
|
-
// Usage in this component are known making this a high risk component. Contact team for more information.
|
|
60
|
-
|
|
61
|
-
(_labelRef$current = labelRef.current) == null || _labelRef$current.setNativeProps({
|
|
62
|
-
text: label
|
|
63
|
-
});
|
|
64
|
-
valuesRef.current = _extends({}, valuesRef.current, {
|
|
65
|
-
label
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}, []);
|
|
69
|
-
const updateTitle = useCallback(title => {
|
|
70
|
-
var _valuesRef$current2;
|
|
71
|
-
const prevTitle = (_valuesRef$current2 = valuesRef.current) == null ? void 0 : _valuesRef$current2.title;
|
|
72
|
-
if (prevTitle !== title && typeof title === 'string') {
|
|
73
|
-
var _titleRef$current;
|
|
74
|
-
// BAD: We only disabled this lint rule to enable eslint upgrade after this component was implemented. These apis should never be used.
|
|
75
|
-
// Usage in this component are known making this a high risk component. Contact team for more information.
|
|
76
|
-
|
|
77
|
-
(_titleRef$current = titleRef.current) == null || _titleRef$current.setNativeProps({
|
|
78
|
-
text: title,
|
|
79
|
-
style: styles.title(title)
|
|
80
|
-
});
|
|
81
|
-
valuesRef.current = _extends({}, valuesRef.current, {
|
|
82
|
-
title
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}, [styles]);
|
|
86
|
-
const updateSubHead = useCallback(subHead => {
|
|
87
|
-
var _valuesRef$current3;
|
|
88
|
-
const prevSubHead = (_valuesRef$current3 = valuesRef.current) == null ? void 0 : _valuesRef$current3.subHead;
|
|
89
|
-
if (prevSubHead !== subHead) {
|
|
90
|
-
var _subHeadIconRef$curre, _subHeadRef$current, _subHeadAccessoryRef$, _subHead$accessoryTex;
|
|
91
|
-
// BAD: We only disabled this lint rule to enable eslint upgrade after this component was implemented. These apis should never be used.
|
|
92
|
-
// Usage in this component are known making this a high risk component. Contact team for more information.
|
|
93
|
-
|
|
94
|
-
(_subHeadIconRef$curre = subHeadIconRef.current) == null || _subHeadIconRef$curre.setNativeProps({
|
|
95
|
-
text: subheadIconSignMap[subHead.sign],
|
|
96
|
-
style: styles.subHeadIcon(subHead.variant)
|
|
97
|
-
});
|
|
98
|
-
// BAD: We only disabled this lint rule to enable eslint upgrade after this component was implemented. These apis should never be used.
|
|
99
|
-
// Usage in this component are known making this a high risk component. Contact team for more information.
|
|
100
|
-
|
|
101
|
-
(_subHeadRef$current = subHeadRef.current) == null || _subHeadRef$current.setNativeProps({
|
|
102
|
-
text: interpolateSubHeadText(subHead),
|
|
103
|
-
style: styles.subHead(subHead.variant, subHead.accessoryText === undefined)
|
|
104
|
-
});
|
|
105
|
-
// BAD: We only disabled this lint rule to enable eslint upgrade after this component was implemented. These apis should never be used.
|
|
106
|
-
// Usage in this component are known making this a high risk component. Contact team for more information.
|
|
107
|
-
|
|
108
|
-
(_subHeadAccessoryRef$ = subHeadAccessoryRef.current) == null || _subHeadAccessoryRef$.setNativeProps({
|
|
109
|
-
text: (_subHead$accessoryTex = subHead.accessoryText) != null ? _subHead$accessoryTex : '',
|
|
110
|
-
style: styles.subHeadAccessory()
|
|
111
|
-
});
|
|
112
|
-
valuesRef.current = _extends({}, valuesRef.current, {
|
|
113
|
-
subHead
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}, [styles]);
|
|
117
|
-
|
|
118
|
-
// update is triggered from a parent component.
|
|
119
|
-
// We track the values of each input in a valuesRef object
|
|
120
|
-
// so that we can avoid updating unnecessarily if previous
|
|
121
|
-
// value is the same as the new value
|
|
122
|
-
const update = useCallback(_ref3 => {
|
|
123
|
-
let {
|
|
124
|
-
label,
|
|
125
|
-
title,
|
|
126
|
-
subHead
|
|
127
|
-
} = _ref3;
|
|
128
|
-
if (label) {
|
|
129
|
-
updateLabel(label);
|
|
130
|
-
}
|
|
131
|
-
if (title) {
|
|
132
|
-
updateTitle(title);
|
|
133
|
-
}
|
|
134
|
-
if (subHead) {
|
|
135
|
-
updateSubHead(subHead);
|
|
136
|
-
}
|
|
137
|
-
}, [updateLabel, updateSubHead, updateTitle]);
|
|
138
|
-
useImperativeHandle(forwardedRef, () => {
|
|
139
|
-
return {
|
|
140
|
-
update
|
|
141
|
-
};
|
|
142
|
-
}, [update]);
|
|
143
|
-
const label = !!defaultLabel && /*#__PURE__*/_jsx(TextInput, {
|
|
144
|
-
ref: labelRef,
|
|
145
|
-
defaultValue: defaultLabel,
|
|
146
|
-
editable: false,
|
|
147
|
-
pointerEvents: "none",
|
|
148
|
-
style: styles.label,
|
|
149
|
-
testID: "SparklineInteractiveHeaderLabel"
|
|
150
|
-
});
|
|
151
|
-
const title = /*#__PURE__*/_jsxs(_Fragment, {
|
|
152
|
-
children: [/*#__PURE__*/_jsx(View, {
|
|
153
|
-
children: typeof defaultTitle === 'string' ? /*#__PURE__*/_jsx(TextInput, {
|
|
154
|
-
ref: titleRef,
|
|
155
|
-
defaultValue: defaultTitle,
|
|
156
|
-
editable: false,
|
|
157
|
-
pointerEvents: "none",
|
|
158
|
-
style: styles.title(defaultTitle),
|
|
159
|
-
testID: "SparklineInteractiveHeaderTitle"
|
|
160
|
-
}) : defaultTitle
|
|
161
|
-
}), !!defaultSubHead && /*#__PURE__*/_jsxs(HStack, {
|
|
162
|
-
accessible: true,
|
|
163
|
-
alignItems: "center",
|
|
164
|
-
padding: 0,
|
|
165
|
-
children: [/*#__PURE__*/_jsx(TextInput, {
|
|
166
|
-
ref: subHeadIconRef,
|
|
167
|
-
defaultValue: subheadIconSignMap[defaultSubHead.sign],
|
|
168
|
-
editable: false,
|
|
169
|
-
pointerEvents: "none",
|
|
170
|
-
style: styles.subHeadIcon(defaultSubHead.variant),
|
|
171
|
-
testID: "SparklineInteractiveHeaderSubHeadIcon"
|
|
172
|
-
}), /*#__PURE__*/_jsx(TextInput, {
|
|
173
|
-
ref: subHeadRef,
|
|
174
|
-
defaultValue: interpolateSubHeadText(defaultSubHead),
|
|
175
|
-
editable: false,
|
|
176
|
-
pointerEvents: "none",
|
|
177
|
-
style: styles.subHead(defaultSubHead.variant, defaultSubHead.accessoryText === undefined),
|
|
178
|
-
testID: "SparklineInteractiveHeaderSubHead"
|
|
179
|
-
}), !!defaultSubHead.accessoryText && /*#__PURE__*/_jsx(TextInput, {
|
|
180
|
-
ref: subHeadAccessoryRef,
|
|
181
|
-
defaultValue: defaultSubHead.accessoryText,
|
|
182
|
-
editable: false,
|
|
183
|
-
pointerEvents: "none",
|
|
184
|
-
style: styles.subHeadAccessory(),
|
|
185
|
-
testID: "SparklineInteractiveHeaderSubHead"
|
|
186
|
-
})]
|
|
187
|
-
})]
|
|
188
|
-
});
|
|
189
|
-
const trendA11yLabel = defaultSubHead ? "" + ((defaultSubHead == null ? void 0 : defaultSubHead.variant) === 'positive' ? 'up' : 'down') : '';
|
|
190
|
-
const headerA11yLabel = defaultLabel + ", " + defaultTitle + ", " + trendA11yLabel + " " + (defaultSubHead == null ? void 0 : defaultSubHead.priceChange) + ", " + (defaultSubHead == null ? void 0 : defaultSubHead.percent);
|
|
191
|
-
return /*#__PURE__*/_jsxs(HStack, {
|
|
192
|
-
accessibilityHint: "The price and difference for this time period",
|
|
193
|
-
accessibilityLabel: "Asset summary",
|
|
194
|
-
accessibilityRole: "header",
|
|
195
|
-
"aria-live": "polite",
|
|
196
|
-
justifyContent: "space-between",
|
|
197
|
-
padding: 0,
|
|
198
|
-
testID: testID,
|
|
199
|
-
children: [/*#__PURE__*/_jsxs(VStack, {
|
|
200
|
-
accessible: true,
|
|
201
|
-
accessibilityLabel: headerA11yLabel,
|
|
202
|
-
flexShrink: 1,
|
|
203
|
-
padding: 0,
|
|
204
|
-
children: [labelNode != null ? labelNode : label, title]
|
|
205
|
-
}), /*#__PURE__*/_jsx(Trailing, {
|
|
206
|
-
children: trailing
|
|
207
|
-
})]
|
|
208
|
-
});
|
|
209
|
-
}));
|
|
210
|
-
export const SparklineInteractiveHeader = /*#__PURE__*/memo(/*#__PURE__*/forwardRef((_ref4, ref) => {
|
|
211
|
-
let {
|
|
212
|
-
defaultLabel,
|
|
213
|
-
defaultTitle,
|
|
214
|
-
defaultSubHead,
|
|
215
|
-
testID,
|
|
216
|
-
trailing,
|
|
217
|
-
labelNode
|
|
218
|
-
} = _ref4;
|
|
219
|
-
return /*#__PURE__*/_jsx(SparklineInteractiveHeaderStable
|
|
220
|
-
// All updates after initial load should be handled imperatively
|
|
221
|
-
// via update function in forwarded ref to prevent overriding
|
|
222
|
-
// values unexpectedly. This is why we use ref here so that the
|
|
223
|
-
// default value is stable and never updates on re-renders
|
|
224
|
-
, {
|
|
225
|
-
ref: ref,
|
|
226
|
-
defaultLabel: useRef(defaultLabel).current,
|
|
227
|
-
defaultSubHead: useRef(defaultSubHead).current,
|
|
228
|
-
defaultTitle: useRef(defaultTitle).current,
|
|
229
|
-
labelNode: labelNode,
|
|
230
|
-
testID: testID,
|
|
231
|
-
trailing: trailing
|
|
232
|
-
});
|
|
233
|
-
}));
|
package/esm/sparkline/sparkline-interactive-header/__figma__/SparklineInteractiveHeader.figma.js
DELETED
|
@@ -1,104 +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 from 'react';
|
|
3
|
-
import { figma } from '@figma/code-connect';
|
|
4
|
-
import { SparklineInteractive } from '../../sparkline-interactive/SparklineInteractive';
|
|
5
|
-
import { SparklineInteractiveHeader } from '../SparklineInteractiveHeader';
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
figma.connect(SparklineInteractiveHeader, 'https://www.figma.com/design/k5CtyJccNQUGMI5bI4lJ2g/✨-CDS-Components?node-id=320-14931&m=dev', {
|
|
8
|
-
imports: ["import { SparklineInteractiveHeader } from '@coinbase/cds-mobile-visualization'", "import { SparklineInteractive } from '@coinbase/cds-mobile-visualization'"],
|
|
9
|
-
props: {
|
|
10
|
-
compact: figma.boolean('compact'),
|
|
11
|
-
disableScrubbing: figma.boolean('scrubbing', {
|
|
12
|
-
false: true,
|
|
13
|
-
true: false
|
|
14
|
-
})
|
|
15
|
-
},
|
|
16
|
-
example: props => {
|
|
17
|
-
const periods = [{
|
|
18
|
-
label: '1H',
|
|
19
|
-
value: 'hour'
|
|
20
|
-
}, {
|
|
21
|
-
label: '1D',
|
|
22
|
-
value: 'day'
|
|
23
|
-
}, {
|
|
24
|
-
label: '1W',
|
|
25
|
-
value: 'week'
|
|
26
|
-
}, {
|
|
27
|
-
label: '1M',
|
|
28
|
-
value: 'month'
|
|
29
|
-
}, {
|
|
30
|
-
label: '1Y',
|
|
31
|
-
value: 'year'
|
|
32
|
-
}, {
|
|
33
|
-
label: 'All',
|
|
34
|
-
value: 'all'
|
|
35
|
-
}];
|
|
36
|
-
const data = {
|
|
37
|
-
hour: [],
|
|
38
|
-
day: [{
|
|
39
|
-
value: 49259.38,
|
|
40
|
-
date: new Date('2021-12-05T04:00:00.000Z')
|
|
41
|
-
}, {
|
|
42
|
-
value: 49163.79,
|
|
43
|
-
date: new Date('2021-12-05T04:05:00.000Z')
|
|
44
|
-
}, {
|
|
45
|
-
value: 49146.66,
|
|
46
|
-
date: new Date('2021-12-05T04:10:00.000Z')
|
|
47
|
-
}, {
|
|
48
|
-
value: 49083.92,
|
|
49
|
-
date: new Date('2021-12-05T04:15:00.000Z')
|
|
50
|
-
}, {
|
|
51
|
-
value: 49115.3,
|
|
52
|
-
date: new Date('2021-12-05T04:20:00.000Z')
|
|
53
|
-
}, {
|
|
54
|
-
value: 48992.14,
|
|
55
|
-
date: new Date('2021-12-05T04:25:00.000Z')
|
|
56
|
-
}, {
|
|
57
|
-
value: 49075.75,
|
|
58
|
-
date: new Date('2021-12-05T04:30:00.000Z')
|
|
59
|
-
}, {
|
|
60
|
-
value: 49025.78,
|
|
61
|
-
date: new Date('2021-12-05T04:35:00.000Z')
|
|
62
|
-
}, {
|
|
63
|
-
value: 49066.23,
|
|
64
|
-
date: new Date('2021-12-05T04:40:00.000Z')
|
|
65
|
-
}, {
|
|
66
|
-
value: 49247.82,
|
|
67
|
-
date: new Date('2021-12-05T04:45:00.000Z')
|
|
68
|
-
}],
|
|
69
|
-
week: [],
|
|
70
|
-
month: [],
|
|
71
|
-
year: [],
|
|
72
|
-
all: []
|
|
73
|
-
};
|
|
74
|
-
const defaultSubHead = {
|
|
75
|
-
percent: '1.35%',
|
|
76
|
-
sign: 'upwardTrend',
|
|
77
|
-
variant: 'positive',
|
|
78
|
-
accessibilityLabel: 'on Sunday, December 5, 2021 at 10:55 PM, up',
|
|
79
|
-
priceChange: '$21.36'
|
|
80
|
-
};
|
|
81
|
-
const header = /*#__PURE__*/_jsx(SparklineInteractiveHeader, {
|
|
82
|
-
defaultLabel: "Portfolio balance"
|
|
83
|
-
// @ts-expect-error: defaultSubHead is not part of the type definition
|
|
84
|
-
,
|
|
85
|
-
defaultSubHead: defaultSubHead,
|
|
86
|
-
defaultTitle: "$10,023.82"
|
|
87
|
-
});
|
|
88
|
-
return /*#__PURE__*/_jsx(SparklineInteractive, _extends({
|
|
89
|
-
data: data,
|
|
90
|
-
defaultPeriod: "day",
|
|
91
|
-
formatDate: date => date.toLocaleString('en-US', {
|
|
92
|
-
timeZone: 'America/New_York',
|
|
93
|
-
hour: 'numeric',
|
|
94
|
-
minute: 'numeric'
|
|
95
|
-
}),
|
|
96
|
-
headerNode: header,
|
|
97
|
-
onPeriodChanged: () => {},
|
|
98
|
-
onScrub: () => {},
|
|
99
|
-
onScrubEnd: () => {},
|
|
100
|
-
periods: periods,
|
|
101
|
-
strokeColor: "#cb51bb"
|
|
102
|
-
}, props));
|
|
103
|
-
}
|
|
104
|
-
});
|