victory-core 37.0.2 → 37.0.3-next.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 (154) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/victory-core.js +390 -350
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/index.d.ts +18 -17
  5. package/es/index.js +2 -1
  6. package/es/types/callbacks.d.ts +36 -36
  7. package/es/types/prop-types.d.ts +130 -129
  8. package/es/victory-accessible-group/victory-accessible-group.d.ts +10 -10
  9. package/es/victory-animation/util.d.ts +66 -66
  10. package/es/victory-animation/victory-animation.d.ts +34 -34
  11. package/es/victory-clip-container/victory-clip-container.d.ts +46 -46
  12. package/es/victory-container/victory-container.d.ts +62 -68
  13. package/es/victory-container/victory-container.js +134 -162
  14. package/es/victory-label/victory-label.d.ts +58 -58
  15. package/es/victory-portal/portal-context.d.ts +12 -11
  16. package/es/victory-portal/portal-context.js +37 -6
  17. package/es/victory-portal/portal-outlet.d.ts +12 -0
  18. package/es/victory-portal/portal-outlet.js +16 -0
  19. package/es/victory-portal/portal.d.ts +9 -20
  20. package/es/victory-portal/portal.js +6 -32
  21. package/es/victory-portal/victory-portal.d.ts +9 -26
  22. package/es/victory-portal/victory-portal.js +27 -44
  23. package/es/victory-primitives/arc.d.ts +14 -14
  24. package/es/victory-primitives/background.d.ts +13 -13
  25. package/es/victory-primitives/border.d.ts +10 -10
  26. package/es/victory-primitives/circle.d.ts +3 -3
  27. package/es/victory-primitives/clip-path.d.ts +7 -7
  28. package/es/victory-primitives/index.d.ts +14 -14
  29. package/es/victory-primitives/line-segment.d.ts +11 -11
  30. package/es/victory-primitives/line.d.ts +3 -3
  31. package/es/victory-primitives/path.d.ts +3 -3
  32. package/es/victory-primitives/point.d.ts +13 -13
  33. package/es/victory-primitives/rect.d.ts +3 -3
  34. package/es/victory-primitives/text.d.ts +8 -8
  35. package/es/victory-primitives/tspan.d.ts +3 -3
  36. package/es/victory-primitives/types.d.ts +7 -7
  37. package/es/victory-primitives/whisker.d.ts +15 -15
  38. package/es/victory-theme/grayscale.d.ts +2 -2
  39. package/es/victory-theme/material.d.ts +2 -2
  40. package/es/victory-theme/types.d.ts +238 -238
  41. package/es/victory-theme/victory-theme.d.ts +5 -5
  42. package/es/victory-transition/victory-transition.d.ts +53 -53
  43. package/es/victory-util/add-events.d.ts +126 -126
  44. package/es/victory-util/axis.d.ts +50 -50
  45. package/es/victory-util/collection.d.ts +15 -15
  46. package/es/victory-util/common-props.d.ts +79 -79
  47. package/es/victory-util/data.d.ts +74 -74
  48. package/es/victory-util/default-transitions.d.ts +4 -4
  49. package/es/victory-util/domain.d.ts +90 -90
  50. package/es/victory-util/events.d.ts +64 -64
  51. package/es/victory-util/helpers.d.ts +96 -96
  52. package/es/victory-util/hooks/index.d.ts +2 -2
  53. package/es/victory-util/hooks/use-animation-state.d.ts +21 -21
  54. package/es/victory-util/hooks/use-previous-props.d.ts +1 -1
  55. package/es/victory-util/immutable.d.ts +11 -11
  56. package/es/victory-util/index.d.ts +27 -26
  57. package/es/victory-util/index.js +1 -0
  58. package/es/victory-util/label-helpers.d.ts +26 -26
  59. package/es/victory-util/line-helpers.d.ts +4 -4
  60. package/es/victory-util/log.d.ts +1 -1
  61. package/es/victory-util/merge-refs.d.ts +13 -0
  62. package/es/victory-util/merge-refs.js +23 -0
  63. package/es/victory-util/point-path-helpers.d.ts +9 -9
  64. package/es/victory-util/scale.d.ts +9 -9
  65. package/es/victory-util/selection.d.ts +28 -28
  66. package/es/victory-util/style.d.ts +18 -18
  67. package/es/victory-util/textsize.d.ts +35 -35
  68. package/es/victory-util/timer-context.d.ts +11 -11
  69. package/es/victory-util/timer.d.ts +16 -16
  70. package/es/victory-util/transitions.d.ts +48 -48
  71. package/es/victory-util/type-helpers.d.ts +9 -9
  72. package/es/victory-util/user-props.d.ts +26 -26
  73. package/es/victory-util/wrapper.d.ts +33 -33
  74. package/lib/index.d.ts +18 -17
  75. package/lib/index.js +16 -4
  76. package/lib/types/callbacks.d.ts +36 -36
  77. package/lib/types/prop-types.d.ts +130 -129
  78. package/lib/victory-accessible-group/victory-accessible-group.d.ts +10 -10
  79. package/lib/victory-animation/util.d.ts +66 -66
  80. package/lib/victory-animation/victory-animation.d.ts +34 -34
  81. package/lib/victory-clip-container/victory-clip-container.d.ts +46 -46
  82. package/lib/victory-container/victory-container.d.ts +62 -68
  83. package/lib/victory-container/victory-container.js +136 -163
  84. package/lib/victory-label/victory-label.d.ts +58 -58
  85. package/lib/victory-portal/portal-context.d.ts +12 -11
  86. package/lib/victory-portal/portal-context.js +40 -7
  87. package/lib/victory-portal/portal-outlet.d.ts +12 -0
  88. package/lib/victory-portal/portal-outlet.js +24 -0
  89. package/lib/victory-portal/portal.d.ts +9 -20
  90. package/lib/victory-portal/portal.js +6 -33
  91. package/lib/victory-portal/victory-portal.d.ts +9 -26
  92. package/lib/victory-portal/victory-portal.js +27 -44
  93. package/lib/victory-primitives/arc.d.ts +14 -14
  94. package/lib/victory-primitives/background.d.ts +13 -13
  95. package/lib/victory-primitives/border.d.ts +10 -10
  96. package/lib/victory-primitives/circle.d.ts +3 -3
  97. package/lib/victory-primitives/clip-path.d.ts +7 -7
  98. package/lib/victory-primitives/index.d.ts +14 -14
  99. package/lib/victory-primitives/line-segment.d.ts +11 -11
  100. package/lib/victory-primitives/line.d.ts +3 -3
  101. package/lib/victory-primitives/path.d.ts +3 -3
  102. package/lib/victory-primitives/point.d.ts +13 -13
  103. package/lib/victory-primitives/rect.d.ts +3 -3
  104. package/lib/victory-primitives/text.d.ts +8 -8
  105. package/lib/victory-primitives/tspan.d.ts +3 -3
  106. package/lib/victory-primitives/types.d.ts +7 -7
  107. package/lib/victory-primitives/whisker.d.ts +15 -15
  108. package/lib/victory-theme/grayscale.d.ts +2 -2
  109. package/lib/victory-theme/material.d.ts +2 -2
  110. package/lib/victory-theme/types.d.ts +238 -238
  111. package/lib/victory-theme/victory-theme.d.ts +5 -5
  112. package/lib/victory-transition/victory-transition.d.ts +53 -53
  113. package/lib/victory-util/add-events.d.ts +126 -126
  114. package/lib/victory-util/axis.d.ts +50 -50
  115. package/lib/victory-util/collection.d.ts +15 -15
  116. package/lib/victory-util/common-props.d.ts +79 -79
  117. package/lib/victory-util/data.d.ts +74 -74
  118. package/lib/victory-util/default-transitions.d.ts +4 -4
  119. package/lib/victory-util/domain.d.ts +90 -90
  120. package/lib/victory-util/events.d.ts +64 -64
  121. package/lib/victory-util/helpers.d.ts +96 -96
  122. package/lib/victory-util/hooks/index.d.ts +2 -2
  123. package/lib/victory-util/hooks/use-animation-state.d.ts +21 -21
  124. package/lib/victory-util/hooks/use-previous-props.d.ts +1 -1
  125. package/lib/victory-util/immutable.d.ts +11 -11
  126. package/lib/victory-util/index.d.ts +27 -26
  127. package/lib/victory-util/index.js +12 -0
  128. package/lib/victory-util/label-helpers.d.ts +26 -26
  129. package/lib/victory-util/line-helpers.d.ts +4 -4
  130. package/lib/victory-util/log.d.ts +1 -1
  131. package/lib/victory-util/merge-refs.d.ts +13 -0
  132. package/lib/victory-util/merge-refs.js +31 -0
  133. package/lib/victory-util/point-path-helpers.d.ts +9 -9
  134. package/lib/victory-util/scale.d.ts +9 -9
  135. package/lib/victory-util/selection.d.ts +28 -28
  136. package/lib/victory-util/style.d.ts +18 -18
  137. package/lib/victory-util/textsize.d.ts +35 -35
  138. package/lib/victory-util/timer-context.d.ts +11 -11
  139. package/lib/victory-util/timer.d.ts +16 -16
  140. package/lib/victory-util/transitions.d.ts +48 -48
  141. package/lib/victory-util/type-helpers.d.ts +9 -9
  142. package/lib/victory-util/user-props.d.ts +26 -26
  143. package/lib/victory-util/wrapper.d.ts +33 -33
  144. package/package.json +2 -5
  145. package/src/index.ts +2 -1
  146. package/src/types/prop-types.ts +7 -0
  147. package/src/victory-container/victory-container.tsx +168 -196
  148. package/src/victory-portal/portal-context.tsx +69 -0
  149. package/src/victory-portal/portal-outlet.tsx +25 -0
  150. package/src/victory-portal/portal.tsx +5 -42
  151. package/src/victory-portal/victory-portal.tsx +34 -64
  152. package/src/victory-util/index.ts +1 -0
  153. package/src/victory-util/merge-refs.ts +26 -0
  154. package/src/victory-portal/portal-context.ts +0 -14
@@ -1,47 +1,47 @@
1
- import React from "react";
2
- import { BlockProps } from "../victory-theme/victory-theme";
3
- import { OriginType } from "../victory-label/victory-label";
4
- export interface VictoryClipContainerProps {
5
- "aria-label"?: string;
6
- children?: React.ReactElement | React.ReactElement[];
7
- circleComponent?: React.ReactElement;
8
- className?: string;
9
- clipHeight?: number;
10
- clipId?: number | string;
11
- clipPadding?: BlockProps;
12
- clipPathComponent?: React.ReactElement;
13
- clipWidth?: number;
14
- events?: React.DOMAttributes<any>;
15
- groupComponent?: React.ReactElement;
16
- origin?: OriginType;
17
- polar?: boolean;
18
- radius?: number;
19
- rectComponent?: React.ReactElement;
20
- translateX?: number;
21
- translateY?: number;
22
- }
23
- export declare class VictoryClipContainer extends React.Component<VictoryClipContainerProps> {
24
- static displayName: string;
25
- static role: string;
26
- static defaultProps: {
27
- circleComponent: JSX.Element;
28
- rectComponent: JSX.Element;
29
- clipPathComponent: JSX.Element;
30
- groupComponent: JSX.Element;
31
- };
32
- clipId: VictoryClipContainerProps["clipId"];
33
- constructor(props: VictoryClipContainerProps);
34
- calculateAttributes(props: any): {
35
- x: number;
36
- y: number;
37
- width: number;
38
- height: number;
39
- };
40
- renderClippedGroup(props: any, clipId: any): React.DetailedReactHTMLElement<any, HTMLElement>;
41
- renderGroup(props: any): React.DetailedReactHTMLElement<any, HTMLElement>;
42
- renderClipComponent(props: any, clipId: any): React.DetailedReactHTMLElement<any, HTMLElement>;
43
- getClipValue(props: any, axis: any): any;
44
- getTranslateValue(props: any, axis: any): any;
45
- render(): React.DetailedReactHTMLElement<any, HTMLElement>;
46
- }
1
+ import React from "react";
2
+ import { BlockProps } from "../victory-theme/victory-theme";
3
+ import { OriginType } from "../victory-label/victory-label";
4
+ export interface VictoryClipContainerProps {
5
+ "aria-label"?: string;
6
+ children?: React.ReactElement | React.ReactElement[];
7
+ circleComponent?: React.ReactElement;
8
+ className?: string;
9
+ clipHeight?: number;
10
+ clipId?: number | string;
11
+ clipPadding?: BlockProps;
12
+ clipPathComponent?: React.ReactElement;
13
+ clipWidth?: number;
14
+ events?: React.DOMAttributes<any>;
15
+ groupComponent?: React.ReactElement;
16
+ origin?: OriginType;
17
+ polar?: boolean;
18
+ radius?: number;
19
+ rectComponent?: React.ReactElement;
20
+ translateX?: number;
21
+ translateY?: number;
22
+ }
23
+ export declare class VictoryClipContainer extends React.Component<VictoryClipContainerProps> {
24
+ static displayName: string;
25
+ static role: string;
26
+ static defaultProps: {
27
+ circleComponent: JSX.Element;
28
+ rectComponent: JSX.Element;
29
+ clipPathComponent: JSX.Element;
30
+ groupComponent: JSX.Element;
31
+ };
32
+ clipId: VictoryClipContainerProps["clipId"];
33
+ constructor(props: VictoryClipContainerProps);
34
+ calculateAttributes(props: any): {
35
+ x: number;
36
+ y: number;
37
+ width: number;
38
+ height: number;
39
+ };
40
+ renderClippedGroup(props: any, clipId: any): React.DetailedReactHTMLElement<any, HTMLElement>;
41
+ renderGroup(props: any): React.DetailedReactHTMLElement<any, HTMLElement>;
42
+ renderClipComponent(props: any, clipId: any): React.DetailedReactHTMLElement<any, HTMLElement>;
43
+ getClipValue(props: any, axis: any): any;
44
+ getTranslateValue(props: any, axis: any): any;
45
+ render(): React.DetailedReactHTMLElement<any, HTMLElement>;
46
+ }
47
47
  //# sourceMappingURL=victory-clip-container.d.ts.map
@@ -1,69 +1,63 @@
1
- import React from "react";
2
- import { OriginType } from "../victory-label/victory-label";
3
- import { D3Scale } from "../types/prop-types";
4
- import { VictoryThemeDefinition } from "../victory-theme/types";
5
- export interface VictoryContainerProps {
6
- "aria-describedby"?: string;
7
- "aria-labelledby"?: string;
8
- children?: React.ReactElement | React.ReactElement[];
9
- className?: string;
10
- containerId?: number | string;
11
- containerRef?: React.Ref<HTMLElement>;
12
- desc?: string;
13
- events?: React.DOMAttributes<any>;
14
- height?: number;
15
- name?: string;
16
- origin?: OriginType;
17
- ouiaId?: number | string;
18
- ouiaSafe?: boolean;
19
- ouiaType?: string;
20
- polar?: boolean;
21
- portalComponent?: React.ReactElement;
22
- portalZIndex?: number;
23
- preserveAspectRatio?: string;
24
- responsive?: boolean;
25
- role?: string;
26
- scale?: {
27
- x?: D3Scale;
28
- y?: D3Scale;
29
- };
30
- style?: React.CSSProperties;
31
- tabIndex?: number;
32
- theme?: VictoryThemeDefinition;
33
- title?: string;
34
- width?: number;
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;
45
- };
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
- }
1
+ import React from "react";
2
+ import { OriginType } from "../victory-label/victory-label";
3
+ import { D3Scale } from "../types/prop-types";
4
+ import { VictoryThemeDefinition } from "../victory-theme/types";
5
+ export interface VictoryContainerProps {
6
+ "aria-describedby"?: string;
7
+ "aria-labelledby"?: string;
8
+ children?: React.ReactElement | React.ReactElement[];
9
+ className?: string;
10
+ containerId?: number | string;
11
+ containerRef?: React.Ref<HTMLElement>;
12
+ desc?: string;
13
+ events?: React.DOMAttributes<any>;
14
+ height?: number;
15
+ name?: string;
16
+ origin?: OriginType;
17
+ polar?: boolean;
18
+ portalComponent?: React.ReactElement;
19
+ portalZIndex?: number;
20
+ preserveAspectRatio?: string;
21
+ responsive?: boolean;
22
+ role?: string;
23
+ scale?: {
24
+ x?: D3Scale;
25
+ y?: D3Scale;
26
+ };
27
+ style?: React.CSSProperties;
28
+ tabIndex?: number;
29
+ theme?: VictoryThemeDefinition;
30
+ title?: string;
31
+ width?: number;
32
+ ouiaId?: number | string;
33
+ ouiaSafe?: boolean;
34
+ ouiaType?: string;
35
+ }
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;
51
+ };
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
@@ -1,179 +1,151 @@
1
- import _isObject from "lodash/isObject";
2
1
  import _uniqueId from "lodash/uniqueId";
3
- import _defaults from "lodash/defaults";
4
2
  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); }
5
- import React from "react";
3
+ import React, { useRef } from "react";
6
4
  import { Portal } from "../victory-portal/portal";
7
- import { PortalContext } from "../victory-portal/portal-context";
8
- import TimerContext from "../victory-util/timer-context";
9
- import * as Helpers from "../victory-util/helpers";
10
5
  import * as UserProps from "../victory-util/user-props";
11
- export class VictoryContainer extends React.Component {
12
- static displayName = "VictoryContainer";
13
- static role = "container";
14
- static defaultProps = {
15
- className: "VictoryContainer",
16
- portalComponent: /*#__PURE__*/React.createElement(Portal, null),
17
- portalZIndex: 99,
18
- responsive: true,
19
- role: "img"
6
+ import { mergeRefs } from "../victory-util";
7
+ import { PortalOutlet } from "../victory-portal/portal-outlet";
8
+ import { PortalProvider } from "../victory-portal/portal-context";
9
+ const defaultProps = {
10
+ className: "VictoryContainer",
11
+ portalComponent: /*#__PURE__*/React.createElement(Portal, null),
12
+ portalZIndex: 99,
13
+ responsive: true,
14
+ role: "img"
15
+ };
16
+ export function useVictoryContainer(initialProps) {
17
+ const props = {
18
+ ...defaultProps,
19
+ ...initialProps
20
20
  };
21
- static contextType = TimerContext;
21
+ const {
22
+ title,
23
+ desc,
24
+ width,
25
+ height,
26
+ responsive
27
+ } = props;
28
+ const localContainerRef = useRef(null);
22
29
 
23
- // @ts-expect-error Ref will be initialized on mount
24
-
25
- // @ts-expect-error Ref will be initialized on mount
26
-
27
- constructor(props) {
28
- super(props);
29
- this.containerId = !_isObject(props) || props.containerId === undefined ? _uniqueId("victory-container-") : props.containerId;
30
- this.shouldHandleWheel = !!(props && props.events && props.events.onWheel);
31
- }
32
- savePortalRef = portal => {
33
- this.portalRef = portal;
34
- return portal;
30
+ // Generated ID stored in ref because it needs to persist across renders
31
+ const generatedId = useRef(_uniqueId("victory-container-"));
32
+ const containerId = props.containerId ?? generatedId.current;
33
+ const getIdForElement = elName => `${containerId}-${elName}`;
34
+ const userProps = UserProps.getSafeUserProps(props);
35
+ const dimensions = responsive ? {
36
+ width: "100%",
37
+ height: "100%"
38
+ } : {
39
+ width,
40
+ height
35
41
  };
36
- portalUpdate = (key, el) => this.portalRef.portalUpdate(key, el);
37
- portalRegister = () => this.portalRef.portalRegister();
38
- portalDeregister = key => this.portalRef.portalDeregister(key);
39
- saveContainerRef = container => {
40
- if (Helpers.isFunction(this.props.containerRef)) {
41
- this.props.containerRef(container);
42
- }
43
- this.containerRef = container;
44
- return container;
42
+ const viewBox = responsive ? `0 0 ${width} ${height}` : undefined;
43
+ const preserveAspectRatio = responsive ? props.preserveAspectRatio : undefined;
44
+ const ariaLabelledBy = [title && getIdForElement("title"), props["aria-labelledby"]].filter(Boolean).join(" ") || undefined;
45
+ const ariaDescribedBy = [desc && getIdForElement("desc"), props["aria-describedby"]].filter(Boolean).join(" ") || undefined;
46
+ const titleId = getIdForElement("title");
47
+ const descId = getIdForElement("desc");
48
+ return {
49
+ ...props,
50
+ titleId,
51
+ descId,
52
+ dimensions,
53
+ viewBox,
54
+ preserveAspectRatio,
55
+ ariaLabelledBy,
56
+ ariaDescribedBy,
57
+ userProps,
58
+ localContainerRef
45
59
  };
46
- handleWheel = e => e.preventDefault();
47
- componentDidMount() {
48
- if (this.shouldHandleWheel && this.containerRef) {
49
- this.containerRef.addEventListener("wheel", this.handleWheel);
50
- }
51
- }
52
- componentWillUnmount() {
53
- if (this.shouldHandleWheel && this.containerRef) {
54
- this.containerRef.removeEventListener("wheel", this.handleWheel);
55
- }
56
- }
57
- getIdForElement(elementName) {
58
- return `${this.containerId}-${elementName}`;
59
- }
60
-
61
- // overridden in custom containers
62
- getChildren(props) {
63
- return props.children;
64
- }
65
-
66
- // Get props defined by the Open UI Automation (OUIA) 1.0-RC spec
67
- // See https://ouia.readthedocs.io/en/latest/README.html#ouia-component
68
- getOUIAProps(props) {
69
- const {
70
- ouiaId,
71
- ouiaSafe,
72
- ouiaType
73
- } = props;
74
- return {
75
- ...(ouiaId && {
76
- "data-ouia-component-id": ouiaId
77
- }),
78
- ...(ouiaType && {
79
- "data-ouia-component-type": ouiaType
80
- }),
81
- ...(ouiaSafe !== undefined && {
82
- "data-ouia-safe": ouiaSafe
83
- })
60
+ }
61
+ export const VictoryContainer = initialProps => {
62
+ const {
63
+ role,
64
+ title,
65
+ desc,
66
+ children,
67
+ className,
68
+ portalZIndex,
69
+ portalComponent,
70
+ width,
71
+ height,
72
+ style,
73
+ tabIndex,
74
+ responsive,
75
+ events,
76
+ ouiaId,
77
+ ouiaSafe,
78
+ ouiaType,
79
+ dimensions,
80
+ ariaDescribedBy,
81
+ ariaLabelledBy,
82
+ viewBox,
83
+ preserveAspectRatio,
84
+ userProps,
85
+ titleId,
86
+ descId,
87
+ containerRef,
88
+ localContainerRef
89
+ } = useVictoryContainer(initialProps);
90
+ React.useEffect(() => {
91
+ if (!events?.onWheel) return;
92
+ const handleWheel = e => e.preventDefault();
93
+ const container = localContainerRef?.current;
94
+ container?.addEventListener("wheel", handleWheel);
95
+ return () => {
96
+ container?.removeEventListener("wheel", handleWheel);
84
97
  };
85
- }
86
- renderContainer(props, svgProps, style) {
87
- const {
88
- title,
89
- desc,
90
- portalComponent,
91
- className,
92
- width,
93
- height,
94
- portalZIndex,
95
- responsive
96
- } = props;
97
- const children = this.getChildren(props);
98
- const dimensions = responsive ? {
99
- width: "100%",
100
- height: "100%"
101
- } : {
102
- width,
103
- height
104
- };
105
- const divStyle = Object.assign({
98
+ // eslint-disable-next-line react-hooks/exhaustive-deps
99
+ }, []);
100
+ return /*#__PURE__*/React.createElement(PortalProvider, null, /*#__PURE__*/React.createElement("div", {
101
+ className: className,
102
+ style: {
103
+ ...style,
104
+ width: responsive ? style?.width : dimensions.width,
105
+ height: responsive ? style?.height : dimensions.height,
106
106
  pointerEvents: "none",
107
107
  touchAction: "none",
108
108
  position: "relative"
109
- }, dimensions);
110
- const portalDivStyle = Object.assign({
109
+ },
110
+ "data-ouia-component-id": ouiaId,
111
+ "data-ouia-component-type": ouiaType,
112
+ "data-ouia-safe": ouiaSafe,
113
+ ref: mergeRefs([localContainerRef, containerRef])
114
+ }, /*#__PURE__*/React.createElement("svg", _extends({
115
+ width: width,
116
+ height: height,
117
+ tabIndex: tabIndex,
118
+ role: role,
119
+ "aria-labelledby": ariaLabelledBy,
120
+ "aria-describedby": ariaDescribedBy,
121
+ viewBox: viewBox,
122
+ preserveAspectRatio: preserveAspectRatio,
123
+ style: {
124
+ ...dimensions,
125
+ pointerEvents: "all"
126
+ }
127
+ }, userProps, events), title ? /*#__PURE__*/React.createElement("title", {
128
+ id: titleId
129
+ }, title) : null, desc ? /*#__PURE__*/React.createElement("desc", {
130
+ id: descId
131
+ }, desc) : null, children), /*#__PURE__*/React.createElement("div", {
132
+ style: {
133
+ ...dimensions,
111
134
  zIndex: portalZIndex,
112
135
  position: "absolute",
113
136
  top: 0,
114
137
  left: 0
115
- }, dimensions);
116
- const svgStyle = Object.assign({
117
- pointerEvents: "all"
118
- }, dimensions);
119
- const portalSvgStyle = Object.assign({
138
+ }
139
+ }, /*#__PURE__*/React.createElement(PortalOutlet, {
140
+ as: portalComponent,
141
+ width: width,
142
+ height: height,
143
+ viewBox: viewBox,
144
+ preserveAspectRatio: preserveAspectRatio,
145
+ style: {
146
+ ...dimensions,
120
147
  overflow: "visible"
121
- }, dimensions);
122
- const portalProps = {
123
- width,
124
- height,
125
- viewBox: svgProps.viewBox,
126
- preserveAspectRatio: svgProps.preserveAspectRatio,
127
- style: portalSvgStyle
128
- };
129
- return /*#__PURE__*/React.createElement(PortalContext.Provider, {
130
- value: {
131
- portalUpdate: this.portalUpdate,
132
- portalRegister: this.portalRegister,
133
- portalDeregister: this.portalDeregister
134
- }
135
- }, /*#__PURE__*/React.createElement("div", _extends({
136
- style: _defaults({}, style, divStyle),
137
- className: className,
138
- ref: this.saveContainerRef
139
- }, this.getOUIAProps(props)), /*#__PURE__*/React.createElement("svg", _extends({}, svgProps, {
140
- style: svgStyle
141
- }), title ? /*#__PURE__*/React.createElement("title", {
142
- id: this.getIdForElement("title")
143
- }, title) : null, desc ? /*#__PURE__*/React.createElement("desc", {
144
- id: this.getIdForElement("desc")
145
- }, desc) : null, children), /*#__PURE__*/React.createElement("div", {
146
- style: portalDivStyle
147
- }, /*#__PURE__*/React.cloneElement(portalComponent, {
148
- ...portalProps,
149
- ref: this.savePortalRef
150
- }))));
151
- }
152
- render() {
153
- const {
154
- width,
155
- height,
156
- responsive,
157
- events,
158
- title,
159
- desc,
160
- tabIndex,
161
- preserveAspectRatio,
162
- role
163
- } = this.props;
164
- const style = responsive ? this.props.style : Helpers.omit(this.props.style, ["height", "width"]);
165
- const userProps = UserProps.getSafeUserProps(this.props);
166
- const svgProps = Object.assign({
167
- width,
168
- height,
169
- tabIndex,
170
- role,
171
- "aria-labelledby": [title && this.getIdForElement("title"), this.props["aria-labelledby"]].filter(Boolean).join(" ") || undefined,
172
- "aria-describedby": [desc && this.getIdForElement("desc"), this.props["aria-describedby"]].filter(Boolean).join(" ") || undefined,
173
- viewBox: responsive ? `0 0 ${width} ${height}` : undefined,
174
- preserveAspectRatio: responsive ? preserveAspectRatio : undefined,
175
- ...userProps
176
- }, events);
177
- return this.renderContainer(this.props, svgProps, style);
178
- }
179
- }
148
+ }
149
+ }))));
150
+ };
151
+ VictoryContainer.role = "container";
@@ -1,59 +1,59 @@
1
- import React from "react";
2
- import { NumberOrCallback, StringOrCallback, StringOrNumberOrCallback } from "../types/callbacks";
3
- import { ValueOrAccessor } from "../types/prop-types";
4
- import { PaddingProps, VerticalAnchorType, VictoryLabelStyleObject } from "../victory-theme/victory-theme";
5
- export declare type TextAnchorType = "start" | "middle" | "end" | "inherit";
6
- export declare type OriginType = {
7
- x: number;
8
- y: number;
9
- };
10
- export declare type LabelOrientationType = "parallel" | "perpendicular" | "vertical";
11
- export interface VictoryLabelProps {
12
- angle?: StringOrNumberOrCallback;
13
- ariaLabel?: StringOrCallback;
14
- backgroundComponent?: React.ReactElement;
15
- backgroundStyle?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
16
- backgroundPadding?: PaddingProps | PaddingProps[];
17
- capHeight?: StringOrNumberOrCallback;
18
- children?: StringOrNumberOrCallback;
19
- className?: string;
20
- datum?: Record<string, any>;
21
- data?: any[];
22
- desc?: string;
23
- direction?: string;
24
- disableInlineStyles?: boolean;
25
- events?: React.DOMAttributes<any>;
26
- groupComponent?: React.ReactElement;
27
- id?: StringOrNumberOrCallback;
28
- inline?: boolean;
29
- labelPlacement?: LabelOrientationType;
30
- lineHeight?: StringOrNumberOrCallback | (string | number)[];
31
- origin?: OriginType;
32
- polar?: boolean;
33
- renderInPortal?: boolean;
34
- style?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
35
- tabIndex?: NumberOrCallback;
36
- text?: string[] | StringOrNumberOrCallback;
37
- textComponent?: React.ReactElement;
38
- textAnchor?: ValueOrAccessor<TextAnchorType>;
39
- title?: string;
40
- transform?: ValueOrAccessor<string | object>;
41
- tspanComponent?: React.ReactElement;
42
- verticalAnchor?: ValueOrAccessor<VerticalAnchorType>;
43
- x?: number;
44
- y?: number;
45
- dx?: StringOrNumberOrCallback;
46
- dy?: StringOrNumberOrCallback;
47
- }
48
- declare const defaultStyles: {
49
- fill: string;
50
- fontSize: number;
51
- fontFamily: string;
52
- stroke: string;
53
- };
54
- export declare const VictoryLabel: {
55
- role: string;
56
- defaultStyles: typeof defaultStyles;
57
- } & React.FC<VictoryLabelProps>;
58
- export {};
1
+ import React from "react";
2
+ import { NumberOrCallback, StringOrCallback, StringOrNumberOrCallback } from "../types/callbacks";
3
+ import { ValueOrAccessor } from "../types/prop-types";
4
+ import { PaddingProps, VerticalAnchorType, VictoryLabelStyleObject } from "../victory-theme/victory-theme";
5
+ export declare type TextAnchorType = "start" | "middle" | "end" | "inherit";
6
+ export declare type OriginType = {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ export declare type LabelOrientationType = "parallel" | "perpendicular" | "vertical";
11
+ export interface VictoryLabelProps {
12
+ angle?: StringOrNumberOrCallback;
13
+ ariaLabel?: StringOrCallback;
14
+ backgroundComponent?: React.ReactElement;
15
+ backgroundStyle?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
16
+ backgroundPadding?: PaddingProps | PaddingProps[];
17
+ capHeight?: StringOrNumberOrCallback;
18
+ children?: StringOrNumberOrCallback;
19
+ className?: string;
20
+ datum?: Record<string, any>;
21
+ data?: any[];
22
+ desc?: string;
23
+ direction?: string;
24
+ disableInlineStyles?: boolean;
25
+ events?: React.DOMAttributes<any>;
26
+ groupComponent?: React.ReactElement;
27
+ id?: StringOrNumberOrCallback;
28
+ inline?: boolean;
29
+ labelPlacement?: LabelOrientationType;
30
+ lineHeight?: StringOrNumberOrCallback | (string | number)[];
31
+ origin?: OriginType;
32
+ polar?: boolean;
33
+ renderInPortal?: boolean;
34
+ style?: VictoryLabelStyleObject | VictoryLabelStyleObject[];
35
+ tabIndex?: NumberOrCallback;
36
+ text?: string[] | StringOrNumberOrCallback;
37
+ textComponent?: React.ReactElement;
38
+ textAnchor?: ValueOrAccessor<TextAnchorType>;
39
+ title?: string;
40
+ transform?: ValueOrAccessor<string | object>;
41
+ tspanComponent?: React.ReactElement;
42
+ verticalAnchor?: ValueOrAccessor<VerticalAnchorType>;
43
+ x?: number;
44
+ y?: number;
45
+ dx?: StringOrNumberOrCallback;
46
+ dy?: StringOrNumberOrCallback;
47
+ }
48
+ declare const defaultStyles: {
49
+ fill: string;
50
+ fontSize: number;
51
+ fontFamily: string;
52
+ stroke: string;
53
+ };
54
+ export declare const VictoryLabel: {
55
+ role: string;
56
+ defaultStyles: typeof defaultStyles;
57
+ } & React.FC<VictoryLabelProps>;
58
+ export {};
59
59
  //# sourceMappingURL=victory-label.d.ts.map