victory-cursor-container 36.9.2-next.1 → 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 +6 -12
- package/LICENSE.txt +30 -0
- package/README.md +2 -2
- package/dist/victory-cursor-container.js +1045 -31023
- package/dist/victory-cursor-container.min.js +1 -2
- package/es/cursor-helpers.d.ts +32 -32
- package/es/index.d.ts +2 -2
- package/es/victory-cursor-container.d.ts +133 -84
- package/es/victory-cursor-container.js +188 -161
- package/lib/cursor-helpers.d.ts +32 -32
- package/lib/index.d.ts +2 -2
- package/lib/victory-cursor-container.d.ts +133 -84
- package/lib/victory-cursor-container.js +189 -166
- package/package.json +6 -3
- package/src/victory-cursor-container.tsx +164 -174
- package/dist/victory-cursor-container.min.js.LICENSE.txt +0 -19
|
@@ -1,85 +1,134 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { VictoryContainerProps, CoordinatesPropType, VictoryLabelProps, ValueOrAccessor
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
};
|
|
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 {};
|
|
85
134
|
//# sourceMappingURL=victory-cursor-container.d.ts.map
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.VictoryCursorContainer = void 0;
|
|
7
|
+
exports.cursorContainerMixin = cursorContainerMixin;
|
|
7
8
|
|
|
8
9
|
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
9
10
|
|
|
@@ -17,6 +18,10 @@ var _cursorHelpers = require("./cursor-helpers");
|
|
|
17
18
|
|
|
18
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
20
|
|
|
21
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
22
|
+
|
|
23
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
24
|
+
|
|
20
25
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
21
26
|
|
|
22
27
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -29,187 +34,205 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
29
34
|
|
|
30
35
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
31
36
|
|
|
32
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
|
-
|
|
34
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
-
|
|
36
37
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
cursorLabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
|
|
40
|
-
cursorLabelOffset: {
|
|
41
|
-
x: 5,
|
|
42
|
-
y: -10
|
|
43
|
-
},
|
|
44
|
-
cursorComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.LineSegment, null)
|
|
45
|
-
};
|
|
46
|
-
exports.VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS = VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS;
|
|
47
|
-
|
|
48
|
-
var useVictoryCursorContainer = function (initialProps) {
|
|
49
|
-
var props = _objectSpread(_objectSpread({}, VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS), initialProps);
|
|
50
|
-
|
|
51
|
-
var children = props.children;
|
|
52
|
-
|
|
53
|
-
var getCursorPosition = function () {
|
|
54
|
-
var cursorValue = props.cursorValue,
|
|
55
|
-
defaultCursorValue = props.defaultCursorValue,
|
|
56
|
-
domain = props.domain,
|
|
57
|
-
cursorDimension = props.cursorDimension;
|
|
58
|
-
|
|
59
|
-
if (cursorValue) {
|
|
60
|
-
return cursorValue;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (typeof defaultCursorValue === "number") {
|
|
64
|
-
return _objectSpread({
|
|
65
|
-
x: (domain.x[0] + domain.x[1]) / 2,
|
|
66
|
-
y: (domain.y[0] + domain.y[1]) / 2
|
|
67
|
-
}, cursorDimension ? _defineProperty({}, cursorDimension, defaultCursorValue) : {});
|
|
68
|
-
}
|
|
39
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
69
40
|
|
|
70
|
-
|
|
71
|
-
};
|
|
41
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
72
42
|
|
|
73
|
-
|
|
74
|
-
var cursorLabelOffset = props.cursorLabelOffset;
|
|
43
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
75
44
|
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
x: cursorLabelOffset,
|
|
79
|
-
y: cursorLabelOffset
|
|
80
|
-
};
|
|
81
|
-
}
|
|
45
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
82
46
|
|
|
83
|
-
|
|
84
|
-
};
|
|
47
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
85
48
|
|
|
86
|
-
|
|
87
|
-
if (props.padding === undefined) {
|
|
88
|
-
var child = Array.isArray(props.children) ? props.children.find(function (c) {
|
|
89
|
-
return (0, _isObject2.default)(c.props) && c.props.padding !== undefined;
|
|
90
|
-
}) : props.children;
|
|
91
|
-
return _victoryCore.Helpers.getPadding(child === null || child === void 0 ? void 0 : child.props);
|
|
92
|
-
}
|
|
49
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
93
50
|
|
|
94
|
-
|
|
95
|
-
};
|
|
51
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
96
52
|
|
|
97
|
-
|
|
98
|
-
var _scale$y, _scale$x, _scale$x2, _scale$y2;
|
|
53
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
99
54
|
|
|
100
|
-
|
|
101
|
-
var scale = props.scale,
|
|
102
|
-
cursorLabelComponent = props.cursorLabelComponent,
|
|
103
|
-
cursorLabel = props.cursorLabel,
|
|
104
|
-
cursorComponent = props.cursorComponent,
|
|
105
|
-
width = props.width,
|
|
106
|
-
height = props.height,
|
|
107
|
-
name = props.name,
|
|
108
|
-
horizontal = props.horizontal,
|
|
109
|
-
theme = props.theme;
|
|
55
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
110
56
|
|
|
111
|
-
|
|
57
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
112
58
|
|
|
113
|
-
|
|
114
|
-
|
|
59
|
+
function cursorContainerMixin(Base) {
|
|
60
|
+
var _class;
|
|
115
61
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
62
|
+
// @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'."
|
|
63
|
+
return _class = /*#__PURE__*/function (_Base) {
|
|
64
|
+
_inherits(VictoryCursorContainer, _Base);
|
|
119
65
|
|
|
120
|
-
var
|
|
121
|
-
var padding = getPadding();
|
|
122
|
-
var cursorCoordinates = {
|
|
123
|
-
x: horizontal ? scale === null || scale === void 0 ? void 0 : (_scale$y = scale.y) === null || _scale$y === void 0 ? void 0 : _scale$y.call(scale, cursorValue.y) : scale === null || scale === void 0 ? void 0 : (_scale$x = scale.x) === null || _scale$x === void 0 ? void 0 : _scale$x.call(scale, cursorValue.x),
|
|
124
|
-
y: horizontal ? scale === null || scale === void 0 ? void 0 : (_scale$x2 = scale.x) === null || _scale$x2 === void 0 ? void 0 : _scale$x2.call(scale, cursorValue.x) : scale === null || scale === void 0 ? void 0 : (_scale$y2 = scale.y) === null || _scale$y2 === void 0 ? void 0 : _scale$y2.call(scale, cursorValue.y)
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
if (cursorLabel) {
|
|
128
|
-
var labelProps = (0, _defaults2.default)({
|
|
129
|
-
active: true
|
|
130
|
-
}, cursorLabelComponent.props, {
|
|
131
|
-
x: cursorCoordinates.x || 0 + cursorLabelOffset.x,
|
|
132
|
-
y: cursorCoordinates.y || 0 + cursorLabelOffset.y,
|
|
133
|
-
datum: cursorValue,
|
|
134
|
-
active: true,
|
|
135
|
-
key: "".concat(name, "-cursor-label")
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
if (_victoryCore.Helpers.isTooltip(cursorLabelComponent)) {
|
|
139
|
-
var tooltipTheme = theme && theme.tooltip || {};
|
|
140
|
-
labelProps = (0, _defaults2.default)({}, labelProps, tooltipTheme);
|
|
141
|
-
}
|
|
66
|
+
var _super = _createSuper(VictoryCursorContainer);
|
|
142
67
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
})));
|
|
146
|
-
}
|
|
68
|
+
function VictoryCursorContainer() {
|
|
69
|
+
_classCallCheck(this, VictoryCursorContainer);
|
|
147
70
|
|
|
148
|
-
|
|
149
|
-
stroke: "black"
|
|
150
|
-
}, cursorComponent.props.style);
|
|
151
|
-
|
|
152
|
-
if (cursorDimension === "x" || cursorDimension === undefined) {
|
|
153
|
-
newElements.push( /*#__PURE__*/_react.default.cloneElement(cursorComponent, {
|
|
154
|
-
key: "".concat(name, "-x-cursor"),
|
|
155
|
-
x1: cursorCoordinates.x,
|
|
156
|
-
x2: cursorCoordinates.x,
|
|
157
|
-
y1: padding.top,
|
|
158
|
-
y2: height || 0 - padding.bottom,
|
|
159
|
-
style: cursorStyle
|
|
160
|
-
}));
|
|
71
|
+
return _super.apply(this, arguments);
|
|
161
72
|
}
|
|
162
73
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
exports.useVictoryCursorContainer = useVictoryCursorContainer;
|
|
184
|
-
|
|
185
|
-
var VictoryCursorContainer = function (initialProps) {
|
|
186
|
-
var _useVictoryCursorCont = useVictoryCursorContainer(initialProps),
|
|
187
|
-
props = _useVictoryCursorCont.props,
|
|
188
|
-
children = _useVictoryCursorCont.children;
|
|
189
|
-
|
|
190
|
-
return /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, props, children);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
exports.VictoryCursorContainer = VictoryCursorContainer;
|
|
194
|
-
VictoryCursorContainer.role = "container";
|
|
195
|
-
|
|
196
|
-
VictoryCursorContainer.defaultEvents = function (initialProps) {
|
|
197
|
-
var props = _objectSpread(_objectSpread({}, VICTORY_CURSOR_CONTAINER_DEFAULT_PROPS), initialProps);
|
|
198
|
-
|
|
199
|
-
var createEventHandler = function (handler, disabled) {
|
|
200
|
-
return (// eslint-disable-next-line max-params
|
|
201
|
-
function (event, targetProps, eventKey, context) {
|
|
202
|
-
return disabled || props.disable ? {} : handler(event, _objectSpread(_objectSpread({}, props), targetProps), eventKey, context);
|
|
74
|
+
_createClass(VictoryCursorContainer, [{
|
|
75
|
+
key: "getCursorPosition",
|
|
76
|
+
value: function getCursorPosition(props) {
|
|
77
|
+
var cursorValue = props.cursorValue,
|
|
78
|
+
defaultCursorValue = props.defaultCursorValue,
|
|
79
|
+
domain = props.domain,
|
|
80
|
+
cursorDimension = props.cursorDimension;
|
|
81
|
+
|
|
82
|
+
if (cursorValue) {
|
|
83
|
+
return cursorValue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (typeof defaultCursorValue === "number") {
|
|
87
|
+
return _defineProperty({
|
|
88
|
+
x: (domain.x[0] + domain.x[1]) / 2,
|
|
89
|
+
y: (domain.y[0] + domain.y[1]) / 2
|
|
90
|
+
}, cursorDimension, defaultCursorValue);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return defaultCursorValue;
|
|
203
94
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
95
|
+
}, {
|
|
96
|
+
key: "getCursorLabelOffset",
|
|
97
|
+
value: function getCursorLabelOffset(props) {
|
|
98
|
+
var cursorLabelOffset = props.cursorLabelOffset;
|
|
99
|
+
|
|
100
|
+
if (typeof cursorLabelOffset === "number") {
|
|
101
|
+
return {
|
|
102
|
+
x: cursorLabelOffset,
|
|
103
|
+
y: cursorLabelOffset
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return cursorLabelOffset;
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "getPadding",
|
|
111
|
+
value: function getPadding(props) {
|
|
112
|
+
if (props.padding === undefined) {
|
|
113
|
+
var child = props.children.find(function (c) {
|
|
114
|
+
return (0, _isObject2.default)(c.props) && c.props.padding !== undefined;
|
|
115
|
+
});
|
|
116
|
+
return _victoryCore.Helpers.getPadding(child.props);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return _victoryCore.Helpers.getPadding(props);
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "getCursorElements",
|
|
123
|
+
value: function getCursorElements(props) {
|
|
124
|
+
// eslint-disable-line max-statements
|
|
125
|
+
var scale = props.scale,
|
|
126
|
+
cursorLabelComponent = props.cursorLabelComponent,
|
|
127
|
+
cursorLabel = props.cursorLabel,
|
|
128
|
+
cursorComponent = props.cursorComponent,
|
|
129
|
+
width = props.width,
|
|
130
|
+
height = props.height,
|
|
131
|
+
name = props.name,
|
|
132
|
+
horizontal = props.horizontal,
|
|
133
|
+
theme = props.theme;
|
|
134
|
+
|
|
135
|
+
var cursorDimension = _cursorHelpers.CursorHelpers.getDimension(props);
|
|
136
|
+
|
|
137
|
+
var cursorValue = this.getCursorPosition(props);
|
|
138
|
+
var cursorLabelOffset = this.getCursorLabelOffset(props);
|
|
139
|
+
|
|
140
|
+
if (!cursorValue) {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
var newElements = [];
|
|
145
|
+
var padding = this.getPadding(props);
|
|
146
|
+
var cursorCoordinates = {
|
|
147
|
+
x: horizontal ? scale.y(cursorValue.y) : scale.x(cursorValue.x),
|
|
148
|
+
y: horizontal ? scale.x(cursorValue.x) : scale.y(cursorValue.y)
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
if (cursorLabel) {
|
|
152
|
+
var labelProps = (0, _defaults2.default)({
|
|
153
|
+
active: true
|
|
154
|
+
}, cursorLabelComponent.props, {
|
|
155
|
+
x: cursorCoordinates.x + cursorLabelOffset.x,
|
|
156
|
+
y: cursorCoordinates.y + cursorLabelOffset.y,
|
|
157
|
+
datum: cursorValue,
|
|
158
|
+
active: true,
|
|
159
|
+
key: "".concat(name, "-cursor-label")
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
if (_victoryCore.Helpers.isTooltip(cursorLabelComponent)) {
|
|
163
|
+
var tooltipTheme = theme && theme.tooltip || {};
|
|
164
|
+
labelProps = (0, _defaults2.default)({}, labelProps, tooltipTheme);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
newElements.push( /*#__PURE__*/_react.default.cloneElement(cursorLabelComponent, (0, _defaults2.default)({}, labelProps, {
|
|
168
|
+
text: _victoryCore.Helpers.evaluateProp(cursorLabel, labelProps)
|
|
169
|
+
})));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
var cursorStyle = Object.assign({
|
|
173
|
+
stroke: "black"
|
|
174
|
+
}, cursorComponent.props.style);
|
|
175
|
+
|
|
176
|
+
if (cursorDimension === "x" || cursorDimension === undefined) {
|
|
177
|
+
newElements.push( /*#__PURE__*/_react.default.cloneElement(cursorComponent, {
|
|
178
|
+
key: "".concat(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( /*#__PURE__*/_react.default.cloneElement(cursorComponent, {
|
|
189
|
+
key: "".concat(name, "-y-cursor"),
|
|
190
|
+
x1: padding.left,
|
|
191
|
+
x2: width - padding.right,
|
|
192
|
+
y1: cursorCoordinates.y,
|
|
193
|
+
y2: cursorCoordinates.y,
|
|
194
|
+
style: cursorStyle
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return newElements;
|
|
199
|
+
} // Overrides method in VictoryContainer
|
|
200
|
+
|
|
201
|
+
}, {
|
|
202
|
+
key: "getChildren",
|
|
203
|
+
value: function getChildren(props) {
|
|
204
|
+
return [].concat(_toConsumableArray(_react.default.Children.toArray(props.children)), _toConsumableArray(this.getCursorElements(props)));
|
|
205
|
+
}
|
|
206
|
+
}]);
|
|
207
|
+
|
|
208
|
+
return VictoryCursorContainer;
|
|
209
|
+
}(Base), _class.displayName = "VictoryCursorContainer", _class.defaultProps = _objectSpread(_objectSpread({}, _victoryCore.VictoryContainer.defaultProps), {}, {
|
|
210
|
+
cursorLabelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
|
|
211
|
+
cursorLabelOffset: {
|
|
212
|
+
x: 5,
|
|
213
|
+
y: -10
|
|
214
|
+
},
|
|
215
|
+
cursorComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.LineSegment, null)
|
|
216
|
+
}), _class.defaultEvents = function (props) {
|
|
217
|
+
return [{
|
|
218
|
+
target: "parent",
|
|
219
|
+
eventHandlers: {
|
|
220
|
+
onMouseLeave: function (evt, targetProps) {
|
|
221
|
+
return props.disable ? {} : _cursorHelpers.CursorHelpers.onMouseLeave(evt, targetProps);
|
|
222
|
+
},
|
|
223
|
+
onTouchCancel: function () {
|
|
224
|
+
return [];
|
|
225
|
+
},
|
|
226
|
+
onMouseMove: function (evt, targetProps) {
|
|
227
|
+
return props.disable ? {} : _cursorHelpers.CursorHelpers.onMouseMove(evt, targetProps);
|
|
228
|
+
},
|
|
229
|
+
onTouchMove: function (evt, targetProps) {
|
|
230
|
+
return props.disable ? {} : _cursorHelpers.CursorHelpers.onMouseMove(evt, targetProps);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}];
|
|
234
|
+
}, _class;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
var VictoryCursorContainer = cursorContainerMixin(_victoryCore.VictoryContainer);
|
|
238
|
+
exports.VictoryCursorContainer = VictoryCursorContainer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-cursor-container",
|
|
3
|
-
"version": "36.9.2
|
|
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://
|
|
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
|
|
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 ####": {},
|