victory-voronoi 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # victory-voronoi
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
+
3
9
  ## 37.0.2
4
10
 
5
11
  ### Patch Changes
@@ -6374,23 +6374,18 @@ const VictoryAnimation = _ref => {
6374
6374
  "use strict";
6375
6375
  __webpack_require__.r(__webpack_exports__);
6376
6376
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6377
- /* harmony export */ "VictoryContainer": function() { return /* binding */ VictoryContainer; }
6377
+ /* harmony export */ "VictoryContainer": function() { return /* binding */ VictoryContainer; },
6378
+ /* harmony export */ "useVictoryContainer": function() { return /* binding */ useVictoryContainer; }
6378
6379
  /* harmony export */ });
6379
- /* 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");
6380
- /* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_isObject__WEBPACK_IMPORTED_MODULE_0__);
6381
- /* 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");
6382
- /* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1__);
6383
- /* 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");
6384
- /* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_defaults__WEBPACK_IMPORTED_MODULE_2__);
6385
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react */ "react");
6386
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_3__);
6387
- /* harmony import */ var _victory_portal_portal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../victory-portal/portal */ "../../victory-core/es/victory-portal/portal.js");
6388
- /* 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");
6389
- /* 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");
6390
- /* harmony import */ var _victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../victory-util/helpers */ "../../victory-core/es/victory-util/helpers.js");
6391
- /* 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");
6392
-
6393
-
6380
+ /* 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");
6381
+ /* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0__);
6382
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
6383
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
6384
+ /* harmony import */ var _victory_portal_portal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../victory-portal/portal */ "../../victory-core/es/victory-portal/portal.js");
6385
+ /* 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");
6386
+ /* harmony import */ var _victory_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../victory-util */ "../../victory-core/es/victory-util/merge-refs.js");
6387
+ /* 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");
6388
+ /* 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");
6394
6389
 
6395
6390
  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); }
6396
6391
 
@@ -6399,175 +6394,149 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
6399
6394
 
6400
6395
 
6401
6396
 
6402
- class VictoryContainer extends (react__WEBPACK_IMPORTED_MODULE_3___default().Component) {
6403
- static displayName = "VictoryContainer";
6404
- static role = "container";
6405
- static defaultProps = {
6406
- className: "VictoryContainer",
6407
- portalComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement(_victory_portal_portal__WEBPACK_IMPORTED_MODULE_4__.Portal, null),
6408
- portalZIndex: 99,
6409
- responsive: true,
6410
- role: "img"
6397
+ const defaultProps = {
6398
+ className: "VictoryContainer",
6399
+ portalComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal__WEBPACK_IMPORTED_MODULE_2__.Portal, null),
6400
+ portalZIndex: 99,
6401
+ responsive: true,
6402
+ role: "img"
6403
+ };
6404
+ function useVictoryContainer(initialProps) {
6405
+ const props = {
6406
+ ...defaultProps,
6407
+ ...initialProps
6411
6408
  };
6412
- static contextType = _victory_util_timer_context__WEBPACK_IMPORTED_MODULE_5__["default"];
6413
-
6414
- // @ts-expect-error Ref will be initialized on mount
6415
-
6416
- // @ts-expect-error Ref will be initialized on mount
6417
-
6418
- constructor(props) {
6419
- super(props);
6420
- this.containerId = !lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default()(props) || props.containerId === undefined ? lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1___default()("victory-container-") : props.containerId;
6421
- this.shouldHandleWheel = !!(props && props.events && props.events.onWheel);
6422
- }
6423
- savePortalRef = portal => {
6424
- this.portalRef = portal;
6425
- return portal;
6409
+ const {
6410
+ title,
6411
+ desc,
6412
+ width,
6413
+ height,
6414
+ responsive
6415
+ } = props;
6416
+ const localContainerRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
6417
+
6418
+ // Generated ID stored in ref because it needs to persist across renders
6419
+ const generatedId = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default()("victory-container-"));
6420
+ const containerId = props.containerId ?? generatedId.current;
6421
+ const getIdForElement = elName => `${containerId}-${elName}`;
6422
+ const userProps = _victory_util_user_props__WEBPACK_IMPORTED_MODULE_3__.getSafeUserProps(props);
6423
+ const dimensions = responsive ? {
6424
+ width: "100%",
6425
+ height: "100%"
6426
+ } : {
6427
+ width,
6428
+ height
6426
6429
  };
6427
- portalUpdate = (key, el) => this.portalRef.portalUpdate(key, el);
6428
- portalRegister = () => this.portalRef.portalRegister();
6429
- portalDeregister = key => this.portalRef.portalDeregister(key);
6430
- saveContainerRef = container => {
6431
- if (_victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__.isFunction(this.props.containerRef)) {
6432
- this.props.containerRef(container);
6433
- }
6434
- this.containerRef = container;
6435
- return container;
6430
+ const viewBox = responsive ? `0 0 ${width} ${height}` : undefined;
6431
+ const preserveAspectRatio = responsive ? props.preserveAspectRatio : undefined;
6432
+ const ariaLabelledBy = [title && getIdForElement("title"), props["aria-labelledby"]].filter(Boolean).join(" ") || undefined;
6433
+ const ariaDescribedBy = [desc && getIdForElement("desc"), props["aria-describedby"]].filter(Boolean).join(" ") || undefined;
6434
+ const titleId = getIdForElement("title");
6435
+ const descId = getIdForElement("desc");
6436
+ return {
6437
+ ...props,
6438
+ titleId,
6439
+ descId,
6440
+ dimensions,
6441
+ viewBox,
6442
+ preserveAspectRatio,
6443
+ ariaLabelledBy,
6444
+ ariaDescribedBy,
6445
+ userProps,
6446
+ localContainerRef
6436
6447
  };
6437
- handleWheel = e => e.preventDefault();
6438
- componentDidMount() {
6439
- if (this.shouldHandleWheel && this.containerRef) {
6440
- this.containerRef.addEventListener("wheel", this.handleWheel);
6441
- }
6442
- }
6443
- componentWillUnmount() {
6444
- if (this.shouldHandleWheel && this.containerRef) {
6445
- this.containerRef.removeEventListener("wheel", this.handleWheel);
6446
- }
6447
- }
6448
- getIdForElement(elementName) {
6449
- return `${this.containerId}-${elementName}`;
6450
- }
6451
-
6452
- // overridden in custom containers
6453
- getChildren(props) {
6454
- return props.children;
6455
- }
6456
-
6457
- // Get props defined by the Open UI Automation (OUIA) 1.0-RC spec
6458
- // See https://ouia.readthedocs.io/en/latest/README.html#ouia-component
6459
- getOUIAProps(props) {
6460
- const {
6461
- ouiaId,
6462
- ouiaSafe,
6463
- ouiaType
6464
- } = props;
6465
- return {
6466
- ...(ouiaId && {
6467
- "data-ouia-component-id": ouiaId
6468
- }),
6469
- ...(ouiaType && {
6470
- "data-ouia-component-type": ouiaType
6471
- }),
6472
- ...(ouiaSafe !== undefined && {
6473
- "data-ouia-safe": ouiaSafe
6474
- })
6475
- };
6476
- }
6477
- renderContainer(props, svgProps, style) {
6478
- const {
6479
- title,
6480
- desc,
6481
- portalComponent,
6482
- className,
6483
- width,
6484
- height,
6485
- portalZIndex,
6486
- responsive
6487
- } = props;
6488
- const children = this.getChildren(props);
6489
- const dimensions = responsive ? {
6490
- width: "100%",
6491
- height: "100%"
6492
- } : {
6493
- width,
6494
- height
6448
+ }
6449
+ const VictoryContainer = initialProps => {
6450
+ const {
6451
+ role,
6452
+ title,
6453
+ desc,
6454
+ children,
6455
+ className,
6456
+ portalZIndex,
6457
+ portalComponent,
6458
+ width,
6459
+ height,
6460
+ style,
6461
+ tabIndex,
6462
+ responsive,
6463
+ events,
6464
+ ouiaId,
6465
+ ouiaSafe,
6466
+ ouiaType,
6467
+ dimensions,
6468
+ ariaDescribedBy,
6469
+ ariaLabelledBy,
6470
+ viewBox,
6471
+ preserveAspectRatio,
6472
+ userProps,
6473
+ titleId,
6474
+ descId,
6475
+ containerRef,
6476
+ localContainerRef
6477
+ } = useVictoryContainer(initialProps);
6478
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
6479
+ if (!events?.onWheel) return;
6480
+ const handleWheel = e => e.preventDefault();
6481
+ const container = localContainerRef?.current;
6482
+ container?.addEventListener("wheel", handleWheel);
6483
+ return () => {
6484
+ container?.removeEventListener("wheel", handleWheel);
6495
6485
  };
6496
- const divStyle = Object.assign({
6486
+ // eslint-disable-next-line react-hooks/exhaustive-deps
6487
+ }, []);
6488
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", {
6489
+ className: className,
6490
+ style: {
6491
+ ...style,
6492
+ width: responsive ? style?.width : dimensions.width,
6493
+ height: responsive ? style?.height : dimensions.height,
6497
6494
  pointerEvents: "none",
6498
6495
  touchAction: "none",
6499
6496
  position: "relative"
6500
- }, dimensions);
6501
- const portalDivStyle = Object.assign({
6497
+ },
6498
+ "data-ouia-component-id": ouiaId,
6499
+ "data-ouia-component-type": ouiaType,
6500
+ "data-ouia-safe": ouiaSafe,
6501
+ ref: (0,_victory_util__WEBPACK_IMPORTED_MODULE_4__.mergeRefs)([localContainerRef, containerRef])
6502
+ }, /*#__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({
6503
+ width: width,
6504
+ height: height,
6505
+ tabIndex: tabIndex,
6506
+ role: role,
6507
+ "aria-labelledby": ariaLabelledBy,
6508
+ "aria-describedby": ariaDescribedBy,
6509
+ viewBox: viewBox,
6510
+ preserveAspectRatio: preserveAspectRatio,
6511
+ style: {
6512
+ ...dimensions,
6513
+ pointerEvents: "all"
6514
+ }
6515
+ }, userProps, events), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("title", {
6516
+ id: titleId
6517
+ }, title) : null, desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("desc", {
6518
+ id: descId
6519
+ }, desc) : null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", {
6520
+ style: {
6521
+ ...dimensions,
6502
6522
  zIndex: portalZIndex,
6503
6523
  position: "absolute",
6504
6524
  top: 0,
6505
6525
  left: 0
6506
- }, dimensions);
6507
- const svgStyle = Object.assign({
6508
- pointerEvents: "all"
6509
- }, dimensions);
6510
- const portalSvgStyle = Object.assign({
6526
+ }
6527
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal_outlet__WEBPACK_IMPORTED_MODULE_6__.PortalOutlet, {
6528
+ as: portalComponent,
6529
+ width: width,
6530
+ height: height,
6531
+ viewBox: viewBox,
6532
+ preserveAspectRatio: preserveAspectRatio,
6533
+ style: {
6534
+ ...dimensions,
6511
6535
  overflow: "visible"
6512
- }, dimensions);
6513
- const portalProps = {
6514
- width,
6515
- height,
6516
- viewBox: svgProps.viewBox,
6517
- preserveAspectRatio: svgProps.preserveAspectRatio,
6518
- style: portalSvgStyle
6519
- };
6520
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement(_victory_portal_portal_context__WEBPACK_IMPORTED_MODULE_7__.PortalContext.Provider, {
6521
- value: {
6522
- portalUpdate: this.portalUpdate,
6523
- portalRegister: this.portalRegister,
6524
- portalDeregister: this.portalDeregister
6525
- }
6526
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("div", _extends({
6527
- style: lodash_defaults__WEBPACK_IMPORTED_MODULE_2___default()({}, style, divStyle),
6528
- className: className,
6529
- ref: this.saveContainerRef
6530
- }, this.getOUIAProps(props)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("svg", _extends({}, svgProps, {
6531
- style: svgStyle
6532
- }), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("title", {
6533
- id: this.getIdForElement("title")
6534
- }, title) : null, desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("desc", {
6535
- id: this.getIdForElement("desc")
6536
- }, desc) : null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("div", {
6537
- style: portalDivStyle
6538
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().cloneElement(portalComponent, {
6539
- ...portalProps,
6540
- ref: this.savePortalRef
6541
- }))));
6542
- }
6543
- render() {
6544
- const {
6545
- width,
6546
- height,
6547
- responsive,
6548
- events,
6549
- title,
6550
- desc,
6551
- tabIndex,
6552
- preserveAspectRatio,
6553
- role
6554
- } = this.props;
6555
- const style = responsive ? this.props.style : _victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__.omit(this.props.style, ["height", "width"]);
6556
- const userProps = _victory_util_user_props__WEBPACK_IMPORTED_MODULE_8__.getSafeUserProps(this.props);
6557
- const svgProps = Object.assign({
6558
- width,
6559
- height,
6560
- tabIndex,
6561
- role,
6562
- "aria-labelledby": [title && this.getIdForElement("title"), this.props["aria-labelledby"]].filter(Boolean).join(" ") || undefined,
6563
- "aria-describedby": [desc && this.getIdForElement("desc"), this.props["aria-describedby"]].filter(Boolean).join(" ") || undefined,
6564
- viewBox: responsive ? `0 0 ${width} ${height}` : undefined,
6565
- preserveAspectRatio: responsive ? preserveAspectRatio : undefined,
6566
- ...userProps
6567
- }, events);
6568
- return this.renderContainer(this.props, svgProps, style);
6569
- }
6570
- }
6536
+ }
6537
+ }))));
6538
+ };
6539
+ VictoryContainer.role = "container";
6571
6540
 
6572
6541
  /***/ }),
6573
6542
 
@@ -7080,17 +7049,78 @@ VictoryLabel.defaultStyles = defaultStyles;
7080
7049
  "use strict";
7081
7050
  __webpack_require__.r(__webpack_exports__);
7082
7051
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7083
- /* harmony export */ "PortalContext": function() { return /* binding */ PortalContext; }
7052
+ /* harmony export */ "PortalContext": function() { return /* binding */ PortalContext; },
7053
+ /* harmony export */ "PortalProvider": function() { return /* binding */ PortalProvider; },
7054
+ /* harmony export */ "usePortalContext": function() { return /* binding */ usePortalContext; }
7084
7055
  /* harmony export */ });
7085
7056
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
7086
7057
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
7087
7058
 
7088
- /**
7089
- * The React context object consumers may use to access the context of the
7090
- * portal.
7091
- */
7092
- const PortalContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext({});
7059
+ const PortalContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext(undefined);
7093
7060
  PortalContext.displayName = "PortalContext";
7061
+ const usePortalContext = () => {
7062
+ const context = react__WEBPACK_IMPORTED_MODULE_0___default().useContext(PortalContext);
7063
+ return context;
7064
+ };
7065
+ const PortalProvider = _ref => {
7066
+ let {
7067
+ children
7068
+ } = _ref;
7069
+ const [portalChildren, setPortalChildren] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(new Map());
7070
+ const addChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback((id, element) => {
7071
+ setPortalChildren(prevChildren => {
7072
+ const nextChildren = new Map(prevChildren);
7073
+ nextChildren.set(id, element);
7074
+ return nextChildren;
7075
+ });
7076
+ }, [setPortalChildren]);
7077
+ const removeChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback(id => {
7078
+ setPortalChildren(prevChildren => {
7079
+ const nextChildren = new Map(prevChildren);
7080
+ nextChildren.delete(id);
7081
+ return nextChildren;
7082
+ });
7083
+ }, [setPortalChildren]);
7084
+ const contextValue = react__WEBPACK_IMPORTED_MODULE_0___default().useMemo(() => ({
7085
+ addChild,
7086
+ removeChild,
7087
+ children: portalChildren
7088
+ }), [addChild, removeChild, portalChildren]);
7089
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(PortalContext.Provider, {
7090
+ value: contextValue
7091
+ }, children);
7092
+ };
7093
+
7094
+ /***/ }),
7095
+
7096
+ /***/ "../../victory-core/es/victory-portal/portal-outlet.js":
7097
+ /*!*************************************************************!*\
7098
+ !*** ../../victory-core/es/victory-portal/portal-outlet.js ***!
7099
+ \*************************************************************/
7100
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
7101
+
7102
+ "use strict";
7103
+ __webpack_require__.r(__webpack_exports__);
7104
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7105
+ /* harmony export */ "PortalOutlet": function() { return /* binding */ PortalOutlet; }
7106
+ /* harmony export */ });
7107
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
7108
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
7109
+ /* harmony import */ var _portal_context__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./portal-context */ "../../victory-core/es/victory-portal/portal-context.js");
7110
+
7111
+
7112
+ const PortalOutlet = _ref => {
7113
+ let {
7114
+ as: portalComponent,
7115
+ ...props
7116
+ } = _ref;
7117
+ const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_1__.usePortalContext)();
7118
+ if (!portalContext) {
7119
+ return null;
7120
+ }
7121
+ const children = Array.from(portalContext.children.values());
7122
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(portalComponent, props, children);
7123
+ };
7094
7124
 
7095
7125
  /***/ }),
7096
7126
 
@@ -7107,39 +7137,13 @@ __webpack_require__.r(__webpack_exports__);
7107
7137
  /* harmony export */ });
7108
7138
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
7109
7139
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
7140
+ 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); }
7110
7141
 
7111
- class Portal extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
7112
- static displayName = "Portal";
7113
- constructor(props) {
7114
- super(props);
7115
- this.map = {};
7116
- this.index = 1;
7117
- }
7118
- portalRegister = () => {
7119
- return ++this.index;
7120
- };
7121
- portalUpdate = (key, element) => {
7122
- this.map[key] = element;
7123
- this.forceUpdate();
7124
- };
7125
- portalDeregister = key => {
7126
- delete this.map[key];
7127
- this.forceUpdate();
7128
- };
7129
- getChildren() {
7130
- return Object.keys(this.map).map(key => {
7131
- const el = this.map[key];
7132
- return el ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(el, {
7133
- key
7134
- }) : el;
7135
- });
7136
- }
7137
-
7138
- // Overridden in victory-core-native
7139
- render() {
7140
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", this.props, this.getChildren());
7141
- }
7142
- }
7142
+ const Portal = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().forwardRef((props, ref) => {
7143
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", _extends({
7144
+ ref: ref
7145
+ }, props));
7146
+ });
7143
7147
 
7144
7148
  /***/ }),
7145
7149
 
@@ -7166,59 +7170,44 @@ __webpack_require__.r(__webpack_exports__);
7166
7170
 
7167
7171
 
7168
7172
 
7169
- class VictoryPortal extends (react__WEBPACK_IMPORTED_MODULE_1___default().Component) {
7170
- static displayName = "VictoryPortal";
7171
- static role = "portal";
7172
- static defaultProps = {
7173
- groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("g", null)
7173
+ const defaultProps = {
7174
+ groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("g", null)
7175
+ };
7176
+ const VictoryPortal = initialProps => {
7177
+ const props = {
7178
+ ...defaultProps,
7179
+ ...initialProps
7174
7180
  };
7175
- static contextType = _portal_context__WEBPACK_IMPORTED_MODULE_2__.PortalContext;
7176
- componentDidMount() {
7177
- if (!this.checkedContext) {
7178
- if (typeof this.context.portalUpdate !== "function") {
7179
- const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
7180
- _victory_util_log__WEBPACK_IMPORTED_MODULE_3__.warn(msg);
7181
- this.renderInPlace = true;
7182
- }
7183
- this.checkedContext = true;
7184
- }
7185
- this.forceUpdate();
7186
- }
7187
- componentDidUpdate() {
7188
- if (!this.renderInPlace) {
7189
- this.portalKey = this.portalKey || this.context.portalRegister();
7190
- this.context.portalUpdate(this.portalKey, this.element);
7191
- }
7192
- }
7193
- componentWillUnmount() {
7194
- if (this.context && this.context.portalDeregister) {
7195
- this.context.portalDeregister(this.portalKey);
7196
- }
7197
- }
7198
-
7199
- // Overridden in victory-core-native
7200
- renderPortal(child) {
7201
- if (this.renderInPlace) {
7202
- return child;
7203
- }
7204
- this.element = child;
7205
- return null;
7206
- }
7207
- render() {
7208
- const children = Array.isArray(this.props.children) ? this.props.children[0] : this.props.children;
7209
- const {
7210
- groupComponent
7211
- } = this.props;
7212
- const childProps = children && children.props || {};
7213
- const standardProps = childProps.groupComponent ? {
7214
- groupComponent,
7215
- standalone: false
7216
- } : {};
7217
- const newProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(standardProps, childProps, _victory_util_helpers__WEBPACK_IMPORTED_MODULE_4__.omit(this.props, ["children", "groupComponent"]));
7218
- const child = children && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().cloneElement(children, newProps);
7219
- return this.renderPortal(child);
7181
+ const id = react__WEBPACK_IMPORTED_MODULE_1___default().useId();
7182
+ const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_2__.usePortalContext)();
7183
+ if (!portalContext) {
7184
+ const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
7185
+ _victory_util_log__WEBPACK_IMPORTED_MODULE_3__.warn(msg);
7220
7186
  }
7221
- }
7187
+ const children = Array.isArray(props.children) ? props.children[0] : props.children;
7188
+ const {
7189
+ groupComponent
7190
+ } = props;
7191
+ const childProps = children && children.props || {};
7192
+ const standardProps = childProps.groupComponent ? {
7193
+ groupComponent,
7194
+ standalone: false
7195
+ } : {};
7196
+ const newProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(standardProps, childProps, _victory_util_helpers__WEBPACK_IMPORTED_MODULE_4__.omit(props, ["children", "groupComponent"]), {
7197
+ key: childProps.key ?? id
7198
+ });
7199
+ const child = children && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().cloneElement(children, newProps);
7200
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
7201
+ portalContext?.addChild(id, child);
7202
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7203
+ }, [props.children]);
7204
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
7205
+ return () => portalContext?.removeChild(id);
7206
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7207
+ }, []);
7208
+ return portalContext ? null : child;
7209
+ };
7210
+ VictoryPortal.role = "portal";
7222
7211
 
7223
7212
  /***/ }),
7224
7213
 
@@ -10739,6 +10728,44 @@ function warn(message) {
10739
10728
 
10740
10729
  /***/ }),
10741
10730
 
10731
+ /***/ "../../victory-core/es/victory-util/merge-refs.js":
10732
+ /*!********************************************************!*\
10733
+ !*** ../../victory-core/es/victory-util/merge-refs.js ***!
10734
+ \********************************************************/
10735
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
10736
+
10737
+ "use strict";
10738
+ __webpack_require__.r(__webpack_exports__);
10739
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10740
+ /* harmony export */ "mergeRefs": function() { return /* binding */ mergeRefs; }
10741
+ /* harmony export */ });
10742
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./helpers */ "../../victory-core/es/victory-util/helpers.js");
10743
+
10744
+ /**
10745
+ * Used to merge multiple React refs into a single callback ref.
10746
+ *
10747
+ * @example
10748
+ * ```tsx
10749
+ * <div ref={mergeRefs([ref, forwardedRef])} />
10750
+ * ```
10751
+ */
10752
+ function mergeRefs(refs) {
10753
+ return value => {
10754
+ refs.forEach(ref => {
10755
+ // If the ref is a function, it's a callback ref and we call it with the value.
10756
+ if (_helpers__WEBPACK_IMPORTED_MODULE_0__.isFunction(ref)) {
10757
+ ref(value);
10758
+ } else if (ref !== null && ref !== undefined) {
10759
+ // If the ref is an object (not null and not undefined), it's an object ref.
10760
+ // We assign the value to its 'current' property.
10761
+ ref.current = value;
10762
+ }
10763
+ });
10764
+ };
10765
+ }
10766
+
10767
+ /***/ }),
10768
+
10742
10769
  /***/ "../../victory-core/es/victory-util/scale.js":
10743
10770
  /*!***************************************************!*\
10744
10771
  !*** ../../victory-core/es/victory-util/scale.js ***!