victory-chart 37.0.2 → 37.0.3-next.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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # victory-chart
2
2
 
3
+ ## 37.0.3-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [65d02419f]
8
+ - victory-core@37.0.3-next.0
9
+ - victory-axis@37.0.3-next.0
10
+ - victory-polar-axis@37.0.3-next.0
11
+ - victory-shared-events@37.0.3-next.0
12
+
3
13
  ## 37.0.2
4
14
 
5
15
  ### Patch Changes
@@ -6332,23 +6332,18 @@ const VictoryAnimation = _ref => {
6332
6332
  "use strict";
6333
6333
  __webpack_require__.r(__webpack_exports__);
6334
6334
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6335
- /* harmony export */ "VictoryContainer": function() { return /* binding */ VictoryContainer; }
6335
+ /* harmony export */ "VictoryContainer": function() { return /* binding */ VictoryContainer; },
6336
+ /* harmony export */ "useVictoryContainer": function() { return /* binding */ useVictoryContainer; }
6336
6337
  /* harmony export */ });
6337
- /* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/isObject */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObject.js");
6338
- /* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_isObject__WEBPACK_IMPORTED_MODULE_0__);
6339
- /* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash/uniqueId */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/uniqueId.js");
6340
- /* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1__);
6341
- /* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash/defaults */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/defaults.js");
6342
- /* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_defaults__WEBPACK_IMPORTED_MODULE_2__);
6343
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react */ "react");
6344
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_3__);
6345
- /* harmony import */ var _victory_portal_portal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../victory-portal/portal */ "../../victory-core/es/victory-portal/portal.js");
6346
- /* 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");
6347
- /* 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");
6348
- /* harmony import */ var _victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../victory-util/helpers */ "../../victory-core/es/victory-util/helpers.js");
6349
- /* 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");
6350
-
6351
-
6338
+ /* 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");
6339
+ /* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0__);
6340
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
6341
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
6342
+ /* harmony import */ var _victory_portal_portal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../victory-portal/portal */ "../../victory-core/es/victory-portal/portal.js");
6343
+ /* 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");
6344
+ /* harmony import */ var _victory_util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../victory-util */ "../../victory-core/es/victory-util/merge-refs.js");
6345
+ /* 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");
6346
+ /* harmony import */ var _victory_portal_portal_context__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../victory-portal/portal-context */ "../../victory-core/es/victory-portal/portal-context.js");
6352
6347
 
6353
6348
  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); }
6354
6349
 
@@ -6357,175 +6352,149 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
6357
6352
 
6358
6353
 
6359
6354
 
6360
- class VictoryContainer extends (react__WEBPACK_IMPORTED_MODULE_3___default().Component) {
6361
- static displayName = "VictoryContainer";
6362
- static role = "container";
6363
- static defaultProps = {
6364
- className: "VictoryContainer",
6365
- portalComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement(_victory_portal_portal__WEBPACK_IMPORTED_MODULE_4__.Portal, null),
6366
- portalZIndex: 99,
6367
- responsive: true,
6368
- role: "img"
6355
+ const defaultProps = {
6356
+ className: "VictoryContainer",
6357
+ portalComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal__WEBPACK_IMPORTED_MODULE_2__.Portal, null),
6358
+ portalZIndex: 99,
6359
+ responsive: true,
6360
+ role: "img"
6361
+ };
6362
+ function useVictoryContainer(initialProps) {
6363
+ const props = {
6364
+ ...defaultProps,
6365
+ ...initialProps
6369
6366
  };
6370
- static contextType = _victory_util_timer_context__WEBPACK_IMPORTED_MODULE_5__["default"];
6371
-
6372
- // @ts-expect-error Ref will be initialized on mount
6373
-
6374
- // @ts-expect-error Ref will be initialized on mount
6375
-
6376
- constructor(props) {
6377
- super(props);
6378
- this.containerId = !lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default()(props) || props.containerId === undefined ? lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1___default()("victory-container-") : props.containerId;
6379
- this.shouldHandleWheel = !!(props && props.events && props.events.onWheel);
6380
- }
6381
- savePortalRef = portal => {
6382
- this.portalRef = portal;
6383
- return portal;
6384
- };
6385
- portalUpdate = (key, el) => this.portalRef.portalUpdate(key, el);
6386
- portalRegister = () => this.portalRef.portalRegister();
6387
- portalDeregister = key => this.portalRef.portalDeregister(key);
6388
- saveContainerRef = container => {
6389
- if (_victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__.isFunction(this.props.containerRef)) {
6390
- this.props.containerRef(container);
6391
- }
6392
- this.containerRef = container;
6393
- return container;
6367
+ const {
6368
+ title,
6369
+ desc,
6370
+ width,
6371
+ height,
6372
+ responsive
6373
+ } = props;
6374
+ const localContainerRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
6375
+
6376
+ // Generated ID stored in ref because it needs to persist across renders
6377
+ const generatedId = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default()("victory-container-"));
6378
+ const containerId = props.containerId ?? generatedId.current;
6379
+ const getIdForElement = elName => `${containerId}-${elName}`;
6380
+ const userProps = _victory_util_user_props__WEBPACK_IMPORTED_MODULE_3__.getSafeUserProps(props);
6381
+ const dimensions = responsive ? {
6382
+ width: "100%",
6383
+ height: "100%"
6384
+ } : {
6385
+ width,
6386
+ height
6394
6387
  };
6395
- handleWheel = e => e.preventDefault();
6396
- componentDidMount() {
6397
- if (this.shouldHandleWheel && this.containerRef) {
6398
- this.containerRef.addEventListener("wheel", this.handleWheel);
6399
- }
6400
- }
6401
- componentWillUnmount() {
6402
- if (this.shouldHandleWheel && this.containerRef) {
6403
- this.containerRef.removeEventListener("wheel", this.handleWheel);
6404
- }
6405
- }
6406
- getIdForElement(elementName) {
6407
- return `${this.containerId}-${elementName}`;
6408
- }
6409
-
6410
- // overridden in custom containers
6411
- getChildren(props) {
6412
- return props.children;
6413
- }
6414
-
6415
- // Get props defined by the Open UI Automation (OUIA) 1.0-RC spec
6416
- // See https://ouia.readthedocs.io/en/latest/README.html#ouia-component
6417
- getOUIAProps(props) {
6418
- const {
6419
- ouiaId,
6420
- ouiaSafe,
6421
- ouiaType
6422
- } = props;
6423
- return {
6424
- ...(ouiaId && {
6425
- "data-ouia-component-id": ouiaId
6426
- }),
6427
- ...(ouiaType && {
6428
- "data-ouia-component-type": ouiaType
6429
- }),
6430
- ...(ouiaSafe !== undefined && {
6431
- "data-ouia-safe": ouiaSafe
6432
- })
6433
- };
6434
- }
6435
- renderContainer(props, svgProps, style) {
6436
- const {
6437
- title,
6438
- desc,
6439
- portalComponent,
6440
- className,
6441
- width,
6442
- height,
6443
- portalZIndex,
6444
- responsive
6445
- } = props;
6446
- const children = this.getChildren(props);
6447
- const dimensions = responsive ? {
6448
- width: "100%",
6449
- height: "100%"
6450
- } : {
6451
- width,
6452
- height
6388
+ const viewBox = responsive ? `0 0 ${width} ${height}` : undefined;
6389
+ const preserveAspectRatio = responsive ? props.preserveAspectRatio : undefined;
6390
+ const ariaLabelledBy = [title && getIdForElement("title"), props["aria-labelledby"]].filter(Boolean).join(" ") || undefined;
6391
+ const ariaDescribedBy = [desc && getIdForElement("desc"), props["aria-describedby"]].filter(Boolean).join(" ") || undefined;
6392
+ const titleId = getIdForElement("title");
6393
+ const descId = getIdForElement("desc");
6394
+ return {
6395
+ ...props,
6396
+ titleId,
6397
+ descId,
6398
+ dimensions,
6399
+ viewBox,
6400
+ preserveAspectRatio,
6401
+ ariaLabelledBy,
6402
+ ariaDescribedBy,
6403
+ userProps,
6404
+ localContainerRef
6405
+ };
6406
+ }
6407
+ const VictoryContainer = initialProps => {
6408
+ const {
6409
+ role,
6410
+ title,
6411
+ desc,
6412
+ children,
6413
+ className,
6414
+ portalZIndex,
6415
+ portalComponent,
6416
+ width,
6417
+ height,
6418
+ style,
6419
+ tabIndex,
6420
+ responsive,
6421
+ events,
6422
+ ouiaId,
6423
+ ouiaSafe,
6424
+ ouiaType,
6425
+ dimensions,
6426
+ ariaDescribedBy,
6427
+ ariaLabelledBy,
6428
+ viewBox,
6429
+ preserveAspectRatio,
6430
+ userProps,
6431
+ titleId,
6432
+ descId,
6433
+ containerRef,
6434
+ localContainerRef
6435
+ } = useVictoryContainer(initialProps);
6436
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
6437
+ if (!events?.onWheel) return;
6438
+ const handleWheel = e => e.preventDefault();
6439
+ const container = localContainerRef?.current;
6440
+ container?.addEventListener("wheel", handleWheel);
6441
+ return () => {
6442
+ container?.removeEventListener("wheel", handleWheel);
6453
6443
  };
6454
- const divStyle = Object.assign({
6444
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6445
+ }, []);
6446
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal_context__WEBPACK_IMPORTED_MODULE_4__.PortalProvider, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", {
6447
+ className: className,
6448
+ style: {
6449
+ ...style,
6450
+ width: responsive ? style?.width : dimensions.width,
6451
+ height: responsive ? style?.height : dimensions.height,
6455
6452
  pointerEvents: "none",
6456
6453
  touchAction: "none",
6457
6454
  position: "relative"
6458
- }, dimensions);
6459
- const portalDivStyle = Object.assign({
6455
+ },
6456
+ "data-ouia-component-id": ouiaId,
6457
+ "data-ouia-component-type": ouiaType,
6458
+ "data-ouia-safe": ouiaSafe,
6459
+ ref: (0,_victory_util__WEBPACK_IMPORTED_MODULE_5__.mergeRefs)([localContainerRef, containerRef])
6460
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("svg", _extends({
6461
+ width: width,
6462
+ height: height,
6463
+ tabIndex: tabIndex,
6464
+ role: role,
6465
+ "aria-labelledby": ariaLabelledBy,
6466
+ "aria-describedby": ariaDescribedBy,
6467
+ viewBox: viewBox,
6468
+ preserveAspectRatio: preserveAspectRatio,
6469
+ style: {
6470
+ ...dimensions,
6471
+ pointerEvents: "all"
6472
+ }
6473
+ }, userProps, events), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("title", {
6474
+ id: titleId
6475
+ }, title) : null, desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("desc", {
6476
+ id: descId
6477
+ }, desc) : null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", {
6478
+ style: {
6479
+ ...dimensions,
6460
6480
  zIndex: portalZIndex,
6461
6481
  position: "absolute",
6462
6482
  top: 0,
6463
6483
  left: 0
6464
- }, dimensions);
6465
- const svgStyle = Object.assign({
6466
- pointerEvents: "all"
6467
- }, dimensions);
6468
- const portalSvgStyle = Object.assign({
6484
+ }
6485
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal_outlet__WEBPACK_IMPORTED_MODULE_6__.PortalOutlet, {
6486
+ as: portalComponent,
6487
+ width: width,
6488
+ height: height,
6489
+ viewBox: viewBox,
6490
+ preserveAspectRatio: preserveAspectRatio,
6491
+ style: {
6492
+ ...dimensions,
6469
6493
  overflow: "visible"
6470
- }, dimensions);
6471
- const portalProps = {
6472
- width,
6473
- height,
6474
- viewBox: svgProps.viewBox,
6475
- preserveAspectRatio: svgProps.preserveAspectRatio,
6476
- style: portalSvgStyle
6477
- };
6478
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement(_victory_portal_portal_context__WEBPACK_IMPORTED_MODULE_7__.PortalContext.Provider, {
6479
- value: {
6480
- portalUpdate: this.portalUpdate,
6481
- portalRegister: this.portalRegister,
6482
- portalDeregister: this.portalDeregister
6483
- }
6484
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("div", _extends({
6485
- style: lodash_defaults__WEBPACK_IMPORTED_MODULE_2___default()({}, style, divStyle),
6486
- className: className,
6487
- ref: this.saveContainerRef
6488
- }, this.getOUIAProps(props)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("svg", _extends({}, svgProps, {
6489
- style: svgStyle
6490
- }), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("title", {
6491
- id: this.getIdForElement("title")
6492
- }, title) : null, desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("desc", {
6493
- id: this.getIdForElement("desc")
6494
- }, desc) : null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("div", {
6495
- style: portalDivStyle
6496
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().cloneElement(portalComponent, {
6497
- ...portalProps,
6498
- ref: this.savePortalRef
6499
- }))));
6500
- }
6501
- render() {
6502
- const {
6503
- width,
6504
- height,
6505
- responsive,
6506
- events,
6507
- title,
6508
- desc,
6509
- tabIndex,
6510
- preserveAspectRatio,
6511
- role
6512
- } = this.props;
6513
- const style = responsive ? this.props.style : _victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__.omit(this.props.style, ["height", "width"]);
6514
- const userProps = _victory_util_user_props__WEBPACK_IMPORTED_MODULE_8__.getSafeUserProps(this.props);
6515
- const svgProps = Object.assign({
6516
- width,
6517
- height,
6518
- tabIndex,
6519
- role,
6520
- "aria-labelledby": [title && this.getIdForElement("title"), this.props["aria-labelledby"]].filter(Boolean).join(" ") || undefined,
6521
- "aria-describedby": [desc && this.getIdForElement("desc"), this.props["aria-describedby"]].filter(Boolean).join(" ") || undefined,
6522
- viewBox: responsive ? `0 0 ${width} ${height}` : undefined,
6523
- preserveAspectRatio: responsive ? preserveAspectRatio : undefined,
6524
- ...userProps
6525
- }, events);
6526
- return this.renderContainer(this.props, svgProps, style);
6527
- }
6528
- }
6494
+ }
6495
+ }))));
6496
+ };
6497
+ VictoryContainer.role = "container";
6529
6498
 
6530
6499
  /***/ }),
6531
6500
 
@@ -7038,17 +7007,83 @@ VictoryLabel.defaultStyles = defaultStyles;
7038
7007
  "use strict";
7039
7008
  __webpack_require__.r(__webpack_exports__);
7040
7009
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7041
- /* harmony export */ "PortalContext": function() { return /* binding */ PortalContext; }
7010
+ /* harmony export */ "PortalContext": function() { return /* binding */ PortalContext; },
7011
+ /* harmony export */ "PortalProvider": function() { return /* binding */ PortalProvider; },
7012
+ /* harmony export */ "usePortalContext": function() { return /* binding */ usePortalContext; }
7042
7013
  /* harmony export */ });
7043
7014
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
7044
7015
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
7045
7016
 
7046
- /**
7047
- * The React context object consumers may use to access the context of the
7048
- * portal.
7049
- */
7050
- const PortalContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext({});
7017
+ const PortalContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext(undefined);
7051
7018
  PortalContext.displayName = "PortalContext";
7019
+ const usePortalContext = () => {
7020
+ const context = react__WEBPACK_IMPORTED_MODULE_0___default().useContext(PortalContext);
7021
+ if (!context) {
7022
+ throw new Error("`usePortalContext` must be used within a `<PortalProvider />`");
7023
+ }
7024
+ return context;
7025
+ };
7026
+ const PortalProvider = _ref => {
7027
+ let {
7028
+ children
7029
+ } = _ref;
7030
+ const [portalChildren, setPortalChildren] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(new Map());
7031
+ const addChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback((id, element) => {
7032
+ setPortalChildren(prevChildren => {
7033
+ const nextChildren = new Map(prevChildren);
7034
+ nextChildren.set(id, element);
7035
+ return nextChildren;
7036
+ });
7037
+ }, [setPortalChildren]);
7038
+ const removeChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback(id => {
7039
+ setPortalChildren(prevChildren => {
7040
+ const nextChildren = new Map(prevChildren);
7041
+ nextChildren.delete(id);
7042
+ return nextChildren;
7043
+ });
7044
+ }, [setPortalChildren]);
7045
+ const contextValue = react__WEBPACK_IMPORTED_MODULE_0___default().useMemo(() => ({
7046
+ addChild,
7047
+ removeChild,
7048
+ children: portalChildren
7049
+ }), [addChild, removeChild, portalChildren]);
7050
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(PortalContext.Provider, {
7051
+ value: contextValue
7052
+ }, children);
7053
+ };
7054
+
7055
+ /***/ }),
7056
+
7057
+ /***/ "../../victory-core/es/victory-portal/portal-outlet.js":
7058
+ /*!*************************************************************!*\
7059
+ !*** ../../victory-core/es/victory-portal/portal-outlet.js ***!
7060
+ \*************************************************************/
7061
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
7062
+
7063
+ "use strict";
7064
+ __webpack_require__.r(__webpack_exports__);
7065
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7066
+ /* harmony export */ "PortalOutlet": function() { return /* binding */ PortalOutlet; }
7067
+ /* harmony export */ });
7068
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
7069
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
7070
+ /* harmony import */ var _portal_context__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./portal-context */ "../../victory-core/es/victory-portal/portal-context.js");
7071
+
7072
+
7073
+ const PortalOutlet = _ref => {
7074
+ let {
7075
+ as: portalComponent,
7076
+ ...props
7077
+ } = _ref;
7078
+ const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_1__.usePortalContext)();
7079
+ const children = Array.from(portalContext.children.entries()).map(_ref2 => {
7080
+ let [key, node] = _ref2;
7081
+ return !node.key ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(node, {
7082
+ key
7083
+ }) : node;
7084
+ });
7085
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(portalComponent, props, children);
7086
+ };
7052
7087
 
7053
7088
  /***/ }),
7054
7089
 
@@ -7065,39 +7100,13 @@ __webpack_require__.r(__webpack_exports__);
7065
7100
  /* harmony export */ });
7066
7101
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
7067
7102
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
7103
+ 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); }
7068
7104
 
7069
- class Portal extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
7070
- static displayName = "Portal";
7071
- constructor(props) {
7072
- super(props);
7073
- this.map = {};
7074
- this.index = 1;
7075
- }
7076
- portalRegister = () => {
7077
- return ++this.index;
7078
- };
7079
- portalUpdate = (key, element) => {
7080
- this.map[key] = element;
7081
- this.forceUpdate();
7082
- };
7083
- portalDeregister = key => {
7084
- delete this.map[key];
7085
- this.forceUpdate();
7086
- };
7087
- getChildren() {
7088
- return Object.keys(this.map).map(key => {
7089
- const el = this.map[key];
7090
- return el ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(el, {
7091
- key
7092
- }) : el;
7093
- });
7094
- }
7095
-
7096
- // Overridden in victory-core-native
7097
- render() {
7098
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", this.props, this.getChildren());
7099
- }
7100
- }
7105
+ const Portal = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().forwardRef((props, ref) => {
7106
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", _extends({
7107
+ ref: ref
7108
+ }, props));
7109
+ });
7101
7110
 
7102
7111
  /***/ }),
7103
7112
 
@@ -7124,59 +7133,42 @@ __webpack_require__.r(__webpack_exports__);
7124
7133
 
7125
7134
 
7126
7135
 
7127
- class VictoryPortal extends (react__WEBPACK_IMPORTED_MODULE_1___default().Component) {
7128
- static displayName = "VictoryPortal";
7129
- static role = "portal";
7130
- static defaultProps = {
7131
- groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("g", null)
7132
- };
7133
- static contextType = _portal_context__WEBPACK_IMPORTED_MODULE_2__.PortalContext;
7134
- componentDidMount() {
7135
- if (!this.checkedContext) {
7136
- if (typeof this.context.portalUpdate !== "function") {
7137
- const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
7138
- _victory_util_log__WEBPACK_IMPORTED_MODULE_3__.warn(msg);
7139
- this.renderInPlace = true;
7140
- }
7141
- this.checkedContext = true;
7142
- }
7143
- this.forceUpdate();
7144
- }
7145
- componentDidUpdate() {
7146
- if (!this.renderInPlace) {
7147
- this.portalKey = this.portalKey || this.context.portalRegister();
7148
- this.context.portalUpdate(this.portalKey, this.element);
7149
- }
7150
- }
7151
- componentWillUnmount() {
7152
- if (this.context && this.context.portalDeregister) {
7153
- this.context.portalDeregister(this.portalKey);
7154
- }
7155
- }
7156
-
7157
- // Overridden in victory-core-native
7158
- renderPortal(child) {
7159
- if (this.renderInPlace) {
7160
- return child;
7161
- }
7162
- this.element = child;
7163
- return null;
7164
- }
7165
- render() {
7166
- const children = Array.isArray(this.props.children) ? this.props.children[0] : this.props.children;
7136
+ const defaultProps = {
7137
+ groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("g", null)
7138
+ };
7139
+ const VictoryPortal = initialProps => {
7140
+ const props = {
7141
+ ...defaultProps,
7142
+ ...initialProps
7143
+ };
7144
+ const id = react__WEBPACK_IMPORTED_MODULE_1___default().useId();
7145
+ const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_2__.usePortalContext)();
7146
+ if (!portalContext) {
7147
+ const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
7148
+ _victory_util_log__WEBPACK_IMPORTED_MODULE_3__.warn(msg);
7149
+ }
7150
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
7151
+ const children = Array.isArray(props.children) ? props.children[0] : props.children;
7167
7152
  const {
7168
7153
  groupComponent
7169
- } = this.props;
7154
+ } = props;
7170
7155
  const childProps = children && children.props || {};
7171
7156
  const standardProps = childProps.groupComponent ? {
7172
7157
  groupComponent,
7173
7158
  standalone: false
7174
7159
  } : {};
7175
- const newProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(standardProps, childProps, _victory_util_helpers__WEBPACK_IMPORTED_MODULE_4__.omit(this.props, ["children", "groupComponent"]));
7160
+ const newProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(standardProps, childProps, _victory_util_helpers__WEBPACK_IMPORTED_MODULE_4__.omit(props, ["children", "groupComponent"]));
7176
7161
  const child = children && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().cloneElement(children, newProps);
7177
- return this.renderPortal(child);
7178
- }
7179
- }
7162
+ portalContext.addChild(id, child);
7163
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7164
+ }, [props.children]);
7165
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
7166
+ return () => portalContext.removeChild(id);
7167
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7168
+ }, []);
7169
+ return null;
7170
+ };
7171
+ VictoryPortal.role = "portal";
7180
7172
 
7181
7173
  /***/ }),
7182
7174
 
@@ -11377,6 +11369,44 @@ function warn(message) {
11377
11369
 
11378
11370
  /***/ }),
11379
11371
 
11372
+ /***/ "../../victory-core/es/victory-util/merge-refs.js":
11373
+ /*!********************************************************!*\
11374
+ !*** ../../victory-core/es/victory-util/merge-refs.js ***!
11375
+ \********************************************************/
11376
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
11377
+
11378
+ "use strict";
11379
+ __webpack_require__.r(__webpack_exports__);
11380
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11381
+ /* harmony export */ "mergeRefs": function() { return /* binding */ mergeRefs; }
11382
+ /* harmony export */ });
11383
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./helpers */ "../../victory-core/es/victory-util/helpers.js");
11384
+
11385
+ /**
11386
+ * Used to merge multiple React refs into a single callback ref.
11387
+ *
11388
+ * @example
11389
+ * ```tsx
11390
+ * <div ref={mergeRefs([ref, forwardedRef])} />
11391
+ * ```
11392
+ */
11393
+ function mergeRefs(refs) {
11394
+ return value => {
11395
+ refs.forEach(ref => {
11396
+ // If the ref is a function, it's a callback ref and we call it with the value.
11397
+ if (_helpers__WEBPACK_IMPORTED_MODULE_0__.isFunction(ref)) {
11398
+ ref(value);
11399
+ } else if (ref !== null && ref !== undefined) {
11400
+ // If the ref is an object (not null and not undefined), it's an object ref.
11401
+ // We assign the value to its 'current' property.
11402
+ ref.current = value;
11403
+ }
11404
+ });
11405
+ };
11406
+ }
11407
+
11408
+ /***/ }),
11409
+
11380
11410
  /***/ "../../victory-core/es/victory-util/scale.js":
11381
11411
  /*!***************************************************!*\
11382
11412
  !*** ../../victory-core/es/victory-util/scale.js ***!