victory-core 36.8.2 → 36.8.4

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.
Files changed (98) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/victory-core.js +181 -159
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/types/callbacks.d.ts +4 -4
  5. package/es/victory-animation/util.d.ts +3 -3
  6. package/es/victory-animation/util.js +5 -3
  7. package/es/victory-animation/victory-animation.js +2 -2
  8. package/es/victory-label/victory-label.d.ts +1 -1
  9. package/es/victory-label/victory-label.js +7 -11
  10. package/es/victory-primitives/arc.d.ts +1 -1
  11. package/es/victory-primitives/arc.js +2 -2
  12. package/es/victory-primitives/background.d.ts +1 -1
  13. package/es/victory-primitives/background.js +2 -2
  14. package/es/victory-primitives/border.d.ts +1 -1
  15. package/es/victory-primitives/border.js +2 -2
  16. package/es/victory-primitives/line-segment.d.ts +1 -1
  17. package/es/victory-primitives/line-segment.js +2 -2
  18. package/es/victory-primitives/point.d.ts +1 -1
  19. package/es/victory-primitives/point.js +2 -2
  20. package/es/victory-primitives/whisker.d.ts +1 -1
  21. package/es/victory-primitives/whisker.js +16 -17
  22. package/es/victory-util/add-events.js +7 -6
  23. package/es/victory-util/axis.js +2 -2
  24. package/es/victory-util/common-props.d.ts +1 -0
  25. package/es/victory-util/data.js +14 -9
  26. package/es/victory-util/domain.js +15 -15
  27. package/es/victory-util/events.d.ts +3 -3
  28. package/es/victory-util/events.js +17 -20
  29. package/es/victory-util/helpers.js +5 -5
  30. package/es/victory-util/immutable.js +4 -2
  31. package/es/victory-util/label-helpers.d.ts +1 -1
  32. package/es/victory-util/label-helpers.js +11 -12
  33. package/es/victory-util/selection.js +1 -2
  34. package/es/victory-util/timer.js +1 -2
  35. package/es/victory-util/transitions.js +37 -26
  36. package/es/victory-util/user-props.d.ts +6 -0
  37. package/es/victory-util/user-props.js +12 -1
  38. package/es/victory-util/wrapper.js +14 -14
  39. package/lib/types/callbacks.d.ts +4 -4
  40. package/lib/victory-animation/util.d.ts +3 -3
  41. package/lib/victory-animation/util.js +5 -3
  42. package/lib/victory-animation/victory-animation.js +2 -2
  43. package/lib/victory-label/victory-label.d.ts +1 -1
  44. package/lib/victory-label/victory-label.js +7 -11
  45. package/lib/victory-primitives/arc.d.ts +1 -1
  46. package/lib/victory-primitives/arc.js +2 -2
  47. package/lib/victory-primitives/background.d.ts +1 -1
  48. package/lib/victory-primitives/background.js +2 -2
  49. package/lib/victory-primitives/border.d.ts +1 -1
  50. package/lib/victory-primitives/border.js +2 -2
  51. package/lib/victory-primitives/line-segment.d.ts +1 -1
  52. package/lib/victory-primitives/line-segment.js +2 -2
  53. package/lib/victory-primitives/point.d.ts +1 -1
  54. package/lib/victory-primitives/point.js +2 -2
  55. package/lib/victory-primitives/whisker.d.ts +1 -1
  56. package/lib/victory-primitives/whisker.js +16 -17
  57. package/lib/victory-util/add-events.js +7 -6
  58. package/lib/victory-util/axis.js +2 -2
  59. package/lib/victory-util/common-props.d.ts +1 -0
  60. package/lib/victory-util/data.js +14 -9
  61. package/lib/victory-util/domain.js +15 -15
  62. package/lib/victory-util/events.d.ts +3 -3
  63. package/lib/victory-util/events.js +17 -20
  64. package/lib/victory-util/helpers.js +5 -5
  65. package/lib/victory-util/immutable.js +4 -2
  66. package/lib/victory-util/label-helpers.d.ts +1 -1
  67. package/lib/victory-util/label-helpers.js +11 -11
  68. package/lib/victory-util/selection.js +1 -2
  69. package/lib/victory-util/timer.js +1 -2
  70. package/lib/victory-util/transitions.js +32 -26
  71. package/lib/victory-util/user-props.d.ts +6 -0
  72. package/lib/victory-util/user-props.js +13 -0
  73. package/lib/victory-util/wrapper.js +16 -14
  74. package/package.json +2 -2
  75. package/src/types/callbacks.ts +8 -5
  76. package/src/victory-animation/util.ts +5 -3
  77. package/src/victory-animation/victory-animation.tsx +3 -2
  78. package/src/victory-label/victory-label.tsx +18 -17
  79. package/src/victory-primitives/arc.tsx +2 -2
  80. package/src/victory-primitives/background.tsx +2 -2
  81. package/src/victory-primitives/border.tsx +2 -2
  82. package/src/victory-primitives/line-segment.tsx +2 -2
  83. package/src/victory-primitives/point.tsx +2 -2
  84. package/src/victory-primitives/whisker.tsx +5 -5
  85. package/src/victory-util/add-events.tsx +10 -9
  86. package/src/victory-util/axis.tsx +6 -2
  87. package/src/victory-util/common-props.tsx +1 -0
  88. package/src/victory-util/data.ts +12 -8
  89. package/src/victory-util/domain.ts +15 -15
  90. package/src/victory-util/events.ts +23 -31
  91. package/src/victory-util/helpers.ts +5 -5
  92. package/src/victory-util/immutable.ts +3 -2
  93. package/src/victory-util/label-helpers.ts +6 -10
  94. package/src/victory-util/selection.ts +3 -2
  95. package/src/victory-util/timer.ts +1 -2
  96. package/src/victory-util/transitions.ts +31 -22
  97. package/src/victory-util/user-props.ts +14 -0
  98. package/src/victory-util/wrapper.tsx +17 -22
@@ -102,11 +102,12 @@ export function getDataFromChildren(props, childComponents) {
102
102
  const iteratee = (child, childName, parent) => {
103
103
  const childProps = assign({}, child.props, parentProps);
104
104
  let childData;
105
+ let childElement = child;
105
106
  if (!Data.isDataComponent(child)) {
106
107
  return null;
107
108
  } else if (child.type && isFunction(child.type.getData)) {
108
- child = parent ? React.cloneElement(child, parent.props) : child;
109
- childData = child.type.getData(childProps);
109
+ childElement = parent ? React.cloneElement(child, parent.props) : child;
110
+ childData = childElement.type.getData(childProps);
110
111
  } else {
111
112
  childData = Data.getData(childProps);
112
113
  }
@@ -135,8 +136,10 @@ export function getData(props, childComponents) {
135
136
  if (props.data) {
136
137
  return Data.getData(props);
137
138
  }
138
- childComponents = childComponents || React.Children.toArray(props.children);
139
- return getDataFromChildren(props, childComponents);
139
+ return getDataFromChildren(
140
+ props,
141
+ childComponents || React.Children.toArray(props.children),
142
+ );
140
143
  }
141
144
 
142
145
  export function getWidth(props, groupLength?, seriesLength?) {
@@ -145,12 +148,12 @@ export function getWidth(props, groupLength?, seriesLength?) {
145
148
  ? Helpers.getRange(props, "y")
146
149
  : Helpers.getRange(props, "x");
147
150
  const extent = Math.abs(range[1] - range[0]);
148
- seriesLength =
151
+ const seriesLengthValue =
149
152
  seriesLength !== undefined
150
153
  ? seriesLength
151
154
  : (Array.isArray(datasets[0]) && datasets[0].length) || 1;
152
- groupLength = groupLength || datasets.length;
153
- const bars = groupLength * seriesLength;
155
+ const groupLengthValue = groupLength || datasets.length;
156
+ const bars = groupLengthValue * seriesLengthValue;
154
157
  const barRatio = 0.5;
155
158
  return Math.round((barRatio * extent) / bars);
156
159
  }
@@ -241,10 +244,10 @@ export function getDomainFromChildren(props, axis, childComponents) {
241
244
  }
242
245
 
243
246
  export function getDomain(props, axis, childComponents) {
244
- childComponents = childComponents || React.Children.toArray(props.children);
247
+ const children = childComponents || React.Children.toArray(props.children);
245
248
 
246
249
  const propsDomain = Domain.getDomainFromProps(props, axis);
247
- const domainPadding = getDefaultDomainPadding(props, axis, childComponents);
250
+ const domainPadding = getDefaultDomainPadding(props, axis, children);
248
251
  let domain;
249
252
 
250
253
  if (propsDomain) {
@@ -256,7 +259,7 @@ export function getDomain(props, axis, childComponents) {
256
259
  const dataDomain = dataset
257
260
  ? Domain.getDomainFromData(props, axis, dataset)!
258
261
  : [];
259
- const childDomain = getDomainFromChildren(props, axis, childComponents);
262
+ const childDomain = getDomainFromChildren(props, axis, children);
260
263
  const min =
261
264
  minDomain || Collection.getMinValue([...dataDomain, ...childDomain]);
262
265
  const max =
@@ -428,20 +431,12 @@ export function getCategoryAndAxisStringsFromChildren(
428
431
  }
429
432
 
430
433
  export function getStringsFromChildren(props, childComponents) {
431
- childComponents = childComponents || React.Children.toArray(props.children);
434
+ const children = childComponents || React.Children.toArray(props.children);
432
435
 
433
- const xStrings = getCategoryAndAxisStringsFromChildren(
434
- props,
435
- "x",
436
- childComponents,
437
- );
438
- const yStrings = getCategoryAndAxisStringsFromChildren(
439
- props,
440
- "y",
441
- childComponents,
442
- );
436
+ const xStrings = getCategoryAndAxisStringsFromChildren(props, "x", children);
437
+ const yStrings = getCategoryAndAxisStringsFromChildren(props, "y", children);
443
438
 
444
- const dataStrings = getStringsFromData(childComponents);
439
+ const dataStrings = getStringsFromData(children);
445
440
 
446
441
  return {
447
442
  x: uniq(flatten([...xStrings, ...dataStrings.x])),