victory-chart 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-chart
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
@@ -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_4__ = __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_5__ = __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("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_4__.mergeRefs)([localContainerRef, containerRef])
6460
+ }, /*#__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({
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,78 @@ 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
+ return context;
7022
+ };
7023
+ const PortalProvider = _ref => {
7024
+ let {
7025
+ children
7026
+ } = _ref;
7027
+ const [portalChildren, setPortalChildren] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(new Map());
7028
+ const addChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback((id, element) => {
7029
+ setPortalChildren(prevChildren => {
7030
+ const nextChildren = new Map(prevChildren);
7031
+ nextChildren.set(id, element);
7032
+ return nextChildren;
7033
+ });
7034
+ }, [setPortalChildren]);
7035
+ const removeChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback(id => {
7036
+ setPortalChildren(prevChildren => {
7037
+ const nextChildren = new Map(prevChildren);
7038
+ nextChildren.delete(id);
7039
+ return nextChildren;
7040
+ });
7041
+ }, [setPortalChildren]);
7042
+ const contextValue = react__WEBPACK_IMPORTED_MODULE_0___default().useMemo(() => ({
7043
+ addChild,
7044
+ removeChild,
7045
+ children: portalChildren
7046
+ }), [addChild, removeChild, portalChildren]);
7047
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(PortalContext.Provider, {
7048
+ value: contextValue
7049
+ }, children);
7050
+ };
7051
+
7052
+ /***/ }),
7053
+
7054
+ /***/ "../../victory-core/es/victory-portal/portal-outlet.js":
7055
+ /*!*************************************************************!*\
7056
+ !*** ../../victory-core/es/victory-portal/portal-outlet.js ***!
7057
+ \*************************************************************/
7058
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
7059
+
7060
+ "use strict";
7061
+ __webpack_require__.r(__webpack_exports__);
7062
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7063
+ /* harmony export */ "PortalOutlet": function() { return /* binding */ PortalOutlet; }
7064
+ /* harmony export */ });
7065
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
7066
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
7067
+ /* harmony import */ var _portal_context__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./portal-context */ "../../victory-core/es/victory-portal/portal-context.js");
7068
+
7069
+
7070
+ const PortalOutlet = _ref => {
7071
+ let {
7072
+ as: portalComponent,
7073
+ ...props
7074
+ } = _ref;
7075
+ const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_1__.usePortalContext)();
7076
+ if (!portalContext) {
7077
+ return null;
7078
+ }
7079
+ const children = Array.from(portalContext.children.values());
7080
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(portalComponent, props, children);
7081
+ };
7052
7082
 
7053
7083
  /***/ }),
7054
7084
 
@@ -7065,39 +7095,13 @@ __webpack_require__.r(__webpack_exports__);
7065
7095
  /* harmony export */ });
7066
7096
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
7067
7097
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
7098
+ 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
7099
 
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
- }
7100
+ const Portal = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().forwardRef((props, ref) => {
7101
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", _extends({
7102
+ ref: ref
7103
+ }, props));
7104
+ });
7101
7105
 
7102
7106
  /***/ }),
7103
7107
 
@@ -7124,59 +7128,44 @@ __webpack_require__.r(__webpack_exports__);
7124
7128
 
7125
7129
 
7126
7130
 
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;
7167
- const {
7168
- groupComponent
7169
- } = this.props;
7170
- const childProps = children && children.props || {};
7171
- const standardProps = childProps.groupComponent ? {
7172
- groupComponent,
7173
- standalone: false
7174
- } : {};
7175
- const newProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(standardProps, childProps, _victory_util_helpers__WEBPACK_IMPORTED_MODULE_4__.omit(this.props, ["children", "groupComponent"]));
7176
- const child = children && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().cloneElement(children, newProps);
7177
- return this.renderPortal(child);
7178
- }
7179
- }
7131
+ const defaultProps = {
7132
+ groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("g", null)
7133
+ };
7134
+ const VictoryPortal = initialProps => {
7135
+ const props = {
7136
+ ...defaultProps,
7137
+ ...initialProps
7138
+ };
7139
+ const id = react__WEBPACK_IMPORTED_MODULE_1___default().useId();
7140
+ const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_2__.usePortalContext)();
7141
+ if (!portalContext) {
7142
+ const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
7143
+ _victory_util_log__WEBPACK_IMPORTED_MODULE_3__.warn(msg);
7144
+ }
7145
+ const children = Array.isArray(props.children) ? props.children[0] : props.children;
7146
+ const {
7147
+ groupComponent
7148
+ } = props;
7149
+ const childProps = children && children.props || {};
7150
+ const standardProps = childProps.groupComponent ? {
7151
+ groupComponent,
7152
+ standalone: false
7153
+ } : {};
7154
+ const newProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(standardProps, childProps, _victory_util_helpers__WEBPACK_IMPORTED_MODULE_4__.omit(props, ["children", "groupComponent"]), {
7155
+ key: childProps.key ?? id
7156
+ });
7157
+ const child = children && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().cloneElement(children, newProps);
7158
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
7159
+ portalContext?.addChild(id, child);
7160
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7161
+ }, [props.children]);
7162
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
7163
+ return () => portalContext?.removeChild(id);
7164
+ // eslint-disable-next-line react-hooks/exhaustive-deps
7165
+ }, []);
7166
+ return portalContext ? null : child;
7167
+ };
7168
+ VictoryPortal.role = "portal";
7180
7169
 
7181
7170
  /***/ }),
7182
7171
 
@@ -11377,6 +11366,44 @@ function warn(message) {
11377
11366
 
11378
11367
  /***/ }),
11379
11368
 
11369
+ /***/ "../../victory-core/es/victory-util/merge-refs.js":
11370
+ /*!********************************************************!*\
11371
+ !*** ../../victory-core/es/victory-util/merge-refs.js ***!
11372
+ \********************************************************/
11373
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
11374
+
11375
+ "use strict";
11376
+ __webpack_require__.r(__webpack_exports__);
11377
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11378
+ /* harmony export */ "mergeRefs": function() { return /* binding */ mergeRefs; }
11379
+ /* harmony export */ });
11380
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./helpers */ "../../victory-core/es/victory-util/helpers.js");
11381
+
11382
+ /**
11383
+ * Used to merge multiple React refs into a single callback ref.
11384
+ *
11385
+ * @example
11386
+ * ```tsx
11387
+ * <div ref={mergeRefs([ref, forwardedRef])} />
11388
+ * ```
11389
+ */
11390
+ function mergeRefs(refs) {
11391
+ return value => {
11392
+ refs.forEach(ref => {
11393
+ // If the ref is a function, it's a callback ref and we call it with the value.
11394
+ if (_helpers__WEBPACK_IMPORTED_MODULE_0__.isFunction(ref)) {
11395
+ ref(value);
11396
+ } else if (ref !== null && ref !== undefined) {
11397
+ // If the ref is an object (not null and not undefined), it's an object ref.
11398
+ // We assign the value to its 'current' property.
11399
+ ref.current = value;
11400
+ }
11401
+ });
11402
+ };
11403
+ }
11404
+
11405
+ /***/ }),
11406
+
11380
11407
  /***/ "../../victory-core/es/victory-util/scale.js":
11381
11408
  /*!***************************************************!*\
11382
11409
  !*** ../../victory-core/es/victory-util/scale.js ***!