victory-cursor-container 36.5.3 → 36.6.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 +34 -0
- package/dist/victory-cursor-container.js +1584 -1434
- package/dist/victory-cursor-container.min.js +1 -1
- package/es/cursor-helpers.d.ts +33 -0
- package/es/cursor-helpers.js +114 -79
- package/es/index.d.ts +3 -37
- package/es/index.js +2 -2
- package/es/victory-cursor-container.d.ts +221 -0
- package/es/victory-cursor-container.js +10 -9
- package/lib/cursor-helpers.d.ts +33 -0
- package/lib/cursor-helpers.js +117 -85
- package/lib/index.d.ts +3 -37
- package/lib/index.js +22 -24
- package/lib/victory-cursor-container.d.ts +221 -0
- package/lib/victory-cursor-container.js +17 -18
- package/package.json +244 -7
- package/src/{cursor-helpers.js → cursor-helpers.tsx} +24 -12
- package/src/index.tsx +2 -0
- package/src/{victory-cursor-container.js → victory-cursor-container.tsx} +33 -7
- package/src/index.d.ts +0 -37
- package/src/index.js +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-cursor-container",
|
|
3
|
-
"version": "36.
|
|
3
|
+
"version": "36.6.2",
|
|
4
4
|
"description": "Interactive Cursor Component for Victory",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/formidablelabs/victory.git"
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://formidable.com/open-source/victory",
|
|
16
|
+
"sideEffects": false,
|
|
16
17
|
"main": "lib/index.js",
|
|
17
18
|
"module": "es/index.js",
|
|
18
19
|
"jsnext:main": "es/index.js",
|
|
@@ -21,14 +22,250 @@
|
|
|
21
22
|
"dependencies": {
|
|
22
23
|
"lodash": "^4.17.19",
|
|
23
24
|
"prop-types": "^15.8.1",
|
|
24
|
-
"victory-core": "^36.
|
|
25
|
+
"victory-core": "^36.6.2"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"react": ">=16.6.0"
|
|
28
29
|
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
30
|
+
"wireit": {
|
|
31
|
+
"### THESE WIREIT CONFIGS ARE GENERATED ####": {},
|
|
32
|
+
"### DO NOT MODIFY THESE MANUALLY ####": {},
|
|
33
|
+
"build": {
|
|
34
|
+
"dependencies": [
|
|
35
|
+
"build:lib",
|
|
36
|
+
"build:dist",
|
|
37
|
+
"types:create"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"build:lib": {
|
|
41
|
+
"dependencies": [
|
|
42
|
+
"build:lib:esm",
|
|
43
|
+
"build:lib:cjs"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"build:lib:esm": {
|
|
47
|
+
"command": "nps build:lib:esm",
|
|
48
|
+
"files": [
|
|
49
|
+
"src/**",
|
|
50
|
+
"!src/**/*.test.*",
|
|
51
|
+
"../../.babelrc.build.js"
|
|
52
|
+
],
|
|
53
|
+
"output": [
|
|
54
|
+
"es/**/*.js",
|
|
55
|
+
"es/**/*.js.map"
|
|
56
|
+
],
|
|
57
|
+
"dependencies": [
|
|
58
|
+
"../victory-core:build:lib:esm"
|
|
59
|
+
],
|
|
60
|
+
"packageLocks": [
|
|
61
|
+
"pnpm-lock.yaml"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"build:lib:cjs": {
|
|
65
|
+
"command": "nps build:lib:cjs",
|
|
66
|
+
"files": [
|
|
67
|
+
"src/**",
|
|
68
|
+
"!src/**/*.test.*",
|
|
69
|
+
"../../.babelrc.build.js"
|
|
70
|
+
],
|
|
71
|
+
"output": [
|
|
72
|
+
"lib/**/*.js",
|
|
73
|
+
"lib/**/*.js.map"
|
|
74
|
+
],
|
|
75
|
+
"dependencies": [
|
|
76
|
+
"../victory-core:build:lib:cjs"
|
|
77
|
+
],
|
|
78
|
+
"packageLocks": [
|
|
79
|
+
"pnpm-lock.yaml"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"build:dist": {
|
|
83
|
+
"dependencies": [
|
|
84
|
+
"build:dist:dev",
|
|
85
|
+
"build:dist:min"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"build:dist:dev": {
|
|
89
|
+
"command": "nps build:dist:dev",
|
|
90
|
+
"files": [
|
|
91
|
+
"src/**",
|
|
92
|
+
"!src/**/*.test.*",
|
|
93
|
+
"../../.babelrc.build.js",
|
|
94
|
+
"../../config/webpack.config.js",
|
|
95
|
+
"../../config/webpack.config.dev.js"
|
|
96
|
+
],
|
|
97
|
+
"output": [
|
|
98
|
+
"dist/victory*.js",
|
|
99
|
+
"!dist/victory*.min.js*"
|
|
100
|
+
],
|
|
101
|
+
"dependencies": [
|
|
102
|
+
"../victory-core:build:lib:esm"
|
|
103
|
+
],
|
|
104
|
+
"packageLocks": [
|
|
105
|
+
"pnpm-lock.yaml"
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
"build:dist:min": {
|
|
109
|
+
"command": "nps build:dist:min",
|
|
110
|
+
"files": [
|
|
111
|
+
"src/**",
|
|
112
|
+
"!src/**/*.test.*",
|
|
113
|
+
"../../.babelrc.build.js",
|
|
114
|
+
"../../config/webpack.config.js"
|
|
115
|
+
],
|
|
116
|
+
"output": [
|
|
117
|
+
"dist/victory*.min.js*"
|
|
118
|
+
],
|
|
119
|
+
"dependencies": [
|
|
120
|
+
"../victory-core:build:lib:esm"
|
|
121
|
+
],
|
|
122
|
+
"packageLocks": [
|
|
123
|
+
"pnpm-lock.yaml"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
"check": {
|
|
127
|
+
"dependencies": [
|
|
128
|
+
"types:check",
|
|
129
|
+
"jest",
|
|
130
|
+
"format",
|
|
131
|
+
"lint"
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
"types:check": {
|
|
135
|
+
"command": "nps types:pkg:check",
|
|
136
|
+
"files": [
|
|
137
|
+
"src/**/*.{ts,tsx}",
|
|
138
|
+
"../../tsconfig.base.json",
|
|
139
|
+
"tsconfig.json"
|
|
140
|
+
],
|
|
141
|
+
"dependencies": [
|
|
142
|
+
"types:create",
|
|
143
|
+
"../victory-core:types:create",
|
|
144
|
+
"../victory-vendor:types:create",
|
|
145
|
+
"../victory-voronoi:types:create"
|
|
146
|
+
],
|
|
147
|
+
"output": [],
|
|
148
|
+
"packageLocks": [
|
|
149
|
+
"pnpm-lock.yaml"
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
"types:create": {
|
|
153
|
+
"command": "nps types:pkg:create",
|
|
154
|
+
"files": [
|
|
155
|
+
"src/**",
|
|
156
|
+
"!src/**/*.test.*",
|
|
157
|
+
"../../tsconfig.base.json",
|
|
158
|
+
"tsconfig.build.json"
|
|
159
|
+
],
|
|
160
|
+
"output": [
|
|
161
|
+
"es/**/*.d.ts",
|
|
162
|
+
"es/**/*.d.ts.map",
|
|
163
|
+
"lib/**/*.d.ts",
|
|
164
|
+
"lib/**/*.d.ts.map"
|
|
165
|
+
],
|
|
166
|
+
"dependencies": [
|
|
167
|
+
"../victory-core:types:create"
|
|
168
|
+
],
|
|
169
|
+
"packageLocks": [
|
|
170
|
+
"pnpm-lock.yaml"
|
|
171
|
+
]
|
|
172
|
+
},
|
|
173
|
+
"format": {
|
|
174
|
+
"command": "nps format:pkg",
|
|
175
|
+
"files": [
|
|
176
|
+
"src/**",
|
|
177
|
+
"*.json",
|
|
178
|
+
"../../.prettierignore",
|
|
179
|
+
"../../.prettierrc.json"
|
|
180
|
+
],
|
|
181
|
+
"output": [],
|
|
182
|
+
"packageLocks": [
|
|
183
|
+
"pnpm-lock.yaml"
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
"format:fix": {
|
|
187
|
+
"command": "pnpm run format || nps format:pkg:fix",
|
|
188
|
+
"files": [
|
|
189
|
+
"src/**",
|
|
190
|
+
"*.json",
|
|
191
|
+
"../../.prettierignore",
|
|
192
|
+
"../../.prettierrc.json"
|
|
193
|
+
],
|
|
194
|
+
"output": [],
|
|
195
|
+
"packageLocks": [
|
|
196
|
+
"pnpm-lock.yaml"
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
"lint": {
|
|
200
|
+
"command": "nps lint:pkg",
|
|
201
|
+
"files": [
|
|
202
|
+
"src/**",
|
|
203
|
+
"../../.eslintignore",
|
|
204
|
+
"../../.eslintrc.js"
|
|
205
|
+
],
|
|
206
|
+
"output": [],
|
|
207
|
+
"dependencies": [
|
|
208
|
+
"../victory-core:types:create",
|
|
209
|
+
"../victory-vendor:types:create",
|
|
210
|
+
"../victory-voronoi:types:create"
|
|
211
|
+
],
|
|
212
|
+
"packageLocks": [
|
|
213
|
+
"pnpm-lock.yaml"
|
|
214
|
+
]
|
|
215
|
+
},
|
|
216
|
+
"lint:fix": {
|
|
217
|
+
"command": "pnpm run lint || nps lint:pkg:fix",
|
|
218
|
+
"files": [
|
|
219
|
+
"src/**",
|
|
220
|
+
"../../.eslintignore",
|
|
221
|
+
"../../.eslintrc.js"
|
|
222
|
+
],
|
|
223
|
+
"output": [],
|
|
224
|
+
"dependencies": [
|
|
225
|
+
"../victory-core:types:create",
|
|
226
|
+
"../victory-vendor:types:create",
|
|
227
|
+
"../victory-voronoi:types:create"
|
|
228
|
+
],
|
|
229
|
+
"packageLocks": [
|
|
230
|
+
"pnpm-lock.yaml"
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
"jest": {
|
|
234
|
+
"command": "nps jest:pkg",
|
|
235
|
+
"files": [
|
|
236
|
+
"src/**/*.test.*",
|
|
237
|
+
"../../.babelrc.js",
|
|
238
|
+
"../../test/jest-config.js",
|
|
239
|
+
"../../test/jest-setup.ts"
|
|
240
|
+
],
|
|
241
|
+
"output": [],
|
|
242
|
+
"dependencies": [
|
|
243
|
+
"build:lib:cjs",
|
|
244
|
+
"../victory-vendor:build:lib:cjs",
|
|
245
|
+
"../victory-voronoi:build:lib:cjs"
|
|
246
|
+
],
|
|
247
|
+
"packageLocks": [
|
|
248
|
+
"pnpm-lock.yaml"
|
|
249
|
+
]
|
|
250
|
+
}
|
|
31
251
|
},
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
252
|
+
"scripts": {
|
|
253
|
+
"### THESE SCRIPTS ARE GENERATED ###": "true",
|
|
254
|
+
"### DO NOT MODIFY THESE MANUALLY ###": "true",
|
|
255
|
+
"build": "wireit",
|
|
256
|
+
"build:lib": "wireit",
|
|
257
|
+
"build:lib:esm": "wireit",
|
|
258
|
+
"build:lib:cjs": "wireit",
|
|
259
|
+
"build:dist": "wireit",
|
|
260
|
+
"build:dist:dev": "wireit",
|
|
261
|
+
"build:dist:min": "wireit",
|
|
262
|
+
"check": "wireit",
|
|
263
|
+
"types:check": "wireit",
|
|
264
|
+
"types:create": "wireit",
|
|
265
|
+
"format": "wireit",
|
|
266
|
+
"format:fix": "wireit",
|
|
267
|
+
"lint": "wireit",
|
|
268
|
+
"lint:fix": "wireit",
|
|
269
|
+
"jest": "wireit"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Selection } from "victory-core";
|
|
1
|
+
import { Selection, SVGCoordinateType } from "victory-core";
|
|
2
2
|
import { throttle, isFunction, mapValues } from "lodash";
|
|
3
3
|
|
|
4
4
|
const ON_MOUSE_MOVE_THROTTLE_MS = 16;
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
class CursorHelpersClass {
|
|
7
7
|
getDimension(props) {
|
|
8
8
|
const { horizontal, cursorDimension } = props;
|
|
9
9
|
if (!horizontal || !cursorDimension) {
|
|
10
10
|
return cursorDimension;
|
|
11
11
|
}
|
|
12
12
|
return cursorDimension === "x" ? "y" : "x";
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
14
|
|
|
15
15
|
withinBounds(point, bounds) {
|
|
16
16
|
const { x1, x2, y1, y2 } = mapValues(bounds, Number);
|
|
@@ -21,14 +21,14 @@ const CursorHelpers = {
|
|
|
21
21
|
y >= Math.min(y1, y2) &&
|
|
22
22
|
y <= Math.max(y1, y2)
|
|
23
23
|
);
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
private handleMouseMove = (evt, targetProps) => {
|
|
27
27
|
const { onCursorChange, domain } = targetProps;
|
|
28
28
|
const cursorDimension = this.getDimension(targetProps);
|
|
29
29
|
const parentSVG = targetProps.parentSVG || Selection.getParentSVG(evt);
|
|
30
30
|
const cursorSVGPosition = Selection.getSVGEventCoordinates(evt, parentSVG);
|
|
31
|
-
let cursorValue = Selection.getDataCoordinates(
|
|
31
|
+
let cursorValue: SVGCoordinateType | null = Selection.getDataCoordinates(
|
|
32
32
|
targetProps,
|
|
33
33
|
targetProps.scale,
|
|
34
34
|
cursorSVGPosition.x,
|
|
@@ -47,7 +47,7 @@ const CursorHelpers = {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
if (isFunction(onCursorChange)) {
|
|
50
|
-
if (
|
|
50
|
+
if (cursorValue) {
|
|
51
51
|
const value = cursorDimension
|
|
52
52
|
? cursorValue[cursorDimension]
|
|
53
53
|
: cursorValue;
|
|
@@ -64,9 +64,16 @@ const CursorHelpers = {
|
|
|
64
64
|
mutation: () => ({ cursorValue, parentSVG }),
|
|
65
65
|
},
|
|
66
66
|
];
|
|
67
|
-
}
|
|
67
|
+
};
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
onMouseMove = throttle(this.handleMouseMove, ON_MOUSE_MOVE_THROTTLE_MS, {
|
|
70
|
+
leading: true,
|
|
71
|
+
trailing: false,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
onMouseLeave = this.handleMouseMove;
|
|
75
|
+
|
|
76
|
+
onTouchEnd = (evt, targetProps) => {
|
|
70
77
|
const { onCursorChange } = targetProps;
|
|
71
78
|
|
|
72
79
|
if (isFunction(targetProps.onCursorChange)) {
|
|
@@ -80,10 +87,12 @@ const CursorHelpers = {
|
|
|
80
87
|
mutation: () => ({ cursorValue: null }),
|
|
81
88
|
},
|
|
82
89
|
];
|
|
83
|
-
}
|
|
84
|
-
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
85
92
|
|
|
86
|
-
export
|
|
93
|
+
export const CursorHelpers = new CursorHelpersClass();
|
|
94
|
+
|
|
95
|
+
/* {
|
|
87
96
|
...CursorHelpers,
|
|
88
97
|
onMouseMove: throttle(
|
|
89
98
|
CursorHelpers.onMouseMove.bind(CursorHelpers),
|
|
@@ -96,3 +105,6 @@ export default {
|
|
|
96
105
|
onMouseLeave: CursorHelpers.onMouseMove.bind(CursorHelpers),
|
|
97
106
|
onTouchEnd: CursorHelpers.onTouchEnd.bind(CursorHelpers),
|
|
98
107
|
};
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
*/
|
package/src/index.tsx
ADDED
|
@@ -5,12 +5,38 @@ import {
|
|
|
5
5
|
VictoryLabel,
|
|
6
6
|
LineSegment,
|
|
7
7
|
Helpers,
|
|
8
|
+
VictoryContainerProps,
|
|
9
|
+
CoordinatesPropType,
|
|
10
|
+
VictoryLabelProps,
|
|
11
|
+
ValueOrCallback,
|
|
8
12
|
} from "victory-core";
|
|
9
13
|
import { defaults, assign, isObject } from "lodash";
|
|
10
|
-
import CursorHelpers from "./cursor-helpers";
|
|
14
|
+
import { CursorHelpers } from "./cursor-helpers";
|
|
11
15
|
|
|
12
|
-
export
|
|
13
|
-
|
|
16
|
+
export type CursorCoordinatesPropType = CoordinatesPropType | number;
|
|
17
|
+
|
|
18
|
+
export interface VictoryCursorContainerProps extends VictoryContainerProps {
|
|
19
|
+
cursorComponent?: React.ReactElement;
|
|
20
|
+
cursorDimension?: "x" | "y";
|
|
21
|
+
cursorLabel?: ValueOrCallback<VictoryLabelProps["text"]>;
|
|
22
|
+
cursorLabelComponent?: React.ReactElement;
|
|
23
|
+
cursorLabelOffset?: CursorCoordinatesPropType;
|
|
24
|
+
defaultCursorValue?: CursorCoordinatesPropType;
|
|
25
|
+
disable?: boolean;
|
|
26
|
+
onCursorChange?: (
|
|
27
|
+
value: CursorCoordinatesPropType,
|
|
28
|
+
props: VictoryCursorContainerProps,
|
|
29
|
+
) => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type ComponentClass<TProps> = { new (props: TProps): React.Component<TProps> };
|
|
33
|
+
|
|
34
|
+
export function cursorContainerMixin<
|
|
35
|
+
TBase extends ComponentClass<TProps>,
|
|
36
|
+
TProps extends VictoryCursorContainerProps,
|
|
37
|
+
>(Base: TBase) {
|
|
38
|
+
// @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'."
|
|
39
|
+
return class VictoryCursorContainer extends Base {
|
|
14
40
|
static displayName = "VictoryCursorContainer";
|
|
15
41
|
static propTypes = {
|
|
16
42
|
...VictoryContainer.propTypes,
|
|
@@ -109,9 +135,8 @@ export const cursorContainerMixin = (base) =>
|
|
|
109
135
|
return isObject(c.props) && c.props.padding !== undefined;
|
|
110
136
|
});
|
|
111
137
|
return Helpers.getPadding(child.props);
|
|
112
|
-
} else {
|
|
113
|
-
return Helpers.getPadding(props);
|
|
114
138
|
}
|
|
139
|
+
return Helpers.getPadding(props);
|
|
115
140
|
}
|
|
116
141
|
|
|
117
142
|
getCursorElements(props) {
|
|
@@ -135,7 +160,7 @@ export const cursorContainerMixin = (base) =>
|
|
|
135
160
|
return [];
|
|
136
161
|
}
|
|
137
162
|
|
|
138
|
-
const newElements = [];
|
|
163
|
+
const newElements: React.ReactElement[] = [];
|
|
139
164
|
const padding = this.getPadding(props);
|
|
140
165
|
const cursorCoordinates = {
|
|
141
166
|
x: horizontal ? scale.y(cursorValue.y) : scale.x(cursorValue.x),
|
|
@@ -206,5 +231,6 @@ export const cursorContainerMixin = (base) =>
|
|
|
206
231
|
];
|
|
207
232
|
}
|
|
208
233
|
};
|
|
234
|
+
}
|
|
209
235
|
|
|
210
|
-
export
|
|
236
|
+
export const VictoryCursorContainer = cursorContainerMixin(VictoryContainer);
|
package/src/index.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
VictoryContainerProps,
|
|
4
|
-
CoordinatesPropType,
|
|
5
|
-
CallbackArgs,
|
|
6
|
-
} from "victory-core";
|
|
7
|
-
|
|
8
|
-
export type CursorCoordinatesPropType = CoordinatesPropType | number;
|
|
9
|
-
|
|
10
|
-
export interface VictoryCursorContainerProps extends VictoryContainerProps {
|
|
11
|
-
cursorComponent?: React.ReactElement;
|
|
12
|
-
cursorDimension?: "x" | "y";
|
|
13
|
-
cursorLabel?: (point: CoordinatesPropType, args: CallbackArgs) => any | void;
|
|
14
|
-
cursorLabelComponent?: React.ReactElement;
|
|
15
|
-
cursorLabelOffset?: CursorCoordinatesPropType;
|
|
16
|
-
defaultCursorValue?: CursorCoordinatesPropType;
|
|
17
|
-
disable?: boolean;
|
|
18
|
-
onCursorChange?: (
|
|
19
|
-
value: CursorCoordinatesPropType,
|
|
20
|
-
props: VictoryCursorContainerProps,
|
|
21
|
-
) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class VictoryCursorContainer extends React.Component<
|
|
25
|
-
VictoryCursorContainerProps,
|
|
26
|
-
any
|
|
27
|
-
> {}
|
|
28
|
-
|
|
29
|
-
export const CursorHelpers: {
|
|
30
|
-
getDimension(props): any;
|
|
31
|
-
withinBounds(point, bounds): any;
|
|
32
|
-
onMouseMove(evt, targetProps): any;
|
|
33
|
-
onMouseLeave(evt, targetProps): any;
|
|
34
|
-
onTouchEnd(evt, targetProps): any;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const cursorContainerMixin: (base: Function) => Function;
|