victory-cursor-container 36.9.2-next.3 → 36.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,22 +1,14 @@
1
1
  # victory-cursor-container
2
2
 
3
- ## 36.9.2-next.3
3
+ ## 36.9.2
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 65d02419f: Refactor containers and portal to function components
8
- - 7efd582cc: Replace lodash array utils with native code
9
- - 9cdaf2c08: Replace lodash values and mapValues with native code
10
- - 6e34169a5: Replace lodash isFunction with native code
11
- - Updated dependencies [7da790934]
12
- - Updated dependencies [3f2da66e3]
13
- - Updated dependencies [c13308624]
14
- - Updated dependencies [65d02419f]
15
- - Updated dependencies [7efd582cc]
16
- - Updated dependencies [9cdaf2c08]
17
- - Updated dependencies [f6f7cc515]
18
- - Updated dependencies [6e34169a5]
19
- - victory-core@36.9.2-next.3
7
+ - Replace lodash array utils with native code ([#2810](https://github.com/FormidableLabs/victory/pull/2810))
8
+
9
+ * Replace lodash values and mapValues with native code ([#2808](https://github.com/FormidableLabs/victory/pull/2808))
10
+
11
+ - Replace lodash isFunction with native code ([#2802](https://github.com/FormidableLabs/victory/pull/2802))
20
12
 
21
13
  ## 36.9.1
22
14
 
package/README.md CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  `victory-cursor-container@^30.0.0` exports `VictoryCursorContainer`, `cursorContainerMixin` and `CursorHelpers`
4
4
 
5
- To view documentation for `VictoryCursorContainer` please see https://formidable.com/open-source/victory/docs/victory-cursor-container
5
+ To view documentation for `VictoryCursorContainer` please see https://commerce.nearform.com/open-source/victory/docs/victory-cursor-container
6
6
 
7
- To suggest an addition or correction to this documentation please see https://github.com/FormidableLabs/victory/blob/main/docs/src/content/docs/victory-cursor-container.md
7
+ To suggest an addition or correction to this documentation please see https://github.com/FormidableLabs/victory/blob/main/docs/src/content/docs/victory-cursor-container.md
@@ -4458,6 +4458,7 @@ __webpack_require__.r(__webpack_exports__);
4458
4458
  /* harmony export */ "containsNumbers": () => (/* binding */ containsNumbers),
4459
4459
  /* harmony export */ "containsOnlyStrings": () => (/* binding */ containsOnlyStrings),
4460
4460
  /* harmony export */ "containsStrings": () => (/* binding */ containsStrings),
4461
+ /* harmony export */ "difference": () => (/* binding */ difference),
4461
4462
  /* harmony export */ "getMaxValue": () => (/* binding */ getMaxValue),
4462
4463
  /* harmony export */ "getMinValue": () => (/* binding */ getMinValue),
4463
4464
  /* harmony export */ "isArrayOfArrays": () => (/* binding */ isArrayOfArrays),
@@ -4499,6 +4500,22 @@ function containsOnlyStrings(collection) {
4499
4500
  return typeof value === "string";
4500
4501
  });
4501
4502
  }
4503
+ /**
4504
+ * Creates an array of array values not included in the other given arrays
4505
+ * @param a The array to inspect
4506
+ * @param b The values to exclude
4507
+ * @returns The new array of filtered values
4508
+ */
4509
+
4510
+ function difference(a, b) {
4511
+ if (a && b) {
4512
+ return a.filter(function (value) {
4513
+ return !b.includes(value);
4514
+ });
4515
+ }
4516
+
4517
+ return [];
4518
+ }
4502
4519
  function isArrayOfArrays(collection) {
4503
4520
  return isNonEmptyArray(collection) && collection.every(Array.isArray);
4504
4521
  }
@@ -4549,6 +4566,7 @@ __webpack_require__.r(__webpack_exports__);
4549
4566
  /* harmony export */ "getRadius": () => (/* binding */ getRadius),
4550
4567
  /* harmony export */ "getRange": () => (/* binding */ getRange),
4551
4568
  /* harmony export */ "getStyles": () => (/* binding */ getStyles),
4569
+ /* harmony export */ "invert": () => (/* binding */ invert),
4552
4570
  /* harmony export */ "isFunction": () => (/* binding */ isFunction),
4553
4571
  /* harmony export */ "isHorizontal": () => (/* binding */ isHorizontal),
4554
4572
  /* harmony export */ "isNil": () => (/* binding */ isNil),
@@ -4599,6 +4617,18 @@ function getPolarRange(props, axis) {
4599
4617
  return [props.innerRadius || 0, getRadius(props)];
4600
4618
  } // Exported Functions
4601
4619
 
4620
+ /**
4621
+ * Creates an object composed of the inverted keys and values of object.
4622
+ * If object contains duplicate values, subsequent values overwrite property assignments of previous values.
4623
+ */
4624
+
4625
+
4626
+ function invert(original) {
4627
+ return Object.entries(original).reduce(function (acc, current) {
4628
+ acc[current[1]] = current[0];
4629
+ return acc;
4630
+ }, {});
4631
+ }
4602
4632
  /**
4603
4633
  * creates an object with some keys excluded
4604
4634
  * replacement for lodash.omit for performance. does not mimic the entire lodash.omit api
@@ -4607,7 +4637,6 @@ function getPolarRange(props, axis) {
4607
4637
  * @returns {Object} new object with same properties as originalObject
4608
4638
  */
4609
4639
 
4610
-
4611
4640
  function omit(originalObject) {
4612
4641
  var ks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
4613
4642
  // code based on babel's _objectWithoutProperties
@@ -1,33 +1,33 @@
1
- /// <reference types="lodash" />
2
- import { Selection } from "victory-core";
3
- declare class CursorHelpersClass {
4
- getDimension(props: any): any;
5
- withinBounds(point: any, bounds: any): boolean;
6
- private handleMouseMove;
7
- onMouseMove: import("lodash").DebouncedFunc<(evt: any, targetProps: any) => {
8
- target: string;
9
- eventKey: string;
10
- mutation: () => {
11
- cursorValue: Selection.SVGCoordinateType | null;
12
- parentSVG: any;
13
- };
14
- }[]>;
15
- onMouseLeave: (evt: any, targetProps: any) => {
16
- target: string;
17
- eventKey: string;
18
- mutation: () => {
19
- cursorValue: Selection.SVGCoordinateType | null;
20
- parentSVG: any;
21
- };
22
- }[];
23
- onTouchEnd: (evt: any, targetProps: any) => {
24
- target: string;
25
- eventKey: string;
26
- mutation: () => {
27
- cursorValue: null;
28
- };
29
- }[];
30
- }
31
- export declare const CursorHelpers: CursorHelpersClass;
32
- export {};
1
+ /// <reference types="lodash" />
2
+ import { Selection } from "victory-core";
3
+ declare class CursorHelpersClass {
4
+ getDimension(props: any): any;
5
+ withinBounds(point: any, bounds: any): boolean;
6
+ private handleMouseMove;
7
+ onMouseMove: import("lodash").DebouncedFunc<(evt: any, targetProps: any) => {
8
+ target: string;
9
+ eventKey: string;
10
+ mutation: () => {
11
+ cursorValue: Selection.SVGCoordinateType | null;
12
+ parentSVG: any;
13
+ };
14
+ }[]>;
15
+ onMouseLeave: (evt: any, targetProps: any) => {
16
+ target: string;
17
+ eventKey: string;
18
+ mutation: () => {
19
+ cursorValue: Selection.SVGCoordinateType | null;
20
+ parentSVG: any;
21
+ };
22
+ }[];
23
+ onTouchEnd: (evt: any, targetProps: any) => {
24
+ target: string;
25
+ eventKey: string;
26
+ mutation: () => {
27
+ cursorValue: null;
28
+ };
29
+ }[];
30
+ }
31
+ export declare const CursorHelpers: CursorHelpersClass;
32
+ export {};
33
33
  //# sourceMappingURL=cursor-helpers.d.ts.map
package/es/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./cursor-helpers";
2
- export * from "./victory-cursor-container";
1
+ export * from "./cursor-helpers";
2
+ export * from "./victory-cursor-container";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,134 +1,134 @@
1
- import React from "react";
2
- import { VictoryContainer, VictoryContainerProps, CoordinatesPropType, VictoryLabelProps, ValueOrAccessor } from "victory-core";
3
- export declare type CursorCoordinatesPropType = CoordinatesPropType | number;
4
- export interface VictoryCursorContainerProps extends VictoryContainerProps {
5
- cursorComponent?: React.ReactElement;
6
- cursorDimension?: "x" | "y";
7
- cursorLabel?: ValueOrAccessor<VictoryLabelProps["text"]>;
8
- cursorLabelComponent?: React.ReactElement;
9
- cursorLabelOffset?: CursorCoordinatesPropType;
10
- defaultCursorValue?: CursorCoordinatesPropType;
11
- disable?: boolean;
12
- onCursorChange?: (value: CursorCoordinatesPropType, props: VictoryCursorContainerProps) => void;
13
- }
14
- declare type ComponentClass<TProps> = {
15
- new (props: TProps): React.Component<TProps>;
16
- };
17
- export declare function cursorContainerMixin<TBase extends ComponentClass<TProps>, TProps extends VictoryCursorContainerProps>(Base: TBase): {
18
- new (props: TProps): {
19
- getCursorPosition(props: any): any;
20
- getCursorLabelOffset(props: any): any;
21
- getPadding(props: any): {
22
- top: any;
23
- bottom: any;
24
- left: any;
25
- right: any;
26
- };
27
- getCursorElements(props: any): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
28
- getChildren(props: any): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment)[];
29
- context: unknown;
30
- setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<TProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
31
- forceUpdate(callback?: (() => void) | undefined): void;
32
- render(): React.ReactNode;
33
- readonly props: Readonly<TProps>;
34
- state: Readonly<{}>;
35
- refs: {
36
- [key: string]: React.ReactInstance;
37
- };
38
- componentDidMount?(): void;
39
- shouldComponentUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): boolean;
40
- componentWillUnmount?(): void;
41
- componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
42
- getSnapshotBeforeUpdate?(prevProps: Readonly<TProps>, prevState: Readonly<{}>): any;
43
- componentDidUpdate?(prevProps: Readonly<TProps>, prevState: Readonly<{}>, snapshot?: any): void;
44
- componentWillMount?(): void;
45
- UNSAFE_componentWillMount?(): void;
46
- componentWillReceiveProps?(nextProps: Readonly<TProps>, nextContext: any): void;
47
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TProps>, nextContext: any): void;
48
- componentWillUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): void;
49
- UNSAFE_componentWillUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): void;
50
- };
51
- displayName: string;
52
- defaultProps: {
53
- cursorLabelComponent: JSX.Element;
54
- cursorLabelOffset: {
55
- x: number;
56
- y: number;
57
- };
58
- cursorComponent: JSX.Element;
59
- className: string;
60
- portalComponent: JSX.Element;
61
- portalZIndex: number;
62
- responsive: boolean;
63
- role: string;
64
- };
65
- defaultEvents: (props: any) => {
66
- target: string;
67
- eventHandlers: {
68
- onMouseLeave: (evt: any, targetProps: any) => {};
69
- onTouchCancel: () => never[];
70
- onMouseMove: (evt: any, targetProps: any) => {} | undefined;
71
- onTouchMove: (evt: any, targetProps: any) => {} | undefined;
72
- };
73
- }[];
74
- } & TBase;
75
- export declare const VictoryCursorContainer: {
76
- new (props: VictoryCursorContainerProps): {
77
- getCursorPosition(props: any): any;
78
- getCursorLabelOffset(props: any): any;
79
- getPadding(props: any): {
80
- top: any;
81
- bottom: any;
82
- left: any;
83
- right: any;
84
- };
85
- getCursorElements(props: any): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
86
- getChildren(props: any): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment)[];
87
- context: unknown;
88
- setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<VictoryCursorContainerProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
89
- forceUpdate(callback?: (() => void) | undefined): void;
90
- render(): React.ReactNode;
91
- readonly props: Readonly<VictoryCursorContainerProps>;
92
- state: Readonly<{}>;
93
- refs: {
94
- [key: string]: React.ReactInstance;
95
- };
96
- componentDidMount?(): void;
97
- shouldComponentUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): boolean;
98
- componentWillUnmount?(): void;
99
- componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
100
- getSnapshotBeforeUpdate?(prevProps: Readonly<VictoryCursorContainerProps>, prevState: Readonly<{}>): any;
101
- componentDidUpdate?(prevProps: Readonly<VictoryCursorContainerProps>, prevState: Readonly<{}>, snapshot?: any): void;
102
- componentWillMount?(): void;
103
- UNSAFE_componentWillMount?(): void;
104
- componentWillReceiveProps?(nextProps: Readonly<VictoryCursorContainerProps>, nextContext: any): void;
105
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<VictoryCursorContainerProps>, nextContext: any): void;
106
- componentWillUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): void;
107
- UNSAFE_componentWillUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): void;
108
- };
109
- displayName: string;
110
- defaultProps: {
111
- cursorLabelComponent: JSX.Element;
112
- cursorLabelOffset: {
113
- x: number;
114
- y: number;
115
- };
116
- cursorComponent: JSX.Element;
117
- className: string;
118
- portalComponent: JSX.Element;
119
- portalZIndex: number;
120
- responsive: boolean;
121
- role: string;
122
- };
123
- defaultEvents: (props: any) => {
124
- target: string;
125
- eventHandlers: {
126
- onMouseLeave: (evt: any, targetProps: any) => {};
127
- onTouchCancel: () => never[];
128
- onMouseMove: (evt: any, targetProps: any) => {} | undefined;
129
- onTouchMove: (evt: any, targetProps: any) => {} | undefined;
130
- };
131
- }[];
132
- } & typeof VictoryContainer;
133
- export {};
1
+ import React from "react";
2
+ import { VictoryContainer, VictoryContainerProps, CoordinatesPropType, VictoryLabelProps, ValueOrAccessor } from "victory-core";
3
+ export declare type CursorCoordinatesPropType = CoordinatesPropType | number;
4
+ export interface VictoryCursorContainerProps extends VictoryContainerProps {
5
+ cursorComponent?: React.ReactElement;
6
+ cursorDimension?: "x" | "y";
7
+ cursorLabel?: ValueOrAccessor<VictoryLabelProps["text"]>;
8
+ cursorLabelComponent?: React.ReactElement;
9
+ cursorLabelOffset?: CursorCoordinatesPropType;
10
+ defaultCursorValue?: CursorCoordinatesPropType;
11
+ disable?: boolean;
12
+ onCursorChange?: (value: CursorCoordinatesPropType, props: VictoryCursorContainerProps) => void;
13
+ }
14
+ declare type ComponentClass<TProps> = {
15
+ new (props: TProps): React.Component<TProps>;
16
+ };
17
+ export declare function cursorContainerMixin<TBase extends ComponentClass<TProps>, TProps extends VictoryCursorContainerProps>(Base: TBase): {
18
+ new (props: TProps): {
19
+ getCursorPosition(props: any): any;
20
+ getCursorLabelOffset(props: any): any;
21
+ getPadding(props: any): {
22
+ top: any;
23
+ bottom: any;
24
+ left: any;
25
+ right: any;
26
+ };
27
+ getCursorElements(props: any): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
28
+ getChildren(props: any): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment)[];
29
+ context: unknown;
30
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<TProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
31
+ forceUpdate(callback?: (() => void) | undefined): void;
32
+ render(): React.ReactNode;
33
+ readonly props: Readonly<TProps>;
34
+ state: Readonly<{}>;
35
+ refs: {
36
+ [key: string]: React.ReactInstance;
37
+ };
38
+ componentDidMount?(): void;
39
+ shouldComponentUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): boolean;
40
+ componentWillUnmount?(): void;
41
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
42
+ getSnapshotBeforeUpdate?(prevProps: Readonly<TProps>, prevState: Readonly<{}>): any;
43
+ componentDidUpdate?(prevProps: Readonly<TProps>, prevState: Readonly<{}>, snapshot?: any): void;
44
+ componentWillMount?(): void;
45
+ UNSAFE_componentWillMount?(): void;
46
+ componentWillReceiveProps?(nextProps: Readonly<TProps>, nextContext: any): void;
47
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TProps>, nextContext: any): void;
48
+ componentWillUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): void;
49
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): void;
50
+ };
51
+ displayName: string;
52
+ defaultProps: {
53
+ cursorLabelComponent: JSX.Element;
54
+ cursorLabelOffset: {
55
+ x: number;
56
+ y: number;
57
+ };
58
+ cursorComponent: JSX.Element;
59
+ className: string;
60
+ portalComponent: JSX.Element;
61
+ portalZIndex: number;
62
+ responsive: boolean;
63
+ role: string;
64
+ };
65
+ defaultEvents: (props: any) => {
66
+ target: string;
67
+ eventHandlers: {
68
+ onMouseLeave: (evt: any, targetProps: any) => {};
69
+ onTouchCancel: () => never[];
70
+ onMouseMove: (evt: any, targetProps: any) => {} | undefined;
71
+ onTouchMove: (evt: any, targetProps: any) => {} | undefined;
72
+ };
73
+ }[];
74
+ } & TBase;
75
+ export declare const VictoryCursorContainer: {
76
+ new (props: VictoryCursorContainerProps): {
77
+ getCursorPosition(props: any): any;
78
+ getCursorLabelOffset(props: any): any;
79
+ getPadding(props: any): {
80
+ top: any;
81
+ bottom: any;
82
+ left: any;
83
+ right: any;
84
+ };
85
+ getCursorElements(props: any): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
86
+ getChildren(props: any): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment)[];
87
+ context: unknown;
88
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<VictoryCursorContainerProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
89
+ forceUpdate(callback?: (() => void) | undefined): void;
90
+ render(): React.ReactNode;
91
+ readonly props: Readonly<VictoryCursorContainerProps>;
92
+ state: Readonly<{}>;
93
+ refs: {
94
+ [key: string]: React.ReactInstance;
95
+ };
96
+ componentDidMount?(): void;
97
+ shouldComponentUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): boolean;
98
+ componentWillUnmount?(): void;
99
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
100
+ getSnapshotBeforeUpdate?(prevProps: Readonly<VictoryCursorContainerProps>, prevState: Readonly<{}>): any;
101
+ componentDidUpdate?(prevProps: Readonly<VictoryCursorContainerProps>, prevState: Readonly<{}>, snapshot?: any): void;
102
+ componentWillMount?(): void;
103
+ UNSAFE_componentWillMount?(): void;
104
+ componentWillReceiveProps?(nextProps: Readonly<VictoryCursorContainerProps>, nextContext: any): void;
105
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<VictoryCursorContainerProps>, nextContext: any): void;
106
+ componentWillUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): void;
107
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): void;
108
+ };
109
+ displayName: string;
110
+ defaultProps: {
111
+ cursorLabelComponent: JSX.Element;
112
+ cursorLabelOffset: {
113
+ x: number;
114
+ y: number;
115
+ };
116
+ cursorComponent: JSX.Element;
117
+ className: string;
118
+ portalComponent: JSX.Element;
119
+ portalZIndex: number;
120
+ responsive: boolean;
121
+ role: string;
122
+ };
123
+ defaultEvents: (props: any) => {
124
+ target: string;
125
+ eventHandlers: {
126
+ onMouseLeave: (evt: any, targetProps: any) => {};
127
+ onTouchCancel: () => never[];
128
+ onMouseMove: (evt: any, targetProps: any) => {} | undefined;
129
+ onTouchMove: (evt: any, targetProps: any) => {} | undefined;
130
+ };
131
+ }[];
132
+ } & typeof VictoryContainer;
133
+ export {};
134
134
  //# sourceMappingURL=victory-cursor-container.d.ts.map
@@ -1,33 +1,33 @@
1
- /// <reference types="lodash" />
2
- import { Selection } from "victory-core";
3
- declare class CursorHelpersClass {
4
- getDimension(props: any): any;
5
- withinBounds(point: any, bounds: any): boolean;
6
- private handleMouseMove;
7
- onMouseMove: import("lodash").DebouncedFunc<(evt: any, targetProps: any) => {
8
- target: string;
9
- eventKey: string;
10
- mutation: () => {
11
- cursorValue: Selection.SVGCoordinateType | null;
12
- parentSVG: any;
13
- };
14
- }[]>;
15
- onMouseLeave: (evt: any, targetProps: any) => {
16
- target: string;
17
- eventKey: string;
18
- mutation: () => {
19
- cursorValue: Selection.SVGCoordinateType | null;
20
- parentSVG: any;
21
- };
22
- }[];
23
- onTouchEnd: (evt: any, targetProps: any) => {
24
- target: string;
25
- eventKey: string;
26
- mutation: () => {
27
- cursorValue: null;
28
- };
29
- }[];
30
- }
31
- export declare const CursorHelpers: CursorHelpersClass;
32
- export {};
1
+ /// <reference types="lodash" />
2
+ import { Selection } from "victory-core";
3
+ declare class CursorHelpersClass {
4
+ getDimension(props: any): any;
5
+ withinBounds(point: any, bounds: any): boolean;
6
+ private handleMouseMove;
7
+ onMouseMove: import("lodash").DebouncedFunc<(evt: any, targetProps: any) => {
8
+ target: string;
9
+ eventKey: string;
10
+ mutation: () => {
11
+ cursorValue: Selection.SVGCoordinateType | null;
12
+ parentSVG: any;
13
+ };
14
+ }[]>;
15
+ onMouseLeave: (evt: any, targetProps: any) => {
16
+ target: string;
17
+ eventKey: string;
18
+ mutation: () => {
19
+ cursorValue: Selection.SVGCoordinateType | null;
20
+ parentSVG: any;
21
+ };
22
+ }[];
23
+ onTouchEnd: (evt: any, targetProps: any) => {
24
+ target: string;
25
+ eventKey: string;
26
+ mutation: () => {
27
+ cursorValue: null;
28
+ };
29
+ }[];
30
+ }
31
+ export declare const CursorHelpers: CursorHelpersClass;
32
+ export {};
33
33
  //# sourceMappingURL=cursor-helpers.d.ts.map
package/lib/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./cursor-helpers";
2
- export * from "./victory-cursor-container";
1
+ export * from "./cursor-helpers";
2
+ export * from "./victory-cursor-container";
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,134 +1,134 @@
1
- import React from "react";
2
- import { VictoryContainer, VictoryContainerProps, CoordinatesPropType, VictoryLabelProps, ValueOrAccessor } from "victory-core";
3
- export declare type CursorCoordinatesPropType = CoordinatesPropType | number;
4
- export interface VictoryCursorContainerProps extends VictoryContainerProps {
5
- cursorComponent?: React.ReactElement;
6
- cursorDimension?: "x" | "y";
7
- cursorLabel?: ValueOrAccessor<VictoryLabelProps["text"]>;
8
- cursorLabelComponent?: React.ReactElement;
9
- cursorLabelOffset?: CursorCoordinatesPropType;
10
- defaultCursorValue?: CursorCoordinatesPropType;
11
- disable?: boolean;
12
- onCursorChange?: (value: CursorCoordinatesPropType, props: VictoryCursorContainerProps) => void;
13
- }
14
- declare type ComponentClass<TProps> = {
15
- new (props: TProps): React.Component<TProps>;
16
- };
17
- export declare function cursorContainerMixin<TBase extends ComponentClass<TProps>, TProps extends VictoryCursorContainerProps>(Base: TBase): {
18
- new (props: TProps): {
19
- getCursorPosition(props: any): any;
20
- getCursorLabelOffset(props: any): any;
21
- getPadding(props: any): {
22
- top: any;
23
- bottom: any;
24
- left: any;
25
- right: any;
26
- };
27
- getCursorElements(props: any): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
28
- getChildren(props: any): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment)[];
29
- context: unknown;
30
- setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<TProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
31
- forceUpdate(callback?: (() => void) | undefined): void;
32
- render(): React.ReactNode;
33
- readonly props: Readonly<TProps>;
34
- state: Readonly<{}>;
35
- refs: {
36
- [key: string]: React.ReactInstance;
37
- };
38
- componentDidMount?(): void;
39
- shouldComponentUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): boolean;
40
- componentWillUnmount?(): void;
41
- componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
42
- getSnapshotBeforeUpdate?(prevProps: Readonly<TProps>, prevState: Readonly<{}>): any;
43
- componentDidUpdate?(prevProps: Readonly<TProps>, prevState: Readonly<{}>, snapshot?: any): void;
44
- componentWillMount?(): void;
45
- UNSAFE_componentWillMount?(): void;
46
- componentWillReceiveProps?(nextProps: Readonly<TProps>, nextContext: any): void;
47
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TProps>, nextContext: any): void;
48
- componentWillUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): void;
49
- UNSAFE_componentWillUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): void;
50
- };
51
- displayName: string;
52
- defaultProps: {
53
- cursorLabelComponent: JSX.Element;
54
- cursorLabelOffset: {
55
- x: number;
56
- y: number;
57
- };
58
- cursorComponent: JSX.Element;
59
- className: string;
60
- portalComponent: JSX.Element;
61
- portalZIndex: number;
62
- responsive: boolean;
63
- role: string;
64
- };
65
- defaultEvents: (props: any) => {
66
- target: string;
67
- eventHandlers: {
68
- onMouseLeave: (evt: any, targetProps: any) => {};
69
- onTouchCancel: () => never[];
70
- onMouseMove: (evt: any, targetProps: any) => {} | undefined;
71
- onTouchMove: (evt: any, targetProps: any) => {} | undefined;
72
- };
73
- }[];
74
- } & TBase;
75
- export declare const VictoryCursorContainer: {
76
- new (props: VictoryCursorContainerProps): {
77
- getCursorPosition(props: any): any;
78
- getCursorLabelOffset(props: any): any;
79
- getPadding(props: any): {
80
- top: any;
81
- bottom: any;
82
- left: any;
83
- right: any;
84
- };
85
- getCursorElements(props: any): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
86
- getChildren(props: any): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment)[];
87
- context: unknown;
88
- setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<VictoryCursorContainerProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
89
- forceUpdate(callback?: (() => void) | undefined): void;
90
- render(): React.ReactNode;
91
- readonly props: Readonly<VictoryCursorContainerProps>;
92
- state: Readonly<{}>;
93
- refs: {
94
- [key: string]: React.ReactInstance;
95
- };
96
- componentDidMount?(): void;
97
- shouldComponentUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): boolean;
98
- componentWillUnmount?(): void;
99
- componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
100
- getSnapshotBeforeUpdate?(prevProps: Readonly<VictoryCursorContainerProps>, prevState: Readonly<{}>): any;
101
- componentDidUpdate?(prevProps: Readonly<VictoryCursorContainerProps>, prevState: Readonly<{}>, snapshot?: any): void;
102
- componentWillMount?(): void;
103
- UNSAFE_componentWillMount?(): void;
104
- componentWillReceiveProps?(nextProps: Readonly<VictoryCursorContainerProps>, nextContext: any): void;
105
- UNSAFE_componentWillReceiveProps?(nextProps: Readonly<VictoryCursorContainerProps>, nextContext: any): void;
106
- componentWillUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): void;
107
- UNSAFE_componentWillUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): void;
108
- };
109
- displayName: string;
110
- defaultProps: {
111
- cursorLabelComponent: JSX.Element;
112
- cursorLabelOffset: {
113
- x: number;
114
- y: number;
115
- };
116
- cursorComponent: JSX.Element;
117
- className: string;
118
- portalComponent: JSX.Element;
119
- portalZIndex: number;
120
- responsive: boolean;
121
- role: string;
122
- };
123
- defaultEvents: (props: any) => {
124
- target: string;
125
- eventHandlers: {
126
- onMouseLeave: (evt: any, targetProps: any) => {};
127
- onTouchCancel: () => never[];
128
- onMouseMove: (evt: any, targetProps: any) => {} | undefined;
129
- onTouchMove: (evt: any, targetProps: any) => {} | undefined;
130
- };
131
- }[];
132
- } & typeof VictoryContainer;
133
- export {};
1
+ import React from "react";
2
+ import { VictoryContainer, VictoryContainerProps, CoordinatesPropType, VictoryLabelProps, ValueOrAccessor } from "victory-core";
3
+ export declare type CursorCoordinatesPropType = CoordinatesPropType | number;
4
+ export interface VictoryCursorContainerProps extends VictoryContainerProps {
5
+ cursorComponent?: React.ReactElement;
6
+ cursorDimension?: "x" | "y";
7
+ cursorLabel?: ValueOrAccessor<VictoryLabelProps["text"]>;
8
+ cursorLabelComponent?: React.ReactElement;
9
+ cursorLabelOffset?: CursorCoordinatesPropType;
10
+ defaultCursorValue?: CursorCoordinatesPropType;
11
+ disable?: boolean;
12
+ onCursorChange?: (value: CursorCoordinatesPropType, props: VictoryCursorContainerProps) => void;
13
+ }
14
+ declare type ComponentClass<TProps> = {
15
+ new (props: TProps): React.Component<TProps>;
16
+ };
17
+ export declare function cursorContainerMixin<TBase extends ComponentClass<TProps>, TProps extends VictoryCursorContainerProps>(Base: TBase): {
18
+ new (props: TProps): {
19
+ getCursorPosition(props: any): any;
20
+ getCursorLabelOffset(props: any): any;
21
+ getPadding(props: any): {
22
+ top: any;
23
+ bottom: any;
24
+ left: any;
25
+ right: any;
26
+ };
27
+ getCursorElements(props: any): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
28
+ getChildren(props: any): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment)[];
29
+ context: unknown;
30
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<TProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
31
+ forceUpdate(callback?: (() => void) | undefined): void;
32
+ render(): React.ReactNode;
33
+ readonly props: Readonly<TProps>;
34
+ state: Readonly<{}>;
35
+ refs: {
36
+ [key: string]: React.ReactInstance;
37
+ };
38
+ componentDidMount?(): void;
39
+ shouldComponentUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): boolean;
40
+ componentWillUnmount?(): void;
41
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
42
+ getSnapshotBeforeUpdate?(prevProps: Readonly<TProps>, prevState: Readonly<{}>): any;
43
+ componentDidUpdate?(prevProps: Readonly<TProps>, prevState: Readonly<{}>, snapshot?: any): void;
44
+ componentWillMount?(): void;
45
+ UNSAFE_componentWillMount?(): void;
46
+ componentWillReceiveProps?(nextProps: Readonly<TProps>, nextContext: any): void;
47
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TProps>, nextContext: any): void;
48
+ componentWillUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): void;
49
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): void;
50
+ };
51
+ displayName: string;
52
+ defaultProps: {
53
+ cursorLabelComponent: JSX.Element;
54
+ cursorLabelOffset: {
55
+ x: number;
56
+ y: number;
57
+ };
58
+ cursorComponent: JSX.Element;
59
+ className: string;
60
+ portalComponent: JSX.Element;
61
+ portalZIndex: number;
62
+ responsive: boolean;
63
+ role: string;
64
+ };
65
+ defaultEvents: (props: any) => {
66
+ target: string;
67
+ eventHandlers: {
68
+ onMouseLeave: (evt: any, targetProps: any) => {};
69
+ onTouchCancel: () => never[];
70
+ onMouseMove: (evt: any, targetProps: any) => {} | undefined;
71
+ onTouchMove: (evt: any, targetProps: any) => {} | undefined;
72
+ };
73
+ }[];
74
+ } & TBase;
75
+ export declare const VictoryCursorContainer: {
76
+ new (props: VictoryCursorContainerProps): {
77
+ getCursorPosition(props: any): any;
78
+ getCursorLabelOffset(props: any): any;
79
+ getPadding(props: any): {
80
+ top: any;
81
+ bottom: any;
82
+ left: any;
83
+ right: any;
84
+ };
85
+ getCursorElements(props: any): React.ReactElement<any, string | React.JSXElementConstructor<any>>[];
86
+ getChildren(props: any): (string | number | React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactFragment)[];
87
+ context: unknown;
88
+ setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<VictoryCursorContainerProps>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void;
89
+ forceUpdate(callback?: (() => void) | undefined): void;
90
+ render(): React.ReactNode;
91
+ readonly props: Readonly<VictoryCursorContainerProps>;
92
+ state: Readonly<{}>;
93
+ refs: {
94
+ [key: string]: React.ReactInstance;
95
+ };
96
+ componentDidMount?(): void;
97
+ shouldComponentUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): boolean;
98
+ componentWillUnmount?(): void;
99
+ componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
100
+ getSnapshotBeforeUpdate?(prevProps: Readonly<VictoryCursorContainerProps>, prevState: Readonly<{}>): any;
101
+ componentDidUpdate?(prevProps: Readonly<VictoryCursorContainerProps>, prevState: Readonly<{}>, snapshot?: any): void;
102
+ componentWillMount?(): void;
103
+ UNSAFE_componentWillMount?(): void;
104
+ componentWillReceiveProps?(nextProps: Readonly<VictoryCursorContainerProps>, nextContext: any): void;
105
+ UNSAFE_componentWillReceiveProps?(nextProps: Readonly<VictoryCursorContainerProps>, nextContext: any): void;
106
+ componentWillUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): void;
107
+ UNSAFE_componentWillUpdate?(nextProps: Readonly<VictoryCursorContainerProps>, nextState: Readonly<{}>, nextContext: any): void;
108
+ };
109
+ displayName: string;
110
+ defaultProps: {
111
+ cursorLabelComponent: JSX.Element;
112
+ cursorLabelOffset: {
113
+ x: number;
114
+ y: number;
115
+ };
116
+ cursorComponent: JSX.Element;
117
+ className: string;
118
+ portalComponent: JSX.Element;
119
+ portalZIndex: number;
120
+ responsive: boolean;
121
+ role: string;
122
+ };
123
+ defaultEvents: (props: any) => {
124
+ target: string;
125
+ eventHandlers: {
126
+ onMouseLeave: (evt: any, targetProps: any) => {};
127
+ onTouchCancel: () => never[];
128
+ onMouseMove: (evt: any, targetProps: any) => {} | undefined;
129
+ onTouchMove: (evt: any, targetProps: any) => {} | undefined;
130
+ };
131
+ }[];
132
+ } & typeof VictoryContainer;
133
+ export {};
134
134
  //# sourceMappingURL=victory-cursor-container.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-cursor-container",
3
- "version": "36.9.2-next.3",
3
+ "version": "36.9.2",
4
4
  "description": "Interactive Cursor Component for Victory",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -12,7 +12,7 @@
12
12
  "type": "git",
13
13
  "url": "https://github.com/FormidableLabs/victory"
14
14
  },
15
- "homepage": "https://formidable.com/open-source/victory",
15
+ "homepage": "https://commerce.nearform.com/open-source/victory",
16
16
  "sideEffects": false,
17
17
  "main": "lib/index.js",
18
18
  "module": "es/index.js",
@@ -21,11 +21,14 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "lodash": "^4.17.19",
24
- "victory-core": "^36.9.2-next.3"
24
+ "victory-core": "^36.9.2"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "react": ">=16.6.0"
28
28
  },
29
+ "publishConfig": {
30
+ "provenance": true
31
+ },
29
32
  "wireit": {
30
33
  "### THESE WIREIT CONFIGS ARE GENERATED ####": {},
31
34
  "### DO NOT MODIFY THESE MANUALLY ####": {},
@@ -1,6 +1,6 @@
1
- /* eslint-disable complexity */
2
1
  import React from "react";
3
2
  import {
3
+ VictoryContainer,
4
4
  Helpers,
5
5
  VictoryContainerProps,
6
6
  CoordinatesPropType,
@@ -8,10 +8,6 @@ import {
8
8
  ValueOrAccessor,
9
9
  VictoryLabel,
10
10
  LineSegment,
11
- VictoryContainer,
12
- VictoryEventHandler,
13
- DomainTuple,
14
- PaddingProps,
15
11
  } from "victory-core";
16
12
  import { defaults, isObject } from "lodash";
17
13
  import { CursorHelpers } from "./cursor-helpers";
@@ -26,208 +22,191 @@ export interface VictoryCursorContainerProps extends VictoryContainerProps {
26
22
  cursorLabelOffset?: CursorCoordinatesPropType;
27
23
  defaultCursorValue?: CursorCoordinatesPropType;
28
24
  disable?: boolean;
29
- horizontal?: boolean;
30
- padding?: PaddingProps;
31
25
  onCursorChange?: (
32
26
  value: CursorCoordinatesPropType,
33
27
  props: VictoryCursorContainerProps,
34
28
  ) => void;
35
29
  }
36
30
 
37
- interface VictoryCursorContainerMutatedProps
38
- extends VictoryCursorContainerProps {
39
- cursorValue: CoordinatesPropType | null;
40
- domain: { x: DomainTuple; y: DomainTuple };
41
- }
42
-
43
- export const VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS = {
44
- cursorLabelComponent: <VictoryLabel />,
45
- cursorLabelOffset: {
46
- x: 5,
47
- y: -10,
48
- },
49
- cursorComponent: <LineSegment />,
50
- };
51
-
52
- export const useVictoryCursorContainer = (
53
- initialProps: VictoryCursorContainerProps,
54
- ) => {
55
- const props = {
56
- ...VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS,
57
- ...(initialProps as VictoryCursorContainerMutatedProps),
58
- };
59
- const { children } = props;
31
+ type ComponentClass<TProps> = { new (props: TProps): React.Component<TProps> };
32
+
33
+ export function cursorContainerMixin<
34
+ TBase extends ComponentClass<TProps>,
35
+ TProps extends VictoryCursorContainerProps,
36
+ >(Base: TBase) {
37
+ // @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'."
38
+ return class VictoryCursorContainer extends Base {
39
+ static displayName = "VictoryCursorContainer";
40
+ static defaultProps = {
41
+ ...VictoryContainer.defaultProps,
42
+ cursorLabelComponent: <VictoryLabel />,
43
+ cursorLabelOffset: {
44
+ x: 5,
45
+ y: -10,
46
+ },
47
+ cursorComponent: <LineSegment />,
48
+ };
49
+ static defaultEvents = (props) => {
50
+ return [
51
+ {
52
+ target: "parent",
53
+ eventHandlers: {
54
+ onMouseLeave: (evt, targetProps) => {
55
+ return props.disable
56
+ ? {}
57
+ : CursorHelpers.onMouseLeave(evt, targetProps);
58
+ },
59
+ onTouchCancel: () => {
60
+ return [];
61
+ },
62
+ onMouseMove: (evt, targetProps) => {
63
+ return props.disable
64
+ ? {}
65
+ : CursorHelpers.onMouseMove(evt, targetProps);
66
+ },
67
+ onTouchMove: (evt, targetProps) => {
68
+ return props.disable
69
+ ? {}
70
+ : CursorHelpers.onMouseMove(evt, targetProps);
71
+ },
72
+ },
73
+ },
74
+ ];
75
+ };
76
+
77
+ getCursorPosition(props) {
78
+ const { cursorValue, defaultCursorValue, domain, cursorDimension } =
79
+ props;
80
+ if (cursorValue) {
81
+ return cursorValue;
82
+ }
60
83
 
61
- const getCursorPosition = () => {
62
- const { cursorValue, defaultCursorValue, domain, cursorDimension } = props;
63
- if (cursorValue) {
64
- return cursorValue;
65
- }
84
+ if (typeof defaultCursorValue === "number") {
85
+ return {
86
+ x: (domain.x[0] + domain.x[1]) / 2,
87
+ y: (domain.y[0] + domain.y[1]) / 2,
88
+ [cursorDimension]: defaultCursorValue,
89
+ };
90
+ }
66
91
 
67
- if (typeof defaultCursorValue === "number") {
68
- return {
69
- x: ((domain.x[0] as number) + (domain.x[1] as number)) / 2,
70
- y: ((domain.y[0] as number) + (domain.y[1] as number)) / 2,
71
- ...(cursorDimension ? { [cursorDimension]: defaultCursorValue } : {}),
72
- };
92
+ return defaultCursorValue;
73
93
  }
74
94
 
75
- return defaultCursorValue;
76
- };
95
+ getCursorLabelOffset(props) {
96
+ const { cursorLabelOffset } = props;
77
97
 
78
- const getCursorLabelOffset = () => {
79
- const { cursorLabelOffset } = props;
98
+ if (typeof cursorLabelOffset === "number") {
99
+ return {
100
+ x: cursorLabelOffset,
101
+ y: cursorLabelOffset,
102
+ };
103
+ }
80
104
 
81
- if (typeof cursorLabelOffset === "number") {
82
- return {
83
- x: cursorLabelOffset,
84
- y: cursorLabelOffset,
85
- };
105
+ return cursorLabelOffset;
86
106
  }
87
107
 
88
- return cursorLabelOffset;
89
- };
90
-
91
- const getPadding = () => {
92
- if (props.padding === undefined) {
93
- const child = Array.isArray(props.children)
94
- ? props.children.find((c: any) => {
95
- return isObject(c.props) && c.props.padding !== undefined;
96
- })
97
- : props.children;
98
- return Helpers.getPadding(child?.props);
108
+ getPadding(props) {
109
+ if (props.padding === undefined) {
110
+ const child = props.children.find((c) => {
111
+ return isObject(c.props) && c.props.padding !== undefined;
112
+ });
113
+ return Helpers.getPadding(child.props);
114
+ }
115
+ return Helpers.getPadding(props);
99
116
  }
100
- return Helpers.getPadding(props);
101
- };
102
117
 
103
- const getCursorElements = () => {
104
- // eslint-disable-line max-statements
105
- const {
106
- scale,
107
- cursorLabelComponent,
108
- cursorLabel,
109
- cursorComponent,
110
- width,
111
- height,
112
- name,
113
- horizontal,
114
- theme,
115
- } = props;
116
- const cursorDimension = CursorHelpers.getDimension(props);
117
- const cursorValue = getCursorPosition();
118
- const cursorLabelOffset = getCursorLabelOffset();
119
-
120
- if (!cursorValue) {
121
- return [];
122
- }
118
+ getCursorElements(props) {
119
+ // eslint-disable-line max-statements
120
+ const {
121
+ scale,
122
+ cursorLabelComponent,
123
+ cursorLabel,
124
+ cursorComponent,
125
+ width,
126
+ height,
127
+ name,
128
+ horizontal,
129
+ theme,
130
+ } = props;
131
+ const cursorDimension = CursorHelpers.getDimension(props);
132
+ const cursorValue = this.getCursorPosition(props);
133
+ const cursorLabelOffset = this.getCursorLabelOffset(props);
134
+
135
+ if (!cursorValue) {
136
+ return [];
137
+ }
123
138
 
124
- const newElements: React.ReactElement[] = [];
125
- const padding = getPadding();
126
- const cursorCoordinates =
127
- scale &&
128
- "x" in scale &&
129
- "y" in scale &&
130
- typeof scale.y === "function" &&
131
- typeof scale.x === "function"
132
- ? {
133
- x: horizontal ? scale.y(cursorValue.y) : scale.x(cursorValue.x),
134
- y: horizontal ? scale.x(cursorValue.x) : scale.y(cursorValue.y),
135
- }
136
- : {
137
- x: cursorValue.x,
138
- y: cursorValue.y,
139
- };
140
- if (cursorLabel) {
141
- let labelProps = defaults({ active: true }, cursorLabelComponent.props, {
142
- x: cursorCoordinates.x + cursorLabelOffset.x,
143
- y: cursorCoordinates.y + cursorLabelOffset.y,
144
- datum: cursorValue,
145
- active: true,
146
- key: `${name}-cursor-label`,
147
- });
148
- if (Helpers.isTooltip(cursorLabelComponent)) {
149
- const tooltipTheme = (theme && theme.tooltip) || {};
150
- labelProps = defaults({}, labelProps, tooltipTheme);
139
+ const newElements: React.ReactElement[] = [];
140
+ const padding = this.getPadding(props);
141
+ const cursorCoordinates = {
142
+ x: horizontal ? scale.y(cursorValue.y) : scale.x(cursorValue.x),
143
+ y: horizontal ? scale.x(cursorValue.x) : scale.y(cursorValue.y),
144
+ };
145
+ if (cursorLabel) {
146
+ let labelProps = defaults(
147
+ { active: true },
148
+ cursorLabelComponent.props,
149
+ {
150
+ x: cursorCoordinates.x + cursorLabelOffset.x,
151
+ y: cursorCoordinates.y + cursorLabelOffset.y,
152
+ datum: cursorValue,
153
+ active: true,
154
+ key: `${name}-cursor-label`,
155
+ },
156
+ );
157
+ if (Helpers.isTooltip(cursorLabelComponent)) {
158
+ const tooltipTheme = (theme && theme.tooltip) || {};
159
+ labelProps = defaults({}, labelProps, tooltipTheme);
160
+ }
161
+ newElements.push(
162
+ React.cloneElement(
163
+ cursorLabelComponent,
164
+ defaults({}, labelProps, {
165
+ text: Helpers.evaluateProp(cursorLabel, labelProps),
166
+ }),
167
+ ),
168
+ );
151
169
  }
152
- newElements.push(
153
- React.cloneElement(
154
- cursorLabelComponent,
155
- defaults({}, labelProps, {
156
- text: Helpers.evaluateProp(cursorLabel, labelProps),
157
- }),
158
- ),
159
- );
160
- }
161
170
 
162
- const cursorStyle = Object.assign(
163
- { stroke: "black" },
164
- cursorComponent.props.style,
165
- );
166
- if (cursorDimension === "x" || cursorDimension === undefined) {
167
- newElements.push(
168
- React.cloneElement(cursorComponent, {
169
- key: `${name}-x-cursor`,
170
- x1: cursorCoordinates.x,
171
- x2: cursorCoordinates.x,
172
- y1: padding.top,
173
- y2: (typeof height === "number" ? height : 0) - padding.bottom,
174
- style: cursorStyle,
175
- }),
171
+ const cursorStyle = Object.assign(
172
+ { stroke: "black" },
173
+ cursorComponent.props.style,
176
174
  );
175
+ if (cursorDimension === "x" || cursorDimension === undefined) {
176
+ newElements.push(
177
+ React.cloneElement(cursorComponent, {
178
+ key: `${name}-x-cursor`,
179
+ x1: cursorCoordinates.x,
180
+ x2: cursorCoordinates.x,
181
+ y1: padding.top,
182
+ y2: height - padding.bottom,
183
+ style: cursorStyle,
184
+ }),
185
+ );
186
+ }
187
+ if (cursorDimension === "y" || cursorDimension === undefined) {
188
+ newElements.push(
189
+ React.cloneElement(cursorComponent, {
190
+ key: `${name}-y-cursor`,
191
+ x1: padding.left,
192
+ x2: width - padding.right,
193
+ y1: cursorCoordinates.y,
194
+ y2: cursorCoordinates.y,
195
+ style: cursorStyle,
196
+ }),
197
+ );
198
+ }
199
+ return newElements;
177
200
  }
178
- if (cursorDimension === "y" || cursorDimension === undefined) {
179
- newElements.push(
180
- React.cloneElement(cursorComponent, {
181
- key: `${name}-y-cursor`,
182
- x1: padding.left,
183
- x2: (typeof width === "number" ? width : 0) - padding.right,
184
- y1: cursorCoordinates.y,
185
- y2: cursorCoordinates.y,
186
- style: cursorStyle,
187
- }),
188
- );
201
+
202
+ // Overrides method in VictoryContainer
203
+ getChildren(props) {
204
+ return [
205
+ ...React.Children.toArray(props.children),
206
+ ...this.getCursorElements(props),
207
+ ];
189
208
  }
190
- return newElements;
191
209
  };
210
+ }
192
211
 
193
- return {
194
- props,
195
- children: [
196
- ...React.Children.toArray(children),
197
- ...getCursorElements(),
198
- ] as React.ReactElement[],
199
- };
200
- };
201
-
202
- export const VictoryCursorContainer = (
203
- initialProps: VictoryCursorContainerProps,
204
- ) => {
205
- const { props, children } = useVictoryCursorContainer(initialProps);
206
- return <VictoryContainer {...props}>{children}</VictoryContainer>;
207
- };
208
-
209
- VictoryCursorContainer.role = "container";
210
-
211
- VictoryCursorContainer.defaultEvents = (
212
- initialProps: VictoryCursorContainerProps,
213
- ) => {
214
- const props = { ...VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS, ...initialProps };
215
- const createEventHandler =
216
- (handler: VictoryEventHandler, disabled?: boolean): VictoryEventHandler =>
217
- // eslint-disable-next-line max-params
218
- (event, targetProps, eventKey, context) =>
219
- disabled || props.disable
220
- ? {}
221
- : handler(event, { ...props, ...targetProps }, eventKey, context);
222
-
223
- return [
224
- {
225
- target: "parent",
226
- eventHandlers: {
227
- onMouseLeave: createEventHandler(CursorHelpers.onMouseLeave),
228
- onMouseMove: createEventHandler(CursorHelpers.onMouseMove),
229
- onTouchMove: createEventHandler(CursorHelpers.onMouseMove),
230
- },
231
- },
232
- ];
233
- };
212
+ export const VictoryCursorContainer = cursorContainerMixin(VictoryContainer);