react-native-wagmi-charts 2.8.1 → 2.8.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-wagmi-charts",
3
- "version": "2.8.1",
3
+ "version": "2.8.3",
4
4
  "description": "A sweet candlestick chart for React Native",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -2,6 +2,7 @@ import type { TCandle } from '../types';
2
2
 
3
3
  export function getDomain(rows: TCandle[]): [min: number, max: number] {
4
4
  'worklet';
5
+ if (rows.length === 0) return [0, 0];
5
6
  const values = rows.map(({ high, low }) => [high, low]).flat();
6
7
  const min = Math.min(...values);
7
8
  const max = Math.max(...values);
@@ -1,4 +1,4 @@
1
- import { interpolate, Extrapolate } from 'react-native-reanimated';
1
+ import { interpolate, Extrapolation } from 'react-native-reanimated';
2
2
 
3
3
  import type { TDomain } from '../types';
4
4
 
@@ -16,6 +16,6 @@ export function getHeight({
16
16
  value,
17
17
  [0, Math.max(...domain) - Math.min(...domain)],
18
18
  [0, maxHeight],
19
- Extrapolate.CLAMP
19
+ Extrapolation.CLAMP
20
20
  );
21
21
  }
@@ -1,4 +1,4 @@
1
- import { interpolate, Extrapolate } from 'react-native-reanimated';
1
+ import { interpolate, Extrapolation } from 'react-native-reanimated';
2
2
 
3
3
  import type { TDomain } from '../types';
4
4
 
@@ -13,5 +13,5 @@ export function getPrice({
13
13
  }) {
14
14
  'worklet';
15
15
  if (y === -1) return -1;
16
- return interpolate(y, [0, maxHeight], domain.reverse(), Extrapolate.CLAMP);
16
+ return interpolate(y, [0, maxHeight], domain.reverse(), Extrapolation.CLAMP);
17
17
  }
@@ -1,4 +1,4 @@
1
- import { interpolate, Extrapolate } from 'react-native-reanimated';
1
+ import { interpolate, Extrapolation } from 'react-native-reanimated';
2
2
 
3
3
  import type { TDomain } from '../types';
4
4
 
@@ -12,5 +12,5 @@ export function getY({
12
12
  maxHeight: number;
13
13
  }) {
14
14
  'worklet';
15
- return interpolate(value, domain, [maxHeight, 0], Extrapolate.CLAMP);
15
+ return interpolate(value, domain, [maxHeight, 0], Extrapolation.CLAMP);
16
16
  }
@@ -20,12 +20,12 @@ export const LineChartDimensionsContext = React.createContext({
20
20
  pathWidth: 0,
21
21
  });
22
22
 
23
- type LineChartProps = ViewProps & {
23
+ export type LineChartProps = ViewProps & {
24
24
  children: React.ReactNode;
25
25
  yGutter?: number;
26
26
  width?: number;
27
27
  height?: number;
28
- shape?: unknown;
28
+ shape?: d3Shape.CurveFactory;
29
29
  /**
30
30
  * If your `LineChart.Provider` uses a dictionary with multiple IDs for multiple paths, then this field is required.
31
31
  */
@@ -110,7 +110,7 @@ export function LineChart({
110
110
  width,
111
111
  height,
112
112
  pathWidth,
113
- shape: shape as d3Shape.CurveFactory,
113
+ shape
114
114
  }),
115
115
  [
116
116
  yGutter,
@@ -2,7 +2,7 @@ import React, { ReactNode, Children, cloneElement } from 'react';
2
2
  import { ViewProps, View } from 'react-native';
3
3
  import flattenChildren from 'react-keyed-flatten-children';
4
4
 
5
- import { LineChart } from './Chart';
5
+ import { LineChart, LineChartProps } from './Chart';
6
6
 
7
7
  type Props = {
8
8
  children: ReactNode;
@@ -13,13 +13,16 @@ export function LineChartGroup({ children, ...props }: Props) {
13
13
  const flatChildrenCount = Children.count(flatChildren);
14
14
  return (
15
15
  <View {...props}>
16
- {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}
17
- {Children.map(flatChildren, (child: any, index) => {
16
+ {Children.map(flatChildren, (child, index) => {
18
17
  const isLast = index === flatChildrenCount - 1;
19
- if (!isLast && child.type === LineChart) {
18
+ if (
19
+ !isLast &&
20
+ React.isValidElement(child) &&
21
+ child.type === LineChart
22
+ ) {
20
23
  return cloneElement(child, {
21
24
  absolute: true,
22
- });
25
+ } as Partial<LineChartProps>);
23
26
  }
24
27
  return child;
25
28
  })}
@@ -2,6 +2,7 @@ import type { TLineChartPoint } from '../types';
2
2
 
3
3
  export function getDomain(rows: TLineChartPoint[]): [number, number] {
4
4
  'worklet';
5
+ if (rows.length === 0) return [0, 0];
5
6
  const values = rows.map(({ value }) => value);
6
7
  return [Math.min(...values), Math.max(...values)];
7
8
  }