From 14a98cf92ab725ee06727cb247f9fd4d0022eaf4 Mon Sep 17 00:00:00 2001 From: Kenan Date: Wed, 24 Jan 2024 12:23:49 +0000 Subject: [PATCH 01/14] Migrate victory-native primitives --- .../src/victory-portal/portal.tsx | 2 +- .../src/victory-portal/victory-portal.tsx | 4 +- .../victory-portal/{portal.js => portal.tsx} | 0 .../{victory-portal.js => victory-portal.tsx} | 0 .../src/components/victory-primitives/arc.js | 7 ---- .../src/components/victory-primitives/arc.tsx | 9 +++++ .../victory-primitives/{area.js => area.tsx} | 4 +- .../{background.js => background.tsx} | 4 +- .../src/components/victory-primitives/bar.js | 7 ---- .../src/components/victory-primitives/bar.tsx | 9 +++++ .../components/victory-primitives/border.js | 7 ---- .../components/victory-primitives/border.tsx | 9 +++++ .../{candle.js => candle.tsx} | 4 +- .../{circle.js => circle.tsx} | 26 ++++--------- .../victory-primitives/clip-path.js | 26 ------------- .../victory-primitives/clip-path.tsx | 21 ++++++++++ .../components/victory-primitives/curve.js | 7 ---- .../components/victory-primitives/curve.tsx | 9 +++++ .../{error-bar.js => error-bar.tsx} | 4 +- .../components/victory-primitives/flyout.js | 7 ---- .../components/victory-primitives/flyout.tsx | 9 +++++ .../{line-segment.js => line-segment.tsx} | 4 +- .../src/components/victory-primitives/line.js | 37 ------------------ .../components/victory-primitives/line.tsx | 25 ++++++++++++ .../victory-primitives/{path.js => path.tsx} | 24 ++++-------- .../components/victory-primitives/point.js | 7 ---- .../components/victory-primitives/point.tsx | 9 +++++ .../src/components/victory-primitives/rect.js | 39 ------------------- .../components/victory-primitives/rect.tsx | 24 ++++++++++++ .../components/victory-primitives/slice.js | 7 ---- .../components/victory-primitives/slice.tsx | 9 +++++ .../victory-primitives/{text.js => text.tsx} | 29 +++++--------- .../components/victory-primitives/tspan.js | 24 ------------ .../components/victory-primitives/tspan.tsx | 15 +++++++ .../components/victory-primitives/types.ts | 9 +++++ .../{voronoi.js => voronoi.tsx} | 4 +- .../{whisker.js => whisker.tsx} | 4 +- 37 files changed, 198 insertions(+), 247 deletions(-) rename packages/victory-native/src/components/victory-portal/{portal.js => portal.tsx} (100%) rename packages/victory-native/src/components/victory-portal/{victory-portal.js => victory-portal.tsx} (100%) delete mode 100644 packages/victory-native/src/components/victory-primitives/arc.js create mode 100644 packages/victory-native/src/components/victory-primitives/arc.tsx rename packages/victory-native/src/components/victory-primitives/{area.js => area.tsx} (67%) rename packages/victory-native/src/components/victory-primitives/{background.js => background.tsx} (64%) delete mode 100644 packages/victory-native/src/components/victory-primitives/bar.js create mode 100644 packages/victory-native/src/components/victory-primitives/bar.tsx delete mode 100644 packages/victory-native/src/components/victory-primitives/border.js create mode 100644 packages/victory-native/src/components/victory-primitives/border.tsx rename packages/victory-native/src/components/victory-primitives/{candle.js => candle.tsx} (71%) rename packages/victory-native/src/components/victory-primitives/{circle.js => circle.tsx} (50%) delete mode 100644 packages/victory-native/src/components/victory-primitives/clip-path.js create mode 100644 packages/victory-native/src/components/victory-primitives/clip-path.tsx delete mode 100644 packages/victory-native/src/components/victory-primitives/curve.js create mode 100644 packages/victory-native/src/components/victory-primitives/curve.tsx rename packages/victory-native/src/components/victory-primitives/{error-bar.js => error-bar.tsx} (63%) delete mode 100644 packages/victory-native/src/components/victory-primitives/flyout.js create mode 100644 packages/victory-native/src/components/victory-primitives/flyout.tsx rename packages/victory-native/src/components/victory-primitives/{line-segment.js => line-segment.tsx} (54%) delete mode 100644 packages/victory-native/src/components/victory-primitives/line.js create mode 100644 packages/victory-native/src/components/victory-primitives/line.tsx rename packages/victory-native/src/components/victory-primitives/{path.js => path.tsx} (51%) delete mode 100644 packages/victory-native/src/components/victory-primitives/point.js create mode 100644 packages/victory-native/src/components/victory-primitives/point.tsx delete mode 100644 packages/victory-native/src/components/victory-primitives/rect.js create mode 100644 packages/victory-native/src/components/victory-primitives/rect.tsx delete mode 100644 packages/victory-native/src/components/victory-primitives/slice.js create mode 100644 packages/victory-native/src/components/victory-primitives/slice.tsx rename packages/victory-native/src/components/victory-primitives/{text.js => text.tsx} (50%) delete mode 100644 packages/victory-native/src/components/victory-primitives/tspan.js create mode 100644 packages/victory-native/src/components/victory-primitives/tspan.tsx create mode 100644 packages/victory-native/src/components/victory-primitives/types.ts rename packages/victory-native/src/components/victory-primitives/{voronoi.js => voronoi.tsx} (76%) rename packages/victory-native/src/components/victory-primitives/{whisker.js => whisker.tsx} (65%) diff --git a/packages/victory-core/src/victory-portal/portal.tsx b/packages/victory-core/src/victory-portal/portal.tsx index c15fc2f0b..b9f7929f4 100644 --- a/packages/victory-core/src/victory-portal/portal.tsx +++ b/packages/victory-core/src/victory-portal/portal.tsx @@ -48,7 +48,7 @@ export class Portal this.forceUpdate(); }; - private getChildren() { + public getChildren() { return keys(this.map).map((key) => { const el = this.map[key]; return el ? React.cloneElement(el, { key }) : el; diff --git a/packages/victory-core/src/victory-portal/victory-portal.tsx b/packages/victory-core/src/victory-portal/victory-portal.tsx index a6acf57c2..79f9ccb63 100644 --- a/packages/victory-core/src/victory-portal/victory-portal.tsx +++ b/packages/victory-core/src/victory-portal/victory-portal.tsx @@ -30,9 +30,9 @@ export class VictoryPortal extends React.Component { static contextType = PortalContext; private checkedContext!: boolean; - private renderInPlace!: boolean; - private element!: React.ReactElement; private portalKey!: number; + public renderInPlace!: boolean; + public element!: React.ReactElement; componentDidMount() { if (!this.checkedContext) { diff --git a/packages/victory-native/src/components/victory-portal/portal.js b/packages/victory-native/src/components/victory-portal/portal.tsx similarity index 100% rename from packages/victory-native/src/components/victory-portal/portal.js rename to packages/victory-native/src/components/victory-portal/portal.tsx diff --git a/packages/victory-native/src/components/victory-portal/victory-portal.js b/packages/victory-native/src/components/victory-portal/victory-portal.tsx similarity index 100% rename from packages/victory-native/src/components/victory-portal/victory-portal.js rename to packages/victory-native/src/components/victory-portal/victory-portal.tsx diff --git a/packages/victory-native/src/components/victory-primitives/arc.js b/packages/victory-native/src/components/victory-primitives/arc.js deleted file mode 100644 index d401e30d5..000000000 --- a/packages/victory-native/src/components/victory-primitives/arc.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; -import Path from "./path"; -import { Arc } from "victory-core/es"; - -const NativeArc = (props) => } {...props} />; - -export default NativeArc; diff --git a/packages/victory-native/src/components/victory-primitives/arc.tsx b/packages/victory-native/src/components/victory-primitives/arc.tsx new file mode 100644 index 000000000..8d6268d03 --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/arc.tsx @@ -0,0 +1,9 @@ +import React from "react"; +import Path from "./path"; +import { Arc, ArcProps } from "victory-core/es"; + +const NativeArc = (props: ArcProps) => ( + } {...props} /> +); + +export default NativeArc; diff --git a/packages/victory-native/src/components/victory-primitives/area.js b/packages/victory-native/src/components/victory-primitives/area.tsx similarity index 67% rename from packages/victory-native/src/components/victory-primitives/area.js rename to packages/victory-native/src/components/victory-primitives/area.tsx index d3151e4dd..c84ee0d88 100644 --- a/packages/victory-native/src/components/victory-primitives/area.js +++ b/packages/victory-native/src/components/victory-primitives/area.tsx @@ -1,9 +1,9 @@ import React from "react"; import Path from "./path"; import { G } from "react-native-svg"; -import { Area } from "victory-area/es"; +import { Area, AreaProps } from "victory-area/es"; -const NativeArea = (props) => ( +const NativeArea = (props: AreaProps) => ( } groupComponent={} {...props} /> ); diff --git a/packages/victory-native/src/components/victory-primitives/background.js b/packages/victory-native/src/components/victory-primitives/background.tsx similarity index 64% rename from packages/victory-native/src/components/victory-primitives/background.js rename to packages/victory-native/src/components/victory-primitives/background.tsx index 6e380be70..5218cbe6d 100644 --- a/packages/victory-native/src/components/victory-primitives/background.js +++ b/packages/victory-native/src/components/victory-primitives/background.tsx @@ -1,9 +1,9 @@ import React from "react"; import Rect from "./rect"; import Circle from "./circle"; -import { Background } from "victory-core/es"; +import { Background, BackgroundProps } from "victory-core/es"; -const NativeBackground = (props) => ( +const NativeBackground = (props: BackgroundProps) => ( } rectComponent={} diff --git a/packages/victory-native/src/components/victory-primitives/bar.js b/packages/victory-native/src/components/victory-primitives/bar.js deleted file mode 100644 index eda14e92d..000000000 --- a/packages/victory-native/src/components/victory-primitives/bar.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; -import Path from "./path"; -import { Bar } from "victory-bar/es"; - -const NativeBar = (props) => } {...props} />; - -export default NativeBar; diff --git a/packages/victory-native/src/components/victory-primitives/bar.tsx b/packages/victory-native/src/components/victory-primitives/bar.tsx new file mode 100644 index 000000000..904354409 --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/bar.tsx @@ -0,0 +1,9 @@ +import React from "react"; +import Path from "./path"; +import { Bar, BarProps } from "victory-bar/es"; + +const NativeBar = (props: BarProps) => ( + } {...props} /> +); + +export default NativeBar; diff --git a/packages/victory-native/src/components/victory-primitives/border.js b/packages/victory-native/src/components/victory-primitives/border.js deleted file mode 100644 index 254a2d963..000000000 --- a/packages/victory-native/src/components/victory-primitives/border.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; -import Rect from "./rect"; -import { Border } from "victory-core/es"; - -const NativeBorder = (props) => } {...props} />; - -export default NativeBorder; diff --git a/packages/victory-native/src/components/victory-primitives/border.tsx b/packages/victory-native/src/components/victory-primitives/border.tsx new file mode 100644 index 000000000..a1639e63e --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/border.tsx @@ -0,0 +1,9 @@ +import React from "react"; +import Rect from "./rect"; +import { Border, BorderProps } from "victory-core/es"; + +const NativeBorder = (props: BorderProps) => ( + } {...props} /> +); + +export default NativeBorder; diff --git a/packages/victory-native/src/components/victory-primitives/candle.js b/packages/victory-native/src/components/victory-primitives/candle.tsx similarity index 71% rename from packages/victory-native/src/components/victory-primitives/candle.js rename to packages/victory-native/src/components/victory-primitives/candle.tsx index ab3865611..cdbf83b9b 100644 --- a/packages/victory-native/src/components/victory-primitives/candle.js +++ b/packages/victory-native/src/components/victory-primitives/candle.tsx @@ -2,9 +2,9 @@ import React from "react"; import Line from "./line"; import Rect from "./rect"; import { G } from "react-native-svg"; -import { Candle } from "victory-candlestick/es"; +import { Candle, CandleProps } from "victory-candlestick/es"; -const NativeCandle = (props) => ( +const NativeCandle = (props: CandleProps) => ( } rectComponent={} diff --git a/packages/victory-native/src/components/victory-primitives/circle.js b/packages/victory-native/src/components/victory-primitives/circle.tsx similarity index 50% rename from packages/victory-native/src/components/victory-primitives/circle.js rename to packages/victory-native/src/components/victory-primitives/circle.tsx index 625697147..4a00ba3af 100644 --- a/packages/victory-native/src/components/victory-primitives/circle.js +++ b/packages/victory-native/src/components/victory-primitives/circle.tsx @@ -1,9 +1,12 @@ import React from "react"; -import PropTypes from "prop-types"; -import { Circle } from "react-native-svg"; +import { Circle, CircleProps } from "react-native-svg"; import { useGetNativeStyle } from "../../helpers/native-helpers"; +import { VictoryNativePrimitiveShapeProps } from "./types"; -const VCircle = (props) => { +export type VictoryNativeCircleProps = CircleProps & + VictoryNativePrimitiveShapeProps; + +const NativeCircle = (props: VictoryNativeCircleProps) => { const { "aria-label": accessibilityLabel, desc, style, ...rest } = props; const nativeStyle = useGetNativeStyle(style); return ( @@ -18,19 +21,4 @@ const VCircle = (props) => { ); }; -export default VCircle; - -VCircle.propTypes = { - "aria-label": PropTypes.string, - className: PropTypes.string, - clipPath: PropTypes.string, - cx: PropTypes.number, - cy: PropTypes.number, - desc: PropTypes.string, - events: PropTypes.object, - r: PropTypes.number, - role: PropTypes.string, - shapeRendering: PropTypes.string, - style: PropTypes.object, - transform: PropTypes.string, -}; +export default NativeCircle; diff --git a/packages/victory-native/src/components/victory-primitives/clip-path.js b/packages/victory-native/src/components/victory-primitives/clip-path.js deleted file mode 100644 index 81d2cd671..000000000 --- a/packages/victory-native/src/components/victory-primitives/clip-path.js +++ /dev/null @@ -1,26 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import { Defs, ClipPath, G } from "react-native-svg"; - -export default class VClipPath extends React.Component { - static propTypes = { - children: PropTypes.oneOfType([ - PropTypes.arrayOf(PropTypes.node), - PropTypes.node, - ]), - clipId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - }; - - render() { - const { children, clipId } = this.props; - // Wrap in G not to cause exceptions in old react-native-svg - // https://github.com/FormidableLabs/victory-native/issues/432#issuecomment-475927581 - return ( - - - {children} - - - ); - } -} diff --git a/packages/victory-native/src/components/victory-primitives/clip-path.tsx b/packages/victory-native/src/components/victory-primitives/clip-path.tsx new file mode 100644 index 000000000..e10526b58 --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/clip-path.tsx @@ -0,0 +1,21 @@ +import React from "react"; +import { Defs, ClipPath, G, ClipPathProps } from "react-native-svg"; + +export interface VictoryNativeClipPathProps extends ClipPathProps { + clipId?: string; +} + +const NativeClipPath = (props: VictoryNativeClipPathProps) => { + const { children, clipId } = props; + // Wrap in G not to cause exceptions in old react-native-svg + // https://github.com/FormidableLabs/victory-native/issues/432#issuecomment-475927581 + return ( + + + {children} + + + ); +}; + +export default NativeClipPath; diff --git a/packages/victory-native/src/components/victory-primitives/curve.js b/packages/victory-native/src/components/victory-primitives/curve.js deleted file mode 100644 index e1ec0286d..000000000 --- a/packages/victory-native/src/components/victory-primitives/curve.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; -import Path from "./path"; -import { Curve } from "victory-line/es"; - -const NativeCurve = (props) => } {...props} />; - -export default NativeCurve; diff --git a/packages/victory-native/src/components/victory-primitives/curve.tsx b/packages/victory-native/src/components/victory-primitives/curve.tsx new file mode 100644 index 000000000..b70a6494e --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/curve.tsx @@ -0,0 +1,9 @@ +import React from "react"; +import Path from "./path"; +import { Curve, CurveProps } from "victory-line/es"; + +const NativeCurve = (props: CurveProps) => ( + } {...props} /> +); + +export default NativeCurve; diff --git a/packages/victory-native/src/components/victory-primitives/error-bar.js b/packages/victory-native/src/components/victory-primitives/error-bar.tsx similarity index 63% rename from packages/victory-native/src/components/victory-primitives/error-bar.js rename to packages/victory-native/src/components/victory-primitives/error-bar.tsx index f7500bd87..a5d65e5dd 100644 --- a/packages/victory-native/src/components/victory-primitives/error-bar.js +++ b/packages/victory-native/src/components/victory-primitives/error-bar.tsx @@ -1,9 +1,9 @@ import React from "react"; import Line from "./line"; import { G } from "react-native-svg"; -import { ErrorBar } from "victory-errorbar/es"; +import { ErrorBar, ErrorBarProps } from "victory-errorbar/es"; -const NativeErrorBar = (props) => ( +const NativeErrorBar = (props: ErrorBarProps) => ( } groupComponent={} {...props} /> ); diff --git a/packages/victory-native/src/components/victory-primitives/flyout.js b/packages/victory-native/src/components/victory-primitives/flyout.js deleted file mode 100644 index 71cf0d905..000000000 --- a/packages/victory-native/src/components/victory-primitives/flyout.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; -import Path from "./path"; -import { Flyout } from "victory-tooltip/es"; - -const NativeFlyout = (props) => } {...props} />; - -export default NativeFlyout; diff --git a/packages/victory-native/src/components/victory-primitives/flyout.tsx b/packages/victory-native/src/components/victory-primitives/flyout.tsx new file mode 100644 index 000000000..e0b5393f2 --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/flyout.tsx @@ -0,0 +1,9 @@ +import React from "react"; +import Path from "./path"; +import { Flyout, FlyoutProps } from "victory-tooltip/es"; + +const NativeFlyout = (props: FlyoutProps) => ( + } {...props} /> +); + +export default NativeFlyout; diff --git a/packages/victory-native/src/components/victory-primitives/line-segment.js b/packages/victory-native/src/components/victory-primitives/line-segment.tsx similarity index 54% rename from packages/victory-native/src/components/victory-primitives/line-segment.js rename to packages/victory-native/src/components/victory-primitives/line-segment.tsx index c5f03b87b..6665a888c 100644 --- a/packages/victory-native/src/components/victory-primitives/line-segment.js +++ b/packages/victory-native/src/components/victory-primitives/line-segment.tsx @@ -1,8 +1,8 @@ import React from "react"; import Line from "./line"; -import { LineSegment } from "victory-core/es"; +import { LineSegment, LineSegmentProps } from "victory-core/es"; -const NativeLineSegment = (props) => ( +const NativeLineSegment = (props: LineSegmentProps) => ( } {...props} /> ); diff --git a/packages/victory-native/src/components/victory-primitives/line.js b/packages/victory-native/src/components/victory-primitives/line.js deleted file mode 100644 index fddad93fe..000000000 --- a/packages/victory-native/src/components/victory-primitives/line.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import { Line } from "react-native-svg"; -import { useGetNativeStyle } from "../../helpers/native-helpers"; - -const VLine = (props) => { - const { "aria-label": accessibilityLabel, desc, style, ...rest } = props; - const nativeStyle = useGetNativeStyle(style); - return ( - - ); -}; - -export default VLine; - -VLine.propTypes = { - "aria-label": PropTypes.string, - className: PropTypes.string, - clipPath: PropTypes.string, - desc: PropTypes.string, - events: PropTypes.object, - role: PropTypes.string, - shapeRendering: PropTypes.string, - style: PropTypes.object, - transform: PropTypes.string, - x1: PropTypes.number, - x2: PropTypes.number, - y1: PropTypes.number, - y2: PropTypes.number, -}; diff --git a/packages/victory-native/src/components/victory-primitives/line.tsx b/packages/victory-native/src/components/victory-primitives/line.tsx new file mode 100644 index 000000000..e3477c799 --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/line.tsx @@ -0,0 +1,25 @@ +import React from "react"; +import { Line, LineProps } from "react-native-svg"; +import { useGetNativeStyle } from "../../helpers/native-helpers"; +import { VictoryNativePrimitiveShapeProps } from "./types"; + +export type VictoryNativeLineProps = LineProps & + VictoryNativePrimitiveShapeProps; + +const NativeLine = (props: VictoryNativeLineProps) => { + const { "aria-label": accessibilityLabel, desc, style, ...rest } = props; + const nativeStyle = useGetNativeStyle(style); + + return ( + + ); +}; + +export default NativeLine; diff --git a/packages/victory-native/src/components/victory-primitives/path.js b/packages/victory-native/src/components/victory-primitives/path.tsx similarity index 51% rename from packages/victory-native/src/components/victory-primitives/path.js rename to packages/victory-native/src/components/victory-primitives/path.tsx index 9099dca68..39b497c7a 100644 --- a/packages/victory-native/src/components/victory-primitives/path.js +++ b/packages/victory-native/src/components/victory-primitives/path.tsx @@ -1,9 +1,12 @@ import React from "react"; -import PropTypes from "prop-types"; -import { Path } from "react-native-svg"; +import { Path, PathProps } from "react-native-svg"; import { useGetNativeStyle } from "../../helpers/native-helpers"; +import { VictoryNativePrimitiveShapeProps } from "./types"; -const VPath = (props) => { +export type VictoryNativePathProps = PathProps & + VictoryNativePrimitiveShapeProps; + +const NativePath = (props: VictoryNativePathProps) => { const { "aria-label": accessibilityLabel, desc, style, ...rest } = props; const nativeStyle = useGetNativeStyle(style); return ( @@ -17,17 +20,4 @@ const VPath = (props) => { ); }; -export default VPath; - -VPath.propTypes = { - "aria-label": PropTypes.string, - className: PropTypes.string, - clipPath: PropTypes.string, - d: PropTypes.string, - desc: PropTypes.string, - events: PropTypes.object, - role: PropTypes.string, - shapeRendering: PropTypes.string, - style: PropTypes.object, - transform: PropTypes.string, -}; +export default NativePath; diff --git a/packages/victory-native/src/components/victory-primitives/point.js b/packages/victory-native/src/components/victory-primitives/point.js deleted file mode 100644 index 04f3f090f..000000000 --- a/packages/victory-native/src/components/victory-primitives/point.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; -import Path from "./path"; -import { Point } from "victory-core/es"; - -const NativePoint = (props) => } {...props} />; - -export default NativePoint; diff --git a/packages/victory-native/src/components/victory-primitives/point.tsx b/packages/victory-native/src/components/victory-primitives/point.tsx new file mode 100644 index 000000000..f83b380f2 --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/point.tsx @@ -0,0 +1,9 @@ +import React from "react"; +import Path from "./path"; +import { Point, PointProps } from "victory-core/es"; + +const NativePoint = (props: PointProps) => ( + } {...props} /> +); + +export default NativePoint; diff --git a/packages/victory-native/src/components/victory-primitives/rect.js b/packages/victory-native/src/components/victory-primitives/rect.js deleted file mode 100644 index a55bcabd4..000000000 --- a/packages/victory-native/src/components/victory-primitives/rect.js +++ /dev/null @@ -1,39 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import { Rect } from "react-native-svg"; -import { useGetNativeStyle } from "../../helpers/native-helpers"; - -const VRect = (props) => { - const { "aria-label": accessibilityLabel, desc, style, ...rest } = props; - const nativeStyle = useGetNativeStyle(style); - return ( - - ); -}; - -export default VRect; - -VRect.propTypes = { - "aria-label": PropTypes.string, - className: PropTypes.string, - clipPath: PropTypes.string, - desc: PropTypes.string, - events: PropTypes.object, - height: PropTypes.number, - role: PropTypes.string, - rx: PropTypes.number, - ry: PropTypes.number, - shapeRendering: PropTypes.string, - style: PropTypes.object, - transform: PropTypes.string, - width: PropTypes.number, - x: PropTypes.number, - y: PropTypes.number, -}; diff --git a/packages/victory-native/src/components/victory-primitives/rect.tsx b/packages/victory-native/src/components/victory-primitives/rect.tsx new file mode 100644 index 000000000..360bae296 --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/rect.tsx @@ -0,0 +1,24 @@ +import React from "react"; +import { Rect, RectProps } from "react-native-svg"; +import { useGetNativeStyle } from "../../helpers/native-helpers"; +import { VictoryNativePrimitiveShapeProps } from "./types"; + +export type VictoryNativeRectProps = RectProps & + VictoryNativePrimitiveShapeProps; + +const NativeRect = (props: VictoryNativeRectProps) => { + const { "aria-label": accessibilityLabel, desc, style, ...rest } = props; + const nativeStyle = useGetNativeStyle(style); + return ( + + ); +}; + +export default NativeRect; diff --git a/packages/victory-native/src/components/victory-primitives/slice.js b/packages/victory-native/src/components/victory-primitives/slice.js deleted file mode 100644 index 28024a123..000000000 --- a/packages/victory-native/src/components/victory-primitives/slice.js +++ /dev/null @@ -1,7 +0,0 @@ -import React from "react"; -import Path from "./path"; -import { Slice } from "victory-pie/es"; - -const NativeSlice = (props) => } {...props} />; - -export default NativeSlice; diff --git a/packages/victory-native/src/components/victory-primitives/slice.tsx b/packages/victory-native/src/components/victory-primitives/slice.tsx new file mode 100644 index 000000000..d49bea0b5 --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/slice.tsx @@ -0,0 +1,9 @@ +import React from "react"; +import Path from "./path"; +import { Slice, SliceProps } from "victory-pie/es"; + +const NativeSlice = (props: SliceProps) => ( + } {...props} /> +); + +export default NativeSlice; diff --git a/packages/victory-native/src/components/victory-primitives/text.js b/packages/victory-native/src/components/victory-primitives/text.tsx similarity index 50% rename from packages/victory-native/src/components/victory-primitives/text.js rename to packages/victory-native/src/components/victory-primitives/text.tsx index e8c1f63b0..d5d2f2f19 100644 --- a/packages/victory-native/src/components/victory-primitives/text.js +++ b/packages/victory-native/src/components/victory-primitives/text.tsx @@ -1,9 +1,15 @@ import React from "react"; -import PropTypes from "prop-types"; -import { Text } from "react-native-svg"; +import { Text, TextProps } from "react-native-svg"; import { useGetNativeStyle } from "../../helpers/native-helpers"; +import { VictoryNativePrimitiveShapeProps } from "./types"; -const VText = (props) => { +export interface VictoryNativeTextProps + extends TextProps, + VictoryNativePrimitiveShapeProps { + direction?: "inherit" | "rtl" | "ltr"; +} + +const NativeText = (props: VictoryNativeTextProps) => { const { "aria-label": accessibilityLabel, children, @@ -25,19 +31,4 @@ const VText = (props) => { ); }; -VText.propTypes = { - "aria-label": PropTypes.string, - children: PropTypes.node, - className: PropTypes.string, - desc: PropTypes.string, - direction: PropTypes.oneOf(["ltr", "rtl", "inherit"]), - dx: PropTypes.number, - dy: PropTypes.number, - events: PropTypes.object, - style: PropTypes.object, - transform: PropTypes.string, - x: PropTypes.number, - y: PropTypes.number, -}; - -export default VText; +export default NativeText; diff --git a/packages/victory-native/src/components/victory-primitives/tspan.js b/packages/victory-native/src/components/victory-primitives/tspan.js deleted file mode 100644 index cdd2c58e7..000000000 --- a/packages/victory-native/src/components/victory-primitives/tspan.js +++ /dev/null @@ -1,24 +0,0 @@ -import React from "react"; -import PropTypes from "prop-types"; -import { TSpan } from "react-native-svg"; -import { useGetNativeStyle } from "../../helpers/native-helpers"; - -const VTSpan = (props) => { - const { style, ...rest } = props; - const nativeStyle = useGetNativeStyle(style); - return ; -}; - -VTSpan.propTypes = { - children: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - className: PropTypes.string, - dx: PropTypes.number, - dy: PropTypes.number, - events: PropTypes.object, - style: PropTypes.object, - textAnchor: PropTypes.oneOf(["start", "middle", "end", "inherit"]), - x: PropTypes.number, - y: PropTypes.number, -}; - -export default VTSpan; diff --git a/packages/victory-native/src/components/victory-primitives/tspan.tsx b/packages/victory-native/src/components/victory-primitives/tspan.tsx new file mode 100644 index 000000000..7cac7468d --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/tspan.tsx @@ -0,0 +1,15 @@ +import React from "react"; +import { TSpan, TSpanProps } from "react-native-svg"; +import { useGetNativeStyle } from "../../helpers/native-helpers"; +import { VictoryNativePrimitiveShapeProps } from "./types"; + +export type VictoryNativeTSpanProps = TSpanProps & + VictoryNativePrimitiveShapeProps; + +const NativeTSpan = (props: VictoryNativeTSpanProps) => { + const { style, ...rest } = props; + const nativeStyle = useGetNativeStyle(style); + return ; +}; + +export default NativeTSpan; diff --git a/packages/victory-native/src/components/victory-primitives/types.ts b/packages/victory-native/src/components/victory-primitives/types.ts new file mode 100644 index 000000000..a1c552c1e --- /dev/null +++ b/packages/victory-native/src/components/victory-primitives/types.ts @@ -0,0 +1,9 @@ +import { VictoryPrimitiveShapeProps } from "victory-core/es"; + +export interface VictoryNativePrimitiveShapeProps + extends Pick< + VictoryPrimitiveShapeProps, + "className" | "events" | "role" | "shapeRendering" | "desc" | "style" + > { + "aria-label"?: string; +} diff --git a/packages/victory-native/src/components/victory-primitives/voronoi.js b/packages/victory-native/src/components/victory-primitives/voronoi.tsx similarity index 76% rename from packages/victory-native/src/components/victory-primitives/voronoi.js rename to packages/victory-native/src/components/victory-primitives/voronoi.tsx index 3cd52e17e..b30890faa 100644 --- a/packages/victory-native/src/components/victory-primitives/voronoi.js +++ b/packages/victory-native/src/components/victory-primitives/voronoi.tsx @@ -3,9 +3,9 @@ import Path from "./path"; import ClipPath from "./clip-path"; import Circle from "./circle"; import { G } from "react-native-svg"; -import { Voronoi } from "victory-voronoi/es"; +import { Voronoi, VoronoiProps } from "victory-voronoi/es"; -const NativeVoronoi = (props) => ( +const NativeVoronoi = (props: VoronoiProps) => ( } groupComponent={} diff --git a/packages/victory-native/src/components/victory-primitives/whisker.js b/packages/victory-native/src/components/victory-primitives/whisker.tsx similarity index 65% rename from packages/victory-native/src/components/victory-primitives/whisker.js rename to packages/victory-native/src/components/victory-primitives/whisker.tsx index 733f6e70e..582648fd2 100644 --- a/packages/victory-native/src/components/victory-primitives/whisker.js +++ b/packages/victory-native/src/components/victory-primitives/whisker.tsx @@ -1,9 +1,9 @@ import React from "react"; import Line from "./line"; import { G } from "react-native-svg"; -import { Whisker } from "victory-core/es"; +import { Whisker, WhiskerProps } from "victory-core/es"; -const NativeWhisker = (props) => ( +const NativeWhisker = (props: WhiskerProps) => ( } groupComponent={} {...props} /> ); From dd54aff98533c009589af16fe0a4b8f608330fb5 Mon Sep 17 00:00:00 2001 From: Kenan Date: Wed, 24 Jan 2024 15:49:00 +0000 Subject: [PATCH 02/14] WIP --- .../victory-clip-container.tsx | 2 +- packages/victory-native/package.json | 3 +- ...{components.test.js => components.test.ts} | 0 .../{victory-area.js => victory-area.tsx} | 5 +- .../{victory-axis.js => victory-axis.tsx} | 5 +- .../{victory-bar.js => victory-bar.tsx} | 5 +- ...victory-boxplot.js => victory-boxplot.tsx} | 5 +- ...candlestick.js => victory-candlestick.tsx} | 5 +- .../{victory-chart.js => victory-chart.tsx} | 4 +- ...ontainer.js => victory-clip-container.tsx} | 5 +- ...ctory-errorbar.js => victory-errorbar.tsx} | 5 +- .../{victory-group.js => victory-group.tsx} | 4 +- ...ory-histogram.js => victory-histogram.tsx} | 5 +- .../{victory-label.js => victory-label.tsx} | 4 +- .../{victory-legend.js => victory-legend.tsx} | 5 +- .../{victory-line.js => victory-line.tsx} | 5 +- .../{victory-pie.js => victory-pie.tsx} | 5 +- ...y-polar-axis.js => victory-polar-axis.tsx} | 9 +- ...victory-scatter.js => victory-scatter.tsx} | 5 +- .../{victory-stack.js => victory-stack.tsx} | 4 +- ...victory-voronoi.js => victory-voronoi.tsx} | 5 +- ...reate-container.js => create-container.ts} | 0 ...helpers.test.js => native-helpers.test.ts} | 0 .../{native-helpers.js => native-helpers.ts} | 0 ...zoom-helpers.js => native-zoom-helpers.ts} | 0 ...e-component.js => wrap-core-component.tsx} | 15 ++-- packages/victory-native/src/index.d.ts | 83 ------------------- .../victory-native/src/{index.js => index.ts} | 0 pnpm-lock.yaml | 2 + 29 files changed, 66 insertions(+), 129 deletions(-) rename packages/victory-native/src/{components.test.js => components.test.ts} (100%) rename packages/victory-native/src/components/{victory-area.js => victory-area.tsx} (91%) rename packages/victory-native/src/components/{victory-axis.js => victory-axis.tsx} (92%) rename packages/victory-native/src/components/{victory-bar.js => victory-bar.tsx} (90%) rename packages/victory-native/src/components/{victory-boxplot.js => victory-boxplot.tsx} (93%) rename packages/victory-native/src/components/{victory-candlestick.js => victory-candlestick.tsx} (90%) rename packages/victory-native/src/components/{victory-chart.js => victory-chart.tsx} (93%) rename packages/victory-native/src/components/{victory-clip-container.js => victory-clip-container.tsx} (88%) rename packages/victory-native/src/components/{victory-errorbar.js => victory-errorbar.tsx} (89%) rename packages/victory-native/src/components/{victory-group.js => victory-group.tsx} (88%) rename packages/victory-native/src/components/{victory-histogram.js => victory-histogram.tsx} (90%) rename packages/victory-native/src/components/{victory-label.js => victory-label.tsx} (78%) rename packages/victory-native/src/components/{victory-legend.js => victory-legend.tsx} (91%) rename packages/victory-native/src/components/{victory-line.js => victory-line.tsx} (91%) rename packages/victory-native/src/components/{victory-pie.js => victory-pie.tsx} (91%) rename packages/victory-native/src/components/{victory-polar-axis.js => victory-polar-axis.tsx} (83%) rename packages/victory-native/src/components/{victory-scatter.js => victory-scatter.tsx} (90%) rename packages/victory-native/src/components/{victory-stack.js => victory-stack.tsx} (88%) rename packages/victory-native/src/components/{victory-voronoi.js => victory-voronoi.tsx} (90%) rename packages/victory-native/src/helpers/{create-container.js => create-container.ts} (100%) rename packages/victory-native/src/helpers/{native-helpers.test.js => native-helpers.test.ts} (100%) rename packages/victory-native/src/helpers/{native-helpers.js => native-helpers.ts} (100%) rename packages/victory-native/src/helpers/{native-zoom-helpers.js => native-zoom-helpers.ts} (100%) rename packages/victory-native/src/helpers/{wrap-core-component.js => wrap-core-component.tsx} (62%) delete mode 100644 packages/victory-native/src/index.d.ts rename packages/victory-native/src/{index.js => index.ts} (100%) diff --git a/packages/victory-core/src/victory-clip-container/victory-clip-container.tsx b/packages/victory-core/src/victory-clip-container/victory-clip-container.tsx index db03e59b9..2fefc1274 100644 --- a/packages/victory-core/src/victory-clip-container/victory-clip-container.tsx +++ b/packages/victory-core/src/victory-clip-container/victory-clip-container.tsx @@ -73,7 +73,7 @@ export class VictoryClipContainer extends React.Component, groupComponent: , }; - private clipId: VictoryClipContainerProps["clipId"]; + public clipId: VictoryClipContainerProps["clipId"]; constructor(props: VictoryClipContainerProps) { super(props); diff --git a/packages/victory-native/package.json b/packages/victory-native/package.json index 5c5500511..63b4ba4a5 100644 --- a/packages/victory-native/package.json +++ b/packages/victory-native/package.json @@ -59,7 +59,8 @@ "@babel/core": "^7.18.9", "react-native": "^0.65.1", "react-native-gesture-handler": "^1.10.3", - "react-native-svg": "^12.4.3" + "react-native-svg": "^12.4.3", + "victory-native": "*" }, "peerDependencies": { "react": ">=16.6.0" diff --git a/packages/victory-native/src/components.test.js b/packages/victory-native/src/components.test.ts similarity index 100% rename from packages/victory-native/src/components.test.js rename to packages/victory-native/src/components.test.ts diff --git a/packages/victory-native/src/components/victory-area.js b/packages/victory-native/src/components/victory-area.tsx similarity index 91% rename from packages/victory-native/src/components/victory-area.js rename to packages/victory-native/src/components/victory-area.tsx index 2f2c3679e..05ae83311 100644 --- a/packages/victory-native/src/components/victory-area.js +++ b/packages/victory-native/src/components/victory-area.tsx @@ -10,13 +10,14 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryArea = wrapCoreComponent({ Component: VictoryArea, - defaultProps: Object.assign({}, VictoryArea.defaultProps, { + defaultProps: { + ...VictoryArea.defaultProps, dataComponent: , labelComponent: , containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryArea; diff --git a/packages/victory-native/src/components/victory-axis.js b/packages/victory-native/src/components/victory-axis.tsx similarity index 92% rename from packages/victory-native/src/components/victory-axis.js rename to packages/victory-native/src/components/victory-axis.tsx index 33cf1e8fc..9a9a1e144 100644 --- a/packages/victory-native/src/components/victory-axis.js +++ b/packages/victory-native/src/components/victory-axis.tsx @@ -9,7 +9,8 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryAxis = wrapCoreComponent({ Component: VictoryAxis, - defaultProps: Object.assign({}, VictoryAxis.defaultProps, { + defaultProps: { + ...VictoryAxis.defaultProps, axisComponent: , axisLabelComponent: , tickLabelComponent: , @@ -18,7 +19,7 @@ const NativeVictoryAxis = wrapCoreComponent({ containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryAxis; diff --git a/packages/victory-native/src/components/victory-bar.js b/packages/victory-native/src/components/victory-bar.tsx similarity index 90% rename from packages/victory-native/src/components/victory-bar.js rename to packages/victory-native/src/components/victory-bar.tsx index be8389c8d..bfd06ca94 100644 --- a/packages/victory-native/src/components/victory-bar.js +++ b/packages/victory-native/src/components/victory-bar.tsx @@ -9,13 +9,14 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryBar = wrapCoreComponent({ Component: VictoryBar, - defaultProps: Object.assign({}, VictoryBar.defaultProps, { + defaultProps: { + ...VictoryBar.defaultProps, dataComponent: , labelComponent: , containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryBar; diff --git a/packages/victory-native/src/components/victory-boxplot.js b/packages/victory-native/src/components/victory-boxplot.tsx similarity index 93% rename from packages/victory-native/src/components/victory-boxplot.js rename to packages/victory-native/src/components/victory-boxplot.tsx index 1690e4b26..ebb23ac10 100644 --- a/packages/victory-native/src/components/victory-boxplot.js +++ b/packages/victory-native/src/components/victory-boxplot.tsx @@ -11,7 +11,8 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryBoxPlot = wrapCoreComponent({ Component: VictoryBoxPlot, - defaultProps: Object.assign({}, VictoryBoxPlot.defaultProps, { + defaultProps: { + ...VictoryBoxPlot.defaultProps, maxComponent: , maxLabelComponent: , medianComponent: , @@ -25,7 +26,7 @@ const NativeVictoryBoxPlot = wrapCoreComponent({ containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryBoxPlot; diff --git a/packages/victory-native/src/components/victory-candlestick.js b/packages/victory-native/src/components/victory-candlestick.tsx similarity index 90% rename from packages/victory-native/src/components/victory-candlestick.js rename to packages/victory-native/src/components/victory-candlestick.tsx index a72f33b65..b06bdeee5 100644 --- a/packages/victory-native/src/components/victory-candlestick.js +++ b/packages/victory-native/src/components/victory-candlestick.tsx @@ -9,13 +9,14 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryCandlestick = wrapCoreComponent({ Component: VictoryCandlestick, - defaultProps: Object.assign({}, VictoryCandlestick.defaultProps, { + defaultProps: { + ...VictoryCandlestick.defaultProps, dataComponent: , labelComponent: , containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryCandlestick; diff --git a/packages/victory-native/src/components/victory-chart.js b/packages/victory-native/src/components/victory-chart.tsx similarity index 93% rename from packages/victory-native/src/components/victory-chart.js rename to packages/victory-native/src/components/victory-chart.tsx index 46e48ebe8..139db70c8 100644 --- a/packages/victory-native/src/components/victory-chart.js +++ b/packages/victory-native/src/components/victory-chart.tsx @@ -10,7 +10,7 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryChart = wrapCoreComponent({ Component: VictoryChart, - defaultProps: Object.assign({}, VictoryChart.defaultProps, { + defaultProps: { backgroundComponent: , containerComponent: , groupComponent: , @@ -24,7 +24,7 @@ const NativeVictoryChart = wrapCoreComponent({ }, prependDefaultAxes: true, width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryChart; diff --git a/packages/victory-native/src/components/victory-clip-container.js b/packages/victory-native/src/components/victory-clip-container.tsx similarity index 88% rename from packages/victory-native/src/components/victory-clip-container.js rename to packages/victory-native/src/components/victory-clip-container.tsx index 4a57505f5..7bd60bfb3 100644 --- a/packages/victory-native/src/components/victory-clip-container.js +++ b/packages/victory-native/src/components/victory-clip-container.tsx @@ -7,12 +7,13 @@ import { VictoryClipContainer } from "victory-core/es"; import { uniqueId } from "lodash"; export default class extends VictoryClipContainer { - static defaultProps = Object.assign({}, VictoryClipContainer.defaultProps, { + static defaultProps = { + ...VictoryClipContainer.defaultProps, groupComponent: , rectComponent: , clipPathComponent: , circleComponent: , - }); + }; // There seems to be a caching issue with clip paths. // This is required to make clip paths update when animating diff --git a/packages/victory-native/src/components/victory-errorbar.js b/packages/victory-native/src/components/victory-errorbar.tsx similarity index 89% rename from packages/victory-native/src/components/victory-errorbar.js rename to packages/victory-native/src/components/victory-errorbar.tsx index 2b0c09bf9..4646919d3 100644 --- a/packages/victory-native/src/components/victory-errorbar.js +++ b/packages/victory-native/src/components/victory-errorbar.tsx @@ -8,12 +8,13 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryErrorBar = wrapCoreComponent({ Component: VictoryErrorBar, - defaultProps: Object.assign({}, VictoryErrorBar.defaultProps, { + defaultProps: { + ...VictoryErrorBar.defaultProps, dataComponent: , containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryErrorBar; diff --git a/packages/victory-native/src/components/victory-group.js b/packages/victory-native/src/components/victory-group.tsx similarity index 88% rename from packages/victory-native/src/components/victory-group.js rename to packages/victory-native/src/components/victory-group.tsx index 79a7f7c9b..55d660f6c 100644 --- a/packages/victory-native/src/components/victory-group.js +++ b/packages/victory-native/src/components/victory-group.tsx @@ -7,11 +7,11 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryGroup = wrapCoreComponent({ Component: VictoryGroup, - defaultProps: Object.assign({}, VictoryGroup.defaultProps, { + defaultProps: { containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryGroup; diff --git a/packages/victory-native/src/components/victory-histogram.js b/packages/victory-native/src/components/victory-histogram.tsx similarity index 90% rename from packages/victory-native/src/components/victory-histogram.js rename to packages/victory-native/src/components/victory-histogram.tsx index 6e83f5a5a..bcdddf5f5 100644 --- a/packages/victory-native/src/components/victory-histogram.js +++ b/packages/victory-native/src/components/victory-histogram.tsx @@ -9,13 +9,14 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryHistogram = wrapCoreComponent({ Component: VictoryHistogram, - defaultProps: Object.assign({}, VictoryHistogram.defaultProps, { + defaultProps: { + ...VictoryHistogram.defaultProps, dataComponent: , labelComponent: , containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryHistogram; diff --git a/packages/victory-native/src/components/victory-label.js b/packages/victory-native/src/components/victory-label.tsx similarity index 78% rename from packages/victory-native/src/components/victory-label.js rename to packages/victory-native/src/components/victory-label.tsx index 9591de2fe..9767947a3 100644 --- a/packages/victory-native/src/components/victory-label.js +++ b/packages/victory-native/src/components/victory-label.tsx @@ -1,11 +1,11 @@ import React from "react"; -import { VictoryLabel } from "victory-core/es"; +import { VictoryLabel, VictoryLabelProps } from "victory-core/es"; import { G } from "react-native-svg"; import Text from "./victory-primitives/text"; import TSpan from "./victory-primitives/tspan"; import Rect from "./victory-primitives/rect"; -const NativeVictoryLabel = (props) => ( +const NativeVictoryLabel = (props: VictoryLabelProps) => ( } tspanComponent={} diff --git a/packages/victory-native/src/components/victory-legend.js b/packages/victory-native/src/components/victory-legend.tsx similarity index 91% rename from packages/victory-native/src/components/victory-legend.js rename to packages/victory-native/src/components/victory-legend.tsx index bcd2ae89e..a66a1185f 100644 --- a/packages/victory-native/src/components/victory-legend.js +++ b/packages/victory-native/src/components/victory-legend.tsx @@ -10,7 +10,8 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryLegend = wrapCoreComponent({ Component: VictoryLegend, - defaultProps: Object.assign({}, VictoryLegend.defaultProps, { + defaultProps: { + ...VictoryLegend.defaultProps, borderComponent: , containerComponent: , dataComponent: , @@ -18,7 +19,7 @@ const NativeVictoryLegend = wrapCoreComponent({ labelComponent: , titleComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryLegend; diff --git a/packages/victory-native/src/components/victory-line.js b/packages/victory-native/src/components/victory-line.tsx similarity index 91% rename from packages/victory-native/src/components/victory-line.js rename to packages/victory-native/src/components/victory-line.tsx index 45265ae65..3d0d6c40d 100644 --- a/packages/victory-native/src/components/victory-line.js +++ b/packages/victory-native/src/components/victory-line.tsx @@ -9,13 +9,14 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryLine = wrapCoreComponent({ Component: VictoryLine, - defaultProps: Object.assign({}, VictoryLine.defaultProps, { + defaultProps: { + ...VictoryLine.defaultProps, dataComponent: , labelComponent: , containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryLine; diff --git a/packages/victory-native/src/components/victory-pie.js b/packages/victory-native/src/components/victory-pie.tsx similarity index 91% rename from packages/victory-native/src/components/victory-pie.js rename to packages/victory-native/src/components/victory-pie.tsx index ead257215..e97f3d074 100644 --- a/packages/victory-native/src/components/victory-pie.js +++ b/packages/victory-native/src/components/victory-pie.tsx @@ -9,14 +9,15 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryPie = wrapCoreComponent({ Component: VictoryPie, - defaultProps: Object.assign({}, VictoryPie.defaultProps, { + defaultProps: { + ...VictoryPie.defaultProps, dataComponent: , labelComponent: , containerComponent: , groupComponent: , height: Dimensions.get("window").width, width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryPie; diff --git a/packages/victory-native/src/components/victory-polar-axis.js b/packages/victory-native/src/components/victory-polar-axis.tsx similarity index 83% rename from packages/victory-native/src/components/victory-polar-axis.js rename to packages/victory-native/src/components/victory-polar-axis.tsx index 09dc4b187..41170febf 100644 --- a/packages/victory-native/src/components/victory-polar-axis.js +++ b/packages/victory-native/src/components/victory-polar-axis.tsx @@ -10,18 +10,19 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryPolarAxis = wrapCoreComponent({ Component: VictoryPolarAxis, - defaultProps: Object.assign({}, VictoryPolarAxis.defaultProps, { + defaultProps: { + ...VictoryPolarAxis.defaultProps, axisComponent: , axisLabelComponent: , - circularAxisComponent: , - circularGridComponent: , + circularAxisComponent: , + circularGridComponent: , tickLabelComponent: , tickComponent: , gridComponent: , containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryPolarAxis; diff --git a/packages/victory-native/src/components/victory-scatter.js b/packages/victory-native/src/components/victory-scatter.tsx similarity index 90% rename from packages/victory-native/src/components/victory-scatter.js rename to packages/victory-native/src/components/victory-scatter.tsx index a92eda37b..233f3b41a 100644 --- a/packages/victory-native/src/components/victory-scatter.js +++ b/packages/victory-native/src/components/victory-scatter.tsx @@ -9,13 +9,14 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryScatter = wrapCoreComponent({ Component: VictoryScatter, - defaultProps: Object.assign({}, VictoryScatter.defaultProps, { + defaultProps: { + ...VictoryScatter.defaultProps, dataComponent: , labelComponent: , containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryScatter; diff --git a/packages/victory-native/src/components/victory-stack.js b/packages/victory-native/src/components/victory-stack.tsx similarity index 88% rename from packages/victory-native/src/components/victory-stack.js rename to packages/victory-native/src/components/victory-stack.tsx index 7033171a8..50cb65487 100644 --- a/packages/victory-native/src/components/victory-stack.js +++ b/packages/victory-native/src/components/victory-stack.tsx @@ -7,11 +7,11 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryStack = wrapCoreComponent({ Component: VictoryStack, - defaultProps: Object.assign({}, VictoryStack.defaultProps, { + defaultProps: { containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryStack; diff --git a/packages/victory-native/src/components/victory-voronoi.js b/packages/victory-native/src/components/victory-voronoi.tsx similarity index 90% rename from packages/victory-native/src/components/victory-voronoi.js rename to packages/victory-native/src/components/victory-voronoi.tsx index 9206c3551..467ffceb4 100644 --- a/packages/victory-native/src/components/victory-voronoi.js +++ b/packages/victory-native/src/components/victory-voronoi.tsx @@ -9,13 +9,14 @@ import { wrapCoreComponent } from "../helpers/wrap-core-component"; const NativeVictoryVoronoi = wrapCoreComponent({ Component: VictoryVoronoi, - defaultProps: Object.assign({}, VictoryVoronoi.defaultProps, { + defaultProps: { + ...VictoryVoronoi.defaultProps, dataComponent: , labelComponent: , containerComponent: , groupComponent: , width: Dimensions.get("window").width, - }), + }, }); export default NativeVictoryVoronoi; diff --git a/packages/victory-native/src/helpers/create-container.js b/packages/victory-native/src/helpers/create-container.ts similarity index 100% rename from packages/victory-native/src/helpers/create-container.js rename to packages/victory-native/src/helpers/create-container.ts diff --git a/packages/victory-native/src/helpers/native-helpers.test.js b/packages/victory-native/src/helpers/native-helpers.test.ts similarity index 100% rename from packages/victory-native/src/helpers/native-helpers.test.js rename to packages/victory-native/src/helpers/native-helpers.test.ts diff --git a/packages/victory-native/src/helpers/native-helpers.js b/packages/victory-native/src/helpers/native-helpers.ts similarity index 100% rename from packages/victory-native/src/helpers/native-helpers.js rename to packages/victory-native/src/helpers/native-helpers.ts diff --git a/packages/victory-native/src/helpers/native-zoom-helpers.js b/packages/victory-native/src/helpers/native-zoom-helpers.ts similarity index 100% rename from packages/victory-native/src/helpers/native-zoom-helpers.js rename to packages/victory-native/src/helpers/native-zoom-helpers.ts diff --git a/packages/victory-native/src/helpers/wrap-core-component.js b/packages/victory-native/src/helpers/wrap-core-component.tsx similarity index 62% rename from packages/victory-native/src/helpers/wrap-core-component.js rename to packages/victory-native/src/helpers/wrap-core-component.tsx index 49a58031c..db51fa78f 100644 --- a/packages/victory-native/src/helpers/wrap-core-component.js +++ b/packages/victory-native/src/helpers/wrap-core-component.tsx @@ -2,12 +2,15 @@ import React from "react"; /** * Wrap a core component, pass props through. - * @param {any} Component Core Component - * @param {object} defaultProps Default props for component - * @returns {React.FC} WrappedComponent Wrapped component (passes props through) */ -export const wrapCoreComponent = ({ Component, defaultProps }) => { - const WrappedComponent = (props) => { +export function wrapCoreComponent({ + Component, + defaultProps, +}: { + Component: React.JSXElementConstructor; + defaultProps: TProps; +}) { + const WrappedComponent = (props: TProps) => { const propsWithDefaults = { ...defaultProps, ...props }; return ; }; @@ -23,4 +26,4 @@ export const wrapCoreComponent = ({ Component, defaultProps }) => { } return WrappedComponent; -}; +} diff --git a/packages/victory-native/src/index.d.ts b/packages/victory-native/src/index.d.ts deleted file mode 100644 index 330dd82b3..000000000 --- a/packages/victory-native/src/index.d.ts +++ /dev/null @@ -1,83 +0,0 @@ -// TODO: Add missing type definitions for all import/export -// items that are commented out. - -export { - Arc, - Background, - Border, - Border as Box, - ClipPath, - LineSegment, - Whisker, - Circle, - Rect, - Line, - Path, - TSpan, - Text, - Point, - VictoryAnimation, - VictoryLabel, - VictoryTheme, - // VictoryTransition, - VictoryPortal, - // Portal, - VictoryClipContainer, - // addEvents, - // Collection, - // Data, - // DefaultTransitions, - // Domain, - // Events, - // Helpers, - // Log, - // PropTypes, - // Scale, - // Style, - TextSize, - // Transitions, - Selection, // LabelHelpers, // Axis, // Wrapper -} from "victory-core"; - -export { VictoryChart } from "victory-chart"; -export { VictoryGroup } from "victory-group"; -export { VictoryStack } from "victory-stack"; -export { VictoryPie, Slice } from "victory-pie"; -export { VictoryArea, Area } from "victory-area"; -export { VictoryBar, Bar } from "victory-bar"; -export { VictoryCandlestick, Candle } from "victory-candlestick"; -export { VictoryErrorBar, ErrorBar } from "victory-errorbar"; -export { VictoryLine, Curve } from "victory-line"; -export { VictoryHistogram } from "victory-histogram"; -export { VictoryScatter } from "victory-scatter"; -export { VictoryBoxPlot } from "victory-box-plot"; -export { Voronoi, VictoryVoronoi } from "victory-voronoi"; -export { VictoryTooltip, Flyout } from "victory-tooltip"; -export { VictoryLegend } from "victory-legend"; -export { VictoryAxis } from "victory-axis"; -export { VictoryPolarAxis } from "victory-polar-axis"; -export { default as VictoryBrushLine } from "./components/victory-brush-line"; - -export { default as VictoryContainer } from "./components/victory-container"; -// export { default as NativeHelpers } from "./helpers/native-helpers"; -// export { default as NativeZoomHelpers } from "./helpers/native-zoom-helpers"; -export { - zoomContainerMixin, - default as VictoryZoomContainer, -} from "./components/victory-zoom-container"; -export { - voronoiContainerMixin, - default as VictoryVoronoiContainer, -} from "./components/victory-voronoi-container"; -// export { -// selectionContainerMixin, default as VictorySelectionContainer -// } from "./components/victory-selection-container"; -export { - cursorContainerMixin, - default as VictoryCursorContainer, -} from "./components/victory-cursor-container"; -export { - brushContainerMixin, - default as VictoryBrushContainer, -} from "./components/victory-brush-container"; -export { createContainer } from "victory-create-container"; diff --git a/packages/victory-native/src/index.js b/packages/victory-native/src/index.ts similarity index 100% rename from packages/victory-native/src/index.js rename to packages/victory-native/src/index.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6e7b10054..e8bd958a5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -553,6 +553,7 @@ importers: victory-histogram: ^36.8.2 victory-legend: ^36.8.2 victory-line: ^36.8.2 + victory-native: '*' victory-pie: ^36.8.2 victory-polar-axis: ^36.8.2 victory-scatter: ^36.8.2 @@ -599,6 +600,7 @@ importers: react-native: 0.65.2_@babel+core@7.18.9 react-native-gesture-handler: 1.10.3 react-native-svg: 12.4.3_react-native@0.65.2 + victory-native: 'link:' packages/victory-pie: specifiers: From 77695796c7892cd016d1ce3dcfad98f58b5f14b6 Mon Sep 17 00:00:00 2001 From: Kenan Date: Thu, 25 Jan 2024 10:47:34 +0000 Subject: [PATCH 03/14] Add types to defaultProps --- packages/victory-area/src/victory-area.tsx | 2 +- packages/victory-box-plot/src/victory-box-plot.tsx | 2 +- packages/victory-errorbar/src/victory-errorbar.tsx | 2 +- packages/victory-polar-axis/src/victory-polar-axis.tsx | 2 +- packages/victory-scatter/src/victory-scatter.tsx | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/victory-area/src/victory-area.tsx b/packages/victory-area/src/victory-area.tsx index f65270ddc..5cde1a2a0 100644 --- a/packages/victory-area/src/victory-area.tsx +++ b/packages/victory-area/src/victory-area.tsx @@ -95,7 +95,7 @@ class VictoryAreaBase extends React.Component { ), }; - static defaultProps = { + static defaultProps: VictoryAreaProps = { containerComponent: , dataComponent: , groupComponent: , diff --git a/packages/victory-box-plot/src/victory-box-plot.tsx b/packages/victory-box-plot/src/victory-box-plot.tsx index aeebd4969..b27dd0241 100644 --- a/packages/victory-box-plot/src/victory-box-plot.tsx +++ b/packages/victory-box-plot/src/victory-box-plot.tsx @@ -283,7 +283,7 @@ class VictoryBoxPlotBase extends React.Component { whiskerWidth: PropTypes.number, }; - static defaultProps = { + static defaultProps: VictoryBoxPlotProps = { containerComponent: , data: defaultData, dataComponent: , diff --git a/packages/victory-errorbar/src/victory-errorbar.tsx b/packages/victory-errorbar/src/victory-errorbar.tsx index 2ed31695e..993f83dfa 100644 --- a/packages/victory-errorbar/src/victory-errorbar.tsx +++ b/packages/victory-errorbar/src/victory-errorbar.tsx @@ -102,7 +102,7 @@ class VictoryErrorBarBase extends React.Component { horizontal: PropTypes.bool, }; - static defaultProps = { + static defaultProps: VictoryErrorBarProps = { containerComponent: , data: defaultData, dataComponent: , diff --git a/packages/victory-polar-axis/src/victory-polar-axis.tsx b/packages/victory-polar-axis/src/victory-polar-axis.tsx index ff5b48bf8..f34bb197f 100644 --- a/packages/victory-polar-axis/src/victory-polar-axis.tsx +++ b/packages/victory-polar-axis/src/victory-polar-axis.tsx @@ -48,7 +48,7 @@ class VictoryPolarAxisBase extends React.Component { }, }; - static defaultProps = { + static defaultProps: VictoryPolarAxisProps = { axisComponent: , axisLabelComponent: , circularAxisComponent: , diff --git a/packages/victory-scatter/src/victory-scatter.tsx b/packages/victory-scatter/src/victory-scatter.tsx index b7e13fc6a..098714c0f 100644 --- a/packages/victory-scatter/src/victory-scatter.tsx +++ b/packages/victory-scatter/src/victory-scatter.tsx @@ -99,7 +99,7 @@ class VictoryScatterBase extends React.Component { ]), }; - static defaultProps = { + static defaultProps: VictoryScatterProps = { containerComponent: , dataComponent: , labelComponent: , From de4e9345a605ae50e7b0e1051680d58d24d641cd Mon Sep 17 00:00:00 2001 From: Kenan Date: Thu, 25 Jan 2024 15:25:33 +0000 Subject: [PATCH 04/14] convert more components --- .../src/victory-brush-line.tsx | 4 +- .../victory-container/victory-container.tsx | 6 +- .../components/victory-brush-container.d.ts | 19 ------- ...ntainer.js => victory-brush-container.tsx} | 46 ++++++++++++---- .../src/components/victory-brush-line.d.ts | 9 --- ...y-brush-line.js => victory-brush-line.tsx} | 55 +++++++++++++------ .../src/components/victory-container.d.ts | 13 ----- ...ory-container.js => victory-container.tsx} | 34 +++++++++--- .../components/victory-cursor-container.d.ts | 19 ------- ...tainer.js => victory-cursor-container.tsx} | 32 +++++++++-- .../victory-selection-container.d.ts | 19 ------- ...ner.js => victory-selection-container.tsx} | 46 ++++++++++++---- ...victory-tooltip.js => victory-tooltip.tsx} | 5 +- .../components/victory-voronoi-container.d.ts | 19 ------- ...ainer.js => victory-voronoi-container.tsx} | 32 +++++++++-- .../components/victory-zoom-container.d.ts | 19 ------- ...ontainer.js => victory-zoom-container.tsx} | 49 +++++++++++------ .../src/helpers/native-helpers.ts | 7 ++- 18 files changed, 235 insertions(+), 198 deletions(-) delete mode 100644 packages/victory-native/src/components/victory-brush-container.d.ts rename packages/victory-native/src/components/{victory-brush-container.js => victory-brush-container.tsx} (63%) delete mode 100644 packages/victory-native/src/components/victory-brush-line.d.ts rename packages/victory-native/src/components/{victory-brush-line.js => victory-brush-line.tsx} (75%) delete mode 100644 packages/victory-native/src/components/victory-container.d.ts rename packages/victory-native/src/components/{victory-container.js => victory-container.tsx} (86%) delete mode 100644 packages/victory-native/src/components/victory-cursor-container.d.ts rename packages/victory-native/src/components/{victory-cursor-container.js => victory-cursor-container.tsx} (64%) delete mode 100644 packages/victory-native/src/components/victory-selection-container.d.ts rename packages/victory-native/src/components/{victory-selection-container.js => victory-selection-container.tsx} (62%) rename packages/victory-native/src/components/{victory-tooltip.js => victory-tooltip.tsx} (96%) delete mode 100644 packages/victory-native/src/components/victory-voronoi-container.d.ts rename packages/victory-native/src/components/{victory-voronoi-container.js => victory-voronoi-container.tsx} (67%) delete mode 100644 packages/victory-native/src/components/victory-zoom-container.d.ts rename packages/victory-native/src/components/{victory-zoom-container.js => victory-zoom-container.tsx} (62%) diff --git a/packages/victory-brush-line/src/victory-brush-line.tsx b/packages/victory-brush-line/src/victory-brush-line.tsx index 700ceb52e..32a365ddd 100644 --- a/packages/victory-brush-line/src/victory-brush-line.tsx +++ b/packages/victory-brush-line/src/victory-brush-line.tsx @@ -174,7 +174,9 @@ const fallbackProps = { }, }; -export class VictoryBrushLine extends React.Component { +export class VictoryBrushLine< + T extends VictoryBrushLineProps, +> extends React.Component { static propTypes = { allowDrag: PropTypes.bool, allowDraw: PropTypes.bool, diff --git a/packages/victory-core/src/victory-container/victory-container.tsx b/packages/victory-core/src/victory-container/victory-container.tsx index d9494e929..6b499b8da 100644 --- a/packages/victory-core/src/victory-container/victory-container.tsx +++ b/packages/victory-core/src/victory-container/victory-container.tsx @@ -43,7 +43,9 @@ export interface VictoryContainerProps { width?: number; } -export class VictoryContainer extends React.Component { +export class VictoryContainer< + TProps extends VictoryContainerProps, +> extends React.Component { static displayName = "VictoryContainer"; static role = "container"; static propTypes = { @@ -96,7 +98,7 @@ export class VictoryContainer extends React.Component { private containerRef: HTMLElement; private shouldHandleWheel: boolean; - constructor(props: VictoryContainerProps) { + constructor(props: TProps) { super(props); this.containerId = !isObject(props) || props.containerId === undefined diff --git a/packages/victory-native/src/components/victory-brush-container.d.ts b/packages/victory-native/src/components/victory-brush-container.d.ts deleted file mode 100644 index 32760217a..000000000 --- a/packages/victory-native/src/components/victory-brush-container.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import React from "react"; -import { - VictoryBrushContainer, - VictoryBrushContainerProps, -} from "victory-brush-container"; - -export const brushContainerMixin: (base: any) => VictoryBrushContainer; - -export interface VictoryBrushContainerNativeProps - extends VictoryBrushContainerProps { - disableContainerEvents?: boolean; - onTouchEnd?: Function; - onTouchStart?: Function; -} - -export default class extends React.Component< - VictoryBrushContainerNativeProps, - any -> {} diff --git a/packages/victory-native/src/components/victory-brush-container.js b/packages/victory-native/src/components/victory-brush-container.tsx similarity index 63% rename from packages/victory-native/src/components/victory-brush-container.js rename to packages/victory-native/src/components/victory-brush-container.tsx index a2a14164e..826c5fcae 100644 --- a/packages/victory-native/src/components/victory-brush-container.js +++ b/packages/victory-native/src/components/victory-brush-container.tsx @@ -1,26 +1,46 @@ import React from "react"; -import PropTypes from "prop-types"; import { Rect } from "react-native-svg"; import { flow } from "lodash"; import { VictoryBrushContainer, BrushHelpers, brushContainerMixin as originalBrushMixin, + VictoryBrushContainerProps, } from "victory-brush-container"; import VictoryContainer from "./victory-container"; import NativeHelpers from "../helpers/native-helpers"; -// ensure the selection component get native styles -const RectWithStyle = ({ style, ...otherProps }) => ( - -); +export interface VictoryBrushContainerNativeProps + extends VictoryBrushContainerProps { + disableContainerEvents?: boolean; + onTouchStart?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; + onTouchEnd?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; +} -RectWithStyle.propTypes = { - style: PropTypes.object, -}; +// ensure the selection component get native styles +const RectWithStyle = ({ + style = {}, + ...otherProps +}: { + style?: Record; +}) => ; -const nativeBrushMixin = (base) => - class VictoryNativeBrushContainer extends base { +function nativeBrushMixin< + TBase extends React.ComponentClass, + TProps extends VictoryBrushContainerNativeProps, +>(Base: TBase) { + // @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'." + return class VictoryNativeBrushContainer extends Base { // eslint-disable-line max-len // assign native specific defaultProps over web `VictoryBrushContainer` defaultProps static defaultProps = { @@ -30,7 +50,7 @@ const nativeBrushMixin = (base) => }; // overrides all web events with native specific events - static defaultEvents = (props) => { + static defaultEvents = (props: TProps) => { return [ { target: "parent", @@ -59,9 +79,11 @@ const nativeBrushMixin = (base) => ]; }; }; +} const combinedMixin = flow(originalBrushMixin, nativeBrushMixin); -export const brushContainerMixin = (base) => combinedMixin(base); +export const brushContainerMixin = (base): VictoryBrushContainer => + combinedMixin(base); export default brushContainerMixin(VictoryContainer); diff --git a/packages/victory-native/src/components/victory-brush-line.d.ts b/packages/victory-native/src/components/victory-brush-line.d.ts deleted file mode 100644 index f2672df8e..000000000 --- a/packages/victory-native/src/components/victory-brush-line.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -import React from "react"; -import { VictoryBrushLineProps } from "victory-brush-line"; - -export interface VictoryNativeBrushLine extends VictoryBrushLineProps { - onTouchStart?: Function; - onTouchEnd?: Function; -} - -export default class extends React.Component {} diff --git a/packages/victory-native/src/components/victory-brush-line.js b/packages/victory-native/src/components/victory-brush-line.tsx similarity index 75% rename from packages/victory-native/src/components/victory-brush-line.js rename to packages/victory-native/src/components/victory-brush-line.tsx index 6c7b6721e..9f24e5f4b 100644 --- a/packages/victory-native/src/components/victory-brush-line.js +++ b/packages/victory-native/src/components/victory-brush-line.tsx @@ -1,47 +1,65 @@ import React from "react"; import { PanResponder } from "react-native"; import { G, Rect } from "react-native-svg"; -import PropTypes from "prop-types"; import { get } from "lodash"; -import { VictoryBrushLine } from "victory-brush-line/es"; +import { VictoryBrushLine, VictoryBrushLineProps } from "victory-brush-line/es"; import LineSegment from "./victory-primitives/line-segment"; import NativeHelpers from "../helpers/native-helpers"; // ensure the selection component get native styles import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const RectWithStyle = ({ style, ...otherProps }) => ( - -); +export interface VictoryNativeBrushLineProps extends VictoryBrushLineProps { + onTouchStart?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; + onTouchEnd?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; +} -RectWithStyle.propTypes = { - style: PropTypes.object, -}; +const RectWithStyle = ({ + style = {}, + ...otherProps +}: { + style?: Record; +}) => ; const yes = () => true; const no = () => false; const vblDefaultEvents = VictoryBrushLine.defaultEvents; -class VictoryNativeBrushLine extends VictoryBrushLine { +class VictoryNativeBrushLine< + TProps extends VictoryNativeBrushLineProps, +> extends VictoryBrushLine { static displayName = "VictoryNativeBrushLine"; - static defaultEvents = function (props) { + + defaultEvents = function (props) { if (props.disable) return undefined; // refer to web victory brush line to see the events we're aliasing here // we're just remapping the existing default events to their mobile equivalent handlers - const existingEventHandlers = vblDefaultEvents(props)[0].eventHandlers; + const existingEventHandlers = vblDefaultEvents(props)?.[0].eventHandlers; return [ { target: props.type, eventHandlers: { - onTouchStart: existingEventHandlers.onMouseDown, - onTouchMove: existingEventHandlers.onMouseMove, - onTouchEnd: existingEventHandlers.onMouseUp, + onTouchStart: existingEventHandlers?.onMouseDown, + onTouchMove: existingEventHandlers?.onMouseMove, + onTouchEnd: existingEventHandlers?.onMouseUp, }, }, ]; }; - constructor(props) { + panResponder: any; + + constructor(props: TProps) { super(props); this.panResponder = this.getResponder(); } @@ -101,7 +119,7 @@ class VictoryNativeBrushLine extends VictoryBrushLine { this.callOptionalEventCallback("onTouchEnd", evt); } - render() { + render(): React.ReactElement { return ( {this.renderLine(this.props)} @@ -115,13 +133,14 @@ class VictoryNativeBrushLine extends VictoryBrushLine { const NativeVictoryBrushLine = wrapCoreComponent({ Component: VictoryNativeBrushLine, - defaultProps: Object.assign({}, VictoryNativeBrushLine.defaultProps, { + defaultProps: { + ...VictoryNativeBrushLine.defaultProps, brushComponent: , brushAreaComponent: , handleComponent: , groupComponent: , lineComponent: , - }), + }, }); export default NativeVictoryBrushLine; diff --git a/packages/victory-native/src/components/victory-container.d.ts b/packages/victory-native/src/components/victory-container.d.ts deleted file mode 100644 index e714dde62..000000000 --- a/packages/victory-native/src/components/victory-container.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import React from "react"; -import { VictoryContainerProps } from "victory-core"; - -export interface VictoryContainerNativeProps extends VictoryContainerProps { - disableContainerEvents?: boolean; - onTouchEnd?: Function; - onTouchStart?: Function; -} - -export default class extends React.Component< - VictoryContainerNativeProps, - any -> {} diff --git a/packages/victory-native/src/components/victory-container.js b/packages/victory-native/src/components/victory-container.tsx similarity index 86% rename from packages/victory-native/src/components/victory-container.js rename to packages/victory-native/src/components/victory-container.tsx index f25b7a8b1..3e6764b20 100644 --- a/packages/victory-native/src/components/victory-container.js +++ b/packages/victory-native/src/components/victory-container.tsx @@ -3,20 +3,38 @@ import PropTypes from "prop-types"; import Svg, { Rect } from "react-native-svg"; import { assign, get } from "lodash"; import { View, PanResponder } from "react-native"; -import { VictoryContainer } from "victory-core/es"; +import { VictoryContainer, VictoryContainerProps } from "victory-core/es"; import NativeHelpers from "../helpers/native-helpers"; import Portal from "./victory-portal/portal"; const yes = () => true; const no = () => false; -export default class extends VictoryContainer { +export interface VictoryContainerNativeProps extends VictoryContainerProps { + disableContainerEvents?: boolean; + onTouchStart?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; + onTouchEnd?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; +} + +export default class extends VictoryContainer { static propTypes = assign({}, VictoryContainer.propTypes, { disableContainerEvents: PropTypes.bool, onTouchEnd: PropTypes.func, onTouchStart: PropTypes.func, }); + panResponder: any; + constructor(props) { super(props); this.panResponder = this.getResponder(); @@ -26,12 +44,12 @@ export default class extends VictoryContainer { let shouldBlockNativeResponder = no; if ( this.props && - (this.props.allowDrag || - this.props.allowDraw || - this.props.allowResize || - this.props.allowSelection || - this.props.allowPan || - this.props.allowZoom) + ((this.props as any).allowDrag || + (this.props as any).allowDraw || + (this.props as any).allowResize || + (this.props as any).allowSelection || + (this.props as any).allowPan || + (this.props as any).allowZoom) ) { shouldBlockNativeResponder = yes; } diff --git a/packages/victory-native/src/components/victory-cursor-container.d.ts b/packages/victory-native/src/components/victory-cursor-container.d.ts deleted file mode 100644 index 1067a5f72..000000000 --- a/packages/victory-native/src/components/victory-cursor-container.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import React from "react"; -import { - VictoryCursorContainer, - VictoryCursorContainerProps, -} from "victory-cursor-container"; - -export const cursorContainerMixin: (base: any) => VictoryCursorContainer; - -export interface VictoryCursorContainerNativeProps - extends VictoryCursorContainerProps { - disableContainerEvents?: boolean; - onTouchEnd?: Function; - onTouchStart?: Function; -} - -export default class extends React.Component< - VictoryCursorContainerNativeProps, - any -> {} diff --git a/packages/victory-native/src/components/victory-cursor-container.js b/packages/victory-native/src/components/victory-cursor-container.tsx similarity index 64% rename from packages/victory-native/src/components/victory-cursor-container.js rename to packages/victory-native/src/components/victory-cursor-container.tsx index 2954b9a99..e47fb90f1 100644 --- a/packages/victory-native/src/components/victory-cursor-container.js +++ b/packages/victory-native/src/components/victory-cursor-container.tsx @@ -4,13 +4,35 @@ import { VictoryCursorContainer, CursorHelpers, cursorContainerMixin as originalCursorMixin, + VictoryCursorContainerProps, } from "victory-cursor-container"; import VictoryLabel from "./victory-label"; import VictoryContainer from "./victory-container"; import LineSegment from "./victory-primitives/line-segment"; -const nativeCursorMixin = (base) => - class VictoryNativeCursorContainer extends base { +export interface VictoryCursorContainerNativeProps + extends VictoryCursorContainerProps { + disableContainerEvents?: boolean; + onTouchStart?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; + onTouchEnd?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; +} + +function nativeCursorMixin< + TBase extends React.ComponentClass, + TProps extends VictoryCursorContainerNativeProps, +>(Base: TBase) { + // @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'." + return class VictoryNativeCursorContainer extends Base { static displayName = "VictoryCursorContainer"; // assign native specific defaultProps over web `VictoryCursorContainer` defaultProps static defaultProps = { @@ -20,7 +42,7 @@ const nativeCursorMixin = (base) => }; // overrides all web events with native specific events - static defaultEvents = (props) => { + static defaultEvents = (props: TProps) => { return [ { target: "parent", @@ -45,9 +67,11 @@ const nativeCursorMixin = (base) => ]; }; }; +} const combinedMixin = flow(originalCursorMixin, nativeCursorMixin); -export const cursorContainerMixin = (base) => combinedMixin(base); +export const cursorContainerMixin = (base): VictoryCursorContainer => + combinedMixin(base); export default cursorContainerMixin(VictoryContainer); diff --git a/packages/victory-native/src/components/victory-selection-container.d.ts b/packages/victory-native/src/components/victory-selection-container.d.ts deleted file mode 100644 index 93ec6dcc1..000000000 --- a/packages/victory-native/src/components/victory-selection-container.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import React from "react"; -import { - VictorySelectionContainer, - VictorySelectionContainerProps, -} from "victory-selection-container"; - -export const selectionContainerMixin: (base: any) => VictorySelectionContainer; - -export interface VictorySelectionContainerNativeProps - extends VictorySelectionContainerProps { - disableContainerEvents?: boolean; - onTouchEnd?: Function; - onTouchStart?: Function; -} - -export default class extends React.Component< - VictorySelectionContainerNativeProps, - any -> {} diff --git a/packages/victory-native/src/components/victory-selection-container.js b/packages/victory-native/src/components/victory-selection-container.tsx similarity index 62% rename from packages/victory-native/src/components/victory-selection-container.js rename to packages/victory-native/src/components/victory-selection-container.tsx index e572f68d4..f1fbec625 100644 --- a/packages/victory-native/src/components/victory-selection-container.js +++ b/packages/victory-native/src/components/victory-selection-container.tsx @@ -1,26 +1,46 @@ import React from "react"; import { flow } from "lodash"; -import PropTypes from "prop-types"; import { Rect } from "react-native-svg"; import { VictorySelectionContainer, SelectionHelpers, selectionContainerMixin as originalSelectionMixin, + VictorySelectionContainerProps, } from "victory-selection-container"; import VictoryContainer from "./victory-container"; import NativeHelpers from "../helpers/native-helpers"; -// ensure the selection component get native styles -const DefaultSelectionComponent = ({ style, ...otherProps }) => ( - -); +export interface VictorySelectionContainerNativeProps + extends VictorySelectionContainerProps { + disableContainerEvents?: boolean; + onTouchStart?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; + onTouchEnd?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; +} -DefaultSelectionComponent.propTypes = { - style: PropTypes.object, -}; +// ensure the selection component get native styles +const DefaultSelectionComponent = ({ + style = {}, + ...otherProps +}: { + style?: Record; +}) => ; -const nativeSelectionMixin = (base) => - class VictoryNativeSelectionContainer extends base { +function nativeSelectionMixin< + TBase extends React.ComponentClass, + TProps extends VictorySelectionContainerNativeProps, +>(Base: TBase) { + // @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'." + return class VictoryNativeSelectionContainer extends Base { // eslint-disable-line max-len // assign native specific defaultProps over web `VictorySelectionContainer` defaultProps static defaultProps = { @@ -30,7 +50,7 @@ const nativeSelectionMixin = (base) => }; // overrides all web events with native specific events - static defaultEvents = (props) => { + static defaultEvents = (props: TProps) => { return [ { target: "parent", @@ -59,9 +79,11 @@ const nativeSelectionMixin = (base) => ]; }; }; +} const combinedMixin = flow(originalSelectionMixin, nativeSelectionMixin); -export const selectionContainerMixin = (base) => combinedMixin(base); +export const selectionContainerMixin = (base): VictorySelectionContainer => + combinedMixin(base); export default selectionContainerMixin(VictoryContainer); diff --git a/packages/victory-native/src/components/victory-tooltip.js b/packages/victory-native/src/components/victory-tooltip.tsx similarity index 96% rename from packages/victory-native/src/components/victory-tooltip.js rename to packages/victory-native/src/components/victory-tooltip.tsx index 648bccabc..02b9436f8 100644 --- a/packages/victory-native/src/components/victory-tooltip.js +++ b/packages/victory-native/src/components/victory-tooltip.tsx @@ -6,11 +6,12 @@ import VictoryPortal from "./victory-portal/victory-portal"; import Flyout from "./victory-primitives/flyout"; export default class extends VictoryTooltip { - static defaultProps = Object.assign({}, VictoryTooltip.defaultProps, { + static defaultProps = { + ...VictoryTooltip.defaultProps, labelComponent: , flyoutComponent: , groupComponent: , - }); + }; static defaultEvents = [ { diff --git a/packages/victory-native/src/components/victory-voronoi-container.d.ts b/packages/victory-native/src/components/victory-voronoi-container.d.ts deleted file mode 100644 index 5a2728218..000000000 --- a/packages/victory-native/src/components/victory-voronoi-container.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import React from "react"; -import { - VictoryVoronoiContainer, - VictoryVoronoiContainerProps, -} from "victory-voronoi-container"; - -export const voronoiContainerMixin: (base: any) => VictoryVoronoiContainer; - -export interface VictoryVoronoiContainerNativeProps - extends VictoryVoronoiContainerProps { - disableContainerEvents?: boolean; - onTouchEnd?: Function; - onTouchStart?: Function; -} - -export default class extends React.Component< - VictoryVoronoiContainerNativeProps, - any -> {} diff --git a/packages/victory-native/src/components/victory-voronoi-container.js b/packages/victory-native/src/components/victory-voronoi-container.tsx similarity index 67% rename from packages/victory-native/src/components/victory-voronoi-container.js rename to packages/victory-native/src/components/victory-voronoi-container.tsx index 4f6b42c4a..d50e2e5ec 100644 --- a/packages/victory-native/src/components/victory-voronoi-container.js +++ b/packages/victory-native/src/components/victory-voronoi-container.tsx @@ -3,14 +3,36 @@ import React from "react"; import { flow } from "lodash"; import { VictoryVoronoiContainer, + VictoryVoronoiContainerProps, VoronoiHelpers, voronoiContainerMixin as originalVoronoiMixin, } from "victory-voronoi-container"; import VictoryContainer from "./victory-container"; import VictoryTooltip from "./victory-tooltip"; -const nativeVoronoiMixin = (base) => - class VictoryNativeVoronoiContainer extends base { +export interface VictoryVoronoiContainerNativeProps + extends VictoryVoronoiContainerProps { + disableContainerEvents?: boolean; + onTouchStart?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; + onTouchEnd?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; +} + +function nativeVoronoiMixin< + TBase extends React.ComponentClass, + TProps extends VictoryVoronoiContainerNativeProps, +>(Base: TBase) { + // @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'." + return class VictoryNativeVoronoiContainer extends Base { // assign native specific defaultProps over web `VictoryVoronoiContainer` defaultProps static defaultProps = { ...VictoryVoronoiContainer.defaultProps, @@ -21,7 +43,7 @@ const nativeVoronoiMixin = (base) => }; // overrides all web events with native specific events - static defaultEvents = (props) => { + static defaultEvents = (props: TProps) => { return [ { target: "parent", @@ -56,9 +78,11 @@ const nativeVoronoiMixin = (base) => ]; }; }; +} const combinedMixin = flow(originalVoronoiMixin, nativeVoronoiMixin); -export const voronoiContainerMixin = (base) => combinedMixin(base); +export const voronoiContainerMixin = (base): VictoryVoronoiContainer => + combinedMixin(base); export default voronoiContainerMixin(VictoryContainer); diff --git a/packages/victory-native/src/components/victory-zoom-container.d.ts b/packages/victory-native/src/components/victory-zoom-container.d.ts deleted file mode 100644 index 168255470..000000000 --- a/packages/victory-native/src/components/victory-zoom-container.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import React from "react"; -import { - VictoryZoomContainer, - VictoryZoomContainerProps, -} from "victory-zoom-container"; - -export const zoomContainerMixin: (base: any) => VictoryZoomContainer; - -export interface VictoryZoomContainerNativeProps - extends VictoryZoomContainerProps { - disableContainerEvents?: boolean; - onTouchEnd?: Function; - onTouchStart?: Function; -} - -export default class extends React.Component< - VictoryZoomContainerNativeProps, - any -> {} diff --git a/packages/victory-native/src/components/victory-zoom-container.js b/packages/victory-native/src/components/victory-zoom-container.tsx similarity index 62% rename from packages/victory-native/src/components/victory-zoom-container.js rename to packages/victory-native/src/components/victory-zoom-container.tsx index d1ca27a5f..03d8e3195 100644 --- a/packages/victory-native/src/components/victory-zoom-container.js +++ b/packages/victory-native/src/components/victory-zoom-container.tsx @@ -1,15 +1,37 @@ -import React from "react"; +import React, { ComponentClass } from "react"; import { flow } from "lodash"; import VictoryContainer from "./victory-container"; import VictoryClipContainer from "./victory-clip-container"; import { VictoryZoomContainer, + VictoryZoomContainerProps, zoomContainerMixin as originalZoomMixin, } from "victory-zoom-container"; import NativeZoomHelpers from "../helpers/native-zoom-helpers"; -const nativeZoomMixin = (base) => - class VictoryNativeZoomContainer extends base { +export interface VictoryZoomContainerNativeProps + extends VictoryZoomContainerProps { + disableContainerEvents?: boolean; + onTouchStart?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; + onTouchEnd?: ( + evt?: any, + targetProps?: any, + eventKey?: any, + ctx?: any, + ) => void; +} + +function nativeZoomMixin< + TBase extends ComponentClass, + TProps extends VictoryZoomContainerNativeProps, +>(Base: TBase) { + // @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'." + return class VictoryNativeZoomContainer extends Base { // assign native specific defaultProps over web `VictoryZoomContainer` defaultProps static defaultProps = { ...VictoryZoomContainer.defaultProps, @@ -17,22 +39,17 @@ const nativeZoomMixin = (base) => }; // overrides all web events with native specific events - static defaultEvents = (props) => { + static defaultEvents = (props: TProps) => { const { disable } = props; return [ { target: "parent", eventHandlers: { // eslint-disable-next-line max-params - onTouchStart: (evt, targetProps, eventKey, ctx) => { + onTouchStart: (evt, targetProps) => { return disable ? {} - : NativeZoomHelpers.onTouchStart( - evt, - targetProps, - eventKey, - ctx, - ); + : NativeZoomHelpers.onTouchStart(evt, targetProps); }, // eslint-disable-next-line max-params onTouchMove: (evt, targetProps, eventKey, ctx) => { @@ -46,10 +63,8 @@ const nativeZoomMixin = (base) => ); }, // eslint-disable-next-line max-params - onTouchEnd: (evt, targetProps, eventKey, ctx) => { - return disable - ? {} - : NativeZoomHelpers.onTouchEnd(evt, targetProps, eventKey, ctx); + onTouchEnd: () => { + return disable ? {} : NativeZoomHelpers.onTouchEnd(); }, // eslint-disable-next-line max-params onTouchPinch: (evt, targetProps, eventKey, ctx) => { @@ -67,9 +82,11 @@ const nativeZoomMixin = (base) => ]; }; }; +} const combinedMixin = flow(originalZoomMixin, nativeZoomMixin); -export const zoomContainerMixin = (base) => combinedMixin(base); +export const zoomContainerMixin = (base): VictoryZoomContainer => + combinedMixin(base); export default zoomContainerMixin(VictoryContainer); diff --git a/packages/victory-native/src/helpers/native-helpers.ts b/packages/victory-native/src/helpers/native-helpers.ts index ce877e561..f00d1e8a6 100644 --- a/packages/victory-native/src/helpers/native-helpers.ts +++ b/packages/victory-native/src/helpers/native-helpers.ts @@ -6,7 +6,7 @@ import * as React from "react"; * @param {Array} keys: an array of keys to omit from the new object * @returns {Object} new object with same properties as originalObject */ -export const omit = (originalObject, keys = []) => { +export const omit = (originalObject, keys: string[] = []) => { // code based on babel's _objectWithoutProperties const newObject = {}; for (const key in originalObject) { @@ -33,7 +33,10 @@ const unsupportedAndStrokeProps = [ ...unsupportedProps, ]; -const getStyle = (style, extraOmitProperties) => { +const getStyle = ( + style: Record, + extraOmitProperties?: string[], +) => { if (!style) { return undefined; } From 16fc15b0e14902612b815a1b7c9bdcda2c2aa690 Mon Sep 17 00:00:00 2001 From: Kenan Date: Fri, 26 Jan 2024 09:51:53 +0000 Subject: [PATCH 05/14] Update exports and imports --- .../src/components/victory-area.tsx | 18 ++- .../src/components/victory-axis.tsx | 16 ++- .../src/components/victory-bar.tsx | 16 ++- .../src/components/victory-boxplot.tsx | 20 ++- .../components/victory-brush-container.tsx | 10 +- .../src/components/victory-brush-line.tsx | 15 +-- .../src/components/victory-candlestick.tsx | 16 ++- .../src/components/victory-chart.tsx | 16 ++- .../src/components/victory-clip-container.tsx | 12 +- .../src/components/victory-container.tsx | 11 +- .../components/victory-cursor-container.tsx | 14 +-- .../src/components/victory-errorbar.tsx | 14 +-- .../src/components/victory-group.tsx | 10 +- .../src/components/victory-histogram.tsx | 16 ++- .../src/components/victory-label.tsx | 19 +-- .../src/components/victory-legend.tsx | 18 ++- .../src/components/victory-line.tsx | 18 ++- .../src/components/victory-pie.tsx | 16 ++- .../src/components/victory-polar-axis.tsx | 18 ++- .../src/components/victory-portal/portal.tsx | 4 +- .../victory-portal/victory-portal.tsx | 4 +- .../src/components/victory-primitives/arc.tsx | 10 +- .../components/victory-primitives/area.tsx | 10 +- .../victory-primitives/background.tsx | 12 +- .../src/components/victory-primitives/bar.tsx | 10 +- .../components/victory-primitives/border.tsx | 10 +- .../components/victory-primitives/candle.tsx | 12 +- .../components/victory-primitives/circle.tsx | 8 +- .../victory-primitives/clip-path.tsx | 13 +- .../components/victory-primitives/curve.tsx | 10 +- .../victory-primitives/error-bar.tsx | 10 +- .../components/victory-primitives/flyout.tsx | 10 +- .../victory-primitives/line-segment.tsx | 13 +- .../components/victory-primitives/line.tsx | 8 +- .../components/victory-primitives/path.tsx | 8 +- .../components/victory-primitives/point.tsx | 10 +- .../components/victory-primitives/rect.tsx | 8 +- .../components/victory-primitives/slice.tsx | 10 +- .../components/victory-primitives/text.tsx | 10 +- .../components/victory-primitives/tspan.tsx | 8 +- .../components/victory-primitives/voronoi.tsx | 14 +-- .../components/victory-primitives/whisker.tsx | 10 +- .../src/components/victory-scatter.tsx | 16 ++- .../victory-selection-container.tsx | 11 +- .../src/components/victory-stack.tsx | 10 +- .../src/components/victory-tooltip.tsx | 12 +- .../components/victory-voronoi-container.tsx | 12 +- .../src/components/victory-voronoi.tsx | 16 ++- .../src/components/victory-zoom-container.tsx | 12 +- .../src/helpers/create-container.ts | 2 +- .../src/helpers/native-helpers.ts | 5 +- packages/victory-native/src/index.ts | 119 ++++++++---------- 52 files changed, 330 insertions(+), 400 deletions(-) diff --git a/packages/victory-native/src/components/victory-area.tsx b/packages/victory-native/src/components/victory-area.tsx index 05ae83311..53f827552 100644 --- a/packages/victory-native/src/components/victory-area.tsx +++ b/packages/victory-native/src/components/victory-area.tsx @@ -1,17 +1,17 @@ import React from "react"; import { Dimensions } from "react-native"; -import { VictoryArea } from "victory-area/es"; +import { VictoryArea as VictoryAreaBase } from "victory-area/es"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import VictoryClipContainer from "./victory-clip-container"; -import Area from "./victory-primitives/area"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { VictoryClipContainer } from "./victory-clip-container"; +import { Area } from "./victory-primitives/area"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryArea = wrapCoreComponent({ - Component: VictoryArea, +export const VictoryArea = wrapCoreComponent({ + Component: VictoryAreaBase, defaultProps: { - ...VictoryArea.defaultProps, + ...VictoryAreaBase.defaultProps, dataComponent: , labelComponent: , containerComponent: , @@ -19,5 +19,3 @@ const NativeVictoryArea = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryArea; diff --git a/packages/victory-native/src/components/victory-axis.tsx b/packages/victory-native/src/components/victory-axis.tsx index 9a9a1e144..a2f9409c3 100644 --- a/packages/victory-native/src/components/victory-axis.tsx +++ b/packages/victory-native/src/components/victory-axis.tsx @@ -1,16 +1,16 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import { VictoryAxis } from "victory-axis/es"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import LineSegment from "./victory-primitives/line-segment"; +import { VictoryAxis as VictoryAxisBase } from "victory-axis/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { LineSegment } from "./victory-primitives/line-segment"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryAxis = wrapCoreComponent({ - Component: VictoryAxis, +export const VictoryAxis = wrapCoreComponent({ + Component: VictoryAxisBase, defaultProps: { - ...VictoryAxis.defaultProps, + ...VictoryAxisBase.defaultProps, axisComponent: , axisLabelComponent: , tickLabelComponent: , @@ -21,5 +21,3 @@ const NativeVictoryAxis = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryAxis; diff --git a/packages/victory-native/src/components/victory-bar.tsx b/packages/victory-native/src/components/victory-bar.tsx index bfd06ca94..bc0eaa5ff 100644 --- a/packages/victory-native/src/components/victory-bar.tsx +++ b/packages/victory-native/src/components/victory-bar.tsx @@ -1,16 +1,16 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import Bar from "./victory-primitives/bar"; -import { VictoryBar } from "victory-bar/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { Bar } from "./victory-primitives/bar"; +import { VictoryBar as VictoryBarBase } from "victory-bar/es"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryBar = wrapCoreComponent({ - Component: VictoryBar, +export const VictoryBar = wrapCoreComponent({ + Component: VictoryBarBase, defaultProps: { - ...VictoryBar.defaultProps, + ...VictoryBarBase.defaultProps, dataComponent: , labelComponent: , containerComponent: , @@ -18,5 +18,3 @@ const NativeVictoryBar = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryBar; diff --git a/packages/victory-native/src/components/victory-boxplot.tsx b/packages/victory-native/src/components/victory-boxplot.tsx index ebb23ac10..a83e28b10 100644 --- a/packages/victory-native/src/components/victory-boxplot.tsx +++ b/packages/victory-native/src/components/victory-boxplot.tsx @@ -1,18 +1,18 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import { VictoryBoxPlot } from "victory-box-plot/es"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import Border from "./victory-primitives/border"; -import Whisker from "./victory-primitives/whisker"; -import LineSegment from "./victory-primitives/line-segment"; +import { VictoryBoxPlot as VictoryBoxPlotBase } from "victory-box-plot/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { Border } from "./victory-primitives/border"; +import { Whisker } from "./victory-primitives/whisker"; +import { LineSegment } from "./victory-primitives/line-segment"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryBoxPlot = wrapCoreComponent({ - Component: VictoryBoxPlot, +export const VictoryBoxPlot = wrapCoreComponent({ + Component: VictoryBoxPlotBase, defaultProps: { - ...VictoryBoxPlot.defaultProps, + ...VictoryBoxPlotBase.defaultProps, maxComponent: , maxLabelComponent: , medianComponent: , @@ -28,5 +28,3 @@ const NativeVictoryBoxPlot = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryBoxPlot; diff --git a/packages/victory-native/src/components/victory-brush-container.tsx b/packages/victory-native/src/components/victory-brush-container.tsx index 826c5fcae..4ba4e4b2f 100644 --- a/packages/victory-native/src/components/victory-brush-container.tsx +++ b/packages/victory-native/src/components/victory-brush-container.tsx @@ -2,12 +2,12 @@ import React from "react"; import { Rect } from "react-native-svg"; import { flow } from "lodash"; import { - VictoryBrushContainer, + VictoryBrushContainer as VictoryBrushContainerBase, BrushHelpers, brushContainerMixin as originalBrushMixin, VictoryBrushContainerProps, } from "victory-brush-container"; -import VictoryContainer from "./victory-container"; +import { VictoryContainer } from "./victory-container"; import NativeHelpers from "../helpers/native-helpers"; export interface VictoryBrushContainerNativeProps @@ -44,7 +44,7 @@ function nativeBrushMixin< // eslint-disable-line max-len // assign native specific defaultProps over web `VictoryBrushContainer` defaultProps static defaultProps = { - ...VictoryBrushContainer.defaultProps, + ...VictoryBrushContainerBase.defaultProps, brushComponent: , handleComponent: , }; @@ -83,7 +83,7 @@ function nativeBrushMixin< const combinedMixin = flow(originalBrushMixin, nativeBrushMixin); -export const brushContainerMixin = (base): VictoryBrushContainer => +export const brushContainerMixin = (base): VictoryBrushContainerBase => combinedMixin(base); -export default brushContainerMixin(VictoryContainer); +export const VictoryBrushContainer = brushContainerMixin(VictoryContainer); diff --git a/packages/victory-native/src/components/victory-brush-line.tsx b/packages/victory-native/src/components/victory-brush-line.tsx index 9f24e5f4b..53a4161d0 100644 --- a/packages/victory-native/src/components/victory-brush-line.tsx +++ b/packages/victory-native/src/components/victory-brush-line.tsx @@ -2,9 +2,12 @@ import React from "react"; import { PanResponder } from "react-native"; import { G, Rect } from "react-native-svg"; import { get } from "lodash"; -import { VictoryBrushLine, VictoryBrushLineProps } from "victory-brush-line/es"; +import { + VictoryBrushLine as VictoryBrushLineBase, + VictoryBrushLineProps, +} from "victory-brush-line/es"; -import LineSegment from "./victory-primitives/line-segment"; +import { LineSegment } from "./victory-primitives/line-segment"; import NativeHelpers from "../helpers/native-helpers"; // ensure the selection component get native styles import { wrapCoreComponent } from "../helpers/wrap-core-component"; @@ -33,11 +36,11 @@ const RectWithStyle = ({ const yes = () => true; const no = () => false; -const vblDefaultEvents = VictoryBrushLine.defaultEvents; +const vblDefaultEvents = VictoryBrushLineBase.defaultEvents; class VictoryNativeBrushLine< TProps extends VictoryNativeBrushLineProps, -> extends VictoryBrushLine { +> extends VictoryBrushLineBase { static displayName = "VictoryNativeBrushLine"; defaultEvents = function (props) { @@ -131,7 +134,7 @@ class VictoryNativeBrushLine< } } -const NativeVictoryBrushLine = wrapCoreComponent({ +export const VictoryBrushLine = wrapCoreComponent({ Component: VictoryNativeBrushLine, defaultProps: { ...VictoryNativeBrushLine.defaultProps, @@ -142,5 +145,3 @@ const NativeVictoryBrushLine = wrapCoreComponent({ lineComponent: , }, }); - -export default NativeVictoryBrushLine; diff --git a/packages/victory-native/src/components/victory-candlestick.tsx b/packages/victory-native/src/components/victory-candlestick.tsx index b06bdeee5..1c918afb1 100644 --- a/packages/victory-native/src/components/victory-candlestick.tsx +++ b/packages/victory-native/src/components/victory-candlestick.tsx @@ -1,16 +1,16 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import Candle from "./victory-primitives/candle"; -import { VictoryCandlestick } from "victory-candlestick/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { Candle } from "./victory-primitives/candle"; +import { VictoryCandlestick as VictoryCandlestickBase } from "victory-candlestick/es"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryCandlestick = wrapCoreComponent({ - Component: VictoryCandlestick, +export const VictoryCandlestick = wrapCoreComponent({ + Component: VictoryCandlestickBase, defaultProps: { - ...VictoryCandlestick.defaultProps, + ...VictoryCandlestickBase.defaultProps, dataComponent: , labelComponent: , containerComponent: , @@ -18,5 +18,3 @@ const NativeVictoryCandlestick = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryCandlestick; diff --git a/packages/victory-native/src/components/victory-chart.tsx b/packages/victory-native/src/components/victory-chart.tsx index 139db70c8..bf3286525 100644 --- a/packages/victory-native/src/components/victory-chart.tsx +++ b/packages/victory-native/src/components/victory-chart.tsx @@ -1,15 +1,15 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import { VictoryChart } from "victory-chart/es"; -import Background from "./victory-primitives/background"; -import VictoryAxis from "./victory-axis"; -import VictoryPolarAxis from "./victory-polar-axis"; -import VictoryContainer from "./victory-container"; +import { VictoryChart as VictoryChartBase } from "victory-chart/es"; +import { Background } from "./victory-primitives/background"; +import { VictoryAxis } from "./victory-axis"; +import { VictoryPolarAxis } from "./victory-polar-axis"; +import { VictoryContainer } from "./victory-container"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryChart = wrapCoreComponent({ - Component: VictoryChart, +export const VictoryChart = wrapCoreComponent({ + Component: VictoryChartBase, defaultProps: { backgroundComponent: , containerComponent: , @@ -26,5 +26,3 @@ const NativeVictoryChart = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryChart; diff --git a/packages/victory-native/src/components/victory-clip-container.tsx b/packages/victory-native/src/components/victory-clip-container.tsx index 7bd60bfb3..a41b5f7fc 100644 --- a/packages/victory-native/src/components/victory-clip-container.tsx +++ b/packages/victory-native/src/components/victory-clip-container.tsx @@ -1,14 +1,14 @@ import React from "react"; import { G } from "react-native-svg"; -import Circle from "./victory-primitives/circle"; -import Rect from "./victory-primitives/rect"; -import ClipPath from "./victory-primitives/clip-path"; -import { VictoryClipContainer } from "victory-core/es"; +import { Circle } from "./victory-primitives/circle"; +import { Rect } from "./victory-primitives/rect"; +import { ClipPath } from "./victory-primitives/clip-path"; +import { VictoryClipContainer as VictoryClipContainerBase } from "victory-core/es"; import { uniqueId } from "lodash"; -export default class extends VictoryClipContainer { +export class VictoryClipContainer extends VictoryClipContainerBase { static defaultProps = { - ...VictoryClipContainer.defaultProps, + ...VictoryClipContainerBase.defaultProps, groupComponent: , rectComponent: , clipPathComponent: , diff --git a/packages/victory-native/src/components/victory-container.tsx b/packages/victory-native/src/components/victory-container.tsx index 3e6764b20..5f1aff080 100644 --- a/packages/victory-native/src/components/victory-container.tsx +++ b/packages/victory-native/src/components/victory-container.tsx @@ -3,9 +3,12 @@ import PropTypes from "prop-types"; import Svg, { Rect } from "react-native-svg"; import { assign, get } from "lodash"; import { View, PanResponder } from "react-native"; -import { VictoryContainer, VictoryContainerProps } from "victory-core/es"; +import { + VictoryContainer as VictoryContainerBase, + VictoryContainerProps, +} from "victory-core/es"; import NativeHelpers from "../helpers/native-helpers"; -import Portal from "./victory-portal/portal"; +import { Portal } from "./victory-portal/portal"; const yes = () => true; const no = () => false; @@ -26,8 +29,8 @@ export interface VictoryContainerNativeProps extends VictoryContainerProps { ) => void; } -export default class extends VictoryContainer { - static propTypes = assign({}, VictoryContainer.propTypes, { +export class VictoryContainer extends VictoryContainerBase { + static propTypes = assign({}, VictoryContainerBase.propTypes, { disableContainerEvents: PropTypes.bool, onTouchEnd: PropTypes.func, onTouchStart: PropTypes.func, diff --git a/packages/victory-native/src/components/victory-cursor-container.tsx b/packages/victory-native/src/components/victory-cursor-container.tsx index e47fb90f1..f6c739701 100644 --- a/packages/victory-native/src/components/victory-cursor-container.tsx +++ b/packages/victory-native/src/components/victory-cursor-container.tsx @@ -1,14 +1,14 @@ import React from "react"; import { flow } from "lodash"; import { - VictoryCursorContainer, + VictoryCursorContainer as VictoryCursorContainerBase, CursorHelpers, cursorContainerMixin as originalCursorMixin, VictoryCursorContainerProps, } from "victory-cursor-container"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import LineSegment from "./victory-primitives/line-segment"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { LineSegment } from "./victory-primitives/line-segment"; export interface VictoryCursorContainerNativeProps extends VictoryCursorContainerProps { @@ -36,7 +36,7 @@ function nativeCursorMixin< static displayName = "VictoryCursorContainer"; // assign native specific defaultProps over web `VictoryCursorContainer` defaultProps static defaultProps = { - ...VictoryCursorContainer.defaultProps, + ...VictoryCursorContainerBase.defaultProps, cursorLabelComponent: , cursorComponent: , }; @@ -71,7 +71,7 @@ function nativeCursorMixin< const combinedMixin = flow(originalCursorMixin, nativeCursorMixin); -export const cursorContainerMixin = (base): VictoryCursorContainer => +export const cursorContainerMixin = (base): VictoryCursorContainerBase => combinedMixin(base); -export default cursorContainerMixin(VictoryContainer); +export const VictoryCursorContainer = cursorContainerMixin(VictoryContainer); diff --git a/packages/victory-native/src/components/victory-errorbar.tsx b/packages/victory-native/src/components/victory-errorbar.tsx index 4646919d3..1b429ce0e 100644 --- a/packages/victory-native/src/components/victory-errorbar.tsx +++ b/packages/victory-native/src/components/victory-errorbar.tsx @@ -1,20 +1,18 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import { VictoryErrorBar } from "victory-errorbar/es"; -import VictoryContainer from "./victory-container"; -import ErrorBar from "./victory-primitives/error-bar"; +import { VictoryErrorBar as VictoryErrorBarBase } from "victory-errorbar/es"; +import { VictoryContainer } from "./victory-container"; +import { ErrorBar } from "./victory-primitives/error-bar"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryErrorBar = wrapCoreComponent({ - Component: VictoryErrorBar, +export const VictoryErrorBar = wrapCoreComponent({ + Component: VictoryErrorBarBase, defaultProps: { - ...VictoryErrorBar.defaultProps, + ...VictoryErrorBarBase.defaultProps, dataComponent: , containerComponent: , groupComponent: , width: Dimensions.get("window").width, }, }); - -export default NativeVictoryErrorBar; diff --git a/packages/victory-native/src/components/victory-group.tsx b/packages/victory-native/src/components/victory-group.tsx index 55d660f6c..efae70c97 100644 --- a/packages/victory-native/src/components/victory-group.tsx +++ b/packages/victory-native/src/components/victory-group.tsx @@ -1,17 +1,15 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import { VictoryGroup } from "victory-group/es"; -import VictoryContainer from "./victory-container"; +import { VictoryGroup as VictoryGroupBase } from "victory-group/es"; +import { VictoryContainer } from "./victory-container"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryGroup = wrapCoreComponent({ - Component: VictoryGroup, +export const VictoryGroup = wrapCoreComponent({ + Component: VictoryGroupBase, defaultProps: { containerComponent: , groupComponent: , width: Dimensions.get("window").width, }, }); - -export default NativeVictoryGroup; diff --git a/packages/victory-native/src/components/victory-histogram.tsx b/packages/victory-native/src/components/victory-histogram.tsx index bcdddf5f5..5c178ef4f 100644 --- a/packages/victory-native/src/components/victory-histogram.tsx +++ b/packages/victory-native/src/components/victory-histogram.tsx @@ -1,16 +1,16 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import Bar from "./victory-primitives/bar"; -import { VictoryHistogram } from "victory-histogram/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { Bar } from "./victory-primitives/bar"; +import { VictoryHistogram as VictoryHistogramBase } from "victory-histogram/es"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryHistogram = wrapCoreComponent({ - Component: VictoryHistogram, +export const VictoryHistogram = wrapCoreComponent({ + Component: VictoryHistogramBase, defaultProps: { - ...VictoryHistogram.defaultProps, + ...VictoryHistogramBase.defaultProps, dataComponent: , labelComponent: , containerComponent: , @@ -18,5 +18,3 @@ const NativeVictoryHistogram = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryHistogram; diff --git a/packages/victory-native/src/components/victory-label.tsx b/packages/victory-native/src/components/victory-label.tsx index 9767947a3..0e27c7aed 100644 --- a/packages/victory-native/src/components/victory-label.tsx +++ b/packages/victory-native/src/components/victory-label.tsx @@ -1,12 +1,15 @@ import React from "react"; -import { VictoryLabel, VictoryLabelProps } from "victory-core/es"; +import { + VictoryLabel as VictoryLabelBase, + VictoryLabelProps, +} from "victory-core/es"; import { G } from "react-native-svg"; -import Text from "./victory-primitives/text"; -import TSpan from "./victory-primitives/tspan"; -import Rect from "./victory-primitives/rect"; +import { Text } from "./victory-primitives/text"; +import { TSpan } from "./victory-primitives/tspan"; +import { Rect } from "./victory-primitives/rect"; -const NativeVictoryLabel = (props: VictoryLabelProps) => ( - ( + } tspanComponent={} backgroundComponent={} @@ -15,6 +18,4 @@ const NativeVictoryLabel = (props: VictoryLabelProps) => ( /> ); -NativeVictoryLabel.role = VictoryLabel.role; - -export default NativeVictoryLabel; +VictoryLabel.role = VictoryLabelBase.role; diff --git a/packages/victory-native/src/components/victory-legend.tsx b/packages/victory-native/src/components/victory-legend.tsx index a66a1185f..388b112fc 100644 --- a/packages/victory-native/src/components/victory-legend.tsx +++ b/packages/victory-native/src/components/victory-legend.tsx @@ -1,17 +1,17 @@ import React from "react"; import { G } from "react-native-svg"; -import { VictoryLegend } from "victory-legend/es"; +import { VictoryLegend as VictoryLegendBase } from "victory-legend/es"; import { Dimensions } from "react-native"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import Point from "./victory-primitives/point"; -import Border from "./victory-primitives/border"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { Point } from "./victory-primitives/point"; +import { Border } from "./victory-primitives/border"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryLegend = wrapCoreComponent({ - Component: VictoryLegend, +export const VictoryLegend = wrapCoreComponent({ + Component: VictoryLegendBase, defaultProps: { - ...VictoryLegend.defaultProps, + ...VictoryLegendBase.defaultProps, borderComponent: , containerComponent: , dataComponent: , @@ -21,5 +21,3 @@ const NativeVictoryLegend = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryLegend; diff --git a/packages/victory-native/src/components/victory-line.tsx b/packages/victory-native/src/components/victory-line.tsx index 3d0d6c40d..3daa9dbfb 100644 --- a/packages/victory-native/src/components/victory-line.tsx +++ b/packages/victory-native/src/components/victory-line.tsx @@ -1,16 +1,16 @@ import React from "react"; import { Dimensions } from "react-native"; -import { VictoryLine } from "victory-line/es"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import VictoryClipContainer from "./victory-clip-container"; -import Curve from "./victory-primitives/curve"; +import { VictoryLine as VictoryLineBase } from "victory-line/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { VictoryClipContainer } from "./victory-clip-container"; +import { Curve } from "./victory-primitives/curve"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryLine = wrapCoreComponent({ - Component: VictoryLine, +export const VictoryLine = wrapCoreComponent({ + Component: VictoryLineBase, defaultProps: { - ...VictoryLine.defaultProps, + ...VictoryLineBase.defaultProps, dataComponent: , labelComponent: , containerComponent: , @@ -18,5 +18,3 @@ const NativeVictoryLine = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryLine; diff --git a/packages/victory-native/src/components/victory-pie.tsx b/packages/victory-native/src/components/victory-pie.tsx index e97f3d074..bb04b0427 100644 --- a/packages/victory-native/src/components/victory-pie.tsx +++ b/packages/victory-native/src/components/victory-pie.tsx @@ -1,16 +1,16 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import { VictoryPie } from "victory-pie/es"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import Slice from "./victory-primitives/slice"; +import { VictoryPie as VictoryPieBase } from "victory-pie/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { Slice } from "./victory-primitives/slice"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryPie = wrapCoreComponent({ - Component: VictoryPie, +export const VictoryPie = wrapCoreComponent({ + Component: VictoryPieBase, defaultProps: { - ...VictoryPie.defaultProps, + ...VictoryPieBase.defaultProps, dataComponent: , labelComponent: , containerComponent: , @@ -19,5 +19,3 @@ const NativeVictoryPie = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryPie; diff --git a/packages/victory-native/src/components/victory-polar-axis.tsx b/packages/victory-native/src/components/victory-polar-axis.tsx index 41170febf..4702664ef 100644 --- a/packages/victory-native/src/components/victory-polar-axis.tsx +++ b/packages/victory-native/src/components/victory-polar-axis.tsx @@ -1,17 +1,17 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import { VictoryPolarAxis } from "victory-polar-axis/es"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import Arc from "./victory-primitives/arc"; -import LineSegment from "./victory-primitives/line-segment"; +import { VictoryPolarAxis as VictoryPolarAxisBase } from "victory-polar-axis/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { Arc } from "./victory-primitives/arc"; +import { LineSegment } from "./victory-primitives/line-segment"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryPolarAxis = wrapCoreComponent({ - Component: VictoryPolarAxis, +export const VictoryPolarAxis = wrapCoreComponent({ + Component: VictoryPolarAxisBase, defaultProps: { - ...VictoryPolarAxis.defaultProps, + ...VictoryPolarAxisBase.defaultProps, axisComponent: , axisLabelComponent: , circularAxisComponent: , @@ -24,5 +24,3 @@ const NativeVictoryPolarAxis = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryPolarAxis; diff --git a/packages/victory-native/src/components/victory-portal/portal.tsx b/packages/victory-native/src/components/victory-portal/portal.tsx index 94ed8bfd7..ac1920c65 100644 --- a/packages/victory-native/src/components/victory-portal/portal.tsx +++ b/packages/victory-native/src/components/victory-portal/portal.tsx @@ -1,8 +1,8 @@ import React from "react"; import Svg from "react-native-svg"; -import { Portal } from "victory-core/es"; +import { Portal as PortalBase } from "victory-core/es"; -export default class extends Portal { +export class Portal extends PortalBase { render() { return {this.getChildren()}; } diff --git a/packages/victory-native/src/components/victory-portal/victory-portal.tsx b/packages/victory-native/src/components/victory-portal/victory-portal.tsx index 168f2b6f9..392c8bd9b 100644 --- a/packages/victory-native/src/components/victory-portal/victory-portal.tsx +++ b/packages/victory-native/src/components/victory-portal/victory-portal.tsx @@ -1,8 +1,8 @@ import React from "react"; import { G } from "react-native-svg"; -import { VictoryPortal } from "victory-core/es"; +import { VictoryPortal as VictoryPortalBase } from "victory-core/es"; -export default class extends VictoryPortal { +export class VictoryPortal extends VictoryPortalBase { renderPortal(child) { if (this.renderInPlace) { return child || ; diff --git a/packages/victory-native/src/components/victory-primitives/arc.tsx b/packages/victory-native/src/components/victory-primitives/arc.tsx index 8d6268d03..57eac76d4 100644 --- a/packages/victory-native/src/components/victory-primitives/arc.tsx +++ b/packages/victory-native/src/components/victory-primitives/arc.tsx @@ -1,9 +1,7 @@ import React from "react"; -import Path from "./path"; -import { Arc, ArcProps } from "victory-core/es"; +import { Path } from "./path"; +import { Arc as ArcBase, ArcProps } from "victory-core/es"; -const NativeArc = (props: ArcProps) => ( - } {...props} /> +export const Arc = (props: ArcProps) => ( + } {...props} /> ); - -export default NativeArc; diff --git a/packages/victory-native/src/components/victory-primitives/area.tsx b/packages/victory-native/src/components/victory-primitives/area.tsx index c84ee0d88..9ec54ee39 100644 --- a/packages/victory-native/src/components/victory-primitives/area.tsx +++ b/packages/victory-native/src/components/victory-primitives/area.tsx @@ -1,10 +1,8 @@ import React from "react"; -import Path from "./path"; +import { Path } from "./path"; import { G } from "react-native-svg"; -import { Area, AreaProps } from "victory-area/es"; +import { Area as AreaBase, AreaProps } from "victory-area/es"; -const NativeArea = (props: AreaProps) => ( - } groupComponent={} {...props} /> +export const Area = (props: AreaProps) => ( + } groupComponent={} {...props} /> ); - -export default NativeArea; diff --git a/packages/victory-native/src/components/victory-primitives/background.tsx b/packages/victory-native/src/components/victory-primitives/background.tsx index 5218cbe6d..8aae73f4c 100644 --- a/packages/victory-native/src/components/victory-primitives/background.tsx +++ b/packages/victory-native/src/components/victory-primitives/background.tsx @@ -1,14 +1,12 @@ import React from "react"; -import Rect from "./rect"; -import Circle from "./circle"; -import { Background, BackgroundProps } from "victory-core/es"; +import { Rect } from "./rect"; +import { Circle } from "./circle"; +import { Background as BackgroundBase, BackgroundProps } from "victory-core/es"; -const NativeBackground = (props: BackgroundProps) => ( - ( + } rectComponent={} {...props} /> ); - -export default NativeBackground; diff --git a/packages/victory-native/src/components/victory-primitives/bar.tsx b/packages/victory-native/src/components/victory-primitives/bar.tsx index 904354409..4a93249d2 100644 --- a/packages/victory-native/src/components/victory-primitives/bar.tsx +++ b/packages/victory-native/src/components/victory-primitives/bar.tsx @@ -1,9 +1,7 @@ import React from "react"; -import Path from "./path"; -import { Bar, BarProps } from "victory-bar/es"; +import { Path } from "./path"; +import { Bar as BarBase, BarProps } from "victory-bar/es"; -const NativeBar = (props: BarProps) => ( - } {...props} /> +export const Bar = (props: BarProps) => ( + } {...props} /> ); - -export default NativeBar; diff --git a/packages/victory-native/src/components/victory-primitives/border.tsx b/packages/victory-native/src/components/victory-primitives/border.tsx index a1639e63e..e13bb141d 100644 --- a/packages/victory-native/src/components/victory-primitives/border.tsx +++ b/packages/victory-native/src/components/victory-primitives/border.tsx @@ -1,9 +1,9 @@ import React from "react"; -import Rect from "./rect"; -import { Border, BorderProps } from "victory-core/es"; +import { Rect } from "./rect"; +import { Border as BorderBase, BorderProps } from "victory-core/es"; -const NativeBorder = (props: BorderProps) => ( - } {...props} /> +export const Border = (props: BorderProps) => ( + } {...props} /> ); -export default NativeBorder; +export const Box = Border; diff --git a/packages/victory-native/src/components/victory-primitives/candle.tsx b/packages/victory-native/src/components/victory-primitives/candle.tsx index cdbf83b9b..934330fe2 100644 --- a/packages/victory-native/src/components/victory-primitives/candle.tsx +++ b/packages/victory-native/src/components/victory-primitives/candle.tsx @@ -1,16 +1,14 @@ import React from "react"; -import Line from "./line"; -import Rect from "./rect"; +import { Line } from "./line"; +import { Rect } from "./rect"; import { G } from "react-native-svg"; -import { Candle, CandleProps } from "victory-candlestick/es"; +import { Candle as CandleBase, CandleProps } from "victory-candlestick/es"; -const NativeCandle = (props: CandleProps) => ( - ( + } rectComponent={} groupComponent={} {...props} /> ); - -export default NativeCandle; diff --git a/packages/victory-native/src/components/victory-primitives/circle.tsx b/packages/victory-native/src/components/victory-primitives/circle.tsx index 4a00ba3af..57f9f806a 100644 --- a/packages/victory-native/src/components/victory-primitives/circle.tsx +++ b/packages/victory-native/src/components/victory-primitives/circle.tsx @@ -1,16 +1,16 @@ import React from "react"; -import { Circle, CircleProps } from "react-native-svg"; +import { Circle as CircleBase, CircleProps } from "react-native-svg"; import { useGetNativeStyle } from "../../helpers/native-helpers"; import { VictoryNativePrimitiveShapeProps } from "./types"; export type VictoryNativeCircleProps = CircleProps & VictoryNativePrimitiveShapeProps; -const NativeCircle = (props: VictoryNativeCircleProps) => { +export const Circle = (props: VictoryNativeCircleProps) => { const { "aria-label": accessibilityLabel, desc, style, ...rest } = props; const nativeStyle = useGetNativeStyle(style); return ( - { /> ); }; - -export default NativeCircle; diff --git a/packages/victory-native/src/components/victory-primitives/clip-path.tsx b/packages/victory-native/src/components/victory-primitives/clip-path.tsx index e10526b58..e0abeccdd 100644 --- a/packages/victory-native/src/components/victory-primitives/clip-path.tsx +++ b/packages/victory-native/src/components/victory-primitives/clip-path.tsx @@ -1,21 +1,24 @@ import React from "react"; -import { Defs, ClipPath, G, ClipPathProps } from "react-native-svg"; +import { + Defs, + ClipPath as ClipPathBase, + G, + ClipPathProps, +} from "react-native-svg"; export interface VictoryNativeClipPathProps extends ClipPathProps { clipId?: string; } -const NativeClipPath = (props: VictoryNativeClipPathProps) => { +export const ClipPath = (props: VictoryNativeClipPathProps) => { const { children, clipId } = props; // Wrap in G not to cause exceptions in old react-native-svg // https://github.com/FormidableLabs/victory-native/issues/432#issuecomment-475927581 return ( - {children} + {children} ); }; - -export default NativeClipPath; diff --git a/packages/victory-native/src/components/victory-primitives/curve.tsx b/packages/victory-native/src/components/victory-primitives/curve.tsx index b70a6494e..a447edcbb 100644 --- a/packages/victory-native/src/components/victory-primitives/curve.tsx +++ b/packages/victory-native/src/components/victory-primitives/curve.tsx @@ -1,9 +1,7 @@ import React from "react"; -import Path from "./path"; -import { Curve, CurveProps } from "victory-line/es"; +import { Path } from "./path"; +import { Curve as CurveBase, CurveProps } from "victory-line/es"; -const NativeCurve = (props: CurveProps) => ( - } {...props} /> +export const Curve = (props: CurveProps) => ( + } {...props} /> ); - -export default NativeCurve; diff --git a/packages/victory-native/src/components/victory-primitives/error-bar.tsx b/packages/victory-native/src/components/victory-primitives/error-bar.tsx index a5d65e5dd..dfc4a62f9 100644 --- a/packages/victory-native/src/components/victory-primitives/error-bar.tsx +++ b/packages/victory-native/src/components/victory-primitives/error-bar.tsx @@ -1,10 +1,8 @@ import React from "react"; -import Line from "./line"; +import { Line } from "./line"; import { G } from "react-native-svg"; -import { ErrorBar, ErrorBarProps } from "victory-errorbar/es"; +import { ErrorBar as ErrorBarBase, ErrorBarProps } from "victory-errorbar/es"; -const NativeErrorBar = (props: ErrorBarProps) => ( - } groupComponent={} {...props} /> +export const ErrorBar = (props: ErrorBarProps) => ( + } groupComponent={} {...props} /> ); - -export default NativeErrorBar; diff --git a/packages/victory-native/src/components/victory-primitives/flyout.tsx b/packages/victory-native/src/components/victory-primitives/flyout.tsx index e0b5393f2..4e145e54a 100644 --- a/packages/victory-native/src/components/victory-primitives/flyout.tsx +++ b/packages/victory-native/src/components/victory-primitives/flyout.tsx @@ -1,9 +1,7 @@ import React from "react"; -import Path from "./path"; -import { Flyout, FlyoutProps } from "victory-tooltip/es"; +import { Path } from "./path"; +import { Flyout as FlyoutBase, FlyoutProps } from "victory-tooltip/es"; -const NativeFlyout = (props: FlyoutProps) => ( - } {...props} /> +export const Flyout = (props: FlyoutProps) => ( + } {...props} /> ); - -export default NativeFlyout; diff --git a/packages/victory-native/src/components/victory-primitives/line-segment.tsx b/packages/victory-native/src/components/victory-primitives/line-segment.tsx index 6665a888c..dfcaf2ead 100644 --- a/packages/victory-native/src/components/victory-primitives/line-segment.tsx +++ b/packages/victory-native/src/components/victory-primitives/line-segment.tsx @@ -1,9 +1,10 @@ import React from "react"; -import Line from "./line"; -import { LineSegment, LineSegmentProps } from "victory-core/es"; +import { Line } from "./line"; +import { + LineSegment as LineSegmentBase, + LineSegmentProps, +} from "victory-core/es"; -const NativeLineSegment = (props: LineSegmentProps) => ( - } {...props} /> +export const LineSegment = (props: LineSegmentProps) => ( + } {...props} /> ); - -export default NativeLineSegment; diff --git a/packages/victory-native/src/components/victory-primitives/line.tsx b/packages/victory-native/src/components/victory-primitives/line.tsx index e3477c799..e65ec0b32 100644 --- a/packages/victory-native/src/components/victory-primitives/line.tsx +++ b/packages/victory-native/src/components/victory-primitives/line.tsx @@ -1,17 +1,17 @@ import React from "react"; -import { Line, LineProps } from "react-native-svg"; +import { Line as LineBase, LineProps } from "react-native-svg"; import { useGetNativeStyle } from "../../helpers/native-helpers"; import { VictoryNativePrimitiveShapeProps } from "./types"; export type VictoryNativeLineProps = LineProps & VictoryNativePrimitiveShapeProps; -const NativeLine = (props: VictoryNativeLineProps) => { +export const Line = (props: VictoryNativeLineProps) => { const { "aria-label": accessibilityLabel, desc, style, ...rest } = props; const nativeStyle = useGetNativeStyle(style); return ( - { /> ); }; - -export default NativeLine; diff --git a/packages/victory-native/src/components/victory-primitives/path.tsx b/packages/victory-native/src/components/victory-primitives/path.tsx index 39b497c7a..cc652fd7e 100644 --- a/packages/victory-native/src/components/victory-primitives/path.tsx +++ b/packages/victory-native/src/components/victory-primitives/path.tsx @@ -1,16 +1,16 @@ import React from "react"; -import { Path, PathProps } from "react-native-svg"; +import { Path as PathBase, PathProps } from "react-native-svg"; import { useGetNativeStyle } from "../../helpers/native-helpers"; import { VictoryNativePrimitiveShapeProps } from "./types"; export type VictoryNativePathProps = PathProps & VictoryNativePrimitiveShapeProps; -const NativePath = (props: VictoryNativePathProps) => { +export const Path = (props: VictoryNativePathProps) => { const { "aria-label": accessibilityLabel, desc, style, ...rest } = props; const nativeStyle = useGetNativeStyle(style); return ( - { /> ); }; - -export default NativePath; diff --git a/packages/victory-native/src/components/victory-primitives/point.tsx b/packages/victory-native/src/components/victory-primitives/point.tsx index f83b380f2..57b0559e7 100644 --- a/packages/victory-native/src/components/victory-primitives/point.tsx +++ b/packages/victory-native/src/components/victory-primitives/point.tsx @@ -1,9 +1,7 @@ import React from "react"; -import Path from "./path"; -import { Point, PointProps } from "victory-core/es"; +import { Path } from "./path"; +import { Point as PointBase, PointProps } from "victory-core/es"; -const NativePoint = (props: PointProps) => ( - } {...props} /> +export const Point = (props: PointProps) => ( + } {...props} /> ); - -export default NativePoint; diff --git a/packages/victory-native/src/components/victory-primitives/rect.tsx b/packages/victory-native/src/components/victory-primitives/rect.tsx index 360bae296..a18e8cce6 100644 --- a/packages/victory-native/src/components/victory-primitives/rect.tsx +++ b/packages/victory-native/src/components/victory-primitives/rect.tsx @@ -1,16 +1,16 @@ import React from "react"; -import { Rect, RectProps } from "react-native-svg"; +import { Rect as RectBase, RectProps } from "react-native-svg"; import { useGetNativeStyle } from "../../helpers/native-helpers"; import { VictoryNativePrimitiveShapeProps } from "./types"; export type VictoryNativeRectProps = RectProps & VictoryNativePrimitiveShapeProps; -const NativeRect = (props: VictoryNativeRectProps) => { +export const Rect = (props: VictoryNativeRectProps) => { const { "aria-label": accessibilityLabel, desc, style, ...rest } = props; const nativeStyle = useGetNativeStyle(style); return ( - { /> ); }; - -export default NativeRect; diff --git a/packages/victory-native/src/components/victory-primitives/slice.tsx b/packages/victory-native/src/components/victory-primitives/slice.tsx index d49bea0b5..41ff74015 100644 --- a/packages/victory-native/src/components/victory-primitives/slice.tsx +++ b/packages/victory-native/src/components/victory-primitives/slice.tsx @@ -1,9 +1,7 @@ import React from "react"; -import Path from "./path"; -import { Slice, SliceProps } from "victory-pie/es"; +import { Path } from "./path"; +import { Slice as SliceBase, SliceProps } from "victory-pie/es"; -const NativeSlice = (props: SliceProps) => ( - } {...props} /> +export const Slice = (props: SliceProps) => ( + } {...props} /> ); - -export default NativeSlice; diff --git a/packages/victory-native/src/components/victory-primitives/text.tsx b/packages/victory-native/src/components/victory-primitives/text.tsx index d5d2f2f19..1827f2cff 100644 --- a/packages/victory-native/src/components/victory-primitives/text.tsx +++ b/packages/victory-native/src/components/victory-primitives/text.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { Text, TextProps } from "react-native-svg"; +import { Text as TextBase, TextProps } from "react-native-svg"; import { useGetNativeStyle } from "../../helpers/native-helpers"; import { VictoryNativePrimitiveShapeProps } from "./types"; @@ -9,7 +9,7 @@ export interface VictoryNativeTextProps direction?: "inherit" | "rtl" | "ltr"; } -const NativeText = (props: VictoryNativeTextProps) => { +export const Text = (props: VictoryNativeTextProps) => { const { "aria-label": accessibilityLabel, children, @@ -19,7 +19,7 @@ const NativeText = (props: VictoryNativeTextProps) => { } = props; const nativeStyle = useGetNativeStyle(style); return ( - { {...nativeStyle} > {children} - + ); }; - -export default NativeText; diff --git a/packages/victory-native/src/components/victory-primitives/tspan.tsx b/packages/victory-native/src/components/victory-primitives/tspan.tsx index 7cac7468d..99a7dd153 100644 --- a/packages/victory-native/src/components/victory-primitives/tspan.tsx +++ b/packages/victory-native/src/components/victory-primitives/tspan.tsx @@ -1,15 +1,13 @@ import React from "react"; -import { TSpan, TSpanProps } from "react-native-svg"; +import { TSpan as TSpanBase, TSpanProps } from "react-native-svg"; import { useGetNativeStyle } from "../../helpers/native-helpers"; import { VictoryNativePrimitiveShapeProps } from "./types"; export type VictoryNativeTSpanProps = TSpanProps & VictoryNativePrimitiveShapeProps; -const NativeTSpan = (props: VictoryNativeTSpanProps) => { +export const TSpan = (props: VictoryNativeTSpanProps) => { const { style, ...rest } = props; const nativeStyle = useGetNativeStyle(style); - return ; + return ; }; - -export default NativeTSpan; diff --git a/packages/victory-native/src/components/victory-primitives/voronoi.tsx b/packages/victory-native/src/components/victory-primitives/voronoi.tsx index b30890faa..2e38520c6 100644 --- a/packages/victory-native/src/components/victory-primitives/voronoi.tsx +++ b/packages/victory-native/src/components/victory-primitives/voronoi.tsx @@ -1,12 +1,12 @@ import React from "react"; -import Path from "./path"; -import ClipPath from "./clip-path"; -import Circle from "./circle"; +import { Path } from "./path"; +import { ClipPath } from "./clip-path"; +import { Circle } from "./circle"; import { G } from "react-native-svg"; -import { Voronoi, VoronoiProps } from "victory-voronoi/es"; +import { Voronoi as VoronoiBase, VoronoiProps } from "victory-voronoi/es"; -const NativeVoronoi = (props: VoronoiProps) => ( - ( + } groupComponent={} clipPathComponent={} @@ -14,5 +14,3 @@ const NativeVoronoi = (props: VoronoiProps) => ( {...props} /> ); - -export default NativeVoronoi; diff --git a/packages/victory-native/src/components/victory-primitives/whisker.tsx b/packages/victory-native/src/components/victory-primitives/whisker.tsx index 582648fd2..721d33f4f 100644 --- a/packages/victory-native/src/components/victory-primitives/whisker.tsx +++ b/packages/victory-native/src/components/victory-primitives/whisker.tsx @@ -1,10 +1,8 @@ import React from "react"; -import Line from "./line"; +import { Line } from "./line"; import { G } from "react-native-svg"; -import { Whisker, WhiskerProps } from "victory-core/es"; +import { Whisker as WhiskerBase, WhiskerProps } from "victory-core/es"; -const NativeWhisker = (props: WhiskerProps) => ( - } groupComponent={} {...props} /> +export const Whisker = (props: WhiskerProps) => ( + } groupComponent={} {...props} /> ); - -export default NativeWhisker; diff --git a/packages/victory-native/src/components/victory-scatter.tsx b/packages/victory-native/src/components/victory-scatter.tsx index 233f3b41a..1592aeac2 100644 --- a/packages/victory-native/src/components/victory-scatter.tsx +++ b/packages/victory-native/src/components/victory-scatter.tsx @@ -1,16 +1,16 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import { VictoryScatter } from "victory-scatter/es"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import Point from "./victory-primitives/point"; +import { VictoryScatter as VictoryScatterBase } from "victory-scatter/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { Point } from "./victory-primitives/point"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryScatter = wrapCoreComponent({ - Component: VictoryScatter, +export const VictoryScatter = wrapCoreComponent({ + Component: VictoryScatterBase, defaultProps: { - ...VictoryScatter.defaultProps, + ...VictoryScatterBase.defaultProps, dataComponent: , labelComponent: , containerComponent: , @@ -18,5 +18,3 @@ const NativeVictoryScatter = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryScatter; diff --git a/packages/victory-native/src/components/victory-selection-container.tsx b/packages/victory-native/src/components/victory-selection-container.tsx index f1fbec625..2fb2bee9e 100644 --- a/packages/victory-native/src/components/victory-selection-container.tsx +++ b/packages/victory-native/src/components/victory-selection-container.tsx @@ -2,12 +2,12 @@ import React from "react"; import { flow } from "lodash"; import { Rect } from "react-native-svg"; import { - VictorySelectionContainer, + VictorySelectionContainer as VictorySelectionContainerBase, SelectionHelpers, selectionContainerMixin as originalSelectionMixin, VictorySelectionContainerProps, } from "victory-selection-container"; -import VictoryContainer from "./victory-container"; +import { VictoryContainer } from "./victory-container"; import NativeHelpers from "../helpers/native-helpers"; export interface VictorySelectionContainerNativeProps @@ -44,7 +44,7 @@ function nativeSelectionMixin< // eslint-disable-line max-len // assign native specific defaultProps over web `VictorySelectionContainer` defaultProps static defaultProps = { - ...VictorySelectionContainer.defaultProps, + ...VictorySelectionContainerBase.defaultProps, standalone: true, selectionComponent: , }; @@ -83,7 +83,8 @@ function nativeSelectionMixin< const combinedMixin = flow(originalSelectionMixin, nativeSelectionMixin); -export const selectionContainerMixin = (base): VictorySelectionContainer => +export const selectionContainerMixin = (base): VictorySelectionContainerBase => combinedMixin(base); -export default selectionContainerMixin(VictoryContainer); +export const VictorySelectionContainer = + selectionContainerMixin(VictoryContainer); diff --git a/packages/victory-native/src/components/victory-stack.tsx b/packages/victory-native/src/components/victory-stack.tsx index 50cb65487..a87e38181 100644 --- a/packages/victory-native/src/components/victory-stack.tsx +++ b/packages/victory-native/src/components/victory-stack.tsx @@ -1,17 +1,15 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import { VictoryStack } from "victory-stack/es"; -import VictoryContainer from "./victory-container"; +import { VictoryStack as VictoryStackBase } from "victory-stack/es"; +import { VictoryContainer } from "./victory-container"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryStack = wrapCoreComponent({ - Component: VictoryStack, +export const VictoryStack = wrapCoreComponent({ + Component: VictoryStackBase, defaultProps: { containerComponent: , groupComponent: , width: Dimensions.get("window").width, }, }); - -export default NativeVictoryStack; diff --git a/packages/victory-native/src/components/victory-tooltip.tsx b/packages/victory-native/src/components/victory-tooltip.tsx index 02b9436f8..05d72f9fc 100644 --- a/packages/victory-native/src/components/victory-tooltip.tsx +++ b/packages/victory-native/src/components/victory-tooltip.tsx @@ -1,13 +1,13 @@ import React from "react"; import { G } from "react-native-svg"; -import { VictoryTooltip } from "victory-tooltip/es"; -import VictoryLabel from "./victory-label"; -import VictoryPortal from "./victory-portal/victory-portal"; -import Flyout from "./victory-primitives/flyout"; +import { VictoryTooltip as VictoryTooltipBase } from "victory-tooltip/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryPortal } from "./victory-portal/victory-portal"; +import { Flyout } from "./victory-primitives/flyout"; -export default class extends VictoryTooltip { +export class VictoryTooltip extends VictoryTooltipBase { static defaultProps = { - ...VictoryTooltip.defaultProps, + ...VictoryTooltipBase.defaultProps, labelComponent: , flyoutComponent: , groupComponent: , diff --git a/packages/victory-native/src/components/victory-voronoi-container.tsx b/packages/victory-native/src/components/victory-voronoi-container.tsx index d50e2e5ec..eb8bfa3de 100644 --- a/packages/victory-native/src/components/victory-voronoi-container.tsx +++ b/packages/victory-native/src/components/victory-voronoi-container.tsx @@ -2,13 +2,13 @@ import React from "react"; import { flow } from "lodash"; import { - VictoryVoronoiContainer, + VictoryVoronoiContainer as VictoryVoronoiContainerBase, VictoryVoronoiContainerProps, VoronoiHelpers, voronoiContainerMixin as originalVoronoiMixin, } from "victory-voronoi-container"; -import VictoryContainer from "./victory-container"; -import VictoryTooltip from "./victory-tooltip"; +import { VictoryContainer } from "./victory-container"; +import { VictoryTooltip } from "./victory-tooltip"; export interface VictoryVoronoiContainerNativeProps extends VictoryVoronoiContainerProps { @@ -35,7 +35,7 @@ function nativeVoronoiMixin< return class VictoryNativeVoronoiContainer extends Base { // assign native specific defaultProps over web `VictoryVoronoiContainer` defaultProps static defaultProps = { - ...VictoryVoronoiContainer.defaultProps, + ...VictoryVoronoiContainerBase.defaultProps, activateData: true, activateLabels: true, labelComponent: , @@ -82,7 +82,7 @@ function nativeVoronoiMixin< const combinedMixin = flow(originalVoronoiMixin, nativeVoronoiMixin); -export const voronoiContainerMixin = (base): VictoryVoronoiContainer => +export const voronoiContainerMixin = (base): VictoryVoronoiContainerBase => combinedMixin(base); -export default voronoiContainerMixin(VictoryContainer); +export const VictoryVoronoiContainer = voronoiContainerMixin(VictoryContainer); diff --git a/packages/victory-native/src/components/victory-voronoi.tsx b/packages/victory-native/src/components/victory-voronoi.tsx index 467ffceb4..e8f3e2854 100644 --- a/packages/victory-native/src/components/victory-voronoi.tsx +++ b/packages/victory-native/src/components/victory-voronoi.tsx @@ -1,16 +1,16 @@ import React from "react"; import { Dimensions } from "react-native"; import { G } from "react-native-svg"; -import { VictoryVoronoi } from "victory-voronoi/es"; -import VictoryLabel from "./victory-label"; -import VictoryContainer from "./victory-container"; -import Voronoi from "./victory-primitives/voronoi"; +import { VictoryVoronoi as VictoryVoronoiBase } from "victory-voronoi/es"; +import { VictoryLabel } from "./victory-label"; +import { VictoryContainer } from "./victory-container"; +import { Voronoi } from "./victory-primitives/voronoi"; import { wrapCoreComponent } from "../helpers/wrap-core-component"; -const NativeVictoryVoronoi = wrapCoreComponent({ - Component: VictoryVoronoi, +export const VictoryVoronoi = wrapCoreComponent({ + Component: VictoryVoronoiBase, defaultProps: { - ...VictoryVoronoi.defaultProps, + ...VictoryVoronoiBase.defaultProps, dataComponent: , labelComponent: , containerComponent: , @@ -18,5 +18,3 @@ const NativeVictoryVoronoi = wrapCoreComponent({ width: Dimensions.get("window").width, }, }); - -export default NativeVictoryVoronoi; diff --git a/packages/victory-native/src/components/victory-zoom-container.tsx b/packages/victory-native/src/components/victory-zoom-container.tsx index 03d8e3195..bbe7b42bd 100644 --- a/packages/victory-native/src/components/victory-zoom-container.tsx +++ b/packages/victory-native/src/components/victory-zoom-container.tsx @@ -1,9 +1,9 @@ import React, { ComponentClass } from "react"; import { flow } from "lodash"; -import VictoryContainer from "./victory-container"; -import VictoryClipContainer from "./victory-clip-container"; +import { VictoryContainer } from "./victory-container"; +import { VictoryClipContainer } from "./victory-clip-container"; import { - VictoryZoomContainer, + VictoryZoomContainer as VictoryZoomContainerBase, VictoryZoomContainerProps, zoomContainerMixin as originalZoomMixin, } from "victory-zoom-container"; @@ -34,7 +34,7 @@ function nativeZoomMixin< return class VictoryNativeZoomContainer extends Base { // assign native specific defaultProps over web `VictoryZoomContainer` defaultProps static defaultProps = { - ...VictoryZoomContainer.defaultProps, + ...VictoryZoomContainerBase.defaultProps, clipContainerComponent: , }; @@ -86,7 +86,7 @@ function nativeZoomMixin< const combinedMixin = flow(originalZoomMixin, nativeZoomMixin); -export const zoomContainerMixin = (base): VictoryZoomContainer => +export const zoomContainerMixin = (base): VictoryZoomContainerBase => combinedMixin(base); -export default zoomContainerMixin(VictoryContainer); +export const VictoryZoomContainer = zoomContainerMixin(VictoryContainer); diff --git a/packages/victory-native/src/helpers/create-container.ts b/packages/victory-native/src/helpers/create-container.ts index ee7901f25..43faf216b 100644 --- a/packages/victory-native/src/helpers/create-container.ts +++ b/packages/victory-native/src/helpers/create-container.ts @@ -1,5 +1,5 @@ import { makeCreateContainerFunction } from "victory-create-container"; -import VictoryContainer from "../components/victory-container"; +import { VictoryContainer } from "../components/victory-container"; import { zoomContainerMixin } from "../components/victory-zoom-container"; import { voronoiContainerMixin } from "../components/victory-voronoi-container"; import { selectionContainerMixin } from "../components/victory-selection-container"; diff --git a/packages/victory-native/src/helpers/native-helpers.ts b/packages/victory-native/src/helpers/native-helpers.ts index f00d1e8a6..5eb5b8d1b 100644 --- a/packages/victory-native/src/helpers/native-helpers.ts +++ b/packages/victory-native/src/helpers/native-helpers.ts @@ -54,7 +54,10 @@ export default { getStyle, }; -export const useGetNativeStyle = (style, extraOmitProperties) => { +export const useGetNativeStyle = ( + style: Record, + extraOmitProperties?: string[], +) => { return React.useMemo( () => getStyle(style, extraOmitProperties), [style, extraOmitProperties], diff --git a/packages/victory-native/src/index.ts b/packages/victory-native/src/index.ts index 2646032cf..88891ea33 100644 --- a/packages/victory-native/src/index.ts +++ b/packages/victory-native/src/index.ts @@ -23,73 +23,58 @@ export { export { VictorySharedEvents } from "victory-shared-events"; -export { default as Circle } from "./components/victory-primitives/circle"; -export { default as Line } from "./components/victory-primitives/line"; -export { default as Path } from "./components/victory-primitives/path"; -export { default as Rect } from "./components/victory-primitives/rect"; -export { default as Text } from "./components/victory-primitives/text"; -export { default as TSpan } from "./components/victory-primitives/tspan"; -export { default as Arc } from "./components/victory-primitives/arc"; -export { default as Area } from "./components/victory-primitives/area"; -export { default as Background } from "./components/victory-primitives/background"; -export { default as Bar } from "./components/victory-primitives/bar"; -export { - default as Border, - default as Box, -} from "./components/victory-primitives/border"; -export { default as Candle } from "./components/victory-primitives/candle"; -export { default as ClipPath } from "./components/victory-primitives/clip-path"; -export { default as Curve } from "./components/victory-primitives/curve"; -export { default as ErrorBar } from "./components/victory-primitives/error-bar"; -export { default as LineSegment } from "./components/victory-primitives/line-segment"; -export { default as Point } from "./components/victory-primitives/point"; -export { default as Slice } from "./components/victory-primitives/slice"; -export { default as Voronoi } from "./components/victory-primitives/voronoi"; -export { default as Flyout } from "./components/victory-primitives/flyout"; -export { default as Whisker } from "./components/victory-primitives/whisker"; -export { default as VictoryTooltip } from "./components/victory-tooltip"; -export { default as VictoryPortal } from "./components/victory-portal/victory-portal"; -export { default as Portal } from "./components/victory-portal/portal"; -export { default as VictoryArea } from "./components/victory-area"; -export { default as VictoryAxis } from "./components/victory-axis"; -export { default as VictoryPolarAxis } from "./components/victory-polar-axis"; -export { default as VictoryBar } from "./components/victory-bar"; -export { default as VictoryBrushLine } from "./components/victory-brush-line"; -export { default as VictoryBoxPlot } from "./components/victory-boxplot"; -export { default as VictoryGroup } from "./components/victory-group"; -export { default as VictoryLine } from "./components/victory-line"; -export { default as VictoryHistogram } from "./components/victory-histogram"; -export { default as VictoryScatter } from "./components/victory-scatter"; -export { default as VictoryStack } from "./components/victory-stack"; -export { default as VictoryChart } from "./components/victory-chart"; -export { default as VictoryErrorBar } from "./components/victory-errorbar"; -export { default as VictoryCandlestick } from "./components/victory-candlestick"; -export { default as VictoryVoronoi } from "./components/victory-voronoi"; -export { default as VictoryPie } from "./components/victory-pie"; -export { default as VictoryContainer } from "./components/victory-container"; -export { default as VictoryClipContainer } from "./components/victory-clip-container"; -export { default as VictoryLabel } from "./components/victory-label"; -export { default as VictoryLegend } from "./components/victory-legend"; +export * from "./components/victory-primitives/circle"; +export * from "./components/victory-primitives/line"; +export * from "./components/victory-primitives/path"; +export * from "./components/victory-primitives/rect"; +export * from "./components/victory-primitives/text"; +export * from "./components/victory-primitives/tspan"; +export * from "./components/victory-primitives/arc"; +export * from "./components/victory-primitives/area"; +export * from "./components/victory-primitives/background"; +export * from "./components/victory-primitives/bar"; +export * from "./components/victory-primitives/border"; +export * from "./components/victory-primitives/candle"; +export * from "./components/victory-primitives/clip-path"; +export * from "./components/victory-primitives/curve"; +export * from "./components/victory-primitives/error-bar"; +export * from "./components/victory-primitives/line-segment"; +export * from "./components/victory-primitives/point"; +export * from "./components/victory-primitives/slice"; +export * from "./components/victory-primitives/voronoi"; +export * from "./components/victory-primitives/flyout"; +export * from "./components/victory-primitives/whisker"; + +export * from "./components/victory-tooltip"; +export * from "./components/victory-portal/victory-portal"; +export * from "./components/victory-portal/portal"; +export * from "./components/victory-area"; +export * from "./components/victory-axis"; +export * from "./components/victory-polar-axis"; +export * from "./components/victory-bar"; +export * from "./components/victory-brush-line"; +export * from "./components/victory-boxplot"; +export * from "./components/victory-group"; +export * from "./components/victory-line"; +export * from "./components/victory-histogram"; +export * from "./components/victory-scatter"; +export * from "./components/victory-stack"; +export * from "./components/victory-chart"; +export * from "./components/victory-errorbar"; +export * from "./components/victory-candlestick"; +export * from "./components/victory-voronoi"; +export * from "./components/victory-pie"; +export * from "./components/victory-container"; +export * from "./components/victory-clip-container"; +export * from "./components/victory-label"; +export * from "./components/victory-legend"; + +export * from "./components/victory-zoom-container"; +export * from "./components/victory-voronoi-container"; +export * from "./components/victory-selection-container"; +export * from "./components/victory-cursor-container"; +export * from "./components/victory-brush-container"; + export { default as NativeHelpers } from "./helpers/native-helpers"; export { default as NativeZoomHelpers } from "./helpers/native-zoom-helpers"; -export { - zoomContainerMixin, - default as VictoryZoomContainer, -} from "./components/victory-zoom-container"; -export { - voronoiContainerMixin, - default as VictoryVoronoiContainer, -} from "./components/victory-voronoi-container"; -export { - selectionContainerMixin, - default as VictorySelectionContainer, -} from "./components/victory-selection-container"; -export { - cursorContainerMixin, - default as VictoryCursorContainer, -} from "./components/victory-cursor-container"; -export { - brushContainerMixin, - default as VictoryBrushContainer, -} from "./components/victory-brush-container"; export { createContainer } from "./helpers/create-container"; From 9ad88a71bb6233f5e9659d316c3440dd47d7283c Mon Sep 17 00:00:00 2001 From: Kenan Date: Fri, 26 Jan 2024 11:07:09 +0000 Subject: [PATCH 06/14] fix more type issues --- .../victory-core/src/victory-primitives/arc.tsx | 1 + packages/victory-native/src/components.test.ts | 2 +- .../src/components/victory-brush-line.tsx | 2 +- .../src/components/victory-container.tsx | 8 +------- .../src/components/victory-primitives/circle.tsx | 2 ++ .../src/components/victory-primitives/line.tsx | 2 ++ .../src/components/victory-primitives/path.tsx | 2 ++ .../src/components/victory-primitives/rect.tsx | 2 ++ .../src/components/victory-primitives/text.tsx | 2 ++ .../src/components/victory-tooltip.tsx | 9 +++++---- .../victory-native/src/helpers/native-helpers.ts | 2 +- packages/victory-tooltip/src/victory-tooltip.tsx | 15 ++++++++++++++- 12 files changed, 34 insertions(+), 15 deletions(-) diff --git a/packages/victory-core/src/victory-primitives/arc.tsx b/packages/victory-core/src/victory-primitives/arc.tsx index ef0621b23..e56356287 100644 --- a/packages/victory-core/src/victory-primitives/arc.tsx +++ b/packages/victory-core/src/victory-primitives/arc.tsx @@ -18,6 +18,7 @@ export interface ArcProps extends VictoryCommonPrimitiveProps { pathComponent?: React.ReactElement; r?: number; startAngle?: number; + type?: string; } const getArcPath = (props) => { diff --git a/packages/victory-native/src/components.test.ts b/packages/victory-native/src/components.test.ts index f31d0dd68..530360e3f 100644 --- a/packages/victory-native/src/components.test.ts +++ b/packages/victory-native/src/components.test.ts @@ -58,7 +58,7 @@ describe("Default render", () => { components.forEach((C) => { it(`should work for ${C.name}`, () => { - const { container } = render(React.createElement(C.component)); + const { container } = render(React.createElement(C.component as any)); expect(container).toBeDefined(); }); }); diff --git a/packages/victory-native/src/components/victory-brush-line.tsx b/packages/victory-native/src/components/victory-brush-line.tsx index 53a4161d0..a55f585f0 100644 --- a/packages/victory-native/src/components/victory-brush-line.tsx +++ b/packages/victory-native/src/components/victory-brush-line.tsx @@ -95,7 +95,7 @@ class VictoryNativeBrushLine< const callback = get(this.props.events, eventName); if (callback) { evt.persist(); // RN nativeEvent is reused. see https://fb.me/react-event-pooling - callback(evt, this.props, "__unknownEventKey__", eventName); + (callback as any)(evt, this.props, "__unknownEventKey__", eventName); } } diff --git a/packages/victory-native/src/components/victory-container.tsx b/packages/victory-native/src/components/victory-container.tsx index 5f1aff080..e2675d4b2 100644 --- a/packages/victory-native/src/components/victory-container.tsx +++ b/packages/victory-native/src/components/victory-container.tsx @@ -169,13 +169,7 @@ export class VictoryContainer extends VictoryContainerBase + {title ? {title} : null} {desc ? {desc} : null} {children} diff --git a/packages/victory-native/src/components/victory-primitives/circle.tsx b/packages/victory-native/src/components/victory-primitives/circle.tsx index 57f9f806a..3ff9aa6e4 100644 --- a/packages/victory-native/src/components/victory-primitives/circle.tsx +++ b/packages/victory-native/src/components/victory-primitives/circle.tsx @@ -12,6 +12,8 @@ export const Circle = (props: VictoryNativeCircleProps) => { return ( { return ( { const nativeStyle = useGetNativeStyle(style); return ( { return ( { const nativeStyle = useGetNativeStyle(style); return ( , }; - static defaultEvents = [ + static defaultEvents = () => [ { target: "data", eventHandlers: { @@ -66,19 +66,20 @@ export class VictoryTooltip extends VictoryTooltipBase { ); } + const calculatedValues = this.getCalculatedValues(evaluatedProps); const children = [ React.cloneElement( - flyoutComponent, + flyoutComponent!, this.getFlyoutProps(evaluatedProps, calculatedValues), ), React.cloneElement( - labelComponent, + labelComponent!, this.getLabelProps(evaluatedProps, calculatedValues), ), ]; const tooltip = React.cloneElement( - groupComponent, + groupComponent!, { role: "presentation" }, children, ); diff --git a/packages/victory-native/src/helpers/native-helpers.ts b/packages/victory-native/src/helpers/native-helpers.ts index 5eb5b8d1b..1e635475a 100644 --- a/packages/victory-native/src/helpers/native-helpers.ts +++ b/packages/victory-native/src/helpers/native-helpers.ts @@ -34,7 +34,7 @@ const unsupportedAndStrokeProps = [ ]; const getStyle = ( - style: Record, + style?: Record, extraOmitProperties?: string[], ) => { if (!style) { diff --git a/packages/victory-tooltip/src/victory-tooltip.tsx b/packages/victory-tooltip/src/victory-tooltip.tsx index 6038b1e99..985566a06 100644 --- a/packages/victory-tooltip/src/victory-tooltip.tsx +++ b/packages/victory-tooltip/src/victory-tooltip.tsx @@ -87,6 +87,14 @@ type InternalEvaluatedProps = VictoryTooltipProps & { text: string | string[]; }; +type EventHandlers = Record< + string, + (props?: any) => { + target: string; + mutation: () => { active?: boolean | undefined }; + }[] +>; + export class VictoryTooltip extends React.Component { static displayName = "VictoryTooltip"; static role = "tooltip"; @@ -99,7 +107,12 @@ export class VictoryTooltip extends React.Component { groupComponent: , }; - static defaultEvents = (props: VictoryTooltipProps) => { + static defaultEvents = ( + props: VictoryTooltipProps, + ): { + target: string; + eventHandlers: EventHandlers; + }[] => { const activate = props.activateData ? [ { target: "labels", mutation: () => ({ active: true }) }, From fa8fe8ee52b27ba5c5b0c8b635b6b300765cbe6b Mon Sep 17 00:00:00 2001 From: Kenan Date: Fri, 26 Jan 2024 11:29:51 +0000 Subject: [PATCH 07/14] fix linting error --- packages/victory-brush-line/src/victory-brush-line.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/victory-brush-line/src/victory-brush-line.tsx b/packages/victory-brush-line/src/victory-brush-line.tsx index 32a365ddd..a293bc75e 100644 --- a/packages/victory-brush-line/src/victory-brush-line.tsx +++ b/packages/victory-brush-line/src/victory-brush-line.tsx @@ -468,7 +468,7 @@ export class VictoryBrushLine< } return []; }, - onMouseUp(evt, targetProps) { + onMouseUp: (evt, targetProps) => { const { onBrushDomainChange, brushDomain, @@ -496,7 +496,7 @@ export class VictoryBrushLine< }, ]; }, - onMouseLeave(evt, targetProps) { + onMouseLeave: (evt, targetProps) => { const { brushDomain } = targetProps; return [ { From 9bdfc6f6cbaf0d1cea6083a2579cfc438855a1c5 Mon Sep 17 00:00:00 2001 From: Kenan Date: Fri, 26 Jan 2024 11:38:51 +0000 Subject: [PATCH 08/14] remove types entry from package.json --- packages/victory-native/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/victory-native/package.json b/packages/victory-native/package.json index 63b4ba4a5..17fb574bc 100644 --- a/packages/victory-native/package.json +++ b/packages/victory-native/package.json @@ -16,7 +16,6 @@ "source": "src/index.js", "sideEffects": false, "main": "src/index.js", - "types": "src/index.d.ts", "files": [ "src", "index.js" From 86f5c73491284c313fa6a5c89fd47b94593b38a0 Mon Sep 17 00:00:00 2001 From: Kenan Date: Tue, 30 Jan 2024 16:53:55 +0000 Subject: [PATCH 09/14] remove prop-types --- packages/victory-native/package.json | 1 - .../victory-native/src/components/victory-container.tsx | 7 ------- 2 files changed, 8 deletions(-) diff --git a/packages/victory-native/package.json b/packages/victory-native/package.json index 17fb574bc..909cb4d56 100644 --- a/packages/victory-native/package.json +++ b/packages/victory-native/package.json @@ -24,7 +24,6 @@ "license": "MIT", "dependencies": { "lodash": "^4.17.21", - "prop-types": "^15.8.1", "react-fast-compare": "^3.2.0", "victory": "^36.8.2", "victory-area": "^36.8.2", diff --git a/packages/victory-native/src/components/victory-container.tsx b/packages/victory-native/src/components/victory-container.tsx index e2675d4b2..66b13929f 100644 --- a/packages/victory-native/src/components/victory-container.tsx +++ b/packages/victory-native/src/components/victory-container.tsx @@ -1,5 +1,4 @@ import React from "react"; -import PropTypes from "prop-types"; import Svg, { Rect } from "react-native-svg"; import { assign, get } from "lodash"; import { View, PanResponder } from "react-native"; @@ -30,12 +29,6 @@ export interface VictoryContainerNativeProps extends VictoryContainerProps { } export class VictoryContainer extends VictoryContainerBase { - static propTypes = assign({}, VictoryContainerBase.propTypes, { - disableContainerEvents: PropTypes.bool, - onTouchEnd: PropTypes.func, - onTouchStart: PropTypes.func, - }); - panResponder: any; constructor(props) { From f942b96054fbeab99a1eef7223f54cd04136a7cd Mon Sep 17 00:00:00 2001 From: Kenan Date: Wed, 31 Jan 2024 12:33:40 +0000 Subject: [PATCH 10/14] victory-native build --- config/webpack/webpack.config.js | 17 +- package.json | 18 +- packages/victory-native/package.json | 393 ++++++++++++++++++++++++--- pnpm-lock.yaml | 3 +- scripts/sync-pkgs-wireit.js | 4 +- 5 files changed, 375 insertions(+), 60 deletions(-) diff --git a/config/webpack/webpack.config.js b/config/webpack/webpack.config.js index 3470e2bea..3ab821655 100644 --- a/config/webpack/webpack.config.js +++ b/config/webpack/webpack.config.js @@ -28,16 +28,15 @@ module.exports = { cache: true, context: SRC, entry: "./index", - externals: [ - { - react: { - root: "React", - commonjs2: "react", - commonjs: "react", - amd: "react", - }, + externals: { + react: { + root: "React", + commonjs2: "react", + commonjs: "react", + amd: "react", }, - ], + "react-native": "react-native", + }, resolve: { extensions: [".ts", ".tsx", ".js", ".jsx"], }, diff --git a/package.json b/package.json index a35cd98e5..ba15d268d 100644 --- a/package.json +++ b/package.json @@ -184,7 +184,6 @@ }, "build": { "dependencies": [ - "./packages/victory-native:build", "./packages/victory-vendor:build", "./packages/victory:build", "./packages/victory-area:build", @@ -204,6 +203,7 @@ "./packages/victory-histogram:build", "./packages/victory-legend:build", "./packages/victory-line:build", + "./packages/victory-native:build", "./packages/victory-pie:build", "./packages/victory-polar-axis:build", "./packages/victory-scatter:build", @@ -218,7 +218,6 @@ }, "build:lib:esm": { "dependencies": [ - "./packages/victory-native:build:lib:esm", "./packages/victory-vendor:build:lib:esm", "./packages/victory:build:lib:esm", "./packages/victory-area:build:lib:esm", @@ -238,6 +237,7 @@ "./packages/victory-histogram:build:lib:esm", "./packages/victory-legend:build:lib:esm", "./packages/victory-line:build:lib:esm", + "./packages/victory-native:build:lib:esm", "./packages/victory-pie:build:lib:esm", "./packages/victory-polar-axis:build:lib:esm", "./packages/victory-scatter:build:lib:esm", @@ -308,7 +308,6 @@ }, "format:pkgs": { "dependencies": [ - "./packages/victory-native:format", "./packages/victory-vendor:format", "./packages/victory:format", "./packages/victory-area:format", @@ -328,6 +327,7 @@ "./packages/victory-histogram:format", "./packages/victory-legend:format", "./packages/victory-line:format", + "./packages/victory-native:format", "./packages/victory-pie:format", "./packages/victory-polar-axis:format", "./packages/victory-scatter:format", @@ -388,7 +388,6 @@ }, "lint:pkgs": { "dependencies": [ - "./packages/victory-native:lint", "./packages/victory-vendor:lint", "./packages/victory:lint", "./packages/victory-area:lint", @@ -408,6 +407,7 @@ "./packages/victory-histogram:lint", "./packages/victory-legend:lint", "./packages/victory-line:lint", + "./packages/victory-native:lint", "./packages/victory-pie:lint", "./packages/victory-polar-axis:lint", "./packages/victory-scatter:lint", @@ -441,7 +441,6 @@ }, "jest:pkgs": { "dependencies": [ - "./packages/victory-native:jest", "./packages/victory-vendor:jest", "./packages/victory:jest", "./packages/victory-area:jest", @@ -461,6 +460,7 @@ "./packages/victory-histogram:jest", "./packages/victory-legend:jest", "./packages/victory-line:jest", + "./packages/victory-native:jest", "./packages/victory-pie:jest", "./packages/victory-polar-axis:jest", "./packages/victory-scatter:jest", @@ -498,7 +498,6 @@ }, "types:check": { "dependencies": [ - "./packages/victory-native:types:check", "./packages/victory-vendor:types:check", "./packages/victory:types:check", "./packages/victory-area:types:check", @@ -518,6 +517,7 @@ "./packages/victory-histogram:types:check", "./packages/victory-legend:types:check", "./packages/victory-line:types:check", + "./packages/victory-native:types:check", "./packages/victory-pie:types:check", "./packages/victory-polar-axis:types:check", "./packages/victory-scatter:types:check", @@ -532,7 +532,6 @@ }, "types:create": { "dependencies": [ - "./packages/victory-native:types:create", "./packages/victory-vendor:types:create", "./packages/victory:types:create", "./packages/victory-area:types:create", @@ -552,6 +551,7 @@ "./packages/victory-histogram:types:create", "./packages/victory-legend:types:create", "./packages/victory-line:types:create", + "./packages/victory-native:types:create", "./packages/victory-pie:types:create", "./packages/victory-polar-axis:types:create", "./packages/victory-scatter:types:create", @@ -566,7 +566,6 @@ }, "lint:pkgs:fix": { "dependencies": [ - "./packages/victory-native:lint:fix", "./packages/victory-vendor:lint:fix", "./packages/victory:lint:fix", "./packages/victory-area:lint:fix", @@ -586,6 +585,7 @@ "./packages/victory-histogram:lint:fix", "./packages/victory-legend:lint:fix", "./packages/victory-line:lint:fix", + "./packages/victory-native:lint:fix", "./packages/victory-pie:lint:fix", "./packages/victory-polar-axis:lint:fix", "./packages/victory-scatter:lint:fix", @@ -600,7 +600,6 @@ }, "format:pkgs:fix": { "dependencies": [ - "./packages/victory-native:format:fix", "./packages/victory-vendor:format:fix", "./packages/victory:format:fix", "./packages/victory-area:format:fix", @@ -620,6 +619,7 @@ "./packages/victory-histogram:format:fix", "./packages/victory-legend:format:fix", "./packages/victory-line:format:fix", + "./packages/victory-native:format:fix", "./packages/victory-pie:format:fix", "./packages/victory-polar-axis:format:fix", "./packages/victory-scatter:format:fix", diff --git a/packages/victory-native/package.json b/packages/victory-native/package.json index b85f18b4f..b0cdc01df 100644 --- a/packages/victory-native/package.json +++ b/packages/victory-native/package.json @@ -13,13 +13,11 @@ "url": "https://github.com/FormidableLabs/victory" }, "homepage": "https://formidable.com/open-source/victory", - "source": "src/index.js", "sideEffects": false, - "main": "src/index.js", - "files": [ - "src", - "index.js" - ], + "source": "src/index.ts", + "main": "lib/index.js", + "module": "es/index.js", + "jsnext:main": "es/index.js", "author": "Formidable", "license": "MIT", "dependencies": { @@ -67,6 +65,8 @@ "provenance": true }, "scripts": { + "### THESE SCRIPTS ARE GENERATED ###": "true", + "### DO NOT MODIFY THESE MANUALLY ###": "true", "build": "wireit", "build:lib": "wireit", "build:lib:esm": "wireit", @@ -84,35 +84,212 @@ "jest": "wireit" }, "wireit": { + "### THESE WIREIT CONFIGS ARE GENERATED ####": {}, + "### DO NOT MODIFY THESE MANUALLY ####": {}, "build": { - "command": "echo \"No build required\"", - "files": [], - "output": [] + "dependencies": [ + "build:lib", + "build:dist", + "types:create" + ] + }, + "build:lib": { + "dependencies": [ + "build:lib:esm", + "build:lib:cjs" + ] }, "build:lib:esm": { - "command": "echo \"No build required\"", - "files": [], - "output": [] + "command": "nps build:lib:esm", + "files": [ + "src/**", + "!src/**/*.test.*", + "../../.babelrc.build.js", + "../../.babelrc.js", + "../../package-scripts.js" + ], + "output": [ + "es/**/*.js", + "es/**/*.js.map" + ], + "dependencies": [ + "../victory:build:lib:esm", + "../victory-area:build:lib:esm", + "../victory-axis:build:lib:esm", + "../victory-bar:build:lib:esm", + "../victory-box-plot:build:lib:esm", + "../victory-brush-container:build:lib:esm", + "../victory-brush-line:build:lib:esm", + "../victory-candlestick:build:lib:esm", + "../victory-chart:build:lib:esm", + "../victory-core:build:lib:esm", + "../victory-create-container:build:lib:esm", + "../victory-cursor-container:build:lib:esm", + "../victory-errorbar:build:lib:esm", + "../victory-group:build:lib:esm", + "../victory-histogram:build:lib:esm", + "../victory-legend:build:lib:esm", + "../victory-line:build:lib:esm", + "../victory-pie:build:lib:esm", + "../victory-polar-axis:build:lib:esm", + "../victory-scatter:build:lib:esm", + "../victory-selection-container:build:lib:esm", + "../victory-shared-events:build:lib:esm", + "../victory-stack:build:lib:esm", + "../victory-tooltip:build:lib:esm", + "../victory-voronoi:build:lib:esm", + "../victory-voronoi-container:build:lib:esm", + "../victory-zoom-container:build:lib:esm" + ], + "packageLocks": [ + "pnpm-lock.yaml" + ] }, "build:lib:cjs": { - "command": "echo \"No build required\"", - "files": [], - "output": [] + "command": "nps build:lib:cjs", + "files": [ + "src/**", + "!src/**/*.test.*", + "../../.babelrc.build.js", + "../../.babelrc.js", + "../../package-scripts.js" + ], + "output": [ + "lib/**/*.js", + "lib/**/*.js.map" + ], + "dependencies": [ + "../victory:build:lib:cjs", + "../victory-area:build:lib:cjs", + "../victory-axis:build:lib:cjs", + "../victory-bar:build:lib:cjs", + "../victory-box-plot:build:lib:cjs", + "../victory-brush-container:build:lib:cjs", + "../victory-brush-line:build:lib:cjs", + "../victory-candlestick:build:lib:cjs", + "../victory-chart:build:lib:cjs", + "../victory-core:build:lib:cjs", + "../victory-create-container:build:lib:cjs", + "../victory-cursor-container:build:lib:cjs", + "../victory-errorbar:build:lib:cjs", + "../victory-group:build:lib:cjs", + "../victory-histogram:build:lib:cjs", + "../victory-legend:build:lib:cjs", + "../victory-line:build:lib:cjs", + "../victory-pie:build:lib:cjs", + "../victory-polar-axis:build:lib:cjs", + "../victory-scatter:build:lib:cjs", + "../victory-selection-container:build:lib:cjs", + "../victory-shared-events:build:lib:cjs", + "../victory-stack:build:lib:cjs", + "../victory-tooltip:build:lib:cjs", + "../victory-voronoi:build:lib:cjs", + "../victory-voronoi-container:build:lib:cjs", + "../victory-zoom-container:build:lib:cjs" + ], + "packageLocks": [ + "pnpm-lock.yaml" + ] }, "build:dist": { - "command": "echo \"No build required\"", - "files": [], - "output": [] + "dependencies": [ + "build:dist:dev", + "build:dist:min" + ] }, "build:dist:dev": { - "command": "echo \"No build required\"", - "files": [], - "output": [] + "command": "nps build:dist:dev", + "files": [ + "src/**", + "!src/**/*.test.*", + "../../.babelrc.build.js", + "../../.babelrc.js", + "../../package-scripts.js", + "../../config/webpack.config.js", + "../../config/webpack.config.dev.js" + ], + "output": [ + "dist/victory*.js", + "!dist/victory*.min.js*" + ], + "dependencies": [ + "../victory:build:lib:esm", + "../victory-area:build:lib:esm", + "../victory-axis:build:lib:esm", + "../victory-bar:build:lib:esm", + "../victory-box-plot:build:lib:esm", + "../victory-brush-container:build:lib:esm", + "../victory-brush-line:build:lib:esm", + "../victory-candlestick:build:lib:esm", + "../victory-chart:build:lib:esm", + "../victory-core:build:lib:esm", + "../victory-create-container:build:lib:esm", + "../victory-cursor-container:build:lib:esm", + "../victory-errorbar:build:lib:esm", + "../victory-group:build:lib:esm", + "../victory-histogram:build:lib:esm", + "../victory-legend:build:lib:esm", + "../victory-line:build:lib:esm", + "../victory-pie:build:lib:esm", + "../victory-polar-axis:build:lib:esm", + "../victory-scatter:build:lib:esm", + "../victory-selection-container:build:lib:esm", + "../victory-shared-events:build:lib:esm", + "../victory-stack:build:lib:esm", + "../victory-tooltip:build:lib:esm", + "../victory-voronoi:build:lib:esm", + "../victory-voronoi-container:build:lib:esm", + "../victory-zoom-container:build:lib:esm" + ], + "packageLocks": [ + "pnpm-lock.yaml" + ] }, "build:dist:min": { - "command": "echo \"No build required\"", - "files": [], - "output": [] + "command": "nps build:dist:min", + "files": [ + "src/**", + "!src/**/*.test.*", + "../../.babelrc.build.js", + "../../.babelrc.js", + "../../package-scripts.js", + "../../config/webpack.config.js" + ], + "output": [ + "dist/victory*.min.js*" + ], + "dependencies": [ + "../victory:build:lib:esm", + "../victory-area:build:lib:esm", + "../victory-axis:build:lib:esm", + "../victory-bar:build:lib:esm", + "../victory-box-plot:build:lib:esm", + "../victory-brush-container:build:lib:esm", + "../victory-brush-line:build:lib:esm", + "../victory-candlestick:build:lib:esm", + "../victory-chart:build:lib:esm", + "../victory-core:build:lib:esm", + "../victory-create-container:build:lib:esm", + "../victory-cursor-container:build:lib:esm", + "../victory-errorbar:build:lib:esm", + "../victory-group:build:lib:esm", + "../victory-histogram:build:lib:esm", + "../victory-legend:build:lib:esm", + "../victory-line:build:lib:esm", + "../victory-pie:build:lib:esm", + "../victory-polar-axis:build:lib:esm", + "../victory-scatter:build:lib:esm", + "../victory-selection-container:build:lib:esm", + "../victory-shared-events:build:lib:esm", + "../victory-stack:build:lib:esm", + "../victory-tooltip:build:lib:esm", + "../victory-voronoi:build:lib:esm", + "../victory-voronoi-container:build:lib:esm", + "../victory-zoom-container:build:lib:esm" + ], + "packageLocks": [ + "pnpm-lock.yaml" + ] }, "check": { "dependencies": [ @@ -123,14 +300,94 @@ ] }, "types:check": { - "command": "echo \"No types to check here\"", - "files": [], - "output": [] + "command": "nps types:pkg:check", + "files": [ + "src/**/*.{ts,tsx}", + "../../tsconfig.base.json", + "tsconfig.json" + ], + "dependencies": [ + "types:create", + "../victory:types:create", + "../victory-area:types:create", + "../victory-axis:types:create", + "../victory-bar:types:create", + "../victory-box-plot:types:create", + "../victory-brush-container:types:create", + "../victory-brush-line:types:create", + "../victory-candlestick:types:create", + "../victory-chart:types:create", + "../victory-core:types:create", + "../victory-create-container:types:create", + "../victory-cursor-container:types:create", + "../victory-errorbar:types:create", + "../victory-group:types:create", + "../victory-histogram:types:create", + "../victory-legend:types:create", + "../victory-line:types:create", + "../victory-pie:types:create", + "../victory-polar-axis:types:create", + "../victory-scatter:types:create", + "../victory-selection-container:types:create", + "../victory-shared-events:types:create", + "../victory-stack:types:create", + "../victory-tooltip:types:create", + "../victory-voronoi:types:create", + "../victory-voronoi-container:types:create", + "../victory-zoom-container:types:create", + "../victory-vendor:types:create" + ], + "output": [], + "packageLocks": [ + "pnpm-lock.yaml" + ] }, "types:create": { - "command": "echo \"No types to create here\"", - "files": [], - "output": [] + "command": "nps types:pkg:create", + "files": [ + "src/**", + "!src/**/*.test.*", + "../../tsconfig.base.json", + "tsconfig.build.json" + ], + "output": [ + "es/**/*.d.ts", + "es/**/*.d.ts.map", + "lib/**/*.d.ts", + "lib/**/*.d.ts.map" + ], + "dependencies": [ + "../victory:types:create", + "../victory-area:types:create", + "../victory-axis:types:create", + "../victory-bar:types:create", + "../victory-box-plot:types:create", + "../victory-brush-container:types:create", + "../victory-brush-line:types:create", + "../victory-candlestick:types:create", + "../victory-chart:types:create", + "../victory-core:types:create", + "../victory-create-container:types:create", + "../victory-cursor-container:types:create", + "../victory-errorbar:types:create", + "../victory-group:types:create", + "../victory-histogram:types:create", + "../victory-legend:types:create", + "../victory-line:types:create", + "../victory-pie:types:create", + "../victory-polar-axis:types:create", + "../victory-scatter:types:create", + "../victory-selection-container:types:create", + "../victory-shared-events:types:create", + "../victory-stack:types:create", + "../victory-tooltip:types:create", + "../victory-voronoi:types:create", + "../victory-voronoi-container:types:create", + "../victory-zoom-container:types:create" + ], + "packageLocks": [ + "pnpm-lock.yaml" + ] }, "format": { "command": "nps format:pkg", @@ -166,33 +423,95 @@ "../../.eslintrc.js" ], "output": [], + "dependencies": [ + "../victory:types:create", + "../victory-area:types:create", + "../victory-axis:types:create", + "../victory-bar:types:create", + "../victory-box-plot:types:create", + "../victory-brush-container:types:create", + "../victory-brush-line:types:create", + "../victory-candlestick:types:create", + "../victory-chart:types:create", + "../victory-core:types:create", + "../victory-create-container:types:create", + "../victory-cursor-container:types:create", + "../victory-errorbar:types:create", + "../victory-group:types:create", + "../victory-histogram:types:create", + "../victory-legend:types:create", + "../victory-line:types:create", + "../victory-pie:types:create", + "../victory-polar-axis:types:create", + "../victory-scatter:types:create", + "../victory-selection-container:types:create", + "../victory-shared-events:types:create", + "../victory-stack:types:create", + "../victory-tooltip:types:create", + "../victory-voronoi:types:create", + "../victory-voronoi-container:types:create", + "../victory-zoom-container:types:create", + "../victory-vendor:types:create" + ], "packageLocks": [ "pnpm-lock.yaml" ] }, "lint:fix": { - "command": "pnpm run lint || nps lint:pkg", + "command": "pnpm run lint || nps lint:pkg:fix", "files": [ "src/**", "../../.eslintignore", "../../.eslintrc.js" ], "output": [], + "dependencies": [ + "../victory:types:create", + "../victory-area:types:create", + "../victory-axis:types:create", + "../victory-bar:types:create", + "../victory-box-plot:types:create", + "../victory-brush-container:types:create", + "../victory-brush-line:types:create", + "../victory-candlestick:types:create", + "../victory-chart:types:create", + "../victory-core:types:create", + "../victory-create-container:types:create", + "../victory-cursor-container:types:create", + "../victory-errorbar:types:create", + "../victory-group:types:create", + "../victory-histogram:types:create", + "../victory-legend:types:create", + "../victory-line:types:create", + "../victory-pie:types:create", + "../victory-polar-axis:types:create", + "../victory-scatter:types:create", + "../victory-selection-container:types:create", + "../victory-shared-events:types:create", + "../victory-stack:types:create", + "../victory-tooltip:types:create", + "../victory-voronoi:types:create", + "../victory-voronoi-container:types:create", + "../victory-zoom-container:types:create", + "../victory-vendor:types:create" + ], "packageLocks": [ "pnpm-lock.yaml" ] }, "jest": { - "command": "nps jest:native", + "command": "nps jest:pkg", "files": [ - "src/**", - "../../.babelrc.native.js", - "../../test/jest-native-config.js", - "../../test/jest-native-setup.js" + "src/**/*.test.*", + "../../.babelrc.js", + "../../test/jest-config.js", + "../../test/jest-setup.ts" ], "output": [], "dependencies": [ - "../victory:build:lib" + "build:lib:cjs", + "../victory-vendor:build:lib:cjs", + "../victory-voronoi:build:lib:cjs" ], "packageLocks": [ "pnpm-lock.yaml" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9d98452a0..cac510a77 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -535,7 +535,6 @@ importers: specifiers: '@babel/core': ^7.18.9 lodash: ^4.17.21 - prop-types: ^15.8.1 react-fast-compare: ^3.2.0 react-native: ^0.65.1 react-native-gesture-handler: ^1.10.3 @@ -557,6 +556,7 @@ importers: victory-histogram: ^36.8.4 victory-legend: ^36.8.4 victory-line: ^36.8.4 + victory-native: '*' victory-pie: ^36.8.4 victory-polar-axis: ^36.8.4 victory-scatter: ^36.8.4 @@ -569,7 +569,6 @@ importers: victory-zoom-container: ^36.8.4 dependencies: lodash: 4.17.21 - prop-types: 15.8.1 react-fast-compare: 3.2.0 victory: link:../victory victory-area: link:../victory-area diff --git a/scripts/sync-pkgs-wireit.js b/scripts/sync-pkgs-wireit.js index 451bf7b90..ecb9c474e 100644 --- a/scripts/sync-pkgs-wireit.js +++ b/scripts/sync-pkgs-wireit.js @@ -10,7 +10,6 @@ * * Note that this script does _not_ mutate: * - victory-vendor - * - victory-native * * If you are editing `victory-vendor` or `victory-native`, directly edit them. * For **all other packages**, make your changes in @@ -30,10 +29,9 @@ const PKGS_ROOT = path.join(ROOT, "packages"); // Special packages const PKGS = { - NATIVE: "victory-native", VENDOR: "victory-vendor", }; -const SPECIAL_PKGS = new Set([PKGS.NATIVE, PKGS.VENDOR]); +const SPECIAL_PKGS = new Set([PKGS.VENDOR]); // ============================================================================ // Helpers From 0f3abe234404301fe3d606367d6018ba5296e5fa Mon Sep 17 00:00:00 2001 From: Kenan Date: Wed, 31 Jan 2024 13:24:48 +0000 Subject: [PATCH 11/14] changeset --- .changeset/fair-bobcats-knock.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .changeset/fair-bobcats-knock.md diff --git a/.changeset/fair-bobcats-knock.md b/.changeset/fair-bobcats-knock.md new file mode 100644 index 000000000..20af66929 --- /dev/null +++ b/.changeset/fair-bobcats-knock.md @@ -0,0 +1,13 @@ +--- +"victory-area": patch +"victory-box-plot": patch +"victory-brush-line": patch +"victory-core": patch +"victory-errorbar": patch +"victory-native": patch +"victory-polar-axis": patch +"victory-scatter": patch +"victory-tooltip": patch +--- + +Migrate victory-native to TypeScript From 7c98d6fc26f9f342e7b013388f177090370da0f9 Mon Sep 17 00:00:00 2001 From: Charlie Brown Date: Wed, 31 Jan 2024 08:02:40 -0600 Subject: [PATCH 12/14] Do not webpack native --- packages/victory-native/package.json | 165 +-------------------------- scripts/sync-pkgs-wireit.js | 4 +- 2 files changed, 9 insertions(+), 160 deletions(-) diff --git a/packages/victory-native/package.json b/packages/victory-native/package.json index b0cdc01df..7a1150a0e 100644 --- a/packages/victory-native/package.json +++ b/packages/victory-native/package.json @@ -13,11 +13,14 @@ "url": "https://github.com/FormidableLabs/victory" }, "homepage": "https://formidable.com/open-source/victory", + "source": "src/index.js", "sideEffects": false, - "source": "src/index.ts", "main": "lib/index.js", - "module": "es/index.js", - "jsnext:main": "es/index.js", + "files": [ + "src", + "lib", + "index.js" + ], "author": "Formidable", "license": "MIT", "dependencies": { @@ -65,15 +68,9 @@ "provenance": true }, "scripts": { - "### THESE SCRIPTS ARE GENERATED ###": "true", - "### DO NOT MODIFY THESE MANUALLY ###": "true", "build": "wireit", "build:lib": "wireit", - "build:lib:esm": "wireit", "build:lib:cjs": "wireit", - "build:dist": "wireit", - "build:dist:dev": "wireit", - "build:dist:min": "wireit", "check": "wireit", "types:check": "wireit", "types:create": "wireit", @@ -84,67 +81,17 @@ "jest": "wireit" }, "wireit": { - "### THESE WIREIT CONFIGS ARE GENERATED ####": {}, - "### DO NOT MODIFY THESE MANUALLY ####": {}, "build": { "dependencies": [ "build:lib", - "build:dist", "types:create" ] }, "build:lib": { "dependencies": [ - "build:lib:esm", "build:lib:cjs" ] }, - "build:lib:esm": { - "command": "nps build:lib:esm", - "files": [ - "src/**", - "!src/**/*.test.*", - "../../.babelrc.build.js", - "../../.babelrc.js", - "../../package-scripts.js" - ], - "output": [ - "es/**/*.js", - "es/**/*.js.map" - ], - "dependencies": [ - "../victory:build:lib:esm", - "../victory-area:build:lib:esm", - "../victory-axis:build:lib:esm", - "../victory-bar:build:lib:esm", - "../victory-box-plot:build:lib:esm", - "../victory-brush-container:build:lib:esm", - "../victory-brush-line:build:lib:esm", - "../victory-candlestick:build:lib:esm", - "../victory-chart:build:lib:esm", - "../victory-core:build:lib:esm", - "../victory-create-container:build:lib:esm", - "../victory-cursor-container:build:lib:esm", - "../victory-errorbar:build:lib:esm", - "../victory-group:build:lib:esm", - "../victory-histogram:build:lib:esm", - "../victory-legend:build:lib:esm", - "../victory-line:build:lib:esm", - "../victory-pie:build:lib:esm", - "../victory-polar-axis:build:lib:esm", - "../victory-scatter:build:lib:esm", - "../victory-selection-container:build:lib:esm", - "../victory-shared-events:build:lib:esm", - "../victory-stack:build:lib:esm", - "../victory-tooltip:build:lib:esm", - "../victory-voronoi:build:lib:esm", - "../victory-voronoi-container:build:lib:esm", - "../victory-zoom-container:build:lib:esm" - ], - "packageLocks": [ - "pnpm-lock.yaml" - ] - }, "build:lib:cjs": { "command": "nps build:lib:cjs", "files": [ @@ -191,106 +138,6 @@ "pnpm-lock.yaml" ] }, - "build:dist": { - "dependencies": [ - "build:dist:dev", - "build:dist:min" - ] - }, - "build:dist:dev": { - "command": "nps build:dist:dev", - "files": [ - "src/**", - "!src/**/*.test.*", - "../../.babelrc.build.js", - "../../.babelrc.js", - "../../package-scripts.js", - "../../config/webpack.config.js", - "../../config/webpack.config.dev.js" - ], - "output": [ - "dist/victory*.js", - "!dist/victory*.min.js*" - ], - "dependencies": [ - "../victory:build:lib:esm", - "../victory-area:build:lib:esm", - "../victory-axis:build:lib:esm", - "../victory-bar:build:lib:esm", - "../victory-box-plot:build:lib:esm", - "../victory-brush-container:build:lib:esm", - "../victory-brush-line:build:lib:esm", - "../victory-candlestick:build:lib:esm", - "../victory-chart:build:lib:esm", - "../victory-core:build:lib:esm", - "../victory-create-container:build:lib:esm", - "../victory-cursor-container:build:lib:esm", - "../victory-errorbar:build:lib:esm", - "../victory-group:build:lib:esm", - "../victory-histogram:build:lib:esm", - "../victory-legend:build:lib:esm", - "../victory-line:build:lib:esm", - "../victory-pie:build:lib:esm", - "../victory-polar-axis:build:lib:esm", - "../victory-scatter:build:lib:esm", - "../victory-selection-container:build:lib:esm", - "../victory-shared-events:build:lib:esm", - "../victory-stack:build:lib:esm", - "../victory-tooltip:build:lib:esm", - "../victory-voronoi:build:lib:esm", - "../victory-voronoi-container:build:lib:esm", - "../victory-zoom-container:build:lib:esm" - ], - "packageLocks": [ - "pnpm-lock.yaml" - ] - }, - "build:dist:min": { - "command": "nps build:dist:min", - "files": [ - "src/**", - "!src/**/*.test.*", - "../../.babelrc.build.js", - "../../.babelrc.js", - "../../package-scripts.js", - "../../config/webpack.config.js" - ], - "output": [ - "dist/victory*.min.js*" - ], - "dependencies": [ - "../victory:build:lib:esm", - "../victory-area:build:lib:esm", - "../victory-axis:build:lib:esm", - "../victory-bar:build:lib:esm", - "../victory-box-plot:build:lib:esm", - "../victory-brush-container:build:lib:esm", - "../victory-brush-line:build:lib:esm", - "../victory-candlestick:build:lib:esm", - "../victory-chart:build:lib:esm", - "../victory-core:build:lib:esm", - "../victory-create-container:build:lib:esm", - "../victory-cursor-container:build:lib:esm", - "../victory-errorbar:build:lib:esm", - "../victory-group:build:lib:esm", - "../victory-histogram:build:lib:esm", - "../victory-legend:build:lib:esm", - "../victory-line:build:lib:esm", - "../victory-pie:build:lib:esm", - "../victory-polar-axis:build:lib:esm", - "../victory-scatter:build:lib:esm", - "../victory-selection-container:build:lib:esm", - "../victory-shared-events:build:lib:esm", - "../victory-stack:build:lib:esm", - "../victory-tooltip:build:lib:esm", - "../victory-voronoi:build:lib:esm", - "../victory-voronoi-container:build:lib:esm", - "../victory-zoom-container:build:lib:esm" - ], - "packageLocks": [ - "pnpm-lock.yaml" - ] - }, "check": { "dependencies": [ "types:check", diff --git a/scripts/sync-pkgs-wireit.js b/scripts/sync-pkgs-wireit.js index ecb9c474e..451bf7b90 100644 --- a/scripts/sync-pkgs-wireit.js +++ b/scripts/sync-pkgs-wireit.js @@ -10,6 +10,7 @@ * * Note that this script does _not_ mutate: * - victory-vendor + * - victory-native * * If you are editing `victory-vendor` or `victory-native`, directly edit them. * For **all other packages**, make your changes in @@ -29,9 +30,10 @@ const PKGS_ROOT = path.join(ROOT, "packages"); // Special packages const PKGS = { + NATIVE: "victory-native", VENDOR: "victory-vendor", }; -const SPECIAL_PKGS = new Set([PKGS.VENDOR]); +const SPECIAL_PKGS = new Set([PKGS.NATIVE, PKGS.VENDOR]); // ============================================================================ // Helpers From 93e8cb9697949b0e620046192c4ad39546657bf6 Mon Sep 17 00:00:00 2001 From: Charlie Brown Date: Wed, 31 Jan 2024 08:08:56 -0600 Subject: [PATCH 13/14] Add no-op --- package.json | 18 +++++++++--------- packages/victory-native/package.json | 6 ++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index ba15d268d..a35cd98e5 100644 --- a/package.json +++ b/package.json @@ -184,6 +184,7 @@ }, "build": { "dependencies": [ + "./packages/victory-native:build", "./packages/victory-vendor:build", "./packages/victory:build", "./packages/victory-area:build", @@ -203,7 +204,6 @@ "./packages/victory-histogram:build", "./packages/victory-legend:build", "./packages/victory-line:build", - "./packages/victory-native:build", "./packages/victory-pie:build", "./packages/victory-polar-axis:build", "./packages/victory-scatter:build", @@ -218,6 +218,7 @@ }, "build:lib:esm": { "dependencies": [ + "./packages/victory-native:build:lib:esm", "./packages/victory-vendor:build:lib:esm", "./packages/victory:build:lib:esm", "./packages/victory-area:build:lib:esm", @@ -237,7 +238,6 @@ "./packages/victory-histogram:build:lib:esm", "./packages/victory-legend:build:lib:esm", "./packages/victory-line:build:lib:esm", - "./packages/victory-native:build:lib:esm", "./packages/victory-pie:build:lib:esm", "./packages/victory-polar-axis:build:lib:esm", "./packages/victory-scatter:build:lib:esm", @@ -308,6 +308,7 @@ }, "format:pkgs": { "dependencies": [ + "./packages/victory-native:format", "./packages/victory-vendor:format", "./packages/victory:format", "./packages/victory-area:format", @@ -327,7 +328,6 @@ "./packages/victory-histogram:format", "./packages/victory-legend:format", "./packages/victory-line:format", - "./packages/victory-native:format", "./packages/victory-pie:format", "./packages/victory-polar-axis:format", "./packages/victory-scatter:format", @@ -388,6 +388,7 @@ }, "lint:pkgs": { "dependencies": [ + "./packages/victory-native:lint", "./packages/victory-vendor:lint", "./packages/victory:lint", "./packages/victory-area:lint", @@ -407,7 +408,6 @@ "./packages/victory-histogram:lint", "./packages/victory-legend:lint", "./packages/victory-line:lint", - "./packages/victory-native:lint", "./packages/victory-pie:lint", "./packages/victory-polar-axis:lint", "./packages/victory-scatter:lint", @@ -441,6 +441,7 @@ }, "jest:pkgs": { "dependencies": [ + "./packages/victory-native:jest", "./packages/victory-vendor:jest", "./packages/victory:jest", "./packages/victory-area:jest", @@ -460,7 +461,6 @@ "./packages/victory-histogram:jest", "./packages/victory-legend:jest", "./packages/victory-line:jest", - "./packages/victory-native:jest", "./packages/victory-pie:jest", "./packages/victory-polar-axis:jest", "./packages/victory-scatter:jest", @@ -498,6 +498,7 @@ }, "types:check": { "dependencies": [ + "./packages/victory-native:types:check", "./packages/victory-vendor:types:check", "./packages/victory:types:check", "./packages/victory-area:types:check", @@ -517,7 +518,6 @@ "./packages/victory-histogram:types:check", "./packages/victory-legend:types:check", "./packages/victory-line:types:check", - "./packages/victory-native:types:check", "./packages/victory-pie:types:check", "./packages/victory-polar-axis:types:check", "./packages/victory-scatter:types:check", @@ -532,6 +532,7 @@ }, "types:create": { "dependencies": [ + "./packages/victory-native:types:create", "./packages/victory-vendor:types:create", "./packages/victory:types:create", "./packages/victory-area:types:create", @@ -551,7 +552,6 @@ "./packages/victory-histogram:types:create", "./packages/victory-legend:types:create", "./packages/victory-line:types:create", - "./packages/victory-native:types:create", "./packages/victory-pie:types:create", "./packages/victory-polar-axis:types:create", "./packages/victory-scatter:types:create", @@ -566,6 +566,7 @@ }, "lint:pkgs:fix": { "dependencies": [ + "./packages/victory-native:lint:fix", "./packages/victory-vendor:lint:fix", "./packages/victory:lint:fix", "./packages/victory-area:lint:fix", @@ -585,7 +586,6 @@ "./packages/victory-histogram:lint:fix", "./packages/victory-legend:lint:fix", "./packages/victory-line:lint:fix", - "./packages/victory-native:lint:fix", "./packages/victory-pie:lint:fix", "./packages/victory-polar-axis:lint:fix", "./packages/victory-scatter:lint:fix", @@ -600,6 +600,7 @@ }, "format:pkgs:fix": { "dependencies": [ + "./packages/victory-native:format:fix", "./packages/victory-vendor:format:fix", "./packages/victory:format:fix", "./packages/victory-area:format:fix", @@ -619,7 +620,6 @@ "./packages/victory-histogram:format:fix", "./packages/victory-legend:format:fix", "./packages/victory-line:format:fix", - "./packages/victory-native:format:fix", "./packages/victory-pie:format:fix", "./packages/victory-polar-axis:format:fix", "./packages/victory-scatter:format:fix", diff --git a/packages/victory-native/package.json b/packages/victory-native/package.json index 7a1150a0e..9879e3d9a 100644 --- a/packages/victory-native/package.json +++ b/packages/victory-native/package.json @@ -70,6 +70,7 @@ "scripts": { "build": "wireit", "build:lib": "wireit", + "build:lib:esm": "wireit", "build:lib:cjs": "wireit", "check": "wireit", "types:check": "wireit", @@ -138,6 +139,11 @@ "pnpm-lock.yaml" ] }, + "build:lib:esm": { + "command": "echo victory-native has no esm build", + "files": [], + "output": [] + }, "check": { "dependencies": [ "types:check", From bcce09b63ecef284c3550265c7ebce560cbfc5ae Mon Sep 17 00:00:00 2001 From: Kenan Date: Wed, 31 Jan 2024 15:41:38 +0000 Subject: [PATCH 14/14] Update package.json source --- packages/victory-native/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/victory-native/package.json b/packages/victory-native/package.json index 9879e3d9a..bd22250a8 100644 --- a/packages/victory-native/package.json +++ b/packages/victory-native/package.json @@ -13,7 +13,7 @@ "url": "https://github.com/FormidableLabs/victory" }, "homepage": "https://formidable.com/open-source/victory", - "source": "src/index.js", + "source": "src/index.ts", "sideEffects": false, "main": "lib/index.js", "files": [