victory-bar
Version:
Bar Component for Victory
1,347 lines (1,264 loc) • 966 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"));
else if(typeof define === 'function' && define.amd)
define(["react"], factory);
else if(typeof exports === 'object')
exports["VictoryBar"] = factory(require("react"));
else
root["VictoryBar"] = factory(root["React"]);
})(self, function(__WEBPACK_EXTERNAL_MODULE_react__) {
return /******/ (function() { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./bar-helper-methods.ts":
/*!*******************************!*\
!*** ./bar-helper-methods.ts ***!
\*******************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "getBarWidth": function() { return /* binding */ getBarWidth; },
/* harmony export */ "getCornerRadius": function() { return /* binding */ getCornerRadius; },
/* harmony export */ "getStyle": function() { return /* binding */ getStyle; }
/* harmony export */ });
/* harmony import */ var lodash_isPlainObject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/isPlainObject */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isPlainObject.js");
/* harmony import */ var lodash_isPlainObject__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_isPlainObject__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/helpers.js");
const DEFAULT_BAR_WIDTH = 8;
const getBarWidth = (barWidth, props) => {
const {
scale,
data,
style
} = props;
if (barWidth) {
return victory_core__WEBPACK_IMPORTED_MODULE_1__.evaluateProp(barWidth, props);
} else if (style.width) {
return style.width;
}
const range = scale.x.range();
const extent = Math.abs(range[1] - range[0]);
const bars = data.length + 2;
const barRatio = props.barRatio || 0.5;
const defaultWidth = barRatio * (data.length < 2 ? DEFAULT_BAR_WIDTH : extent / bars);
return Math.max(1, defaultWidth);
};
const getCornerRadiusFromObject = (cornerRadius, props) => {
const realCornerRadius = {
topLeft: 0,
topRight: 0,
bottomLeft: 0,
bottomRight: 0
};
const updateCornerRadius = (corner, fallback) => {
if (!victory_core__WEBPACK_IMPORTED_MODULE_1__.isNil(cornerRadius[corner])) {
realCornerRadius[corner] = victory_core__WEBPACK_IMPORTED_MODULE_1__.evaluateProp(cornerRadius[corner], props);
} else if (!victory_core__WEBPACK_IMPORTED_MODULE_1__.isNil(cornerRadius[fallback])) {
realCornerRadius[corner] = victory_core__WEBPACK_IMPORTED_MODULE_1__.evaluateProp(cornerRadius[fallback], props);
}
};
updateCornerRadius("topLeft", "top");
updateCornerRadius("topRight", "top");
updateCornerRadius("bottomLeft", "bottom");
updateCornerRadius("bottomRight", "bottom");
return realCornerRadius;
};
function isCornerRadiusObject(cornerRadius) {
return lodash_isPlainObject__WEBPACK_IMPORTED_MODULE_0___default()(cornerRadius);
}
const getCornerRadius = (cornerRadius, props) => {
const realCornerRadius = {
topLeft: 0,
topRight: 0,
bottomLeft: 0,
bottomRight: 0
};
if (!cornerRadius) {
return realCornerRadius;
}
if (isCornerRadiusObject(cornerRadius)) {
return getCornerRadiusFromObject(cornerRadius, props);
}
realCornerRadius.topLeft = victory_core__WEBPACK_IMPORTED_MODULE_1__.evaluateProp(cornerRadius, props);
realCornerRadius.topRight = victory_core__WEBPACK_IMPORTED_MODULE_1__.evaluateProp(cornerRadius, props);
return realCornerRadius;
};
const getStyle = function (style, props) {
if (style === void 0) {
style = {};
}
if (props.disableInlineStyles) {
return {};
}
const stroke = style.fill || "black";
const baseStyle = {
fill: "black",
stroke
};
return victory_core__WEBPACK_IMPORTED_MODULE_1__.evaluateStyle(Object.assign(baseStyle, style), props);
};
/***/ }),
/***/ "./bar.tsx":
/*!*****************!*\
!*** ./bar.tsx ***!
\*****************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "Bar": function() { return /* binding */ Bar; }
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash/defaults */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/defaults.js");
/* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_defaults__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/helpers.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-primitives/path.js");
/* harmony import */ var _bar_helper_methods__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bar-helper-methods */ "./bar-helper-methods.ts");
/* harmony import */ var _path_helper_methods__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./path-helper-methods */ "./path-helper-methods.ts");
const evaluateProps = props => {
/**
* Potential evaluated props of following must be evaluated in this order:
* 1) `style`
* 2) `barWidth`
* 3) `cornerRadius`
*
* Everything else does not have to be evaluated in a particular order:
* `ariaLabel`
* `desc`
* `id`
* `tabIndex`
*/
const style = (0,_bar_helper_methods__WEBPACK_IMPORTED_MODULE_2__.getStyle)(props.style, props);
const barWidth = (0,_bar_helper_methods__WEBPACK_IMPORTED_MODULE_2__.getBarWidth)(props.barWidth, Object.assign({}, props, {
style
}));
const cornerRadius = (0,_bar_helper_methods__WEBPACK_IMPORTED_MODULE_2__.getCornerRadius)(props.cornerRadius, Object.assign({}, props, {
style,
barWidth
}));
const ariaLabel = victory_core__WEBPACK_IMPORTED_MODULE_3__.evaluateProp(props.ariaLabel, props);
const desc = victory_core__WEBPACK_IMPORTED_MODULE_3__.evaluateProp(props.desc, props);
const id = victory_core__WEBPACK_IMPORTED_MODULE_3__.evaluateProp(props.id, props);
const tabIndex = victory_core__WEBPACK_IMPORTED_MODULE_3__.evaluateProp(props.tabIndex, props);
return Object.assign({}, props, {
ariaLabel,
style,
barWidth,
cornerRadius,
desc,
id,
tabIndex
});
};
const defaultProps = {
pathComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_4__.Path, null),
role: "presentation",
shapeRendering: "auto"
};
const Bar = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
// eslint-disable-next-line prefer-arrow-callback
function Bar(initialProps, ref) {
const props = evaluateProps(lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({}, initialProps, defaultProps));
const {
polar,
origin,
style,
barWidth,
cornerRadius
} = props;
const path = polar ? (0,_path_helper_methods__WEBPACK_IMPORTED_MODULE_5__.getPolarBarPath)(props, cornerRadius) : (0,_path_helper_methods__WEBPACK_IMPORTED_MODULE_5__.getBarPath)(props, barWidth, cornerRadius);
const defaultTransform = polar && origin ? `translate(${origin.x}, ${origin.y})` : undefined;
if (!props.pathComponent) {
return null;
}
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(props.pathComponent, {
...props.events,
"aria-label": props.ariaLabel,
style,
d: path,
className: props.className,
clipPath: props.clipPath,
desc: props.desc,
index: props.index,
role: props.role,
shapeRendering: props.shapeRendering,
transform: props.transform || defaultTransform,
tabIndex: props.tabIndex,
ref
});
});
/***/ }),
/***/ "./geometry-helper-methods.ts":
/*!************************************!*\
!*** ./geometry-helper-methods.ts ***!
\************************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "circle": function() { return /* binding */ circle; },
/* harmony export */ "point": function() { return /* binding */ point; }
/* harmony export */ });
/**
* A point in the 2d plane
*/
const point = (x, y) => ({
x,
y,
distance(p1) {
return Math.sqrt(Math.pow(this.x - p1.x, 2) + Math.pow(this.y - p1.y, 2));
},
// vector addition in 2d plane
add(p1) {
return point(this.x + p1.x, this.y + p1.y);
},
// vector subtraction in 2d
// returns p0 - p1
subtract(p1) {
return point(this.x - p1.x, this.y - p1.y);
},
// multiply a 2d point by a scalar
scalarMult(n) {
return point(this.x * n, this.y * n);
},
scalarDivide(n) {
if (n === 0) {
throw new Error("Division by 0 error");
}
return point(this.x / n, this.y / n);
},
equals(p1) {
return this.x === p1.x && this.y === p1.y;
}
});
/**
* A circle in the 2d plane
*/
const circle = (center, radius) => ({
center,
radius,
hasIntersection(circle1) {
const P0 = this.center;
const P1 = circle1.center;
const r0 = this.radius;
const r1 = circle1.radius;
const d = P0.distance(P1);
if (d > r0 + r1) {
return false; // separate circles
}
if (d < Math.abs(r0 - r1)) {
return false; // one circle contains another
}
return true;
},
equals(circle1) {
const P0 = this.center;
const P1 = circle1.center;
const r0 = this.radius;
const r1 = circle1.radius;
return r0 === r1 && P0.equals(P1);
},
// Source: http://paulbourke.net/geometry/circlesphere/
// "Intersection of two circles" by Paul Bourke
// Left-most point is returned as 0th element of array
// Right-most point is returned as 1st elemennt of array
intersection(circle1) {
const P0 = this.center;
const P1 = circle1.center;
const r0 = this.radius;
const r1 = circle1.radius;
const d = P0.distance(P1);
if (!this.hasIntersection(circle1) || this.equals(circle1)) {
return [];
}
const a = (Math.pow(r0, 2) - Math.pow(r1, 2) + Math.pow(d, 2)) / (2 * d);
const h = Math.sqrt(Math.pow(r0, 2) - Math.pow(a, 2));
const P2 = P0.add(P1.subtract(P0).scalarMult(a).scalarDivide(d));
const {
x: x0,
y: y0
} = P0;
const {
x: x1,
y: y1
} = P1;
const {
x: x2,
y: y2
} = P2;
const P3s = [point(x2 - h * (y1 - y0) / d, y2 + h * (x1 - x0) / d), point(x2 + h * (y1 - y0) / d, y2 - h * (x1 - x0) / d)];
P3s.sort((Point1, Point2) => Point1.x - Point2.x);
return P3s;
},
solveX(y) {
const sqrt = Math.sqrt(Math.pow(this.radius, 2) - Math.pow(y - this.center.y, 2));
return [this.center.x - sqrt, this.center.x + sqrt];
},
solveY(x) {
const sqrt = Math.sqrt(Math.pow(this.radius, 2) - Math.pow(x - this.center.x, 2));
return [this.center.y - sqrt, this.center.y + sqrt];
}
});
/***/ }),
/***/ "./helper-methods.ts":
/*!***************************!*\
!*** ./helper-methods.ts ***!
\***************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "getBarPosition": function() { return /* binding */ getBarPosition; },
/* harmony export */ "getBaseProps": function() { return /* binding */ getBaseProps; }
/* harmony export */ });
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/scale.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/collection.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/helpers.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/domain.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/data.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-clip-container/victory-clip-container.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/label-helpers.js");
const getBarPosition = (props, datum) => {
const getDefaultMin = axis => {
const defaultZero = victory_core__WEBPACK_IMPORTED_MODULE_0__.getType(props.scale[axis]) === "log" ? 1 / Number.MAX_SAFE_INTEGER : 0;
let defaultMin = defaultZero;
const minY = victory_core__WEBPACK_IMPORTED_MODULE_1__.getMinValue(props.domain[axis]);
const maxY = victory_core__WEBPACK_IMPORTED_MODULE_1__.getMaxValue(props.domain[axis]);
if (minY < 0 && maxY <= 0) {
defaultMin = maxY;
} else if (minY >= 0 && maxY > 0) {
defaultMin = minY;
}
return datum[`_${axis}`] instanceof Date ? new Date(defaultMin) : defaultMin;
};
const _y0 = datum._y0 !== undefined ? datum._y0 : getDefaultMin("y");
const _x0 = datum._x0 !== undefined ? datum._x0 : getDefaultMin("x");
return victory_core__WEBPACK_IMPORTED_MODULE_2__.scalePoint(props, Object.assign({}, datum, {
_y0,
_x0
}));
};
const getCalculatedValues = props => {
const {
polar
} = props;
const defaultStyles = victory_core__WEBPACK_IMPORTED_MODULE_2__.getDefaultStyles(props, "bar");
const style = !props.disableInlineStyles ? victory_core__WEBPACK_IMPORTED_MODULE_2__.getStyles(props.style, defaultStyles) : {};
const range = props.range || {
x: victory_core__WEBPACK_IMPORTED_MODULE_2__.getRange(props, "x"),
y: victory_core__WEBPACK_IMPORTED_MODULE_2__.getRange(props, "y")
};
const domain = {
x: victory_core__WEBPACK_IMPORTED_MODULE_3__.getDomainWithZero(props, "x"),
y: victory_core__WEBPACK_IMPORTED_MODULE_3__.getDomainWithZero(props, "y")
};
const scale = {
x: victory_core__WEBPACK_IMPORTED_MODULE_0__.getBaseScale(props, "x").domain(domain.x).range(props.horizontal ? range.y : range.x),
y: victory_core__WEBPACK_IMPORTED_MODULE_0__.getBaseScale(props, "y").domain(domain.y).range(props.horizontal ? range.x : range.y)
};
const origin = polar ? props.origin || victory_core__WEBPACK_IMPORTED_MODULE_2__.getPolarOrigin(props) : undefined;
let data = victory_core__WEBPACK_IMPORTED_MODULE_4__.getData(props);
data = victory_core__WEBPACK_IMPORTED_MODULE_4__.formatDataFromDomain(data, domain, 0);
// when inside a zoom container, reset the _x and _y properties of each datum to the original
// x and y property values so they will not be clipped. See https://github.com/FormidableLabs/victory/pull/2970
if (props.groupComponent?.type === victory_core__WEBPACK_IMPORTED_MODULE_5__.VictoryClipContainer) {
data = data.map(datum => ({
...datum,
_x: datum.x,
_y: datum.y
}));
}
return {
style,
data,
scale,
domain,
origin
};
};
const getBaseProps = (initialProps, fallbackProps) => {
const modifiedProps = victory_core__WEBPACK_IMPORTED_MODULE_2__.modifyProps(initialProps, fallbackProps, "bar");
const props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
const {
alignment,
barRatio,
cornerRadius,
data,
disableInlineStyles,
domain,
events,
height,
horizontal,
origin,
padding,
polar,
scale,
sharedEvents,
standalone,
style,
theme,
width,
labels,
name,
barWidth,
getPath
} = props;
const initialChildProps = {
parent: {
horizontal,
domain,
scale,
width,
height,
data,
standalone,
name,
theme,
polar,
origin,
padding,
style: style.parent
}
};
return data.reduce((childProps, datum, index) => {
const eventKey = !victory_core__WEBPACK_IMPORTED_MODULE_2__.isNil(datum.eventKey) ? datum.eventKey : index;
const {
x,
y,
y0,
x0
} = getBarPosition(props, datum);
const dataProps = {
alignment,
barRatio,
barWidth,
cornerRadius,
data,
datum,
disableInlineStyles,
getPath,
horizontal,
index,
polar,
origin,
scale,
style: style.data,
width,
height,
x,
y,
y0,
x0
};
childProps[eventKey] = {
data: dataProps
};
const text = victory_core__WEBPACK_IMPORTED_MODULE_6__.getText(props, datum, index);
if (text !== undefined && text !== null || labels && (events || sharedEvents)) {
childProps[eventKey].labels = victory_core__WEBPACK_IMPORTED_MODULE_6__.getProps(props, index);
}
return childProps;
}, initialChildProps);
};
/***/ }),
/***/ "./path-helper-methods.ts":
/*!********************************!*\
!*** ./path-helper-methods.ts ***!
\********************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "getBarPath": function() { return /* binding */ getBarPath; },
/* harmony export */ "getCustomBarPath": function() { return /* binding */ getCustomBarPath; },
/* harmony export */ "getHorizontalBarPath": function() { return /* binding */ getHorizontalBarPath; },
/* harmony export */ "getPolarBarPath": function() { return /* binding */ getPolarBarPath; },
/* harmony export */ "getVerticalBarPath": function() { return /* binding */ getVerticalBarPath; },
/* harmony export */ "getVerticalPolarBarPath": function() { return /* binding */ getVerticalPolarBarPath; }
/* harmony export */ });
/* harmony import */ var victory_vendor_d3_shape__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! victory-vendor/d3-shape */ "../../victory-vendor/es/d3-shape.js");
/* harmony import */ var _geometry_helper_methods__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./geometry-helper-methods */ "./geometry-helper-methods.ts");
const getPosition = (props, width) => {
const {
x,
x0,
y,
y0,
horizontal
} = props;
const alignment = props.alignment || "middle";
const size = alignment === "middle" ? width / 2 : width;
const sign = horizontal ? -1 : 1;
if (horizontal) {
return {
x0,
x1: x,
y0: alignment === "start" ? y : y - sign * size,
y1: alignment === "end" ? y : y + sign * size
};
}
return {
x0: alignment === "start" ? x : x - sign * size,
x1: alignment === "end" ? x : x + sign * size,
y0,
y1: y
};
};
const getAngle = (props, index) => {
const {
data,
scale
} = props;
const x = data[index]._x1 === undefined ? "_x" : "_x1";
return scale.x(data[index][x]);
};
const getAngularWidth = (props, width) => {
const {
scale
} = props;
const range = scale.y.range();
const r = Math.max(...range);
const angularRange = Math.abs(scale.x.range()[1] - scale.x.range()[0]);
return width / (2 * Math.PI * r) * angularRange;
};
const transformAngle = angle => {
return -1 * angle + Math.PI / 2;
};
const getCustomBarPath = (props, width) => {
const {
getPath
} = props;
if (typeof getPath === "function") {
const propsWithCalculatedValues = {
...props,
...getPosition(props, width)
};
return getPath(propsWithCalculatedValues);
}
};
const getStartAngle = (props, index) => {
const {
data,
scale,
alignment
} = props;
const currentAngle = getAngle(props, index);
const angularRange = Math.abs(scale.x.range()[1] - scale.x.range()[0]);
const previousAngle = index === 0 ? getAngle(props, data.length - 1) - Math.PI * 2 : getAngle(props, index - 1);
if (index === 0 && angularRange < 2 * Math.PI) {
return scale.x.range()[0];
} else if (alignment === "start" || alignment === "end") {
return alignment === "start" ? previousAngle : currentAngle;
}
return (currentAngle + previousAngle) / 2;
};
const getEndAngle = (props, index) => {
const {
data,
scale,
alignment
} = props;
const currentAngle = getAngle(props, index);
const angularRange = Math.abs(scale.x.range()[1] - scale.x.range()[0]);
const lastAngle = scale.x.range()[1] === 2 * Math.PI ? getAngle(props, 0) + Math.PI * 2 : scale.x.range()[1];
const nextAngle = index === data.length - 1 ? getAngle(props, 0) + Math.PI * 2 : getAngle(props, index + 1);
if (index === data.length - 1 && angularRange < 2 * Math.PI) {
return lastAngle;
} else if (alignment === "start" || alignment === "end") {
return alignment === "start" ? currentAngle : nextAngle;
}
return (currentAngle + nextAngle) / 2;
};
const mapPointsToPath = (coords, cornerRadius, direction) => {
const topLeftPath = `${cornerRadius.topLeft} ${cornerRadius.topLeft} ${direction}`;
const topRightPath = `${cornerRadius.topRight} ${cornerRadius.topRight} ${direction}`;
const bottomLeftPath = `${cornerRadius.bottomLeft} ${cornerRadius.bottomLeft} ${direction}`;
const bottomRightPath = `${cornerRadius.bottomRight} ${cornerRadius.bottomRight} ${direction}`;
const commands = ["M", `A ${bottomLeftPath},`, "L", `A ${topLeftPath},`, "L", `A ${topRightPath},`, "L", `A ${bottomRightPath},`];
const path = commands.reduce((acc, command, i) => `${acc}${command} ${coords[i].x}, ${coords[i].y} \n`, "");
return `${path} z`;
};
const getVerticalBarPoints = (position, sign, cr) => {
const {
x0,
x1,
y0,
y1
} = position;
const getHalfPoints = side => {
const isLeft = side === "Left";
const signL = isLeft ? 1 : -1;
const x = isLeft ? x0 : x1;
let bottomPoint = {
x: x + signL * cr[`bottom${side}`],
y: y0
};
let bottomMiddlePoint = {
x,
y: y0 - sign * cr[`bottom${side}`]
};
let topMiddlePoint = {
x,
y: y1 + sign * cr[`top${side}`]
};
let topPoint = {
x: x + signL * cr[`top${side}`],
y: y1
};
const hasIntersection = sign === 1 ? y0 - cr[`bottom${side}`] < y1 + cr[`top${side}`] : y0 + cr[`bottom${side}`] > y1 - cr[`top${side}`];
if (hasIntersection) {
const topCenter = (0,_geometry_helper_methods__WEBPACK_IMPORTED_MODULE_1__.point)(x + signL * cr[`top${side}`], y1 + sign * cr[`top${side}`]);
const topCircle = (0,_geometry_helper_methods__WEBPACK_IMPORTED_MODULE_1__.circle)(topCenter, cr[`top${side}`]);
const bottomCenter = (0,_geometry_helper_methods__WEBPACK_IMPORTED_MODULE_1__.point)(x + signL * cr[`bottom${side}`], y0 - sign * cr[`bottom${side}`]);
const bottomCircle = (0,_geometry_helper_methods__WEBPACK_IMPORTED_MODULE_1__.circle)(bottomCenter, cr[`bottom${side}`]);
const circleIntersection = topCircle.intersection(bottomCircle);
const hasArcIntersection = circleIntersection.length > 0;
if (hasArcIntersection) {
const arcIntersection = circleIntersection[isLeft ? 0 : 1];
bottomMiddlePoint = {
x: arcIntersection.x,
y: arcIntersection.y
};
topMiddlePoint = {
x: arcIntersection.x,
y: arcIntersection.y
};
} else {
const hasBottomLineTopArcIntersection = cr[`top${side}`] > cr[`bottom${side}`];
if (hasBottomLineTopArcIntersection) {
const newX = topCircle.solveX(y0)[isLeft ? 0 : 1];
bottomPoint = {
x: newX,
y: y0
};
bottomMiddlePoint = {
x: newX,
y: y0
};
topMiddlePoint = {
x: newX,
y: y0
};
} else {
const newX = bottomCircle.solveX(y1)[isLeft ? 0 : 1];
bottomMiddlePoint = {
x: newX,
y: y1
};
topMiddlePoint = {
x: newX,
y: y1
};
topPoint = {
x: newX,
y: y1
};
}
}
}
const points = [bottomPoint, bottomMiddlePoint, topMiddlePoint, topPoint];
return isLeft ? points : points.reverse();
};
return getHalfPoints("Left").concat(getHalfPoints("Right"));
};
const getHorizontalBarPoints = (position, sign, cr) => {
const {
y0,
y1
} = position;
const x0 = position.x0 < position.x1 ? position.x0 : position.x1;
const x1 = position.x0 < position.x1 ? position.x1 : position.x0;
const getHalfPoints = side => {
const isTop = side === "top";
const signL = isTop ? -1 : 1;
const y = isTop ? y1 : y0;
let leftPoint = {
x: x0,
y: y - signL * cr[`${side}Left`]
};
let leftMiddlePoint = {
x: x0 + cr[`${side}Left`],
y
};
let rightMiddlePoint = {
x: x1 - cr[`${side}Right`],
y
};
let rightPoint = {
x: x1,
y: y - signL * cr[`${side}Right`]
};
const hasIntersection = leftMiddlePoint.x > rightMiddlePoint.x;
if (hasIntersection) {
const leftCenter = (0,_geometry_helper_methods__WEBPACK_IMPORTED_MODULE_1__.point)(x0 + cr[`${side}Left`], y - signL * cr[`${side}Left`]);
const leftCircle = (0,_geometry_helper_methods__WEBPACK_IMPORTED_MODULE_1__.circle)(leftCenter, cr[`${side}Left`]);
const rightCenter = (0,_geometry_helper_methods__WEBPACK_IMPORTED_MODULE_1__.point)(x1 - cr[`${side}Right`], y - signL * cr[`${side}Right`]);
const rightCircle = (0,_geometry_helper_methods__WEBPACK_IMPORTED_MODULE_1__.circle)(rightCenter, cr[`${side}Right`]);
const circleIntersection = leftCircle.intersection(rightCircle);
const hasArcIntersection = circleIntersection.length > 0;
if (hasArcIntersection) {
const arcIntersection = circleIntersection[sign > 0 ? 1 : 0];
leftMiddlePoint = {
x: arcIntersection.x,
y: arcIntersection.y
};
rightMiddlePoint = {
x: arcIntersection.x,
y: arcIntersection.y
};
} else {
const hasLeftLineRightArcIntersection = cr[`${side}Right`] > cr[`${side}Left`];
if (hasLeftLineRightArcIntersection) {
const newY = rightCircle.solveY(x0)[isTop ? 0 : 1];
leftPoint = {
x: x0,
y: newY
};
leftMiddlePoint = {
x: x0,
y: newY
};
rightMiddlePoint = {
x: x0,
y: newY
};
} else {
const newY = leftCircle.solveY(x1)[isTop ? 0 : 1];
rightPoint = {
x: x1,
y: newY
};
rightMiddlePoint = {
x: x1,
y: newY
};
leftMiddlePoint = {
x: x1,
y: newY
};
}
}
}
return [leftPoint, leftMiddlePoint, rightMiddlePoint, rightPoint];
};
const topPoints = getHalfPoints("top");
const bottomPoints = getHalfPoints("bottom");
return [bottomPoints[1], bottomPoints[0], ...topPoints,
// eslint-disable-next-line no-magic-numbers
bottomPoints[3], bottomPoints[2]];
};
const getVerticalBarPath = (props, width, cornerRadius) => {
const position = getPosition(props, width);
const sign = position.y0 > position.y1 ? 1 : -1;
const direction = sign > 0 ? "0 0 1" : "0 0 0";
const points = getVerticalBarPoints(position, sign, cornerRadius);
return mapPointsToPath(points, cornerRadius, direction);
};
const getHorizontalBarPath = (props, width, cornerRadius) => {
const position = getPosition(props, width);
const sign = position.x0 < position.x1 ? 1 : -1;
const direction = "0 0 1";
const cr = {
topRight: sign > 0 ? cornerRadius.topLeft : cornerRadius.bottomLeft,
bottomRight: sign > 0 ? cornerRadius.topRight : cornerRadius.bottomRight,
bottomLeft: sign > 0 ? cornerRadius.bottomRight : cornerRadius.topRight,
topLeft: sign > 0 ? cornerRadius.bottomLeft : cornerRadius.topLeft
};
const points = getHorizontalBarPoints(position, sign, cr);
return mapPointsToPath(points, cr, direction);
};
const getVerticalPolarBarPath = (props, cornerRadius) => {
const {
datum,
scale,
index,
alignment,
style
} = props;
const r1 = scale.y(datum._y0 || 0);
const r2 = scale.y(datum._y1 !== undefined ? datum._y1 : datum._y);
const currentAngle = scale.x(datum._x1 !== undefined ? datum._x1 : datum._x);
let start;
let end;
if (style.width) {
const width = getAngularWidth(props, style.width);
const size = alignment === "middle" ? width / 2 : width;
start = alignment === "start" ? currentAngle : currentAngle - size;
end = alignment === "end" ? currentAngle : currentAngle + size;
} else {
start = getStartAngle(props, Number(index));
end = getEndAngle(props, Number(index));
}
const getPath = edge => {
const pathFunction = victory_vendor_d3_shape__WEBPACK_IMPORTED_MODULE_0__.arc().innerRadius(r1).outerRadius(r2).startAngle(transformAngle(start)).endAngle(transformAngle(end)).cornerRadius(cornerRadius[edge]);
return pathFunction();
};
const getPathData = edge => {
const rightPath = getPath(`${edge}Right`);
const rightMoves = rightPath.match(/[A-Z]/g) || [];
const rightCoords = rightPath.split(/[A-Z]/).slice(1);
const rightMiddle = rightMoves.indexOf("L");
const leftPath = getPath(`${edge}Left`);
const leftMoves = leftPath.match(/[A-Z]/g) || [];
const leftCoords = leftPath.split(/[A-Z]/).slice(1);
const leftMiddle = leftMoves.indexOf("L");
return {
rightMoves,
rightCoords,
rightMiddle,
leftMoves,
leftCoords,
leftMiddle
};
};
const getTopPath = () => {
const {
topRight,
topLeft
} = cornerRadius;
const arcLength = r2 * Math.abs(end - start);
const {
rightMoves,
rightCoords,
rightMiddle,
leftMoves,
leftCoords,
leftMiddle
} = getPathData("top");
let moves;
let coords;
if (topRight === topLeft || arcLength < 2 * topRight + 2 * topLeft) {
moves = topRight > topLeft ? rightMoves : leftMoves;
coords = topRight > topLeft ? rightCoords : leftCoords;
} else {
// eslint-disable-next-line no-magic-numbers
const isShort = middle => middle < 3;
const rightOffset = topLeft > topRight && isShort(rightMiddle) ? 1 : 2;
let leftOffset;
if (topRight > topLeft) {
const defaultOffset = isShort(rightMiddle) ? leftMiddle : leftMiddle - 2;
leftOffset = isShort(leftMiddle) ? leftMiddle - 1 : defaultOffset;
} else {
const defaultOffset = isShort(leftMiddle) ? 1 : 2;
leftOffset = isShort(rightMiddle) ? defaultOffset : leftMiddle - 2;
}
moves = [...rightMoves.slice(0, rightOffset), ...leftMoves.slice(leftOffset)];
coords = [...rightCoords.slice(0, rightOffset), ...leftCoords.slice(leftOffset)];
}
const middle = moves.indexOf("L");
const subMoves = moves.slice(0, middle);
const subCoords = coords.slice(0, middle);
return subMoves.map((m, i) => ({
command: m,
coords: subCoords[i].split(",")
}));
};
const getBottomPath = () => {
const {
bottomRight,
bottomLeft
} = cornerRadius;
const arcLength = r1 * Math.abs(end - start);
const {
rightMoves,
rightCoords,
rightMiddle,
leftMoves,
leftCoords,
leftMiddle
} = getPathData("bottom");
let moves;
let coords;
if (bottomRight === bottomLeft || arcLength < 2 * bottomRight + 2 * bottomLeft) {
moves = bottomRight > bottomLeft ? rightMoves : leftMoves;
coords = bottomRight > bottomLeft ? rightCoords : leftCoords;
} else {
// eslint-disable-next-line no-magic-numbers
const isShort = (m, middle) => m.length - middle < 4;
const shortPath = bottomRight > bottomLeft ? isShort(rightMoves, rightMiddle) : isShort(leftMoves, leftMiddle);
// eslint-disable-next-line no-magic-numbers
const rightOffset = shortPath ? -1 : -3;
moves = [...leftMoves.slice(0, leftMiddle + 2), ...rightMoves.slice(rightOffset)];
coords = [...leftCoords.slice(0, leftMiddle + 2), ...rightCoords.slice(rightOffset)];
}
const middle = moves.indexOf("L");
const subMoves = moves.slice(middle, -1);
const subCoords = coords.slice(middle, -1);
return subMoves.map((m, i) => ({
command: m,
coords: subCoords[i].split(",")
}));
};
const topPath = getTopPath();
const bottomPath = getBottomPath();
const moves = [...topPath, ...bottomPath];
const path = moves.reduce((memo, move) => `${memo}${move.command} ${move.coords.join()}`, "");
return `${path} z`;
};
const getBarPath = (props, width, cornerRadius) => {
if (props.getPath) {
return getCustomBarPath(props, width);
}
return props.horizontal ? getHorizontalBarPath(props, width, cornerRadius) : getVerticalBarPath(props, width, cornerRadius);
};
const getPolarBarPath = (props, cornerRadius) => {
// TODO Radial bars
return getVerticalPolarBarPath(props, cornerRadius);
};
/***/ }),
/***/ "./victory-bar.tsx":
/*!*************************!*\
!*** ./victory-bar.tsx ***!
\*************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "VictoryBar": function() { return /* binding */ VictoryBar; }
/* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _helper_methods__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./helper-methods */ "./helper-methods.ts");
/* harmony import */ var _bar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bar */ "./bar.tsx");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-container/victory-container.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-label/victory-label.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-theme/victory-theme.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/domain.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/data.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/helpers.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-clip-container/victory-clip-container.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/user-props.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/add-events.js");
const fallbackProps = {
width: 450,
height: 300,
padding: 50
};
const defaultData = [{
x: 1,
y: 1
}, {
x: 2,
y: 2
}, {
x: 3,
y: 3
}, {
x: 4,
y: 4
}];
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
/**
* Draw SVG bar charts with React. VictoryBar is a composable component, so it doesn"t include axes
* Check out VictoryChart for complete bar charts and more.
*/
class VictoryBarBase extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
static animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
static displayName = "VictoryBar";
static role = "bar";
static defaultTransitions = {
onLoad: {
duration: 2000,
before: () => ({
_y: 0,
_y1: 0,
_y0: 0
}),
after: datum => ({
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
})
},
onExit: {
duration: 500,
before: () => ({
_y: 0,
yOffset: 0
})
},
onEnter: {
duration: 500,
before: () => ({
_y: 0,
_y1: 0,
_y0: 0
}),
after: datum => ({
_y: datum._y,
_y1: datum._y1,
_y0: datum._y0
})
}
};
static defaultProps = {
containerComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_1__.VictoryContainer, null),
data: defaultData,
dataComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_bar__WEBPACK_IMPORTED_MODULE_2__.Bar, null),
groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("g", {
role: "presentation"
}),
labelComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_3__.VictoryLabel, null),
samples: 50,
sortOrder: "ascending",
standalone: true,
theme: victory_core__WEBPACK_IMPORTED_MODULE_4__.VictoryTheme.grayscale
};
static getDomain = victory_core__WEBPACK_IMPORTED_MODULE_5__.getDomainWithZero;
static getData = victory_core__WEBPACK_IMPORTED_MODULE_6__.getData;
static getBaseProps(props) {
return (0,_helper_methods__WEBPACK_IMPORTED_MODULE_7__.getBaseProps)(props, fallbackProps);
}
static expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
// passed to addEvents.renderData to prevent data props with undefined _x or _y from excluding data from render.
// used when inside of VictoryZoomContainer
static shouldRenderDatum = () => true;
// Overridden in native versions
shouldAnimate() {
return !!this.props.animate;
}
render() {
const {
animationWhitelist,
role
} = VictoryBar;
const props = victory_core__WEBPACK_IMPORTED_MODULE_8__.modifyProps(this.props, fallbackProps, role);
if (this.shouldAnimate()) {
return this.animateComponent(props, animationWhitelist);
}
let children;
// when inside a zoom container (the only place VictoryClipContainer is used), all data
// should be renderable so bars won't dissappear before they've fully exited the container's bounds
// see https://github.com/FormidableLabs/victory/pull/2970
if (props.groupComponent?.type === victory_core__WEBPACK_IMPORTED_MODULE_9__.VictoryClipContainer) {
children = this.renderData(props, VictoryBarBase.shouldRenderDatum);
} else {
children = this.renderData(props);
}
const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
return victory_core__WEBPACK_IMPORTED_MODULE_10__.withSafeUserProps(component, props);
}
}
const VictoryBar = (0,victory_core__WEBPACK_IMPORTED_MODULE_11__.addEvents)(VictoryBarBase);
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_MapCache.js":
/*!***********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_MapCache.js ***!
\***********************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var listCacheClear = __webpack_require__(/*! ./_listCacheClear */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheClear.js"),
listCacheDelete = __webpack_require__(/*! ./_listCacheDelete */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js"),
listCacheGet = __webpack_require__(/*! ./_listCacheGet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheGet.js"),
listCacheHas = __webpack_require__(/*! ./_listCacheHas */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheHas.js"),
listCacheSet = __webpack_require__(/*! ./_listCacheSet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheSet.js");
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
module.exports = ListCache;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_SetCache.js":
/*!***********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_SetCache.js ***!
\***********************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var isArray = __webpack_require__(/*! ./isArray */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isArray.js");
/**
* Casts `value` as an array if it's not one.
*
* @static
* @memberOf _
* @since 4.4.0
* @category Lang
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast array.
* @example
*
* _.castArray(1);
* // => [1]
*
* _.castArray({ 'a': 1 });
* // => [{ 'a': 1 }]
*
* _.castArray('abc');
* // => ['abc']
*
* _.castArray(null);
* // => [null]
*
* _.castArray(undefined);
* // => [undefined]
*
* _.castArray();
* // => []
*
* var array = [1, 2, 3];
* console.log(_.castArray(array) === array);
* // => true
*/
function castArray() {
if (!arguments.length) {
return [];
}
var value = arguments[0];
return isArray(value) ? value : [value];
}
module.exports = castArray;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Stack.js":
/*!********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Stack.js ***!
\********************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var listCacheClear = __webpack_require__(/*! ./_listCacheClear */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheClear.js"),
listCacheDelete = __webpack_require__(/*! ./_listCacheDelete */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js"),
listCacheGet = __webpack_require__(/*! ./_listCacheGet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheGet.js"),
listCacheHas = __webpack_require__(/*! ./_listCacheHas */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheHas.js"),
listCacheSet = __webpack_require__(/*! ./_listCacheSet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheSet.js");
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
// Add methods to `ListCache`.
ListCache.prototype.clear = listCacheClear;
ListCache.prototype['delete'] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
module.exports = ListCache;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Symbol.js":
/*!*********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_Symbol.js ***!
\*********************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var root = __webpack_require__(/*! ./_root */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_root.js");
/** Built-in value references. */
var Symbol = root.Symbol;
module.exports = Symbol;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_apply.js":
/*!********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_apply.js ***!
\********************************************************************************/
/***/ (function(module) {
/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
switch (args.length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
module.exports = apply;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludes.js":
/*!****************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludes.js ***!
\****************************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var baseIndexOf = __webpack_require__(/*! ./_baseIndexOf */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseIndexOf.js");
/**
* A specialized version of `_.includes` for arrays without support for
* specifying an index to search from.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludes(array, value) {
var length = array == null ? 0 : array.length;
return !!length && baseIndexOf(array, value, 0) > -1;
}
module.exports = arrayIncludes;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludesWith.js":
/*!********************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayIncludesWith.js ***!
\********************************************************************************************/
/***/ (function(module) {
/**
* This function is like `arrayIncludes` except that it accepts a comparator.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @param {Function} comparator The comparator invoked per element.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludesWith(array, value, comparator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (comparator(value, array[index])) {
return true;
}
}
return false;
}
module.exports = arrayIncludesWith;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayMap.js":
/*!***********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayMap.js ***!
\***********************************************************************************/
/***/ (function(module) {
/**
* A specialized version of `_.map` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function arrayMap(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = Array(length);
while (++index < length) {
result