victory-core 36.9.2 → 37.0.0
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 -0
- package/dist/victory-core.js +4371 -5749
- package/dist/victory-core.min.js +1 -1
- package/es/victory-accessible-group/victory-accessible-group.js +9 -15
- package/es/victory-animation/util.js +28 -47
- package/es/victory-animation/victory-animation.js +51 -67
- package/es/victory-clip-container/victory-clip-container.js +153 -229
- package/es/victory-container/victory-container.js +157 -216
- package/es/victory-label/victory-label.js +246 -323
- package/es/victory-portal/portal-context.js +1 -2
- package/es/victory-portal/portal.js +30 -76
- package/es/victory-portal/victory-portal.js +47 -104
- package/es/victory-primitives/arc.js +44 -47
- package/es/victory-primitives/background.js +14 -17
- package/es/victory-primitives/border.js +20 -24
- package/es/victory-primitives/circle.js +13 -27
- package/es/victory-primitives/clip-path.js +3 -7
- package/es/victory-primitives/line-segment.js +20 -24
- package/es/victory-primitives/line.js +13 -27
- package/es/victory-primitives/path.js +13 -27
- package/es/victory-primitives/point.js +36 -40
- package/es/victory-primitives/rect.js +13 -27
- package/es/victory-primitives/text.js +15 -28
- package/es/victory-primitives/tspan.js +13 -26
- package/es/victory-primitives/whisker.js +43 -47
- package/es/victory-theme/grayscale.js +22 -22
- package/es/victory-theme/material.js +46 -46
- package/es/victory-theme/victory-theme.js +3 -3
- package/es/victory-transition/victory-transition.js +126 -206
- package/es/victory-util/add-events.js +263 -374
- package/es/victory-util/axis.js +126 -222
- package/es/victory-util/collection.js +13 -41
- package/es/victory-util/data.js +159 -214
- package/es/victory-util/default-transitions.js +33 -51
- package/es/victory-util/domain.js +122 -171
- package/es/victory-util/events.js +168 -258
- package/es/victory-util/helpers.js +153 -178
- package/es/victory-util/hooks/use-animation-state.js +61 -99
- package/es/victory-util/hooks/use-previous-props.js +2 -2
- package/es/victory-util/immutable.js +6 -8
- package/es/victory-util/label-helpers.js +128 -130
- package/es/victory-util/line-helpers.js +29 -41
- package/es/victory-util/log.js +1 -1
- package/es/victory-util/point-path-helpers.js +89 -49
- package/es/victory-util/scale.js +24 -42
- package/es/victory-util/selection.js +39 -40
- package/es/victory-util/style.js +8 -13
- package/es/victory-util/textsize.js +80 -154
- package/es/victory-util/timer-context.js +2 -2
- package/es/victory-util/timer.js +40 -76
- package/es/victory-util/transitions.js +110 -150
- package/es/victory-util/type-helpers.js +2 -3
- package/es/victory-util/user-props.js +24 -49
- package/es/victory-util/wrapper.js +184 -247
- package/lib/index.js +0 -30
- package/lib/victory-accessible-group/victory-accessible-group.js +9 -19
- package/lib/victory-animation/util.js +28 -63
- package/lib/victory-animation/victory-animation.js +54 -83
- package/lib/victory-clip-container/victory-clip-container.js +156 -243
- package/lib/victory-container/victory-container.js +160 -232
- package/lib/victory-label/victory-label.js +248 -344
- package/lib/victory-portal/portal-context.js +1 -6
- package/lib/victory-portal/portal.js +31 -81
- package/lib/victory-portal/victory-portal.js +50 -116
- package/lib/victory-primitives/arc.js +48 -57
- package/lib/victory-primitives/background.js +16 -28
- package/lib/victory-primitives/border.js +22 -34
- package/lib/victory-primitives/circle.js +16 -36
- package/lib/victory-primitives/clip-path.js +3 -11
- package/lib/victory-primitives/index.js +0 -28
- package/lib/victory-primitives/line-segment.js +22 -34
- package/lib/victory-primitives/line.js +16 -36
- package/lib/victory-primitives/path.js +16 -36
- package/lib/victory-primitives/point.js +38 -52
- package/lib/victory-primitives/rect.js +16 -36
- package/lib/victory-primitives/text.js +15 -33
- package/lib/victory-primitives/tspan.js +13 -31
- package/lib/victory-primitives/whisker.js +45 -57
- package/lib/victory-theme/grayscale.js +23 -24
- package/lib/victory-theme/material.js +47 -48
- package/lib/victory-theme/victory-theme.js +2 -7
- package/lib/victory-transition/victory-transition.js +129 -224
- package/lib/victory-util/add-events.js +263 -380
- package/lib/victory-util/axis.js +128 -241
- package/lib/victory-util/collection.js +13 -50
- package/lib/victory-util/data.js +160 -239
- package/lib/victory-util/default-transitions.js +33 -54
- package/lib/victory-util/domain.js +123 -193
- package/lib/victory-util/events.js +167 -274
- package/lib/victory-util/helpers.js +156 -207
- package/lib/victory-util/hooks/index.js +0 -2
- package/lib/victory-util/hooks/use-animation-state.js +63 -113
- package/lib/victory-util/hooks/use-previous-props.js +2 -7
- package/lib/victory-util/immutable.js +6 -18
- package/lib/victory-util/index.js +2 -51
- package/lib/victory-util/label-helpers.js +130 -141
- package/lib/victory-util/line-helpers.js +31 -49
- package/lib/victory-util/log.js +1 -2
- package/lib/victory-util/point-path-helpers.js +91 -63
- package/lib/victory-util/scale.js +26 -57
- package/lib/victory-util/selection.js +41 -49
- package/lib/victory-util/style.js +8 -16
- package/lib/victory-util/textsize.js +80 -157
- package/lib/victory-util/timer-context.js +2 -8
- package/lib/victory-util/timer.js +40 -76
- package/lib/victory-util/transitions.js +110 -152
- package/lib/victory-util/type-helpers.js +2 -9
- package/lib/victory-util/user-props.js +25 -59
- package/lib/victory-util/wrapper.js +186 -281
- package/package.json +2 -2
|
@@ -5,43 +5,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.assert = assert;
|
|
7
7
|
exports.withSafeUserProps = exports.getSafeUserProps = void 0;
|
|
8
|
-
|
|
9
8
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
-
|
|
11
9
|
var _helpers = require("./helpers");
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
-
|
|
17
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
18
|
-
|
|
19
|
-
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."); }
|
|
20
|
-
|
|
21
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
|
|
25
|
-
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; }
|
|
26
|
-
|
|
27
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
28
|
-
|
|
29
|
-
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; }
|
|
30
|
-
|
|
31
|
-
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; }
|
|
32
|
-
|
|
33
|
-
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; }
|
|
34
|
-
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
35
12
|
/*
|
|
36
13
|
USER_PROPS_SAFELIST is to contain any string deemed safe for user props.
|
|
37
14
|
The startsWidth array will contain the start of any accepted user-prop that
|
|
38
15
|
starts with these characters.
|
|
39
16
|
The exactMatch will contain a list of exact prop names that are accepted.
|
|
40
17
|
*/
|
|
41
|
-
|
|
18
|
+
const USER_PROPS_SAFELIST = {
|
|
42
19
|
startsWith: ["data-", "aria-"],
|
|
43
20
|
exactMatch: []
|
|
44
|
-
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Normally we'd use Template Literal Types, but we're avoiding it to maximize TS compatibility with TS < 4.1
|
|
45
24
|
|
|
46
25
|
// `data-${string}` | `aria-${string}`;
|
|
47
26
|
|
|
@@ -53,14 +32,15 @@ var USER_PROPS_SAFELIST = {
|
|
|
53
32
|
* @returns {Boolean}: returns true if the key starts with an option or false if
|
|
54
33
|
* otherwise
|
|
55
34
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
USER_PROPS_SAFELIST.startsWith.forEach(
|
|
59
|
-
|
|
35
|
+
const doesPropStartWith = key => {
|
|
36
|
+
let startsWith = false;
|
|
37
|
+
USER_PROPS_SAFELIST.startsWith.forEach(starterString => {
|
|
38
|
+
const regex = new RegExp(`\\b(${starterString})(\\w|-)+`, "g");
|
|
60
39
|
if (regex.test(key)) startsWith = true;
|
|
61
40
|
});
|
|
62
41
|
return startsWith;
|
|
63
42
|
};
|
|
43
|
+
|
|
64
44
|
/**
|
|
65
45
|
* isExactMatch: checks to see if the given key matches any of the 'exactMatch'
|
|
66
46
|
* items in the whitelist
|
|
@@ -69,34 +49,29 @@ var doesPropStartWith = function (key) {
|
|
|
69
49
|
* @returns {Boolean}: return true if whitelist contains that key, otherwise
|
|
70
50
|
* returns false.
|
|
71
51
|
*/
|
|
52
|
+
const isExactMatch = key => USER_PROPS_SAFELIST.exactMatch.includes(key);
|
|
72
53
|
|
|
73
|
-
|
|
74
|
-
var isExactMatch = function (key) {
|
|
75
|
-
return USER_PROPS_SAFELIST.exactMatch.includes(key);
|
|
76
|
-
};
|
|
77
54
|
/**
|
|
78
55
|
* testIfSafeProp: tests prop's key against both startsWith and exactMatch values
|
|
79
56
|
* @param {String} key: prop key to be tested against the whitelist
|
|
80
57
|
* @returns {Boolean}: returns true if found in whitelist, otherwise returns false
|
|
81
58
|
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var testIfSafeProp = function (key) {
|
|
59
|
+
const testIfSafeProp = key => {
|
|
85
60
|
if (doesPropStartWith(key) || isExactMatch(key)) return true;
|
|
86
61
|
return false;
|
|
87
62
|
};
|
|
63
|
+
|
|
88
64
|
/**
|
|
89
65
|
* Asserts that value is not null or undefined, throwing an error if it is.
|
|
90
66
|
* @param value The value to assert
|
|
91
67
|
* @param message The error message to throw
|
|
92
68
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
69
|
function assert(value, message) {
|
|
96
70
|
if (value === undefined || value === null) {
|
|
97
71
|
throw new Error(message);
|
|
98
72
|
}
|
|
99
73
|
}
|
|
74
|
+
|
|
100
75
|
/**
|
|
101
76
|
* getSafeUserProps - function that takes in a props object and removes any
|
|
102
77
|
* key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
|
|
@@ -105,24 +80,19 @@ function assert(value, message) {
|
|
|
105
80
|
* @param {Object} props: props to be filtered against USER_PROPS_SAFELIST
|
|
106
81
|
* @returns {Object}: object containing remaining acceptable props
|
|
107
82
|
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
115
|
-
key = _ref2[0];
|
|
116
|
-
|
|
83
|
+
const getSafeUserProps = props => {
|
|
84
|
+
const propsToFilter = {
|
|
85
|
+
...props
|
|
86
|
+
};
|
|
87
|
+
return Object.fromEntries(Object.entries(propsToFilter).filter(_ref => {
|
|
88
|
+
let [key] = _ref;
|
|
117
89
|
return testIfSafeProp(key);
|
|
118
|
-
}).map(
|
|
119
|
-
|
|
120
|
-
key = _ref4[0],
|
|
121
|
-
value = _ref4[1];
|
|
122
|
-
|
|
90
|
+
}).map(_ref2 => {
|
|
91
|
+
let [key, value] = _ref2;
|
|
123
92
|
return [key, (0, _helpers.evaluateProp)(value, props)];
|
|
124
93
|
}));
|
|
125
94
|
};
|
|
95
|
+
|
|
126
96
|
/**
|
|
127
97
|
* Wraps a component and adds safe user props
|
|
128
98
|
*
|
|
@@ -130,12 +100,8 @@ var getSafeUserProps = function (props) {
|
|
|
130
100
|
* @param {Object} props: props to be filtered
|
|
131
101
|
* @returns {ReactElement} modified component
|
|
132
102
|
*/
|
|
133
|
-
|
|
134
|
-
|
|
135
103
|
exports.getSafeUserProps = getSafeUserProps;
|
|
136
|
-
|
|
137
|
-
var withSafeUserProps = function (component, props) {
|
|
104
|
+
const withSafeUserProps = (component, props) => {
|
|
138
105
|
return /*#__PURE__*/React.cloneElement(component, getSafeUserProps(props));
|
|
139
106
|
};
|
|
140
|
-
|
|
141
107
|
exports.withSafeUserProps = withSafeUserProps;
|