victory-core 36.8.2 → 36.8.3
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 +12 -0
- package/dist/victory-core.js +177 -155
- package/dist/victory-core.min.js +1 -1
- package/es/types/callbacks.d.ts +4 -4
- package/es/victory-animation/util.d.ts +3 -3
- package/es/victory-animation/util.js +5 -3
- package/es/victory-animation/victory-animation.js +2 -2
- package/es/victory-label/victory-label.d.ts +1 -1
- package/es/victory-label/victory-label.js +7 -11
- package/es/victory-primitives/arc.d.ts +1 -1
- package/es/victory-primitives/arc.js +2 -2
- package/es/victory-primitives/background.d.ts +1 -1
- package/es/victory-primitives/background.js +2 -2
- package/es/victory-primitives/border.d.ts +1 -1
- package/es/victory-primitives/border.js +2 -2
- package/es/victory-primitives/line-segment.d.ts +1 -1
- package/es/victory-primitives/line-segment.js +2 -2
- package/es/victory-primitives/point.d.ts +1 -1
- package/es/victory-primitives/point.js +2 -2
- package/es/victory-primitives/whisker.d.ts +1 -1
- package/es/victory-primitives/whisker.js +16 -17
- package/es/victory-util/add-events.js +7 -6
- package/es/victory-util/axis.js +2 -2
- package/es/victory-util/common-props.d.ts +1 -0
- package/es/victory-util/data.js +14 -9
- package/es/victory-util/domain.js +15 -15
- package/es/victory-util/events.d.ts +3 -3
- package/es/victory-util/events.js +13 -16
- package/es/victory-util/helpers.js +5 -5
- package/es/victory-util/immutable.js +4 -2
- package/es/victory-util/label-helpers.d.ts +1 -1
- package/es/victory-util/label-helpers.js +11 -12
- package/es/victory-util/selection.js +1 -2
- package/es/victory-util/timer.js +1 -2
- package/es/victory-util/transitions.js +37 -26
- package/es/victory-util/user-props.d.ts +6 -0
- package/es/victory-util/user-props.js +12 -1
- package/es/victory-util/wrapper.js +14 -14
- package/lib/types/callbacks.d.ts +4 -4
- package/lib/victory-animation/util.d.ts +3 -3
- package/lib/victory-animation/util.js +5 -3
- package/lib/victory-animation/victory-animation.js +2 -2
- package/lib/victory-label/victory-label.d.ts +1 -1
- package/lib/victory-label/victory-label.js +7 -11
- package/lib/victory-primitives/arc.d.ts +1 -1
- package/lib/victory-primitives/arc.js +2 -2
- package/lib/victory-primitives/background.d.ts +1 -1
- package/lib/victory-primitives/background.js +2 -2
- package/lib/victory-primitives/border.d.ts +1 -1
- package/lib/victory-primitives/border.js +2 -2
- package/lib/victory-primitives/line-segment.d.ts +1 -1
- package/lib/victory-primitives/line-segment.js +2 -2
- package/lib/victory-primitives/point.d.ts +1 -1
- package/lib/victory-primitives/point.js +2 -2
- package/lib/victory-primitives/whisker.d.ts +1 -1
- package/lib/victory-primitives/whisker.js +16 -17
- package/lib/victory-util/add-events.js +7 -6
- package/lib/victory-util/axis.js +2 -2
- package/lib/victory-util/common-props.d.ts +1 -0
- package/lib/victory-util/data.js +14 -9
- package/lib/victory-util/domain.js +15 -15
- package/lib/victory-util/events.d.ts +3 -3
- package/lib/victory-util/events.js +13 -16
- package/lib/victory-util/helpers.js +5 -5
- package/lib/victory-util/immutable.js +4 -2
- package/lib/victory-util/label-helpers.d.ts +1 -1
- package/lib/victory-util/label-helpers.js +11 -11
- package/lib/victory-util/selection.js +1 -2
- package/lib/victory-util/timer.js +1 -2
- package/lib/victory-util/transitions.js +32 -26
- package/lib/victory-util/user-props.d.ts +6 -0
- package/lib/victory-util/user-props.js +13 -0
- package/lib/victory-util/wrapper.js +16 -14
- package/package.json +2 -2
- package/src/types/callbacks.ts +8 -5
- package/src/victory-animation/util.ts +5 -3
- package/src/victory-animation/victory-animation.tsx +3 -2
- package/src/victory-label/victory-label.tsx +18 -17
- package/src/victory-primitives/arc.tsx +2 -2
- package/src/victory-primitives/background.tsx +2 -2
- package/src/victory-primitives/border.tsx +2 -2
- package/src/victory-primitives/line-segment.tsx +2 -2
- package/src/victory-primitives/point.tsx +2 -2
- package/src/victory-primitives/whisker.tsx +5 -5
- package/src/victory-util/add-events.tsx +10 -9
- package/src/victory-util/axis.tsx +6 -2
- package/src/victory-util/common-props.tsx +1 -0
- package/src/victory-util/data.ts +12 -8
- package/src/victory-util/domain.ts +15 -15
- package/src/victory-util/events.ts +15 -23
- package/src/victory-util/helpers.ts +5 -5
- package/src/victory-util/immutable.ts +3 -2
- package/src/victory-util/label-helpers.ts +6 -10
- package/src/victory-util/selection.ts +3 -2
- package/src/victory-util/timer.ts +1 -2
- package/src/victory-util/transitions.ts +31 -22
- package/src/victory-util/user-props.ts +14 -0
- package/src/victory-util/wrapper.tsx +17 -22
|
@@ -12,7 +12,7 @@ export interface PointProps extends VictoryCommonPrimitiveProps {
|
|
|
12
12
|
y?: number;
|
|
13
13
|
}
|
|
14
14
|
export declare const Point: {
|
|
15
|
-
(
|
|
15
|
+
(initialProps: PointProps): React.DetailedReactHTMLElement<any, HTMLElement>;
|
|
16
16
|
propTypes: {
|
|
17
17
|
datum: PropTypes.Requireable<object>;
|
|
18
18
|
getPath: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -83,8 +83,8 @@ var defaultProps = {
|
|
|
83
83
|
shapeRendering: "auto"
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
var Point = function (
|
|
87
|
-
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps),
|
|
86
|
+
var Point = function (initialProps) {
|
|
87
|
+
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
|
|
88
88
|
var userProps = UserProps.getSafeUserProps(props);
|
|
89
89
|
return /*#__PURE__*/_react.default.cloneElement(props.pathComponent, _objectSpread(_objectSpread({}, props.events), {}, {
|
|
90
90
|
"aria-label": props.ariaLabel,
|
|
@@ -14,7 +14,7 @@ export interface WhiskerProps extends VictoryCommonPrimitiveProps {
|
|
|
14
14
|
minorWhisker?: WhiskerAxes;
|
|
15
15
|
}
|
|
16
16
|
export declare const Whisker: {
|
|
17
|
-
(
|
|
17
|
+
(initialProps: WhiskerProps): React.DetailedReactHTMLElement<{}, HTMLElement>;
|
|
18
18
|
propTypes: {
|
|
19
19
|
groupComponent: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
20
20
|
lineComponent: PropTypes.Requireable<PropTypes.ReactElementLike>;
|
|
@@ -59,23 +59,22 @@ var defaultProps = {
|
|
|
59
59
|
shapeRendering: "auto"
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
var Whisker = function (
|
|
63
|
-
props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps),
|
|
64
|
-
var
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
tabIndex = _props.tabIndex;
|
|
62
|
+
var Whisker = function (initialProps) {
|
|
63
|
+
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
|
|
64
|
+
var ariaLabel = props.ariaLabel,
|
|
65
|
+
groupComponent = props.groupComponent,
|
|
66
|
+
lineComponent = props.lineComponent,
|
|
67
|
+
events = props.events,
|
|
68
|
+
className = props.className,
|
|
69
|
+
majorWhisker = props.majorWhisker,
|
|
70
|
+
minorWhisker = props.minorWhisker,
|
|
71
|
+
transform = props.transform,
|
|
72
|
+
clipPath = props.clipPath,
|
|
73
|
+
role = props.role,
|
|
74
|
+
shapeRendering = props.shapeRendering,
|
|
75
|
+
style = props.style,
|
|
76
|
+
desc = props.desc,
|
|
77
|
+
tabIndex = props.tabIndex;
|
|
79
78
|
|
|
80
79
|
var baseProps = _objectSpread(_objectSpread({}, events), {}, {
|
|
81
80
|
style: style,
|
|
@@ -240,8 +240,7 @@ function addEvents(WrappedComponent) {
|
|
|
240
240
|
value: function applyExternalMutations(props, externalMutations) {
|
|
241
241
|
if (!(0, _isEmpty2.default)(externalMutations)) {
|
|
242
242
|
var callbacks = props.externalEventMutations.reduce(function (memo, mutation) {
|
|
243
|
-
|
|
244
|
-
return memo;
|
|
243
|
+
return (0, _isFunction2.default)(mutation.callback) ? memo.concat(mutation.callback) : memo;
|
|
245
244
|
}, []);
|
|
246
245
|
var compiledCallbacks = callbacks.length ? function () {
|
|
247
246
|
callbacks.forEach(function (c) {
|
|
@@ -294,8 +293,8 @@ function addEvents(WrappedComponent) {
|
|
|
294
293
|
}, {
|
|
295
294
|
key: "getBaseProps",
|
|
296
295
|
value: function getBaseProps(props, getSharedEventState) {
|
|
297
|
-
|
|
298
|
-
var sharedParentState =
|
|
296
|
+
var getSharedEventStateFunction = getSharedEventState || this.getSharedEventState.bind(this);
|
|
297
|
+
var sharedParentState = getSharedEventStateFunction("parent", "parent");
|
|
299
298
|
var parentState = this.getEventState("parent", "parent");
|
|
300
299
|
var baseParentProps = (0, _defaults2.default)({}, parentState, sharedParentState);
|
|
301
300
|
var parentPropsList = baseParentProps.parentControlledProps;
|
|
@@ -385,13 +384,15 @@ function addEvents(WrappedComponent) {
|
|
|
385
384
|
groupComponent = props.groupComponent;
|
|
386
385
|
var dataKeys = (0, _without2.default)(this.dataKeys, "all");
|
|
387
386
|
var labelComponents = dataKeys.reduce(function (memo, key) {
|
|
387
|
+
var newMemo = memo;
|
|
388
|
+
|
|
388
389
|
var labelProps = _this8.getComponentProps(labelComponent, "labels", key);
|
|
389
390
|
|
|
390
391
|
if (labelProps && labelProps.text !== undefined && labelProps.text !== null) {
|
|
391
|
-
|
|
392
|
+
newMemo = newMemo.concat( /*#__PURE__*/_react.default.cloneElement(labelComponent, labelProps));
|
|
392
393
|
}
|
|
393
394
|
|
|
394
|
-
return
|
|
395
|
+
return newMemo;
|
|
395
396
|
}, []);
|
|
396
397
|
var dataProps = this.getComponentProps(dataComponent, "data", "all");
|
|
397
398
|
var children = [/*#__PURE__*/_react.default.cloneElement(dataComponent, dataProps)].concat(_toConsumableArray(labelComponents));
|
package/lib/victory-util/axis.js
CHANGED
|
@@ -86,11 +86,11 @@ function getAxis(props) {
|
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
function findAxisComponents(childComponents, predicate) {
|
|
89
|
-
|
|
89
|
+
var predicateFunction = predicate || _identity2.default;
|
|
90
90
|
|
|
91
91
|
var findAxes = function (children) {
|
|
92
92
|
return children.reduce(function (memo, child) {
|
|
93
|
-
if (child.type && child.type.role === "axis" &&
|
|
93
|
+
if (child.type && child.type.role === "axis" && predicateFunction(child)) {
|
|
94
94
|
return memo.concat(child);
|
|
95
95
|
} else if (child.props && child.props.children) {
|
|
96
96
|
return memo.concat(findAxes(_react.default.Children.toArray(child.props.children)));
|
|
@@ -20,6 +20,7 @@ export interface VictoryCommonThemeProps {
|
|
|
20
20
|
animate?: boolean | AnimatePropTypeInterface;
|
|
21
21
|
colorScale?: ColorScalePropType;
|
|
22
22
|
containerComponent?: React.ReactElement;
|
|
23
|
+
disableInlineStyles?: boolean;
|
|
23
24
|
domainPadding?: DomainPaddingPropType;
|
|
24
25
|
externalEventMutations?: EventCallbackInterface<string | string[], StringOrNumberOrList>[];
|
|
25
26
|
groupComponent?: React.ReactElement;
|
package/lib/victory-util/data.js
CHANGED
|
@@ -103,12 +103,14 @@ function sortData(dataset, sortKey) {
|
|
|
103
103
|
} // Ensures previous VictoryLine api for sortKey prop stays consistent
|
|
104
104
|
|
|
105
105
|
|
|
106
|
+
var formattedSortKey = sortKey;
|
|
107
|
+
|
|
106
108
|
if (sortKey === "x" || sortKey === "y") {
|
|
107
|
-
|
|
109
|
+
formattedSortKey = "_".concat(sortKey);
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
var order = sortOrder === "ascending" ? "asc" : "desc";
|
|
111
|
-
return (0, _orderBy2.default)(dataset,
|
|
113
|
+
return (0, _orderBy2.default)(dataset, formattedSortKey, order);
|
|
112
114
|
} // This method will remove data points that break certain scales. (log scale only)
|
|
113
115
|
|
|
114
116
|
|
|
@@ -300,7 +302,10 @@ function formatData(dataset, props, expectedKeys) {
|
|
|
300
302
|
return [];
|
|
301
303
|
}
|
|
302
304
|
|
|
303
|
-
var defaultKeys = ["x", "y", "y0"];
|
|
305
|
+
var defaultKeys = ["x", "y", "y0"]; // TODO: We shouldn’t mutate the expectedKeys param here,
|
|
306
|
+
// but we need to figure out why changing it causes regressions in tests.
|
|
307
|
+
// eslint-disable-next-line no-param-reassign
|
|
308
|
+
|
|
304
309
|
expectedKeys = Array.isArray(expectedKeys) ? expectedKeys : defaultKeys;
|
|
305
310
|
|
|
306
311
|
var createAccessor = function (name) {
|
|
@@ -325,13 +330,13 @@ function formatData(dataset, props, expectedKeys) {
|
|
|
325
330
|
|
|
326
331
|
var data = preformattedData ? dataset : dataset.reduce(function (dataArr, datum, index) {
|
|
327
332
|
// eslint-disable-line complexity
|
|
328
|
-
|
|
333
|
+
var parsedDatum = parseDatum(datum);
|
|
329
334
|
var fallbackValues = {
|
|
330
335
|
x: index,
|
|
331
|
-
y:
|
|
336
|
+
y: parsedDatum
|
|
332
337
|
};
|
|
333
338
|
var processedValues = expectedKeys.reduce(function (memo, type) {
|
|
334
|
-
var processedValue = accessor[type](
|
|
339
|
+
var processedValue = accessor[type](parsedDatum);
|
|
335
340
|
var value = processedValue !== undefined ? processedValue : fallbackValues[type];
|
|
336
341
|
|
|
337
342
|
if (value !== undefined) {
|
|
@@ -345,7 +350,7 @@ function formatData(dataset, props, expectedKeys) {
|
|
|
345
350
|
|
|
346
351
|
return memo;
|
|
347
352
|
}, {});
|
|
348
|
-
var formattedDatum = (0, _assign2.default)({}, processedValues,
|
|
353
|
+
var formattedDatum = (0, _assign2.default)({}, processedValues, parsedDatum);
|
|
349
354
|
|
|
350
355
|
if (!(0, _isEmpty2.default)(formattedDatum)) {
|
|
351
356
|
dataArr.push(formattedDatum);
|
|
@@ -462,8 +467,8 @@ function getStringsFromData(props, axis) {
|
|
|
462
467
|
}, []);
|
|
463
468
|
var sortedData = sortData(data, props.sortKey, props.sortOrder);
|
|
464
469
|
var dataStrings = sortedData.reduce(function (dataArr, datum) {
|
|
465
|
-
|
|
466
|
-
dataArr.push(accessor(
|
|
470
|
+
var parsedDatum = parseDatum(datum);
|
|
471
|
+
dataArr.push(accessor(parsedDatum));
|
|
467
472
|
return dataArr;
|
|
468
473
|
}, []).filter(function (datum) {
|
|
469
474
|
return typeof datum === "string";
|
|
@@ -195,18 +195,18 @@ function padDomain(domain, props, axis) {
|
|
|
195
195
|
|
|
196
196
|
|
|
197
197
|
function createDomainFunction(getDomainFromDataFunction, formatDomainFunction) {
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
var getDomainFromDataFn = (0, _isFunction2.default)(getDomainFromDataFunction) ? getDomainFromDataFunction : getDomainFromData;
|
|
199
|
+
var formatDomainFn = (0, _isFunction2.default)(formatDomainFunction) ? formatDomainFunction : formatDomain;
|
|
200
200
|
return function (props, axis) {
|
|
201
201
|
var propsDomain = getDomainFromProps(props, axis);
|
|
202
202
|
|
|
203
203
|
if (propsDomain) {
|
|
204
|
-
return
|
|
204
|
+
return formatDomainFn(propsDomain, props, axis);
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
var categories = Data.getCategories(props, axis);
|
|
208
|
-
var domain = categories ? getDomainFromCategories(props, axis, categories) :
|
|
209
|
-
return domain ?
|
|
208
|
+
var domain = categories ? getDomainFromCategories(props, axis, categories) : getDomainFromDataFn(props, axis);
|
|
209
|
+
return domain ? formatDomainFn(domain, props, axis) : undefined;
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
/**
|
|
@@ -242,27 +242,27 @@ function getDomain(props, axis) {
|
|
|
242
242
|
|
|
243
243
|
|
|
244
244
|
function getDomainFromCategories(props, axis, categories) {
|
|
245
|
-
|
|
245
|
+
var categoriesArray = categories || Data.getCategories(props, axis);
|
|
246
246
|
var polar = props.polar,
|
|
247
247
|
_props$startAngle = props.startAngle,
|
|
248
248
|
startAngle = _props$startAngle === void 0 ? 0 : _props$startAngle,
|
|
249
249
|
_props$endAngle = props.endAngle,
|
|
250
250
|
endAngle = _props$endAngle === void 0 ? 360 : _props$endAngle;
|
|
251
251
|
|
|
252
|
-
if (!
|
|
252
|
+
if (!categoriesArray) {
|
|
253
253
|
return undefined;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
var minDomain = getMinFromProps(props, axis);
|
|
257
257
|
var maxDomain = getMaxFromProps(props, axis);
|
|
258
|
-
var stringArray = Collection.containsStrings(
|
|
258
|
+
var stringArray = Collection.containsStrings(categoriesArray) ? Data.getStringsFromCategories(props, axis) : [];
|
|
259
259
|
var stringMap = stringArray.length === 0 ? null : stringArray.reduce(function (memo, string, index) {
|
|
260
260
|
memo[string] = index + 1;
|
|
261
261
|
return memo;
|
|
262
262
|
}, {});
|
|
263
|
-
var categoryValues = stringMap ?
|
|
263
|
+
var categoryValues = stringMap ? categoriesArray.map(function (value) {
|
|
264
264
|
return stringMap[value];
|
|
265
|
-
}) :
|
|
265
|
+
}) : categoriesArray;
|
|
266
266
|
var min = minDomain !== undefined ? minDomain : Collection.getMinValue(categoryValues);
|
|
267
267
|
var max = maxDomain !== undefined ? maxDomain : Collection.getMaxValue(categoryValues);
|
|
268
268
|
var categoryDomain = getDomainFromMinMax(min, max);
|
|
@@ -278,7 +278,7 @@ function getDomainFromCategories(props, axis, categories) {
|
|
|
278
278
|
|
|
279
279
|
|
|
280
280
|
function getDomainFromData(props, axis, dataset) {
|
|
281
|
-
|
|
281
|
+
var datasetArray = dataset || Data.getData(props);
|
|
282
282
|
var polar = props.polar,
|
|
283
283
|
_props$startAngle2 = props.startAngle,
|
|
284
284
|
startAngle = _props$startAngle2 === void 0 ? 0 : _props$startAngle2,
|
|
@@ -287,14 +287,14 @@ function getDomainFromData(props, axis, dataset) {
|
|
|
287
287
|
var minDomain = getMinFromProps(props, axis);
|
|
288
288
|
var maxDomain = getMaxFromProps(props, axis);
|
|
289
289
|
|
|
290
|
-
if (
|
|
290
|
+
if (datasetArray.length < 1) {
|
|
291
291
|
return minDomain !== undefined && maxDomain !== undefined ? getDomainFromMinMax(minDomain, maxDomain) : undefined;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
var min = minDomain !== undefined ? minDomain : getExtremeFromData(
|
|
295
|
-
var max = maxDomain !== undefined ? maxDomain : getExtremeFromData(
|
|
294
|
+
var min = minDomain !== undefined ? minDomain : getExtremeFromData(datasetArray, axis, "min");
|
|
295
|
+
var max = maxDomain !== undefined ? maxDomain : getExtremeFromData(datasetArray, axis, "max");
|
|
296
296
|
var domain = getDomainFromMinMax(min, max);
|
|
297
|
-
return polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? getSymmetricDomain(domain, getFlatData(
|
|
297
|
+
return polar && axis === "x" && Math.abs(startAngle - endAngle) === 360 ? getSymmetricDomain(domain, getFlatData(datasetArray, axis)) : domain;
|
|
298
298
|
}
|
|
299
299
|
/**
|
|
300
300
|
* Returns a domain in the form of a two element array given a min and max value.
|
|
@@ -16,7 +16,7 @@ interface ComponentWithEvents extends EventMixinCalculatedValues {
|
|
|
16
16
|
state: any;
|
|
17
17
|
setState: any;
|
|
18
18
|
}
|
|
19
|
-
export declare function getEvents(this: ComponentWithEvents, props: any, target
|
|
19
|
+
export declare function getEvents(this: ComponentWithEvents, props: any, target?: any, eventKey?: any, getScopedEvents?: any): any;
|
|
20
20
|
export declare function getScopedEvents(this: ComponentWithEvents, events: any, namespace: any, childType: any, baseProps: any): {};
|
|
21
21
|
export declare function getPartialEvents(events: ComponentEventHandlers, eventKey: ComponentEventKey, childProps: unknown): PartialEvents;
|
|
22
22
|
export interface PartialEvents {
|
|
@@ -33,7 +33,7 @@ export declare function getEventState(this: ComponentWithEvents, eventKey: Compo
|
|
|
33
33
|
*
|
|
34
34
|
* @return {Object} a object describing all mutations for VictorySharedEvents
|
|
35
35
|
*/
|
|
36
|
-
export declare function getExternalMutationsWithChildren(mutations: any, baseProps:
|
|
36
|
+
export declare function getExternalMutationsWithChildren(mutations: any, baseProps: {} | undefined, baseState: {} | undefined, childNames: any): any;
|
|
37
37
|
/**
|
|
38
38
|
* Returns a set of all mutations for a component
|
|
39
39
|
*
|
|
@@ -44,7 +44,7 @@ export declare function getExternalMutationsWithChildren(mutations: any, basePro
|
|
|
44
44
|
*
|
|
45
45
|
* @return {Object} a object describing mutations for a given component
|
|
46
46
|
*/
|
|
47
|
-
export declare function getExternalMutations(mutations: any, baseProps
|
|
47
|
+
export declare function getExternalMutations(mutations: any, baseProps?: {}, baseState?: {}, childName?: any): {};
|
|
48
48
|
/**
|
|
49
49
|
* Returns a set of mutations for a particular element given scoped baseProps and baseState
|
|
50
50
|
*
|
|
@@ -146,14 +146,14 @@ function getScopedEvents(events, namespace, childType, baseProps) {
|
|
|
146
146
|
// eslint-disable-next-line no-invalid-this
|
|
147
147
|
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
var newBaseProps = baseProps || this.baseProps; // returns the original base props or base state of a given target element
|
|
150
150
|
|
|
151
151
|
var getTargetProps = function (identifier, type) {
|
|
152
152
|
var childName = identifier.childName,
|
|
153
153
|
target = identifier.target,
|
|
154
154
|
key = identifier.key; // eslint-disable-next-line no-invalid-this
|
|
155
155
|
|
|
156
|
-
var baseType = type === "props" ?
|
|
156
|
+
var baseType = type === "props" ? newBaseProps : _this2.state || {};
|
|
157
157
|
var base = childName === undefined || childName === null || !baseType[childName] ? baseType : baseType[childName];
|
|
158
158
|
return key === "parent" ? base.parent : base[key] && base[key][target];
|
|
159
159
|
}; // Returns the state object with the mutation caused by a given eventReturn
|
|
@@ -241,8 +241,7 @@ function getScopedEvents(events, namespace, childType, baseProps) {
|
|
|
241
241
|
|
|
242
242
|
var parseEventReturn = function (eventReturn, eventKey) {
|
|
243
243
|
return Array.isArray(eventReturn) ? eventReturn.reduce(function (memo, props) {
|
|
244
|
-
|
|
245
|
-
return memo;
|
|
244
|
+
return (0, _assign6.default)({}, memo, parseEvent(props, eventKey));
|
|
246
245
|
}, {}) : parseEvent(eventReturn, eventKey);
|
|
247
246
|
};
|
|
248
247
|
|
|
@@ -330,9 +329,10 @@ function getEventState(eventKey, namespace, childType) {
|
|
|
330
329
|
// eslint-disable-next-line max-params
|
|
331
330
|
|
|
332
331
|
|
|
333
|
-
function getExternalMutationsWithChildren(mutations
|
|
334
|
-
baseProps =
|
|
335
|
-
baseState =
|
|
332
|
+
function getExternalMutationsWithChildren(mutations) {
|
|
333
|
+
var baseProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
334
|
+
var baseState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
335
|
+
var childNames = arguments.length > 3 ? arguments[3] : undefined;
|
|
336
336
|
return childNames.reduce(function (memo, childName) {
|
|
337
337
|
var childState = baseState[childName];
|
|
338
338
|
var mutation = getExternalMutations(mutations, baseProps[childName], baseState[childName], childName);
|
|
@@ -355,9 +355,10 @@ function getExternalMutationsWithChildren(mutations, baseProps, baseState, child
|
|
|
355
355
|
// eslint-disable-next-line max-params
|
|
356
356
|
|
|
357
357
|
|
|
358
|
-
function getExternalMutations(mutations
|
|
359
|
-
baseProps =
|
|
360
|
-
baseState =
|
|
358
|
+
function getExternalMutations(mutations) {
|
|
359
|
+
var baseProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
360
|
+
var baseState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
361
|
+
var childName = arguments.length > 3 ? arguments[3] : undefined;
|
|
361
362
|
var eventKeys = (0, _keys2.default)(baseProps);
|
|
362
363
|
return eventKeys.reduce(function (memo, eventKey) {
|
|
363
364
|
var keyState = baseState[eventKey] || {};
|
|
@@ -421,8 +422,7 @@ function getExternalMutation(mutations, baseProps, baseState, identifier) {
|
|
|
421
422
|
return false;
|
|
422
423
|
};
|
|
423
424
|
|
|
424
|
-
|
|
425
|
-
var scopedMutations = mutations;
|
|
425
|
+
var scopedMutations = Array.isArray(mutations) ? mutations : [mutations];
|
|
426
426
|
|
|
427
427
|
if (identifier.childName) {
|
|
428
428
|
scopedMutations = mutations.filter(function (m) {
|
|
@@ -462,13 +462,10 @@ function getExternalMutation(mutations, baseProps, baseState, identifier) {
|
|
|
462
462
|
|
|
463
463
|
function getComponentEvents(props, components) {
|
|
464
464
|
var events = Array.isArray(components) && components.reduce(function (memo, componentName) {
|
|
465
|
-
var _memo;
|
|
466
|
-
|
|
467
465
|
var component = props[componentName];
|
|
468
466
|
var defaultEvents = component && component.type && component.type.defaultEvents;
|
|
469
467
|
var componentEvents = (0, _isFunction2.default)(defaultEvents) ? defaultEvents(component.props) : defaultEvents;
|
|
470
|
-
|
|
471
|
-
return memo;
|
|
468
|
+
return Array.isArray(componentEvents) ? memo.concat.apply(memo, _toConsumableArray(componentEvents)) : memo;
|
|
472
469
|
}, []);
|
|
473
470
|
return events && events.length ? events : undefined;
|
|
474
471
|
}
|
|
@@ -338,6 +338,7 @@ function reduceChildren(children, iteratee) {
|
|
|
338
338
|
|
|
339
339
|
var traverseChildren = function (childArray, names, parent) {
|
|
340
340
|
return childArray.reduce(function (memo, child, index) {
|
|
341
|
+
var newMemo = memo;
|
|
341
342
|
var childRole = child.type && child.type.role;
|
|
342
343
|
var childName = child.props.name || "".concat(childRole, "-").concat(names[index]);
|
|
343
344
|
|
|
@@ -353,16 +354,16 @@ function reduceChildren(children, iteratee) {
|
|
|
353
354
|
});
|
|
354
355
|
|
|
355
356
|
var nestedResults = traverseChildren(nestedChildren, _childNames, child);
|
|
356
|
-
|
|
357
|
+
newMemo = combine(newMemo, nestedResults);
|
|
357
358
|
} else {
|
|
358
359
|
var result = iteratee(child, childName, parent);
|
|
359
360
|
|
|
360
361
|
if (result) {
|
|
361
|
-
|
|
362
|
+
newMemo = combine(newMemo, result);
|
|
362
363
|
}
|
|
363
364
|
}
|
|
364
365
|
|
|
365
|
-
return
|
|
366
|
+
return newMemo;
|
|
366
367
|
}, initialMemo);
|
|
367
368
|
};
|
|
368
369
|
|
|
@@ -389,8 +390,7 @@ function isHorizontal(props) {
|
|
|
389
390
|
var childProps = child.props || {};
|
|
390
391
|
|
|
391
392
|
if (memo || childProps.horizontal || !childProps.children) {
|
|
392
|
-
|
|
393
|
-
return memo;
|
|
393
|
+
return memo || childProps.horizontal;
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
return traverseChildren(_react.default.Children.toArray(childProps.children));
|
|
@@ -41,11 +41,13 @@ function isMap(x) {
|
|
|
41
41
|
|
|
42
42
|
function shallowToJS(x, whitelist) {
|
|
43
43
|
return isIterable(x) ? x.reduce(function (result, curr, key) {
|
|
44
|
+
var newCurr = curr;
|
|
45
|
+
|
|
44
46
|
if (whitelist && whitelist[key]) {
|
|
45
|
-
|
|
47
|
+
newCurr = shallowToJS(curr);
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
result[key] =
|
|
50
|
+
result[key] = newCurr;
|
|
49
51
|
return result;
|
|
50
52
|
}, isList(x) ? [] : {}) : x;
|
|
51
53
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function getText(props: any, datum: any, index: any): any;
|
|
1
|
+
export declare function getText(props: any, datum: Record<string, any> | undefined, index: any): any;
|
|
2
2
|
export declare function getPolarTextAnchor(props: any, degrees: any): "end" | "start" | "middle";
|
|
3
3
|
export declare function getPolarVerticalAnchor(props: any, degrees: any): "end" | "start" | "middle";
|
|
4
4
|
export declare function getPolarAngle(props: any, baseAngle?: any): number;
|
|
@@ -20,10 +20,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
20
20
|
|
|
21
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
22
|
|
|
23
|
-
/* eslint-disable no-use-before-define */
|
|
24
23
|
// Private Functions
|
|
25
|
-
function getVerticalAnchor(props
|
|
26
|
-
datum =
|
|
24
|
+
function getVerticalAnchor(props) {
|
|
25
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
27
26
|
var sign = datum._y >= 0 ? 1 : -1;
|
|
28
27
|
var labelStyle = props.style && props.style.labels || {};
|
|
29
28
|
|
|
@@ -36,8 +35,8 @@ function getVerticalAnchor(props, datum) {
|
|
|
36
35
|
return "middle";
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
function getTextAnchor(props
|
|
40
|
-
datum =
|
|
38
|
+
function getTextAnchor(props) {
|
|
39
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
41
40
|
var style = props.style,
|
|
42
41
|
horizontal = props.horizontal;
|
|
43
42
|
var sign = datum._y >= 0 ? 1 : -1;
|
|
@@ -52,14 +51,14 @@ function getTextAnchor(props, datum) {
|
|
|
52
51
|
return sign >= 0 ? "start" : "end";
|
|
53
52
|
}
|
|
54
53
|
|
|
55
|
-
function getAngle(props
|
|
56
|
-
datum =
|
|
54
|
+
function getAngle(props) {
|
|
55
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
57
56
|
var labelStyle = props.style && props.style.labels || {};
|
|
58
57
|
return datum.angle === undefined ? labelStyle.angle : datum.angle;
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
function getPadding(props
|
|
62
|
-
datum =
|
|
60
|
+
function getPadding(props) {
|
|
61
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
63
62
|
var horizontal = props.horizontal,
|
|
64
63
|
style = props.style;
|
|
65
64
|
var labelStyle = style.labels || {};
|
|
@@ -138,8 +137,9 @@ function getPolarOrientation(degrees) {
|
|
|
138
137
|
} // Exported Functions
|
|
139
138
|
|
|
140
139
|
|
|
141
|
-
function getText(props
|
|
142
|
-
datum =
|
|
140
|
+
function getText(props) {
|
|
141
|
+
var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
142
|
+
var index = arguments.length > 2 ? arguments[2] : undefined;
|
|
143
143
|
|
|
144
144
|
if (datum.label !== undefined) {
|
|
145
145
|
return datum.label;
|
|
@@ -65,8 +65,7 @@ function getSVGEventCoordinates(evt, svg) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
var location = isReactTouchEvent(evt) ? evt.changedTouches[0] : evt;
|
|
68
|
-
|
|
69
|
-
var matrix = getTransformationMatrix(svg);
|
|
68
|
+
var matrix = getTransformationMatrix(svg || getParentSVG(location));
|
|
70
69
|
return {
|
|
71
70
|
x: transformTarget(location.clientX, matrix, "x"),
|
|
72
71
|
y: transformTarget(location.clientY, matrix, "y")
|
|
@@ -64,11 +64,10 @@ var Timer = /*#__PURE__*/function () {
|
|
|
64
64
|
}, {
|
|
65
65
|
key: "subscribe",
|
|
66
66
|
value: function subscribe(callback, duration) {
|
|
67
|
-
duration = this.shouldAnimate ? duration : 0;
|
|
68
67
|
var subscriptionID = this.subscribers.push({
|
|
69
68
|
startTime: (0, _d3Timer.now)(),
|
|
70
69
|
callback: callback,
|
|
71
|
-
duration: duration
|
|
70
|
+
duration: this.shouldAnimate ? duration : 0
|
|
72
71
|
});
|
|
73
72
|
this.activeSubscriptions++;
|
|
74
73
|
this.start();
|