@hero-design/rn 8.100.2 → 8.101.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +12 -0
  3. package/es/index.js +111 -27
  4. package/lib/index.js +111 -27
  5. package/package.json +1 -1
  6. package/src/components/Chart/ColumnChart/ColumnChartContent.tsx +19 -3
  7. package/src/components/Chart/ColumnChart/Segment.tsx +1 -1
  8. package/src/components/Chart/ColumnChart/StackedSegment.tsx +10 -6
  9. package/src/components/Chart/ColumnChart/__tests__/Segment.spec.tsx +1 -1
  10. package/src/components/Chart/ColumnChart/__tests__/__snapshots__/StackedSegment.spec.tsx.snap +6 -21
  11. package/src/components/Chart/ColumnChart/__tests__/__snapshots__/index.spec.tsx.snap +999 -6
  12. package/src/components/Chart/ColumnChart/__tests__/index.spec.tsx +107 -0
  13. package/src/components/Chart/ColumnChart/index.tsx +15 -0
  14. package/src/components/Chart/Line/Line.tsx +5 -2
  15. package/src/components/Chart/Line/__tests__/Line.spec.tsx +13 -6
  16. package/src/components/Chart/Line/__tests__/__snapshots__/Line.spec.tsx.snap +1 -1
  17. package/src/components/Chart/Line/__tests__/__snapshots__/index.spec.tsx.snap +1464 -4
  18. package/src/components/Chart/Line/__tests__/index.spec.tsx +95 -1
  19. package/src/components/Chart/Line/index.tsx +14 -2
  20. package/src/components/Chart/shared/__tests__/utils.spec.ts +16 -0
  21. package/src/components/Chart/shared/constants.ts +4 -0
  22. package/src/components/Chart/shared/hooks/useCustomColor.ts +84 -0
  23. package/src/components/Chart/shared/utils.ts +14 -0
  24. package/src/components/Chart/types.ts +32 -0
  25. package/src/components/StatusScreens/Empty/__tests__/__snapshots__/index.spec.tsx.snap +8 -35
  26. package/src/components/StatusScreens/Empty/index.tsx +7 -3
  27. package/stats/8.100.2/rn-stats.html +1 -3
  28. package/stats/8.101.0/rn-stats.html +4842 -0
  29. package/stats/8.101.1/rn-stats.html +4844 -0
  30. package/types/components/Chart/ColumnChart/ColumnChartContent.d.ts +5 -1
  31. package/types/components/Chart/ColumnChart/StackedSegment.d.ts +4 -0
  32. package/types/components/Chart/ColumnChart/index.d.ts +8 -2
  33. package/types/components/Chart/Line/Line.d.ts +3 -1
  34. package/types/components/Chart/Line/index.d.ts +8 -2
  35. package/types/components/Chart/index.d.ts +2 -2
  36. package/types/components/Chart/shared/constants.d.ts +2 -0
  37. package/types/components/Chart/shared/hooks/useCustomColor.d.ts +22 -0
  38. package/types/components/Chart/shared/utils.d.ts +11 -0
  39. package/types/components/Chart/types.d.ts +14 -1
@@ -3,11 +3,10 @@
3
3
  // Each segment represents a value from a different series, stacked vertically. Uses the Segment component for rendering each bar.
4
4
 
5
5
  import React, { memo } from 'react';
6
- import Segment from './Segment';
7
- import { DataValue, YAxisConfig } from '../types';
8
- import useScaleLinearY from '../shared/hooks/useScaleLinearY';
9
- import useColorScale from '../shared/hooks/useColorScale';
10
6
  import { deepCompareValue } from '../../../utils/helpers';
7
+ import useScaleLinearY from '../shared/hooks/useScaleLinearY';
8
+ import { DataValue, YAxisConfig } from '../types';
9
+ import Segment from './Segment';
11
10
 
12
11
  interface StackedSegmentProps {
13
12
  stackedData: Array<DataValue>;
@@ -27,6 +26,10 @@ interface StackedSegmentProps {
27
26
  seriesIndex: number;
28
27
  xIndex: number;
29
28
  }) => void;
29
+ /**
30
+ * A function that maps series labels to colors.
31
+ */
32
+ colorScale?: (label: string) => string | undefined;
30
33
  }
31
34
 
32
35
  /**
@@ -43,6 +46,7 @@ const StackedSegment: React.FC<StackedSegmentProps> = ({
43
46
  xCenter,
44
47
  xIndex,
45
48
  onBarPress,
49
+ colorScale,
46
50
  }) => {
47
51
  const { yStart, yEnd } = coordinates;
48
52
  const stackedMaxY = yAxisConfig.maxValue ?? 0;
@@ -54,7 +58,7 @@ const StackedSegment: React.FC<StackedSegmentProps> = ({
54
58
  });
55
59
 
56
60
  let yStack = 0; // running sum for stacking
57
- const colorScale = useColorScale(seriesLabels);
61
+
58
62
  return stackedData.map((value, index) => {
59
63
  // If value is undefined, skip this segment
60
64
  if (value === undefined) {
@@ -74,7 +78,7 @@ const StackedSegment: React.FC<StackedSegmentProps> = ({
74
78
  xCenter={xCenter}
75
79
  y={y1}
76
80
  height={colHeight}
77
- color={colorScale(seriesLabel)}
81
+ color={colorScale?.(seriesLabel)}
78
82
  value={value}
79
83
  xLabel={xLabel}
80
84
  seriesLabel={seriesLabel}
@@ -25,7 +25,7 @@ describe('Segment', () => {
25
25
 
26
26
  const segment = getByTestId('test-segment');
27
27
  expect(segment.props.accessibilityLabel).toBe(
28
- 'Column segment: value 10, x-label A, series Series 1'
28
+ 'Column segment: value 10, x-label A, series Series 1, color #000000'
29
29
  );
30
30
  });
31
31
 
@@ -35,19 +35,14 @@ exports[`StackedSegment renders segments with correct accessibilityLabel and tes
35
35
  }
36
36
  >
37
37
  <RNSVGRect
38
- accessibilityLabel="Column segment: value 10, x-label A, series Series 1"
38
+ accessibilityLabel="Column segment: value 10, x-label A, series Series 1, color undefined"
39
39
  fill={
40
40
  {
41
- "payload": 4291005678,
41
+ "payload": 4278190080,
42
42
  "type": 0,
43
43
  }
44
44
  }
45
45
  height={31.333333333333314}
46
- propList={
47
- [
48
- "fill",
49
- ]
50
- }
51
46
  rx={8}
52
47
  testID="column-segment-A-Series 1"
53
48
  width={16}
@@ -55,19 +50,14 @@ exports[`StackedSegment renders segments with correct accessibilityLabel and tes
55
50
  y={167.66666666666669}
56
51
  />
57
52
  <RNSVGRect
58
- accessibilityLabel="Column segment: value 20, x-label A, series Series 2"
53
+ accessibilityLabel="Column segment: value 20, x-label A, series Series 2, color undefined"
59
54
  fill={
60
55
  {
61
- "payload": 4280139502,
56
+ "payload": 4278190080,
62
57
  "type": 0,
63
58
  }
64
59
  }
65
60
  height={64.66666666666669}
66
- propList={
67
- [
68
- "fill",
69
- ]
70
- }
71
61
  rx={8}
72
62
  testID="column-segment-A-Series 2"
73
63
  width={16}
@@ -75,19 +65,14 @@ exports[`StackedSegment renders segments with correct accessibilityLabel and tes
75
65
  y={101}
76
66
  />
77
67
  <RNSVGRect
78
- accessibilityLabel="Column segment: value 30, x-label A, series Series 3"
68
+ accessibilityLabel="Column segment: value 30, x-label A, series Series 3, color undefined"
79
69
  fill={
80
70
  {
81
- "payload": 4284471940,
71
+ "payload": 4278190080,
82
72
  "type": 0,
83
73
  }
84
74
  }
85
75
  height={98}
86
- propList={
87
- [
88
- "fill",
89
- ]
90
- }
91
76
  rx={8}
92
77
  testID="column-segment-A-Series 3"
93
78
  width={16}