victory-selection-container
Advanced tools
Comparing version 36.8.1 to 36.8.2
# victory-selection-container | ||
## 36.8.2 | ||
### Patch Changes | ||
- Migrated victory-selection-container to TypeScript ([#2706](https://github.com/FormidableLabs/victory/pull/2706)) | ||
## 36.8.1 | ||
@@ -4,0 +10,0 @@ |
@@ -1,41 +0,3 @@ | ||
import * as React from "react"; | ||
import { VictoryContainerProps } from "victory-core"; | ||
interface PointsInterface { | ||
childName?: string | string[]; | ||
eventKey?: string | number; | ||
data?: any; | ||
} | ||
interface VictorySelectionContainerProps extends VictoryContainerProps { | ||
activateSelectedData?: boolean; | ||
allowSelection?: boolean; | ||
disable?: boolean; | ||
onSelection?: ( | ||
points: PointsInterface[], | ||
bounds: { x: number | Date; y: number | Date }[], | ||
props: VictorySelectionContainerProps, | ||
) => void; | ||
onSelectionCleared?: (props: VictorySelectionContainerProps) => void; | ||
selectionBlacklist?: string[]; | ||
selectionComponent?: React.ReactElement; | ||
selectionDimension?: "x" | "y"; | ||
selectionStyle?: React.CSSProperties; | ||
} | ||
export class VictorySelectionContainer extends React.Component< | ||
VictorySelectionContainerProps, | ||
any | ||
> {} | ||
export const SelectionHelpers: { | ||
getDimension(props: any): any; | ||
getDatasets(props: any): any; | ||
filterDatasets(props: any, datasets: any, bounds: any): any; | ||
getSelectedData(props: any, dataset: any): any; | ||
onMouseDown(evt: any, targetProps: any): any; | ||
onMouseMove(evt: any, targetProps: any): any; | ||
onMouseUp(evt: any, targetProps: any): any; | ||
}; | ||
export const selectionContainerMixin: (base: Function) => Function; | ||
export * from "./victory-selection-container"; | ||
export * from "./selection-helpers"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export { selectionContainerMixin, default as VictorySelectionContainer } from "./victory-selection-container"; | ||
export { default as SelectionHelpers } from "./selection-helpers"; | ||
export * from "./victory-selection-container"; | ||
export * from "./selection-helpers"; |
@@ -7,8 +7,2 @@ import _includes from "lodash/includes"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
@@ -26,247 +20,277 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
import { Selection, Data, Helpers } from "victory-core"; | ||
import React from "react"; | ||
var SelectionHelpers = { | ||
getDimension: function (props) { | ||
var horizontal = props.horizontal, | ||
selectionDimension = props.selectionDimension; | ||
var ON_MOUSE_MOVE_THROTTLE_MS = 16; | ||
if (!horizontal || !selectionDimension) { | ||
return selectionDimension; | ||
} | ||
var SelectionHelpersClass = /*#__PURE__*/function () { | ||
function SelectionHelpersClass() { | ||
var _this = this; | ||
return selectionDimension === "x" ? "y" : "x"; | ||
}, | ||
getDatasets: function (props) { | ||
if (props.data) { | ||
return [{ | ||
data: props.data | ||
}]; | ||
} | ||
_classCallCheck(this, SelectionHelpersClass); | ||
var getData = function (childProps) { | ||
var data = Data.getData(childProps); | ||
return Array.isArray(data) && data.length > 0 ? data : undefined; | ||
}; | ||
this.onMouseDown = function (evt, targetProps) { | ||
evt.preventDefault(); | ||
var activateSelectedData = targetProps.activateSelectedData, | ||
allowSelection = targetProps.allowSelection, | ||
polar = targetProps.polar, | ||
selectedData = targetProps.selectedData; | ||
var iteratee = function (child, childName, parent) { | ||
var blacklist = props.selectionBlacklist || []; | ||
if (!allowSelection) { | ||
return {}; | ||
} | ||
if (!Data.isDataComponent(child) || _includes(blacklist, childName)) { | ||
return null; | ||
} else if (child.type && _isFunction(child.type.getData)) { | ||
child = parent ? /*#__PURE__*/React.cloneElement(child, parent.props) : child; | ||
var dimension = _this.getDimension(targetProps); | ||
var _childData = child.props && child.type.getData(child.props); | ||
var parentSVG = targetProps.parentSVG || Selection.getParentSVG(evt); | ||
return _childData ? { | ||
childName: childName, | ||
data: _childData | ||
} : null; | ||
var _Selection$getSVGEven = Selection.getSVGEventCoordinates(evt, parentSVG), | ||
x = _Selection$getSVGEven.x, | ||
y = _Selection$getSVGEven.y; | ||
var x1 = polar || dimension !== "y" ? x : Selection.getDomainCoordinates(targetProps).x[0]; | ||
var y1 = polar || dimension !== "x" ? y : Selection.getDomainCoordinates(targetProps).y[0]; | ||
var x2 = polar || dimension !== "y" ? x : Selection.getDomainCoordinates(targetProps).x[1]; | ||
var y2 = polar || dimension !== "x" ? y : Selection.getDomainCoordinates(targetProps).y[1]; | ||
var mutatedProps = { | ||
x1: x1, | ||
y1: y1, | ||
select: true, | ||
x2: x2, | ||
y2: y2, | ||
parentSVG: parentSVG | ||
}; | ||
if (selectedData && _isFunction(targetProps.onSelectionCleared)) { | ||
targetProps.onSelectionCleared(_defaults({}, mutatedProps, targetProps)); | ||
} | ||
var childData = getData(child.props); | ||
return childData ? { | ||
childName: childName, | ||
data: childData | ||
} : null; | ||
var parentMutation = [{ | ||
target: "parent", | ||
mutation: function () { | ||
return mutatedProps; | ||
} | ||
}]; | ||
var dataMutation = selectedData && activateSelectedData ? selectedData.map(function (d) { | ||
return { | ||
childName: d.childName, | ||
eventKey: d.eventKey, | ||
target: "data", | ||
mutation: function () { | ||
return null; | ||
} | ||
}; | ||
}) : []; | ||
return parentMutation.concat.apply(parentMutation, _toConsumableArray(dataMutation)); | ||
}; | ||
return Helpers.reduceChildren(React.Children.toArray(props.children), iteratee, props); | ||
}, | ||
filterDatasets: function (props, datasets, bounds) { | ||
var _this = this; | ||
this.handleMouseMove = function (evt, targetProps) { | ||
var allowSelection = targetProps.allowSelection, | ||
select = targetProps.select, | ||
polar = targetProps.polar; | ||
var filtered = datasets.reduce(function (memo, dataset) { | ||
var selectedData = _this.getSelectedData(props, dataset.data, bounds); | ||
var dimension = _this.getDimension(targetProps); | ||
memo = selectedData ? memo.concat({ | ||
childName: dataset.childName, | ||
eventKey: selectedData.eventKey, | ||
data: selectedData.data | ||
}) : memo; | ||
return memo; | ||
}, []); | ||
return filtered.length ? filtered : null; | ||
}, | ||
getSelectedData: function (props, dataset) { | ||
var x1 = props.x1, | ||
y1 = props.y1, | ||
x2 = props.x2, | ||
y2 = props.y2; | ||
if (!allowSelection || !select) { | ||
return null; | ||
} | ||
var withinBounds = function (d) { | ||
var scaledPoint = Helpers.scalePoint(props, d); | ||
return scaledPoint.x >= Math.min(x1, x2) && scaledPoint.x <= Math.max(x1, x2) && scaledPoint.y >= Math.min(y1, y2) && scaledPoint.y <= Math.max(y1, y2); | ||
var parentSVG = targetProps.parentSVG || Selection.getParentSVG(evt); | ||
var _Selection$getSVGEven2 = Selection.getSVGEventCoordinates(evt, parentSVG), | ||
x = _Selection$getSVGEven2.x, | ||
y = _Selection$getSVGEven2.y; | ||
var x2 = polar || dimension !== "y" ? x : Selection.getDomainCoordinates(targetProps).x[1]; | ||
var y2 = polar || dimension !== "x" ? y : Selection.getDomainCoordinates(targetProps).y[1]; | ||
return { | ||
target: "parent", | ||
mutation: function () { | ||
return { | ||
x2: x2, | ||
y2: y2, | ||
parentSVG: parentSVG | ||
}; | ||
} | ||
}; | ||
}; | ||
var eventKey = []; | ||
var data = []; | ||
var count = 0; | ||
this.onMouseMove = _throttle(this.handleMouseMove, ON_MOUSE_MOVE_THROTTLE_MS, { | ||
leading: true, | ||
trailing: false | ||
}); | ||
for (var index = 0, len = dataset.length; index < len; index++) { | ||
var datum = dataset[index]; | ||
this.onMouseUp = function (evt, targetProps) { | ||
var activateSelectedData = targetProps.activateSelectedData, | ||
allowSelection = targetProps.allowSelection, | ||
x2 = targetProps.x2, | ||
y2 = targetProps.y2; | ||
if (withinBounds(datum)) { | ||
data[count] = datum; | ||
eventKey[count] = datum.eventKey === undefined ? index : datum.eventKey; | ||
count++; | ||
if (!allowSelection) { | ||
return null; | ||
} | ||
} | ||
return count > 0 ? { | ||
eventKey: eventKey, | ||
data: data | ||
} : null; | ||
}, | ||
// eslint-disable-next-line complexity, max-statements | ||
onMouseDown: function (evt, targetProps) { | ||
evt.preventDefault(); | ||
var activateSelectedData = targetProps.activateSelectedData, | ||
allowSelection = targetProps.allowSelection, | ||
polar = targetProps.polar, | ||
selectedData = targetProps.selectedData; | ||
if (!x2 || !y2) { | ||
return [{ | ||
target: "parent", | ||
mutation: function () { | ||
return { | ||
select: false, | ||
x1: null, | ||
x2: null, | ||
y1: null, | ||
y2: null | ||
}; | ||
} | ||
}]; | ||
} | ||
if (!allowSelection) { | ||
return {}; | ||
} | ||
var datasets = _this.getDatasets(targetProps); | ||
var dimension = this.getDimension(targetProps); | ||
var parentSVG = targetProps.parentSVG || Selection.getParentSVG(evt); | ||
var bounds = Selection.getBounds(targetProps); | ||
var _Selection$getSVGEven = Selection.getSVGEventCoordinates(evt, parentSVG), | ||
x = _Selection$getSVGEven.x, | ||
y = _Selection$getSVGEven.y; | ||
var selectedData = _this.filterDatasets(targetProps, datasets); | ||
var x1 = polar || dimension !== "y" ? x : Selection.getDomainCoordinates(targetProps).x[0]; | ||
var y1 = polar || dimension !== "x" ? y : Selection.getDomainCoordinates(targetProps).y[0]; | ||
var x2 = polar || dimension !== "y" ? x : Selection.getDomainCoordinates(targetProps).x[1]; | ||
var y2 = polar || dimension !== "x" ? y : Selection.getDomainCoordinates(targetProps).y[1]; | ||
var mutatedProps = { | ||
x1: x1, | ||
y1: y1, | ||
select: true, | ||
x2: x2, | ||
y2: y2, | ||
parentSVG: parentSVG | ||
var mutatedProps = { | ||
selectedData: selectedData, | ||
datasets: datasets, | ||
select: false, | ||
x1: null, | ||
x2: null, | ||
y1: null, | ||
y2: null | ||
}; | ||
var callbackMutation = selectedData && _isFunction(targetProps.onSelection) ? targetProps.onSelection(selectedData, bounds, _defaults({}, mutatedProps, targetProps)) : {}; | ||
var parentMutation = [{ | ||
target: "parent", | ||
mutation: function () { | ||
return mutatedProps; | ||
} | ||
}]; | ||
var dataMutation = selectedData && activateSelectedData ? selectedData.map(function (d) { | ||
return { | ||
childName: d.childName, | ||
eventKey: d.eventKey, | ||
target: "data", | ||
mutation: function () { | ||
return _assign({ | ||
active: true | ||
}, callbackMutation); | ||
} | ||
}; | ||
}) : []; | ||
return parentMutation.concat(dataMutation); | ||
}; | ||
} | ||
if (selectedData && _isFunction(targetProps.onSelectionCleared)) { | ||
targetProps.onSelectionCleared(_defaults({}, mutatedProps, targetProps)); | ||
_createClass(SelectionHelpersClass, [{ | ||
key: "getDimension", | ||
value: function getDimension(props) { | ||
var horizontal = props.horizontal, | ||
selectionDimension = props.selectionDimension; | ||
if (!horizontal || !selectionDimension) { | ||
return selectionDimension; | ||
} | ||
return selectionDimension === "x" ? "y" : "x"; | ||
} | ||
}, { | ||
key: "getDatasets", | ||
value: function getDatasets(props) { | ||
if (props.data) { | ||
return [{ | ||
data: props.data | ||
}]; | ||
} | ||
var parentMutation = [{ | ||
target: "parent", | ||
mutation: function () { | ||
return mutatedProps; | ||
} | ||
}]; | ||
var dataMutation = selectedData && activateSelectedData ? selectedData.map(function (d) { | ||
return { | ||
childName: d.childName, | ||
eventKey: d.eventKey, | ||
target: "data", | ||
mutation: function () { | ||
var getData = function (childProps) { | ||
var data = Data.getData(childProps); | ||
return Array.isArray(data) && data.length > 0 ? data : undefined; | ||
}; | ||
var iteratee = function (child, childName, parent) { | ||
var blacklist = props.selectionBlacklist || []; | ||
if (!Data.isDataComponent(child) || _includes(blacklist, childName)) { | ||
return null; | ||
} else if (child.type && _isFunction(child.type.getData)) { | ||
child = parent ? /*#__PURE__*/React.cloneElement(child, parent.props) : child; | ||
var _childData = child.props && child.type.getData(child.props); | ||
return _childData ? { | ||
childName: childName, | ||
data: _childData | ||
} : null; | ||
} | ||
var childData = getData(child.props); | ||
return childData ? { | ||
childName: childName, | ||
data: childData | ||
} : null; | ||
}; | ||
}) : []; | ||
return parentMutation.concat.apply(parentMutation, _toConsumableArray(dataMutation)); | ||
}, | ||
onMouseMove: function (evt, targetProps) { | ||
var allowSelection = targetProps.allowSelection, | ||
select = targetProps.select, | ||
polar = targetProps.polar; | ||
var dimension = this.getDimension(targetProps); | ||
if (!allowSelection || !select) { | ||
return null; | ||
return Helpers.reduceChildren(React.Children.toArray(props.children), iteratee, props); | ||
} | ||
}, { | ||
key: "filterDatasets", | ||
value: function filterDatasets(props, datasets) { | ||
var _this2 = this; | ||
var parentSVG = targetProps.parentSVG || Selection.getParentSVG(evt); | ||
var filtered = datasets.reduce(function (memo, dataset) { | ||
var selectedData = _this2.getSelectedData(props, dataset.data); | ||
var _Selection$getSVGEven2 = Selection.getSVGEventCoordinates(evt, parentSVG), | ||
x = _Selection$getSVGEven2.x, | ||
y = _Selection$getSVGEven2.y; | ||
memo = selectedData ? memo.concat({ | ||
childName: dataset.childName, | ||
eventKey: selectedData.eventKey, | ||
data: selectedData.data | ||
}) : memo; | ||
return memo; | ||
}, []); | ||
return filtered.length ? filtered : null; | ||
} | ||
}, { | ||
key: "getSelectedData", | ||
value: function getSelectedData(props, dataset) { | ||
var x1 = props.x1, | ||
y1 = props.y1, | ||
x2 = props.x2, | ||
y2 = props.y2; | ||
var x2 = polar || dimension !== "y" ? x : Selection.getDomainCoordinates(targetProps).x[1]; | ||
var y2 = polar || dimension !== "x" ? y : Selection.getDomainCoordinates(targetProps).y[1]; | ||
return { | ||
target: "parent", | ||
mutation: function () { | ||
return { | ||
x2: x2, | ||
y2: y2, | ||
parentSVG: parentSVG | ||
}; | ||
} | ||
}; | ||
}, | ||
onMouseUp: function (evt, targetProps) { | ||
var activateSelectedData = targetProps.activateSelectedData, | ||
allowSelection = targetProps.allowSelection, | ||
x2 = targetProps.x2, | ||
y2 = targetProps.y2; | ||
var withinBounds = function (d) { | ||
var scaledPoint = Helpers.scalePoint(props, d); | ||
return scaledPoint.x >= Math.min(x1, x2) && scaledPoint.x <= Math.max(x1, x2) && scaledPoint.y >= Math.min(y1, y2) && scaledPoint.y <= Math.max(y1, y2); | ||
}; | ||
if (!allowSelection) { | ||
return null; | ||
} | ||
var eventKey = []; | ||
var data = []; | ||
var count = 0; | ||
if (!x2 || !y2) { | ||
return [{ | ||
target: "parent", | ||
mutation: function () { | ||
return { | ||
select: false, | ||
x1: null, | ||
x2: null, | ||
y1: null, | ||
y2: null | ||
}; | ||
for (var index = 0, len = dataset.length; index < len; index++) { | ||
var datum = dataset[index]; | ||
if (withinBounds(datum)) { | ||
data[count] = datum; | ||
eventKey[count] = datum.eventKey === undefined ? index : datum.eventKey; | ||
count++; | ||
} | ||
}]; | ||
} | ||
return count > 0 ? { | ||
eventKey: eventKey, | ||
data: data | ||
} : null; | ||
} | ||
}]); | ||
var datasets = this.getDatasets(targetProps); | ||
var bounds = Selection.getBounds(targetProps); | ||
var selectedData = this.filterDatasets(targetProps, datasets, bounds); | ||
var mutatedProps = { | ||
selectedData: selectedData, | ||
datasets: datasets, | ||
select: false, | ||
x1: null, | ||
x2: null, | ||
y1: null, | ||
y2: null | ||
}; | ||
var callbackMutation = selectedData && _isFunction(targetProps.onSelection) ? targetProps.onSelection(selectedData, bounds, _defaults({}, mutatedProps, targetProps)) : {}; | ||
var parentMutation = [{ | ||
target: "parent", | ||
mutation: function () { | ||
return mutatedProps; | ||
} | ||
}]; | ||
var dataMutation = selectedData && activateSelectedData ? selectedData.map(function (d) { | ||
return { | ||
childName: d.childName, | ||
eventKey: d.eventKey, | ||
target: "data", | ||
mutation: function () { | ||
return _assign({ | ||
active: true | ||
}, callbackMutation); | ||
} | ||
}; | ||
}) : []; | ||
return parentMutation.concat(dataMutation); | ||
} | ||
}; | ||
export default _objectSpread(_objectSpread({}, SelectionHelpers), {}, { | ||
onMouseDown: SelectionHelpers.onMouseDown.bind(SelectionHelpers), | ||
onMouseUp: SelectionHelpers.onMouseUp.bind(SelectionHelpers), | ||
onMouseMove: _throttle(SelectionHelpers.onMouseMove.bind(SelectionHelpers), 16, // eslint-disable-line no-magic-numbers | ||
{ | ||
leading: true, | ||
trailing: false | ||
}) | ||
}); | ||
return SelectionHelpersClass; | ||
}(); | ||
export var SelectionHelpers = new SelectionHelpersClass(); |
@@ -39,11 +39,11 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
import { VictoryContainer, Rect } from "victory-core"; | ||
import SelectionHelpers from "./selection-helpers"; | ||
export var selectionContainerMixin = function (base) { | ||
import { Rect, VictoryContainer } from "victory-core"; | ||
import { SelectionHelpers } from "./selection-helpers"; | ||
export function selectionContainerMixin(Base) { | ||
var _class; | ||
return _class = /*#__PURE__*/function (_base) { | ||
_inherits(VictorySelectionContainer, _base); | ||
// @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'." | ||
return _class = /*#__PURE__*/function (_Base) { | ||
_inherits(VictorySelectionContainer, _Base); | ||
@@ -90,13 +90,3 @@ var _super = _createSuper(VictorySelectionContainer); | ||
return VictorySelectionContainer; | ||
}(base), _class.displayName = "VictorySelectionContainer", _class.propTypes = _objectSpread(_objectSpread({}, VictoryContainer.propTypes), {}, { | ||
activateSelectedData: PropTypes.bool, | ||
allowSelection: PropTypes.bool, | ||
disable: PropTypes.bool, | ||
onSelection: PropTypes.func, | ||
onSelectionCleared: PropTypes.func, | ||
selectionBlacklist: PropTypes.arrayOf(PropTypes.string), | ||
selectionComponent: PropTypes.element, | ||
selectionDimension: PropTypes.oneOf(["x", "y"]), | ||
selectionStyle: PropTypes.object | ||
}), _class.defaultProps = _objectSpread(_objectSpread({}, VictoryContainer.defaultProps), {}, { | ||
}(Base), _class.displayName = "VictorySelectionContainer", _class.defaultProps = _objectSpread(_objectSpread({}, VictoryContainer.defaultProps), {}, { | ||
activateSelectedData: true, | ||
@@ -135,5 +125,3 @@ allowSelection: true, | ||
}, _class; | ||
}; | ||
export default selectionContainerMixin(VictoryContainer); // @ts-expect-error IMPORTANT: when converting this file to TypeScript, you must export the type as well: | ||
// export const VictorySelectionContainer = selectionContainerMixin(VictoryContainer); | ||
// export type VictorySelectionContainer = typeof VictorySelectionContainer; | ||
} | ||
export var VictorySelectionContainer = selectionContainerMixin(VictoryContainer); |
@@ -1,41 +0,3 @@ | ||
import * as React from "react"; | ||
import { VictoryContainerProps } from "victory-core"; | ||
interface PointsInterface { | ||
childName?: string | string[]; | ||
eventKey?: string | number; | ||
data?: any; | ||
} | ||
interface VictorySelectionContainerProps extends VictoryContainerProps { | ||
activateSelectedData?: boolean; | ||
allowSelection?: boolean; | ||
disable?: boolean; | ||
onSelection?: ( | ||
points: PointsInterface[], | ||
bounds: { x: number | Date; y: number | Date }[], | ||
props: VictorySelectionContainerProps, | ||
) => void; | ||
onSelectionCleared?: (props: VictorySelectionContainerProps) => void; | ||
selectionBlacklist?: string[]; | ||
selectionComponent?: React.ReactElement; | ||
selectionDimension?: "x" | "y"; | ||
selectionStyle?: React.CSSProperties; | ||
} | ||
export class VictorySelectionContainer extends React.Component< | ||
VictorySelectionContainerProps, | ||
any | ||
> {} | ||
export const SelectionHelpers: { | ||
getDimension(props: any): any; | ||
getDatasets(props: any): any; | ||
filterDatasets(props: any, datasets: any, bounds: any): any; | ||
getSelectedData(props: any, dataset: any): any; | ||
onMouseDown(evt: any, targetProps: any): any; | ||
onMouseMove(evt: any, targetProps: any): any; | ||
onMouseUp(evt: any, targetProps: any): any; | ||
}; | ||
export const selectionContainerMixin: (base: Function) => Function; | ||
export * from "./victory-selection-container"; | ||
export * from "./selection-helpers"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -6,29 +6,27 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "SelectionHelpers", { | ||
enumerable: true, | ||
get: function () { | ||
return _selectionHelpers.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "VictorySelectionContainer", { | ||
enumerable: true, | ||
get: function () { | ||
return _victorySelectionContainer.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "selectionContainerMixin", { | ||
enumerable: true, | ||
get: function () { | ||
return _victorySelectionContainer.selectionContainerMixin; | ||
} | ||
}); | ||
var _victorySelectionContainer = _interopRequireWildcard(require("./victory-selection-container")); | ||
var _victorySelectionContainer = require("./victory-selection-container"); | ||
var _selectionHelpers = _interopRequireDefault(require("./selection-helpers")); | ||
Object.keys(_victorySelectionContainer).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _victorySelectionContainer[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _victorySelectionContainer[key]; | ||
} | ||
}); | ||
}); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _selectionHelpers = require("./selection-helpers"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
Object.keys(_selectionHelpers).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (key in exports && exports[key] === _selectionHelpers[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _selectionHelpers[key]; | ||
} | ||
}); | ||
}); |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports.SelectionHelpers = void 0; | ||
@@ -25,8 +25,2 @@ var _includes2 = _interopRequireDefault(require("lodash/includes")); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
@@ -44,253 +38,278 @@ | ||
var SelectionHelpers = { | ||
getDimension: function (props) { | ||
var horizontal = props.horizontal, | ||
selectionDimension = props.selectionDimension; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
if (!horizontal || !selectionDimension) { | ||
return selectionDimension; | ||
} | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
return selectionDimension === "x" ? "y" : "x"; | ||
}, | ||
getDatasets: function (props) { | ||
if (props.data) { | ||
return [{ | ||
data: props.data | ||
}]; | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
var getData = function (childProps) { | ||
var data = _victoryCore.Data.getData(childProps); | ||
var ON_MOUSE_MOVE_THROTTLE_MS = 16; | ||
return Array.isArray(data) && data.length > 0 ? data : undefined; | ||
}; | ||
var SelectionHelpersClass = /*#__PURE__*/function () { | ||
function SelectionHelpersClass() { | ||
var _this = this; | ||
var iteratee = function (child, childName, parent) { | ||
var blacklist = props.selectionBlacklist || []; | ||
_classCallCheck(this, SelectionHelpersClass); | ||
if (!_victoryCore.Data.isDataComponent(child) || (0, _includes2.default)(blacklist, childName)) { | ||
return null; | ||
} else if (child.type && (0, _isFunction2.default)(child.type.getData)) { | ||
child = parent ? /*#__PURE__*/_react.default.cloneElement(child, parent.props) : child; | ||
this.onMouseDown = function (evt, targetProps) { | ||
evt.preventDefault(); | ||
var activateSelectedData = targetProps.activateSelectedData, | ||
allowSelection = targetProps.allowSelection, | ||
polar = targetProps.polar, | ||
selectedData = targetProps.selectedData; | ||
var _childData = child.props && child.type.getData(child.props); | ||
return _childData ? { | ||
childName: childName, | ||
data: _childData | ||
} : null; | ||
if (!allowSelection) { | ||
return {}; | ||
} | ||
var childData = getData(child.props); | ||
return childData ? { | ||
childName: childName, | ||
data: childData | ||
} : null; | ||
}; | ||
var dimension = _this.getDimension(targetProps); | ||
return _victoryCore.Helpers.reduceChildren(_react.default.Children.toArray(props.children), iteratee, props); | ||
}, | ||
filterDatasets: function (props, datasets, bounds) { | ||
var _this = this; | ||
var parentSVG = targetProps.parentSVG || _victoryCore.Selection.getParentSVG(evt); | ||
var filtered = datasets.reduce(function (memo, dataset) { | ||
var selectedData = _this.getSelectedData(props, dataset.data, bounds); | ||
var _Selection$getSVGEven = _victoryCore.Selection.getSVGEventCoordinates(evt, parentSVG), | ||
x = _Selection$getSVGEven.x, | ||
y = _Selection$getSVGEven.y; | ||
memo = selectedData ? memo.concat({ | ||
childName: dataset.childName, | ||
eventKey: selectedData.eventKey, | ||
data: selectedData.data | ||
}) : memo; | ||
return memo; | ||
}, []); | ||
return filtered.length ? filtered : null; | ||
}, | ||
getSelectedData: function (props, dataset) { | ||
var x1 = props.x1, | ||
y1 = props.y1, | ||
x2 = props.x2, | ||
y2 = props.y2; | ||
var x1 = polar || dimension !== "y" ? x : _victoryCore.Selection.getDomainCoordinates(targetProps).x[0]; | ||
var y1 = polar || dimension !== "x" ? y : _victoryCore.Selection.getDomainCoordinates(targetProps).y[0]; | ||
var x2 = polar || dimension !== "y" ? x : _victoryCore.Selection.getDomainCoordinates(targetProps).x[1]; | ||
var y2 = polar || dimension !== "x" ? y : _victoryCore.Selection.getDomainCoordinates(targetProps).y[1]; | ||
var mutatedProps = { | ||
x1: x1, | ||
y1: y1, | ||
select: true, | ||
x2: x2, | ||
y2: y2, | ||
parentSVG: parentSVG | ||
}; | ||
var withinBounds = function (d) { | ||
var scaledPoint = _victoryCore.Helpers.scalePoint(props, d); | ||
if (selectedData && (0, _isFunction2.default)(targetProps.onSelectionCleared)) { | ||
targetProps.onSelectionCleared((0, _defaults2.default)({}, mutatedProps, targetProps)); | ||
} | ||
return scaledPoint.x >= Math.min(x1, x2) && scaledPoint.x <= Math.max(x1, x2) && scaledPoint.y >= Math.min(y1, y2) && scaledPoint.y <= Math.max(y1, y2); | ||
var parentMutation = [{ | ||
target: "parent", | ||
mutation: function () { | ||
return mutatedProps; | ||
} | ||
}]; | ||
var dataMutation = selectedData && activateSelectedData ? selectedData.map(function (d) { | ||
return { | ||
childName: d.childName, | ||
eventKey: d.eventKey, | ||
target: "data", | ||
mutation: function () { | ||
return null; | ||
} | ||
}; | ||
}) : []; | ||
return parentMutation.concat.apply(parentMutation, _toConsumableArray(dataMutation)); | ||
}; | ||
var eventKey = []; | ||
var data = []; | ||
var count = 0; | ||
this.handleMouseMove = function (evt, targetProps) { | ||
var allowSelection = targetProps.allowSelection, | ||
select = targetProps.select, | ||
polar = targetProps.polar; | ||
for (var index = 0, len = dataset.length; index < len; index++) { | ||
var datum = dataset[index]; | ||
var dimension = _this.getDimension(targetProps); | ||
if (withinBounds(datum)) { | ||
data[count] = datum; | ||
eventKey[count] = datum.eventKey === undefined ? index : datum.eventKey; | ||
count++; | ||
if (!allowSelection || !select) { | ||
return null; | ||
} | ||
} | ||
return count > 0 ? { | ||
eventKey: eventKey, | ||
data: data | ||
} : null; | ||
}, | ||
// eslint-disable-next-line complexity, max-statements | ||
onMouseDown: function (evt, targetProps) { | ||
evt.preventDefault(); | ||
var activateSelectedData = targetProps.activateSelectedData, | ||
allowSelection = targetProps.allowSelection, | ||
polar = targetProps.polar, | ||
selectedData = targetProps.selectedData; | ||
var parentSVG = targetProps.parentSVG || _victoryCore.Selection.getParentSVG(evt); | ||
if (!allowSelection) { | ||
return {}; | ||
} | ||
var _Selection$getSVGEven2 = _victoryCore.Selection.getSVGEventCoordinates(evt, parentSVG), | ||
x = _Selection$getSVGEven2.x, | ||
y = _Selection$getSVGEven2.y; | ||
var dimension = this.getDimension(targetProps); | ||
var parentSVG = targetProps.parentSVG || _victoryCore.Selection.getParentSVG(evt); | ||
var _Selection$getSVGEven = _victoryCore.Selection.getSVGEventCoordinates(evt, parentSVG), | ||
x = _Selection$getSVGEven.x, | ||
y = _Selection$getSVGEven.y; | ||
var x1 = polar || dimension !== "y" ? x : _victoryCore.Selection.getDomainCoordinates(targetProps).x[0]; | ||
var y1 = polar || dimension !== "x" ? y : _victoryCore.Selection.getDomainCoordinates(targetProps).y[0]; | ||
var x2 = polar || dimension !== "y" ? x : _victoryCore.Selection.getDomainCoordinates(targetProps).x[1]; | ||
var y2 = polar || dimension !== "x" ? y : _victoryCore.Selection.getDomainCoordinates(targetProps).y[1]; | ||
var mutatedProps = { | ||
x1: x1, | ||
y1: y1, | ||
select: true, | ||
x2: x2, | ||
y2: y2, | ||
parentSVG: parentSVG | ||
}; | ||
if (selectedData && (0, _isFunction2.default)(targetProps.onSelectionCleared)) { | ||
targetProps.onSelectionCleared((0, _defaults2.default)({}, mutatedProps, targetProps)); | ||
} | ||
var parentMutation = [{ | ||
target: "parent", | ||
mutation: function () { | ||
return mutatedProps; | ||
} | ||
}]; | ||
var dataMutation = selectedData && activateSelectedData ? selectedData.map(function (d) { | ||
var x2 = polar || dimension !== "y" ? x : _victoryCore.Selection.getDomainCoordinates(targetProps).x[1]; | ||
var y2 = polar || dimension !== "x" ? y : _victoryCore.Selection.getDomainCoordinates(targetProps).y[1]; | ||
return { | ||
childName: d.childName, | ||
eventKey: d.eventKey, | ||
target: "data", | ||
target: "parent", | ||
mutation: function () { | ||
return null; | ||
return { | ||
x2: x2, | ||
y2: y2, | ||
parentSVG: parentSVG | ||
}; | ||
} | ||
}; | ||
}) : []; | ||
return parentMutation.concat.apply(parentMutation, _toConsumableArray(dataMutation)); | ||
}, | ||
onMouseMove: function (evt, targetProps) { | ||
var allowSelection = targetProps.allowSelection, | ||
select = targetProps.select, | ||
polar = targetProps.polar; | ||
var dimension = this.getDimension(targetProps); | ||
}; | ||
if (!allowSelection || !select) { | ||
return null; | ||
} | ||
this.onMouseMove = (0, _throttle2.default)(this.handleMouseMove, ON_MOUSE_MOVE_THROTTLE_MS, { | ||
leading: true, | ||
trailing: false | ||
}); | ||
var parentSVG = targetProps.parentSVG || _victoryCore.Selection.getParentSVG(evt); | ||
this.onMouseUp = function (evt, targetProps) { | ||
var activateSelectedData = targetProps.activateSelectedData, | ||
allowSelection = targetProps.allowSelection, | ||
x2 = targetProps.x2, | ||
y2 = targetProps.y2; | ||
var _Selection$getSVGEven2 = _victoryCore.Selection.getSVGEventCoordinates(evt, parentSVG), | ||
x = _Selection$getSVGEven2.x, | ||
y = _Selection$getSVGEven2.y; | ||
if (!allowSelection) { | ||
return null; | ||
} | ||
var x2 = polar || dimension !== "y" ? x : _victoryCore.Selection.getDomainCoordinates(targetProps).x[1]; | ||
var y2 = polar || dimension !== "x" ? y : _victoryCore.Selection.getDomainCoordinates(targetProps).y[1]; | ||
return { | ||
target: "parent", | ||
mutation: function () { | ||
return { | ||
x2: x2, | ||
y2: y2, | ||
parentSVG: parentSVG | ||
}; | ||
if (!x2 || !y2) { | ||
return [{ | ||
target: "parent", | ||
mutation: function () { | ||
return { | ||
select: false, | ||
x1: null, | ||
x2: null, | ||
y1: null, | ||
y2: null | ||
}; | ||
} | ||
}]; | ||
} | ||
}; | ||
}, | ||
onMouseUp: function (evt, targetProps) { | ||
var activateSelectedData = targetProps.activateSelectedData, | ||
allowSelection = targetProps.allowSelection, | ||
x2 = targetProps.x2, | ||
y2 = targetProps.y2; | ||
if (!allowSelection) { | ||
return null; | ||
} | ||
var datasets = _this.getDatasets(targetProps); | ||
if (!x2 || !y2) { | ||
return [{ | ||
var bounds = _victoryCore.Selection.getBounds(targetProps); | ||
var selectedData = _this.filterDatasets(targetProps, datasets); | ||
var mutatedProps = { | ||
selectedData: selectedData, | ||
datasets: datasets, | ||
select: false, | ||
x1: null, | ||
x2: null, | ||
y1: null, | ||
y2: null | ||
}; | ||
var callbackMutation = selectedData && (0, _isFunction2.default)(targetProps.onSelection) ? targetProps.onSelection(selectedData, bounds, (0, _defaults2.default)({}, mutatedProps, targetProps)) : {}; | ||
var parentMutation = [{ | ||
target: "parent", | ||
mutation: function () { | ||
return { | ||
select: false, | ||
x1: null, | ||
x2: null, | ||
y1: null, | ||
y2: null | ||
}; | ||
return mutatedProps; | ||
} | ||
}]; | ||
var dataMutation = selectedData && activateSelectedData ? selectedData.map(function (d) { | ||
return { | ||
childName: d.childName, | ||
eventKey: d.eventKey, | ||
target: "data", | ||
mutation: function () { | ||
return (0, _assign2.default)({ | ||
active: true | ||
}, callbackMutation); | ||
} | ||
}; | ||
}) : []; | ||
return parentMutation.concat(dataMutation); | ||
}; | ||
} | ||
_createClass(SelectionHelpersClass, [{ | ||
key: "getDimension", | ||
value: function getDimension(props) { | ||
var horizontal = props.horizontal, | ||
selectionDimension = props.selectionDimension; | ||
if (!horizontal || !selectionDimension) { | ||
return selectionDimension; | ||
} | ||
return selectionDimension === "x" ? "y" : "x"; | ||
} | ||
}, { | ||
key: "getDatasets", | ||
value: function getDatasets(props) { | ||
if (props.data) { | ||
return [{ | ||
data: props.data | ||
}]; | ||
} | ||
var datasets = this.getDatasets(targetProps); | ||
var getData = function (childProps) { | ||
var data = _victoryCore.Data.getData(childProps); | ||
var bounds = _victoryCore.Selection.getBounds(targetProps); | ||
return Array.isArray(data) && data.length > 0 ? data : undefined; | ||
}; | ||
var selectedData = this.filterDatasets(targetProps, datasets, bounds); | ||
var mutatedProps = { | ||
selectedData: selectedData, | ||
datasets: datasets, | ||
select: false, | ||
x1: null, | ||
x2: null, | ||
y1: null, | ||
y2: null | ||
}; | ||
var callbackMutation = selectedData && (0, _isFunction2.default)(targetProps.onSelection) ? targetProps.onSelection(selectedData, bounds, (0, _defaults2.default)({}, mutatedProps, targetProps)) : {}; | ||
var parentMutation = [{ | ||
target: "parent", | ||
mutation: function () { | ||
return mutatedProps; | ||
} | ||
}]; | ||
var dataMutation = selectedData && activateSelectedData ? selectedData.map(function (d) { | ||
return { | ||
childName: d.childName, | ||
eventKey: d.eventKey, | ||
target: "data", | ||
mutation: function () { | ||
return (0, _assign2.default)({ | ||
active: true | ||
}, callbackMutation); | ||
var iteratee = function (child, childName, parent) { | ||
var blacklist = props.selectionBlacklist || []; | ||
if (!_victoryCore.Data.isDataComponent(child) || (0, _includes2.default)(blacklist, childName)) { | ||
return null; | ||
} else if (child.type && (0, _isFunction2.default)(child.type.getData)) { | ||
child = parent ? /*#__PURE__*/_react.default.cloneElement(child, parent.props) : child; | ||
var _childData = child.props && child.type.getData(child.props); | ||
return _childData ? { | ||
childName: childName, | ||
data: _childData | ||
} : null; | ||
} | ||
var childData = getData(child.props); | ||
return childData ? { | ||
childName: childName, | ||
data: childData | ||
} : null; | ||
}; | ||
}) : []; | ||
return parentMutation.concat(dataMutation); | ||
} | ||
}; | ||
var _default = _objectSpread(_objectSpread({}, SelectionHelpers), {}, { | ||
onMouseDown: SelectionHelpers.onMouseDown.bind(SelectionHelpers), | ||
onMouseUp: SelectionHelpers.onMouseUp.bind(SelectionHelpers), | ||
onMouseMove: (0, _throttle2.default)(SelectionHelpers.onMouseMove.bind(SelectionHelpers), 16, // eslint-disable-line no-magic-numbers | ||
{ | ||
leading: true, | ||
trailing: false | ||
}) | ||
}); | ||
return _victoryCore.Helpers.reduceChildren(_react.default.Children.toArray(props.children), iteratee, props); | ||
} | ||
}, { | ||
key: "filterDatasets", | ||
value: function filterDatasets(props, datasets) { | ||
var _this2 = this; | ||
exports.default = _default; | ||
var filtered = datasets.reduce(function (memo, dataset) { | ||
var selectedData = _this2.getSelectedData(props, dataset.data); | ||
memo = selectedData ? memo.concat({ | ||
childName: dataset.childName, | ||
eventKey: selectedData.eventKey, | ||
data: selectedData.data | ||
}) : memo; | ||
return memo; | ||
}, []); | ||
return filtered.length ? filtered : null; | ||
} | ||
}, { | ||
key: "getSelectedData", | ||
value: function getSelectedData(props, dataset) { | ||
var x1 = props.x1, | ||
y1 = props.y1, | ||
x2 = props.x2, | ||
y2 = props.y2; | ||
var withinBounds = function (d) { | ||
var scaledPoint = _victoryCore.Helpers.scalePoint(props, d); | ||
return scaledPoint.x >= Math.min(x1, x2) && scaledPoint.x <= Math.max(x1, x2) && scaledPoint.y >= Math.min(y1, y2) && scaledPoint.y <= Math.max(y1, y2); | ||
}; | ||
var eventKey = []; | ||
var data = []; | ||
var count = 0; | ||
for (var index = 0, len = dataset.length; index < len; index++) { | ||
var datum = dataset[index]; | ||
if (withinBounds(datum)) { | ||
data[count] = datum; | ||
eventKey[count] = datum.eventKey === undefined ? index : datum.eventKey; | ||
count++; | ||
} | ||
} | ||
return count > 0 ? { | ||
eventKey: eventKey, | ||
data: data | ||
} : null; | ||
} | ||
}]); | ||
return SelectionHelpersClass; | ||
}(); | ||
var SelectionHelpers = new SelectionHelpersClass(); | ||
exports.SelectionHelpers = SelectionHelpers; |
@@ -6,6 +6,5 @@ "use strict"; | ||
}); | ||
exports.selectionContainerMixin = exports.default = void 0; | ||
exports.VictorySelectionContainer = void 0; | ||
exports.selectionContainerMixin = selectionContainerMixin; | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _react = _interopRequireDefault(require("react")); | ||
@@ -15,3 +14,3 @@ | ||
var _selectionHelpers = _interopRequireDefault(require("./selection-helpers")); | ||
var _selectionHelpers = require("./selection-helpers"); | ||
@@ -58,7 +57,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var selectionContainerMixin = function (base) { | ||
function selectionContainerMixin(Base) { | ||
var _class; | ||
return _class = /*#__PURE__*/function (_base) { | ||
_inherits(VictorySelectionContainer, _base); | ||
// @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'." | ||
return _class = /*#__PURE__*/function (_Base) { | ||
_inherits(VictorySelectionContainer, _Base); | ||
@@ -105,13 +105,3 @@ var _super = _createSuper(VictorySelectionContainer); | ||
return VictorySelectionContainer; | ||
}(base), _class.displayName = "VictorySelectionContainer", _class.propTypes = _objectSpread(_objectSpread({}, _victoryCore.VictoryContainer.propTypes), {}, { | ||
activateSelectedData: _propTypes.default.bool, | ||
allowSelection: _propTypes.default.bool, | ||
disable: _propTypes.default.bool, | ||
onSelection: _propTypes.default.func, | ||
onSelectionCleared: _propTypes.default.func, | ||
selectionBlacklist: _propTypes.default.arrayOf(_propTypes.default.string), | ||
selectionComponent: _propTypes.default.element, | ||
selectionDimension: _propTypes.default.oneOf(["x", "y"]), | ||
selectionStyle: _propTypes.default.object | ||
}), _class.defaultProps = _objectSpread(_objectSpread({}, _victoryCore.VictoryContainer.defaultProps), {}, { | ||
}(Base), _class.displayName = "VictorySelectionContainer", _class.defaultProps = _objectSpread(_objectSpread({}, _victoryCore.VictoryContainer.defaultProps), {}, { | ||
activateSelectedData: true, | ||
@@ -130,18 +120,18 @@ allowSelection: true, | ||
onMouseDown: function (evt, targetProps) { | ||
return props.disable ? {} : _selectionHelpers.default.onMouseDown(evt, targetProps); | ||
return props.disable ? {} : _selectionHelpers.SelectionHelpers.onMouseDown(evt, targetProps); | ||
}, | ||
onTouchStart: function (evt, targetProps) { | ||
return props.disable ? {} : _selectionHelpers.default.onMouseDown(evt, targetProps); | ||
return props.disable ? {} : _selectionHelpers.SelectionHelpers.onMouseDown(evt, targetProps); | ||
}, | ||
onMouseMove: function (evt, targetProps) { | ||
return props.disable ? {} : _selectionHelpers.default.onMouseMove(evt, targetProps); | ||
return props.disable ? {} : _selectionHelpers.SelectionHelpers.onMouseMove(evt, targetProps); | ||
}, | ||
onTouchMove: function (evt, targetProps) { | ||
return props.disable ? {} : _selectionHelpers.default.onMouseMove(evt, targetProps); | ||
return props.disable ? {} : _selectionHelpers.SelectionHelpers.onMouseMove(evt, targetProps); | ||
}, | ||
onMouseUp: function (evt, targetProps) { | ||
return props.disable ? {} : _selectionHelpers.default.onMouseUp(evt, targetProps); | ||
return props.disable ? {} : _selectionHelpers.SelectionHelpers.onMouseUp(evt, targetProps); | ||
}, | ||
onTouchEnd: function (evt, targetProps) { | ||
return props.disable ? {} : _selectionHelpers.default.onMouseUp(evt, targetProps); | ||
return props.disable ? {} : _selectionHelpers.SelectionHelpers.onMouseUp(evt, targetProps); | ||
} | ||
@@ -151,11 +141,5 @@ } | ||
}, _class; | ||
}; | ||
} | ||
exports.selectionContainerMixin = selectionContainerMixin; | ||
var _default = selectionContainerMixin(_victoryCore.VictoryContainer); // @ts-expect-error IMPORTANT: when converting this file to TypeScript, you must export the type as well: | ||
// export const VictorySelectionContainer = selectionContainerMixin(VictoryContainer); | ||
// export type VictorySelectionContainer = typeof VictorySelectionContainer; | ||
exports.default = _default; | ||
var VictorySelectionContainer = selectionContainerMixin(_victoryCore.VictoryContainer); | ||
exports.VictorySelectionContainer = VictorySelectionContainer; |
{ | ||
"name": "victory-selection-container", | ||
"version": "36.8.1", | ||
"version": "36.8.2", | ||
"description": "Interactive Selection Component for Victory", | ||
@@ -25,3 +25,3 @@ "keywords": [ | ||
"prop-types": "^15.8.1", | ||
"victory-core": "^36.8.1" | ||
"victory-core": "^36.8.2" | ||
}, | ||
@@ -32,3 +32,4 @@ "peerDependencies": { | ||
"devDependencies": { | ||
"victory-bar": "^36.8.1" | ||
"victory-bar": "^36.8.2", | ||
"victory-selection-container": "*" | ||
}, | ||
@@ -35,0 +36,0 @@ "publishConfig": { |
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
780785
21
14146
2
Updatedvictory-core@^36.8.2