victory-core 36.6.2 → 36.6.5

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 (228) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/victory-core.js +2053 -4568
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/index.d.ts +0 -1
  5. package/es/index.js +1 -3
  6. package/es/types/callbacks.d.ts +0 -1
  7. package/es/types/callbacks.js +1 -2
  8. package/es/types/prop-types.d.ts +3 -3
  9. package/es/types/prop-types.js +1 -2
  10. package/es/v37/clone.d.ts +23 -0
  11. package/es/v37/clone.js +32 -0
  12. package/es/v37/index.d.ts +5 -0
  13. package/es/v37/index.js +4 -0
  14. package/es/{victory-state → v37/victory-state}/defaults.d.ts +0 -0
  15. package/es/v37/victory-state/defaults.js +2 -0
  16. package/es/v37/victory-state/helpers/get-axis-data.d.ts +3 -0
  17. package/es/{victory-state → v37/victory-state}/helpers/get-axis-data.js +2 -3
  18. package/es/{victory-state → v37/victory-state}/helpers/get-data.d.ts +1 -1
  19. package/es/{victory-state → v37/victory-state}/helpers/get-data.js +2 -3
  20. package/{lib → es/v37}/victory-state/helpers/get-domain.d.ts +1 -1
  21. package/es/{victory-state → v37/victory-state}/helpers/get-domain.js +2 -3
  22. package/{lib → es/v37}/victory-state/helpers/get-range.d.ts +1 -1
  23. package/es/{victory-state → v37/victory-state}/helpers/get-range.js +3 -4
  24. package/{lib → es/v37}/victory-state/helpers/get-scale.d.ts +1 -1
  25. package/es/{victory-state → v37/victory-state}/helpers/get-scale.js +3 -4
  26. package/es/v37/victory-state/index.d.ts +4 -0
  27. package/es/{victory-state → v37/victory-state}/index.js +1 -1
  28. package/{lib → es/v37}/victory-state/types.d.ts +2 -2
  29. package/es/v37/victory-state/types.js +1 -0
  30. package/{lib → es/v37}/victory-state/victory-provider.d.ts +5 -4
  31. package/es/{victory-state → v37/victory-state}/victory-provider.js +59 -29
  32. package/es/v37/victory-state/with-victory-provider.d.ts +7 -0
  33. package/es/v37/victory-state/with-victory-provider.js +43 -0
  34. package/es/{victory-util → v37}/with-container.d.ts +2 -2
  35. package/es/{victory-util → v37}/with-container.js +2 -3
  36. package/es/v37/with-normalized-props.d.ts +17 -0
  37. package/es/v37/with-normalized-props.js +18 -0
  38. package/es/victory-accessible-group/victory-accessible-group.js +1 -2
  39. package/es/victory-animation/util.js +1 -2
  40. package/es/victory-animation/victory-animation.js +1 -2
  41. package/es/victory-clip-container/victory-clip-container.js +1 -2
  42. package/es/victory-container/victory-container.js +1 -2
  43. package/es/victory-label/victory-label.d.ts +5 -4
  44. package/es/victory-label/victory-label.js +1 -2
  45. package/es/victory-portal/portal-context.js +1 -2
  46. package/es/victory-portal/portal.js +1 -2
  47. package/es/victory-portal/victory-portal.js +1 -2
  48. package/es/victory-primitives/arc.js +1 -2
  49. package/es/victory-primitives/background.js +1 -2
  50. package/es/victory-primitives/border.js +1 -2
  51. package/es/victory-primitives/circle.js +1 -2
  52. package/es/victory-primitives/clip-path.js +1 -2
  53. package/es/victory-primitives/index.js +1 -2
  54. package/es/victory-primitives/line-segment.js +1 -2
  55. package/es/victory-primitives/line.js +1 -2
  56. package/es/victory-primitives/path.js +1 -2
  57. package/es/victory-primitives/point.js +1 -2
  58. package/es/victory-primitives/rect.js +1 -2
  59. package/es/victory-primitives/text.js +1 -2
  60. package/es/victory-primitives/tspan.js +1 -2
  61. package/es/victory-primitives/types.js +1 -2
  62. package/es/victory-primitives/whisker.js +1 -2
  63. package/es/victory-theme/grayscale.js +1 -2
  64. package/es/victory-theme/material.js +1 -2
  65. package/es/victory-theme/types.js +1 -2
  66. package/es/victory-theme/victory-theme.js +1 -2
  67. package/es/victory-transition/victory-transition.js +1 -2
  68. package/es/victory-util/add-events.js +1 -2
  69. package/es/victory-util/axis.js +1 -2
  70. package/es/victory-util/collection.js +1 -2
  71. package/es/victory-util/common-props.js +1 -2
  72. package/es/victory-util/data.js +1 -2
  73. package/es/victory-util/default-transitions.js +1 -2
  74. package/es/victory-util/domain.js +1 -2
  75. package/es/victory-util/events.js +1 -2
  76. package/es/victory-util/helpers.d.ts +3 -2
  77. package/es/victory-util/helpers.js +1 -2
  78. package/es/victory-util/hooks/index.js +1 -2
  79. package/es/victory-util/hooks/use-animation-state.js +1 -2
  80. package/es/victory-util/hooks/use-previous-props.js +1 -2
  81. package/es/victory-util/immutable-types.d.ts +2523 -0
  82. package/es/victory-util/immutable.d.ts +1 -1
  83. package/es/victory-util/immutable.js +1 -2
  84. package/es/victory-util/index.d.ts +0 -1
  85. package/es/victory-util/index.js +1 -3
  86. package/es/victory-util/label-helpers.js +1 -2
  87. package/es/victory-util/line-helpers.js +1 -2
  88. package/es/victory-util/log.js +1 -2
  89. package/es/victory-util/point-path-helpers.js +1 -2
  90. package/es/victory-util/prop-types.js +1 -2
  91. package/es/victory-util/scale.js +1 -2
  92. package/es/victory-util/selection.js +1 -2
  93. package/es/victory-util/style.js +1 -2
  94. package/es/victory-util/textsize.js +1 -2
  95. package/es/victory-util/timer-context.js +1 -2
  96. package/es/victory-util/timer.js +1 -2
  97. package/es/victory-util/transitions.js +1 -2
  98. package/es/victory-util/type-helpers.js +1 -2
  99. package/es/victory-util/user-props.js +1 -2
  100. package/es/victory-util/wrapper.js +1 -2
  101. package/lib/index.d.ts +0 -1
  102. package/lib/index.js +1 -16
  103. package/lib/types/callbacks.d.ts +0 -1
  104. package/lib/types/callbacks.js +1 -2
  105. package/lib/types/prop-types.d.ts +3 -3
  106. package/lib/types/prop-types.js +1 -2
  107. package/lib/v37/clone.d.ts +23 -0
  108. package/lib/v37/clone.js +43 -0
  109. package/lib/v37/index.d.ts +5 -0
  110. package/lib/v37/index.js +57 -0
  111. package/lib/{victory-state → v37/victory-state}/defaults.d.ts +0 -0
  112. package/lib/{victory-state → v37/victory-state}/defaults.js +1 -2
  113. package/lib/v37/victory-state/helpers/get-axis-data.d.ts +3 -0
  114. package/lib/{victory-state → v37/victory-state}/helpers/get-axis-data.js +2 -3
  115. package/lib/{victory-state → v37/victory-state}/helpers/get-data.d.ts +1 -1
  116. package/lib/{victory-state → v37/victory-state}/helpers/get-data.js +2 -3
  117. package/{es → lib/v37}/victory-state/helpers/get-domain.d.ts +1 -1
  118. package/lib/{victory-state → v37/victory-state}/helpers/get-domain.js +2 -3
  119. package/{es → lib/v37}/victory-state/helpers/get-range.d.ts +1 -1
  120. package/lib/{victory-state → v37/victory-state}/helpers/get-range.js +3 -4
  121. package/{es → lib/v37}/victory-state/helpers/get-scale.d.ts +1 -1
  122. package/lib/{victory-state → v37/victory-state}/helpers/get-scale.js +3 -4
  123. package/lib/v37/victory-state/index.d.ts +4 -0
  124. package/lib/{victory-state → v37/victory-state}/index.js +13 -1
  125. package/{es → lib/v37}/victory-state/types.d.ts +2 -2
  126. package/lib/v37/victory-state/types.js +1 -0
  127. package/{es → lib/v37}/victory-state/victory-provider.d.ts +5 -4
  128. package/lib/{victory-state → v37/victory-state}/victory-provider.js +61 -30
  129. package/lib/v37/victory-state/with-victory-provider.d.ts +7 -0
  130. package/lib/v37/victory-state/with-victory-provider.js +56 -0
  131. package/lib/{victory-util → v37}/with-container.d.ts +2 -2
  132. package/lib/{victory-util → v37}/with-container.js +2 -3
  133. package/lib/v37/with-normalized-props.d.ts +17 -0
  134. package/lib/v37/with-normalized-props.js +29 -0
  135. package/lib/victory-accessible-group/victory-accessible-group.js +1 -2
  136. package/lib/victory-animation/util.js +1 -2
  137. package/lib/victory-animation/victory-animation.js +1 -2
  138. package/lib/victory-clip-container/victory-clip-container.js +1 -2
  139. package/lib/victory-container/victory-container.js +1 -2
  140. package/lib/victory-label/victory-label.d.ts +5 -4
  141. package/lib/victory-label/victory-label.js +1 -2
  142. package/lib/victory-portal/portal-context.js +1 -2
  143. package/lib/victory-portal/portal.js +1 -2
  144. package/lib/victory-portal/victory-portal.js +1 -2
  145. package/lib/victory-primitives/arc.js +1 -2
  146. package/lib/victory-primitives/background.js +1 -2
  147. package/lib/victory-primitives/border.js +1 -2
  148. package/lib/victory-primitives/circle.js +1 -2
  149. package/lib/victory-primitives/clip-path.js +1 -2
  150. package/lib/victory-primitives/index.js +1 -2
  151. package/lib/victory-primitives/line-segment.js +1 -2
  152. package/lib/victory-primitives/line.js +1 -2
  153. package/lib/victory-primitives/path.js +1 -2
  154. package/lib/victory-primitives/point.js +1 -2
  155. package/lib/victory-primitives/rect.js +1 -2
  156. package/lib/victory-primitives/text.js +1 -2
  157. package/lib/victory-primitives/tspan.js +1 -2
  158. package/lib/victory-primitives/types.js +1 -2
  159. package/lib/victory-primitives/whisker.js +1 -2
  160. package/lib/victory-theme/grayscale.js +1 -2
  161. package/lib/victory-theme/material.js +1 -2
  162. package/lib/victory-theme/types.js +1 -2
  163. package/lib/victory-theme/victory-theme.js +1 -2
  164. package/lib/victory-transition/victory-transition.js +1 -2
  165. package/lib/victory-util/add-events.js +1 -2
  166. package/lib/victory-util/axis.js +1 -2
  167. package/lib/victory-util/collection.js +1 -2
  168. package/lib/victory-util/common-props.js +1 -2
  169. package/lib/victory-util/data.js +1 -2
  170. package/lib/victory-util/default-transitions.js +1 -2
  171. package/lib/victory-util/domain.js +1 -2
  172. package/lib/victory-util/events.js +1 -2
  173. package/lib/victory-util/helpers.d.ts +3 -2
  174. package/lib/victory-util/helpers.js +1 -2
  175. package/lib/victory-util/hooks/index.js +1 -2
  176. package/lib/victory-util/hooks/use-animation-state.js +1 -2
  177. package/lib/victory-util/hooks/use-previous-props.js +1 -2
  178. package/lib/victory-util/immutable-types.d.ts +2523 -0
  179. package/lib/victory-util/immutable.d.ts +1 -1
  180. package/lib/victory-util/immutable.js +1 -2
  181. package/lib/victory-util/index.d.ts +0 -1
  182. package/lib/victory-util/index.js +1 -16
  183. package/lib/victory-util/label-helpers.js +1 -2
  184. package/lib/victory-util/line-helpers.js +1 -2
  185. package/lib/victory-util/log.js +1 -2
  186. package/lib/victory-util/point-path-helpers.js +1 -2
  187. package/lib/victory-util/prop-types.js +1 -2
  188. package/lib/victory-util/scale.js +1 -2
  189. package/lib/victory-util/selection.js +1 -2
  190. package/lib/victory-util/style.js +1 -2
  191. package/lib/victory-util/textsize.js +1 -2
  192. package/lib/victory-util/timer-context.js +1 -2
  193. package/lib/victory-util/timer.js +1 -2
  194. package/lib/victory-util/transitions.js +1 -2
  195. package/lib/victory-util/type-helpers.js +1 -2
  196. package/lib/victory-util/user-props.js +1 -2
  197. package/lib/victory-util/wrapper.js +1 -2
  198. package/package.json +12 -4
  199. package/src/index.ts +0 -1
  200. package/src/types/callbacks.ts +0 -2
  201. package/src/types/prop-types.ts +4 -3
  202. package/src/v37/clone.tsx +30 -0
  203. package/src/v37/index.tsx +4 -0
  204. package/src/{victory-state → v37/victory-state}/defaults.ts +0 -0
  205. package/src/{victory-state → v37/victory-state}/helpers/get-axis-data.ts +2 -2
  206. package/src/{victory-state → v37/victory-state}/helpers/get-data.ts +3 -3
  207. package/src/{victory-state → v37/victory-state}/helpers/get-domain.ts +2 -2
  208. package/src/{victory-state → v37/victory-state}/helpers/get-range.ts +3 -3
  209. package/src/{victory-state → v37/victory-state}/helpers/get-scale.ts +6 -3
  210. package/src/{victory-state → v37/victory-state}/index.ts +1 -0
  211. package/src/{victory-state → v37/victory-state}/types.ts +2 -2
  212. package/src/{victory-state → v37/victory-state}/victory-provider.tsx +61 -27
  213. package/src/v37/victory-state/with-victory-provider.tsx +53 -0
  214. package/src/{victory-util → v37}/with-container.tsx +2 -2
  215. package/src/v37/with-normalized-props.tsx +43 -0
  216. package/src/victory-label/victory-label.tsx +4 -4
  217. package/src/victory-util/data.ts +1 -1
  218. package/src/victory-util/helpers.ts +3 -2
  219. package/src/victory-util/immutable-types.d.ts +2523 -0
  220. package/src/victory-util/immutable.ts +1 -1
  221. package/src/victory-util/index.ts +0 -1
  222. package/es/victory-state/defaults.js +0 -3
  223. package/es/victory-state/helpers/get-axis-data.d.ts +0 -3
  224. package/es/victory-state/index.d.ts +0 -3
  225. package/es/victory-state/types.js +0 -2
  226. package/lib/victory-state/helpers/get-axis-data.d.ts +0 -3
  227. package/lib/victory-state/index.d.ts +0 -3
  228. package/lib/victory-state/types.js +0 -2
package/es/index.d.ts CHANGED
@@ -15,5 +15,4 @@ export * from "./victory-primitives";
15
15
  export { Border as Box } from "./victory-primitives";
16
16
  export type { BorderProps as BoxProps } from "./victory-primitives";
17
17
  export * from "./victory-util";
18
- export * from "./victory-state";
19
18
  //# sourceMappingURL=index.d.ts.map
package/es/index.js CHANGED
@@ -13,6 +13,4 @@ export * from "./victory-portal/portal-context";
13
13
  export * from "./victory-portal/victory-portal";
14
14
  export * from "./victory-primitives";
15
15
  export { Border as Box } from "./victory-primitives";
16
- export * from "./victory-util";
17
- export * from "./victory-state";
18
- //# sourceMappingURL=index.js.map
16
+ export * from "./victory-util";
@@ -34,5 +34,4 @@ export declare type VictoryOrientationCallback = (args: CallbackArgs) => Orienta
34
34
  export declare type NumberOrCallback = number | VictoryNumberCallback;
35
35
  export declare type PaddingOrCallback = number | BlockProps | VictoryPaddingCallback;
36
36
  export declare type OrientationOrCallback = OrientationTypes | VictoryOrientationCallback;
37
- export declare type ValueOrCallback<TValue> = TValue | ((args: CallbackArgs) => TValue);
38
37
  //# sourceMappingURL=callbacks.d.ts.map
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=callbacks.js.map
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { ScaleLinear, ScaleLogarithmic, ScalePower, ScaleTime } from "victory-vendor/d3-scale";
3
3
  import { AnimationEasing, AnimationStyle } from "../victory-animation/victory-animation";
4
- import { StringOrNumberOrCallback } from "./callbacks";
4
+ import { CallbackArgs, StringOrNumberOrCallback } from "./callbacks";
5
5
  export declare type AxisType = "x" | "y";
6
6
  export declare type DatumValue = number | string | Date | null | undefined;
7
7
  export declare type Datum = any;
@@ -10,7 +10,7 @@ export declare type ForAxes<T> = T | {
10
10
  y?: T;
11
11
  };
12
12
  export declare type ID = number | string;
13
- export declare type ValueOrAccessor<ValueType = unknown, PropsType = object> = ValueType | ((props: PropsType) => ValueType);
13
+ export declare type ValueOrAccessor<ValueType, PropsType = CallbackArgs> = ValueType | ((props: PropsType) => ValueType);
14
14
  export declare type Tuple<T> = [T, T];
15
15
  export declare type ValueOrAxes<T> = T | ForAxes<T>;
16
16
  export declare type DomainPaddingPropType = ValueOrAxes<PaddingType>;
@@ -105,7 +105,7 @@ export declare type CategoryPropType = string[] | {
105
105
  x: string[];
106
106
  y: string[];
107
107
  };
108
- export declare type DataGetterPropType = ValueOrAccessor<string | string[] | number | number[]>;
108
+ export declare type DataGetterPropType = ValueOrAccessor<string | string[] | number | number[], any>;
109
109
  export declare type InterpolationPropType = "basis" | "basisClosed" | "basisOpen" | "bundle" | "cardinal" | "cardinalClosed" | "cardinalOpen" | "catmullRom" | "catmullRomClosed" | "catmullRomOpen" | "linear" | "linearClosed" | "monotoneX" | "monotoneY" | "natural" | "radial" | "step" | "stepAfter" | "stepBefore";
110
110
  export declare type ColorScalePropType = "grayscale" | "qualitative" | "heatmap" | "warm" | "cool" | "red" | "green" | "blue" | string[];
111
111
  export declare type SortOrderPropType = "ascending" | "descending";
@@ -1,2 +1 @@
1
- export {};
2
- //# sourceMappingURL=prop-types.js.map
1
+ export {};
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ /**
3
+ * Syntax sugar for `React.cloneElement`, so that we can use JSX instead
4
+ *
5
+ * @example
6
+ * // Before:
7
+ * const children = React.cloneElement(props.groupComponent, { prop2 }, props.children);
8
+ * return React.cloneElement(props.containerComponent, { prop1 }, children);
9
+ *
10
+ * // After:
11
+ * return (
12
+ * <Clone element={props.containerComponent} prop1={prop1}>
13
+ * <Clone element={props.groupComponent} prop2={prop2}>
14
+ * {props.children}
15
+ * </Clone>
16
+ * </Clone>
17
+ * );
18
+ */
19
+ export declare const Clone: <TProps>(props: React.PropsWithChildren<{
20
+ element: React.ReactElement<TProps, string | React.JSXElementConstructor<any>>;
21
+ children?: React.ReactNode | React.ReactNode[];
22
+ } & TProps>) => React.ReactElement<TProps, string | React.JSXElementConstructor<any>>;
23
+ //# sourceMappingURL=clone.d.ts.map
@@ -0,0 +1,32 @@
1
+ var _excluded = ["children", "element"];
2
+
3
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
+
5
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
+
7
+ import React from "react";
8
+ /**
9
+ * Syntax sugar for `React.cloneElement`, so that we can use JSX instead
10
+ *
11
+ * @example
12
+ * // Before:
13
+ * const children = React.cloneElement(props.groupComponent, { prop2 }, props.children);
14
+ * return React.cloneElement(props.containerComponent, { prop1 }, children);
15
+ *
16
+ * // After:
17
+ * return (
18
+ * <Clone element={props.containerComponent} prop1={prop1}>
19
+ * <Clone element={props.groupComponent} prop2={prop2}>
20
+ * {props.children}
21
+ * </Clone>
22
+ * </Clone>
23
+ * );
24
+ */
25
+
26
+ export var Clone = function (props) {
27
+ var children = props.children,
28
+ element = props.element,
29
+ rest = _objectWithoutProperties(props, _excluded);
30
+
31
+ return /*#__PURE__*/React.cloneElement(element, rest, children);
32
+ };
@@ -0,0 +1,5 @@
1
+ export * from "./victory-state";
2
+ export * from "./clone";
3
+ export * from "./with-normalized-props";
4
+ export * from "./with-container";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export * from "./victory-state";
2
+ export * from "./clone";
3
+ export * from "./with-normalized-props";
4
+ export * from "./with-container";
@@ -0,0 +1,2 @@
1
+ export var DEFAULT_HEIGHT = 300;
2
+ export var DEFAULT_WIDTH = 450;
@@ -0,0 +1,3 @@
1
+ import { AxisType, Datum } from "../../../types/prop-types";
2
+ export declare function getAxisData(data: Datum[], axis: AxisType): any;
3
+ //# sourceMappingURL=get-axis-data.d.ts.map
@@ -1,4 +1,4 @@
1
- import { isKeyValueObject } from "../../victory-util/type-helpers";
1
+ import { isKeyValueObject } from "../../../victory-util/type-helpers";
2
2
  export function getAxisData(data, axis) {
3
3
  return data.reduce(function (acc, datum) {
4
4
  if (isKeyValueObject(datum)) {
@@ -11,5 +11,4 @@ export function getAxisData(data, axis) {
11
11
 
12
12
  return acc;
13
13
  }, []);
14
- }
15
- //# sourceMappingURL=get-axis-data.js.map
14
+ }
@@ -1,4 +1,4 @@
1
- import { DatumValue } from "../../types/prop-types";
1
+ import { DatumValue } from "../../../types/prop-types";
2
2
  import { VictoryProviderProps } from "../types";
3
3
  declare type DataProps = Pick<VictoryProviderProps, "data" | "x" | "y" | "sortKey" | "sortOrder" | "samples">;
4
4
  export interface FormattedDatum {
@@ -20,7 +20,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
20
20
 
21
21
  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; }
22
22
 
23
- import { isKeyValueObject } from "../../victory-util/type-helpers";
23
+ import { isKeyValueObject } from "../../../victory-util/type-helpers";
24
24
 
25
25
  function getValue(datum, key) {
26
26
  if (typeof datum === "object") {
@@ -84,5 +84,4 @@ export function getData() {
84
84
  }
85
85
 
86
86
  return formattedData;
87
- }
88
- //# sourceMappingURL=get-data.js.map
87
+ }
@@ -1,5 +1,5 @@
1
1
  import { VictoryProviderProps } from "../types";
2
- import { AxisType, DomainTuple } from "../../types/prop-types";
2
+ import { AxisType, DomainTuple } from "../../../types/prop-types";
3
3
  declare type DomainProps = Pick<VictoryProviderProps, "data" | "domain" | "maxDomain" | "minDomain" | "includeZero">;
4
4
  export declare function getDomain({ data, includeZero, ...props }: DomainProps, axis: AxisType): DomainTuple;
5
5
  export {};
@@ -18,7 +18,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
18
18
 
19
19
  import * as d3Array from "victory-vendor/d3-array";
20
20
  import { getAxisData } from "./get-axis-data";
21
- import { getValueForAxis, isDate, isTuple } from "../../victory-util/type-helpers";
21
+ import { getValueForAxis, isDate, isTuple } from "../../../victory-util/type-helpers";
22
22
  // TODO: What should this default value be?
23
23
  var DEFAULT_MIN = 0;
24
24
  var DEFAULT_MAX = 1;
@@ -64,5 +64,4 @@ export function getDomain(_ref, axis) {
64
64
 
65
65
 
66
66
  return getDomainFromMinMax(minDomain, maxDomain);
67
- }
68
- //# sourceMappingURL=get-domain.js.map
67
+ }
@@ -1,4 +1,4 @@
1
- import { AxisType } from "../../types/prop-types";
1
+ import { AxisType } from "../../../types/prop-types";
2
2
  import { VictoryProviderProps } from "../types";
3
3
  declare type RangeProps = Pick<VictoryProviderProps, "range" | "padding" | "height" | "width">;
4
4
  export declare function getRange({ range, height, width, ...props }: RangeProps, axis: AxisType): number[];
@@ -4,8 +4,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
4
4
 
5
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
6
 
7
- import { getPadding } from "../../victory-util/helpers";
8
- import { getValueForAxis, isTuple } from "../../victory-util/type-helpers";
7
+ import { getPadding } from "../../../victory-util/helpers";
8
+ import { getValueForAxis, isTuple } from "../../../victory-util/type-helpers";
9
9
  // TODO: Should we store these defaults somewhere?
10
10
  var DEFAULT_HEIGHT = 300;
11
11
  var DEFAULT_WIDTH = 450; // TODO: This does not include polar range
@@ -33,5 +33,4 @@ export function getRange(_ref, axis) {
33
33
  y: [height - padding.top, padding.bottom]
34
34
  };
35
35
  return rangeForAxis[axis];
36
- }
37
- //# sourceMappingURL=get-range.js.map
36
+ }
@@ -1,4 +1,4 @@
1
- import { AxisType, D3ScaleFn } from "../../types/prop-types";
1
+ import { AxisType, D3ScaleFn } from "../../../types/prop-types";
2
2
  import { VictoryProviderProps } from "../types";
3
3
  declare type ScaleProps = Pick<VictoryProviderProps, "data" | "scale">;
4
4
  export declare function getScale({ data, ...props }: ScaleProps, axis: AxisType): D3ScaleFn;
@@ -5,8 +5,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
5
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
6
 
7
7
  import { scaleLinear, scaleTime, scaleLog, scaleSqrt } from "victory-vendor/d3-scale";
8
- import * as Collection from "../../victory-util/collection";
9
- import { getValueForAxis, isFunction } from "../../victory-util/type-helpers";
8
+ import * as Collection from "../../../victory-util/collection";
9
+ import { getValueForAxis, isFunction } from "../../../victory-util/type-helpers";
10
10
  import { getAxisData } from "./get-axis-data";
11
11
  var DEFAULT_SCALE = scaleLinear;
12
12
 
@@ -55,5 +55,4 @@ export function getScale(_ref, axis) {
55
55
  }
56
56
 
57
57
  return DEFAULT_SCALE;
58
- }
59
- //# sourceMappingURL=get-scale.js.map
58
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./victory-provider";
2
+ export * from "./types";
3
+ export * from "./with-victory-provider";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,3 @@
1
1
  export * from "./victory-provider";
2
2
  export * from "./types";
3
- //# sourceMappingURL=index.js.map
3
+ export * from "./with-victory-provider";
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { D3ScaleFn, Datum, DomainTuple, RangeTuple, ScalePropType, ValueOrAxes } from "../types/prop-types";
3
- import { PaddingProps } from "../victory-theme/types";
2
+ import { D3ScaleFn, Datum, DomainTuple, RangeTuple, ScalePropType, ValueOrAxes } from "../../types/prop-types";
3
+ import { PaddingProps } from "../../victory-theme/types";
4
4
  export interface VictoryCalculatedStateProps {
5
5
  data?: Datum[];
6
6
  domain?: ValueOrAxes<DomainTuple>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { D3ScaleFn, DomainTuple, ForAxes } from "../types/prop-types";
2
+ import { D3ScaleFn, DomainTuple, ForAxes } from "../../types/prop-types";
3
3
  import { FormattedDatum } from "./helpers/get-data";
4
4
  import { VictoryCalculatedStateProps, VictoryProviderProps } from "./types";
5
5
  declare type ScaleType = Required<ForAxes<D3ScaleFn>>;
@@ -8,13 +8,14 @@ export interface ContextType {
8
8
  data: FormattedDatum[];
9
9
  scale: ScaleType;
10
10
  domain: DomainType;
11
- setChildProps: (id: string, props: VictoryProviderProps) => void;
11
+ updateChildProps: (id: symbol, props: VictoryProviderProps | null) => void;
12
12
  }
13
- export declare function VictoryProvider({ children, ...initialProps }: VictoryProviderProps): JSX.Element;
13
+ export declare function VictoryProvider({ children, ...providerProps }: VictoryProviderProps): JSX.Element;
14
+ export declare function useVictoryContextMaybe<T>(selector: (value: ContextType | null) => T): T;
14
15
  export declare function useVictoryContext<T>(selector: (value: ContextType) => T): T;
15
16
  export declare function useScale(): ScaleType;
16
17
  export declare function useData(): FormattedDatum[];
17
18
  export declare function useDomain(): DomainType;
18
- export declare function useVictoryProviderSync(id: string, props: VictoryCalculatedStateProps): VictoryCalculatedStateProps;
19
+ export declare function useVictoryProviderSync(props: VictoryCalculatedStateProps): void;
19
20
  export {};
20
21
  //# sourceMappingURL=victory-provider.d.ts.map
@@ -1,5 +1,9 @@
1
1
  var _excluded = ["children"];
2
2
 
3
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
+
5
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
+
3
7
  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; }
4
8
 
5
9
  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; }
@@ -18,10 +22,6 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
18
22
 
19
23
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
24
 
21
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
22
-
23
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
24
-
25
25
  import * as React from "react";
26
26
  import { createContext, useContext } from "react";
27
27
  import { getData } from "./helpers/get-data";
@@ -29,21 +29,31 @@ import { getDomain } from "./helpers/get-domain";
29
29
  import { getRange } from "./helpers/get-range";
30
30
  import { getScale } from "./helpers/get-scale";
31
31
  var VictoryContext = /*#__PURE__*/createContext(null);
32
- export function VictoryProvider(_ref) {
33
- var children = _ref.children,
34
- initialProps = _objectWithoutProperties(_ref, _excluded);
35
32
 
36
- // We need to store the props in state so they can be overwritten by child components
37
- var _React$useState = React.useState(initialProps),
33
+ function useNormalizedProps() {
34
+ var _React$useState = React.useState({}),
38
35
  _React$useState2 = _slicedToArray(_React$useState, 2),
39
- props = _React$useState2[0],
40
- setProps = _React$useState2[1];
36
+ collectedProps = _React$useState2[0],
37
+ setCollectedProps = _React$useState2[1];
38
+
39
+ var updateChildProps = React.useCallback(function (id, newProps) {
40
+ setCollectedProps(function (prev) {
41
+ var result = _objectSpread({}, prev);
41
42
 
42
- var setChildProps = React.useCallback(function (id, newProps) {
43
- setProps(function (prevProps) {
44
- return _objectSpread(_objectSpread({}, prevProps), newProps);
43
+ if (newProps === null) {
44
+ delete result[id];
45
+ } else {
46
+ result[id] = newProps;
47
+ }
48
+
49
+ return result;
45
50
  });
46
- }, []);
51
+ }, []); // TEMP: combine all props into a single result:
52
+ // TODO: instead, we should intelligently aggregate all these props
53
+
54
+ var props = Object.values(collectedProps).reduce(function (result, childProps) {
55
+ return Object.assign(result, childProps);
56
+ }, {});
47
57
  var data = React.useMemo(function () {
48
58
  return getData(props);
49
59
  }, [props]);
@@ -71,16 +81,31 @@ export function VictoryProvider(_ref) {
71
81
  y: yScaleFn
72
82
  };
73
83
  }, [props, domain, range]);
74
- var value = {
75
- scale: scale,
76
- data: data,
77
- domain: domain,
78
- setChildProps: setChildProps
79
- };
84
+ var normalizedProps = React.useMemo(function () {
85
+ return {
86
+ scale: scale,
87
+ data: data,
88
+ domain: domain,
89
+ updateChildProps: updateChildProps
90
+ };
91
+ }, [scale, data, domain, updateChildProps]);
92
+ return normalizedProps;
93
+ }
94
+
95
+ export function VictoryProvider(_ref) {
96
+ var children = _ref.children,
97
+ providerProps = _objectWithoutProperties(_ref, _excluded);
98
+
99
+ var value = useNormalizedProps(); // TODO: sync the providerProps
100
+
80
101
  return /*#__PURE__*/React.createElement(VictoryContext.Provider, {
81
102
  value: value
82
103
  }, children);
83
104
  }
105
+ export function useVictoryContextMaybe(selector) {
106
+ var context = useContext(VictoryContext);
107
+ return selector(context);
108
+ }
84
109
  export function useVictoryContext(selector) {
85
110
  var context = useContext(VictoryContext);
86
111
 
@@ -106,13 +131,18 @@ export function useDomain() {
106
131
  });
107
132
  } // This function keeps props in sync betwen the VictoryProvider and child components
108
133
 
109
- export function useVictoryProviderSync(id, props) {
110
- var setChildProps = useVictoryContext(function (value) {
111
- return value.setChildProps;
134
+ export function useVictoryProviderSync(props) {
135
+ var updateChildProps = useVictoryContext(function (value) {
136
+ return value.updateChildProps;
112
137
  });
138
+
139
+ var _React$useState3 = React.useState(function () {
140
+ return Symbol("UniqueIdFor(VictoryProviderChild)");
141
+ }),
142
+ _React$useState4 = _slicedToArray(_React$useState3, 1),
143
+ myId = _React$useState4[0];
144
+
113
145
  React.useEffect(function () {
114
- setChildProps(id, props);
115
- }, []);
116
- return props;
117
- }
118
- //# sourceMappingURL=victory-provider.js.map
146
+ updateChildProps(myId, props);
147
+ }, [updateChildProps, props]);
148
+ }
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import { VictoryCommonProps } from "../../victory-util/common-props";
3
+ /**
4
+ * Ensures the component is wrapped by a VictoryProvider, if not already.
5
+ */
6
+ export declare function withVictoryProvider<TComp extends React.FC<TProps>, TProps extends React.PropsWithChildren<VictoryCommonProps>>(Comp: TComp): TComp;
7
+ //# sourceMappingURL=with-victory-provider.d.ts.map
@@ -0,0 +1,43 @@
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); }
2
+
3
+ import * as React from "react";
4
+ import { useVictoryContextMaybe, VictoryProvider } from "./victory-provider";
5
+ import { Clone } from "../clone";
6
+
7
+ /* eslint-disable react/prop-types */
8
+
9
+ /**
10
+ * Ensures the component is wrapped by a VictoryProvider, if not already.
11
+ */
12
+ export function withVictoryProvider(Comp) {
13
+ var WithVictoryProvider = /*#__PURE__*/React.memo(function (props) {
14
+ var updateChildProps = useVictoryContextMaybe(function (value) {
15
+ return value === null || value === void 0 ? void 0 : value.updateChildProps;
16
+ });
17
+ var hasParentProvider = !!updateChildProps;
18
+ React.useEffect(function () {
19
+ if (!hasParentProvider) return;
20
+ var id = Symbol("WithVictoryProvider");
21
+ updateChildProps(id, props); // eslint-disable-next-line consistent-return
22
+
23
+ return function () {
24
+ return updateChildProps(id, null);
25
+ };
26
+ }); // @ts-expect-error "TProps not assignable to LibraryManagedAttributes"
27
+
28
+ var result = /*#__PURE__*/React.createElement(Comp, props, props.children);
29
+
30
+ if (!hasParentProvider) {
31
+ // Wrap with a parent Provider:
32
+ result = /*#__PURE__*/React.createElement(VictoryProvider, null, /*#__PURE__*/React.createElement(Clone, _extends({
33
+ element: props.containerComponent
34
+ }, props), result));
35
+ }
36
+
37
+ return result;
38
+ });
39
+ var name = Comp.displayName || Comp.name;
40
+ WithVictoryProvider.displayName = name ? "WithVictoryProvider(".concat(name, ")") : "WithVictoryProvider"; // @ts-expect-error "WithVictoryProvider does not overlap with TComp"
41
+
42
+ return WithVictoryProvider;
43
+ }
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { VictoryProviderProps } from "../victory-state";
3
- import { VictoryCommonProps } from "./common-props";
2
+ import { VictoryProviderProps } from "./victory-state";
3
+ import { VictoryCommonProps } from "../victory-util/common-props";
4
4
  export declare function withContainer<Props extends VictoryCommonProps>(WrappedComponent: React.FC<Props>, initialProviderProps?: Partial<VictoryProviderProps>): React.FC<Props>;
5
5
  //# sourceMappingURL=with-container.d.ts.map
@@ -5,7 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
5
5
  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; }
6
6
 
7
7
  import React from "react";
8
- import { VictoryProvider } from "../victory-state";
8
+ import { VictoryProvider } from "./victory-state";
9
9
  import { VictoryContainer } from "../victory-container/victory-container";
10
10
  var defaultProviderProps = {
11
11
  width: 450,
@@ -29,5 +29,4 @@ export function withContainer(WrappedComponent) {
29
29
 
30
30
  return /*#__PURE__*/React.createElement(WrappedComponent, props);
31
31
  };
32
- }
33
- //# sourceMappingURL=with-container.js.map
32
+ }
@@ -0,0 +1,17 @@
1
+ import { VictoryCommonProps } from "../victory-util/common-props";
2
+ import React from "react";
3
+ import { VictoryProviderProps } from "./victory-state";
4
+ declare type FC<TProps> = (props: TProps) => JSX.Element;
5
+ export declare function withNormalizedProps<TProps extends React.PropsWithChildren<VictoryCommonProps>, TDefaultPropKeys extends keyof TProps>(config: {
6
+ displayName: string;
7
+ propTypes?: React.WeakValidationMap<Omit<TProps, keyof VictoryCommonProps>>;
8
+ defaultProps: Pick<TProps, TDefaultPropKeys>;
9
+ /** @deprecated */
10
+ initialProviderProps?: Partial<VictoryProviderProps>;
11
+ }, WrappedComponent: React.FC<TProps>): FC<TProps> & {
12
+ displayName: string;
13
+ defaultProps: Pick<TProps, TDefaultPropKeys>;
14
+ propTypes: React.WeakValidationMap<Omit<TProps, keyof VictoryCommonProps>> | undefined;
15
+ };
16
+ export {};
17
+ //# sourceMappingURL=with-normalized-props.d.ts.map
@@ -0,0 +1,18 @@
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); }
2
+
3
+ import React from "react";
4
+ import { useVictoryContext, withVictoryProvider } from "./victory-state";
5
+ export function withNormalizedProps(config, WrappedComponent) {
6
+ WrappedComponent.displayName = config.displayName;
7
+ var WithNormalizedProps = withVictoryProvider(function (props) {
8
+ var normalizedProps = useVictoryContext(function (v) {
9
+ return v;
10
+ });
11
+ return /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, normalizedProps), props.children);
12
+ });
13
+ return Object.assign(WithNormalizedProps, {
14
+ displayName: "WithNormalizedProps(".concat(config.displayName),
15
+ defaultProps: config.defaultProps,
16
+ propTypes: config.propTypes
17
+ });
18
+ }
@@ -69,5 +69,4 @@ VictoryAccessibleGroup.propTypes = {
69
69
  };
70
70
  VictoryAccessibleGroup.defaultProps = {
71
71
  className: "VictoryAccessibleGroup"
72
- };
73
- //# sourceMappingURL=victory-accessible-group.js.map
72
+ };
@@ -210,5 +210,4 @@ export var victoryInterpolator = function (a, b) {
210
210
 
211
211
 
212
212
  return interpolate(a, b);
213
- };
214
- //# sourceMappingURL=util.js.map
213
+ };
@@ -236,5 +236,4 @@ VictoryAnimation.defaultProps = {
236
236
  duration: 1000,
237
237
  easing: "quadInOut"
238
238
  };
239
- VictoryAnimation.contextType = TimerContext;
240
- //# sourceMappingURL=victory-animation.js.map
239
+ VictoryAnimation.contextType = TimerContext;
@@ -275,5 +275,4 @@ VictoryClipContainer.defaultProps = {
275
275
  rectComponent: /*#__PURE__*/React.createElement(Rect, null),
276
276
  clipPathComponent: /*#__PURE__*/React.createElement(ClipPath, null),
277
277
  groupComponent: /*#__PURE__*/React.createElement("g", null)
278
- };
279
- //# sourceMappingURL=victory-clip-container.js.map
278
+ };
@@ -276,5 +276,4 @@ VictoryContainer.defaultProps = {
276
276
  responsive: true,
277
277
  role: "img"
278
278
  };
279
- VictoryContainer.contextType = TimerContext;
280
- //# sourceMappingURL=victory-container.js.map
279
+ VictoryContainer.contextType = TimerContext;
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
- import { NumberOrCallback, StringOrCallback, StringOrNumberOrCallback, ValueOrCallback } from "../types/callbacks";
2
+ import { NumberOrCallback, StringOrCallback, StringOrNumberOrCallback } from "../types/callbacks";
3
+ import { ValueOrAccessor } from "../types/prop-types";
3
4
  import { PaddingProps, VerticalAnchorType, VictoryLabelStyleObject } from "../victory-theme/victory-theme";
4
5
  export declare type TextAnchorType = "start" | "middle" | "end" | "inherit";
5
6
  export declare type OriginType = {
@@ -34,11 +35,11 @@ export interface VictoryLabelProps {
34
35
  tabIndex?: NumberOrCallback;
35
36
  text?: string[] | StringOrNumberOrCallback;
36
37
  textComponent?: React.ReactElement;
37
- textAnchor?: ValueOrCallback<TextAnchorType>;
38
+ textAnchor?: ValueOrAccessor<TextAnchorType>;
38
39
  title?: string;
39
- transform?: ValueOrCallback<string | object>;
40
+ transform?: ValueOrAccessor<string | object>;
40
41
  tspanComponent?: React.ReactElement;
41
- verticalAnchor?: ValueOrCallback<VerticalAnchorType>;
42
+ verticalAnchor?: ValueOrAccessor<VerticalAnchorType>;
42
43
  x?: number;
43
44
  y?: number;
44
45
  dx?: StringOrNumberOrCallback;
@@ -603,5 +603,4 @@ VictoryLabel.defaultProps = {
603
603
  capHeight: 0.71,
604
604
  // Magic number from d3.
605
605
  lineHeight: 1
606
- };
607
- //# sourceMappingURL=victory-label.js.map
606
+ };