Skip to content

Commit

Permalink
Fix the signature of class static fields as functions (#2840)
Browse files Browse the repository at this point in the history
  • Loading branch information
carbonrobot committed Mar 25, 2024
1 parent 300b527 commit 06b9f31
Show file tree
Hide file tree
Showing 27 changed files with 162 additions and 92 deletions.
25 changes: 25 additions & 0 deletions .changeset/stale-shirts-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
"victory-area": patch
"victory-axis": patch
"victory-bar": patch
"victory-box-plot": patch
"victory-brush-container": patch
"victory-candlestick": patch
"victory-create-container": patch
"victory-cursor-container": patch
"victory-errorbar": patch
"victory-histogram": patch
"victory-legend": patch
"victory-line": patch
"victory-native": patch
"victory-pie": patch
"victory-polar-axis": patch
"victory-scatter": patch
"victory-selection-container": patch
"victory-tooltip": patch
"victory-voronoi": patch
"victory-voronoi-container": patch
"victory-zoom-container": patch
---

Fix the signature of class static functions in components
4 changes: 3 additions & 1 deletion packages/victory-area/src/victory-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ class VictoryAreaBase extends React.Component<VictoryAreaProps> {
DefaultTransitions.continuousPolarTransitions();
static getDomain = Domain.getDomainWithZero;
static getData = Data.getData;
static getBaseProps = (props) => getBaseProps(props, fallbackProps);
static getBaseProps(props) {
return getBaseProps(props, fallbackProps);
}
static expectedComponents = [
"dataComponent",
"labelComponent",
Expand Down
8 changes: 6 additions & 2 deletions packages/victory-axis/src/victory-axis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,12 @@ class VictoryAxisBase extends React.Component<VictoryAxisProps> {

static getDomain = Axis.getDomain;
static getAxis = Axis.getAxis;
static getStyles = (props) => getStyles(props);
static getBaseProps = (props) => getBaseProps(props, fallbackProps);
static getStyles(props) {
return getStyles(props);
}
static getBaseProps(props) {
return getBaseProps(props, fallbackProps);
}
static expectedComponents: Array<keyof VictoryAxisProps> = [
"axisComponent",
"axisLabelComponent",
Expand Down
5 changes: 3 additions & 2 deletions packages/victory-bar/src/victory-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ class VictoryBarBase extends React.Component<VictoryBarProps> {

static getDomain = Domain.getDomainWithZero;
static getData = Data.getData;
static getBaseProps = (props: VictoryBarProps) =>
getBaseProps(props, fallbackProps);
static getBaseProps(props: VictoryBarProps) {
return getBaseProps(props, fallbackProps);
}
static expectedComponents: (keyof VictoryBarProps)[] = [
"dataComponent",
"labelComponent",
Expand Down
12 changes: 9 additions & 3 deletions packages/victory-box-plot/src/victory-box-plot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,15 @@ class VictoryBoxPlotBase extends React.Component<VictoryBoxPlotProps> {
theme: VictoryTheme.grayscale,
};

static getDomain = getDomain;
static getData = getData;
static getBaseProps = (props) => getBaseProps(props, fallbackProps);
static getDomain(props, axis) {
return getDomain(props, axis);
}
static getData(props) {
return getData(props);
}
static getBaseProps(props) {
return getBaseProps(props, fallbackProps);
}
static expectedComponents: Array<keyof VictoryBoxPlotProps> = [
"maxComponent",
"maxLabelComponent",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function brushContainerMixin<
mouseMoveThreshold: 0,
};

static defaultEvents = (props) => {
static defaultEvents(props) {
return [
{
target: "parent",
Expand Down Expand Up @@ -111,7 +111,7 @@ export function brushContainerMixin<
},
},
];
};
}

getSelectBox(props, coordinates) {
const { x, y } = coordinates;
Expand Down
13 changes: 9 additions & 4 deletions packages/victory-candlestick/src/victory-candlestick.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,15 @@ class VictoryCandlestickBase extends React.Component<VictoryCandlestickProps> {
theme: VictoryTheme.grayscale,
};

static getDomain = getDomain;
static getData = getData;
static getBaseProps = (props: VictoryCandlestickProps) =>
getBaseProps(props, fallbackProps);
static getDomain(props, axis) {
return getDomain(props, axis);
}
static getData(props) {
return getData(props);
}
static getBaseProps(props: VictoryCandlestickProps) {
return getBaseProps(props, fallbackProps);
}
static expectedComponents = [
"openLabelComponent",
"closeLabelComponent",
Expand Down
4 changes: 2 additions & 2 deletions packages/victory-create-container/src/create-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const combineContainerMixins = (
{},
);

static defaultEvents = (props) => {
static defaultEvents(props) {
return combineDefaultEvents(
Classes.reduce((defaultEvents, Class) => {
const events = Helpers.isFunction(Class.defaultEvents)
Expand All @@ -106,7 +106,7 @@ export const combineContainerMixins = (
return [...defaultEvents, ...events];
}, []),
);
};
}

getChildren(props) {
return instances.reduce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function cursorContainerMixin<
},
cursorComponent: <LineSegment />,
};
static defaultEvents = (props) => {
static defaultEvents(props) {
return [
{
target: "parent",
Expand All @@ -72,7 +72,7 @@ export function cursorContainerMixin<
},
},
];
};
}

getCursorPosition(props) {
const { cursorValue, defaultCursorValue, domain, cursorDimension } =
Expand Down
12 changes: 9 additions & 3 deletions packages/victory-errorbar/src/victory-errorbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,15 @@ class VictoryErrorBarBase extends React.Component<VictoryErrorBarProps> {
theme: VictoryTheme.grayscale,
};

static getDomain = getDomain;
static getData = getData;
static getBaseProps = (props) => getBaseProps(props, fallbackProps);
static getDomain(props, axis) {
return getDomain(props, axis);
}
static getData(props) {
return getData(props);
}
static getBaseProps(props) {
return getBaseProps(props, fallbackProps);
}
static expectedComponents = [
"dataComponent",
"labelComponent",
Expand Down
17 changes: 12 additions & 5 deletions packages/victory-histogram/src/victory-histogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ class VictoryHistogramBase extends React.Component<VictoryHistogramProps> {
},
};

static getFormattedData = getFormattedData;
static getFormattedData(...args: any) {
return getFormattedData(...args);
}

static defaultProps: VictoryHistogramProps = {
containerComponent: <VictoryContainer />,
Expand All @@ -111,10 +113,15 @@ class VictoryHistogramBase extends React.Component<VictoryHistogramProps> {
theme: VictoryTheme.grayscale,
};

static getDomain = getDomain;
static getData = getData;
static getBaseProps = (props: VictoryHistogramProps) =>
getBaseProps(props, fallbackProps);
static getDomain(props, axis) {
return getDomain(props, axis);
}
static getData(props) {
return getData(props);
}
static getBaseProps(props: VictoryHistogramProps) {
return getBaseProps(props, fallbackProps);
}
static expectedComponents: Partial<keyof VictoryHistogramProps>[] = [
"dataComponent",
"labelComponent",
Expand Down
10 changes: 6 additions & 4 deletions packages/victory-legend/src/victory-legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ class VictoryLegendBase extends React.Component<VictoryLegendProps> {
titleComponent: <VictoryLabel />,
};

static getBaseProps = (props: VictoryLegendProps) =>
getBaseProps(props, fallbackProps);
static getBaseProps(props: VictoryLegendProps) {
return getBaseProps(props, fallbackProps);
}

static getDimensions = (props: VictoryLegendProps) =>
getDimensions(props, fallbackProps);
static getDimensions(props: VictoryLegendProps) {
return getDimensions(props, fallbackProps);
}

static expectedComponents = [
"borderComponent",
Expand Down
4 changes: 3 additions & 1 deletion packages/victory-line/src/victory-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ class VictoryLineBase extends React.Component<VictoryLineProps> {

static getDomain = Domain.getDomain;
static getData = Data.getData;
static getBaseProps = (props) => getBaseProps(props, fallbackProps);
static getBaseProps(props) {
return getBaseProps(props, fallbackProps);
}
static expectedComponents = [
"dataComponent",
"labelComponent",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function nativeBrushMixin<
};

// overrides all web events with native specific events
static defaultEvents = (props: TProps) => {
static defaultEvents(props: TProps) {
return [
{
target: "parent",
Expand All @@ -77,7 +77,7 @@ function nativeBrushMixin<
},
},
];
};
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function nativeCursorMixin<
};

// overrides all web events with native specific events
static defaultEvents = (props: TProps) => {
static defaultEvents(props: TProps) {
return [
{
target: "parent",
Expand All @@ -65,7 +65,7 @@ function nativeCursorMixin<
},
},
];
};
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function nativeSelectionMixin<
};

// overrides all web events with native specific events
static defaultEvents = (props: TProps) => {
static defaultEvents(props: TProps) {
return [
{
target: "parent",
Expand All @@ -77,7 +77,7 @@ function nativeSelectionMixin<
},
},
];
};
}
};
}

Expand Down
66 changes: 34 additions & 32 deletions packages/victory-native/src/components/victory-tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,42 @@ export class VictoryTooltip extends VictoryTooltipBase {
groupComponent: <G />,
};

static defaultEvents = () => [
{
target: "data",
eventHandlers: {
onPressIn: (targetProps) => {
return [
{
target: "labels",
mutation: () => ({ active: true }),
},
{
target: "data",
mutation: () =>
targetProps.activateData
? { active: true }
: { active: undefined },
},
];
},
onPressOut: () => {
return [
{
target: "labels",
mutation: () => ({ active: undefined }),
},
{
target: "data",
mutation: () => ({ active: undefined }),
},
];
static defaultEvents() {
return [
{
target: "data",
eventHandlers: {
onPressIn: (targetProps) => {
return [
{
target: "labels",
mutation: () => ({ active: true }),
},
{
target: "data",
mutation: () =>
targetProps.activateData
? { active: true }
: { active: undefined },
},
];
},
onPressOut: () => {
return [
{
target: "labels",
mutation: () => ({ active: undefined }),
},
{
target: "data",
mutation: () => ({ active: undefined }),
},
];
},
},
},
},
];
];
}

renderTooltip(props) {
const evaluatedProps = this.getEvaluatedProps(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function nativeVoronoiMixin<
};

// overrides all web events with native specific events
static defaultEvents = (props: TProps) => {
static defaultEvents(props: TProps) {
return [
{
target: "parent",
Expand Down Expand Up @@ -76,7 +76,7 @@ function nativeVoronoiMixin<
},
},
];
};
}
};
}

Expand Down

0 comments on commit 06b9f31

Please sign in to comment.