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.
- package/CHANGELOG.md +8 -0
- package/dist/victory-core.js +395 -358
- package/dist/victory-core.min.js +1 -1
- package/es/index.d.ts +2 -1
- package/es/index.js +2 -1
- package/es/types/prop-types.d.ts +1 -0
- package/es/victory-container/victory-container.d.ts +29 -35
- package/es/victory-container/victory-container.js +134 -162
- package/es/victory-portal/portal-context.d.ts +9 -8
- package/es/victory-portal/portal-context.js +34 -6
- package/es/victory-portal/portal-outlet.d.ts +12 -0
- package/es/victory-portal/portal-outlet.js +14 -0
- package/es/victory-portal/portal.d.ts +1 -12
- package/es/victory-portal/portal.js +6 -32
- package/es/victory-portal/victory-portal.d.ts +5 -22
- package/es/victory-portal/victory-portal.js +37 -52
- package/es/victory-util/index.d.ts +1 -0
- package/es/victory-util/index.js +1 -0
- package/es/victory-util/merge-refs.d.ts +13 -0
- package/es/victory-util/merge-refs.js +23 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +16 -4
- package/lib/types/prop-types.d.ts +1 -0
- package/lib/victory-container/victory-container.d.ts +29 -35
- package/lib/victory-container/victory-container.js +136 -163
- package/lib/victory-portal/portal-context.d.ts +9 -8
- package/lib/victory-portal/portal-context.js +37 -7
- package/lib/victory-portal/portal-outlet.d.ts +12 -0
- package/lib/victory-portal/portal-outlet.js +22 -0
- package/lib/victory-portal/portal.d.ts +1 -12
- package/lib/victory-portal/portal.js +6 -33
- package/lib/victory-portal/victory-portal.d.ts +5 -22
- package/lib/victory-portal/victory-portal.js +37 -52
- package/lib/victory-util/index.d.ts +1 -0
- package/lib/victory-util/index.js +12 -0
- package/lib/victory-util/merge-refs.d.ts +13 -0
- package/lib/victory-util/merge-refs.js +31 -0
- package/package.json +2 -2
- package/src/index.ts +2 -1
- package/src/types/prop-types.ts +7 -0
- package/src/victory-container/victory-container.tsx +167 -195
- package/src/victory-portal/portal-context.tsx +63 -0
- package/src/victory-portal/portal-outlet.tsx +26 -0
- package/src/victory-portal/portal.tsx +5 -42
- package/src/victory-portal/victory-portal.tsx +44 -73
- package/src/victory-util/index.ts +1 -0
- package/src/victory-util/merge-refs.ts +26 -0
- 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 {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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";
|
package/es/victory-util/index.js
CHANGED
|
@@ -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
|
|
160
|
-
Object.keys(
|
|
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] ===
|
|
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
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
7
|
+
exports.useVictoryContainer = useVictoryContainer;
|
|
8
8
|
var _uniqueId2 = _interopRequireDefault(require("lodash/uniqueId"));
|
|
9
|
-
var
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const {
|
|
32
|
+
title,
|
|
33
|
+
desc,
|
|
34
|
+
width,
|
|
35
|
+
height,
|
|
36
|
+
responsive
|
|
37
|
+
} = props;
|
|
38
|
+
const localContainerRef = (0, _react.useRef)(null);
|
|
33
39
|
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
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
|
-
},
|
|
119
|
-
|
|
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
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
addChild: (id: string, node: React.ReactElement) => void;
|
|
4
|
+
removeChild: (id: string) => void;
|
|
5
|
+
children: Map<string, React.ReactElement>;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|