victory-core 37.3.2 → 37.3.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.
Files changed (127) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/victory-core.js +423 -371
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/types/callbacks.d.ts +11 -11
  5. package/es/types/prop-types.d.ts +28 -28
  6. package/es/victory-animation/util.js +6 -6
  7. package/es/victory-animation/victory-animation.d.ts +3 -3
  8. package/es/victory-clip-container/victory-clip-container.d.ts +6 -1
  9. package/es/victory-clip-container/victory-clip-container.js +20 -12
  10. package/es/victory-container/victory-container.js +2 -2
  11. package/es/victory-label/victory-label.d.ts +3 -3
  12. package/es/victory-label/victory-label.js +12 -16
  13. package/es/victory-portal/victory-portal.js +4 -4
  14. package/es/victory-primitives/arc.js +2 -2
  15. package/es/victory-primitives/background.js +2 -2
  16. package/es/victory-primitives/border.js +2 -2
  17. package/es/victory-primitives/line-segment.js +2 -2
  18. package/es/victory-primitives/point.js +2 -2
  19. package/es/victory-primitives/tspan.d.ts +0 -1
  20. package/es/victory-primitives/types.d.ts +1 -1
  21. package/es/victory-primitives/whisker.d.ts +1 -1
  22. package/es/victory-primitives/whisker.js +2 -2
  23. package/es/victory-theme/types.d.ts +11 -11
  24. package/es/victory-transition/victory-transition.d.ts +1 -1
  25. package/es/victory-transition/victory-transition.js +7 -7
  26. package/es/victory-util/add-events.d.ts +8 -8
  27. package/es/victory-util/add-events.js +13 -13
  28. package/es/victory-util/axis.js +11 -11
  29. package/es/victory-util/data.js +16 -16
  30. package/es/victory-util/domain.js +13 -13
  31. package/es/victory-util/events.d.ts +4 -4
  32. package/es/victory-util/events.js +14 -14
  33. package/es/victory-util/helpers.d.ts +94 -19
  34. package/es/victory-util/helpers.js +95 -49
  35. package/es/victory-util/hooks/use-animation-state.d.ts +2 -2
  36. package/es/victory-util/hooks/use-animation-state.js +4 -4
  37. package/es/victory-util/label-helpers.d.ts +4 -3
  38. package/es/victory-util/label-helpers.js +3 -2
  39. package/es/victory-util/line-helpers.d.ts +1 -1
  40. package/es/victory-util/log.js +3 -2
  41. package/es/victory-util/merge-refs.d.ts +1 -1
  42. package/es/victory-util/scale.js +2 -2
  43. package/es/victory-util/selection.d.ts +3 -3
  44. package/es/victory-util/textsize.js +7 -5
  45. package/es/victory-util/timer.d.ts +1 -1
  46. package/es/victory-util/transitions.d.ts +1 -1
  47. package/es/victory-util/transitions.js +12 -12
  48. package/es/victory-util/type-helpers.d.ts +0 -1
  49. package/es/victory-util/type-helpers.js +0 -5
  50. package/es/victory-util/user-props.d.ts +2 -2
  51. package/es/victory-util/wrapper.js +12 -12
  52. package/lib/types/callbacks.d.ts +11 -11
  53. package/lib/types/prop-types.d.ts +28 -28
  54. package/lib/victory-animation/util.js +6 -6
  55. package/lib/victory-animation/victory-animation.d.ts +3 -3
  56. package/lib/victory-clip-container/victory-clip-container.d.ts +6 -1
  57. package/lib/victory-clip-container/victory-clip-container.js +20 -12
  58. package/lib/victory-container/victory-container.js +3 -3
  59. package/lib/victory-label/victory-label.d.ts +3 -3
  60. package/lib/victory-label/victory-label.js +12 -16
  61. package/lib/victory-portal/victory-portal.js +5 -5
  62. package/lib/victory-primitives/arc.js +2 -2
  63. package/lib/victory-primitives/background.js +2 -2
  64. package/lib/victory-primitives/border.js +2 -2
  65. package/lib/victory-primitives/line-segment.js +2 -2
  66. package/lib/victory-primitives/point.js +2 -2
  67. package/lib/victory-primitives/tspan.d.ts +0 -1
  68. package/lib/victory-primitives/types.d.ts +1 -1
  69. package/lib/victory-primitives/whisker.d.ts +1 -1
  70. package/lib/victory-primitives/whisker.js +2 -2
  71. package/lib/victory-theme/types.d.ts +11 -11
  72. package/lib/victory-transition/victory-transition.d.ts +1 -1
  73. package/lib/victory-transition/victory-transition.js +7 -7
  74. package/lib/victory-util/add-events.d.ts +8 -8
  75. package/lib/victory-util/add-events.js +13 -13
  76. package/lib/victory-util/axis.js +11 -11
  77. package/lib/victory-util/data.js +16 -16
  78. package/lib/victory-util/domain.js +13 -13
  79. package/lib/victory-util/events.d.ts +4 -4
  80. package/lib/victory-util/events.js +14 -14
  81. package/lib/victory-util/helpers.d.ts +94 -19
  82. package/lib/victory-util/helpers.js +96 -50
  83. package/lib/victory-util/hooks/use-animation-state.d.ts +2 -2
  84. package/lib/victory-util/hooks/use-animation-state.js +4 -4
  85. package/lib/victory-util/label-helpers.d.ts +4 -3
  86. package/lib/victory-util/label-helpers.js +3 -3
  87. package/lib/victory-util/line-helpers.d.ts +1 -1
  88. package/lib/victory-util/log.js +3 -2
  89. package/lib/victory-util/merge-refs.d.ts +1 -1
  90. package/lib/victory-util/scale.js +2 -2
  91. package/lib/victory-util/selection.d.ts +3 -3
  92. package/lib/victory-util/textsize.js +5 -5
  93. package/lib/victory-util/timer.d.ts +1 -1
  94. package/lib/victory-util/transitions.d.ts +1 -1
  95. package/lib/victory-util/transitions.js +12 -12
  96. package/lib/victory-util/type-helpers.d.ts +0 -1
  97. package/lib/victory-util/type-helpers.js +0 -6
  98. package/lib/victory-util/user-props.d.ts +2 -2
  99. package/lib/victory-util/wrapper.js +12 -12
  100. package/package.json +2 -30
  101. package/src/victory-animation/util.ts +3 -1
  102. package/src/victory-clip-container/victory-clip-container.tsx +26 -11
  103. package/src/victory-container/victory-container.tsx +1 -1
  104. package/src/victory-label/victory-label.tsx +5 -3
  105. package/src/victory-portal/victory-portal.tsx +3 -1
  106. package/src/victory-primitives/arc.tsx +1 -1
  107. package/src/victory-primitives/background.tsx +1 -1
  108. package/src/victory-primitives/border.tsx +1 -1
  109. package/src/victory-primitives/line-segment.tsx +1 -1
  110. package/src/victory-primitives/point.tsx +1 -1
  111. package/src/victory-primitives/whisker.tsx +1 -1
  112. package/src/victory-transition/victory-transition.tsx +4 -2
  113. package/src/victory-util/add-events.tsx +5 -2
  114. package/src/victory-util/axis.tsx +7 -3
  115. package/src/victory-util/data.ts +9 -10
  116. package/src/victory-util/domain.ts +8 -4
  117. package/src/victory-util/events.ts +4 -1
  118. package/src/victory-util/helpers.ts +155 -39
  119. package/src/victory-util/hooks/use-animation-state.ts +1 -1
  120. package/src/victory-util/label-helpers.ts +1 -1
  121. package/src/victory-util/log.ts +3 -2
  122. package/src/victory-util/scale.ts +1 -1
  123. package/src/victory-util/textsize.ts +2 -1
  124. package/src/victory-util/transitions.ts +3 -1
  125. package/src/victory-util/type-helpers.ts +0 -5
  126. package/src/victory-util/user-props.ts +1 -1
  127. package/src/victory-util/wrapper.tsx +5 -1
@@ -1,13 +1,13 @@
1
- import _pick from "lodash/pick";
2
- import _defaults from "lodash/defaults";
3
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
2
  import React from "react";
3
+ import defaults from "lodash/defaults";
4
+ import pick from "lodash/pick";
5
+ import isEqual from "react-fast-compare";
5
6
  import { VictoryAnimation } from "../victory-animation/victory-animation";
6
7
  import * as Collection from "../victory-util/collection";
7
8
  import * as Helpers from "../victory-util/helpers";
8
9
  import TimerContext from "../victory-util/timer-context";
9
10
  import * as Transitions from "../victory-util/transitions";
10
- import isEqual from "react-fast-compare";
11
11
  export class VictoryTransition extends React.Component {
12
12
  static displayName = "VictoryTransition";
13
13
  static contextType = TimerContext;
@@ -121,13 +121,13 @@ export class VictoryTransition extends React.Component {
121
121
  y: this.getDomainFromChildren(props, "y")
122
122
  };
123
123
  const clipWidth = this.getClipWidth(props, child);
124
- const combinedProps = _defaults({
124
+ const combinedProps = defaults({
125
125
  domain,
126
126
  clipWidth
127
127
  }, transitionProps, child.props);
128
128
  const animationWhitelist = props.animationWhitelist || [];
129
129
  const whitelist = animationWhitelist.concat(["clipWidth"]);
130
- const propsToAnimate = whitelist.length ? _pick(combinedProps, whitelist) : combinedProps;
130
+ const propsToAnimate = whitelist.length ? pick(combinedProps, whitelist) : combinedProps;
131
131
  return /*#__PURE__*/React.createElement(VictoryAnimation, _extends({}, combinedProps.animate, {
132
132
  data: propsToAnimate
133
133
  }), newProps => {
@@ -135,13 +135,13 @@ export class VictoryTransition extends React.Component {
135
135
  const groupComponent = this.continuous ? /*#__PURE__*/React.cloneElement(child.props.groupComponent, {
136
136
  clipWidth: newProps.clipWidth || 0
137
137
  }) : child.props.groupComponent;
138
- return /*#__PURE__*/React.cloneElement(child, _defaults({
138
+ return /*#__PURE__*/React.cloneElement(child, defaults({
139
139
  animate: null,
140
140
  animating: true,
141
141
  groupComponent
142
142
  }, newProps, combinedProps));
143
143
  }
144
- return /*#__PURE__*/React.cloneElement(child, _defaults({
144
+ return /*#__PURE__*/React.cloneElement(child, defaults({
145
145
  animate: null,
146
146
  animating: true
147
147
  }, newProps, combinedProps));
@@ -3,7 +3,7 @@ import { VictoryLabelableProps } from "../types/prop-types";
3
3
  import { VictoryCommonProps, VictoryDatableProps } from "./common-props";
4
4
  import type { ComponentEvent } from "./events";
5
5
  import * as Events from "./events";
6
- export declare type MixinOptions = {
6
+ export type MixinOptions = {
7
7
  components?: Array<{
8
8
  name: string;
9
9
  index?: string | number;
@@ -24,7 +24,7 @@ export interface EventsMixinClass<TProps> {
24
24
  renderContainer(component: React.ReactElement, children: React.ReactElement | React.ReactElement[]): React.ReactElement;
25
25
  cacheValues<TThis>(this: TThis, obj: Partial<TThis>): void;
26
26
  getEventState: typeof Events.getEventState;
27
- renderData(props: TProps): any;
27
+ renderData(props: TProps, shouldRenderDatum?: () => boolean): any;
28
28
  renderContinuousData(props: TProps): any;
29
29
  animateComponent(props: TProps, defaultAnimationWhitelist: string[]): React.ReactElement;
30
30
  getComponentProps(component: React.ReactNode, type: string, index: string | number): TProps;
@@ -44,12 +44,12 @@ export interface EventMixinCalculatedValues {
44
44
  /**
45
45
  * These are the common roles that we care about internally.
46
46
  */
47
- export declare type VictoryComponentCommonRole = "container" | "group" | "histogram" | "label" | "line" | "portal" | "stack" | "tooltip" | "voronoi";
47
+ export type VictoryComponentCommonRole = "container" | "group" | "histogram" | "label" | "line" | "portal" | "stack" | "tooltip" | "voronoi";
48
48
  /**
49
49
  * A component can have any "role",
50
50
  * but there are certain ones that we actually care about internally
51
51
  */
52
- export declare type VictoryComponentRole = VictoryComponentCommonRole | string;
52
+ export type VictoryComponentRole = VictoryComponentCommonRole | string;
53
53
  /**
54
54
  * Static component fields used by Victory for common behavior
55
55
  */
@@ -111,17 +111,17 @@ export declare function addEvents<TBase extends WrappedComponentClass<TProps>, T
111
111
  UNSAFE_componentWillReceiveProps?(nextProps: Readonly<TProps>, nextContext: any): void;
112
112
  componentWillUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): void;
113
113
  UNSAFE_componentWillUpdate?(nextProps: Readonly<TProps>, nextState: Readonly<{}>, nextContext: any): void;
114
- componentEvents: ComponentEvent[];
114
+ componentEvents: Array<ComponentEvent>;
115
115
  getSharedEventState: (key: string, value: string) => unknown;
116
116
  baseProps: Record<string, object>;
117
117
  dataKeys: string[];
118
118
  hasEvents: unknown;
119
119
  events: unknown;
120
120
  };
121
- getBaseProps?(props: TProps): Record<string, object>;
122
- role?: string | undefined;
121
+ getBaseProps?(props: TProps): EventMixinCalculatedValues["baseProps"];
122
+ role?: VictoryComponentRole;
123
123
  expectedComponents?: (string | keyof TProps)[] | undefined;
124
- getChildren?: ((props: TProps, childComponents?: React.ReactNode[] | undefined, calculatedProps?: TProps | undefined) => void) | undefined;
124
+ getChildren?: ((props: TProps, childComponents?: Array<React.ReactNode>, calculatedProps?: TProps | undefined) => void) | undefined;
125
125
  animationWhitelist?: (string | keyof TProps)[] | undefined;
126
126
  } & TBase;
127
127
  //# sourceMappingURL=add-events.d.ts.map
@@ -1,7 +1,7 @@
1
- import _pick from "lodash/pick";
2
- import _isEmpty from "lodash/isEmpty";
3
- import _defaults from "lodash/defaults";
4
1
  import React from "react";
2
+ import defaults from "lodash/defaults";
3
+ import isEmpty from "lodash/isEmpty";
4
+ import pick from "lodash/pick";
5
5
  import isEqual from "react-fast-compare";
6
6
  import { VictoryTransition } from "../victory-transition/victory-transition";
7
7
  import { difference } from "./collection";
@@ -138,8 +138,8 @@ export function addEvents(WrappedComponent, options) {
138
138
  return {};
139
139
  }
140
140
  const getState = (key, type) => {
141
- const result = _defaults({}, this.getEventState(key, type), this.getSharedEventState(key, type));
142
- return _isEmpty(result) ? undefined : result;
141
+ const result = defaults({}, this.getEventState(key, type), this.getSharedEventState(key, type));
142
+ return isEmpty(result) ? undefined : result;
143
143
  };
144
144
  const components = options.components || defaultComponents;
145
145
  const stateChanges = components.map(component => {
@@ -152,7 +152,7 @@ export function addEvents(WrappedComponent, options) {
152
152
  return stateChanges;
153
153
  }
154
154
  applyExternalMutations(props, externalMutations) {
155
- if (!_isEmpty(externalMutations)) {
155
+ if (!isEmpty(externalMutations)) {
156
156
  const callbacks = props.externalEventMutations.reduce((memo, mutation) => isFunction(mutation.callback) ? memo.concat(mutation.callback) : memo, []);
157
157
  const compiledCallbacks = callbacks.length ? () => {
158
158
  callbacks.forEach(c => c());
@@ -185,7 +185,7 @@ export function addEvents(WrappedComponent, options) {
185
185
  sharedEvents,
186
186
  externalEventMutations
187
187
  } = props;
188
- return _isEmpty(externalEventMutations) || sharedEvents ? undefined : Events.getExternalMutations(externalEventMutations, this.baseProps, this.state);
188
+ return isEmpty(externalEventMutations) || sharedEvents ? undefined : Events.getExternalMutations(externalEventMutations, this.baseProps, this.state);
189
189
  }
190
190
  cacheValues(obj) {
191
191
  Object.keys(obj).forEach(key => {
@@ -196,10 +196,10 @@ export function addEvents(WrappedComponent, options) {
196
196
  const getSharedEventStateFunction = getSharedEventState || this.getSharedEventState.bind(this);
197
197
  const sharedParentState = getSharedEventStateFunction("parent", "parent");
198
198
  const parentState = this.getEventState("parent", "parent");
199
- const baseParentProps = _defaults({}, parentState, sharedParentState);
199
+ const baseParentProps = defaults({}, parentState, sharedParentState);
200
200
  const parentPropsList = baseParentProps.parentControlledProps;
201
- const parentProps = parentPropsList ? _pick(baseParentProps, parentPropsList) : {};
202
- const modifiedProps = _defaults({}, parentProps, props);
201
+ const parentProps = parentPropsList ? pick(baseParentProps, parentPropsList) : {};
202
+ const modifiedProps = defaults({}, parentProps, props);
203
203
  return typeof WrappedComponent.getBaseProps === "function" ? WrappedComponent.getBaseProps(modifiedProps) : {};
204
204
  }
205
205
  getAllEvents(props) {
@@ -219,18 +219,18 @@ export function addEvents(WrappedComponent, options) {
219
219
  const currentProps = component && typeof component === "object" && "props" in component ? component.props : undefined;
220
220
  if (this.hasEvents) {
221
221
  const baseEvents = this.getEvents(this.props, type, key);
222
- const componentProps = _defaults({
222
+ const componentProps = defaults({
223
223
  index,
224
224
  key: id
225
225
  }, this.getEventState(key, type), this.getSharedEventState(key, type), currentProps, baseProps, {
226
226
  id
227
227
  });
228
- const events = _defaults({}, Events.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
228
+ const events = defaults({}, Events.getPartialEvents(baseEvents, key, componentProps), componentProps.events);
229
229
  return Object.assign({}, componentProps, {
230
230
  events
231
231
  });
232
232
  }
233
- return _defaults({
233
+ return defaults({
234
234
  index,
235
235
  key: id
236
236
  }, currentProps, baseProps, {
@@ -1,8 +1,8 @@
1
- import _orderBy from "lodash/orderBy";
2
- import _uniq from "lodash/uniq";
3
- import _isObject from "lodash/isObject";
4
- import _defaults from "lodash/defaults";
5
1
  import React from "react";
2
+ import defaults from "lodash/defaults";
3
+ import isObject from "lodash/isObject";
4
+ import uniq from "lodash/uniq";
5
+ import orderBy from "lodash/orderBy";
6
6
  import * as Collection from "./collection";
7
7
  import * as Domain from "./domain";
8
8
  import * as Helpers from "./helpers";
@@ -138,7 +138,7 @@ function getDefaultTickFormat(props) {
138
138
  return stringTicks(props) ? (x, index) => tickValues[index] : fallbackFormat;
139
139
  }
140
140
  const invertedStringMap = stringMap && Helpers.invert(stringMap);
141
- const tickValueArray = _orderBy(Object.values(stringMap), n => n);
141
+ const tickValueArray = orderBy(Object.values(stringMap), n => n);
142
142
  const dataNames = tickValueArray.map(tick => invertedStringMap[tick]);
143
143
  // string ticks should have one tick of padding at the beginning
144
144
  const dataTicks = ["", ...dataNames, ""];
@@ -175,14 +175,14 @@ function getTickArray(props) {
175
175
  if (tickValues && Collection.containsStrings(tickValues)) {
176
176
  ticks = stringMap ? tickValues.map(tick => stringMap[tick]) : Helpers.range(1, tickValues.length + 1);
177
177
  }
178
- const tickArray = ticks ? _uniq(ticks) : getTicksFromFormat();
178
+ const tickArray = ticks ? uniq(ticks) : getTicksFromFormat();
179
179
  const buildTickArray = arr => {
180
180
  const newTickArray = [];
181
181
  const domain = props.domain && props.domain[axis] || props.domain;
182
182
  if (arr) {
183
183
  arr.forEach((t, index) => {
184
184
  if (Array.isArray(domain)) {
185
- if (t >= Collection.getMinValue(domain) && t <= Collection.getMaxValue(domain)) {
185
+ if (t >= Collection.getMinValue(domain).valueOf() && t <= Collection.getMaxValue(domain).valueOf()) {
186
186
  newTickArray.push({
187
187
  value: t,
188
188
  index
@@ -312,17 +312,17 @@ export function getAxisValue(props, axis) {
312
312
  return undefined;
313
313
  }
314
314
  const scaleAxis = axis === "x" ? "y" : "x";
315
- const scale = _isObject(props.scale) && Helpers.isFunction(props.scale[scaleAxis]) ? props.scale[scaleAxis] : undefined;
315
+ const scale = isObject(props.scale) && Helpers.isFunction(props.scale[scaleAxis]) ? props.scale[scaleAxis] : undefined;
316
316
  if (!scale) {
317
317
  return undefined;
318
318
  }
319
319
  const stringMapAxis = axis === "x" ? "y" : "x";
320
- const stringMap = _isObject(props.stringMap) && props.stringMap[stringMapAxis];
320
+ const stringMap = isObject(props.stringMap) && props.stringMap[stringMapAxis];
321
321
  const axisValue = stringMap && typeof props.axisValue === "string" ? stringMap[props.axisValue] : props.axisValue;
322
322
  return scale(axisValue);
323
323
  }
324
324
  export function modifyProps(props, fallbackProps) {
325
- if (!_isObject(props.theme)) {
325
+ if (!isObject(props.theme)) {
326
326
  return Helpers.modifyProps(props, fallbackProps, "axis");
327
327
  }
328
328
  let role = "axis";
@@ -334,7 +334,7 @@ export function modifyProps(props, fallbackProps) {
334
334
  if (role === "axis") {
335
335
  return Helpers.modifyProps(props, fallbackProps, "axis");
336
336
  }
337
- const axisTheme = _defaults({}, props.theme[role], props.theme.axis);
337
+ const axisTheme = defaults({}, props.theme[role], props.theme.axis);
338
338
  const theme = Object.assign({}, props.theme, {
339
339
  axis: axisTheme
340
340
  });
@@ -1,12 +1,12 @@
1
- import _omitBy from "lodash/omitBy";
2
- import _isUndefined from "lodash/isUndefined";
3
- import _isEqual from "lodash/isEqual";
4
- import _isEmpty from "lodash/isEmpty";
5
- import _orderBy from "lodash/orderBy";
6
- import _property from "lodash/property";
7
- import _isPlainObject from "lodash/isPlainObject";
8
- import _uniq from "lodash/uniq";
9
1
  import React from "react";
2
+ import isEmpty from "lodash/isEmpty";
3
+ import isEqual from "lodash/isEqual";
4
+ import isPlainObject from "lodash/isPlainObject";
5
+ import isUndefined from "lodash/isUndefined";
6
+ import omitBy from "lodash/omitBy";
7
+ import orderBy from "lodash/orderBy";
8
+ import property from "lodash/property";
9
+ import uniq from "lodash/uniq";
10
10
  import * as Helpers from "./helpers";
11
11
  import * as Collection from "./collection";
12
12
  import * as Scale from "./scale";
@@ -27,7 +27,7 @@ function getLength(data) {
27
27
 
28
28
  // Returns generated data for a given axis based on domain and sample from props
29
29
  function generateDataArray(props, axis) {
30
- const propsDomain = _isPlainObject(props.domain) ? props.domain[axis] : props.domain;
30
+ const propsDomain = isPlainObject(props.domain) ? props.domain[axis] : props.domain;
31
31
  const domain = propsDomain || Scale.getBaseScale(props, axis).domain();
32
32
  const samples = props.samples || 1;
33
33
  const domainMax = Math.max(...domain);
@@ -52,7 +52,7 @@ function sortData(dataset, sortKey, sortOrder) {
52
52
  formattedSortKey = `_${sortKey}`;
53
53
  }
54
54
  const order = sortOrder === "ascending" ? "asc" : "desc";
55
- return _orderBy(dataset, formattedSortKey, order);
55
+ return orderBy(dataset, formattedSortKey, order);
56
56
  }
57
57
 
58
58
  // This method will remove data points that break certain scales. (log scale only)
@@ -96,7 +96,7 @@ function getEventKey(key) {
96
96
  return () => undefined;
97
97
  }
98
98
  // otherwise, assume it is an array index, property key or path (_.property handles all three)
99
- return _property(key);
99
+ return property(key);
100
100
  }
101
101
 
102
102
  // Returns data with an eventKey prop added to each datum
@@ -155,12 +155,12 @@ export function formatDataFromDomain(dataset, domain, defaultBaseline) {
155
155
  if (isUnderMinY(baseline) && !isUnderMinY(value)) _y0 = minDomainY;
156
156
  // baseline and value with only baseline above max, set baseline to maxDomainY
157
157
  if (isOverMaxY(baseline) && !isOverMaxY(value)) _y0 = maxDomainY;
158
- return Object.assign({}, datum, _omitBy({
158
+ return Object.assign({}, datum, omitBy({
159
159
  _x,
160
160
  _y,
161
161
  _y0,
162
162
  _y1
163
- }, _isUndefined));
163
+ }, isUndefined));
164
164
  });
165
165
  }
166
166
 
@@ -174,7 +174,7 @@ export function createStringMap(props, axis) {
174
174
  const stringsFromAxes = getStringsFromAxes(props, axis);
175
175
  const stringsFromCategories = getStringsFromCategories(props, axis);
176
176
  const stringsFromData = getStringsFromData(props, axis);
177
- const allStrings = _uniq([...stringsFromAxes, ...stringsFromCategories, ...stringsFromData]);
177
+ const allStrings = uniq([...stringsFromAxes, ...stringsFromCategories, ...stringsFromData]);
178
178
  return allStrings.length === 0 ? null : allStrings.reduce((memo, string, index) => {
179
179
  memo[string] = index + 1;
180
180
  return memo;
@@ -230,7 +230,7 @@ export function formatData(dataset, props, expectedKeys) {
230
230
  memo[type] = createAccessor(type);
231
231
  return memo;
232
232
  }, {});
233
- const preformattedData = _isEqual(expectedKeys, defaultKeys) && props.x === "_x" && props.y === "_y" && props.y0 === "_y0";
233
+ const preformattedData = isEqual(expectedKeys, defaultKeys) && props.x === "_x" && props.y === "_y" && props.y0 === "_y0";
234
234
  let stringMap;
235
235
  if (preformattedData === false) {
236
236
  // stringMap is not required if the data is preformatted
@@ -260,7 +260,7 @@ export function formatData(dataset, props, expectedKeys) {
260
260
  return memo;
261
261
  }, {});
262
262
  const formattedDatum = Object.assign({}, processedValues, parsedDatum);
263
- if (!_isEmpty(formattedDatum)) {
263
+ if (!isEmpty(formattedDatum)) {
264
264
  dataArr.push(formattedDatum);
265
265
  }
266
266
  return dataArr;
@@ -1,7 +1,7 @@
1
- import _isDate from "lodash/isDate";
2
- import _sortedUniq from "lodash/sortedUniq";
3
- import _isPlainObject from "lodash/isPlainObject";
4
1
  import React from "react";
2
+ import isDate from "lodash/isDate";
3
+ import isPlainObject from "lodash/isPlainObject";
4
+ import sortedUniq from "lodash/sortedUniq";
5
5
  import * as Data from "./data";
6
6
  import * as Scale from "./scale";
7
7
  import * as Helpers from "./helpers";
@@ -32,7 +32,7 @@ function getDomainPadding(props, axis) {
32
32
  right: padding
33
33
  };
34
34
  };
35
- return _isPlainObject(props.domainPadding) ? formatPadding(props.domainPadding[axis]) : formatPadding(props.domainPadding);
35
+ return isPlainObject(props.domainPadding) ? formatPadding(props.domainPadding[axis]) : formatPadding(props.domainPadding);
36
36
  }
37
37
  function getFlatData(dataset, axis) {
38
38
  const axisKey = `_${axis}`;
@@ -81,10 +81,10 @@ function padDomain(domain, props, axis) {
81
81
  min: min.valueOf() - simplePadding.left,
82
82
  max: max.valueOf() + simplePadding.right
83
83
  };
84
- const singleQuadrantDomainPadding = _isPlainObject(props.singleQuadrantDomainPadding) ? props.singleQuadrantDomainPadding[axis] : props.singleQuadrantDomainPadding;
85
- const addsQuadrants = min >= 0 && paddedDomain.min <= 0 || max <= 0 && paddedDomain.max >= 0;
84
+ const singleQuadrantDomainPadding = isPlainObject(props.singleQuadrantDomainPadding) ? props.singleQuadrantDomainPadding[axis] : props.singleQuadrantDomainPadding;
85
+ const addsQuadrants = min.valueOf() >= 0 && paddedDomain.min <= 0 || max.valueOf() <= 0 && paddedDomain.max >= 0;
86
86
  const adjust = (val, type) => {
87
- const coerce = type === "min" && min >= 0 && val <= 0 || type === "max" && max <= 0 && val >= 0;
87
+ const coerce = type === "min" && min.valueOf() >= 0 && val <= 0 || type === "max" && max.valueOf() <= 0 && val >= 0;
88
88
  return coerce ? 0 : val;
89
89
  };
90
90
  if (addsQuadrants && singleQuadrantDomainPadding !== false) {
@@ -253,7 +253,7 @@ export function getDomainFromMinMax(min, max) {
253
253
  export function getDomainFromProps(props, axis) {
254
254
  const minDomain = getMinFromProps(props, axis);
255
255
  const maxDomain = getMaxFromProps(props, axis);
256
- if (_isPlainObject(props.domain) && props.domain[axis]) {
256
+ if (isPlainObject(props.domain) && props.domain[axis]) {
257
257
  return props.domain[axis];
258
258
  } else if (Array.isArray(props.domain)) {
259
259
  return props.domain;
@@ -304,10 +304,10 @@ export function getDomainWithZero(props, axis) {
304
304
  * @returns {Number|Date|undefined} the maxDomain based on props
305
305
  */
306
306
  export function getMaxFromProps(props, axis) {
307
- if (_isPlainObject(props.maxDomain) && props.maxDomain[axis] !== undefined) {
307
+ if (isPlainObject(props.maxDomain) && props.maxDomain[axis] !== undefined) {
308
308
  return props.maxDomain[axis];
309
309
  }
310
- return typeof props.maxDomain === "number" || _isDate(props.maxDomain) ? props.maxDomain : undefined;
310
+ return typeof props.maxDomain === "number" || isDate(props.maxDomain) ? props.maxDomain : undefined;
311
311
  }
312
312
 
313
313
  /**
@@ -317,10 +317,10 @@ export function getMaxFromProps(props, axis) {
317
317
  * @returns {Number|Date|undefined} the minDomain based on props
318
318
  */
319
319
  export function getMinFromProps(props, axis) {
320
- if (_isPlainObject(props.minDomain) && props.minDomain[axis] !== undefined) {
320
+ if (isPlainObject(props.minDomain) && props.minDomain[axis] !== undefined) {
321
321
  return props.minDomain[axis];
322
322
  }
323
- return typeof props.minDomain === "number" || _isDate(props.minDomain) ? props.minDomain : undefined;
323
+ return typeof props.minDomain === "number" || isDate(props.minDomain) ? props.minDomain : undefined;
324
324
  }
325
325
 
326
326
  /**
@@ -331,7 +331,7 @@ export function getMinFromProps(props, axis) {
331
331
  * @returns {Array} the symmetric domain
332
332
  */
333
333
  export function getSymmetricDomain(domain, values) {
334
- const processedData = _sortedUniq(values.sort((a, b) => a - b));
334
+ const processedData = sortedUniq(values.sort((a, b) => a - b));
335
335
  const step = processedData[1] - processedData[0];
336
336
  return [domain[0], domain[1] + step];
337
337
  }
@@ -1,17 +1,17 @@
1
1
  import React from "react";
2
2
  import type { EventMixinCalculatedValues } from "./add-events";
3
- declare type ComponentEventKey = string | number;
3
+ type ComponentEventKey = string | number;
4
4
  export interface ComponentEvent {
5
5
  target?: "parent" | string;
6
6
  eventKey?: ComponentEventKey | ComponentEventKey[];
7
7
  eventHandlers: ComponentEventHandlers;
8
8
  }
9
- export declare type ComponentEventName = string;
9
+ export type ComponentEventName = string;
10
10
  export interface ComponentEventHandlers {
11
11
  [k: ComponentEventName]: ComponentEventHandler;
12
12
  }
13
- export declare type ComponentEventHandler = (evt: React.SyntheticEvent, childProps: unknown, eventKey: ComponentEventKey, eventName: ComponentEventName) => UpdatedProps;
14
- export declare type UpdatedProps = any;
13
+ export type ComponentEventHandler = (evt: React.SyntheticEvent, childProps: unknown, eventKey: ComponentEventKey, eventName: ComponentEventName) => UpdatedProps;
14
+ export type UpdatedProps = any;
15
15
  interface ComponentWithEvents extends EventMixinCalculatedValues {
16
16
  state: any;
17
17
  setState: any;
@@ -1,7 +1,7 @@
1
- import _uniq from "lodash/uniq";
2
- import _omitBy from "lodash/omitBy";
3
- import _pickBy from "lodash/pickBy";
4
- import _isEmpty from "lodash/isEmpty";
1
+ import isEmpty from "lodash/isEmpty";
2
+ import pickBy from "lodash/pickBy";
3
+ import omitBy from "lodash/omitBy";
4
+ import uniq from "lodash/uniq";
5
5
  import { isFunction } from "./helpers";
6
6
  const GLOBAL_EVENT_REGEX = /^onGlobal(.*)$/;
7
7
 
@@ -72,7 +72,7 @@ getScopedEvents) {
72
72
  */
73
73
  // eslint-disable-next-line max-params
74
74
  export function getScopedEvents(events, namespace, childType, baseProps) {
75
- if (_isEmpty(events)) {
75
+ if (isEmpty(events)) {
76
76
  return {};
77
77
  }
78
78
 
@@ -185,7 +185,7 @@ export function getScopedEvents(events, namespace, childType, baseProps) {
185
185
  // eslint-disable-next-line max-params
186
186
  const onEvent = (evt, childProps, eventKey, eventName) => {
187
187
  const eventReturn = events[eventName](evt, childProps, eventKey, this);
188
- if (!_isEmpty(eventReturn)) {
188
+ if (!isEmpty(eventReturn)) {
189
189
  const callbacks = compileCallbacks(eventReturn);
190
190
  this.setState(parseEventReturn(eventReturn, eventKey), callbacks);
191
191
  }
@@ -246,7 +246,7 @@ export function getExternalMutationsWithChildren(mutations, baseProps, baseState
246
246
  const childState = baseState[childName];
247
247
  const mutation = getExternalMutations(mutations, baseProps[childName], baseState[childName], childName);
248
248
  memo[childName] = mutation ? mutation : childState;
249
- return _pickBy(memo, v => !_isEmpty(v));
249
+ return pickBy(memo, v => !isEmpty(v));
250
250
  }, {});
251
251
  }
252
252
 
@@ -282,7 +282,7 @@ export function getExternalMutations(mutations, baseProps, baseState, childName)
282
282
  } else {
283
283
  // use keys from both state and props so that elements not intially included in baseProps
284
284
  // will be used. (i.e. labels)
285
- const targets = _uniq(Object.keys(keyProps).concat(Object.keys(keyState)));
285
+ const targets = uniq(Object.keys(keyProps).concat(Object.keys(keyState)));
286
286
  memo[eventKey] = targets.reduce((m, target) => {
287
287
  const identifier = {
288
288
  eventKey,
@@ -291,10 +291,10 @@ export function getExternalMutations(mutations, baseProps, baseState, childName)
291
291
  };
292
292
  const mutation = getExternalMutation(mutations, keyProps[target], keyState[target], identifier);
293
293
  m[target] = mutation !== undefined ? Object.assign({}, keyState[target], mutation) : keyState[target];
294
- return _pickBy(m, v => !_isEmpty(v));
294
+ return pickBy(m, v => !isEmpty(v));
295
295
  }, {});
296
296
  }
297
- return _pickBy(memo, v => !_isEmpty(v));
297
+ return pickBy(memo, v => !isEmpty(v));
298
298
  }, {});
299
299
  }
300
300
 
@@ -326,11 +326,11 @@ export function getExternalMutation(mutations, baseProps, baseState, identifier)
326
326
  }
327
327
  // find any mutation objects that match the target
328
328
  const targetMutations = scopedMutations.filter(m => filterMutations(m, "target"));
329
- if (_isEmpty(targetMutations)) {
329
+ if (isEmpty(targetMutations)) {
330
330
  return undefined;
331
331
  }
332
332
  const keyMutations = targetMutations.filter(m => filterMutations(m, "eventKey"));
333
- if (_isEmpty(keyMutations)) {
333
+ if (isEmpty(keyMutations)) {
334
334
  return undefined;
335
335
  }
336
336
  return keyMutations.reduce((memo, curr) => {
@@ -356,8 +356,8 @@ export function getGlobalEventNameFromKey(key) {
356
356
  const match = key.match(GLOBAL_EVENT_REGEX);
357
357
  return match && match[1] && match[1].toLowerCase();
358
358
  }
359
- export const getGlobalEvents = events => _pickBy(events, (_, key) => GLOBAL_EVENT_REGEX.test(key));
360
- export const omitGlobalEvents = events => _omitBy(events, (_, key) => GLOBAL_EVENT_REGEX.test(key));
359
+ export const getGlobalEvents = events => pickBy(events, (_, key) => GLOBAL_EVENT_REGEX.test(key));
360
+ export const omitGlobalEvents = events => omitBy(events, (_, key) => GLOBAL_EVENT_REGEX.test(key));
361
361
  export const emulateReactEvent = event => Object.assign(event, {
362
362
  nativeEvent: event
363
363
  });
@@ -1,6 +1,27 @@
1
1
  import React from "react";
2
- import { CallbackArgs } from "../types/callbacks";
3
2
  import { ValueOrAccessor } from "../types/prop-types";
3
+ export type ElementPadding = {
4
+ top: number;
5
+ bottom: number;
6
+ left: number;
7
+ right: number;
8
+ };
9
+ export type MaybePointData = {
10
+ x?: number;
11
+ x0?: number;
12
+ x1?: number;
13
+ y?: number;
14
+ y0?: number;
15
+ y1?: number;
16
+ _x?: number;
17
+ _x0?: number;
18
+ _x1?: number;
19
+ _y?: number;
20
+ _y0?: number;
21
+ _y1?: number;
22
+ _voronoiX?: number;
23
+ _voronoiY?: number;
24
+ };
4
25
  /**
5
26
  * Creates an object composed of the inverted keys and values of object.
6
27
  * If object contains duplicate values, subsequent values overwrite property assignments of previous values.
@@ -14,32 +35,83 @@ export declare function invert(original: Record<string, string | number>): {};
14
35
  * @returns {Object} new object with same properties as originalObject
15
36
  */
16
37
  export declare function omit<T, Keys extends keyof T>(originalObject: T, ks?: Array<Keys>): Omit<T, Keys>;
17
- export declare function getPoint(datum: any): any;
18
- export declare function scalePoint(props: any, datum: any): {
19
- x: any;
20
- x0: any;
21
- y: any;
22
- y0: any;
23
- };
24
- export declare function getPadding(props: any, name?: string): {
25
- top: any;
26
- bottom: any;
27
- left: any;
28
- right: any;
38
+ /**
39
+ * Coalesce the x and y values from a data point
40
+ */
41
+ export declare function getPoint(datum: MaybePointData): MaybePointData;
42
+ /**
43
+ * Scale a point based on the origin, direction, and given scale function
44
+ */
45
+ export declare function scalePoint(props: {
46
+ scale: {
47
+ x: (x?: number) => number;
48
+ y: (y?: number) => number;
49
+ };
50
+ polar?: boolean;
51
+ horizontal?: boolean;
52
+ origin?: {
53
+ x: number;
54
+ y: number;
55
+ };
56
+ }, datum: MaybePointData): {
57
+ x: number;
58
+ x0: number;
59
+ y: number;
60
+ y0: number;
29
61
  };
30
- export declare function isTooltip(component: any): boolean;
62
+ /**
63
+ * Returns a padding value from a number or partial padding values
64
+ */
65
+ export declare function getPadding(padding?: number | Partial<ElementPadding>): ElementPadding;
66
+ /**
67
+ * Returns true if the component is defined as a tooltip
68
+ */
69
+ export declare function isTooltip(component?: {
70
+ type?: {
71
+ role?: string;
72
+ };
73
+ }): boolean;
31
74
  export declare function getDefaultStyles(props: any, role: any): any;
32
75
  export declare function getStyles(style: any, defaultStyles: any): any;
33
- export declare function evaluateProp<TValue>(prop: ValueOrAccessor<TValue, CallbackArgs>, props: CallbackArgs): TValue;
76
+ /**
77
+ * Returns the value of a prop or accessor function with the given props
78
+ */
79
+ export declare function evaluateProp<TValue>(prop: ValueOrAccessor<TValue, Record<string, any>>, props: Record<string, any>): TValue;
34
80
  export declare function evaluateStyle(style: any, props: any): any;
35
81
  export declare function degreesToRadians(degrees: any): any;
36
82
  export declare function radiansToDegrees(radians: any): any;
37
- export declare function getRadius(props: any): number;
38
- export declare function getPolarOrigin(props: any): {
83
+ /**
84
+ * Get the maximum radius that will fit in the container
85
+ */
86
+ export declare function getRadius(options: {
87
+ height: number;
88
+ width: number;
89
+ padding: ElementPadding;
90
+ }): number;
91
+ /**
92
+ * Returns the origin for a polar chart within the padded area
93
+ */
94
+ export declare function getPolarOrigin(props: {
95
+ height: number;
96
+ width: number;
97
+ padding: ElementPadding;
98
+ }): {
39
99
  x: number;
40
100
  y: number;
41
101
  };
42
- export declare function getRange(props: any, axis: any): any;
102
+ /**
103
+ * Determine the range of an axis based on the given props
104
+ */
105
+ export declare function getRange(props: {
106
+ range?: [number, number];
107
+ polar?: boolean;
108
+ innerRadius?: number;
109
+ startAngle?: number;
110
+ endAngle?: number;
111
+ height: number;
112
+ width: number;
113
+ padding: number | Partial<ElementPadding>;
114
+ }, axis: "x" | "y"): any;
43
115
  /**
44
116
  * Checks if `value` is `null` or `undefined`.
45
117
  * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
@@ -93,5 +165,8 @@ export declare function reduceChildren<TChildren extends React.ReactNode, TItem,
93
165
  * @returns {Boolean} returns true if the props object contains `horizontal: true` of if any
94
166
  * children or nested children are horizontal
95
167
  */
96
- export declare function isHorizontal(props: any): any;
168
+ export declare function isHorizontal(props: {
169
+ horizontal?: boolean;
170
+ children?: React.ReactNode;
171
+ }): any;
97
172
  //# sourceMappingURL=helpers.d.ts.map