victory-cursor-container 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.
@@ -139,8 +139,9 @@ const CursorHelpers = new CursorHelpersClass();
139
139
  "use strict";
140
140
  __webpack_require__.r(__webpack_exports__);
141
141
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
142
+ /* harmony export */ "VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS": function() { return /* binding */ VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS; },
142
143
  /* harmony export */ "VictoryCursorContainer": function() { return /* binding */ VictoryCursorContainer; },
143
- /* harmony export */ "cursorContainerMixin": function() { return /* binding */ cursorContainerMixin; }
144
+ /* harmony export */ "useVictoryCursorContainer": function() { return /* binding */ useVictoryCursorContainer; }
144
145
  /* harmony export */ });
145
146
  /* 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");
146
147
  /* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_isObject__WEBPACK_IMPORTED_MODULE_0__);
@@ -148,164 +149,179 @@ __webpack_require__.r(__webpack_exports__);
148
149
  /* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_defaults__WEBPACK_IMPORTED_MODULE_1__);
149
150
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! react */ "react");
150
151
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_2__);
151
- /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-container/victory-container.js");
152
- /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-label/victory-label.js");
153
- /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-primitives/line-segment.js");
154
- /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/helpers.js");
152
+ /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-label/victory-label.js");
153
+ /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-primitives/line-segment.js");
154
+ /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-util/helpers.js");
155
+ /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-container/victory-container.js");
155
156
  /* harmony import */ var _cursor_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./cursor-helpers */ "./cursor-helpers.tsx");
156
157
 
157
158
 
159
+ /* eslint-disable complexity */
158
160
 
159
161
 
160
162
 
161
- function cursorContainerMixin(Base) {
162
- // @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'."
163
- return class VictoryCursorContainer extends Base {
164
- static displayName = "VictoryCursorContainer";
165
- static defaultProps = {
166
- ...victory_core__WEBPACK_IMPORTED_MODULE_3__.VictoryContainer.defaultProps,
167
- cursorLabelComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_4__.VictoryLabel, null),
168
- cursorLabelOffset: {
169
- x: 5,
170
- y: -10
171
- },
172
- cursorComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_5__.LineSegment, null)
173
- };
174
- static defaultEvents(props) {
175
- return [{
176
- target: "parent",
177
- eventHandlers: {
178
- onMouseLeave: (evt, targetProps) => {
179
- return props.disable ? {} : _cursor_helpers__WEBPACK_IMPORTED_MODULE_6__.CursorHelpers.onMouseLeave(evt, targetProps);
180
- },
181
- onTouchCancel: () => {
182
- return [];
183
- },
184
- onMouseMove: (evt, targetProps) => {
185
- return props.disable ? {} : _cursor_helpers__WEBPACK_IMPORTED_MODULE_6__.CursorHelpers.onMouseMove(evt, targetProps);
186
- },
187
- onTouchMove: (evt, targetProps) => {
188
- return props.disable ? {} : _cursor_helpers__WEBPACK_IMPORTED_MODULE_6__.CursorHelpers.onMouseMove(evt, targetProps);
189
- }
190
- }
191
- }];
163
+ const VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS = {
164
+ cursorLabelComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_3__.VictoryLabel, null),
165
+ cursorLabelOffset: {
166
+ x: 5,
167
+ y: -10
168
+ },
169
+ cursorComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_4__.LineSegment, null)
170
+ };
171
+ const useVictoryCursorContainer = initialProps => {
172
+ const props = {
173
+ ...VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS,
174
+ ...initialProps
175
+ };
176
+ const {
177
+ children
178
+ } = props;
179
+ const getCursorPosition = () => {
180
+ const {
181
+ cursorValue,
182
+ defaultCursorValue,
183
+ domain,
184
+ cursorDimension
185
+ } = props;
186
+ if (cursorValue) {
187
+ return cursorValue;
192
188
  }
193
- getCursorPosition(props) {
194
- const {
195
- cursorValue,
196
- defaultCursorValue,
197
- domain,
198
- cursorDimension
199
- } = props;
200
- if (cursorValue) {
201
- return cursorValue;
202
- }
203
- if (typeof defaultCursorValue === "number") {
204
- return {
205
- x: (domain.x[0] + domain.x[1]) / 2,
206
- y: (domain.y[0] + domain.y[1]) / 2,
189
+ if (typeof defaultCursorValue === "number") {
190
+ return {
191
+ x: (domain.x[0] + domain.x[1]) / 2,
192
+ y: (domain.y[0] + domain.y[1]) / 2,
193
+ ...(cursorDimension ? {
207
194
  [cursorDimension]: defaultCursorValue
208
- };
209
- }
210
- return defaultCursorValue;
195
+ } : {})
196
+ };
211
197
  }
212
- getCursorLabelOffset(props) {
213
- const {
214
- cursorLabelOffset
215
- } = props;
216
- if (typeof cursorLabelOffset === "number") {
217
- return {
218
- x: cursorLabelOffset,
219
- y: cursorLabelOffset
220
- };
221
- }
222
- return cursorLabelOffset;
198
+ return defaultCursorValue;
199
+ };
200
+ const getCursorLabelOffset = () => {
201
+ const {
202
+ cursorLabelOffset
203
+ } = props;
204
+ if (typeof cursorLabelOffset === "number") {
205
+ return {
206
+ x: cursorLabelOffset,
207
+ y: cursorLabelOffset
208
+ };
223
209
  }
224
- getPadding(props) {
225
- if (props.padding === undefined) {
226
- const child = props.children.find(c => {
227
- return lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default()(c.props) && c.props.padding !== undefined;
228
- });
229
- return victory_core__WEBPACK_IMPORTED_MODULE_7__.getPadding(child.props);
230
- }
231
- return victory_core__WEBPACK_IMPORTED_MODULE_7__.getPadding(props);
210
+ return cursorLabelOffset;
211
+ };
212
+ const getPadding = () => {
213
+ if (props.padding === undefined) {
214
+ const child = Array.isArray(props.children) ? props.children.find(c => {
215
+ return lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default()(c.props) && c.props.padding !== undefined;
216
+ }) : props.children;
217
+ return victory_core__WEBPACK_IMPORTED_MODULE_5__.getPadding(child?.props);
232
218
  }
233
- getCursorElements(props) {
234
- // eslint-disable-line max-statements
235
- const {
236
- scale,
237
- cursorLabelComponent,
238
- cursorLabel,
239
- cursorComponent,
240
- width,
241
- height,
242
- name,
243
- horizontal,
244
- theme
245
- } = props;
246
- const cursorDimension = _cursor_helpers__WEBPACK_IMPORTED_MODULE_6__.CursorHelpers.getDimension(props);
247
- const cursorValue = this.getCursorPosition(props);
248
- const cursorLabelOffset = this.getCursorLabelOffset(props);
249
- if (!cursorValue) {
250
- return [];
251
- }
252
- const newElements = [];
253
- const padding = this.getPadding(props);
254
- const cursorCoordinates = {
255
- x: horizontal ? scale.y(cursorValue.y) : scale.x(cursorValue.x),
256
- y: horizontal ? scale.x(cursorValue.x) : scale.y(cursorValue.y)
257
- };
258
- if (cursorLabel) {
259
- let labelProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({
260
- active: true
261
- }, cursorLabelComponent.props, {
262
- x: cursorCoordinates.x + cursorLabelOffset.x,
263
- y: cursorCoordinates.y + cursorLabelOffset.y,
264
- datum: cursorValue,
265
- active: true,
266
- key: `${name}-cursor-label`
267
- });
268
- if (victory_core__WEBPACK_IMPORTED_MODULE_7__.isTooltip(cursorLabelComponent)) {
269
- const tooltipTheme = theme && theme.tooltip || {};
270
- labelProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({}, labelProps, tooltipTheme);
271
- }
272
- newElements.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().cloneElement(cursorLabelComponent, lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({}, labelProps, {
273
- text: victory_core__WEBPACK_IMPORTED_MODULE_7__.evaluateProp(cursorLabel, labelProps)
274
- })));
275
- }
276
- const cursorStyle = Object.assign({
277
- stroke: "black"
278
- }, cursorComponent.props.style);
279
- if (cursorDimension === "x" || cursorDimension === undefined) {
280
- newElements.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().cloneElement(cursorComponent, {
281
- key: `${name}-x-cursor`,
282
- x1: cursorCoordinates.x,
283
- x2: cursorCoordinates.x,
284
- y1: padding.top,
285
- y2: height - padding.bottom,
286
- style: cursorStyle
287
- }));
288
- }
289
- if (cursorDimension === "y" || cursorDimension === undefined) {
290
- newElements.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().cloneElement(cursorComponent, {
291
- key: `${name}-y-cursor`,
292
- x1: padding.left,
293
- x2: width - padding.right,
294
- y1: cursorCoordinates.y,
295
- y2: cursorCoordinates.y,
296
- style: cursorStyle
297
- }));
219
+ return victory_core__WEBPACK_IMPORTED_MODULE_5__.getPadding(props);
220
+ };
221
+ const getCursorElements = () => {
222
+ // eslint-disable-line max-statements
223
+ const {
224
+ scale,
225
+ cursorLabelComponent,
226
+ cursorLabel,
227
+ cursorComponent,
228
+ width,
229
+ height,
230
+ name,
231
+ horizontal,
232
+ theme
233
+ } = props;
234
+ const cursorDimension = _cursor_helpers__WEBPACK_IMPORTED_MODULE_6__.CursorHelpers.getDimension(props);
235
+ const cursorValue = getCursorPosition();
236
+ const cursorLabelOffset = getCursorLabelOffset();
237
+ if (!cursorValue) {
238
+ return [];
239
+ }
240
+ const newElements = [];
241
+ const padding = getPadding();
242
+ const cursorCoordinates = scale && "x" in scale && "y" in scale && typeof scale.y === "function" && typeof scale.x === "function" ? {
243
+ x: horizontal ? scale.y(cursorValue.y) : scale.x(cursorValue.x),
244
+ y: horizontal ? scale.x(cursorValue.x) : scale.y(cursorValue.y)
245
+ } : {
246
+ x: cursorValue.x,
247
+ y: cursorValue.y
248
+ };
249
+ if (cursorLabel) {
250
+ let labelProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({
251
+ active: true
252
+ }, cursorLabelComponent.props, {
253
+ x: cursorCoordinates.x + cursorLabelOffset.x,
254
+ y: cursorCoordinates.y + cursorLabelOffset.y,
255
+ datum: cursorValue,
256
+ active: true,
257
+ key: `${name}-cursor-label`
258
+ });
259
+ if (victory_core__WEBPACK_IMPORTED_MODULE_5__.isTooltip(cursorLabelComponent)) {
260
+ const tooltipTheme = theme && theme.tooltip || {};
261
+ labelProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({}, labelProps, tooltipTheme);
298
262
  }
299
- return newElements;
263
+ newElements.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().cloneElement(cursorLabelComponent, lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({}, labelProps, {
264
+ text: victory_core__WEBPACK_IMPORTED_MODULE_5__.evaluateProp(cursorLabel, labelProps)
265
+ })));
300
266
  }
301
-
302
- // Overrides method in VictoryContainer
303
- getChildren(props) {
304
- return [...react__WEBPACK_IMPORTED_MODULE_2___default().Children.toArray(props.children), ...this.getCursorElements(props)];
267
+ const cursorStyle = Object.assign({
268
+ stroke: "black"
269
+ }, cursorComponent.props.style);
270
+ if (cursorDimension === "x" || cursorDimension === undefined) {
271
+ newElements.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().cloneElement(cursorComponent, {
272
+ key: `${name}-x-cursor`,
273
+ x1: cursorCoordinates.x,
274
+ x2: cursorCoordinates.x,
275
+ y1: padding.top,
276
+ y2: (typeof height === "number" ? height : 0) - padding.bottom,
277
+ style: cursorStyle
278
+ }));
305
279
  }
280
+ if (cursorDimension === "y" || cursorDimension === undefined) {
281
+ newElements.push( /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().cloneElement(cursorComponent, {
282
+ key: `${name}-y-cursor`,
283
+ x1: padding.left,
284
+ x2: (typeof width === "number" ? width : 0) - padding.right,
285
+ y1: cursorCoordinates.y,
286
+ y2: cursorCoordinates.y,
287
+ style: cursorStyle
288
+ }));
289
+ }
290
+ return newElements;
306
291
  };
307
- }
308
- const VictoryCursorContainer = cursorContainerMixin(victory_core__WEBPACK_IMPORTED_MODULE_3__.VictoryContainer);
292
+ return {
293
+ props,
294
+ children: [...react__WEBPACK_IMPORTED_MODULE_2___default().Children.toArray(children), ...getCursorElements()]
295
+ };
296
+ };
297
+ const VictoryCursorContainer = initialProps => {
298
+ const {
299
+ props,
300
+ children
301
+ } = useVictoryCursorContainer(initialProps);
302
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_2___default().createElement(victory_core__WEBPACK_IMPORTED_MODULE_7__.VictoryContainer, props, children);
303
+ };
304
+ VictoryCursorContainer.role = "container";
305
+ VictoryCursorContainer.defaultEvents = initialProps => {
306
+ const props = {
307
+ ...VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS,
308
+ ...initialProps
309
+ };
310
+ const createEventHandler = (handler, disabled) =>
311
+ // eslint-disable-next-line max-params
312
+ (event, targetProps, eventKey, context) => disabled || props.disable ? {} : handler(event, {
313
+ ...props,
314
+ ...targetProps
315
+ }, eventKey, context);
316
+ return [{
317
+ target: "parent",
318
+ eventHandlers: {
319
+ onMouseLeave: createEventHandler(_cursor_helpers__WEBPACK_IMPORTED_MODULE_6__.CursorHelpers.onMouseLeave),
320
+ onMouseMove: createEventHandler(_cursor_helpers__WEBPACK_IMPORTED_MODULE_6__.CursorHelpers.onMouseMove),
321
+ onTouchMove: createEventHandler(_cursor_helpers__WEBPACK_IMPORTED_MODULE_6__.CursorHelpers.onMouseMove)
322
+ }
323
+ }];
324
+ };
309
325
 
310
326
  /***/ }),
311
327
 
@@ -2963,23 +2979,18 @@ module.exports = uniqueId;
2963
2979
  "use strict";
2964
2980
  __webpack_require__.r(__webpack_exports__);
2965
2981
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2966
- /* harmony export */ "VictoryContainer": function() { return /* binding */ VictoryContainer; }
2982
+ /* harmony export */ "VictoryContainer": function() { return /* binding */ VictoryContainer; },
2983
+ /* harmony export */ "useVictoryContainer": function() { return /* binding */ useVictoryContainer; }
2967
2984
  /* harmony export */ });
2968
- /* 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");
2969
- /* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_isObject__WEBPACK_IMPORTED_MODULE_0__);
2970
- /* 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");
2971
- /* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1__);
2972
- /* 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");
2973
- /* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_defaults__WEBPACK_IMPORTED_MODULE_2__);
2974
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react */ "react");
2975
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_3__);
2976
- /* harmony import */ var _victory_portal_portal__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../victory-portal/portal */ "../../victory-core/es/victory-portal/portal.js");
2977
- /* 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");
2978
- /* 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");
2979
- /* harmony import */ var _victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../victory-util/helpers */ "../../victory-core/es/victory-util/helpers.js");
2980
- /* 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");
2981
-
2982
-
2985
+ /* 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");
2986
+ /* harmony import */ var lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0__);
2987
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ "react");
2988
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
2989
+ /* harmony import */ var _victory_portal_portal__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../victory-portal/portal */ "../../victory-core/es/victory-portal/portal.js");
2990
+ /* 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");
2991
+ /* harmony import */ var _victory_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../victory-util */ "../../victory-core/es/victory-util/merge-refs.js");
2992
+ /* 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");
2993
+ /* 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");
2983
2994
 
2984
2995
  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); }
2985
2996
 
@@ -2988,175 +2999,149 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
2988
2999
 
2989
3000
 
2990
3001
 
2991
- class VictoryContainer extends (react__WEBPACK_IMPORTED_MODULE_3___default().Component) {
2992
- static displayName = "VictoryContainer";
2993
- static role = "container";
2994
- static defaultProps = {
2995
- className: "VictoryContainer",
2996
- portalComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement(_victory_portal_portal__WEBPACK_IMPORTED_MODULE_4__.Portal, null),
2997
- portalZIndex: 99,
2998
- responsive: true,
2999
- role: "img"
3002
+ const defaultProps = {
3003
+ className: "VictoryContainer",
3004
+ portalComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal__WEBPACK_IMPORTED_MODULE_2__.Portal, null),
3005
+ portalZIndex: 99,
3006
+ responsive: true,
3007
+ role: "img"
3008
+ };
3009
+ function useVictoryContainer(initialProps) {
3010
+ const props = {
3011
+ ...defaultProps,
3012
+ ...initialProps
3000
3013
  };
3001
- static contextType = _victory_util_timer_context__WEBPACK_IMPORTED_MODULE_5__["default"];
3002
-
3003
- // @ts-expect-error Ref will be initialized on mount
3004
-
3005
- // @ts-expect-error Ref will be initialized on mount
3006
-
3007
- constructor(props) {
3008
- super(props);
3009
- this.containerId = !lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default()(props) || props.containerId === undefined ? lodash_uniqueId__WEBPACK_IMPORTED_MODULE_1___default()("victory-container-") : props.containerId;
3010
- this.shouldHandleWheel = !!(props && props.events && props.events.onWheel);
3011
- }
3012
- savePortalRef = portal => {
3013
- this.portalRef = portal;
3014
- return portal;
3014
+ const {
3015
+ title,
3016
+ desc,
3017
+ width,
3018
+ height,
3019
+ responsive
3020
+ } = props;
3021
+ const localContainerRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
3022
+
3023
+ // Generated ID stored in ref because it needs to persist across renders
3024
+ const generatedId = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(lodash_uniqueId__WEBPACK_IMPORTED_MODULE_0___default()("victory-container-"));
3025
+ const containerId = props.containerId ?? generatedId.current;
3026
+ const getIdForElement = elName => `${containerId}-${elName}`;
3027
+ const userProps = _victory_util_user_props__WEBPACK_IMPORTED_MODULE_3__.getSafeUserProps(props);
3028
+ const dimensions = responsive ? {
3029
+ width: "100%",
3030
+ height: "100%"
3031
+ } : {
3032
+ width,
3033
+ height
3015
3034
  };
3016
- portalUpdate = (key, el) => this.portalRef.portalUpdate(key, el);
3017
- portalRegister = () => this.portalRef.portalRegister();
3018
- portalDeregister = key => this.portalRef.portalDeregister(key);
3019
- saveContainerRef = container => {
3020
- if (_victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__.isFunction(this.props.containerRef)) {
3021
- this.props.containerRef(container);
3022
- }
3023
- this.containerRef = container;
3024
- return container;
3035
+ const viewBox = responsive ? `0 0 ${width} ${height}` : undefined;
3036
+ const preserveAspectRatio = responsive ? props.preserveAspectRatio : undefined;
3037
+ const ariaLabelledBy = [title && getIdForElement("title"), props["aria-labelledby"]].filter(Boolean).join(" ") || undefined;
3038
+ const ariaDescribedBy = [desc && getIdForElement("desc"), props["aria-describedby"]].filter(Boolean).join(" ") || undefined;
3039
+ const titleId = getIdForElement("title");
3040
+ const descId = getIdForElement("desc");
3041
+ return {
3042
+ ...props,
3043
+ titleId,
3044
+ descId,
3045
+ dimensions,
3046
+ viewBox,
3047
+ preserveAspectRatio,
3048
+ ariaLabelledBy,
3049
+ ariaDescribedBy,
3050
+ userProps,
3051
+ localContainerRef
3025
3052
  };
3026
- handleWheel = e => e.preventDefault();
3027
- componentDidMount() {
3028
- if (this.shouldHandleWheel && this.containerRef) {
3029
- this.containerRef.addEventListener("wheel", this.handleWheel);
3030
- }
3031
- }
3032
- componentWillUnmount() {
3033
- if (this.shouldHandleWheel && this.containerRef) {
3034
- this.containerRef.removeEventListener("wheel", this.handleWheel);
3035
- }
3036
- }
3037
- getIdForElement(elementName) {
3038
- return `${this.containerId}-${elementName}`;
3039
- }
3040
-
3041
- // overridden in custom containers
3042
- getChildren(props) {
3043
- return props.children;
3044
- }
3045
-
3046
- // Get props defined by the Open UI Automation (OUIA) 1.0-RC spec
3047
- // See https://ouia.readthedocs.io/en/latest/README.html#ouia-component
3048
- getOUIAProps(props) {
3049
- const {
3050
- ouiaId,
3051
- ouiaSafe,
3052
- ouiaType
3053
- } = props;
3054
- return {
3055
- ...(ouiaId && {
3056
- "data-ouia-component-id": ouiaId
3057
- }),
3058
- ...(ouiaType && {
3059
- "data-ouia-component-type": ouiaType
3060
- }),
3061
- ...(ouiaSafe !== undefined && {
3062
- "data-ouia-safe": ouiaSafe
3063
- })
3064
- };
3065
- }
3066
- renderContainer(props, svgProps, style) {
3067
- const {
3068
- title,
3069
- desc,
3070
- portalComponent,
3071
- className,
3072
- width,
3073
- height,
3074
- portalZIndex,
3075
- responsive
3076
- } = props;
3077
- const children = this.getChildren(props);
3078
- const dimensions = responsive ? {
3079
- width: "100%",
3080
- height: "100%"
3081
- } : {
3082
- width,
3083
- height
3053
+ }
3054
+ const VictoryContainer = initialProps => {
3055
+ const {
3056
+ role,
3057
+ title,
3058
+ desc,
3059
+ children,
3060
+ className,
3061
+ portalZIndex,
3062
+ portalComponent,
3063
+ width,
3064
+ height,
3065
+ style,
3066
+ tabIndex,
3067
+ responsive,
3068
+ events,
3069
+ ouiaId,
3070
+ ouiaSafe,
3071
+ ouiaType,
3072
+ dimensions,
3073
+ ariaDescribedBy,
3074
+ ariaLabelledBy,
3075
+ viewBox,
3076
+ preserveAspectRatio,
3077
+ userProps,
3078
+ titleId,
3079
+ descId,
3080
+ containerRef,
3081
+ localContainerRef
3082
+ } = useVictoryContainer(initialProps);
3083
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
3084
+ if (!events?.onWheel) return;
3085
+ const handleWheel = e => e.preventDefault();
3086
+ const container = localContainerRef?.current;
3087
+ container?.addEventListener("wheel", handleWheel);
3088
+ return () => {
3089
+ container?.removeEventListener("wheel", handleWheel);
3084
3090
  };
3085
- const divStyle = Object.assign({
3091
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3092
+ }, []);
3093
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", {
3094
+ className: className,
3095
+ style: {
3096
+ ...style,
3097
+ width: responsive ? style?.width : dimensions.width,
3098
+ height: responsive ? style?.height : dimensions.height,
3086
3099
  pointerEvents: "none",
3087
3100
  touchAction: "none",
3088
3101
  position: "relative"
3089
- }, dimensions);
3090
- const portalDivStyle = Object.assign({
3102
+ },
3103
+ "data-ouia-component-id": ouiaId,
3104
+ "data-ouia-component-type": ouiaType,
3105
+ "data-ouia-safe": ouiaSafe,
3106
+ ref: (0,_victory_util__WEBPACK_IMPORTED_MODULE_4__.mergeRefs)([localContainerRef, containerRef])
3107
+ }, /*#__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({
3108
+ width: width,
3109
+ height: height,
3110
+ tabIndex: tabIndex,
3111
+ role: role,
3112
+ "aria-labelledby": ariaLabelledBy,
3113
+ "aria-describedby": ariaDescribedBy,
3114
+ viewBox: viewBox,
3115
+ preserveAspectRatio: preserveAspectRatio,
3116
+ style: {
3117
+ ...dimensions,
3118
+ pointerEvents: "all"
3119
+ }
3120
+ }, userProps, events), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("title", {
3121
+ id: titleId
3122
+ }, title) : null, desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("desc", {
3123
+ id: descId
3124
+ }, desc) : null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("div", {
3125
+ style: {
3126
+ ...dimensions,
3091
3127
  zIndex: portalZIndex,
3092
3128
  position: "absolute",
3093
3129
  top: 0,
3094
3130
  left: 0
3095
- }, dimensions);
3096
- const svgStyle = Object.assign({
3097
- pointerEvents: "all"
3098
- }, dimensions);
3099
- const portalSvgStyle = Object.assign({
3131
+ }
3132
+ }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_victory_portal_portal_outlet__WEBPACK_IMPORTED_MODULE_6__.PortalOutlet, {
3133
+ as: portalComponent,
3134
+ width: width,
3135
+ height: height,
3136
+ viewBox: viewBox,
3137
+ preserveAspectRatio: preserveAspectRatio,
3138
+ style: {
3139
+ ...dimensions,
3100
3140
  overflow: "visible"
3101
- }, dimensions);
3102
- const portalProps = {
3103
- width,
3104
- height,
3105
- viewBox: svgProps.viewBox,
3106
- preserveAspectRatio: svgProps.preserveAspectRatio,
3107
- style: portalSvgStyle
3108
- };
3109
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement(_victory_portal_portal_context__WEBPACK_IMPORTED_MODULE_7__.PortalContext.Provider, {
3110
- value: {
3111
- portalUpdate: this.portalUpdate,
3112
- portalRegister: this.portalRegister,
3113
- portalDeregister: this.portalDeregister
3114
- }
3115
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("div", _extends({
3116
- style: lodash_defaults__WEBPACK_IMPORTED_MODULE_2___default()({}, style, divStyle),
3117
- className: className,
3118
- ref: this.saveContainerRef
3119
- }, this.getOUIAProps(props)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("svg", _extends({}, svgProps, {
3120
- style: svgStyle
3121
- }), title ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("title", {
3122
- id: this.getIdForElement("title")
3123
- }, title) : null, desc ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("desc", {
3124
- id: this.getIdForElement("desc")
3125
- }, desc) : null, children), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().createElement("div", {
3126
- style: portalDivStyle
3127
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default().cloneElement(portalComponent, {
3128
- ...portalProps,
3129
- ref: this.savePortalRef
3130
- }))));
3131
- }
3132
- render() {
3133
- const {
3134
- width,
3135
- height,
3136
- responsive,
3137
- events,
3138
- title,
3139
- desc,
3140
- tabIndex,
3141
- preserveAspectRatio,
3142
- role
3143
- } = this.props;
3144
- const style = responsive ? this.props.style : _victory_util_helpers__WEBPACK_IMPORTED_MODULE_6__.omit(this.props.style, ["height", "width"]);
3145
- const userProps = _victory_util_user_props__WEBPACK_IMPORTED_MODULE_8__.getSafeUserProps(this.props);
3146
- const svgProps = Object.assign({
3147
- width,
3148
- height,
3149
- tabIndex,
3150
- role,
3151
- "aria-labelledby": [title && this.getIdForElement("title"), this.props["aria-labelledby"]].filter(Boolean).join(" ") || undefined,
3152
- "aria-describedby": [desc && this.getIdForElement("desc"), this.props["aria-describedby"]].filter(Boolean).join(" ") || undefined,
3153
- viewBox: responsive ? `0 0 ${width} ${height}` : undefined,
3154
- preserveAspectRatio: responsive ? preserveAspectRatio : undefined,
3155
- ...userProps
3156
- }, events);
3157
- return this.renderContainer(this.props, svgProps, style);
3158
- }
3159
- }
3141
+ }
3142
+ }))));
3143
+ };
3144
+ VictoryContainer.role = "container";
3160
3145
 
3161
3146
  /***/ }),
3162
3147
 
@@ -3669,17 +3654,78 @@ VictoryLabel.defaultStyles = defaultStyles;
3669
3654
  "use strict";
3670
3655
  __webpack_require__.r(__webpack_exports__);
3671
3656
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3672
- /* harmony export */ "PortalContext": function() { return /* binding */ PortalContext; }
3657
+ /* harmony export */ "PortalContext": function() { return /* binding */ PortalContext; },
3658
+ /* harmony export */ "PortalProvider": function() { return /* binding */ PortalProvider; },
3659
+ /* harmony export */ "usePortalContext": function() { return /* binding */ usePortalContext; }
3673
3660
  /* harmony export */ });
3674
3661
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
3675
3662
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
3676
3663
 
3677
- /**
3678
- * The React context object consumers may use to access the context of the
3679
- * portal.
3680
- */
3681
- const PortalContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext({});
3664
+ const PortalContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext(undefined);
3682
3665
  PortalContext.displayName = "PortalContext";
3666
+ const usePortalContext = () => {
3667
+ const context = react__WEBPACK_IMPORTED_MODULE_0___default().useContext(PortalContext);
3668
+ return context;
3669
+ };
3670
+ const PortalProvider = _ref => {
3671
+ let {
3672
+ children
3673
+ } = _ref;
3674
+ const [portalChildren, setPortalChildren] = react__WEBPACK_IMPORTED_MODULE_0___default().useState(new Map());
3675
+ const addChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback((id, element) => {
3676
+ setPortalChildren(prevChildren => {
3677
+ const nextChildren = new Map(prevChildren);
3678
+ nextChildren.set(id, element);
3679
+ return nextChildren;
3680
+ });
3681
+ }, [setPortalChildren]);
3682
+ const removeChild = react__WEBPACK_IMPORTED_MODULE_0___default().useCallback(id => {
3683
+ setPortalChildren(prevChildren => {
3684
+ const nextChildren = new Map(prevChildren);
3685
+ nextChildren.delete(id);
3686
+ return nextChildren;
3687
+ });
3688
+ }, [setPortalChildren]);
3689
+ const contextValue = react__WEBPACK_IMPORTED_MODULE_0___default().useMemo(() => ({
3690
+ addChild,
3691
+ removeChild,
3692
+ children: portalChildren
3693
+ }), [addChild, removeChild, portalChildren]);
3694
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(PortalContext.Provider, {
3695
+ value: contextValue
3696
+ }, children);
3697
+ };
3698
+
3699
+ /***/ }),
3700
+
3701
+ /***/ "../../victory-core/es/victory-portal/portal-outlet.js":
3702
+ /*!*************************************************************!*\
3703
+ !*** ../../victory-core/es/victory-portal/portal-outlet.js ***!
3704
+ \*************************************************************/
3705
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
3706
+
3707
+ "use strict";
3708
+ __webpack_require__.r(__webpack_exports__);
3709
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3710
+ /* harmony export */ "PortalOutlet": function() { return /* binding */ PortalOutlet; }
3711
+ /* harmony export */ });
3712
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
3713
+ /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
3714
+ /* harmony import */ var _portal_context__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./portal-context */ "../../victory-core/es/victory-portal/portal-context.js");
3715
+
3716
+
3717
+ const PortalOutlet = _ref => {
3718
+ let {
3719
+ as: portalComponent,
3720
+ ...props
3721
+ } = _ref;
3722
+ const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_1__.usePortalContext)();
3723
+ if (!portalContext) {
3724
+ return null;
3725
+ }
3726
+ const children = Array.from(portalContext.children.values());
3727
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(portalComponent, props, children);
3728
+ };
3683
3729
 
3684
3730
  /***/ }),
3685
3731
 
@@ -3696,39 +3742,13 @@ __webpack_require__.r(__webpack_exports__);
3696
3742
  /* harmony export */ });
3697
3743
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
3698
3744
  /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
3745
+ 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); }
3699
3746
 
3700
- class Portal extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
3701
- static displayName = "Portal";
3702
- constructor(props) {
3703
- super(props);
3704
- this.map = {};
3705
- this.index = 1;
3706
- }
3707
- portalRegister = () => {
3708
- return ++this.index;
3709
- };
3710
- portalUpdate = (key, element) => {
3711
- this.map[key] = element;
3712
- this.forceUpdate();
3713
- };
3714
- portalDeregister = key => {
3715
- delete this.map[key];
3716
- this.forceUpdate();
3717
- };
3718
- getChildren() {
3719
- return Object.keys(this.map).map(key => {
3720
- const el = this.map[key];
3721
- return el ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().cloneElement(el, {
3722
- key
3723
- }) : el;
3724
- });
3725
- }
3726
-
3727
- // Overridden in victory-core-native
3728
- render() {
3729
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", this.props, this.getChildren());
3730
- }
3731
- }
3747
+ const Portal = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().forwardRef((props, ref) => {
3748
+ return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("svg", _extends({
3749
+ ref: ref
3750
+ }, props));
3751
+ });
3732
3752
 
3733
3753
  /***/ }),
3734
3754
 
@@ -3755,59 +3775,44 @@ __webpack_require__.r(__webpack_exports__);
3755
3775
 
3756
3776
 
3757
3777
 
3758
- class VictoryPortal extends (react__WEBPACK_IMPORTED_MODULE_1___default().Component) {
3759
- static displayName = "VictoryPortal";
3760
- static role = "portal";
3761
- static defaultProps = {
3762
- groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("g", null)
3778
+ const defaultProps = {
3779
+ groupComponent: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement("g", null)
3780
+ };
3781
+ const VictoryPortal = initialProps => {
3782
+ const props = {
3783
+ ...defaultProps,
3784
+ ...initialProps
3763
3785
  };
3764
- static contextType = _portal_context__WEBPACK_IMPORTED_MODULE_2__.PortalContext;
3765
- componentDidMount() {
3766
- if (!this.checkedContext) {
3767
- if (typeof this.context.portalUpdate !== "function") {
3768
- const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
3769
- _victory_util_log__WEBPACK_IMPORTED_MODULE_3__.warn(msg);
3770
- this.renderInPlace = true;
3771
- }
3772
- this.checkedContext = true;
3773
- }
3774
- this.forceUpdate();
3775
- }
3776
- componentDidUpdate() {
3777
- if (!this.renderInPlace) {
3778
- this.portalKey = this.portalKey || this.context.portalRegister();
3779
- this.context.portalUpdate(this.portalKey, this.element);
3780
- }
3781
- }
3782
- componentWillUnmount() {
3783
- if (this.context && this.context.portalDeregister) {
3784
- this.context.portalDeregister(this.portalKey);
3785
- }
3786
+ const id = react__WEBPACK_IMPORTED_MODULE_1___default().useId();
3787
+ const portalContext = (0,_portal_context__WEBPACK_IMPORTED_MODULE_2__.usePortalContext)();
3788
+ if (!portalContext) {
3789
+ const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
3790
+ _victory_util_log__WEBPACK_IMPORTED_MODULE_3__.warn(msg);
3786
3791
  }
3787
-
3788
- // Overridden in victory-core-native
3789
- renderPortal(child) {
3790
- if (this.renderInPlace) {
3791
- return child;
3792
- }
3793
- this.element = child;
3794
- return null;
3795
- }
3796
- render() {
3797
- const children = Array.isArray(this.props.children) ? this.props.children[0] : this.props.children;
3798
- const {
3799
- groupComponent
3800
- } = this.props;
3801
- const childProps = children && children.props || {};
3802
- const standardProps = childProps.groupComponent ? {
3803
- groupComponent,
3804
- standalone: false
3805
- } : {};
3806
- const newProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(standardProps, childProps, _victory_util_helpers__WEBPACK_IMPORTED_MODULE_4__.omit(this.props, ["children", "groupComponent"]));
3807
- const child = children && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().cloneElement(children, newProps);
3808
- return this.renderPortal(child);
3809
- }
3810
- }
3792
+ const children = Array.isArray(props.children) ? props.children[0] : props.children;
3793
+ const {
3794
+ groupComponent
3795
+ } = props;
3796
+ const childProps = children && children.props || {};
3797
+ const standardProps = childProps.groupComponent ? {
3798
+ groupComponent,
3799
+ standalone: false
3800
+ } : {};
3801
+ const newProps = lodash_defaults__WEBPACK_IMPORTED_MODULE_0___default()(standardProps, childProps, _victory_util_helpers__WEBPACK_IMPORTED_MODULE_4__.omit(props, ["children", "groupComponent"]), {
3802
+ key: childProps.key ?? id
3803
+ });
3804
+ const child = children && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().cloneElement(children, newProps);
3805
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
3806
+ portalContext?.addChild(id, child);
3807
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3808
+ }, [props.children]);
3809
+ react__WEBPACK_IMPORTED_MODULE_1___default().useEffect(() => {
3810
+ return () => portalContext?.removeChild(id);
3811
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3812
+ }, []);
3813
+ return portalContext ? null : child;
3814
+ };
3815
+ VictoryPortal.role = "portal";
3811
3816
 
3812
3817
  /***/ }),
3813
3818
 
@@ -4838,6 +4843,44 @@ function warn(message) {
4838
4843
 
4839
4844
  /***/ }),
4840
4845
 
4846
+ /***/ "../../victory-core/es/victory-util/merge-refs.js":
4847
+ /*!********************************************************!*\
4848
+ !*** ../../victory-core/es/victory-util/merge-refs.js ***!
4849
+ \********************************************************/
4850
+ /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
4851
+
4852
+ "use strict";
4853
+ __webpack_require__.r(__webpack_exports__);
4854
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4855
+ /* harmony export */ "mergeRefs": function() { return /* binding */ mergeRefs; }
4856
+ /* harmony export */ });
4857
+ /* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./helpers */ "../../victory-core/es/victory-util/helpers.js");
4858
+
4859
+ /**
4860
+ * Used to merge multiple React refs into a single callback ref.
4861
+ *
4862
+ * @example
4863
+ * ```tsx
4864
+ * <div ref={mergeRefs([ref, forwardedRef])} />
4865
+ * ```
4866
+ */
4867
+ function mergeRefs(refs) {
4868
+ return value => {
4869
+ refs.forEach(ref => {
4870
+ // If the ref is a function, it's a callback ref and we call it with the value.
4871
+ if (_helpers__WEBPACK_IMPORTED_MODULE_0__.isFunction(ref)) {
4872
+ ref(value);
4873
+ } else if (ref !== null && ref !== undefined) {
4874
+ // If the ref is an object (not null and not undefined), it's an object ref.
4875
+ // We assign the value to its 'current' property.
4876
+ ref.current = value;
4877
+ }
4878
+ });
4879
+ };
4880
+ }
4881
+
4882
+ /***/ }),
4883
+
4841
4884
  /***/ "../../victory-core/es/victory-util/selection.js":
4842
4885
  /*!*******************************************************!*\
4843
4886
  !*** ../../victory-core/es/victory-util/selection.js ***!
@@ -5363,98 +5406,6 @@ const approximateTextSize = (text, style) => _approximateTextSizeInternal.impl(t
5363
5406
 
5364
5407
  /***/ }),
5365
5408
 
5366
- /***/ "../../victory-core/es/victory-util/timer-context.js":
5367
- /*!***********************************************************!*\
5368
- !*** ../../victory-core/es/victory-util/timer-context.js ***!
5369
- \***********************************************************/
5370
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5371
-
5372
- "use strict";
5373
- __webpack_require__.r(__webpack_exports__);
5374
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
5375
- /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
5376
- /* harmony import */ var _timer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./timer */ "../../victory-core/es/victory-util/timer.js");
5377
-
5378
-
5379
-
5380
- /**
5381
- * The React context object consumers may use to access or override the global
5382
- * timer.
5383
- */
5384
- const TimerContext = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createContext({
5385
- transitionTimer: new _timer__WEBPACK_IMPORTED_MODULE_1__["default"](),
5386
- animationTimer: new _timer__WEBPACK_IMPORTED_MODULE_1__["default"]()
5387
- });
5388
- TimerContext.displayName = "TimerContext";
5389
- /* harmony default export */ __webpack_exports__["default"] = (TimerContext);
5390
-
5391
- /***/ }),
5392
-
5393
- /***/ "../../victory-core/es/victory-util/timer.js":
5394
- /*!***************************************************!*\
5395
- !*** ../../victory-core/es/victory-util/timer.js ***!
5396
- \***************************************************/
5397
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5398
-
5399
- "use strict";
5400
- __webpack_require__.r(__webpack_exports__);
5401
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5402
- /* harmony export */ "default": function() { return /* binding */ Timer; }
5403
- /* harmony export */ });
5404
- /* harmony import */ var victory_vendor_d3_timer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! victory-vendor/d3-timer */ "../../victory-vendor/es/d3-timer.js");
5405
-
5406
- class Timer {
5407
- constructor() {
5408
- this.shouldAnimate = true;
5409
- this.subscribers = [];
5410
- this.timer = null;
5411
- this.activeSubscriptions = 0;
5412
- }
5413
- bypassAnimation() {
5414
- this.shouldAnimate = false;
5415
- }
5416
- resumeAnimation() {
5417
- this.shouldAnimate = true;
5418
- }
5419
- loop = () => {
5420
- this.subscribers.forEach(s => {
5421
- s.callback((0,victory_vendor_d3_timer__WEBPACK_IMPORTED_MODULE_0__.now)() - s.startTime, s.duration);
5422
- });
5423
- };
5424
- start() {
5425
- if (!this.timer) {
5426
- this.timer = (0,victory_vendor_d3_timer__WEBPACK_IMPORTED_MODULE_0__.timer)(this.loop);
5427
- }
5428
- }
5429
- stop() {
5430
- if (this.timer) {
5431
- this.timer.stop();
5432
- this.timer = null;
5433
- }
5434
- }
5435
- subscribe(callback, duration) {
5436
- const subscriptionID = this.subscribers.push({
5437
- startTime: (0,victory_vendor_d3_timer__WEBPACK_IMPORTED_MODULE_0__.now)(),
5438
- callback,
5439
- duration: this.shouldAnimate ? duration : 0
5440
- });
5441
- this.activeSubscriptions++;
5442
- this.start();
5443
- return subscriptionID;
5444
- }
5445
- unsubscribe(id) {
5446
- if (id !== null && this.subscribers[id - 1]) {
5447
- delete this.subscribers[id - 1];
5448
- this.activeSubscriptions--;
5449
- }
5450
- if (this.activeSubscriptions === 0) {
5451
- this.stop();
5452
- }
5453
- }
5454
- }
5455
-
5456
- /***/ }),
5457
-
5458
5409
  /***/ "../../victory-core/es/victory-util/user-props.js":
5459
5410
  /*!********************************************************!*\
5460
5411
  !*** ../../victory-core/es/victory-util/user-props.js ***!
@@ -5569,32 +5520,6 @@ const withSafeUserProps = (component, props) => {
5569
5520
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.cloneElement(component, getSafeUserProps(props));
5570
5521
  };
5571
5522
 
5572
- /***/ }),
5573
-
5574
- /***/ "../../victory-vendor/es/d3-timer.js":
5575
- /*!*******************************************!*\
5576
- !*** ../../victory-vendor/es/d3-timer.js ***!
5577
- \*******************************************/
5578
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5579
-
5580
- "use strict";
5581
- __webpack_require__.r(__webpack_exports__);
5582
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5583
- /* harmony export */ "interval": function() { return /* reexport safe */ d3_timer__WEBPACK_IMPORTED_MODULE_0__.interval; },
5584
- /* harmony export */ "now": function() { return /* reexport safe */ d3_timer__WEBPACK_IMPORTED_MODULE_0__.now; },
5585
- /* harmony export */ "timeout": function() { return /* reexport safe */ d3_timer__WEBPACK_IMPORTED_MODULE_0__.timeout; },
5586
- /* harmony export */ "timer": function() { return /* reexport safe */ d3_timer__WEBPACK_IMPORTED_MODULE_0__.timer; },
5587
- /* harmony export */ "timerFlush": function() { return /* reexport safe */ d3_timer__WEBPACK_IMPORTED_MODULE_0__.timerFlush; }
5588
- /* harmony export */ });
5589
- /* harmony import */ var d3_timer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3-timer */ "../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/index.js");
5590
-
5591
- // `victory-vendor/d3-timer` (ESM)
5592
- // See upstream license: https://github.com/d3/d3-timer/blob/main/LICENSE
5593
- //
5594
- // Our ESM package uses the underlying installed dependencies of `node_modules/d3-timer`
5595
-
5596
-
5597
-
5598
5523
  /***/ }),
5599
5524
 
5600
5525
  /***/ "react":
@@ -5606,221 +5531,6 @@ __webpack_require__.r(__webpack_exports__);
5606
5531
  "use strict";
5607
5532
  module.exports = __WEBPACK_EXTERNAL_MODULE_react__;
5608
5533
 
5609
- /***/ }),
5610
-
5611
- /***/ "../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/index.js":
5612
- /*!*************************************************************************************!*\
5613
- !*** ../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/index.js ***!
5614
- \*************************************************************************************/
5615
- /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5616
-
5617
- "use strict";
5618
- __webpack_require__.r(__webpack_exports__);
5619
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5620
- /* harmony export */ "interval": function() { return /* reexport safe */ _interval_js__WEBPACK_IMPORTED_MODULE_2__["default"]; },
5621
- /* harmony export */ "now": function() { return /* reexport safe */ _timer_js__WEBPACK_IMPORTED_MODULE_0__.now; },
5622
- /* harmony export */ "timeout": function() { return /* reexport safe */ _timeout_js__WEBPACK_IMPORTED_MODULE_1__["default"]; },
5623
- /* harmony export */ "timer": function() { return /* reexport safe */ _timer_js__WEBPACK_IMPORTED_MODULE_0__.timer; },
5624
- /* harmony export */ "timerFlush": function() { return /* reexport safe */ _timer_js__WEBPACK_IMPORTED_MODULE_0__.timerFlush; }
5625
- /* harmony export */ });
5626
- /* harmony import */ var _timer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./timer.js */ "../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js");
5627
- /* harmony import */ var _timeout_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./timeout.js */ "../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timeout.js");
5628
- /* harmony import */ var _interval_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./interval.js */ "../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/interval.js");
5629
-
5630
-
5631
-
5632
-
5633
-
5634
-
5635
-
5636
- /***/ }),
5637
-
5638
- /***/ "../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/interval.js":
5639
- /*!****************************************************************************************!*\
5640
- !*** ../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/interval.js ***!
5641
- \****************************************************************************************/
5642
- /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5643
-
5644
- "use strict";
5645
- __webpack_require__.r(__webpack_exports__);
5646
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5647
- /* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
5648
- /* harmony export */ });
5649
- /* harmony import */ var _timer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./timer.js */ "../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js");
5650
-
5651
-
5652
- /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(callback, delay, time) {
5653
- var t = new _timer_js__WEBPACK_IMPORTED_MODULE_0__.Timer, total = delay;
5654
- if (delay == null) return t.restart(callback, delay, time), t;
5655
- t._restart = t.restart;
5656
- t.restart = function(callback, delay, time) {
5657
- delay = +delay, time = time == null ? (0,_timer_js__WEBPACK_IMPORTED_MODULE_0__.now)() : +time;
5658
- t._restart(function tick(elapsed) {
5659
- elapsed += total;
5660
- t._restart(tick, total += delay, time);
5661
- callback(elapsed);
5662
- }, delay, time);
5663
- }
5664
- t.restart(callback, delay, time);
5665
- return t;
5666
- }
5667
-
5668
-
5669
- /***/ }),
5670
-
5671
- /***/ "../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timeout.js":
5672
- /*!***************************************************************************************!*\
5673
- !*** ../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timeout.js ***!
5674
- \***************************************************************************************/
5675
- /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5676
-
5677
- "use strict";
5678
- __webpack_require__.r(__webpack_exports__);
5679
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5680
- /* harmony export */ "default": function() { return /* export default binding */ __WEBPACK_DEFAULT_EXPORT__; }
5681
- /* harmony export */ });
5682
- /* harmony import */ var _timer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./timer.js */ "../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js");
5683
-
5684
-
5685
- /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(callback, delay, time) {
5686
- var t = new _timer_js__WEBPACK_IMPORTED_MODULE_0__.Timer;
5687
- delay = delay == null ? 0 : +delay;
5688
- t.restart(elapsed => {
5689
- t.stop();
5690
- callback(elapsed + delay);
5691
- }, delay, time);
5692
- return t;
5693
- }
5694
-
5695
-
5696
- /***/ }),
5697
-
5698
- /***/ "../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js":
5699
- /*!*************************************************************************************!*\
5700
- !*** ../../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timer.js ***!
5701
- \*************************************************************************************/
5702
- /***/ (function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
5703
-
5704
- "use strict";
5705
- __webpack_require__.r(__webpack_exports__);
5706
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5707
- /* harmony export */ "Timer": function() { return /* binding */ Timer; },
5708
- /* harmony export */ "now": function() { return /* binding */ now; },
5709
- /* harmony export */ "timer": function() { return /* binding */ timer; },
5710
- /* harmony export */ "timerFlush": function() { return /* binding */ timerFlush; }
5711
- /* harmony export */ });
5712
- var frame = 0, // is an animation frame pending?
5713
- timeout = 0, // is a timeout pending?
5714
- interval = 0, // are any timers active?
5715
- pokeDelay = 1000, // how frequently we check for clock skew
5716
- taskHead,
5717
- taskTail,
5718
- clockLast = 0,
5719
- clockNow = 0,
5720
- clockSkew = 0,
5721
- clock = typeof performance === "object" && performance.now ? performance : Date,
5722
- setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) { setTimeout(f, 17); };
5723
-
5724
- function now() {
5725
- return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
5726
- }
5727
-
5728
- function clearNow() {
5729
- clockNow = 0;
5730
- }
5731
-
5732
- function Timer() {
5733
- this._call =
5734
- this._time =
5735
- this._next = null;
5736
- }
5737
-
5738
- Timer.prototype = timer.prototype = {
5739
- constructor: Timer,
5740
- restart: function(callback, delay, time) {
5741
- if (typeof callback !== "function") throw new TypeError("callback is not a function");
5742
- time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
5743
- if (!this._next && taskTail !== this) {
5744
- if (taskTail) taskTail._next = this;
5745
- else taskHead = this;
5746
- taskTail = this;
5747
- }
5748
- this._call = callback;
5749
- this._time = time;
5750
- sleep();
5751
- },
5752
- stop: function() {
5753
- if (this._call) {
5754
- this._call = null;
5755
- this._time = Infinity;
5756
- sleep();
5757
- }
5758
- }
5759
- };
5760
-
5761
- function timer(callback, delay, time) {
5762
- var t = new Timer;
5763
- t.restart(callback, delay, time);
5764
- return t;
5765
- }
5766
-
5767
- function timerFlush() {
5768
- now(); // Get the current time, if not already set.
5769
- ++frame; // Pretend we’ve set an alarm, if we haven’t already.
5770
- var t = taskHead, e;
5771
- while (t) {
5772
- if ((e = clockNow - t._time) >= 0) t._call.call(undefined, e);
5773
- t = t._next;
5774
- }
5775
- --frame;
5776
- }
5777
-
5778
- function wake() {
5779
- clockNow = (clockLast = clock.now()) + clockSkew;
5780
- frame = timeout = 0;
5781
- try {
5782
- timerFlush();
5783
- } finally {
5784
- frame = 0;
5785
- nap();
5786
- clockNow = 0;
5787
- }
5788
- }
5789
-
5790
- function poke() {
5791
- var now = clock.now(), delay = now - clockLast;
5792
- if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
5793
- }
5794
-
5795
- function nap() {
5796
- var t0, t1 = taskHead, t2, time = Infinity;
5797
- while (t1) {
5798
- if (t1._call) {
5799
- if (time > t1._time) time = t1._time;
5800
- t0 = t1, t1 = t1._next;
5801
- } else {
5802
- t2 = t1._next, t1._next = null;
5803
- t1 = t0 ? t0._next = t2 : taskHead = t2;
5804
- }
5805
- }
5806
- taskTail = t0;
5807
- sleep(time);
5808
- }
5809
-
5810
- function sleep(time) {
5811
- if (frame) return; // Soonest alarm already set, or will be.
5812
- if (timeout) timeout = clearTimeout(timeout);
5813
- var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
5814
- if (delay > 24) {
5815
- if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
5816
- if (interval) interval = clearInterval(interval);
5817
- } else {
5818
- if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
5819
- frame = 1, setFrame(wake);
5820
- }
5821
- }
5822
-
5823
-
5824
5534
  /***/ })
5825
5535
 
5826
5536
  /******/ });
@@ -5913,8 +5623,9 @@ var __webpack_exports__ = {};
5913
5623
  __webpack_require__.r(__webpack_exports__);
5914
5624
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5915
5625
  /* harmony export */ "CursorHelpers": function() { return /* reexport safe */ _cursor_helpers__WEBPACK_IMPORTED_MODULE_0__.CursorHelpers; },
5626
+ /* harmony export */ "VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS": function() { return /* reexport safe */ _victory_cursor_container__WEBPACK_IMPORTED_MODULE_1__.VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS; },
5916
5627
  /* harmony export */ "VictoryCursorContainer": function() { return /* reexport safe */ _victory_cursor_container__WEBPACK_IMPORTED_MODULE_1__.VictoryCursorContainer; },
5917
- /* harmony export */ "cursorContainerMixin": function() { return /* reexport safe */ _victory_cursor_container__WEBPACK_IMPORTED_MODULE_1__.cursorContainerMixin; }
5628
+ /* harmony export */ "useVictoryCursorContainer": function() { return /* reexport safe */ _victory_cursor_container__WEBPACK_IMPORTED_MODULE_1__.useVictoryCursorContainer; }
5918
5629
  /* harmony export */ });
5919
5630
  /* harmony import */ var _cursor_helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cursor-helpers */ "./cursor-helpers.tsx");
5920
5631
  /* harmony import */ var _victory_cursor_container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./victory-cursor-container */ "./victory-cursor-container.tsx");