victory-core 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.
Files changed (48) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/victory-core.js +395 -358
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/index.d.ts +2 -1
  5. package/es/index.js +2 -1
  6. package/es/types/prop-types.d.ts +1 -0
  7. package/es/victory-container/victory-container.d.ts +29 -35
  8. package/es/victory-container/victory-container.js +134 -162
  9. package/es/victory-portal/portal-context.d.ts +9 -8
  10. package/es/victory-portal/portal-context.js +34 -6
  11. package/es/victory-portal/portal-outlet.d.ts +12 -0
  12. package/es/victory-portal/portal-outlet.js +14 -0
  13. package/es/victory-portal/portal.d.ts +1 -12
  14. package/es/victory-portal/portal.js +6 -32
  15. package/es/victory-portal/victory-portal.d.ts +5 -22
  16. package/es/victory-portal/victory-portal.js +37 -52
  17. package/es/victory-util/index.d.ts +1 -0
  18. package/es/victory-util/index.js +1 -0
  19. package/es/victory-util/merge-refs.d.ts +13 -0
  20. package/es/victory-util/merge-refs.js +23 -0
  21. package/lib/index.d.ts +2 -1
  22. package/lib/index.js +16 -4
  23. package/lib/types/prop-types.d.ts +1 -0
  24. package/lib/victory-container/victory-container.d.ts +29 -35
  25. package/lib/victory-container/victory-container.js +136 -163
  26. package/lib/victory-portal/portal-context.d.ts +9 -8
  27. package/lib/victory-portal/portal-context.js +37 -7
  28. package/lib/victory-portal/portal-outlet.d.ts +12 -0
  29. package/lib/victory-portal/portal-outlet.js +22 -0
  30. package/lib/victory-portal/portal.d.ts +1 -12
  31. package/lib/victory-portal/portal.js +6 -33
  32. package/lib/victory-portal/victory-portal.d.ts +5 -22
  33. package/lib/victory-portal/victory-portal.js +37 -52
  34. package/lib/victory-util/index.d.ts +1 -0
  35. package/lib/victory-util/index.js +12 -0
  36. package/lib/victory-util/merge-refs.d.ts +13 -0
  37. package/lib/victory-util/merge-refs.js +31 -0
  38. package/package.json +2 -2
  39. package/src/index.ts +2 -1
  40. package/src/types/prop-types.ts +7 -0
  41. package/src/victory-container/victory-container.tsx +167 -195
  42. package/src/victory-portal/portal-context.tsx +63 -0
  43. package/src/victory-portal/portal-outlet.tsx +26 -0
  44. package/src/victory-portal/portal.tsx +5 -42
  45. package/src/victory-portal/victory-portal.tsx +44 -73
  46. package/src/victory-util/index.ts +1 -0
  47. package/src/victory-util/merge-refs.ts +26 -0
  48. package/src/victory-portal/portal-context.ts +0 -14
@@ -2,57 +2,42 @@ import _defaults from "lodash/defaults";
2
2
  import React from "react";
3
3
  import * as Log from "../victory-util/log";
4
4
  import * as Helpers from "../victory-util/helpers";
5
- import { PortalContext } from "./portal-context";
6
- export class VictoryPortal extends React.Component {
7
- static displayName = "VictoryPortal";
8
- static role = "portal";
9
- static defaultProps = {
10
- groupComponent: /*#__PURE__*/React.createElement("g", null)
5
+ import { usePortalContext } from "./portal-context";
6
+ const defaultProps = {
7
+ groupComponent: /*#__PURE__*/React.createElement("g", null)
8
+ };
9
+ export const VictoryPortal = initialProps => {
10
+ const props = {
11
+ ...defaultProps,
12
+ ...initialProps
11
13
  };
12
- static contextType = PortalContext;
13
- componentDidMount() {
14
- if (!this.checkedContext) {
15
- if (typeof this.context.portalUpdate !== "function") {
16
- const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
17
- Log.warn(msg);
18
- this.renderInPlace = true;
19
- }
20
- this.checkedContext = true;
21
- }
22
- this.forceUpdate();
14
+ const id = React.useId();
15
+ const portalContext = usePortalContext();
16
+ if (!portalContext) {
17
+ const msg = "`renderInPortal` is not supported outside of `VictoryContainer`. " + "Component will be rendered in place";
18
+ Log.warn(msg);
23
19
  }
24
- componentDidUpdate() {
25
- if (!this.renderInPlace) {
26
- this.portalKey = this.portalKey || this.context.portalRegister();
27
- this.context.portalUpdate(this.portalKey, this.element);
28
- }
29
- }
30
- componentWillUnmount() {
31
- if (this.context && this.context.portalDeregister) {
32
- this.context.portalDeregister(this.portalKey);
33
- }
34
- }
35
-
36
- // Overridden in victory-core-native
37
- renderPortal(child) {
38
- if (this.renderInPlace) {
39
- return child;
40
- }
41
- this.element = child;
42
- return null;
43
- }
44
- render() {
45
- const children = Array.isArray(this.props.children) ? this.props.children[0] : this.props.children;
46
- const {
47
- groupComponent
48
- } = this.props;
49
- const childProps = children && children.props || {};
50
- const standardProps = childProps.groupComponent ? {
51
- groupComponent,
52
- standalone: false
53
- } : {};
54
- const newProps = _defaults(standardProps, childProps, Helpers.omit(this.props, ["children", "groupComponent"]));
55
- const child = children && /*#__PURE__*/React.cloneElement(children, newProps);
56
- return this.renderPortal(child);
57
- }
58
- }
20
+ const children = Array.isArray(props.children) ? props.children[0] : props.children;
21
+ const {
22
+ groupComponent
23
+ } = props;
24
+ const childProps = children && children.props || {};
25
+ const standardProps = childProps.groupComponent ? {
26
+ groupComponent,
27
+ standalone: false
28
+ } : {};
29
+ const newProps = _defaults(standardProps, childProps, Helpers.omit(props, ["children", "groupComponent"]), {
30
+ key: childProps.key ?? id
31
+ });
32
+ const child = children && /*#__PURE__*/React.cloneElement(children, newProps);
33
+ React.useEffect(() => {
34
+ portalContext?.addChild(id, child);
35
+ // eslint-disable-next-line react-hooks/exhaustive-deps
36
+ }, [props.children]);
37
+ React.useEffect(() => {
38
+ return () => portalContext?.removeChild(id);
39
+ // eslint-disable-next-line react-hooks/exhaustive-deps
40
+ }, []);
41
+ return portalContext ? null : child;
42
+ };
43
+ VictoryPortal.role = "portal";
@@ -1,4 +1,5 @@
1
1
  export * from "./add-events";
2
+ export * from "./merge-refs";
2
3
  export * as Axis from "./axis";
3
4
  export * as Collection from "./collection";
4
5
  export * from "./common-props";
@@ -1,4 +1,5 @@
1
1
  export * from "./add-events";
2
+ export * from "./merge-refs";
2
3
  import * as _Axis from "./axis";
3
4
  export { _Axis as Axis };
4
5
  import * as _Collection from "./collection";
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ declare type Ref<T> = React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null;
3
+ /**
4
+ * Used to merge multiple React refs into a single callback ref.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * <div ref={mergeRefs([ref, forwardedRef])} />
9
+ * ```
10
+ */
11
+ export declare function mergeRefs<T>(refs: Ref<T>[]): React.RefCallback<T>;
12
+ export {};
13
+ //# sourceMappingURL=merge-refs.d.ts.map
@@ -0,0 +1,23 @@
1
+ import * as Helpers from "./helpers";
2
+ /**
3
+ * Used to merge multiple React refs into a single callback ref.
4
+ *
5
+ * @example
6
+ * ```tsx
7
+ * <div ref={mergeRefs([ref, forwardedRef])} />
8
+ * ```
9
+ */
10
+ export function mergeRefs(refs) {
11
+ return value => {
12
+ refs.forEach(ref => {
13
+ // If the ref is a function, it's a callback ref and we call it with the value.
14
+ if (Helpers.isFunction(ref)) {
15
+ ref(value);
16
+ } else if (ref !== null && ref !== undefined) {
17
+ // If the ref is an object (not null and not undefined), it's an object ref.
18
+ // We assign the value to its 'current' property.
19
+ ref.current = value;
20
+ }
21
+ });
22
+ };
23
+ }
package/lib/index.d.ts CHANGED
@@ -9,8 +9,9 @@ export * from "./victory-clip-container/victory-clip-container";
9
9
  export * from "./victory-theme/types";
10
10
  export * from "./victory-theme/victory-theme";
11
11
  export * from "./victory-portal/portal";
12
- export * from "./victory-portal/portal-context";
13
12
  export * from "./victory-portal/victory-portal";
13
+ export * from "./victory-portal/portal-context";
14
+ export * from "./victory-portal/portal-outlet";
14
15
  export * from "./victory-primitives";
15
16
  export { Border as Box } from "./victory-primitives";
16
17
  export type { BorderProps as BoxProps } from "./victory-primitives";
package/lib/index.js CHANGED
@@ -144,6 +144,18 @@ Object.keys(_portal).forEach(function (key) {
144
144
  }
145
145
  });
146
146
  });
147
+ var _victoryPortal = require("./victory-portal/victory-portal");
148
+ Object.keys(_victoryPortal).forEach(function (key) {
149
+ if (key === "default" || key === "__esModule") return;
150
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
151
+ if (key in exports && exports[key] === _victoryPortal[key]) return;
152
+ Object.defineProperty(exports, key, {
153
+ enumerable: true,
154
+ get: function () {
155
+ return _victoryPortal[key];
156
+ }
157
+ });
158
+ });
147
159
  var _portalContext = require("./victory-portal/portal-context");
148
160
  Object.keys(_portalContext).forEach(function (key) {
149
161
  if (key === "default" || key === "__esModule") return;
@@ -156,15 +168,15 @@ Object.keys(_portalContext).forEach(function (key) {
156
168
  }
157
169
  });
158
170
  });
159
- var _victoryPortal = require("./victory-portal/victory-portal");
160
- Object.keys(_victoryPortal).forEach(function (key) {
171
+ var _portalOutlet = require("./victory-portal/portal-outlet");
172
+ Object.keys(_portalOutlet).forEach(function (key) {
161
173
  if (key === "default" || key === "__esModule") return;
162
174
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
163
- if (key in exports && exports[key] === _victoryPortal[key]) return;
175
+ if (key in exports && exports[key] === _portalOutlet[key]) return;
164
176
  Object.defineProperty(exports, key, {
165
177
  enumerable: true,
166
178
  get: function () {
167
- return _victoryPortal[key];
179
+ return _portalOutlet[key];
168
180
  }
169
181
  });
170
182
  });
@@ -126,5 +126,6 @@ export declare type CoordinatesPropType = {
126
126
  x: number;
127
127
  y: number;
128
128
  };
129
+ export declare type VictoryEventHandler = (event?: any, targetProps?: any, eventKey?: any, context?: any) => void;
129
130
  export {};
130
131
  //# sourceMappingURL=prop-types.d.ts.map
@@ -14,9 +14,6 @@ export interface VictoryContainerProps {
14
14
  height?: number;
15
15
  name?: string;
16
16
  origin?: OriginType;
17
- ouiaId?: number | string;
18
- ouiaSafe?: boolean;
19
- ouiaType?: string;
20
17
  polar?: boolean;
21
18
  portalComponent?: React.ReactElement;
22
19
  portalZIndex?: number;
@@ -32,38 +29,35 @@ export interface VictoryContainerProps {
32
29
  theme?: VictoryThemeDefinition;
33
30
  title?: string;
34
31
  width?: number;
32
+ ouiaId?: number | string;
33
+ ouiaSafe?: boolean;
34
+ ouiaType?: string;
35
35
  }
36
- export declare class VictoryContainer<TProps extends VictoryContainerProps> extends React.Component<TProps> {
37
- static displayName: string;
38
- static role: string;
39
- static defaultProps: {
40
- className: string;
41
- portalComponent: JSX.Element;
42
- portalZIndex: number;
43
- responsive: boolean;
44
- role: string;
36
+ export declare function useVictoryContainer<TProps extends VictoryContainerProps>(initialProps: TProps): {
37
+ className: string;
38
+ portalComponent: JSX.Element;
39
+ portalZIndex: number;
40
+ responsive: boolean;
41
+ role: string;
42
+ } & TProps & {
43
+ titleId: string;
44
+ descId: string;
45
+ dimensions: {
46
+ width: string;
47
+ height: string;
48
+ } | {
49
+ width: number | undefined;
50
+ height: number | undefined;
45
51
  };
46
- static contextType: React.Context<{
47
- transitionTimer: import("..").Timer;
48
- animationTimer: import("..").Timer;
49
- }>;
50
- private containerId;
51
- private portalRef;
52
- private containerRef;
53
- private shouldHandleWheel;
54
- constructor(props: TProps);
55
- savePortalRef: (portal: any) => any;
56
- portalUpdate: (key: any, el: any) => void;
57
- portalRegister: () => number;
58
- portalDeregister: (key: any) => void;
59
- saveContainerRef: (container: HTMLElement) => HTMLElement;
60
- handleWheel: (e: any) => any;
61
- componentDidMount(): void;
62
- componentWillUnmount(): void;
63
- getIdForElement(elementName: any): string;
64
- getChildren(props: any): any;
65
- getOUIAProps(props: any): any;
66
- renderContainer(props: any, svgProps: any, style: any): JSX.Element;
67
- render(): JSX.Element;
68
- }
52
+ viewBox: string | undefined;
53
+ preserveAspectRatio: string | undefined;
54
+ ariaLabelledBy: string | undefined;
55
+ ariaDescribedBy: string | undefined;
56
+ userProps: Record<string, string>;
57
+ localContainerRef: React.RefObject<HTMLDivElement>;
58
+ };
59
+ export declare const VictoryContainer: {
60
+ (initialProps: VictoryContainerProps): JSX.Element;
61
+ role: string;
62
+ };
69
63
  //# sourceMappingURL=victory-container.d.ts.map
@@ -4,186 +4,159 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VictoryContainer = void 0;
7
- var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
7
+ exports.useVictoryContainer = useVictoryContainer;
8
8
  var _uniqueId2 = _interopRequireDefault(require("lodash/uniqueId"));
9
- var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
10
- var _react = _interopRequireDefault(require("react"));
9
+ var _react = _interopRequireWildcard(require("react"));
11
10
  var _portal = require("../victory-portal/portal");
12
- var _portalContext = require("../victory-portal/portal-context");
13
- var _timerContext = _interopRequireDefault(require("../victory-util/timer-context"));
14
- var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
15
11
  var UserProps = _interopRequireWildcard(require("../victory-util/user-props"));
12
+ var _victoryUtil = require("../victory-util");
13
+ var _portalOutlet = require("../victory-portal/portal-outlet");
14
+ var _portalContext = require("../victory-portal/portal-context");
16
15
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
16
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
18
  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); }
20
- class VictoryContainer extends _react.default.Component {
21
- static displayName = "VictoryContainer";
22
- static role = "container";
23
- static defaultProps = {
24
- className: "VictoryContainer",
25
- portalComponent: /*#__PURE__*/_react.default.createElement(_portal.Portal, null),
26
- portalZIndex: 99,
27
- responsive: true,
28
- role: "img"
19
+ const defaultProps = {
20
+ className: "VictoryContainer",
21
+ portalComponent: /*#__PURE__*/_react.default.createElement(_portal.Portal, null),
22
+ portalZIndex: 99,
23
+ responsive: true,
24
+ role: "img"
25
+ };
26
+ function useVictoryContainer(initialProps) {
27
+ const props = {
28
+ ...defaultProps,
29
+ ...initialProps
29
30
  };
30
- static contextType = _timerContext.default;
31
-
32
- // @ts-expect-error Ref will be initialized on mount
31
+ const {
32
+ title,
33
+ desc,
34
+ width,
35
+ height,
36
+ responsive
37
+ } = props;
38
+ const localContainerRef = (0, _react.useRef)(null);
33
39
 
34
- // @ts-expect-error Ref will be initialized on mount
35
-
36
- constructor(props) {
37
- super(props);
38
- this.containerId = !(0, _isObject2.default)(props) || props.containerId === undefined ? (0, _uniqueId2.default)("victory-container-") : props.containerId;
39
- this.shouldHandleWheel = !!(props && props.events && props.events.onWheel);
40
- }
41
- savePortalRef = portal => {
42
- this.portalRef = portal;
43
- return portal;
40
+ // Generated ID stored in ref because it needs to persist across renders
41
+ const generatedId = (0, _react.useRef)((0, _uniqueId2.default)("victory-container-"));
42
+ const containerId = props.containerId ?? generatedId.current;
43
+ const getIdForElement = elName => `${containerId}-${elName}`;
44
+ const userProps = UserProps.getSafeUserProps(props);
45
+ const dimensions = responsive ? {
46
+ width: "100%",
47
+ height: "100%"
48
+ } : {
49
+ width,
50
+ height
44
51
  };
45
- portalUpdate = (key, el) => this.portalRef.portalUpdate(key, el);
46
- portalRegister = () => this.portalRef.portalRegister();
47
- portalDeregister = key => this.portalRef.portalDeregister(key);
48
- saveContainerRef = container => {
49
- if (Helpers.isFunction(this.props.containerRef)) {
50
- this.props.containerRef(container);
51
- }
52
- this.containerRef = container;
53
- return container;
52
+ const viewBox = responsive ? `0 0 ${width} ${height}` : undefined;
53
+ const preserveAspectRatio = responsive ? props.preserveAspectRatio : undefined;
54
+ const ariaLabelledBy = [title && getIdForElement("title"), props["aria-labelledby"]].filter(Boolean).join(" ") || undefined;
55
+ const ariaDescribedBy = [desc && getIdForElement("desc"), props["aria-describedby"]].filter(Boolean).join(" ") || undefined;
56
+ const titleId = getIdForElement("title");
57
+ const descId = getIdForElement("desc");
58
+ return {
59
+ ...props,
60
+ titleId,
61
+ descId,
62
+ dimensions,
63
+ viewBox,
64
+ preserveAspectRatio,
65
+ ariaLabelledBy,
66
+ ariaDescribedBy,
67
+ userProps,
68
+ localContainerRef
54
69
  };
55
- handleWheel = e => e.preventDefault();
56
- componentDidMount() {
57
- if (this.shouldHandleWheel && this.containerRef) {
58
- this.containerRef.addEventListener("wheel", this.handleWheel);
59
- }
60
- }
61
- componentWillUnmount() {
62
- if (this.shouldHandleWheel && this.containerRef) {
63
- this.containerRef.removeEventListener("wheel", this.handleWheel);
64
- }
65
- }
66
- getIdForElement(elementName) {
67
- return `${this.containerId}-${elementName}`;
68
- }
69
-
70
- // overridden in custom containers
71
- getChildren(props) {
72
- return props.children;
73
- }
74
-
75
- // Get props defined by the Open UI Automation (OUIA) 1.0-RC spec
76
- // See https://ouia.readthedocs.io/en/latest/README.html#ouia-component
77
- getOUIAProps(props) {
78
- const {
79
- ouiaId,
80
- ouiaSafe,
81
- ouiaType
82
- } = props;
83
- return {
84
- ...(ouiaId && {
85
- "data-ouia-component-id": ouiaId
86
- }),
87
- ...(ouiaType && {
88
- "data-ouia-component-type": ouiaType
89
- }),
90
- ...(ouiaSafe !== undefined && {
91
- "data-ouia-safe": ouiaSafe
92
- })
93
- };
94
- }
95
- renderContainer(props, svgProps, style) {
96
- const {
97
- title,
98
- desc,
99
- portalComponent,
100
- className,
101
- width,
102
- height,
103
- portalZIndex,
104
- responsive
105
- } = props;
106
- const children = this.getChildren(props);
107
- const dimensions = responsive ? {
108
- width: "100%",
109
- height: "100%"
110
- } : {
111
- width,
112
- height
70
+ }
71
+ const VictoryContainer = initialProps => {
72
+ const {
73
+ role,
74
+ title,
75
+ desc,
76
+ children,
77
+ className,
78
+ portalZIndex,
79
+ portalComponent,
80
+ width,
81
+ height,
82
+ style,
83
+ tabIndex,
84
+ responsive,
85
+ events,
86
+ ouiaId,
87
+ ouiaSafe,
88
+ ouiaType,
89
+ dimensions,
90
+ ariaDescribedBy,
91
+ ariaLabelledBy,
92
+ viewBox,
93
+ preserveAspectRatio,
94
+ userProps,
95
+ titleId,
96
+ descId,
97
+ containerRef,
98
+ localContainerRef
99
+ } = useVictoryContainer(initialProps);
100
+ _react.default.useEffect(() => {
101
+ if (!events?.onWheel) return;
102
+ const handleWheel = e => e.preventDefault();
103
+ const container = localContainerRef?.current;
104
+ container?.addEventListener("wheel", handleWheel);
105
+ return () => {
106
+ container?.removeEventListener("wheel", handleWheel);
113
107
  };
114
- const divStyle = Object.assign({
108
+ // eslint-disable-next-line react-hooks/exhaustive-deps
109
+ }, []);
110
+ return /*#__PURE__*/_react.default.createElement("div", {
111
+ className: className,
112
+ style: {
113
+ ...style,
114
+ width: responsive ? style?.width : dimensions.width,
115
+ height: responsive ? style?.height : dimensions.height,
115
116
  pointerEvents: "none",
116
117
  touchAction: "none",
117
118
  position: "relative"
118
- }, dimensions);
119
- const portalDivStyle = Object.assign({
119
+ },
120
+ "data-ouia-component-id": ouiaId,
121
+ "data-ouia-component-type": ouiaType,
122
+ "data-ouia-safe": ouiaSafe,
123
+ ref: (0, _victoryUtil.mergeRefs)([localContainerRef, containerRef])
124
+ }, /*#__PURE__*/_react.default.createElement(_portalContext.PortalProvider, null, /*#__PURE__*/_react.default.createElement("svg", _extends({
125
+ width: width,
126
+ height: height,
127
+ tabIndex: tabIndex,
128
+ role: role,
129
+ "aria-labelledby": ariaLabelledBy,
130
+ "aria-describedby": ariaDescribedBy,
131
+ viewBox: viewBox,
132
+ preserveAspectRatio: preserveAspectRatio,
133
+ style: {
134
+ ...dimensions,
135
+ pointerEvents: "all"
136
+ }
137
+ }, userProps, events), title ? /*#__PURE__*/_react.default.createElement("title", {
138
+ id: titleId
139
+ }, title) : null, desc ? /*#__PURE__*/_react.default.createElement("desc", {
140
+ id: descId
141
+ }, desc) : null, children), /*#__PURE__*/_react.default.createElement("div", {
142
+ style: {
143
+ ...dimensions,
120
144
  zIndex: portalZIndex,
121
145
  position: "absolute",
122
146
  top: 0,
123
147
  left: 0
124
- }, dimensions);
125
- const svgStyle = Object.assign({
126
- pointerEvents: "all"
127
- }, dimensions);
128
- const portalSvgStyle = Object.assign({
148
+ }
149
+ }, /*#__PURE__*/_react.default.createElement(_portalOutlet.PortalOutlet, {
150
+ as: portalComponent,
151
+ width: width,
152
+ height: height,
153
+ viewBox: viewBox,
154
+ preserveAspectRatio: preserveAspectRatio,
155
+ style: {
156
+ ...dimensions,
129
157
  overflow: "visible"
130
- }, dimensions);
131
- const portalProps = {
132
- width,
133
- height,
134
- viewBox: svgProps.viewBox,
135
- preserveAspectRatio: svgProps.preserveAspectRatio,
136
- style: portalSvgStyle
137
- };
138
- return /*#__PURE__*/_react.default.createElement(_portalContext.PortalContext.Provider, {
139
- value: {
140
- portalUpdate: this.portalUpdate,
141
- portalRegister: this.portalRegister,
142
- portalDeregister: this.portalDeregister
143
- }
144
- }, /*#__PURE__*/_react.default.createElement("div", _extends({
145
- style: (0, _defaults2.default)({}, style, divStyle),
146
- className: className,
147
- ref: this.saveContainerRef
148
- }, this.getOUIAProps(props)), /*#__PURE__*/_react.default.createElement("svg", _extends({}, svgProps, {
149
- style: svgStyle
150
- }), title ? /*#__PURE__*/_react.default.createElement("title", {
151
- id: this.getIdForElement("title")
152
- }, title) : null, desc ? /*#__PURE__*/_react.default.createElement("desc", {
153
- id: this.getIdForElement("desc")
154
- }, desc) : null, children), /*#__PURE__*/_react.default.createElement("div", {
155
- style: portalDivStyle
156
- }, /*#__PURE__*/_react.default.cloneElement(portalComponent, {
157
- ...portalProps,
158
- ref: this.savePortalRef
159
- }))));
160
- }
161
- render() {
162
- const {
163
- width,
164
- height,
165
- responsive,
166
- events,
167
- title,
168
- desc,
169
- tabIndex,
170
- preserveAspectRatio,
171
- role
172
- } = this.props;
173
- const style = responsive ? this.props.style : Helpers.omit(this.props.style, ["height", "width"]);
174
- const userProps = UserProps.getSafeUserProps(this.props);
175
- const svgProps = Object.assign({
176
- width,
177
- height,
178
- tabIndex,
179
- role,
180
- "aria-labelledby": [title && this.getIdForElement("title"), this.props["aria-labelledby"]].filter(Boolean).join(" ") || undefined,
181
- "aria-describedby": [desc && this.getIdForElement("desc"), this.props["aria-describedby"]].filter(Boolean).join(" ") || undefined,
182
- viewBox: responsive ? `0 0 ${width} ${height}` : undefined,
183
- preserveAspectRatio: responsive ? preserveAspectRatio : undefined,
184
- ...userProps
185
- }, events);
186
- return this.renderContainer(this.props, svgProps, style);
187
- }
188
- }
189
- exports.VictoryContainer = VictoryContainer;
158
+ }
159
+ }))));
160
+ };
161
+ exports.VictoryContainer = VictoryContainer;
162
+ VictoryContainer.role = "container";
@@ -1,12 +1,13 @@
1
1
  import React from "react";
2
2
  export interface PortalContextValue {
3
- portalRegister(): number;
4
- portalUpdate(key: number, element: React.ReactElement): void;
5
- portalDeregister(key: number): void;
3
+ addChild: (id: string, node: React.ReactElement) => void;
4
+ removeChild: (id: string) => void;
5
+ children: Map<string, React.ReactElement>;
6
6
  }
7
- /**
8
- * The React context object consumers may use to access the context of the
9
- * portal.
10
- */
11
- export declare const PortalContext: React.Context<PortalContextValue>;
7
+ export declare const PortalContext: React.Context<PortalContextValue | undefined>;
8
+ export declare const usePortalContext: () => PortalContextValue | undefined;
9
+ export interface PortalProviderProps {
10
+ children?: React.ReactNode;
11
+ }
12
+ export declare const PortalProvider: ({ children }: PortalProviderProps) => JSX.Element;
12
13
  //# sourceMappingURL=portal-context.d.ts.map