Skip to content

Commit

Permalink
typescript(vx-shape): update types path, update all restProps signatu…
Browse files Browse the repository at this point in the history
…res to omit own props
  • Loading branch information
Chris Williams committed Sep 20, 2019
1 parent 305636e commit 4ece259
Show file tree
Hide file tree
Showing 30 changed files with 62 additions and 60 deletions.
5 changes: 0 additions & 5 deletions packages/vx-shape/.notes

This file was deleted.

2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/Arc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function Arc<Datum>({
children,
innerRef,
...restProps
}: ArcProps<Datum> & React.SVGProps<SVGPathElement>) {
}: ArcProps<Datum> & Omit<React.SVGProps<SVGPathElement>, keyof ArcProps<Datum>>) {
const arc = d3Arc<Datum>();
if (innerRadius != null) setNumOrAccessor(arc.innerRadius, innerRadius);
if (outerRadius != null) setNumOrAccessor(arc.outerRadius, outerRadius);
Expand Down
11 changes: 2 additions & 9 deletions packages/vx-shape/src/shapes/Area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function Area<Datum>({
curve,
innerRef,
...restProps
}: AreaProps<Datum> & React.SVGProps<SVGPathElement>) {
}: AreaProps<Datum> & Omit<React.SVGProps<SVGPathElement>, keyof AreaProps<Datum>>) {
const path = area<Datum>();
if (x) path.x(x);
if (x0) path.x0(x0);
Expand All @@ -57,13 +57,6 @@ export default function Area<Datum>({
if (curve) path.curve(curve);
if (children) return <>{children({ path })}</>;
return (
<g>
<path
ref={innerRef}
className={cx('vx-area', className)}
d={path(data) || ''}
{...restProps}
/>
</g>
<path ref={innerRef} className={cx('vx-area', className)} d={path(data) || ''} {...restProps} />
);
}
4 changes: 2 additions & 2 deletions packages/vx-shape/src/shapes/AreaClosed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import cx from 'classnames';
import { area } from 'd3-shape';
import { AreaProps } from './Area';
import { ScaleType } from './link/types';
import { ScaleType } from '../types';

export type AreaClosedProps<Datum> = {
yScale: ScaleType;
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function AreaClosed<Datum>({
innerRef,
children,
...restProps
}: AreaClosedProps<Datum> & React.SVGProps<SVGPathElement>) {
}: AreaClosedProps<Datum> & Omit<React.SVGProps<SVGPathElement>, keyof AreaClosedProps<Datum>>) {
const path = area<Datum>();
if (x) path.x(x);
if (x0) path.x0(x0);
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/AreaStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function AreaStack<Datum>({
color,
children,
...restProps
}: AreaStackProps<Datum> & React.SVGProps<SVGPathElement>) {
}: AreaStackProps<Datum> & Omit<React.SVGProps<SVGPathElement>, keyof AreaStackProps<Datum>>) {
return (
<Stack<Datum>
className={className}
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/Bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default function Bar({
className,
innerRef,
...restProps
}: BarProps & React.SVGProps<SVGRectElement>) {
}: BarProps & Omit<React.SVGProps<SVGRectElement>, keyof BarProps>) {
return <rect ref={innerRef} className={cx('vx-bar', className)} {...restProps} />;
}
4 changes: 2 additions & 2 deletions packages/vx-shape/src/shapes/BarGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import cx from 'classnames';
import { Group } from '@vx/group';
import Bar from './Bar';
import { ScaleType } from './link/types';
import { ScaleType } from '../types';

type Key = string;

Expand Down Expand Up @@ -112,7 +112,7 @@ export default function BarGroup<Datum extends { [key: string]: number }>({
height,
children,
...restProps
}: BarGroupProps<Datum>) {
}: BarGroupProps<Datum> & Omit<React.SVGProps<SVGRectElement>, keyof BarGroupProps<Datum>>) {
const x1Range = x1Scale.range();
const x1Domain = x1Scale.domain();

Expand Down
5 changes: 3 additions & 2 deletions packages/vx-shape/src/shapes/BarGroupHorizontal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import cx from 'classnames';
import { Group } from '@vx/group';
import Bar from './Bar';
import { BarGroupProps } from './BarGroup';
import { ScaleType } from './link/types';
import { ScaleType } from '../types';

type Key = string;

Expand Down Expand Up @@ -69,7 +69,8 @@ export default function BarGroupHorizontal<Datum extends { [key: string]: number
width,
children,
...restProps
}: BarGroupHorizontalProps<Datum>) {
}: BarGroupHorizontalProps<Datum> &
Omit<React.SVGProps<SVGRectElement>, keyof BarGroupHorizontalProps<Datum>>) {
const y1Range = y1Scale.range();
const y1Domain = y1Scale.domain();
const barHeight =
Expand Down
4 changes: 2 additions & 2 deletions packages/vx-shape/src/shapes/BarStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import stackOrder from '../util/stackOrder';
import stackOffset from '../util/stackOffset';
import Bar from './Bar';
import { StackProps, Key } from './Stack';
import { ScaleType } from './link/types';
import { ScaleType } from '../types';

export type BarStackProps<Datum> = Pick<
StackProps<Datum>,
Expand Down Expand Up @@ -61,7 +61,7 @@ export default function BarStack<Datum>({
offset,
children,
...restProps
}: BarStackProps<Datum>) {
}: BarStackProps<Datum> & Omit<React.SVGProps<SVGRectElement>, keyof BarStackProps<Datum>>) {
const stack = d3stack<Datum>();
if (keys) stack.keys(keys);
if (value) stack.value(value);
Expand Down
3 changes: 2 additions & 1 deletion packages/vx-shape/src/shapes/BarStackHorizontal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export default function BarStackHorizontal<Datum>({
offset,
children,
...restProps
}: BarStackHorizontalProps<Datum>) {
}: BarStackHorizontalProps<Datum> &
Omit<React.SVGProps<SVGRectElement>, keyof BarStackHorizontalProps<Datum>>) {
const stack = d3stack<Datum>();
if (keys) stack.keys(keys);
if (value) stack.value(value);
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/Circle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default function Circle({
className,
innerRef,
...restProps
}: CircleProps & React.SVGProps<SVGCircleElement>) {
}: CircleProps & Omit<React.SVGProps<SVGCircleElement>, keyof CircleProps>) {
return <circle ref={innerRef} className={cx('vx-circle', className)} {...restProps} />;
}
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/Line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function Line({
className,
innerRef,
...restProps
}: LineProps & Omit<React.SVGProps<SVGLineElement>, 'from' | 'to'>) {
}: LineProps & Omit<React.SVGProps<SVGLineElement>, keyof LineProps>) {
return (
<line
ref={innerRef}
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/LinePath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function LinePath<Datum>({
innerRef,
defined = () => true,
...restProps
}: LinePathProps<Datum> & React.SVGProps<SVGPathElement>) {
}: LinePathProps<Datum> & Omit<React.SVGProps<SVGPathElement>, keyof LinePathProps<Datum>>) {
const path = line<Datum>();
if (x) path.x(x);
if (y) path.y(y);
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/LineRadial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function LineRadial<Datum>({
children,
fill = 'transparent',
...restProps
}: LineRadialProps<Datum> & React.SVGProps<SVGPathElement>) {
}: LineRadialProps<Datum> & Omit<React.SVGProps<SVGPathElement>, keyof LineRadialProps<Datum>>) {
const path = radialLine<Datum>();
if (angle) path.angle(angle);
if (radius) path.radius(radius);
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/Pie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default function Pie<Datum>({
pieValue,
children,
...restProps
}: PieProps<Datum> & React.SVGProps<SVGPathElement>) {
}: PieProps<Datum> & Omit<React.SVGProps<SVGPathElement>, keyof PieProps<Datum>>) {
const path = d3Arc<PieArcDatum<Datum>>();

if (innerRadius != null) setNumOrAccessor(path.innerRadius, innerRadius);
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/Polygon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default function Polygon({
children,
innerRef,
...restProps
}: PolygonProps & React.SVGProps<SVGPolygonElement>) {
}: PolygonProps & Omit<React.SVGProps<SVGPolygonElement>, keyof PolygonProps>) {
const points: [number, number][] = getPoints({
sides,
size,
Expand Down
2 changes: 1 addition & 1 deletion packages/vx-shape/src/shapes/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function Stack<Datum>({
color,
children,
...restProps
}: StackProps<Datum> & React.SVGProps<SVGPathElement>) {
}: StackProps<Datum> & Omit<React.SVGProps<SVGPathElement>, keyof StackProps<Datum>>) {
const stack = d3stack<Datum>();
if (keys) stack.keys(keys);
if (value) stack.value(value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cx from 'classnames';
import { path as d3Path } from 'd3-path';
import { SharedLinkProps, AccessorProps } from '../types';
import { SharedLinkProps, AccessorProps } from '../../../types';

export function pathHorizontalCurve<Link, Node>({
source,
Expand Down Expand Up @@ -49,7 +49,8 @@ export default function LinkHorizontalCurve<Link, Node>({
source = (l: any) => l && l.source,
target = (l: any) => l && l.target,
...restProps
}: LinkHorizontalCurveProps<Link, Node>) {
}: LinkHorizontalCurveProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkHorizontalCurveProps<Link, Node>>) {
const pathGen = path || pathHorizontalCurve({ source, target, x, y, percent });
if (children) return <>{children({ path })}</>;
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/vx-shape/src/shapes/link/curve/LinkRadialCurve.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cx from 'classnames';
import { path as d3Path } from 'd3-path';
import { SharedLinkProps, AccessorProps } from '../types';
import { SharedLinkProps, AccessorProps } from '../../../types';

export function pathRadialCurve<Link, Node>({
source,
Expand Down Expand Up @@ -59,7 +59,8 @@ export default function LinkRadialCurve<Link, Node>({
source = (l: any) => l && l.source,
target = (l: any) => l && l.target,
...restProps
}: LinkRadialCurveProps<Link, Node>) {
}: LinkRadialCurveProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkRadialCurveProps<Link, Node>>) {
const pathGen = path || pathRadialCurve({ source, target, x, y, percent });
if (children) return <>{children({ path })}</>;
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/vx-shape/src/shapes/link/curve/LinkVerticalCurve.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cx from 'classnames';
import { path as d3Path } from 'd3-path';
import { SharedLinkProps, AccessorProps } from '../types';
import { SharedLinkProps, AccessorProps } from '../../../types';

export function pathVerticalCurve<Link, Node>({
source,
Expand Down Expand Up @@ -49,7 +49,8 @@ export default function LinkVerticalCurve<Link, Node>({
source = (l: any) => l && l.source,
target = (l: any) => l && l.target,
...restProps
}: LinkVerticalCurveProps<Link, Node>) {
}: LinkVerticalCurveProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkVerticalCurveProps<Link, Node>>) {
const pathGen = path || pathVerticalCurve({ source, target, x, y, percent });
if (children) return <>{children({ path })}</>;
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/vx-shape/src/shapes/link/diagonal/LinkHorizontal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cx from 'classnames';
import { linkHorizontal } from 'd3-shape';
import { SharedLinkProps, AccessorProps } from '../types';
import { SharedLinkProps, AccessorProps } from '../../../types';

export function pathHorizontalDiagonal<Link, Node>({
source,
Expand Down Expand Up @@ -33,7 +33,8 @@ export default function LinkHorizontalDiagonal<Link, Node>({
source = (l: any) => l && l.source,
target = (l: any) => l && l.target,
...restProps
}: LinkHorizontalDiagonalProps<Link, Node>) {
}: LinkHorizontalDiagonalProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkHorizontalDiagonalProps<Link, Node>>) {
const pathGen = path || pathHorizontalDiagonal({ source, target, x, y });
if (children) return <>{children({ path })}</>;
return (
Expand Down
7 changes: 4 additions & 3 deletions packages/vx-shape/src/shapes/link/diagonal/LinkRadial.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cx from 'classnames';
import { linkRadial } from 'd3-shape';
import { SharedLinkProps, RadialAccessorProps } from '../types';
import { linkRadial, LinkRadial } from 'd3-shape';
import { SharedLinkProps, RadialAccessorProps } from '../../../types';

export function pathRadialDiagonal<Link, Node>({
source,
Expand Down Expand Up @@ -36,7 +36,8 @@ export default function LinkRadialDiagonal<Link, Node>({
source = (n: any) => n.source,
target = (n: any) => n.target,
...restProps
}: LinkRadialDiagonalProps<Node, Link>) {
}: LinkRadialDiagonalProps<Node, Link> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkRadialDiagonalProps<Link, Node>>) {
const pathGen = path || pathRadialDiagonal({ source, target, angle, radius });
if (children) return <>{children({ path })}</>;
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/vx-shape/src/shapes/link/diagonal/LinkVertical.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cx from 'classnames';
import { linkVertical } from 'd3-shape';
import { SharedLinkProps, AccessorProps } from '../types';
import { SharedLinkProps, AccessorProps } from '../../../types';

export function pathVerticalDiagonal<Link, Node>({
source,
Expand Down Expand Up @@ -32,7 +32,8 @@ export default function LinkVerticalDiagonal<Link, Node>({
source = (d: any) => d.source,
target = (d: any) => d.target,
...restProps
}: LinkVerticalDiagonalProps<Link, Node>) {
}: LinkVerticalDiagonalProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkVerticalDiagonalProps<Link, Node>>) {
const pathGen = path || pathVerticalDiagonal({ source, target, x, y });
if (children) return <>{children({ path })}</>;
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/vx-shape/src/shapes/link/line/LinkHorizontalLine.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cx from 'classnames';
import { path as d3Path } from 'd3-path';
import { SharedLinkProps, AccessorProps } from '../types';
import { SharedLinkProps, AccessorProps } from '../../../types';

export function pathHorizontalLine<Link, Node>({
source,
Expand Down Expand Up @@ -39,7 +39,8 @@ export default function LinkHorizontalLine<Link, Node>({
source = (d: any) => d.source,
target = (d: any) => d.target,
...restProps
}: LinkHorizontalLineProps<Link, Node>) {
}: LinkHorizontalLineProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkHorizontalLineProps<Link, Node>>) {
const pathGen = path || pathHorizontalLine({ source, target, x, y });
if (children) return <>{children({ path })}</>;
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/vx-shape/src/shapes/link/line/LinkRadialLine.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cx from 'classnames';
import { path as d3Path } from 'd3-path';
import { SharedLinkProps, AccessorProps } from '../types';
import { SharedLinkProps, AccessorProps } from '../../../types';

export function pathRadialLine<Link, Node>({
source,
Expand Down Expand Up @@ -44,7 +44,8 @@ export default function LinkRadialLine<Link, Node>({
target = (d: any) => d.target,
children,
...restProps
}: LinkRadialLineProps<Link, Node>) {
}: LinkRadialLineProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkRadialLineProps<Link, Node>>) {
const pathGen = path || pathRadialLine({ source, target, x, y });
if (children) return <>{children({ path })}</>;
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/vx-shape/src/shapes/link/line/LinkVerticalLine.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cx from 'classnames';
import { path as d3Path } from 'd3-path';
import { SharedLinkProps, AccessorProps } from '../types';
import { SharedLinkProps, AccessorProps } from '../../../types';

export function pathVerticalLine<Link, Node>({
source,
Expand Down Expand Up @@ -39,7 +39,8 @@ export default function LinkVerticalLine<Link, Node>({
target = (d: any) => d.target,
children,
...restProps
}: LinkVerticalLineProps<Link, Node>) {
}: LinkVerticalLineProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkVerticalLineProps<Link, Node>>) {
const pathGen = path || pathVerticalLine({ source, target, x, y });
if (children) return <>{children({ path })}</>;
return (
Expand Down
5 changes: 3 additions & 2 deletions packages/vx-shape/src/shapes/link/step/LinkHorizontalStep.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import cx from 'classnames';
import { path as d3Path } from 'd3-path';
import { SharedLinkProps, AccessorProps } from '../types';
import { SharedLinkProps, AccessorProps } from '../../../types';

export function pathHorizontalStep<Link, Node>({
source,
Expand Down Expand Up @@ -46,7 +46,8 @@ export default function LinkHorizontalStep<Link, Node>({
target = (d: any) => d.target,
children,
...restProps
}: LinkHorizontalStepProps<Link, Node>) {
}: LinkHorizontalStepProps<Link, Node> &
Omit<React.SVGProps<SVGPathElement>, keyof LinkHorizontalStepProps<Link, Node>>) {
const pathGen = path || pathHorizontalStep({ source, target, x, y, percent });
if (children) return <>{children({ path })}</>;
return (
Expand Down
Loading

0 comments on commit 4ece259

Please sign in to comment.