From ec30451574f66caa9fa5d82aedf11ab1e5c09a0b Mon Sep 17 00:00:00 2001 From: Esteban Ibarra Date: Wed, 13 Mar 2019 12:24:23 -0500 Subject: [PATCH] Add createContainer function for victory (#33786) * Add function createContainer for victory * Fix tests * Update types/victory/index.d.ts Change FunctionComponent to ComponentType Co-Authored-By: ibarrae --- types/victory/index.d.ts | 22 ++++++++++++++++++++++ types/victory/tslint.json | 3 ++- types/victory/victory-tests.tsx | 19 ++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/types/victory/index.d.ts b/types/victory/index.d.ts index 4fc95db8f1..29d0dd068a 100644 --- a/types/victory/index.d.ts +++ b/types/victory/index.d.ts @@ -5,6 +5,8 @@ // Krzysztof Cebula // Vitaliy Polyanskiy // James Lismore +// Stack Builders +// Esteban Ibarra // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -2424,4 +2426,24 @@ declare module "victory" { * Data changes are animated with VictoryAnimation. */ export class VictoryPie extends React.Component {} + + export type ContainerType = + | "brush" + | "cursor" + | "selection" + | "voronoi" + | "zoom"; + + /** + * createContainer makes a container component with multiple behaviors. + * It allows you to effectively combine any two of the following containers: + * VictoryBrushContainer, VictoryCursorContainer, VictorySelectionContainer, + * VictoryVoronoiContainer, or VictoryZoomContainer. + * @param c1 : "brush" | "cursor" | "selection" | "voronoi" | "zoom" + * @param c2 : "brush" | "cursor" | "selection" | "voronoi" | "zoom" + */ + export function createContainer( + c1: ContainerType, + c2: ContainerType + ): React.ComponentType; } diff --git a/types/victory/tslint.json b/types/victory/tslint.json index 2fccde6e9b..ec47eebc69 100644 --- a/types/victory/tslint.json +++ b/types/victory/tslint.json @@ -9,6 +9,7 @@ "no-declare-current-package": false, "no-empty-interface": false, "no-single-declare-module": false, - "strict-export-declare-modifiers": false + "strict-export-declare-modifiers": false, + "no-unnecessary-generics": false } } diff --git a/types/victory/victory-tests.tsx b/types/victory/victory-tests.tsx index 32c9b3160d..ac60806cee 100644 --- a/types/victory/victory-tests.tsx +++ b/types/victory/victory-tests.tsx @@ -14,7 +14,10 @@ import { VictoryTheme, VictoryLegend, VictoryBoxPlot, - VictoryGroup + VictoryGroup, + createContainer, + VictoryZoomContainerProps, + VictoryBrushContainerProps } from "victory"; // VictoryAnimation test @@ -804,3 +807,17 @@ test = ( }]} /> ); + +// createContainer test + +const VictoryZoomBrushContainer = createContainer< + VictoryZoomContainerProps, + VictoryBrushContainerProps +>("zoom", "brush"); + +test = ( + +);