victory-core 36.6.8 → 36.6.10
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 +16 -0
- package/dist/victory-core.js +229 -15
- package/dist/victory-core.min.js +1 -1
- package/es/v37/victory-state/victory-provider.js +1 -1
- package/es/victory-util/textsize.d.ts +1 -2
- package/es/victory-util/textsize.js +96 -9
- package/lib/v37/victory-state/victory-provider.js +1 -1
- package/lib/victory-util/textsize.d.ts +1 -2
- package/lib/victory-util/textsize.js +97 -9
- package/package.json +6 -3
- package/src/v37/victory-state/helpers/get-data.ts +0 -1
- package/src/v37/victory-state/victory-provider.tsx +3 -1
- package/src/victory-util/textsize.ts +107 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# victory-core
|
|
2
2
|
|
|
3
|
+
## 36.6.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Setup NPM Provenance ([#2590](https://github.com/FormidableLabs/victory/pull/2590))
|
|
8
|
+
|
|
9
|
+
## 36.6.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Lint fixes. ([#2497](https://github.com/FormidableLabs/victory/pull/2497))
|
|
14
|
+
|
|
15
|
+
* Setup NPM Provenance ([#2587](https://github.com/FormidableLabs/victory/pull/2587))
|
|
16
|
+
|
|
17
|
+
- Improve accuracy of text size measurements (fixes [#2475](https://github.com/FormidableLabs/victory/issues/2475)) ([#2505](https://github.com/FormidableLabs/victory/pull/2505))
|
|
18
|
+
|
|
3
19
|
## 36.6.8
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/victory-core.js
CHANGED
|
@@ -8600,13 +8600,24 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
8600
8600
|
/* harmony export */ "approximateTextSize": () => (/* binding */ approximateTextSize),
|
|
8601
8601
|
/* harmony export */ "convertLengthToPixels": () => (/* binding */ convertLengthToPixels)
|
|
8602
8602
|
/* harmony export */ });
|
|
8603
|
-
/* harmony import */ var
|
|
8604
|
-
/* harmony import */ var
|
|
8605
|
-
/* harmony import */ var
|
|
8606
|
-
/* harmony import */ var
|
|
8603
|
+
/* harmony import */ var lodash_memoize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lodash/memoize */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/memoize.js");
|
|
8604
|
+
/* harmony import */ var lodash_memoize__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lodash_memoize__WEBPACK_IMPORTED_MODULE_0__);
|
|
8605
|
+
/* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash/defaults */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/defaults.js");
|
|
8606
|
+
/* harmony import */ var lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(lodash_defaults__WEBPACK_IMPORTED_MODULE_1__);
|
|
8607
|
+
/* harmony import */ var lodash_assign__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash/assign */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/assign.js");
|
|
8608
|
+
/* harmony import */ var lodash_assign__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(lodash_assign__WEBPACK_IMPORTED_MODULE_2__);
|
|
8607
8609
|
|
|
8608
8610
|
|
|
8609
8611
|
|
|
8612
|
+
|
|
8613
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8614
|
+
|
|
8615
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8616
|
+
|
|
8617
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
8618
|
+
|
|
8619
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8620
|
+
|
|
8610
8621
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8611
8622
|
|
|
8612
8623
|
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."); }
|
|
@@ -8810,9 +8821,9 @@ var convertLengthToPixels = function (length, fontSize) {
|
|
|
8810
8821
|
var _prepareParams = function (inputStyle, index) {
|
|
8811
8822
|
var lineStyle = Array.isArray(inputStyle) ? inputStyle[index] : inputStyle;
|
|
8812
8823
|
|
|
8813
|
-
var style =
|
|
8824
|
+
var style = lodash_defaults__WEBPACK_IMPORTED_MODULE_1___default()({}, lineStyle, defaultStyle);
|
|
8814
8825
|
|
|
8815
|
-
return
|
|
8826
|
+
return lodash_assign__WEBPACK_IMPORTED_MODULE_2___default()({}, style, {
|
|
8816
8827
|
fontFamily: style.fontFamily,
|
|
8817
8828
|
letterSpacing: typeof style.letterSpacing === "number" ? style.letterSpacing : convertLengthToPixels(String(style.letterSpacing), style.fontSize),
|
|
8818
8829
|
fontSize: typeof style.fontSize === "number" ? style.fontSize : convertLengthToPixels(String(style.fontSize))
|
|
@@ -8859,21 +8870,99 @@ var _approximateTextHeightInternal = function (text, style) {
|
|
|
8859
8870
|
}, 0);
|
|
8860
8871
|
};
|
|
8861
8872
|
|
|
8873
|
+
var _approximateDimensionsInternal = function (text, style) {
|
|
8874
|
+
var angle = Array.isArray(style) ? style[0] && style[0].angle : style && style.angle;
|
|
8875
|
+
|
|
8876
|
+
var height = _approximateTextHeightInternal(text, style);
|
|
8877
|
+
|
|
8878
|
+
var width = _approximateTextWidthInternal(text, style);
|
|
8879
|
+
|
|
8880
|
+
var widthWithRotate = angle ? _getSizeWithRotate(width, height, angle) : width;
|
|
8881
|
+
var heightWithRotate = angle ? _getSizeWithRotate(height, width, angle) : height;
|
|
8882
|
+
return {
|
|
8883
|
+
width: widthWithRotate,
|
|
8884
|
+
height: heightWithRotate * coefficients.heightOverlapCoef
|
|
8885
|
+
};
|
|
8886
|
+
};
|
|
8887
|
+
|
|
8888
|
+
var _getMeasurementContainer = lodash_memoize__WEBPACK_IMPORTED_MODULE_0___default()(function () {
|
|
8889
|
+
var element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
8890
|
+
element.setAttribute("xlink", "http://www.w3.org/1999/xlink");
|
|
8891
|
+
var containerElement = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
8892
|
+
element.appendChild(containerElement);
|
|
8893
|
+
element.style.position = "fixed";
|
|
8894
|
+
element.style.top = "-9999px";
|
|
8895
|
+
element.style.left = "-9999px";
|
|
8896
|
+
document.body.appendChild(element);
|
|
8897
|
+
return containerElement;
|
|
8898
|
+
});
|
|
8899
|
+
|
|
8900
|
+
var styleToKeyComponent = function (style) {
|
|
8901
|
+
if (!style) {
|
|
8902
|
+
return "null";
|
|
8903
|
+
}
|
|
8904
|
+
|
|
8905
|
+
return "".concat(style.angle, ":").concat(style.fontFamily, ":").concat(style.fontSize, ":").concat(style.letterSpacing, ":").concat(style.lineHeight);
|
|
8906
|
+
};
|
|
8907
|
+
|
|
8908
|
+
var _measureDimensionsInternal = lodash_memoize__WEBPACK_IMPORTED_MODULE_0___default()(function (text, style) {
|
|
8909
|
+
var containerElement = _getMeasurementContainer();
|
|
8910
|
+
|
|
8911
|
+
var lines = _splitToLines(text);
|
|
8912
|
+
|
|
8913
|
+
var heightAcc = 0;
|
|
8914
|
+
|
|
8915
|
+
for (var _ref of lines.entries()) {
|
|
8916
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
8917
|
+
|
|
8918
|
+
var i = _ref2[0];
|
|
8919
|
+
var line = _ref2[1];
|
|
8920
|
+
var textElement = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
|
8921
|
+
|
|
8922
|
+
var params = _prepareParams(style, i);
|
|
8923
|
+
|
|
8924
|
+
textElement.style.fontFamily = params.fontFamily;
|
|
8925
|
+
textElement.style.transform = "rotate(".concat(params.angle, ")");
|
|
8926
|
+
textElement.style.fontSize = "".concat(params.fontSize, "px");
|
|
8927
|
+
textElement.style.lineHeight = params.lineHeight;
|
|
8928
|
+
textElement.style.fontFamily = params.fontFamily;
|
|
8929
|
+
textElement.style.letterSpacing = params.letterSpacing;
|
|
8930
|
+
textElement.textContent = line;
|
|
8931
|
+
textElement.setAttribute("x", "0");
|
|
8932
|
+
textElement.setAttribute("y", "".concat(heightAcc));
|
|
8933
|
+
heightAcc += params.lineHeight * params.fontSize;
|
|
8934
|
+
containerElement.appendChild(textElement);
|
|
8935
|
+
}
|
|
8936
|
+
|
|
8937
|
+
var _containerElement$get = containerElement.getBoundingClientRect(),
|
|
8938
|
+
width = _containerElement$get.width,
|
|
8939
|
+
height = _containerElement$get.height;
|
|
8940
|
+
|
|
8941
|
+
containerElement.innerHTML = "";
|
|
8942
|
+
return {
|
|
8943
|
+
width: width,
|
|
8944
|
+
height: height
|
|
8945
|
+
};
|
|
8946
|
+
}, function (text, style) {
|
|
8947
|
+
var totalText = Array.isArray(text) ? text.join() : text;
|
|
8948
|
+
var totalStyle = Array.isArray(style) ? style.map(styleToKeyComponent).join() : styleToKeyComponent(style);
|
|
8949
|
+
return "".concat(totalText, "::").concat(totalStyle);
|
|
8950
|
+
});
|
|
8951
|
+
|
|
8862
8952
|
// Stubbable implementation.
|
|
8863
8953
|
var _approximateTextSizeInternal = {
|
|
8864
8954
|
impl: function (text, style) {
|
|
8865
|
-
var
|
|
8955
|
+
var __debugForceApproximate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
8866
8956
|
|
|
8867
|
-
|
|
8957
|
+
// Attempt to first measure the element in DOM. If there is no DOM, fallback
|
|
8958
|
+
// to the less accurate approximation algorithm.
|
|
8959
|
+
var isClient = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
8868
8960
|
|
|
8869
|
-
|
|
8961
|
+
if (!isClient || __debugForceApproximate) {
|
|
8962
|
+
return _approximateDimensionsInternal(text, style);
|
|
8963
|
+
}
|
|
8870
8964
|
|
|
8871
|
-
|
|
8872
|
-
var heightWithRotate = angle ? _getSizeWithRotate(height, width, angle) : height;
|
|
8873
|
-
return {
|
|
8874
|
-
width: widthWithRotate,
|
|
8875
|
-
height: heightWithRotate * coefficients.heightOverlapCoef
|
|
8876
|
-
};
|
|
8965
|
+
return _measureDimensionsInternal(text, style);
|
|
8877
8966
|
}
|
|
8878
8967
|
};
|
|
8879
8968
|
/**
|
|
@@ -10108,6 +10197,48 @@ function getCategories(props, childComponents, allStrings) {
|
|
|
10108
10197
|
};
|
|
10109
10198
|
}
|
|
10110
10199
|
|
|
10200
|
+
/***/ }),
|
|
10201
|
+
|
|
10202
|
+
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_MapCache.js":
|
|
10203
|
+
/*!***********************************************************************************!*\
|
|
10204
|
+
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_MapCache.js ***!
|
|
10205
|
+
\***********************************************************************************/
|
|
10206
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
10207
|
+
|
|
10208
|
+
var listCacheClear = __webpack_require__(/*! ./_listCacheClear */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheClear.js"),
|
|
10209
|
+
listCacheDelete = __webpack_require__(/*! ./_listCacheDelete */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js"),
|
|
10210
|
+
listCacheGet = __webpack_require__(/*! ./_listCacheGet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheGet.js"),
|
|
10211
|
+
listCacheHas = __webpack_require__(/*! ./_listCacheHas */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheHas.js"),
|
|
10212
|
+
listCacheSet = __webpack_require__(/*! ./_listCacheSet */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_listCacheSet.js");
|
|
10213
|
+
|
|
10214
|
+
/**
|
|
10215
|
+
* Creates an list cache object.
|
|
10216
|
+
*
|
|
10217
|
+
* @private
|
|
10218
|
+
* @constructor
|
|
10219
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
10220
|
+
*/
|
|
10221
|
+
function ListCache(entries) {
|
|
10222
|
+
var index = -1,
|
|
10223
|
+
length = entries == null ? 0 : entries.length;
|
|
10224
|
+
|
|
10225
|
+
this.clear();
|
|
10226
|
+
while (++index < length) {
|
|
10227
|
+
var entry = entries[index];
|
|
10228
|
+
this.set(entry[0], entry[1]);
|
|
10229
|
+
}
|
|
10230
|
+
}
|
|
10231
|
+
|
|
10232
|
+
// Add methods to `ListCache`.
|
|
10233
|
+
ListCache.prototype.clear = listCacheClear;
|
|
10234
|
+
ListCache.prototype['delete'] = listCacheDelete;
|
|
10235
|
+
ListCache.prototype.get = listCacheGet;
|
|
10236
|
+
ListCache.prototype.has = listCacheHas;
|
|
10237
|
+
ListCache.prototype.set = listCacheSet;
|
|
10238
|
+
|
|
10239
|
+
module.exports = ListCache;
|
|
10240
|
+
|
|
10241
|
+
|
|
10111
10242
|
/***/ }),
|
|
10112
10243
|
|
|
10113
10244
|
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_SetCache.js":
|
|
@@ -15092,6 +15223,89 @@ function last(array) {
|
|
|
15092
15223
|
module.exports = last;
|
|
15093
15224
|
|
|
15094
15225
|
|
|
15226
|
+
/***/ }),
|
|
15227
|
+
|
|
15228
|
+
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/memoize.js":
|
|
15229
|
+
/*!*********************************************************************************!*\
|
|
15230
|
+
!*** ../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/memoize.js ***!
|
|
15231
|
+
\*********************************************************************************/
|
|
15232
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
15233
|
+
|
|
15234
|
+
var MapCache = __webpack_require__(/*! ./_MapCache */ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/_MapCache.js");
|
|
15235
|
+
|
|
15236
|
+
/** Error message constants. */
|
|
15237
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
15238
|
+
|
|
15239
|
+
/**
|
|
15240
|
+
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
15241
|
+
* provided, it determines the cache key for storing the result based on the
|
|
15242
|
+
* arguments provided to the memoized function. By default, the first argument
|
|
15243
|
+
* provided to the memoized function is used as the map cache key. The `func`
|
|
15244
|
+
* is invoked with the `this` binding of the memoized function.
|
|
15245
|
+
*
|
|
15246
|
+
* **Note:** The cache is exposed as the `cache` property on the memoized
|
|
15247
|
+
* function. Its creation may be customized by replacing the `_.memoize.Cache`
|
|
15248
|
+
* constructor with one whose instances implement the
|
|
15249
|
+
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
|
|
15250
|
+
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
|
|
15251
|
+
*
|
|
15252
|
+
* @static
|
|
15253
|
+
* @memberOf _
|
|
15254
|
+
* @since 0.1.0
|
|
15255
|
+
* @category Function
|
|
15256
|
+
* @param {Function} func The function to have its output memoized.
|
|
15257
|
+
* @param {Function} [resolver] The function to resolve the cache key.
|
|
15258
|
+
* @returns {Function} Returns the new memoized function.
|
|
15259
|
+
* @example
|
|
15260
|
+
*
|
|
15261
|
+
* var object = { 'a': 1, 'b': 2 };
|
|
15262
|
+
* var other = { 'c': 3, 'd': 4 };
|
|
15263
|
+
*
|
|
15264
|
+
* var values = _.memoize(_.values);
|
|
15265
|
+
* values(object);
|
|
15266
|
+
* // => [1, 2]
|
|
15267
|
+
*
|
|
15268
|
+
* values(other);
|
|
15269
|
+
* // => [3, 4]
|
|
15270
|
+
*
|
|
15271
|
+
* object.a = 2;
|
|
15272
|
+
* values(object);
|
|
15273
|
+
* // => [1, 2]
|
|
15274
|
+
*
|
|
15275
|
+
* // Modify the result cache.
|
|
15276
|
+
* values.cache.set(object, ['a', 'b']);
|
|
15277
|
+
* values(object);
|
|
15278
|
+
* // => ['a', 'b']
|
|
15279
|
+
*
|
|
15280
|
+
* // Replace `_.memoize.Cache`.
|
|
15281
|
+
* _.memoize.Cache = WeakMap;
|
|
15282
|
+
*/
|
|
15283
|
+
function memoize(func, resolver) {
|
|
15284
|
+
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
|
|
15285
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
15286
|
+
}
|
|
15287
|
+
var memoized = function() {
|
|
15288
|
+
var args = arguments,
|
|
15289
|
+
key = resolver ? resolver.apply(this, args) : args[0],
|
|
15290
|
+
cache = memoized.cache;
|
|
15291
|
+
|
|
15292
|
+
if (cache.has(key)) {
|
|
15293
|
+
return cache.get(key);
|
|
15294
|
+
}
|
|
15295
|
+
var result = func.apply(this, args);
|
|
15296
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
15297
|
+
return result;
|
|
15298
|
+
};
|
|
15299
|
+
memoized.cache = new (memoize.Cache || MapCache);
|
|
15300
|
+
return memoized;
|
|
15301
|
+
}
|
|
15302
|
+
|
|
15303
|
+
// Expose `MapCache`.
|
|
15304
|
+
memoize.Cache = MapCache;
|
|
15305
|
+
|
|
15306
|
+
module.exports = memoize;
|
|
15307
|
+
|
|
15308
|
+
|
|
15095
15309
|
/***/ }),
|
|
15096
15310
|
|
|
15097
15311
|
/***/ "../../../node_modules/.pnpm/lodash@4.17.21/node_modules/lodash/negate.js":
|