victory-box-plot
Version:
Box Plot Component for Victory
1,255 lines (1,130 loc) • 896 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["VictoryBoxPlot"] = factory(require("react"));
else
root["VictoryBoxPlot"] = factory(root["React"]);
})(self, function(__WEBPACK_EXTERNAL_MODULE_react__) {
return /******/ (function() { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./helper-methods.tsx":
/*!****************************!*\
!*** ./helper-methods.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 */ "getBaseProps": function() { return /* binding */ getBaseProps; },
/* harmony export */ "getData": function() { return /* binding */ getData; },
/* harmony export */ "getDomain": function() { return /* binding */ getDomain; }
/* harmony export */ });
/* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/defaults */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/defaults.js");
/* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_defaults__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var lodash_groupBy__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash/groupBy */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/groupBy.js");
/* harmony import */ var lodash_groupBy__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_groupBy__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var lodash_orderBy__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash/orderBy */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/orderBy.js");
/* harmony import */ var lodash_orderBy__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_orderBy__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var lodash_uniq__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! lodash/uniq */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/uniq.js");
/* harmony import */ var lodash_uniq__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(lodash_uniq__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/data.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/domain.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/helpers.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/scale.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/collection.js");
/* harmony import */ var victory_vendor_d3_array__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! victory-vendor/d3-array */ "../../victory-vendor/es/d3-array.js");
const TYPES = ["max", "min", "median", "q1", "q3"];
const checkProcessedData = data => {
/* check if the data is pre-processed. start by checking that it has
all required quartile attributes. */
const hasQuartileAttributes = data.every(datum => {
return TYPES.every(val => typeof datum[`_${val}`] !== "undefined");
});
if (hasQuartileAttributes) {
// check that the independent variable is distinct
const values = data.map(d => d._x);
if (!lodash_uniq__WEBPACK_IMPORTED_MODULE_3___default()(values).length === values.length) {
throw new Error(`
data prop may only take an array of objects with a unique
independent variable. Make sure your x values are distinct.
`);
}
return true;
}
return false;
};
const nanToNull = val => Number.isNaN(val) ? null : val;
const getSummaryStatistics = data => {
const dependentVars = data.map(datum => datum._y);
const quartiles = {
_q1: nanToNull((0,victory_vendor_d3_array__WEBPACK_IMPORTED_MODULE_4__.quantile)(dependentVars, 0.25)),
// eslint-disable-line no-magic-numbers
_q3: nanToNull((0,victory_vendor_d3_array__WEBPACK_IMPORTED_MODULE_4__.quantile)(dependentVars, 0.75)),
// eslint-disable-line no-magic-numbers
_min: nanToNull((0,victory_vendor_d3_array__WEBPACK_IMPORTED_MODULE_4__.min)(dependentVars)),
_median: nanToNull((0,victory_vendor_d3_array__WEBPACK_IMPORTED_MODULE_4__.quantile)(dependentVars, 0.5)),
_max: nanToNull((0,victory_vendor_d3_array__WEBPACK_IMPORTED_MODULE_4__.max)(dependentVars))
};
return Object.assign({}, data[0], quartiles, {
_y: data[0]._y
});
};
const processData = data => {
/* check if the data is coming in a pre-processed form,
i.e. { x || y, min, max, q1, q3, median }. if not, process it. */
const isProcessed = checkProcessedData(data);
if (!isProcessed) {
// check if the data is coming with x or y values as an array
const arrayX = data.every(datum => Array.isArray(datum._x));
const arrayY = data.every(datum => Array.isArray(datum._y));
const sortKey = "_y";
const groupKey = "_x";
if (arrayX) {
throw new Error(`
data should not be given as in array for x
`);
} else if (arrayY) {
/* generate summary statistics for each datum. to do this, flatten
the depedentVarArray and process each datum separately */
return data.map(datum => {
const dataArray = datum[sortKey].map(d => Object.assign({}, datum, {
[sortKey]: d
}));
const sortedData = lodash_orderBy__WEBPACK_IMPORTED_MODULE_2___default()(dataArray, sortKey);
return getSummaryStatistics(sortedData);
});
} else {
/* Group data by independent variable and generate summary statistics for each group */
const groupedData = lodash_groupBy__WEBPACK_IMPORTED_MODULE_1___default()(data, groupKey);
return Object.keys(groupedData).map(key => {
const datum = groupedData[key];
const sortedData = lodash_orderBy__WEBPACK_IMPORTED_MODULE_2___default()(datum, sortKey);
return getSummaryStatistics(sortedData);
});
}
} else {
return data;
}
};
const getData = props => {
const accessorTypes = TYPES.concat("x", "y");
const formattedData = victory_core__WEBPACK_IMPORTED_MODULE_5__.formatData(props.data, props, accessorTypes);
return formattedData.length ? processData(formattedData) : [];
};
const reduceDataset = (dataset, props, axis) => {
const minDomain = victory_core__WEBPACK_IMPORTED_MODULE_6__.getMinFromProps(props, axis);
const maxDomain = victory_core__WEBPACK_IMPORTED_MODULE_6__.getMaxFromProps(props, axis);
const minData = minDomain !== undefined ? minDomain : dataset.reduce((memo, datum) => {
return memo < datum[`_${axis}`] ? memo : datum[`_${axis}`];
}, Infinity);
const maxData = maxDomain !== undefined ? maxDomain : dataset.reduce((memo, datum) => {
return memo > datum[`_${axis}`] ? memo : datum[`_${axis}`];
}, -Infinity);
return victory_core__WEBPACK_IMPORTED_MODULE_6__.getDomainFromMinMax(minData, maxData);
};
const getDomainFromMinMaxValues = (dataset, props, axis) => {
const minDomain = victory_core__WEBPACK_IMPORTED_MODULE_6__.getMinFromProps(props, axis);
const maxDomain = victory_core__WEBPACK_IMPORTED_MODULE_6__.getMaxFromProps(props, axis);
const minData = minDomain !== undefined ? minDomain : dataset.reduce((memo, datum) => {
return memo < datum._min ? memo : datum._min;
}, Infinity);
const maxData = maxDomain !== undefined ? maxDomain : dataset.reduce((memo, datum) => {
return memo > datum._max ? memo : datum._max;
}, -Infinity);
return victory_core__WEBPACK_IMPORTED_MODULE_6__.getDomainFromMinMax(minData, maxData);
};
const getDomainFromData = (props, axis) => {
const minDomain = victory_core__WEBPACK_IMPORTED_MODULE_6__.getMinFromProps(props, axis);
const maxDomain = victory_core__WEBPACK_IMPORTED_MODULE_6__.getMaxFromProps(props, axis);
const dataset = getData(props);
if (dataset.length < 1) {
return minDomain !== undefined && maxDomain !== undefined ? victory_core__WEBPACK_IMPORTED_MODULE_6__.getDomainFromMinMax(minDomain, maxDomain) : undefined;
}
return axis === "y" ? getDomainFromMinMaxValues(dataset, props, axis) : reduceDataset(dataset, props, axis);
};
const getDomain = (props, axis) => {
return victory_core__WEBPACK_IMPORTED_MODULE_6__.createDomainFunction(getDomainFromData)(props, axis);
};
const getLabelStyle = (props, styleObject, namespace) => {
const component = props[`${namespace}LabelComponent`] || props.labelComponent;
const baseStyle = styleObject[`${namespace}Labels`] || styleObject.labels;
if (!victory_core__WEBPACK_IMPORTED_MODULE_7__.isTooltip(component)) {
return baseStyle;
}
const tooltipTheme = props.theme && props.theme.tooltip || {};
return lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, tooltipTheme.style, baseStyle);
};
const getStyles = function (props, styleObject) {
if (styleObject === void 0) {
styleObject = {};
}
if (props.disableInlineStyles) {
return {};
}
const style = props.style || {};
const parentStyles = {
height: "100%",
width: "100%"
};
const labelStyles = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.labels, getLabelStyle(props, styleObject));
const boxStyles = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.boxes, styleObject.boxes);
const whiskerStyles = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.whiskers, styleObject.whiskers);
return {
boxes: boxStyles,
labels: labelStyles,
parent: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.parent, styleObject.parent, parentStyles),
max: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.max, styleObject.max, whiskerStyles),
maxLabels: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.maxLabels, getLabelStyle(props, styleObject, "max"), labelStyles),
median: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.median, styleObject.median, whiskerStyles),
medianLabels: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.medianLabels, getLabelStyle(props, styleObject, "median"), labelStyles),
min: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.min, styleObject.min, whiskerStyles),
minLabels: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.minLabels, getLabelStyle(props, styleObject, "min"), labelStyles),
q1: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.q1, styleObject.q1, boxStyles),
q1Labels: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.q1Labels, getLabelStyle(props, styleObject, "q1"), labelStyles),
q3: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.q3, styleObject.q3, boxStyles),
q3Labels: lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, style.q3Labels, getLabelStyle(props, styleObject, "q3"), labelStyles),
whiskers: whiskerStyles
};
};
const getCalculatedValues = props => {
const {
theme,
horizontal
} = props;
const data = getData(props);
const range = {
x: victory_core__WEBPACK_IMPORTED_MODULE_7__.getRange(props, "x"),
y: victory_core__WEBPACK_IMPORTED_MODULE_7__.getRange(props, "y")
};
const domain = {
x: getDomain(props, "x"),
y: getDomain(props, "y")
};
const scale = {
x: victory_core__WEBPACK_IMPORTED_MODULE_8__.getBaseScale(props, "x").domain(domain.x).range(props.horizontal ? range.y : range.x),
y: victory_core__WEBPACK_IMPORTED_MODULE_8__.getBaseScale(props, "y").domain(domain.y).range(props.horizontal ? range.x : range.y)
};
const defaultStyles = theme && theme.boxplot && theme.boxplot.style ? theme.boxplot.style : {};
const style = getStyles(props, defaultStyles);
const defaultOrientation = props.horizontal ? "top" : "right";
const labelOrientation = props.labelOrientation || defaultOrientation;
const boxWidth = props.boxWidth || 1;
return {
data,
horizontal,
domain,
scale,
style,
labelOrientation,
boxWidth
};
};
const getWhiskerProps = (props, type) => {
const {
horizontal,
style,
boxWidth,
whiskerWidth,
datum,
scale,
index,
disableInlineStyles
} = props;
const {
min,
max,
q1,
q3,
x,
y
} = props.positions;
const boxValue = type === "min" ? q1 : q3;
const whiskerValue = type === "min" ? min : max;
const width = typeof whiskerWidth === "number" ? whiskerWidth : boxWidth;
return {
datum,
index,
scale,
majorWhisker: {
x1: horizontal ? boxValue : x,
y1: horizontal ? y : boxValue,
x2: horizontal ? whiskerValue : x,
y2: horizontal ? y : whiskerValue
},
minorWhisker: {
x1: horizontal ? whiskerValue : x - width / 2,
y1: horizontal ? y - width / 2 : whiskerValue,
x2: horizontal ? whiskerValue : x + width / 2,
y2: horizontal ? y + width / 2 : whiskerValue
},
style: disableInlineStyles ? {} : style[type] || style.whisker,
disableInlineStyles
};
};
const getBoxProps = (props, type) => {
const {
horizontal,
boxWidth,
style,
scale,
datum,
index,
disableInlineStyles
} = props;
const {
median,
q1,
q3,
x,
y
} = props.positions;
const defaultX = type === "q1" ? q1 : median;
const defaultY = type === "q1" ? median : q3;
const defaultWidth = type === "q1" ? median - q1 : q3 - median;
const defaultHeight = type === "q1" ? q1 - median : median - q3;
return {
datum,
scale,
index,
x: horizontal ? defaultX : x - boxWidth / 2,
y: horizontal ? y - boxWidth / 2 : defaultY,
width: horizontal ? defaultWidth : boxWidth,
height: horizontal ? boxWidth : defaultHeight,
style: disableInlineStyles ? {} : style[type] || style.boxes,
disableInlineStyles
};
};
const getMedianProps = props => {
const {
boxWidth,
horizontal,
style,
datum,
scale,
index,
disableInlineStyles
} = props;
const {
median,
x,
y
} = props.positions;
return {
datum,
scale,
index,
x1: horizontal ? median : x - boxWidth / 2,
y1: horizontal ? y - boxWidth / 2 : median,
x2: horizontal ? median : x + boxWidth / 2,
y2: horizontal ? y + boxWidth / 2 : median,
style: disableInlineStyles ? {} : style.median,
disableInlineStyles
};
};
const getText = (props, type) => {
const {
datum,
index,
labels
} = props;
const propName = `${type}Labels`;
const labelProp = props[propName];
if (!labelProp && !labels) {
return null;
} else if (labelProp === true || labels === true) {
const dataName = `_${type}`;
return `${datum[dataName]}`;
}
return Array.isArray(labelProp) ? labelProp[index] : labelProp;
};
const getOrientation = (labelOrientation, type) => typeof labelOrientation === "object" && labelOrientation[type] || labelOrientation;
const getLabelProps = (props, text, type) => {
const {
datum,
positions,
index,
boxWidth,
horizontal,
labelOrientation,
style,
theme,
disableInlineStyles
} = props;
const orientation = getOrientation(labelOrientation, type);
const namespace = `${type}Labels`;
const labelStyle = style[namespace] || style.labels;
const defaultVerticalAnchors = {
top: "end",
bottom: "start",
left: "middle",
right: "middle"
};
const defaultTextAnchors = {
left: "end",
right: "start",
top: "middle",
bottom: "middle"
};
const whiskerWidth = typeof props.whiskerWidth === "number" ? props.whiskerWidth : boxWidth;
const width = type === "min" || type === "max" ? whiskerWidth : boxWidth;
const getOffset = coord => {
const sign = {
x: orientation === "left" ? -1 : 1,
y: orientation === "top" ? -1 : 1
};
return sign[coord] * width / 2 + sign[coord] * (labelStyle.padding || 0);
};
const labelProps = {
text,
datum,
index,
orientation,
style: disableInlineStyles ? {} : labelStyle,
y: horizontal ? positions.y : positions[type],
x: horizontal ? positions[type] : positions.x,
dy: horizontal ? getOffset("y") : 0,
dx: horizontal ? 0 : getOffset("x"),
textAnchor: labelStyle.textAnchor || defaultTextAnchors[orientation],
verticalAnchor: labelStyle.verticalAnchor || defaultVerticalAnchors[orientation],
angle: labelStyle.angle,
horizontal,
disableInlineStyles
};
const component = props[`${type}LabelComponent`];
if (!victory_core__WEBPACK_IMPORTED_MODULE_7__.isTooltip(component)) {
return labelProps;
}
const tooltipTheme = theme && theme.tooltip || {};
return lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()({}, labelProps, victory_core__WEBPACK_IMPORTED_MODULE_7__.omit(tooltipTheme, ["style"]));
};
const getDataProps = (props, type) => {
if (type === "median") {
return getMedianProps(props);
} else if (type === "min" || type === "max") {
return getWhiskerProps(props, type);
}
return getBoxProps(props, type);
};
// if all data points on an axis are out of bound of the domain, filter out this datum
const isDatumOutOfBounds = (datum, domain) => {
const exists = val => val !== undefined;
const {
_x,
_min,
_max
} = datum;
const minDomainX = victory_core__WEBPACK_IMPORTED_MODULE_9__.getMinValue(domain.x);
const maxDomainX = victory_core__WEBPACK_IMPORTED_MODULE_9__.getMaxValue(domain.x);
const minDomainY = victory_core__WEBPACK_IMPORTED_MODULE_9__.getMinValue(domain.y);
const maxDomainY = victory_core__WEBPACK_IMPORTED_MODULE_9__.getMaxValue(domain.y);
const underMin = min => val => exists(val) && val < min;
const overMax = max => val => exists(val) && val > max;
const isUnderMinX = underMin(minDomainX);
const isUnderMinY = underMin(minDomainY);
const isOverMaxX = overMax(maxDomainX);
const isOverMaxY = overMax(maxDomainY);
let yOutOfBounds;
let xOutOfBounds;
// if x is out of the bounds of the domain
if (isUnderMinX(_x) || isOverMaxX(_x)) xOutOfBounds = true;
// if min/max are out of the bounds of the domain
if (isUnderMinY(_min) && isUnderMinY(_max) || isOverMaxY(_min) && isOverMaxY(_max)) yOutOfBounds = true;
return yOutOfBounds || xOutOfBounds;
};
const getBaseProps = (initialProps, fallbackProps) => {
const modifiedProps = victory_core__WEBPACK_IMPORTED_MODULE_7__.modifyProps(initialProps, fallbackProps, "boxplot");
const props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
const {
groupComponent,
width,
height,
padding,
standalone,
theme,
events,
sharedEvents,
scale,
horizontal,
data,
style,
domain,
name
} = props;
const initialChildProps = {
parent: {
domain,
scale,
width,
height,
data,
standalone,
name,
theme,
style: style.parent || {},
padding,
groupComponent,
horizontal
}
};
const boxScale = scale.y;
return data.reduce((acc, datum, index) => {
const eventKey = !victory_core__WEBPACK_IMPORTED_MODULE_7__.isNil(datum.eventKey) ? datum.eventKey : index;
if (isDatumOutOfBounds(datum, domain)) return acc;
const positions = {
x: horizontal ? scale.y(datum._y) : scale.x(datum._x),
y: horizontal ? scale.x(datum._x) : scale.y(datum._y),
min: boxScale(datum._min),
max: boxScale(datum._max),
median: boxScale(datum._median),
q1: boxScale(datum._q1),
q3: boxScale(datum._q3)
};
const dataProps = Object.assign({
index,
datum,
positions
}, props);
const dataObj = TYPES.reduce((memo, type) => {
memo[type] = getDataProps(dataProps, type);
return memo;
}, {});
acc[eventKey] = dataObj;
TYPES.forEach(type => {
const labelText = getText(dataProps, type);
const labelProp = props.labels || props[`${type}Labels`];
if (labelText !== null && labelText !== undefined || labelProp && (events || sharedEvents)) {
const target = `${type}Labels`;
acc[eventKey][target] = getLabelProps(Object.assign({}, props, dataProps), labelText, type);
}
});
return acc;
}, initialChildProps);
};
/***/ }),
/***/ "./victory-box-plot.tsx":
/*!******************************!*\
!*** ./victory-box-plot.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 */ "VictoryBoxPlot": function() { return /* binding */ VictoryBoxPlot; }
/* 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 victory_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/default-transitions.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_2__ = __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-primitives/border.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-primitives/whisker.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-label/victory-label.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-primitives/line-segment.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-theme/victory-theme.js");
/* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/helpers.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");
/* harmony import */ var _helper_methods__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./helper-methods */ "./helper-methods.tsx");
const fallbackProps = {
width: 450,
height: 300,
padding: {
top: 20,
right: 20,
bottom: 20,
left: 20
}
};
const defaultData = [{
x: 1,
min: 5,
q1: 7,
median: 12,
q3: 18,
max: 20
}, {
x: 2,
min: 2,
q1: 5,
median: 8,
q3: 12,
max: 15
}];
const options = {
components: [{
name: "min"
}, {
name: "minLabels"
}, {
name: "max"
}, {
name: "maxLabels"
}, {
name: "median"
}, {
name: "medianLabels"
}, {
name: "q1"
}, {
name: "q1Labels"
}, {
name: "q3"
}, {
name: "q3Labels"
}, {
name: "parent",
index: "parent"
}]
};
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
class VictoryBoxPlotBase extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
static animationWhitelist = ["data", "domain", "height", "padding", "style", "width"];
static displayName = "VictoryBoxPlot";
static role = "boxplot";
static defaultTransitions = victory_core__WEBPACK_IMPORTED_MODULE_1__.discreteTransitions();
static defaultProps = {
containerComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_2__.VictoryContainer, null),
data: defaultData,
dataComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_3__.Border, null),
groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("g", {
role: "presentation"
}),
maxComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_4__.Whisker, null),
maxLabelComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_5__.VictoryLabel, null),
medianComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_6__.LineSegment, null),
medianLabelComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_5__.VictoryLabel, null),
minComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_4__.Whisker, null),
minLabelComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_5__.VictoryLabel, null),
q1Component: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_3__.Border, null),
q1LabelComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_5__.VictoryLabel, null),
q3Component: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_3__.Border, null),
q3LabelComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_5__.VictoryLabel, null),
samples: 50,
sortKey: "x",
sortOrder: "ascending",
standalone: true,
theme: victory_core__WEBPACK_IMPORTED_MODULE_7__.VictoryTheme.grayscale
};
static getDomain(props, axis) {
return (0,_helper_methods__WEBPACK_IMPORTED_MODULE_8__.getDomain)(props, axis);
}
static getData(props) {
return (0,_helper_methods__WEBPACK_IMPORTED_MODULE_8__.getData)(props);
}
static getBaseProps(props) {
return (0,_helper_methods__WEBPACK_IMPORTED_MODULE_8__.getBaseProps)(props, fallbackProps);
}
static expectedComponents = ["maxComponent", "maxLabelComponent", "medianComponent", "medianLabelComponent", "minComponent", "minLabelComponent", "q1Component", "q1LabelComponent", "q3Component", "q3LabelComponent", "groupComponent", "containerComponent"];
renderBoxPlot(props) {
const types = ["q1", "q3", "max", "min", "median"];
const dataComponents = types.map(type => {
return this.dataKeys.reduce((validDataComponents, _key, index) => {
const baseComponent = props[`${type}Component`];
const componentProps = this.getComponentProps(baseComponent, type, index);
if (this.shouldRenderDatum(componentProps.datum)) {
validDataComponents.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(baseComponent, componentProps));
}
return validDataComponents;
}, []);
}).flat();
const labelComponents = types.map(type => {
const components = this.dataKeys.reduce((validComponents, _key, index) => {
const name = `${type}Labels`;
const baseComponent = props[`${type}LabelComponent`];
const labelProps = this.getComponentProps(baseComponent, name, index);
if (labelProps.text !== undefined && labelProps.text !== null) {
validComponents.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(baseComponent, labelProps));
}
return validComponents;
}, []);
return components.filter(Boolean);
}).flat();
const children = [...dataComponents, ...labelComponents];
return this.renderContainer(props.groupComponent, children);
}
// Overridden in native versions
shouldAnimate() {
return !!this.props.animate;
}
shouldRenderDatum(datum) {
const hasX = !victory_core__WEBPACK_IMPORTED_MODULE_9__.isNil(datum._x);
const hasY = !victory_core__WEBPACK_IMPORTED_MODULE_9__.isNil(datum._y);
const hasSummaryStatistics = !victory_core__WEBPACK_IMPORTED_MODULE_9__.isNil(datum._min) && !victory_core__WEBPACK_IMPORTED_MODULE_9__.isNil(datum._max) && !victory_core__WEBPACK_IMPORTED_MODULE_9__.isNil(datum._median) && !victory_core__WEBPACK_IMPORTED_MODULE_9__.isNil(datum._q1) && !victory_core__WEBPACK_IMPORTED_MODULE_9__.isNil(datum._q3);
return hasSummaryStatistics && (this.props.horizontal ? hasY : hasX);
}
render() {
const {
animationWhitelist,
role
} = VictoryBoxPlot;
const props = victory_core__WEBPACK_IMPORTED_MODULE_9__.modifyProps(this.props, fallbackProps, role);
if (this.shouldAnimate()) {
return this.animateComponent(props, animationWhitelist);
}
const children = this.renderBoxPlot(props);
const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
return victory_core__WEBPACK_IMPORTED_MODULE_10__.withSafeUserProps(component, props);
}
}
const VictoryBoxPlot = (0,victory_core__WEBPACK_IMPORTED_MODULE_11__.addEvents)(VictoryBoxPlotBase, options);
/***/ }),
/***/ "../../../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/_arrayAggregator.js":
/*!******************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayAggregator.js ***!
\******************************************************************************************/
/***/ (function(module) {
/**
* A specialized version of `baseAggregator` for arrays.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function arrayAggregator(array, setter, iteratee, accumulator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
var value = array[index];
setter(accumulator, value, iteratee(value), array);
}
return accumulator;
}
module.exports = arrayAggregator;
/***/ }),
/***/ "../../../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[index] = iteratee(array[index], index, array);
}
return result;
}
module.exports = arrayMap;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayPush.js":
/*!************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayPush.js ***!
\************************************************************************************/
/***/ (function(module) {
/**
* Appends the elements of `values` to `array`.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to append.
* @returns {Array} Returns `array`.
*/
function arrayPush(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
}
module.exports = arrayPush;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arraySome.js":
/*!************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arraySome.js ***!
\************************************************************************************/
/***/ (function(module) {
/**
* A specialized version of `_.some` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
*/
function arraySome(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (predicate(array[index], index, array)) {
return true;
}
}
return false;
}
module.exports = arraySome;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assignValue.js":
/*!**************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assignValue.js ***!
\**************************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var baseAssignValue = __webpack_require__(/*! ./_baseAssignValue */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAssignValue.js"),
eq = __webpack_require__(/*! ./eq */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/eq.js");
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Assigns `value` to `key` of `object` if the existing value is not equivalent
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function assignValue(object, key, value) {
var objValue = object[key];
if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
(value === undefined && !(key in object))) {
baseAssignValue(object, key, value);
}
}
module.exports = assignValue;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js":
/*!***************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js ***!
\***************************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var eq = __webpack_require__(/*! ./eq */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/eq.js");
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
module.exports = assocIndexOf;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAggregator.js":
/*!*****************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAggregator.js ***!
\*****************************************************************************************/
/***/ (function(module) {
/**
* A specialized version of `baseAggregator` for arrays.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} setter The function to set `accumulator` values.
* @param {Function} iteratee The iteratee to transform keys.
* @param {Object} accumulator The initial aggregated object.
* @returns {Function} Returns `accumulator`.
*/
function arrayAggregator(array, setter, iteratee, accumulator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
var value = array[index];
setter(accumulator, value, iteratee(value), array);
}
return accumulator;
}
module.exports = arrayAggregator;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAssignValue.js":
/*!******************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseAssignValue.js ***!
\******************************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var defineProperty = __webpack_require__(/*! ./_defineProperty */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_defineProperty.js");
/**
* The base implementation of `assignValue` and `assignMergeValue` without
* value checks.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function baseAssignValue(object, key, value) {
if (key == '__proto__' && defineProperty) {
defineProperty(object, key, {
'configurable': true,
'enumerable': true,
'value': value,
'writable': true
});
} else {
object[key] = value;
}
}
module.exports = baseAssignValue;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseFlatten.js":
/*!**************************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseFlatten.js ***!
\**************************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var arrayPush = __webpack_require__(/*! ./_arrayPush */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_arrayPush.js"),
isFlattenable = __webpack_require__(/*! ./_isFlattenable */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_isFlattenable.js");
/**
* The base implementation of `_.flatten` with support for restricting flattening.
*
* @private
* @param {Array} array The array to flatten.
* @param {number} depth The maximum recursion depth.
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
function baseFlatten(array, depth, predicate, isStrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && predicate(value)) {
if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits).
baseFlatten(value, depth - 1, predicate, isStrict, result);
} else {
arrayPush(result, value);
}
} else if (!isStrict) {
result[result.length] = value;
}
}
return result;
}
module.exports = baseFlatten;
/***/ }),
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGet.js":
/*!**********************************************************************************!*\
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_baseGet.js ***!
\**********************************************************************************/
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var castPath = __webpack_require__(/*! ./_castPath */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_castPath.js"),
toKey = __webpack_require__(/*! ./_toKey */ "../../../node_modules/.pnpm/lodash@4.1