victory-cursor-container 36.6.0 → 36.6.1

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,5 +1,16 @@
1
1
  # victory-cursor-container
2
2
 
3
+ ## 36.6.1
4
+
5
+ ### Patch Changes
6
+
7
+ - - Removed Template Literal Types to increase TS compatibility (fixes [#2418](https://github.com/FormidableLabs/victory/issues/2418)) ([#2420](https://github.com/FormidableLabs/victory/pull/2420))
8
+ - Improved type for `VictoryLabelProps["textAnchor"]` (fixes [#2361](https://github.com/FormidableLabs/victory/issues/2361))
9
+ - Fixed exported types for `VictoryAxis`, `VictoryBoxPlot`, `VictoryErrorBar`, and `VictoryScatter` (fixes [#2411](https://github.com/FormidableLabs/victory/issues/2411))
10
+ - Migrate `victory-cursor-container` to TS (fixes [#2402](https://github.com/FormidableLabs/victory/issues/2402))
11
+ - Updated dependencies [[`d1f281104`](https://github.com/FormidableLabs/victory/commit/d1f281104c7598c43e220dafd57546ab03daeeb5)]:
12
+ - victory-core@36.6.1
13
+
3
14
  ## 36.6.0
4
15
 
5
16
  ### Patch Changes
@@ -11,16 +11,16 @@
11
11
  return /******/ (() => { // webpackBootstrap
12
12
  /******/ var __webpack_modules__ = ({
13
13
 
14
- /***/ "./cursor-helpers.js":
15
- /*!***************************!*\
16
- !*** ./cursor-helpers.js ***!
17
- \***************************/
14
+ /***/ "./cursor-helpers.tsx":
15
+ /*!****************************!*\
16
+ !*** ./cursor-helpers.tsx ***!
17
+ \****************************/
18
18
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
19
19
 
20
20
  "use strict";
21
21
  __webpack_require__.r(__webpack_exports__);
22
22
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
23
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
23
+ /* harmony export */ "CursorHelpers": () => (/* binding */ CursorHelpers)
24
24
  /* harmony export */ });
25
25
  /* harmony import */ var lodash_mapValues__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/mapValues */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/mapValues.js");
26
26
  /* harmony import */ var lodash_mapValues__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_mapValues__WEBPACK_IMPORTED_MODULE_0__);
@@ -33,116 +33,151 @@ __webpack_require__.r(__webpack_exports__);
33
33
 
34
34
 
35
35
 
36
- 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; }
36
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
37
37
 
38
- 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; }
38
+ 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); } }
39
39
 
40
- 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; }
40
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
41
41
 
42
42
 
43
43
  var ON_MOUSE_MOVE_THROTTLE_MS = 16;
44
- var CursorHelpers = {
45
- getDimension: function (props) {
46
- var horizontal = props.horizontal,
47
- cursorDimension = props.cursorDimension;
48
44
 
49
- if (!horizontal || !cursorDimension) {
50
- return cursorDimension;
51
- }
45
+ var CursorHelpersClass = /*#__PURE__*/function () {
46
+ function CursorHelpersClass() {
47
+ var _this = this;
52
48
 
53
- return cursorDimension === "x" ? "y" : "x";
54
- },
55
- withinBounds: function (point, bounds) {
56
- var _mapValues2 = lodash_mapValues__WEBPACK_IMPORTED_MODULE_0___default()(bounds, Number),
57
- x1 = _mapValues2.x1,
58
- x2 = _mapValues2.x2,
59
- y1 = _mapValues2.y1,
60
- y2 = _mapValues2.y2;
61
-
62
- var _mapValues3 = lodash_mapValues__WEBPACK_IMPORTED_MODULE_0___default()(point, Number),
63
- x = _mapValues3.x,
64
- y = _mapValues3.y;
65
-
66
- return x >= Math.min(x1, x2) && x <= Math.max(x1, x2) && y >= Math.min(y1, y2) && y <= Math.max(y1, y2);
67
- },
68
- onMouseMove: function (evt, targetProps) {
69
- var onCursorChange = targetProps.onCursorChange,
70
- domain = targetProps.domain;
71
- var cursorDimension = this.getDimension(targetProps);
72
- var parentSVG = targetProps.parentSVG || victory_core__WEBPACK_IMPORTED_MODULE_3__.getParentSVG(evt);
73
- var cursorSVGPosition = victory_core__WEBPACK_IMPORTED_MODULE_3__.getSVGEventCoordinates(evt, parentSVG);
74
- var cursorValue = victory_core__WEBPACK_IMPORTED_MODULE_3__.getDataCoordinates(targetProps, targetProps.scale, cursorSVGPosition.x, cursorSVGPosition.y);
75
- var inBounds = this.withinBounds(cursorValue, {
76
- x1: domain.x[0],
77
- x2: domain.x[1],
78
- y1: domain.y[0],
79
- y2: domain.y[1]
80
- });
49
+ _classCallCheck(this, CursorHelpersClass);
81
50
 
82
- if (!inBounds) {
83
- cursorValue = null;
84
- }
51
+ this.handleMouseMove = function (evt, targetProps) {
52
+ var onCursorChange = targetProps.onCursorChange,
53
+ domain = targetProps.domain;
54
+
55
+ var cursorDimension = _this.getDimension(targetProps);
56
+
57
+ var parentSVG = targetProps.parentSVG || victory_core__WEBPACK_IMPORTED_MODULE_3__.getParentSVG(evt);
58
+ var cursorSVGPosition = victory_core__WEBPACK_IMPORTED_MODULE_3__.getSVGEventCoordinates(evt, parentSVG);
59
+ var cursorValue = victory_core__WEBPACK_IMPORTED_MODULE_3__.getDataCoordinates(targetProps, targetProps.scale, cursorSVGPosition.x, cursorSVGPosition.y);
60
+
61
+ var inBounds = _this.withinBounds(cursorValue, {
62
+ x1: domain.x[0],
63
+ x2: domain.x[1],
64
+ y1: domain.y[0],
65
+ y2: domain.y[1]
66
+ });
85
67
 
86
- if (lodash_isFunction__WEBPACK_IMPORTED_MODULE_1___default()(onCursorChange)) {
87
- if (inBounds) {
88
- var value = cursorDimension ? cursorValue[cursorDimension] : cursorValue;
89
- onCursorChange(value, targetProps);
90
- } else if (cursorValue !== targetProps.cursorValue) {
91
- onCursorChange(targetProps.defaultCursorValue || null, targetProps);
68
+ if (!inBounds) {
69
+ cursorValue = null;
92
70
  }
93
- }
94
71
 
95
- return [{
96
- target: "parent",
97
- eventKey: "parent",
98
- mutation: function () {
99
- return {
100
- cursorValue: cursorValue,
101
- parentSVG: parentSVG
102
- };
72
+ if (lodash_isFunction__WEBPACK_IMPORTED_MODULE_1___default()(onCursorChange)) {
73
+ if (cursorValue) {
74
+ var value = cursorDimension ? cursorValue[cursorDimension] : cursorValue;
75
+ onCursorChange(value, targetProps);
76
+ } else if (cursorValue !== targetProps.cursorValue) {
77
+ onCursorChange(targetProps.defaultCursorValue || null, targetProps);
78
+ }
103
79
  }
104
- }];
105
- },
106
- onTouchEnd: function (evt, targetProps) {
107
- var onCursorChange = targetProps.onCursorChange;
108
80
 
109
- if (lodash_isFunction__WEBPACK_IMPORTED_MODULE_1___default()(targetProps.onCursorChange)) {
110
- onCursorChange(null, targetProps);
111
- }
81
+ return [{
82
+ target: "parent",
83
+ eventKey: "parent",
84
+ mutation: function () {
85
+ return {
86
+ cursorValue: cursorValue,
87
+ parentSVG: parentSVG
88
+ };
89
+ }
90
+ }];
91
+ };
112
92
 
113
- return [{
114
- target: "parent",
115
- eventKey: "parent",
116
- mutation: function () {
117
- return {
118
- cursorValue: null
119
- };
93
+ this.onMouseMove = lodash_throttle__WEBPACK_IMPORTED_MODULE_2___default()(this.handleMouseMove, ON_MOUSE_MOVE_THROTTLE_MS, {
94
+ leading: true,
95
+ trailing: false
96
+ });
97
+ this.onMouseLeave = this.handleMouseMove;
98
+
99
+ this.onTouchEnd = function (evt, targetProps) {
100
+ var onCursorChange = targetProps.onCursorChange;
101
+
102
+ if (lodash_isFunction__WEBPACK_IMPORTED_MODULE_1___default()(targetProps.onCursorChange)) {
103
+ onCursorChange(null, targetProps);
120
104
  }
121
- }];
105
+
106
+ return [{
107
+ target: "parent",
108
+ eventKey: "parent",
109
+ mutation: function () {
110
+ return {
111
+ cursorValue: null
112
+ };
113
+ }
114
+ }];
115
+ };
122
116
  }
123
- };
124
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_objectSpread(_objectSpread({}, CursorHelpers), {}, {
125
- onMouseMove: lodash_throttle__WEBPACK_IMPORTED_MODULE_2___default()(CursorHelpers.onMouseMove.bind(CursorHelpers), ON_MOUSE_MOVE_THROTTLE_MS, {
126
- leading: true,
127
- trailing: false
128
- }),
117
+
118
+ _createClass(CursorHelpersClass, [{
119
+ key: "getDimension",
120
+ value: function getDimension(props) {
121
+ var horizontal = props.horizontal,
122
+ cursorDimension = props.cursorDimension;
123
+
124
+ if (!horizontal || !cursorDimension) {
125
+ return cursorDimension;
126
+ }
127
+
128
+ return cursorDimension === "x" ? "y" : "x";
129
+ }
130
+ }, {
131
+ key: "withinBounds",
132
+ value: function withinBounds(point, bounds) {
133
+ var _mapValues2 = lodash_mapValues__WEBPACK_IMPORTED_MODULE_0___default()(bounds, Number),
134
+ x1 = _mapValues2.x1,
135
+ x2 = _mapValues2.x2,
136
+ y1 = _mapValues2.y1,
137
+ y2 = _mapValues2.y2;
138
+
139
+ var _mapValues3 = lodash_mapValues__WEBPACK_IMPORTED_MODULE_0___default()(point, Number),
140
+ x = _mapValues3.x,
141
+ y = _mapValues3.y;
142
+
143
+ return x >= Math.min(x1, x2) && x <= Math.max(x1, x2) && y >= Math.min(y1, y2) && y <= Math.max(y1, y2);
144
+ }
145
+ }]);
146
+
147
+ return CursorHelpersClass;
148
+ }();
149
+
150
+ var CursorHelpers = new CursorHelpersClass();
151
+ /* {
152
+ ...CursorHelpers,
153
+ onMouseMove: throttle(
154
+ CursorHelpers.onMouseMove.bind(CursorHelpers),
155
+ ON_MOUSE_MOVE_THROTTLE_MS,
156
+ {
157
+ leading: true,
158
+ trailing: false,
159
+ },
160
+ ),
129
161
  onMouseLeave: CursorHelpers.onMouseMove.bind(CursorHelpers),
130
- onTouchEnd: CursorHelpers.onTouchEnd.bind(CursorHelpers)
131
- }));
162
+ onTouchEnd: CursorHelpers.onTouchEnd.bind(CursorHelpers),
163
+ };
164
+
165
+
166
+ */
132
167
 
133
168
  /***/ }),
134
169
 
135
- /***/ "./victory-cursor-container.js":
136
- /*!*************************************!*\
137
- !*** ./victory-cursor-container.js ***!
138
- \*************************************/
170
+ /***/ "./victory-cursor-container.tsx":
171
+ /*!**************************************!*\
172
+ !*** ./victory-cursor-container.tsx ***!
173
+ \**************************************/
139
174
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
140
175
 
141
176
  "use strict";
142
177
  __webpack_require__.r(__webpack_exports__);
143
178
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
144
- /* harmony export */ "cursorContainerMixin": () => (/* binding */ cursorContainerMixin),
145
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
179
+ /* harmony export */ "VictoryCursorContainer": () => (/* binding */ VictoryCursorContainer),
180
+ /* harmony export */ "cursorContainerMixin": () => (/* binding */ cursorContainerMixin)
146
181
  /* harmony export */ });
147
182
  /* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/isObject */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/isObject.js");
148
183
  /* harmony import */ var lodash_isObject__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_isObject__WEBPACK_IMPORTED_MODULE_0__);
@@ -158,7 +193,7 @@ __webpack_require__.r(__webpack_exports__);
158
193
  /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-container/victory-container.js");
159
194
  /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-label/victory-label.js");
160
195
  /* harmony import */ var victory_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! victory-core */ "../../victory-core/es/victory-primitives/line-segment.js");
161
- /* harmony import */ var _cursor_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./cursor-helpers */ "./cursor-helpers.js");
196
+ /* harmony import */ var _cursor_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./cursor-helpers */ "./cursor-helpers.tsx");
162
197
 
163
198
 
164
199
 
@@ -205,11 +240,12 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
205
240
 
206
241
 
207
242
 
208
- var cursorContainerMixin = function (base) {
243
+ function cursorContainerMixin(Base) {
209
244
  var _class;
210
245
 
211
- return _class = /*#__PURE__*/function (_base) {
212
- _inherits(VictoryCursorContainer, _base);
246
+ // @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'."
247
+ return _class = /*#__PURE__*/function (_Base) {
248
+ _inherits(VictoryCursorContainer, _Base);
213
249
 
214
250
  var _super = _createSuper(VictoryCursorContainer);
215
251
 
@@ -279,7 +315,7 @@ var cursorContainerMixin = function (base) {
279
315
  name = props.name,
280
316
  horizontal = props.horizontal,
281
317
  theme = props.theme;
282
- var cursorDimension = _cursor_helpers__WEBPACK_IMPORTED_MODULE_5__["default"].getDimension(props);
318
+ var cursorDimension = _cursor_helpers__WEBPACK_IMPORTED_MODULE_5__.CursorHelpers.getDimension(props);
283
319
  var cursorValue = this.getCursorPosition(props);
284
320
  var cursorLabelOffset = this.getCursorLabelOffset(props);
285
321
 
@@ -352,7 +388,7 @@ var cursorContainerMixin = function (base) {
352
388
  }]);
353
389
 
354
390
  return VictoryCursorContainer;
355
- }(base), _class.displayName = "VictoryCursorContainer", _class.propTypes = _objectSpread(_objectSpread({}, victory_core__WEBPACK_IMPORTED_MODULE_6__.VictoryContainer.propTypes), {}, {
391
+ }(Base), _class.displayName = "VictoryCursorContainer", _class.propTypes = _objectSpread(_objectSpread({}, victory_core__WEBPACK_IMPORTED_MODULE_6__.VictoryContainer.propTypes), {}, {
356
392
  cursorDimension: prop_types__WEBPACK_IMPORTED_MODULE_7___default().oneOf(["x", "y"]),
357
393
  cursorLabel: (prop_types__WEBPACK_IMPORTED_MODULE_7___default().func),
358
394
  cursorLabelComponent: (prop_types__WEBPACK_IMPORTED_MODULE_7___default().element),
@@ -378,22 +414,22 @@ var cursorContainerMixin = function (base) {
378
414
  target: "parent",
379
415
  eventHandlers: {
380
416
  onMouseLeave: function (evt, targetProps) {
381
- return props.disable ? {} : _cursor_helpers__WEBPACK_IMPORTED_MODULE_5__["default"].onMouseLeave(evt, targetProps);
417
+ return props.disable ? {} : _cursor_helpers__WEBPACK_IMPORTED_MODULE_5__.CursorHelpers.onMouseLeave(evt, targetProps);
382
418
  },
383
419
  onTouchCancel: function () {
384
420
  return [];
385
421
  },
386
422
  onMouseMove: function (evt, targetProps) {
387
- return props.disable ? {} : _cursor_helpers__WEBPACK_IMPORTED_MODULE_5__["default"].onMouseMove(evt, targetProps);
423
+ return props.disable ? {} : _cursor_helpers__WEBPACK_IMPORTED_MODULE_5__.CursorHelpers.onMouseMove(evt, targetProps);
388
424
  },
389
425
  onTouchMove: function (evt, targetProps) {
390
- return props.disable ? {} : _cursor_helpers__WEBPACK_IMPORTED_MODULE_5__["default"].onMouseMove(evt, targetProps);
426
+ return props.disable ? {} : _cursor_helpers__WEBPACK_IMPORTED_MODULE_5__.CursorHelpers.onMouseMove(evt, targetProps);
391
427
  }
392
428
  }
393
429
  }];
394
430
  }, _class;
395
- };
396
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (cursorContainerMixin(victory_core__WEBPACK_IMPORTED_MODULE_6__.VictoryContainer));
431
+ }
432
+ var VictoryCursorContainer = cursorContainerMixin(victory_core__WEBPACK_IMPORTED_MODULE_6__.VictoryContainer);
397
433
 
398
434
  /***/ }),
399
435
 
@@ -9343,7 +9379,9 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
9343
9379
  var USER_PROPS_SAFELIST = {
9344
9380
  startsWith: ["data-", "aria-"],
9345
9381
  exactMatch: []
9346
- };
9382
+ }; // Normally we'd use Template Literal Types, but we're avoiding it to maximize TS compatibility with TS < 4.1
9383
+
9384
+ // `data-${string}` | `aria-${string}`;
9347
9385
 
9348
9386
  /**
9349
9387
  * doesPropStartWith: Function that takes a prop's key and runs it against all
@@ -15270,17 +15308,17 @@ var __webpack_exports__ = {};
15270
15308
  // This entry need to be wrapped in an IIFE because it need to be in strict mode.
15271
15309
  (() => {
15272
15310
  "use strict";
15273
- /*!******************!*\
15274
- !*** ./index.js ***!
15275
- \******************/
15311
+ /*!*******************!*\
15312
+ !*** ./index.tsx ***!
15313
+ \*******************/
15276
15314
  __webpack_require__.r(__webpack_exports__);
15277
15315
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
15278
- /* harmony export */ "CursorHelpers": () => (/* reexport safe */ _cursor_helpers__WEBPACK_IMPORTED_MODULE_1__["default"]),
15279
- /* harmony export */ "VictoryCursorContainer": () => (/* reexport safe */ _victory_cursor_container__WEBPACK_IMPORTED_MODULE_0__["default"]),
15280
- /* harmony export */ "cursorContainerMixin": () => (/* reexport safe */ _victory_cursor_container__WEBPACK_IMPORTED_MODULE_0__.cursorContainerMixin)
15316
+ /* harmony export */ "CursorHelpers": () => (/* reexport safe */ _cursor_helpers__WEBPACK_IMPORTED_MODULE_0__.CursorHelpers),
15317
+ /* harmony export */ "VictoryCursorContainer": () => (/* reexport safe */ _victory_cursor_container__WEBPACK_IMPORTED_MODULE_1__.VictoryCursorContainer),
15318
+ /* harmony export */ "cursorContainerMixin": () => (/* reexport safe */ _victory_cursor_container__WEBPACK_IMPORTED_MODULE_1__.cursorContainerMixin)
15281
15319
  /* harmony export */ });
15282
- /* harmony import */ var _victory_cursor_container__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./victory-cursor-container */ "./victory-cursor-container.js");
15283
- /* harmony import */ var _cursor_helpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cursor-helpers */ "./cursor-helpers.js");
15320
+ /* harmony import */ var _cursor_helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cursor-helpers */ "./cursor-helpers.tsx");
15321
+ /* harmony import */ var _victory_cursor_container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./victory-cursor-container */ "./victory-cursor-container.tsx");
15284
15322
 
15285
15323
 
15286
15324
  })();