victory-legend 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,12 @@
1
1
  # victory-legend
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
+
3
10
  ## 37.0.2
4
11
 
5
12
  ## 37.0.1
@@ -5394,23 +5394,18 @@ const VictoryAnimation = _ref => {
5394
5394
  "use strict";
5395
5395
  __webpack_require__.r(__webpack_exports__);
5396
5396
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5397
- /* harmony export */ "VictoryContainer": function() { return /* binding */ VictoryContainer; }
5397
+ /* harmony export */ "VictoryContainer": function() { return /* binding */ VictoryContainer; },
5398
+ /* harmony export */ "useVictoryContainer": function() { return /* binding */ useVictoryContainer; }
5398
5399
  /* harmony export */ });
5399
- /* 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");
5400
- /* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_isObject__WEBPACK_IMPORTED_MODULE_0__);
5401
- /* 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");
5402
- /* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1__);
5403
- /* 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");
5404
- /* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_defaults__WEBPACK_IMPORTED_MODULE_2__);
5405
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react */ "react");
5406
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_3__);
5407
- /* harmony import */ var _victory_portal_portal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../victory-portal/portal */ "../../victory-core/es/victory-portal/portal.js");
5408
- /* 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");
5409
- /* 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");
5410
- /* harmony import */ var _victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../victory-util/helpers */ "../../victory-core/es/victory-util/helpers.js");
5411
- /* 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");
5412
-
5413
-
5400
+ /* 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");
5401
+ /* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0__);
5402
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
5403
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
5404
+ /* harmony import */ var _victory_portal_portal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../victory-portal/portal */ "../../victory-core/es/victory-portal/portal.js");
5405
+ /* 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");
5406
+ /* harmony import */ var _victory_util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../victory-util */ "../../victory-core/es/victory-util/merge-refs.js");
5407
+ /* 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");
5408
+ /* 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");
5414
5409
 
5415
5410
  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); }
5416
5411
 
@@ -5419,175 +5414,149 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
5419
5414
 
5420
5415
 
5421
5416
 
5422
- class VictoryContainer extends (react__WEBPACK_IMPORTED_MODULE_3___default().Component) {
5423
- static displayName = "VictoryContainer";
5424
- static role = "container";
5425
- static defaultProps = {
5426
- className: "VictoryContainer",
5427
- portalComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement(_victory_portal_portal__WEBPACK_IMPORTED_MODULE_4__.Portal, null),
5428
- portalZIndex: 99,
5429
- responsive: true,
5430
- role: "img"
5417
+ const defaultProps = {
5418
+ className: "VictoryContainer",
5419
+ portalComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal__WEBPACK_IMPORTED_MODULE_2__.Portal, null),
5420
+ portalZIndex: 99,
5421
+ responsive: true,
5422
+ role: "img"
5423
+ };
5424
+ function useVictoryContainer(initialProps) {
5425
+ const props = {
5426
+ ...defaultProps,
5427
+ ...initialProps
5431
5428
  };
5432
- static contextType = _victory_util_timer_context__WEBPACK_IMPORTED_MODULE_5__["default"];
5433
-
5434
- // @ts-expect-error Ref will be initialized on mount
5435
-
5436
- // @ts-expect-error Ref will be initialized on mount
5437
-
5438
- constructor(props) {
5439
- super(props);
5440
- this.containerId = !lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default()(props) || props.containerId === undefined ? lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1___default()("victory-container-") : props.containerId;
5441
- this.shouldHandleWheel = !!(props && props.events && props.events.onWheel);
5442
- }
5443
- savePortalRef = portal => {
5444
- this.portalRef = portal;
5445
- return portal;
5429
+ const {
5430
+ title,
5431
+ desc,
5432
+ width,
5433
+ height,
5434
+ responsive
5435
+ } = props;
5436
+ const localContainerRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
5437
+
5438
+ // Generated ID stored in ref because it needs to persist across renders
5439
+ const generatedId = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default()("victory-container-"));
5440
+ const containerId = props.containerId ?? generatedId.current;
5441
+ const getIdForElement = elName => `${containerId}-${elName}`;
5442
+ const userProps = _victory_util_user_props__WEBPACK_IMPORTED_MODULE_3__.getSafeUserProps(props);
5443
+ const dimensions = responsive ? {
5444
+ width: "100%",
5445
+ height: "100%"
5446
+ } : {
5447
+ width,
5448
+ height
5446
5449
  };
5447
- portalUpdate = (key, el) => this.portalRef.portalUpdate(key, el);
5448
- portalRegister = () => this.portalRef.portalRegister();
5449
- portalDeregister = key => this.portalRef.portalDeregister(key);
5450
- saveContainerRef = container => {
5451
- if (_victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__.isFunction(this.props.containerRef)) {
5452
- this.props.containerRef(container);
5453
- }
5454
- this.containerRef = container;
5455
- return container;
5450
+ const viewBox = responsive ? `0 0 ${width} ${height}` : undefined;
5451
+ const preserveAspectRatio = responsive ? props.preserveAspectRatio : undefined;
5452
+ const ariaLabelledBy = [title && getIdForElement("title"), props["aria-labelledby"]].filter(Boolean).join(" ") || undefined;
5453
+ const ariaDescribedBy = [desc && getIdForElement("desc"), props["aria-describedby"]].filter(Boolean).join(" ") || undefined;
5454
+ const titleId = getIdForElement("title");
5455
+ const descId = getIdForElement("desc");
5456
+ return {
5457
+ ...props,
5458
+ titleId,
5459
+ descId,
5460
+ dimensions,
5461
+ viewBox,
5462
+ preserveAspectRatio,
5463
+ ariaLabelledBy,
5464
+ ariaDescribedBy,
5465
+ userProps,
5466
+ localContainerRef
5456
5467
  };
5457
- handleWheel = e => e.preventDefault();
5458
- componentDidMount() {
5459
- if (this.shouldHandleWheel && this.containerRef) {
5460
- this.containerRef.addEventListener("wheel", this.handleWheel);
5461
- }
5462
- }
5463
- componentWillUnmount() {
5464
- if (this.shouldHandleWheel && this.containerRef) {
5465
- this.containerRef.removeEventListener("wheel", this.handleWheel);
5466
- }
5467
- }
5468
- getIdForElement(elementName) {
5469
- return `${this.containerId}-${elementName}`;
5470
- }
5471
-
5472
- // overridden in custom containers
5473
- getChildren(props) {
5474
- return props.children;
5475
- }
5476
-
5477
- // Get props defined by the Open UI Automation (OUIA) 1.0-RC spec
5478
- // See https://ouia.readthedocs.io/en/latest/README.html#ouia-component
5479
- getOUIAProps(props) {
5480
- const {
5481
- ouiaId,
5482
- ouiaSafe,
5483
- ouiaType
5484
- } = props;
5485
- return {
5486
- ...(ouiaId && {
5487
- "data-ouia-component-id": ouiaId
5488
- }),
5489
- ...(ouiaType && {
5490
- "data-ouia-component-type": ouiaType
5491
- }),
5492
- ...(ouiaSafe !== undefined && {
5493
- "data-ouia-safe": ouiaSafe
5494
- })
5495
- };
5496
- }
5497
- renderContainer(props, svgProps, style) {
5498
- const {
5499
- title,
5500
- desc,
5501
- portalComponent,
5502
- className,
5503
- width,
5504
- height,
5505
- portalZIndex,
5506
- responsive
5507
- } = props;
5508
- const children = this.getChildren(props);
5509
- const dimensions = responsive ? {
5510
- width: "100%",
5511
- height: "100%"
5512
- } : {
5513
- width,
5514
- height
5468
+ }
5469
+ const VictoryContainer = initialProps => {
5470
+ const {
5471
+ role,
5472
+ title,
5473
+ desc,
5474
+ children,
5475
+ className,
5476
+ portalZIndex,
5477
+ portalComponent,
5478
+ width,
5479
+ height,
5480
+ style,
5481
+ tabIndex,
5482
+ responsive,
5483
+ events,
5484
+ ouiaId,
5485
+ ouiaSafe,
5486
+ ouiaType,
5487
+ dimensions,
5488
+ ariaDescribedBy,
5489
+ ariaLabelledBy,
5490
+ viewBox,
5491
+ preserveAspectRatio,
5492
+ userProps,
5493
+ titleId,
5494
+ descId,
5495
+ containerRef,
5496
+ localContainerRef
5497
+ } = useVictoryContainer(initialProps);
5498
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
5499
+ if (!events?.onWheel) return;
5500
+ const handleWheel = e => e.preventDefault();
5501
+ const container = localContainerRef?.current;
5502
+ container?.addEventListener("wheel", handleWheel);
5503
+ return () => {
5504
+ container?.removeEventListener("wheel", handleWheel);
5515
5505
  };
5516
- const divStyle = Object.assign({
5506
+ // eslint-disable-next-line react-hooks/exhaustive-deps
5507
+ }, []);
5508
+ 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", {
5509
+ className: className,
5510
+ style: {
5511
+ ...style,
5512
+ width: responsive ? style?.width : dimensions.width,
5513
+ height: responsive ? style?.height : dimensions.height,
5517
5514
  pointerEvents: "none",
5518
5515
  touchAction: "none",
5519
5516
  position: "relative"
5520
- }, dimensions);
5521
- const portalDivStyle = Object.assign({
5517
+ },
5518
+ "data-ouia-component-id": ouiaId,
5519
+ "data-ouia-component-type": ouiaType,
5520
+ "data-ouia-safe": ouiaSafe,
5521
+ ref: (0,_victory_util__WEBPACK_IMPORTED_MODULE_5__.mergeRefs)([localContainerRef, containerRef])
5522
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("svg", _extends({
5523
+ width: width,
5524
+ height: height,
5525
+ tabIndex: tabIndex,
5526
+ role: role,
5527
+ "aria-labelledby": ariaLabelledBy,
5528
+ "aria-describedby": ariaDescribedBy,
5529
+ viewBox: viewBox,
5530
+ preserveAspectRatio: preserveAspectRatio,
5531
+ style: {
5532
+ ...dimensions,
5533
+ pointerEvents: "all"
5534
+ }
5535
+ }, userProps, events), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("title", {
5536
+ id: titleId
5537
+ }, title) : null, desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("desc", {
5538
+ id: descId
5539
+ }, desc) : null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", {
5540
+ style: {
5541
+ ...dimensions,
5522
5542
  zIndex: portalZIndex,
5523
5543
  position: "absolute",
5524
5544
  top: 0,
5525
5545
  left: 0
5526
- }, dimensions);
5527
- const svgStyle = Object.assign({
5528
- pointerEvents: "all"
5529
- }, dimensions);
5530
- const portalSvgStyle = Object.assign({
5546
+ }
5547
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal_outlet__WEBPACK_IMPORTED_MODULE_6__.PortalOutlet, {
5548
+ as: portalComponent,
5549
+ width: width,
5550
+ height: height,
5551
+ viewBox: viewBox,
5552
+ preserveAspectRatio: preserveAspectRatio,
5553
+ style: {
5554
+ ...dimensions,
5531
5555
  overflow: "visible"
5532
- }, dimensions);
5533
- const portalProps = {
5534
- width,
5535
- height,
5536
- viewBox: svgProps.viewBox,
5537
- preserveAspectRatio: svgProps.preserveAspectRatio,
5538
- style: portalSvgStyle
5539
- };
5540
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement(_victory_portal_portal_context__WEBPACK_IMPORTED_MODULE_7__.PortalContext.Provider, {
5541
- value: {
5542
- portalUpdate: this.portalUpdate,
5543
- portalRegister: this.portalRegister,
5544
- portalDeregister: this.portalDeregister
5545
- }
5546
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("div", _extends({
5547
- style: lodash_defaults__WEBPACK_IMPORTED_MODULE_2___default()({}, style, divStyle),
5548
- className: className,
5549
- ref: this.saveContainerRef
5550
- }, this.getOUIAProps(props)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("svg", _extends({}, svgProps, {
5551
- style: svgStyle
5552
- }), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("title", {
5553
- id: this.getIdForElement("title")
5554
- }, title) : null, desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("desc", {
5555
- id: this.getIdForElement("desc")
5556
- }, desc) : null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("div", {
5557
- style: portalDivStyle
5558
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().cloneElement(portalComponent, {
5559
- ...portalProps,
5560
- ref: this.savePortalRef
5561
- }))));
5562
- }
5563
- render() {
5564
- const {
5565
- width,
5566
- height,
5567
- responsive,
5568
- events,
5569
- title,
5570
- desc,
5571
- tabIndex,
5572
- preserveAspectRatio,
5573
- role
5574
- } = this.props;
5575
- const style = responsive ? this.props.style : _victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__.omit(this.props.style, ["height", "width"]);
5576
- const userProps = _victory_util_user_props__WEBPACK_IMPORTED_MODULE_8__.getSafeUserProps(this.props);
5577
- const svgProps = Object.assign({
5578
- width,
5579
- height,
5580
- tabIndex,
5581
- role,
5582
- "aria-labelledby": [title && this.getIdForElement("title"), this.props["aria-labelledby"]].filter(Boolean).join(" ") || undefined,
5583
- "aria-describedby": [desc && this.getIdForElement("desc"), this.props["aria-describedby"]].filter(Boolean).join(" ") || undefined,
5584
- viewBox: responsive ? `0 0 ${width} ${height}` : undefined,
5585
- preserveAspectRatio: responsive ? preserveAspectRatio : undefined,
5586
- ...userProps
5587
- }, events);
5588
- return this.renderContainer(this.props, svgProps, style);
5589
- }
5590
- }
5556
+ }
5557
+ }))));
5558
+ };
5559
+ VictoryContainer.role = "container";
5591
5560
 
5592
5561
  /***/ }),
5593
5562
 
@@ -6100,17 +6069,83 @@ VictoryLabel.defaultStyles = defaultStyles;
6100
6069
  "use strict";
6101
6070
  __webpack_require__.r(__webpack_exports__);
6102
6071
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6103
- /* harmony export */ "PortalContext": function() { return /* binding */ PortalContext; }
6072
+ /* harmony export */ "PortalContext": function() { return /* binding */ PortalContext; },
6073
+ /* harmony export */ "PortalProvider": function() { return /* binding */ PortalProvider; },
6074
+ /* harmony export */ "usePortalContext": function() { return /* binding */ usePortalContext; }
6104
6075
  /* harmony export */ });
6105
6076
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
6106
6077
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
6107
6078
 
6108
- /**
6109
- * The React context object consumers may use to access the context of the
6110
- * portal.
6111
- */
6112
- const PortalContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext({});
6079
+ const PortalContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext(undefined);
6113
6080
  PortalContext.displayName = "PortalContext";
6081
+ const usePortalContext = () => {
6082
+ const context = react__WEBPACK_IMPORTED_MODULE_0___default().useContext(PortalContext);
6083
+ if (!context) {
6084
+ throw new Error("`usePortalContext` must be used within a `<PortalProvider />`");
6085
+ }
6086
+ return context;
6087
+ };
6088
+ const PortalProvider = _ref => {
6089
+ let {
6090
+ children
6091
+ } = _ref;
6092
+ const [portalChildren, setPortalChildren] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(new Map());
6093
+ const addChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback((id, element) => {
6094
+ setPortalChildren(prevChildren => {
6095
+ const nextChildren = new Map(prevChildren);
6096
+ nextChildren.set(id, element);
6097
+ return nextChildren;
6098
+ });
6099
+ }, [setPortalChildren]);
6100
+ const removeChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback(id => {
6101
+ setPortalChildren(prevChildren => {
6102
+ const nextChildren = new Map(prevChildren);
6103
+ nextChildren.delete(id);
6104
+ return nextChildren;
6105
+ });
6106
+ }, [setPortalChildren]);
6107
+ const contextValue = react__WEBPACK_IMPORTED_MODULE_0___default().useMemo(() => ({
6108
+ addChild,
6109
+ removeChild,
6110
+ children: portalChildren
6111
+ }), [addChild, removeChild, portalChildren]);
6112
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(PortalContext.Provider, {
6113
+ value: contextValue
6114
+ }, children);
6115
+ };
6116
+
6117
+ /***/ }),
6118
+
6119
+ /***/ "../../victory-core/es/victory-portal/portal-outlet.js":
6120
+ /*!*************************************************************!*\
6121
+ !*** ../../victory-core/es/victory-portal/portal-outlet.js ***!
6122
+ \*************************************************************/
6123
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
6124
+
6125
+ "use strict";
6126
+ __webpack_require__.r(__webpack_exports__);
6127
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6128
+ /* harmony export */ "PortalOutlet": function() { return /* binding */ PortalOutlet; }
6129
+ /* harmony export */ });
6130
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
6131
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
6132
+ /* harmony import */ var _portal_context__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./portal-context */ "../../victory-core/es/victory-portal/portal-context.js");
6133
+
6134
+
6135
+ const PortalOutlet = _ref => {
6136
+ let {
6137
+ as: portalComponent,
6138
+ ...props
6139
+ } = _ref;
6140
+ const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_1__.usePortalContext)();
6141
+ const children = Array.from(portalContext.children.entries()).map(_ref2 => {
6142
+ let [key, node] = _ref2;
6143
+ return !node.key ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(node, {
6144
+ key
6145
+ }) : node;
6146
+ });
6147
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(portalComponent, props, children);
6148
+ };
6114
6149
 
6115
6150
  /***/ }),
6116
6151
 
@@ -6127,39 +6162,13 @@ __webpack_require__.r(__webpack_exports__);
6127
6162
  /* harmony export */ });
6128
6163
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
6129
6164
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
6165
+ 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); }
6130
6166
 
6131
- class Portal extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
6132
- static displayName = "Portal";
6133
- constructor(props) {
6134
- super(props);
6135
- this.map = {};
6136
- this.index = 1;
6137
- }
6138
- portalRegister = () => {
6139
- return ++this.index;
6140
- };
6141
- portalUpdate = (key, element) => {
6142
- this.map[key] = element;
6143
- this.forceUpdate();
6144
- };
6145
- portalDeregister = key => {
6146
- delete this.map[key];
6147
- this.forceUpdate();
6148
- };
6149
- getChildren() {
6150
- return Object.keys(this.map).map(key => {
6151
- const el = this.map[key];
6152
- return el ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(el, {
6153
- key
6154
- }) : el;
6155
- });
6156
- }
6157
-
6158
- // Overridden in victory-core-native
6159
- render() {
6160
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", this.props, this.getChildren());
6161
- }
6162
- }
6167
+ const Portal = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().forwardRef((props, ref) => {
6168
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", _extends({
6169
+ ref: ref
6170
+ }, props));
6171
+ });
6163
6172
 
6164
6173
  /***/ }),
6165
6174
 
@@ -6186,59 +6195,42 @@ __webpack_require__.r(__webpack_exports__);
6186
6195
 
6187
6196
 
6188
6197
 
6189
- class VictoryPortal extends (react__WEBPACK_IMPORTED_MODULE_1___default().Component) {
6190
- static displayName = "VictoryPortal";
6191
- static role = "portal";
6192
- static defaultProps = {
6193
- groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("g", null)
6198
+ const defaultProps = {
6199
+ groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("g", null)
6200
+ };
6201
+ const VictoryPortal = initialProps => {
6202
+ const props = {
6203
+ ...defaultProps,
6204
+ ...initialProps
6194
6205
  };
6195
- static contextType = _portal_context__WEBPACK_IMPORTED_MODULE_2__.PortalContext;
6196
- componentDidMount() {
6197
- if (!this.checkedContext) {
6198
- if (typeof this.context.portalUpdate !== "function") {
6199
- const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
6200
- _victory_util_log__WEBPACK_IMPORTED_MODULE_3__.warn(msg);
6201
- this.renderInPlace = true;
6202
- }
6203
- this.checkedContext = true;
6204
- }
6205
- this.forceUpdate();
6206
- }
6207
- componentDidUpdate() {
6208
- if (!this.renderInPlace) {
6209
- this.portalKey = this.portalKey || this.context.portalRegister();
6210
- this.context.portalUpdate(this.portalKey, this.element);
6211
- }
6212
- }
6213
- componentWillUnmount() {
6214
- if (this.context && this.context.portalDeregister) {
6215
- this.context.portalDeregister(this.portalKey);
6216
- }
6217
- }
6218
-
6219
- // Overridden in victory-core-native
6220
- renderPortal(child) {
6221
- if (this.renderInPlace) {
6222
- return child;
6223
- }
6224
- this.element = child;
6225
- return null;
6226
- }
6227
- render() {
6228
- const children = Array.isArray(this.props.children) ? this.props.children[0] : this.props.children;
6206
+ const id = react__WEBPACK_IMPORTED_MODULE_1___default().useId();
6207
+ const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_2__.usePortalContext)();
6208
+ if (!portalContext) {
6209
+ const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
6210
+ _victory_util_log__WEBPACK_IMPORTED_MODULE_3__.warn(msg);
6211
+ }
6212
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
6213
+ const children = Array.isArray(props.children) ? props.children[0] : props.children;
6229
6214
  const {
6230
6215
  groupComponent
6231
- } = this.props;
6216
+ } = props;
6232
6217
  const childProps = children && children.props || {};
6233
6218
  const standardProps = childProps.groupComponent ? {
6234
6219
  groupComponent,
6235
6220
  standalone: false
6236
6221
  } : {};
6237
- const newProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(standardProps, childProps, _victory_util_helpers__WEBPACK_IMPORTED_MODULE_4__.omit(this.props, ["children", "groupComponent"]));
6222
+ const newProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(standardProps, childProps, _victory_util_helpers__WEBPACK_IMPORTED_MODULE_4__.omit(props, ["children", "groupComponent"]));
6238
6223
  const child = children && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().cloneElement(children, newProps);
6239
- return this.renderPortal(child);
6240
- }
6241
- }
6224
+ portalContext.addChild(id, child);
6225
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6226
+ }, [props.children]);
6227
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
6228
+ return () => portalContext.removeChild(id);
6229
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6230
+ }, []);
6231
+ return null;
6232
+ };
6233
+ VictoryPortal.role = "portal";
6242
6234
 
6243
6235
  /***/ }),
6244
6236
 
@@ -8865,6 +8857,44 @@ function warn(message) {
8865
8857
 
8866
8858
  /***/ }),
8867
8859
 
8860
+ /***/ "../../victory-core/es/victory-util/merge-refs.js":
8861
+ /*!********************************************************!*\
8862
+ !*** ../../victory-core/es/victory-util/merge-refs.js ***!
8863
+ \********************************************************/
8864
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
8865
+
8866
+ "use strict";
8867
+ __webpack_require__.r(__webpack_exports__);
8868
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8869
+ /* harmony export */ "mergeRefs": function() { return /* binding */ mergeRefs; }
8870
+ /* harmony export */ });
8871
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./helpers */ "../../victory-core/es/victory-util/helpers.js");
8872
+
8873
+ /**
8874
+ * Used to merge multiple React refs into a single callback ref.
8875
+ *
8876
+ * @example
8877
+ * ```tsx
8878
+ * <div ref={mergeRefs([ref, forwardedRef])} />
8879
+ * ```
8880
+ */
8881
+ function mergeRefs(refs) {
8882
+ return value => {
8883
+ refs.forEach(ref => {
8884
+ // If the ref is a function, it's a callback ref and we call it with the value.
8885
+ if (_helpers__WEBPACK_IMPORTED_MODULE_0__.isFunction(ref)) {
8886
+ ref(value);
8887
+ } else if (ref !== null && ref !== undefined) {
8888
+ // If the ref is an object (not null and not undefined), it's an object ref.
8889
+ // We assign the value to its 'current' property.
8890
+ ref.current = value;
8891
+ }
8892
+ });
8893
+ };
8894
+ }
8895
+
8896
+ /***/ }),
8897
+
8868
8898
  /***/ "../../victory-core/es/victory-util/point-path-helpers.js":
8869
8899
  /*!****************************************************************!*\
8870
8900
  !*** ../../victory-core/es/victory-util/point-path-helpers.js ***!