victory-tooltip
Advanced tools
Comparing version 35.8.1 to 35.9.0
@@ -43,3 +43,5 @@ import * as React from "react"; | ||
pointerLength?: NumberOrCallback; | ||
pointerOrientation?: OrientationTypes | ((...args: any[]) => OrientationTypes); | ||
pointerOrientation?: | ||
| OrientationTypes | ||
| ((...args: any[]) => OrientationTypes); | ||
pointerWidth?: NumberOrCallback; | ||
@@ -87,3 +89,6 @@ renderInPortal?: boolean; | ||
export class VictoryTooltip extends React.Component<VictoryTooltipProps, any> { | ||
static defaultEvents: EventPropTypeInterface<string, StringOrNumberOrCallback>[]; | ||
static defaultEvents: EventPropTypeInterface< | ||
string, | ||
StringOrNumberOrCallback | ||
>[]; | ||
} |
@@ -43,3 +43,5 @@ import * as React from "react"; | ||
pointerLength?: NumberOrCallback; | ||
pointerOrientation?: OrientationTypes | ((...args: any[]) => OrientationTypes); | ||
pointerOrientation?: | ||
| OrientationTypes | ||
| ((...args: any[]) => OrientationTypes); | ||
pointerWidth?: NumberOrCallback; | ||
@@ -87,3 +89,6 @@ renderInPortal?: boolean; | ||
export class VictoryTooltip extends React.Component<VictoryTooltipProps, any> { | ||
static defaultEvents: EventPropTypeInterface<string, StringOrNumberOrCallback>[]; | ||
static defaultEvents: EventPropTypeInterface< | ||
string, | ||
StringOrNumberOrCallback | ||
>[]; | ||
} |
{ | ||
"name": "victory-tooltip", | ||
"version": "35.8.1", | ||
"version": "35.9.0", | ||
"description": "Tooltip Component for Victory", | ||
@@ -24,3 +24,3 @@ "keywords": [ | ||
"prop-types": "^15.5.8", | ||
"victory-core": "^35.8.1" | ||
"victory-core": "^35.9.0" | ||
}, | ||
@@ -27,0 +27,0 @@ "scripts": { |
@@ -8,3 +8,4 @@ /*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2] }]*/ | ||
const getVerticalPath = (props) => { | ||
const { pointerWidth, cornerRadius, orientation, width, height, center } = props; | ||
const { pointerWidth, cornerRadius, orientation, width, height, center } = | ||
props; | ||
const sign = orientation === "bottom" ? 1 : -1; | ||
@@ -23,3 +24,5 @@ const x = props.x + (props.dx || 0); | ||
return `M ${centerX - pointerWidth / 2}, ${pointerEdge} | ||
L ${pointerLength ? x : centerX + pointerWidth / 2}, ${pointerLength ? y : pointerEdge} | ||
L ${pointerLength ? x : centerX + pointerWidth / 2}, ${ | ||
pointerLength ? y : pointerEdge | ||
} | ||
L ${centerX + pointerWidth / 2}, ${pointerEdge} | ||
@@ -38,3 +41,4 @@ L ${rightEdge - cornerRadius}, ${pointerEdge} | ||
const getHorizontalPath = (props) => { | ||
const { pointerWidth, cornerRadius, orientation, width, height, center } = props; | ||
const { pointerWidth, cornerRadius, orientation, width, height, center } = | ||
props; | ||
const sign = orientation === "left" ? 1 : -1; | ||
@@ -53,3 +57,5 @@ const x = props.x + (props.dx || 0); | ||
return `M ${pointerEdge}, ${centerY - pointerWidth / 2} | ||
L ${pointerLength ? x : pointerEdge}, ${pointerLength ? y : centerY + pointerWidth / 2} | ||
L ${pointerLength ? x : pointerEdge}, ${ | ||
pointerLength ? y : centerY + pointerWidth / 2 | ||
} | ||
L ${pointerEdge}, ${centerY + pointerWidth / 2} | ||
@@ -56,0 +62,0 @@ L ${pointerEdge}, ${bottomEdge - cornerRadius} |
@@ -43,3 +43,5 @@ import * as React from "react"; | ||
pointerLength?: NumberOrCallback; | ||
pointerOrientation?: OrientationTypes | ((...args: any[]) => OrientationTypes); | ||
pointerOrientation?: | ||
| OrientationTypes | ||
| ((...args: any[]) => OrientationTypes); | ||
pointerWidth?: NumberOrCallback; | ||
@@ -87,3 +89,6 @@ renderInPortal?: boolean; | ||
export class VictoryTooltip extends React.Component<VictoryTooltipProps, any> { | ||
static defaultEvents: EventPropTypeInterface<string, StringOrNumberOrCallback>[]; | ||
static defaultEvents: EventPropTypeInterface< | ||
string, | ||
StringOrNumberOrCallback | ||
>[]; | ||
} |
@@ -29,3 +29,6 @@ import React from "react"; | ||
angle: PropTypes.number, | ||
center: PropTypes.shape({ x: CustomPropTypes.nonNegative, y: CustomPropTypes.nonNegative }), | ||
center: PropTypes.shape({ | ||
x: CustomPropTypes.nonNegative, | ||
y: CustomPropTypes.nonNegative | ||
}), | ||
centerOffset: PropTypes.shape({ | ||
@@ -36,3 +39,6 @@ x: PropTypes.oneOfType([PropTypes.number, PropTypes.func]), | ||
constrainToVisibleArea: PropTypes.bool, | ||
cornerRadius: PropTypes.oneOfType([CustomPropTypes.nonNegative, PropTypes.func]), | ||
cornerRadius: PropTypes.oneOfType([ | ||
CustomPropTypes.nonNegative, | ||
PropTypes.func | ||
]), | ||
data: PropTypes.array, | ||
@@ -44,3 +50,6 @@ datum: PropTypes.object, | ||
flyoutComponent: PropTypes.element, | ||
flyoutHeight: PropTypes.oneOfType([CustomPropTypes.nonNegative, PropTypes.func]), | ||
flyoutHeight: PropTypes.oneOfType([ | ||
CustomPropTypes.nonNegative, | ||
PropTypes.func | ||
]), | ||
flyoutPadding: PropTypes.oneOfType([ | ||
@@ -57,3 +66,6 @@ PropTypes.func, | ||
flyoutStyle: PropTypes.object, | ||
flyoutWidth: PropTypes.oneOfType([CustomPropTypes.nonNegative, PropTypes.func]), | ||
flyoutWidth: PropTypes.oneOfType([ | ||
CustomPropTypes.nonNegative, | ||
PropTypes.func | ||
]), | ||
groupComponent: PropTypes.element, | ||
@@ -69,3 +81,6 @@ height: PropTypes.number, | ||
]), | ||
pointerLength: PropTypes.oneOfType([CustomPropTypes.nonNegative, PropTypes.func]), | ||
pointerLength: PropTypes.oneOfType([ | ||
CustomPropTypes.nonNegative, | ||
PropTypes.func | ||
]), | ||
pointerOrientation: PropTypes.oneOfType([ | ||
@@ -75,3 +90,6 @@ PropTypes.oneOf(["top", "bottom", "left", "right"]), | ||
]), | ||
pointerWidth: PropTypes.oneOfType([CustomPropTypes.nonNegative, PropTypes.func]), | ||
pointerWidth: PropTypes.oneOfType([ | ||
CustomPropTypes.nonNegative, | ||
PropTypes.func | ||
]), | ||
polar: PropTypes.bool, | ||
@@ -183,3 +201,5 @@ renderInPortal: PropTypes.bool, | ||
const defaultFlyoutStyles = | ||
theme && theme.tooltip && theme.tooltip.flyoutStyle ? theme.tooltip.flyoutStyle : {}; | ||
theme && theme.tooltip && theme.tooltip.flyoutStyle | ||
? theme.tooltip.flyoutStyle | ||
: {}; | ||
const baseFlyoutStyle = props.flyoutStyle | ||
@@ -191,3 +211,6 @@ ? defaults({}, props.flyoutStyle, defaultFlyoutStyles) | ||
: Helpers.evaluateStyle(baseLabelStyle, props); | ||
const flyoutStyle = Helpers.evaluateStyle(baseFlyoutStyle, assign({}, props, { style })); | ||
const flyoutStyle = Helpers.evaluateStyle( | ||
baseFlyoutStyle, | ||
assign({}, props, { style }) | ||
); | ||
return { style, flyoutStyle }; | ||
@@ -200,4 +223,9 @@ } | ||
const active = Helpers.evaluateProp(props.active, props); | ||
const text = Helpers.evaluateProp(props.text, assign({}, props, { active })); | ||
const { style, flyoutStyle } = this.getStyles(assign({}, props, { active, text })); | ||
const text = Helpers.evaluateProp( | ||
props.text, | ||
assign({}, props, { active }) | ||
); | ||
const { style, flyoutStyle } = this.getStyles( | ||
assign({}, props, { active, text }) | ||
); | ||
const orientation = | ||
@@ -292,3 +320,4 @@ Helpers.evaluateProp( | ||
const labelStyle = style || {}; | ||
const angle = labelStyle.angle || props.angle || this.getDefaultAngle(props); | ||
const angle = | ||
labelStyle.angle || props.angle || this.getDefaultAngle(props); | ||
return angle ? `rotate(${angle} ${x} ${y})` : undefined; | ||
@@ -395,3 +424,5 @@ } | ||
} | ||
const paddings = Array.isArray(style) ? style.map((s) => s.padding) : [style.padding]; | ||
const paddings = Array.isArray(style) | ||
? style.map((s) => s.padding) | ||
: [style.padding]; | ||
return Math.max(...paddings, 0); | ||
@@ -411,3 +442,4 @@ } | ||
const getHeight = () => { | ||
const calculatedHeight = labelSize.height + flyoutPadding.top + flyoutPadding.bottom; | ||
const calculatedHeight = | ||
labelSize.height + flyoutPadding.top + flyoutPadding.bottom; | ||
@@ -421,3 +453,4 @@ const minHeight = | ||
const getWidth = () => { | ||
const calculatedWidth = labelSize.width + flyoutPadding.left + flyoutPadding.right; | ||
const calculatedWidth = | ||
labelSize.width + flyoutPadding.left + flyoutPadding.right; | ||
@@ -442,5 +475,8 @@ const minWidth = | ||
const { flyoutCenter, style, labelSize, dy = 0, dx = 0 } = calculatedValues; | ||
const { text, datum, activePoints, labelComponent, index, flyoutPadding } = props; | ||
const { text, datum, activePoints, labelComponent, index, flyoutPadding } = | ||
props; | ||
const textAnchor = | ||
(Array.isArray(style) && style.length ? style[0].textAnchor : style.textAnchor) || "middle"; | ||
(Array.isArray(style) && style.length | ||
? style[0].textAnchor | ||
: style.textAnchor) || "middle"; | ||
const getLabelX = () => { | ||
@@ -479,4 +515,10 @@ if (!textAnchor || textAnchor === "middle") { | ||
{ side: "top", val: edges.top > point.y ? edges.top - point.y : -1 }, | ||
{ side: "bottom", val: edges.bottom < point.y ? point.y - edges.bottom : -1 }, | ||
{ side: "right", val: edges.right < point.x ? point.x - edges.right : -1 }, | ||
{ | ||
side: "bottom", | ||
val: edges.bottom < point.y ? point.y - edges.bottom : -1 | ||
}, | ||
{ | ||
side: "right", | ||
val: edges.right < point.x ? point.x - edges.right : -1 | ||
}, | ||
{ side: "left", val: edges.left > point.x ? edges.left - point.x : -1 } | ||
@@ -504,3 +546,6 @@ ]; | ||
} = props; | ||
const pointerOrientation = Helpers.evaluateProp(props.pointerOrientation, props); | ||
const pointerOrientation = Helpers.evaluateProp( | ||
props.pointerOrientation, | ||
props | ||
); | ||
return defaults({}, flyoutComponent.props, { | ||
@@ -519,3 +564,4 @@ x, | ||
orientation: | ||
pointerOrientation || this.getPointerOrientation({ x, y }, flyoutCenter, flyoutDimensions), | ||
pointerOrientation || | ||
this.getPointerOrientation({ x, y }, flyoutCenter, flyoutDimensions), | ||
key: `${this.id}-tooltip-${index}`, | ||
@@ -544,4 +590,10 @@ width: flyoutDimensions.width, | ||
const children = [ | ||
React.cloneElement(flyoutComponent, this.getFlyoutProps(evaluatedProps, calculatedValues)), | ||
React.cloneElement(labelComponent, this.getLabelProps(evaluatedProps, calculatedValues)) | ||
React.cloneElement( | ||
flyoutComponent, | ||
this.getFlyoutProps(evaluatedProps, calculatedValues) | ||
), | ||
React.cloneElement( | ||
labelComponent, | ||
this.getLabelProps(evaluatedProps, calculatedValues) | ||
) | ||
]; | ||
@@ -548,0 +600,0 @@ const tooltip = React.cloneElement( |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1262623
23652
Updatedvictory-core@^35.9.0