victory-stack 37.0.2 → 37.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/victory-stack.js +257 -215
- package/dist/victory-stack.min.js +1 -1
- package/es/helper-methods.js +3 -3
- package/lib/helper-methods.js +3 -3
- package/package.json +8 -3
- package/src/helper-methods.tsx +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# victory-stack
|
|
2
2
|
|
|
3
|
+
## 37.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Pin all internal victory package versions ([#2876](https://github.com/FormidableLabs/victory/pull/2876))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Fix bug when one child of a Stack has a date axis and all null values for the other axis ([#2888](https://github.com/FormidableLabs/victory/pull/2888))
|
|
12
|
+
|
|
3
13
|
## 37.0.2
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/dist/victory-stack.js
CHANGED
|
@@ -125,9 +125,9 @@ function addLayoutData(props, datasets, index) {
|
|
|
125
125
|
|
|
126
126
|
function stackData(props, childComponents) {
|
|
127
127
|
const dataFromChildren = victory_core__WEBPACK_IMPORTED_MODULE_3__.getDataFromChildren(props, childComponents);
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
return
|
|
128
|
+
const filledDatasets = fillData(props, dataFromChildren);
|
|
129
|
+
const filteredNullChild = filledDatasets.map(dataset => dataset.filter(datum => datum._x !== null && datum._y !== null));
|
|
130
|
+
return filteredNullChild.map((d, i) => addLayoutData(props, filledDatasets, i));
|
|
131
131
|
}
|
|
132
132
|
function getCalculatedProps(initialProps, childComponents) {
|
|
133
133
|
const children = childComponents || react__WEBPACK_IMPORTED_MODULE_1___default().Children.toArray(initialProps.children);
|
|
@@ -5026,23 +5026,18 @@ module.exports = function isEqual(a, b) {
|
|
|
5026
5026
|
"use strict";
|
|
5027
5027
|
__webpack_require__.r(__webpack_exports__);
|
|
5028
5028
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5029
|
-
/* harmony export */ "VictoryContainer": function() { return /* binding */ VictoryContainer; }
|
|
5029
|
+
/* harmony export */ "VictoryContainer": function() { return /* binding */ VictoryContainer; },
|
|
5030
|
+
/* harmony export */ "useVictoryContainer": function() { return /* binding */ useVictoryContainer; }
|
|
5030
5031
|
/* harmony export */ });
|
|
5031
|
-
/* harmony import */ var
|
|
5032
|
-
/* harmony import */ var
|
|
5033
|
-
/* harmony import */ var
|
|
5034
|
-
/* harmony import */ var
|
|
5035
|
-
/* harmony import */ var
|
|
5036
|
-
/* harmony import */ var
|
|
5037
|
-
/* harmony import */ var
|
|
5038
|
-
/* harmony import */ var
|
|
5039
|
-
/* harmony import */ var
|
|
5040
|
-
/* harmony import */ var _victory_portal_portal_context__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../victory-portal/portal-context */ "../../victory-core/es/victory-portal/portal-context.js");
|
|
5041
|
-
/* harmony import */ var _victory_util_timer_context__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../victory-util/timer-context */ "../../victory-core/es/victory-util/timer-context.js");
|
|
5042
|
-
/* harmony import */ var _victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../victory-util/helpers */ "../../victory-core/es/victory-util/helpers.js");
|
|
5043
|
-
/* harmony import */ var _victory_util_user_props__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../victory-util/user-props */ "../../victory-core/es/victory-util/user-props.js");
|
|
5044
|
-
|
|
5045
|
-
|
|
5032
|
+
/* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/uniqueId */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/uniqueId.js");
|
|
5033
|
+
/* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0__);
|
|
5034
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
|
|
5035
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
5036
|
+
/* harmony import */ var _victory_portal_portal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../victory-portal/portal */ "../../victory-core/es/victory-portal/portal.js");
|
|
5037
|
+
/* harmony import */ var _victory_util_user_props__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../victory-util/user-props */ "../../victory-core/es/victory-util/user-props.js");
|
|
5038
|
+
/* harmony import */ var _victory_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../victory-util */ "../../victory-core/es/victory-util/merge-refs.js");
|
|
5039
|
+
/* harmony import */ var _victory_portal_portal_outlet__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../victory-portal/portal-outlet */ "../../victory-core/es/victory-portal/portal-outlet.js");
|
|
5040
|
+
/* harmony import */ var _victory_portal_portal_context__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../victory-portal/portal-context */ "../../victory-core/es/victory-portal/portal-context.js");
|
|
5046
5041
|
|
|
5047
5042
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5048
5043
|
|
|
@@ -5051,175 +5046,149 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
|
|
|
5051
5046
|
|
|
5052
5047
|
|
|
5053
5048
|
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
// @ts-expect-error Ref will be initialized on mount
|
|
5067
|
-
|
|
5068
|
-
// @ts-expect-error Ref will be initialized on mount
|
|
5069
|
-
|
|
5070
|
-
constructor(props) {
|
|
5071
|
-
super(props);
|
|
5072
|
-
this.containerId = !lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default()(props) || props.containerId === undefined ? lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1___default()("victory-container-") : props.containerId;
|
|
5073
|
-
this.shouldHandleWheel = !!(props && props.events && props.events.onWheel);
|
|
5074
|
-
}
|
|
5075
|
-
savePortalRef = portal => {
|
|
5076
|
-
this.portalRef = portal;
|
|
5077
|
-
return portal;
|
|
5049
|
+
const defaultProps = {
|
|
5050
|
+
className: "VictoryContainer",
|
|
5051
|
+
portalComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal__WEBPACK_IMPORTED_MODULE_2__.Portal, null),
|
|
5052
|
+
portalZIndex: 99,
|
|
5053
|
+
responsive: true,
|
|
5054
|
+
role: "img"
|
|
5055
|
+
};
|
|
5056
|
+
function useVictoryContainer(initialProps) {
|
|
5057
|
+
const props = {
|
|
5058
|
+
...defaultProps,
|
|
5059
|
+
...initialProps
|
|
5078
5060
|
};
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5061
|
+
const {
|
|
5062
|
+
title,
|
|
5063
|
+
desc,
|
|
5064
|
+
width,
|
|
5065
|
+
height,
|
|
5066
|
+
responsive
|
|
5067
|
+
} = props;
|
|
5068
|
+
const localContainerRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
|
|
5069
|
+
|
|
5070
|
+
// Generated ID stored in ref because it needs to persist across renders
|
|
5071
|
+
const generatedId = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default()("victory-container-"));
|
|
5072
|
+
const containerId = props.containerId ?? generatedId.current;
|
|
5073
|
+
const getIdForElement = elName => `${containerId}-${elName}`;
|
|
5074
|
+
const userProps = _victory_util_user_props__WEBPACK_IMPORTED_MODULE_3__.getSafeUserProps(props);
|
|
5075
|
+
const dimensions = responsive ? {
|
|
5076
|
+
width: "100%",
|
|
5077
|
+
height: "100%"
|
|
5078
|
+
} : {
|
|
5079
|
+
width,
|
|
5080
|
+
height
|
|
5088
5081
|
};
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
const
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
} : {
|
|
5145
|
-
width,
|
|
5146
|
-
height
|
|
5082
|
+
const viewBox = responsive ? `0 0 ${width} ${height}` : undefined;
|
|
5083
|
+
const preserveAspectRatio = responsive ? props.preserveAspectRatio : undefined;
|
|
5084
|
+
const ariaLabelledBy = [title && getIdForElement("title"), props["aria-labelledby"]].filter(Boolean).join(" ") || undefined;
|
|
5085
|
+
const ariaDescribedBy = [desc && getIdForElement("desc"), props["aria-describedby"]].filter(Boolean).join(" ") || undefined;
|
|
5086
|
+
const titleId = getIdForElement("title");
|
|
5087
|
+
const descId = getIdForElement("desc");
|
|
5088
|
+
return {
|
|
5089
|
+
...props,
|
|
5090
|
+
titleId,
|
|
5091
|
+
descId,
|
|
5092
|
+
dimensions,
|
|
5093
|
+
viewBox,
|
|
5094
|
+
preserveAspectRatio,
|
|
5095
|
+
ariaLabelledBy,
|
|
5096
|
+
ariaDescribedBy,
|
|
5097
|
+
userProps,
|
|
5098
|
+
localContainerRef
|
|
5099
|
+
};
|
|
5100
|
+
}
|
|
5101
|
+
const VictoryContainer = initialProps => {
|
|
5102
|
+
const {
|
|
5103
|
+
role,
|
|
5104
|
+
title,
|
|
5105
|
+
desc,
|
|
5106
|
+
children,
|
|
5107
|
+
className,
|
|
5108
|
+
portalZIndex,
|
|
5109
|
+
portalComponent,
|
|
5110
|
+
width,
|
|
5111
|
+
height,
|
|
5112
|
+
style,
|
|
5113
|
+
tabIndex,
|
|
5114
|
+
responsive,
|
|
5115
|
+
events,
|
|
5116
|
+
ouiaId,
|
|
5117
|
+
ouiaSafe,
|
|
5118
|
+
ouiaType,
|
|
5119
|
+
dimensions,
|
|
5120
|
+
ariaDescribedBy,
|
|
5121
|
+
ariaLabelledBy,
|
|
5122
|
+
viewBox,
|
|
5123
|
+
preserveAspectRatio,
|
|
5124
|
+
userProps,
|
|
5125
|
+
titleId,
|
|
5126
|
+
descId,
|
|
5127
|
+
containerRef,
|
|
5128
|
+
localContainerRef
|
|
5129
|
+
} = useVictoryContainer(initialProps);
|
|
5130
|
+
react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
|
|
5131
|
+
if (!events?.onWheel) return;
|
|
5132
|
+
const handleWheel = e => e.preventDefault();
|
|
5133
|
+
const container = localContainerRef?.current;
|
|
5134
|
+
container?.addEventListener("wheel", handleWheel);
|
|
5135
|
+
return () => {
|
|
5136
|
+
container?.removeEventListener("wheel", handleWheel);
|
|
5147
5137
|
};
|
|
5148
|
-
|
|
5138
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5139
|
+
}, []);
|
|
5140
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", {
|
|
5141
|
+
className: className,
|
|
5142
|
+
style: {
|
|
5143
|
+
...style,
|
|
5144
|
+
width: responsive ? style?.width : dimensions.width,
|
|
5145
|
+
height: responsive ? style?.height : dimensions.height,
|
|
5149
5146
|
pointerEvents: "none",
|
|
5150
5147
|
touchAction: "none",
|
|
5151
5148
|
position: "relative"
|
|
5152
|
-
},
|
|
5153
|
-
|
|
5149
|
+
},
|
|
5150
|
+
"data-ouia-component-id": ouiaId,
|
|
5151
|
+
"data-ouia-component-type": ouiaType,
|
|
5152
|
+
"data-ouia-safe": ouiaSafe,
|
|
5153
|
+
ref: (0,_victory_util__WEBPACK_IMPORTED_MODULE_4__.mergeRefs)([localContainerRef, containerRef])
|
|
5154
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal_context__WEBPACK_IMPORTED_MODULE_5__.PortalProvider, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("svg", _extends({
|
|
5155
|
+
width: width,
|
|
5156
|
+
height: height,
|
|
5157
|
+
tabIndex: tabIndex,
|
|
5158
|
+
role: role,
|
|
5159
|
+
"aria-labelledby": ariaLabelledBy,
|
|
5160
|
+
"aria-describedby": ariaDescribedBy,
|
|
5161
|
+
viewBox: viewBox,
|
|
5162
|
+
preserveAspectRatio: preserveAspectRatio,
|
|
5163
|
+
style: {
|
|
5164
|
+
...dimensions,
|
|
5165
|
+
pointerEvents: "all"
|
|
5166
|
+
}
|
|
5167
|
+
}, userProps, events), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("title", {
|
|
5168
|
+
id: titleId
|
|
5169
|
+
}, title) : null, desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("desc", {
|
|
5170
|
+
id: descId
|
|
5171
|
+
}, desc) : null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", {
|
|
5172
|
+
style: {
|
|
5173
|
+
...dimensions,
|
|
5154
5174
|
zIndex: portalZIndex,
|
|
5155
5175
|
position: "absolute",
|
|
5156
5176
|
top: 0,
|
|
5157
5177
|
left: 0
|
|
5158
|
-
}
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5178
|
+
}
|
|
5179
|
+
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal_outlet__WEBPACK_IMPORTED_MODULE_6__.PortalOutlet, {
|
|
5180
|
+
as: portalComponent,
|
|
5181
|
+
width: width,
|
|
5182
|
+
height: height,
|
|
5183
|
+
viewBox: viewBox,
|
|
5184
|
+
preserveAspectRatio: preserveAspectRatio,
|
|
5185
|
+
style: {
|
|
5186
|
+
...dimensions,
|
|
5163
5187
|
overflow: "visible"
|
|
5164
|
-
}
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
viewBox: svgProps.viewBox,
|
|
5169
|
-
preserveAspectRatio: svgProps.preserveAspectRatio,
|
|
5170
|
-
style: portalSvgStyle
|
|
5171
|
-
};
|
|
5172
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement(_victory_portal_portal_context__WEBPACK_IMPORTED_MODULE_7__.PortalContext.Provider, {
|
|
5173
|
-
value: {
|
|
5174
|
-
portalUpdate: this.portalUpdate,
|
|
5175
|
-
portalRegister: this.portalRegister,
|
|
5176
|
-
portalDeregister: this.portalDeregister
|
|
5177
|
-
}
|
|
5178
|
-
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("div", _extends({
|
|
5179
|
-
style: lodash_defaults__WEBPACK_IMPORTED_MODULE_2___default()({}, style, divStyle),
|
|
5180
|
-
className: className,
|
|
5181
|
-
ref: this.saveContainerRef
|
|
5182
|
-
}, this.getOUIAProps(props)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("svg", _extends({}, svgProps, {
|
|
5183
|
-
style: svgStyle
|
|
5184
|
-
}), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("title", {
|
|
5185
|
-
id: this.getIdForElement("title")
|
|
5186
|
-
}, title) : null, desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("desc", {
|
|
5187
|
-
id: this.getIdForElement("desc")
|
|
5188
|
-
}, desc) : null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("div", {
|
|
5189
|
-
style: portalDivStyle
|
|
5190
|
-
}, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().cloneElement(portalComponent, {
|
|
5191
|
-
...portalProps,
|
|
5192
|
-
ref: this.savePortalRef
|
|
5193
|
-
}))));
|
|
5194
|
-
}
|
|
5195
|
-
render() {
|
|
5196
|
-
const {
|
|
5197
|
-
width,
|
|
5198
|
-
height,
|
|
5199
|
-
responsive,
|
|
5200
|
-
events,
|
|
5201
|
-
title,
|
|
5202
|
-
desc,
|
|
5203
|
-
tabIndex,
|
|
5204
|
-
preserveAspectRatio,
|
|
5205
|
-
role
|
|
5206
|
-
} = this.props;
|
|
5207
|
-
const style = responsive ? this.props.style : _victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__.omit(this.props.style, ["height", "width"]);
|
|
5208
|
-
const userProps = _victory_util_user_props__WEBPACK_IMPORTED_MODULE_8__.getSafeUserProps(this.props);
|
|
5209
|
-
const svgProps = Object.assign({
|
|
5210
|
-
width,
|
|
5211
|
-
height,
|
|
5212
|
-
tabIndex,
|
|
5213
|
-
role,
|
|
5214
|
-
"aria-labelledby": [title && this.getIdForElement("title"), this.props["aria-labelledby"]].filter(Boolean).join(" ") || undefined,
|
|
5215
|
-
"aria-describedby": [desc && this.getIdForElement("desc"), this.props["aria-describedby"]].filter(Boolean).join(" ") || undefined,
|
|
5216
|
-
viewBox: responsive ? `0 0 ${width} ${height}` : undefined,
|
|
5217
|
-
preserveAspectRatio: responsive ? preserveAspectRatio : undefined,
|
|
5218
|
-
...userProps
|
|
5219
|
-
}, events);
|
|
5220
|
-
return this.renderContainer(this.props, svgProps, style);
|
|
5221
|
-
}
|
|
5222
|
-
}
|
|
5188
|
+
}
|
|
5189
|
+
}))));
|
|
5190
|
+
};
|
|
5191
|
+
VictoryContainer.role = "container";
|
|
5223
5192
|
|
|
5224
5193
|
/***/ }),
|
|
5225
5194
|
|
|
@@ -5232,17 +5201,78 @@ class VictoryContainer extends (react__WEBPACK_IMPORTED_MODULE_3___default().Com
|
|
|
5232
5201
|
"use strict";
|
|
5233
5202
|
__webpack_require__.r(__webpack_exports__);
|
|
5234
5203
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5235
|
-
/* harmony export */ "PortalContext": function() { return /* binding */ PortalContext; }
|
|
5204
|
+
/* harmony export */ "PortalContext": function() { return /* binding */ PortalContext; },
|
|
5205
|
+
/* harmony export */ "PortalProvider": function() { return /* binding */ PortalProvider; },
|
|
5206
|
+
/* harmony export */ "usePortalContext": function() { return /* binding */ usePortalContext; }
|
|
5236
5207
|
/* harmony export */ });
|
|
5237
5208
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
5238
5209
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
5239
5210
|
|
|
5240
|
-
|
|
5241
|
-
* The React context object consumers may use to access the context of the
|
|
5242
|
-
* portal.
|
|
5243
|
-
*/
|
|
5244
|
-
const PortalContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext({});
|
|
5211
|
+
const PortalContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext(undefined);
|
|
5245
5212
|
PortalContext.displayName = "PortalContext";
|
|
5213
|
+
const usePortalContext = () => {
|
|
5214
|
+
const context = react__WEBPACK_IMPORTED_MODULE_0___default().useContext(PortalContext);
|
|
5215
|
+
return context;
|
|
5216
|
+
};
|
|
5217
|
+
const PortalProvider = _ref => {
|
|
5218
|
+
let {
|
|
5219
|
+
children
|
|
5220
|
+
} = _ref;
|
|
5221
|
+
const [portalChildren, setPortalChildren] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(new Map());
|
|
5222
|
+
const addChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback((id, element) => {
|
|
5223
|
+
setPortalChildren(prevChildren => {
|
|
5224
|
+
const nextChildren = new Map(prevChildren);
|
|
5225
|
+
nextChildren.set(id, element);
|
|
5226
|
+
return nextChildren;
|
|
5227
|
+
});
|
|
5228
|
+
}, [setPortalChildren]);
|
|
5229
|
+
const removeChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback(id => {
|
|
5230
|
+
setPortalChildren(prevChildren => {
|
|
5231
|
+
const nextChildren = new Map(prevChildren);
|
|
5232
|
+
nextChildren.delete(id);
|
|
5233
|
+
return nextChildren;
|
|
5234
|
+
});
|
|
5235
|
+
}, [setPortalChildren]);
|
|
5236
|
+
const contextValue = react__WEBPACK_IMPORTED_MODULE_0___default().useMemo(() => ({
|
|
5237
|
+
addChild,
|
|
5238
|
+
removeChild,
|
|
5239
|
+
children: portalChildren
|
|
5240
|
+
}), [addChild, removeChild, portalChildren]);
|
|
5241
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(PortalContext.Provider, {
|
|
5242
|
+
value: contextValue
|
|
5243
|
+
}, children);
|
|
5244
|
+
};
|
|
5245
|
+
|
|
5246
|
+
/***/ }),
|
|
5247
|
+
|
|
5248
|
+
/***/ "../../victory-core/es/victory-portal/portal-outlet.js":
|
|
5249
|
+
/*!*************************************************************!*\
|
|
5250
|
+
!*** ../../victory-core/es/victory-portal/portal-outlet.js ***!
|
|
5251
|
+
\*************************************************************/
|
|
5252
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5253
|
+
|
|
5254
|
+
"use strict";
|
|
5255
|
+
__webpack_require__.r(__webpack_exports__);
|
|
5256
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5257
|
+
/* harmony export */ "PortalOutlet": function() { return /* binding */ PortalOutlet; }
|
|
5258
|
+
/* harmony export */ });
|
|
5259
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
5260
|
+
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
5261
|
+
/* harmony import */ var _portal_context__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./portal-context */ "../../victory-core/es/victory-portal/portal-context.js");
|
|
5262
|
+
|
|
5263
|
+
|
|
5264
|
+
const PortalOutlet = _ref => {
|
|
5265
|
+
let {
|
|
5266
|
+
as: portalComponent,
|
|
5267
|
+
...props
|
|
5268
|
+
} = _ref;
|
|
5269
|
+
const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_1__.usePortalContext)();
|
|
5270
|
+
if (!portalContext) {
|
|
5271
|
+
return null;
|
|
5272
|
+
}
|
|
5273
|
+
const children = Array.from(portalContext.children.values());
|
|
5274
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(portalComponent, props, children);
|
|
5275
|
+
};
|
|
5246
5276
|
|
|
5247
5277
|
/***/ }),
|
|
5248
5278
|
|
|
@@ -5259,39 +5289,13 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5259
5289
|
/* harmony export */ });
|
|
5260
5290
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
|
|
5261
5291
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
5292
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
5262
5293
|
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
this.index = 1;
|
|
5269
|
-
}
|
|
5270
|
-
portalRegister = () => {
|
|
5271
|
-
return ++this.index;
|
|
5272
|
-
};
|
|
5273
|
-
portalUpdate = (key, element) => {
|
|
5274
|
-
this.map[key] = element;
|
|
5275
|
-
this.forceUpdate();
|
|
5276
|
-
};
|
|
5277
|
-
portalDeregister = key => {
|
|
5278
|
-
delete this.map[key];
|
|
5279
|
-
this.forceUpdate();
|
|
5280
|
-
};
|
|
5281
|
-
getChildren() {
|
|
5282
|
-
return Object.keys(this.map).map(key => {
|
|
5283
|
-
const el = this.map[key];
|
|
5284
|
-
return el ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(el, {
|
|
5285
|
-
key
|
|
5286
|
-
}) : el;
|
|
5287
|
-
});
|
|
5288
|
-
}
|
|
5289
|
-
|
|
5290
|
-
// Overridden in victory-core-native
|
|
5291
|
-
render() {
|
|
5292
|
-
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", this.props, this.getChildren());
|
|
5293
|
-
}
|
|
5294
|
-
}
|
|
5294
|
+
const Portal = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().forwardRef((props, ref) => {
|
|
5295
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", _extends({
|
|
5296
|
+
ref: ref
|
|
5297
|
+
}, props));
|
|
5298
|
+
});
|
|
5295
5299
|
|
|
5296
5300
|
/***/ }),
|
|
5297
5301
|
|
|
@@ -8245,6 +8249,44 @@ function warn(message) {
|
|
|
8245
8249
|
|
|
8246
8250
|
/***/ }),
|
|
8247
8251
|
|
|
8252
|
+
/***/ "../../victory-core/es/victory-util/merge-refs.js":
|
|
8253
|
+
/*!********************************************************!*\
|
|
8254
|
+
!*** ../../victory-core/es/victory-util/merge-refs.js ***!
|
|
8255
|
+
\********************************************************/
|
|
8256
|
+
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
8257
|
+
|
|
8258
|
+
"use strict";
|
|
8259
|
+
__webpack_require__.r(__webpack_exports__);
|
|
8260
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
8261
|
+
/* harmony export */ "mergeRefs": function() { return /* binding */ mergeRefs; }
|
|
8262
|
+
/* harmony export */ });
|
|
8263
|
+
/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./helpers */ "../../victory-core/es/victory-util/helpers.js");
|
|
8264
|
+
|
|
8265
|
+
/**
|
|
8266
|
+
* Used to merge multiple React refs into a single callback ref.
|
|
8267
|
+
*
|
|
8268
|
+
* @example
|
|
8269
|
+
* ```tsx
|
|
8270
|
+
* <div ref={mergeRefs([ref, forwardedRef])} />
|
|
8271
|
+
* ```
|
|
8272
|
+
*/
|
|
8273
|
+
function mergeRefs(refs) {
|
|
8274
|
+
return value => {
|
|
8275
|
+
refs.forEach(ref => {
|
|
8276
|
+
// If the ref is a function, it's a callback ref and we call it with the value.
|
|
8277
|
+
if (_helpers__WEBPACK_IMPORTED_MODULE_0__.isFunction(ref)) {
|
|
8278
|
+
ref(value);
|
|
8279
|
+
} else if (ref !== null && ref !== undefined) {
|
|
8280
|
+
// If the ref is an object (not null and not undefined), it's an object ref.
|
|
8281
|
+
// We assign the value to its 'current' property.
|
|
8282
|
+
ref.current = value;
|
|
8283
|
+
}
|
|
8284
|
+
});
|
|
8285
|
+
};
|
|
8286
|
+
}
|
|
8287
|
+
|
|
8288
|
+
/***/ }),
|
|
8289
|
+
|
|
8248
8290
|
/***/ "../../victory-core/es/victory-util/scale.js":
|
|
8249
8291
|
/*!***************************************************!*\
|
|
8250
8292
|
!*** ../../victory-core/es/victory-util/scale.js ***!
|