victory-core 36.4.1 → 36.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/dist/victory-core.js +874 -879
  2. package/dist/victory-core.min.js +1 -1
  3. package/es/index.d.ts +38 -941
  4. package/es/index.js +19 -28
  5. package/es/types.d.ts +33 -0
  6. package/es/types.js +1 -0
  7. package/es/victory-accessible-group/victory-accessible-group.d.ts +25 -0
  8. package/es/victory-accessible-group/victory-accessible-group.js +8 -16
  9. package/es/victory-animation/util.d.ts +66 -0
  10. package/es/victory-animation/util.js +2 -1
  11. package/es/victory-animation/victory-animation.d.ts +69 -0
  12. package/es/victory-animation/victory-animation.js +59 -67
  13. package/es/victory-clip-container/victory-clip-container.d.ts +76 -0
  14. package/es/victory-clip-container/victory-clip-container.js +15 -21
  15. package/es/victory-container/victory-container.d.ts +99 -0
  16. package/es/victory-container/victory-container.js +31 -31
  17. package/es/victory-label/victory-label.d.ts +61 -0
  18. package/es/victory-label/victory-label.js +13 -8
  19. package/es/victory-portal/portal-context.d.ts +11 -0
  20. package/es/victory-portal/portal-context.js +3 -4
  21. package/es/victory-portal/portal.d.ts +28 -0
  22. package/es/victory-portal/portal.js +25 -33
  23. package/es/victory-portal/victory-portal.d.ts +31 -0
  24. package/es/victory-portal/victory-portal.js +23 -22
  25. package/es/victory-primitives/arc.d.ts +21 -0
  26. package/es/victory-primitives/arc.js +3 -5
  27. package/es/victory-primitives/background.d.ts +22 -0
  28. package/es/victory-primitives/background.js +4 -6
  29. package/es/victory-primitives/border.d.ts +18 -0
  30. package/es/victory-primitives/border.js +3 -5
  31. package/es/victory-primitives/circle.d.ts +2 -0
  32. package/es/victory-primitives/circle.js +11 -8
  33. package/es/victory-primitives/clip-path.d.ts +14 -0
  34. package/es/victory-primitives/clip-path.js +6 -6
  35. package/es/victory-primitives/index.d.ts +14 -0
  36. package/es/victory-primitives/index.js +14 -0
  37. package/es/victory-primitives/line-segment.d.ts +19 -0
  38. package/es/victory-primitives/line-segment.js +3 -5
  39. package/es/victory-primitives/line.d.ts +2 -0
  40. package/es/victory-primitives/line.js +11 -8
  41. package/es/victory-primitives/path.d.ts +2 -0
  42. package/es/victory-primitives/path.js +9 -6
  43. package/es/victory-primitives/point.d.ts +21 -0
  44. package/es/victory-primitives/point.js +9 -19
  45. package/es/victory-primitives/rect.d.ts +2 -0
  46. package/es/victory-primitives/rect.js +11 -8
  47. package/es/victory-primitives/text.d.ts +16 -0
  48. package/es/victory-primitives/text.js +7 -6
  49. package/es/victory-primitives/tspan.d.ts +2 -0
  50. package/es/victory-primitives/tspan.js +7 -6
  51. package/es/victory-primitives/types.d.ts +7 -0
  52. package/es/victory-primitives/types.js +1 -0
  53. package/es/victory-primitives/whisker.d.ts +24 -0
  54. package/es/victory-primitives/whisker.js +3 -5
  55. package/es/victory-theme/grayscale.d.ts +2 -0
  56. package/es/victory-theme/grayscale.js +1 -1
  57. package/es/victory-theme/material.d.ts +2 -0
  58. package/es/victory-theme/material.js +1 -1
  59. package/es/victory-theme/victory-theme-definition.d.ts +244 -0
  60. package/es/victory-theme/victory-theme-definition.js +1 -0
  61. package/es/victory-theme/victory-theme.d.ts +5 -0
  62. package/es/victory-theme/victory-theme.js +6 -5
  63. package/es/victory-transition/victory-transition.d.ts +59 -0
  64. package/es/victory-transition/victory-transition.js +19 -23
  65. package/es/victory-util/add-events.js +6 -3
  66. package/es/victory-util/axis.js +0 -1
  67. package/es/victory-util/collection.js +0 -2
  68. package/es/victory-util/data.js +0 -2
  69. package/es/victory-util/default-transitions.js +0 -1
  70. package/es/victory-util/domain.js +0 -2
  71. package/es/victory-util/helpers.js +0 -2
  72. package/es/victory-util/immutable.js +0 -1
  73. package/es/victory-util/label-helpers.js +0 -2
  74. package/es/victory-util/log.js +0 -1
  75. package/es/victory-util/point-path-helpers.d.ts +9 -0
  76. package/es/victory-util/point-path-helpers.js +59 -61
  77. package/es/victory-util/selection.d.ts +23 -0
  78. package/es/victory-util/selection.js +0 -2
  79. package/es/victory-util/style.js +0 -2
  80. package/es/victory-util/textsize.d.ts +8 -0
  81. package/es/victory-util/timer-context.d.ts +11 -0
  82. package/es/victory-util/timer.d.ts +16 -0
  83. package/es/victory-util/timer.js +13 -8
  84. package/es/victory-util/types.d.ts +188 -0
  85. package/es/victory-util/types.js +1 -0
  86. package/lib/index.d.ts +38 -941
  87. package/lib/index.js +195 -193
  88. package/lib/types.d.ts +33 -0
  89. package/lib/types.js +1 -0
  90. package/lib/victory-accessible-group/victory-accessible-group.d.ts +25 -0
  91. package/lib/victory-accessible-group/victory-accessible-group.js +9 -15
  92. package/lib/victory-animation/util.d.ts +66 -0
  93. package/lib/victory-animation/util.js +2 -1
  94. package/lib/victory-animation/victory-animation.d.ts +69 -0
  95. package/lib/victory-animation/victory-animation.js +60 -65
  96. package/lib/victory-clip-container/victory-clip-container.d.ts +76 -0
  97. package/lib/victory-clip-container/victory-clip-container.js +19 -22
  98. package/lib/victory-container/victory-container.d.ts +99 -0
  99. package/lib/victory-container/victory-container.js +34 -31
  100. package/lib/victory-label/victory-label.d.ts +61 -0
  101. package/lib/victory-label/victory-label.js +19 -13
  102. package/lib/victory-portal/portal-context.d.ts +11 -0
  103. package/lib/victory-portal/portal-context.js +3 -4
  104. package/lib/victory-portal/portal.d.ts +28 -0
  105. package/lib/victory-portal/portal.js +26 -31
  106. package/lib/victory-portal/victory-portal.d.ts +31 -0
  107. package/lib/victory-portal/victory-portal.js +24 -20
  108. package/lib/victory-primitives/arc.d.ts +21 -0
  109. package/lib/victory-primitives/arc.js +5 -6
  110. package/lib/victory-primitives/background.d.ts +22 -0
  111. package/lib/victory-primitives/background.js +7 -8
  112. package/lib/victory-primitives/border.d.ts +18 -0
  113. package/lib/victory-primitives/border.js +5 -6
  114. package/lib/victory-primitives/circle.d.ts +2 -0
  115. package/lib/victory-primitives/circle.js +11 -6
  116. package/lib/victory-primitives/clip-path.d.ts +14 -0
  117. package/lib/victory-primitives/clip-path.js +7 -5
  118. package/lib/victory-primitives/index.d.ts +14 -0
  119. package/lib/victory-primitives/index.js +187 -0
  120. package/lib/victory-primitives/line-segment.d.ts +19 -0
  121. package/lib/victory-primitives/line-segment.js +5 -6
  122. package/lib/victory-primitives/line.d.ts +2 -0
  123. package/lib/victory-primitives/line.js +11 -6
  124. package/lib/victory-primitives/path.d.ts +2 -0
  125. package/lib/victory-primitives/path.js +9 -4
  126. package/lib/victory-primitives/point.d.ts +21 -0
  127. package/lib/victory-primitives/point.js +13 -21
  128. package/lib/victory-primitives/rect.d.ts +2 -0
  129. package/lib/victory-primitives/rect.js +11 -6
  130. package/lib/victory-primitives/text.d.ts +16 -0
  131. package/lib/victory-primitives/text.js +8 -5
  132. package/lib/victory-primitives/tspan.d.ts +2 -0
  133. package/lib/victory-primitives/tspan.js +7 -4
  134. package/lib/victory-primitives/types.d.ts +7 -0
  135. package/lib/victory-primitives/types.js +1 -0
  136. package/lib/victory-primitives/whisker.d.ts +24 -0
  137. package/lib/victory-primitives/whisker.js +5 -6
  138. package/lib/victory-theme/grayscale.d.ts +2 -0
  139. package/lib/victory-theme/grayscale.js +3 -3
  140. package/lib/victory-theme/material.d.ts +2 -0
  141. package/lib/victory-theme/material.js +3 -3
  142. package/lib/victory-theme/victory-theme-definition.d.ts +244 -0
  143. package/lib/victory-theme/victory-theme-definition.js +1 -0
  144. package/lib/victory-theme/victory-theme.d.ts +5 -0
  145. package/lib/victory-theme/victory-theme.js +22 -8
  146. package/lib/victory-transition/victory-transition.d.ts +59 -0
  147. package/lib/victory-transition/victory-transition.js +21 -23
  148. package/lib/victory-util/add-events.js +8 -4
  149. package/lib/victory-util/collection.js +0 -2
  150. package/lib/victory-util/default-transitions.js +0 -1
  151. package/lib/victory-util/helpers.js +0 -2
  152. package/lib/victory-util/immutable.js +0 -2
  153. package/lib/victory-util/label-helpers.js +0 -2
  154. package/lib/victory-util/log.js +0 -1
  155. package/lib/victory-util/point-path-helpers.d.ts +9 -0
  156. package/lib/victory-util/point-path-helpers.js +86 -73
  157. package/lib/victory-util/selection.d.ts +23 -0
  158. package/lib/victory-util/selection.js +0 -2
  159. package/lib/victory-util/style.js +0 -2
  160. package/lib/victory-util/textsize.d.ts +8 -0
  161. package/lib/victory-util/timer-context.d.ts +11 -0
  162. package/lib/victory-util/timer.d.ts +16 -0
  163. package/lib/victory-util/timer.js +13 -8
  164. package/lib/victory-util/types.d.ts +188 -0
  165. package/lib/victory-util/types.js +1 -0
  166. package/package.json +4 -4
  167. package/src/index.ts +42 -0
  168. package/src/types.ts +45 -0
  169. package/src/victory-accessible-group/{victory-accessible-group.js → victory-accessible-group.tsx} +10 -3
  170. package/src/victory-animation/{util.js → util.ts} +4 -3
  171. package/src/victory-animation/{victory-animation.js → victory-animation.tsx} +89 -12
  172. package/src/victory-clip-container/{victory-clip-container.js → victory-clip-container.tsx} +29 -5
  173. package/src/victory-container/{victory-container.js → victory-container.tsx} +70 -26
  174. package/src/victory-label/{victory-label.js → victory-label.tsx} +71 -14
  175. package/src/victory-portal/portal-context.ts +14 -0
  176. package/src/victory-portal/{portal.js → portal.tsx} +23 -12
  177. package/src/victory-portal/{victory-portal.js → victory-portal.tsx} +21 -6
  178. package/src/victory-primitives/{arc.js → arc.tsx} +15 -5
  179. package/src/victory-primitives/{background.js → background.tsx} +17 -7
  180. package/src/victory-primitives/{border.js → border.tsx} +12 -5
  181. package/src/victory-primitives/{circle.js → circle.tsx} +4 -3
  182. package/src/victory-primitives/clip-path.tsx +25 -0
  183. package/src/victory-primitives/index.ts +14 -0
  184. package/src/victory-primitives/{line-segment.js → line-segment.tsx} +13 -5
  185. package/src/victory-primitives/{line.js → line.tsx} +4 -3
  186. package/src/victory-primitives/{path.js → path.tsx} +4 -3
  187. package/src/victory-primitives/{point.js → point.tsx} +25 -20
  188. package/src/victory-primitives/{rect.js → rect.tsx} +4 -2
  189. package/src/victory-primitives/{text.js → text.tsx} +9 -3
  190. package/src/victory-primitives/tspan.tsx +7 -0
  191. package/src/victory-primitives/types.ts +19 -0
  192. package/src/victory-primitives/{whisker.js → whisker.tsx} +20 -7
  193. package/src/victory-theme/{grayscale.js → grayscale.tsx} +2 -1
  194. package/src/victory-theme/{material.js → material.tsx} +2 -1
  195. package/src/victory-theme/victory-theme-definition.ts +261 -0
  196. package/src/victory-theme/victory-theme.tsx +5 -0
  197. package/src/victory-transition/{victory-transition.js → victory-transition.tsx} +68 -19
  198. package/src/victory-util/add-events.js +6 -1
  199. package/src/victory-util/axis.js +0 -1
  200. package/src/victory-util/collection.js +0 -1
  201. package/src/victory-util/data.js +0 -1
  202. package/src/victory-util/default-transitions.js +0 -1
  203. package/src/victory-util/domain.js +0 -1
  204. package/src/victory-util/events.js +1 -1
  205. package/src/victory-util/helpers.js +0 -1
  206. package/src/victory-util/immutable.js +0 -1
  207. package/src/victory-util/label-helpers.js +0 -1
  208. package/src/victory-util/log.js +0 -1
  209. package/src/victory-util/point-path-helpers.ts +119 -0
  210. package/src/victory-util/prop-types.js +0 -1
  211. package/src/victory-util/scale.js +0 -1
  212. package/src/victory-util/selection.d.ts +23 -0
  213. package/src/victory-util/selection.js +0 -1
  214. package/src/victory-util/style.js +0 -1
  215. package/src/victory-util/textsize.d.ts +8 -0
  216. package/src/victory-util/{timer-context.js → timer-context.ts} +0 -0
  217. package/src/victory-util/{timer.js → timer.ts} +19 -4
  218. package/src/victory-util/transitions.js +0 -1
  219. package/src/victory-util/types.ts +247 -0
  220. package/src/victory-util/wrapper.js +0 -1
  221. package/src/index.d.ts +0 -941
  222. package/src/index.js +0 -51
  223. package/src/victory-portal/portal-context.js +0 -10
  224. package/src/victory-primitives/clip-path.js +0 -18
  225. package/src/victory-primitives/tspan.js +0 -5
  226. package/src/victory-theme/victory-theme.js +0 -7
  227. package/src/victory-util/point-path-helpers.js +0 -121
@@ -0,0 +1,188 @@
1
+ import * as React from "react";
2
+ import { OriginType } from "../victory-label/victory-label";
3
+ import { NumberOrCallback, PaddingProps, VictoryThemeDefinition } from "../victory-theme/victory-theme";
4
+ import { StringOrCallback, StringOrNumberOrCallback } from "../types";
5
+ import { AnimationEasing, AnimationStyle } from "../victory-animation/victory-animation";
6
+ export declare type StringOrNumberOrList = string | number | (string | number)[];
7
+ export interface AnimatePropTypeInterface {
8
+ duration?: number;
9
+ onEnd?: () => void;
10
+ onExit?: {
11
+ duration?: number;
12
+ before?: (datum: any) => AnimationStyle;
13
+ };
14
+ onEnter?: {
15
+ duration?: number;
16
+ before?: (datum: any) => AnimationStyle;
17
+ after?: (datum: any) => AnimationStyle;
18
+ };
19
+ onLoad?: {
20
+ duration?: number;
21
+ before?: (datum: any) => AnimationStyle;
22
+ after?: (datum: any) => AnimationStyle;
23
+ };
24
+ easing?: AnimationEasing;
25
+ animationWhitelist?: string[];
26
+ }
27
+ export interface EventCallbackInterface<TTarget, TEventKey> {
28
+ childName?: string | string[];
29
+ target?: TTarget;
30
+ eventKey?: TEventKey;
31
+ mutation: (props: any) => any;
32
+ callback?: (props: any) => any;
33
+ }
34
+ export interface EventPropTypeInterface<TTarget, TEventKey> {
35
+ childName?: string | Array<StringOrNumberOrCallback>;
36
+ target: TTarget;
37
+ eventKey?: TEventKey;
38
+ eventHandlers: {
39
+ [key: string]: {
40
+ (event: React.SyntheticEvent<any>, props?: any): EventCallbackInterface<TTarget, TEventKey>;
41
+ } | {
42
+ (event: React.SyntheticEvent<any>, props?: any): EventCallbackInterface<TTarget, TEventKey>[];
43
+ } | {
44
+ (event: React.SyntheticEvent<any>, props?: any): void;
45
+ };
46
+ };
47
+ }
48
+ export declare type DomainTuple = [number, number] | [Date, Date];
49
+ export declare type DomainPropObjectType = {
50
+ x?: DomainTuple;
51
+ y: DomainTuple;
52
+ } | {
53
+ x: DomainTuple;
54
+ y?: DomainTuple;
55
+ };
56
+ export declare type DomainPropType = DomainPropObjectType | DomainTuple;
57
+ export declare type PaddingType = number | [number, number];
58
+ export declare type DomainPaddingPropType = PaddingType | {
59
+ x?: PaddingType;
60
+ y?: PaddingType;
61
+ };
62
+ export declare type RangeTuple = [number, number];
63
+ export declare type RangePropType = RangeTuple | {
64
+ x?: RangeTuple;
65
+ y?: RangeTuple;
66
+ };
67
+ /**
68
+ * D3 scale function shape. Don"t want to introduce typing dependency to d3
69
+ */
70
+ export interface D3Scale {
71
+ (input: string | number): number;
72
+ domain: () => any;
73
+ range: () => any;
74
+ copy: () => any;
75
+ }
76
+ export declare type ScalePropType = "linear" | "time" | "log" | "sqrt";
77
+ export declare type CategoryPropType = string[] | {
78
+ x: string[];
79
+ } | {
80
+ y: string[];
81
+ } | {
82
+ x: string[];
83
+ y: string[];
84
+ };
85
+ export declare type DataGetterPropType = number | string | string[] | {
86
+ (data: any): number | string | string[];
87
+ } | Function;
88
+ export declare type InterpolationPropType = "basis" | "basisClosed" | "basisOpen" | "bundle" | "cardinal" | "cardinalClosed" | "cardinalOpen" | "catmullRom" | "catmullRomClosed" | "catmullRomOpen" | "linear" | "linearClosed" | "monotoneX" | "monotoneY" | "natural" | "radial" | "step" | "stepAfter" | "stepBefore";
89
+ export declare type ColorScalePropType = "grayscale" | "qualitative" | "heatmap" | "warm" | "cool" | "red" | "green" | "blue" | string[];
90
+ export declare type SortOrderPropType = "ascending" | "descending";
91
+ export declare type SVGCoordinateType = {
92
+ x: number;
93
+ y: number;
94
+ };
95
+ export interface VictoryCommonThemeProps {
96
+ animate?: boolean | AnimatePropTypeInterface;
97
+ colorScale?: ColorScalePropType;
98
+ containerComponent?: React.ReactElement;
99
+ domainPadding?: DomainPaddingPropType;
100
+ externalEventMutations?: EventCallbackInterface<string | string[], StringOrNumberOrList>[];
101
+ groupComponent?: React.ReactElement;
102
+ height?: number;
103
+ horizontal?: boolean;
104
+ maxDomain?: number | {
105
+ x?: number;
106
+ y?: number;
107
+ };
108
+ minDomain?: number | {
109
+ x?: number;
110
+ y?: number;
111
+ };
112
+ name?: string;
113
+ origin?: OriginType;
114
+ padding?: PaddingProps;
115
+ polar?: boolean;
116
+ range?: RangePropType;
117
+ scale?: ScalePropType | D3Scale | {
118
+ x?: ScalePropType | D3Scale;
119
+ y?: ScalePropType | D3Scale;
120
+ };
121
+ sharedEvents?: {
122
+ events: any[];
123
+ getEventState: Function;
124
+ };
125
+ singleQuadrantDomainPadding?: boolean | {
126
+ x?: boolean;
127
+ y?: boolean;
128
+ };
129
+ standalone?: boolean;
130
+ width?: number;
131
+ }
132
+ export interface VictoryCommonProps extends VictoryCommonThemeProps {
133
+ theme?: VictoryThemeDefinition;
134
+ }
135
+ export interface VictoryCommonPrimitiveProps {
136
+ active?: boolean;
137
+ ariaLabel?: StringOrCallback;
138
+ className?: string;
139
+ clipPath?: string;
140
+ data?: any;
141
+ desc?: string | Function;
142
+ disableInlineStyles?: boolean;
143
+ events?: object;
144
+ id?: number | string | Function;
145
+ index?: number | string;
146
+ origin?: OriginType;
147
+ polar?: boolean;
148
+ role?: string;
149
+ scale?: any;
150
+ shapeRendering?: string;
151
+ style?: any;
152
+ tabIndex?: NumberOrCallback;
153
+ transform?: string;
154
+ }
155
+ export interface VictoryDatableProps {
156
+ categories?: CategoryPropType;
157
+ data?: any[];
158
+ dataComponent?: React.ReactElement;
159
+ domain?: DomainPropType;
160
+ domainPadding?: DomainPaddingPropType;
161
+ samples?: number;
162
+ sortKey?: DataGetterPropType;
163
+ sortOrder?: SortOrderPropType;
164
+ x?: DataGetterPropType;
165
+ y?: DataGetterPropType;
166
+ y0?: DataGetterPropType;
167
+ }
168
+ export interface VictoryLabelableProps {
169
+ labelComponent?: React.ReactElement;
170
+ }
171
+ export interface VictoryMultiLabelableProps extends VictoryLabelableProps {
172
+ labels?: string[] | number[] | {
173
+ (data: any): string | string[] | number | number[] | null;
174
+ };
175
+ }
176
+ export interface VictorySingleLabelableProps extends VictoryLabelableProps {
177
+ label?: string | {
178
+ (data: any): string | number | null;
179
+ };
180
+ }
181
+ export interface TextSizeStyleInterface {
182
+ angle?: number;
183
+ characterConstant?: string;
184
+ fontFamily?: string;
185
+ fontSize?: number | string;
186
+ letterSpacing?: string;
187
+ lineHeight?: number;
188
+ }
@@ -0,0 +1 @@
1
+ "use strict";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-core",
3
- "version": "36.4.1",
3
+ "version": "36.5.0",
4
4
  "description": "Victory Core",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -22,14 +22,14 @@
22
22
  "lodash": "^4.17.21",
23
23
  "prop-types": "^15.8.1",
24
24
  "react-fast-compare": "^3.2.0",
25
- "victory-vendor": "^36.4.0"
25
+ "victory-vendor": "^36.5.0"
26
26
  },
27
27
  "peerDependencies": {
28
- "react": "^16.6.0 || ^17.0.0"
28
+ "react": ">=16.6.0"
29
29
  },
30
30
  "scripts": {
31
31
  "version": "yarn run nps build-libs && nps build-dists"
32
32
  },
33
33
  "sideEffects": false,
34
- "gitHead": "aa44a22e5a93989773a560f765f83ac151f44c46"
34
+ "gitHead": "7cecba921f751c3decc8215f7e866f51d11203c1"
35
35
  }
package/src/index.ts ADDED
@@ -0,0 +1,42 @@
1
+ // This rule doesn't play well with namespaced exports
2
+ /* eslint-disable import/export */
3
+ export * from "./victory-accessible-group/victory-accessible-group";
4
+ export * from "./victory-animation/victory-animation";
5
+ export * from "./victory-container/victory-container";
6
+ export * from "./victory-label/victory-label";
7
+ export * from "./victory-transition/victory-transition";
8
+ export * from "./victory-clip-container/victory-clip-container";
9
+ export * from "./victory-theme/victory-theme";
10
+ export * from "./victory-portal/portal";
11
+ export * from "./victory-portal/portal-context";
12
+ export * from "./victory-portal/victory-portal";
13
+ export * from "./victory-primitives";
14
+ export { Border as Box } from "./victory-primitives";
15
+
16
+ // victory-util:
17
+ export { default as addEvents } from "./victory-util/add-events";
18
+ export * as Collection from "./victory-util/collection";
19
+ export * as Data from "./victory-util/data";
20
+ export * as DefaultTransitions from "./victory-util/default-transitions";
21
+ export * as Domain from "./victory-util/domain";
22
+ export * as Events from "./victory-util/events";
23
+ export * as Helpers from "./victory-util/helpers";
24
+ export * as Immutable from "./victory-util/immutable";
25
+ export * as LabelHelpers from "./victory-util/label-helpers";
26
+ export * as Log from "./victory-util/log";
27
+ export * as PropTypes from "./victory-util/prop-types";
28
+ export * as Scale from "./victory-util/scale";
29
+ export * as Selection from "./victory-util/selection";
30
+ export * as Style from "./victory-util/style";
31
+ export * as TextSize from "./victory-util/textsize";
32
+ export * as Transitions from "./victory-util/transitions";
33
+ export * as UserProps from "./victory-util/user-props";
34
+ export * as CommonProps from "./victory-util/common-props";
35
+ export * as Wrapper from "./victory-util/wrapper";
36
+ export * as Axis from "./victory-util/axis";
37
+ export * as Hooks from "./victory-util/hooks";
38
+ export * as LineHelpers from "./victory-util/line-helpers";
39
+ export { default as Timer } from "./victory-util/timer";
40
+ export * as PointPathHelpers from "./victory-util/point-path-helpers";
41
+ export { default as TimerContext } from "./victory-util/timer-context";
42
+ export * from "./victory-util/types";
package/src/types.ts ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * This is the first parameter of a callback when a callback is used to
3
+ * resolve the value of a property instead of a concrete value.
4
+ *
5
+ * Note that additional properties here like `scale`, `x`, `y`, etc are resolved
6
+ * values of properties from the VictoryXXXProps for each component.
7
+ */
8
+ import type { D3Scale } from "./victory-util/types";
9
+
10
+ export interface CallbackArgs {
11
+ active?: boolean;
12
+ data?: any;
13
+ datum?: any;
14
+ horizontal?: boolean;
15
+ index: number | string;
16
+ x?: number;
17
+ y?: number;
18
+ scale?: {
19
+ x?: D3Scale;
20
+ y?: D3Scale;
21
+ };
22
+ tick?: any;
23
+ ticks?: any;
24
+ text?: any;
25
+ }
26
+
27
+ export type VictoryStringOrNumberCallback = (
28
+ args: CallbackArgs
29
+ ) => string | number;
30
+ export type VictoryStringCallback = (args: CallbackArgs) => string;
31
+ export type StringOrNumberOrCallback =
32
+ | string
33
+ | number
34
+ | VictoryStringOrNumberCallback;
35
+ export type StringOrCallback = string | VictoryStringCallback;
36
+
37
+ export type SliceNumberOrCallback<
38
+ T,
39
+ P extends string | number | symbol = never
40
+ > = number | ((props: Omit<T, P>) => number);
41
+
42
+ export type CoordinatesPropType = {
43
+ x: number;
44
+ y: number;
45
+ };
@@ -1,7 +1,16 @@
1
1
  import React from "react";
2
2
  import PropTypes from "prop-types";
3
3
 
4
- class VictoryAccessibleGroup extends React.Component {
4
+ export interface VictoryAccessibleGroupProps {
5
+ desc?: string;
6
+ "aria-describedby"?: string;
7
+ "aria-label"?: string;
8
+ children?: React.ReactElement | React.ReactElement[];
9
+ className?: string;
10
+ tabIndex?: number;
11
+ }
12
+
13
+ export class VictoryAccessibleGroup extends React.Component<VictoryAccessibleGroupProps> {
5
14
  static displayName = "VictoryAccessibleGroup";
6
15
  static propTypes = {
7
16
  "aria-describedby": PropTypes.string,
@@ -46,5 +55,3 @@ class VictoryAccessibleGroup extends React.Component {
46
55
  );
47
56
  }
48
57
  }
49
-
50
- export default VictoryAccessibleGroup;
@@ -82,8 +82,8 @@ export const interpolateFunction = function (a, b) {
82
82
  if (t >= 1) {
83
83
  return b;
84
84
  }
85
- return function () {
86
- /* eslint-disable no-invalid-this */
85
+ return function (this: unknown) {
86
+ /* eslint-disable no-invalid-this, prefer-rest-params */
87
87
  const aval = typeof a === "function" ? a.apply(this, arguments) : a;
88
88
  const bval = typeof b === "function" ? b.apply(this, arguments) : b;
89
89
  return interpolate(aval, bval)(t);
@@ -182,7 +182,7 @@ export const interpolateString = function (a, b) {
182
182
  * @param {any} b - End value.
183
183
  * @returns {Function|undefined} An interpolation function, if necessary.
184
184
  */
185
- export const victoryInterpolator = function (a, b) {
185
+ export const victoryInterpolator = function <T>(a: T, b: T): (t: number) => T {
186
186
  // If the values are strictly equal, or either value is not interpolatable,
187
187
  // just use either the start value `a` or end value `b` at every step, as
188
188
  // there is no reasonable in-between value.
@@ -193,6 +193,7 @@ export const victoryInterpolator = function (a, b) {
193
193
  return interpolateFunction(a, b);
194
194
  }
195
195
  if (isPlainObject(a) || isPlainObject(b)) {
196
+ // @ts-expect-error These generics are tough, but they work ok?
196
197
  return interpolateObject(a, b);
197
198
  }
198
199
  if (typeof a === "string" || typeof b === "string") {
@@ -5,8 +5,85 @@ import * as d3Ease from "victory-vendor/d3-ease";
5
5
  import { victoryInterpolator } from "./util";
6
6
  import TimerContext from "../victory-util/timer-context";
7
7
  import isEqual from "react-fast-compare";
8
+ import type Timer from "../victory-util/timer";
8
9
 
9
- export default class VictoryAnimation extends React.Component {
10
+ /**
11
+ * Single animation object to interpolate
12
+ */
13
+ export type AnimationStyle = { [key: string]: string | number };
14
+ /**
15
+ * Animation styles to interpolate
16
+ */
17
+
18
+ export type AnimationData = AnimationStyle | AnimationStyle[];
19
+ export type AnimationEasing =
20
+ | "back"
21
+ | "backIn"
22
+ | "backOut"
23
+ | "backInOut"
24
+ | "bounce"
25
+ | "bounceIn"
26
+ | "bounceOut"
27
+ | "bounceInOut"
28
+ | "circle"
29
+ | "circleIn"
30
+ | "circleOut"
31
+ | "circleInOut"
32
+ | "linear"
33
+ | "linearIn"
34
+ | "linearOut"
35
+ | "linearInOut"
36
+ | "cubic"
37
+ | "cubicIn"
38
+ | "cubicOut"
39
+ | "cubicInOut"
40
+ | "elastic"
41
+ | "elasticIn"
42
+ | "elasticOut"
43
+ | "elasticInOut"
44
+ | "exp"
45
+ | "expIn"
46
+ | "expOut"
47
+ | "expInOut"
48
+ | "poly"
49
+ | "polyIn"
50
+ | "polyOut"
51
+ | "polyInOut"
52
+ | "quad"
53
+ | "quadIn"
54
+ | "quadOut"
55
+ | "quadInOut"
56
+ | "sin"
57
+ | "sinIn"
58
+ | "sinOut"
59
+ | "sinInOut";
60
+
61
+ export interface VictoryAnimationProps {
62
+ children: (style: AnimationStyle, info: AnimationInfo) => React.ReactNode;
63
+ duration?: number;
64
+ easing?: AnimationEasing;
65
+ delay?: number;
66
+ onEnd?: () => void;
67
+ data: AnimationData;
68
+ }
69
+ export interface VictoryAnimationState {
70
+ data: AnimationStyle;
71
+ animationInfo: AnimationInfo;
72
+ }
73
+ export interface AnimationInfo {
74
+ progress: number;
75
+ animating: boolean;
76
+ terminating?: boolean;
77
+ }
78
+
79
+ export interface VictoryAnimation {
80
+ context: React.ContextType<typeof TimerContext>;
81
+ }
82
+
83
+ export class VictoryAnimation extends React.Component<
84
+ VictoryAnimationProps,
85
+ VictoryAnimationState
86
+ > {
10
87
  static displayName = "VictoryAnimation";
11
88
 
12
89
  static propTypes = {
@@ -67,6 +144,11 @@ export default class VictoryAnimation extends React.Component {
67
144
  };
68
145
 
69
146
  static contextType = TimerContext;
147
+ private interpolator: null | ((value: number) => AnimationStyle);
148
+ private queue: AnimationStyle[];
149
+ private ease: any;
150
+ private timer: Timer;
151
+ private loopID?: number;
70
152
 
71
153
  constructor(props, context) {
72
154
  super(props, context);
@@ -84,11 +166,6 @@ export default class VictoryAnimation extends React.Component {
84
166
  this.queue = Array.isArray(this.props.data) ? this.props.data.slice(1) : [];
85
167
  /* build easing function */
86
168
  this.ease = d3Ease[this.toNewName(this.props.easing)];
87
- /*
88
- There is no autobinding of this in ES6 classes
89
- so we bind functionToBeRunEachFrame to current instance of victory animation class
90
- */
91
- this.functionToBeRunEachFrame = this.functionToBeRunEachFrame.bind(this);
92
169
  this.timer = this.context.animationTimer;
93
170
  }
94
171
 
@@ -163,13 +240,13 @@ export default class VictoryAnimation extends React.Component {
163
240
  setTimeout(() => {
164
241
  this.loopID = this.timer.subscribe(
165
242
  this.functionToBeRunEachFrame,
166
- this.props.duration
243
+ this.props.duration!
167
244
  );
168
245
  }, this.props.delay);
169
246
  } else {
170
247
  this.loopID = this.timer.subscribe(
171
248
  this.functionToBeRunEachFrame,
172
- this.props.duration
249
+ this.props.duration!
173
250
  );
174
251
  }
175
252
  } else if (this.props.onEnd) {
@@ -177,7 +254,7 @@ export default class VictoryAnimation extends React.Component {
177
254
  }
178
255
  }
179
256
  /* every frame we... */
180
- functionToBeRunEachFrame(elapsed, duration) {
257
+ functionToBeRunEachFrame = (elapsed, duration) => {
181
258
  /*
182
259
  step can generate imprecise values, sometimes greater than 1
183
260
  if this happens set the state to 1 and return, cancelling the timer
@@ -186,7 +263,7 @@ export default class VictoryAnimation extends React.Component {
186
263
  const step = duration ? elapsed / duration : 1;
187
264
  if (step >= 1) {
188
265
  this.setState({
189
- data: this.interpolator(1),
266
+ data: this.interpolator!(1),
190
267
  animationInfo: {
191
268
  progress: 1,
192
269
  animating: false,
@@ -206,13 +283,13 @@ export default class VictoryAnimation extends React.Component {
206
283
  interpolator, which is cached for performance whenever props are received
207
284
  */
208
285
  this.setState({
209
- data: this.interpolator(this.ease(step)),
286
+ data: this.interpolator!(this.ease(step)),
210
287
  animationInfo: {
211
288
  progress: step,
212
289
  animating: step < 1
213
290
  }
214
291
  });
215
- }
292
+ };
216
293
 
217
294
  render() {
218
295
  return this.props.children(this.state.data, this.state.animationInfo);
@@ -4,11 +4,34 @@ import * as CustomPropTypes from "../victory-util/prop-types";
4
4
  import * as Helpers from "../victory-util/helpers";
5
5
  import * as UserProps from "../victory-util/user-props";
6
6
  import { assign, defaults, isObject, uniqueId } from "lodash";
7
- import ClipPath from "../victory-primitives/clip-path";
8
- import Circle from "../victory-primitives/circle";
9
- import Rect from "../victory-primitives/rect";
7
+ import { ClipPath } from "../victory-primitives/clip-path";
8
+ import { Circle } from "../victory-primitives/circle";
9
+ import { Rect } from "../victory-primitives/rect";
10
10
 
11
- export default class VictoryClipContainer extends React.Component {
11
+ import { BlockProps } from "../victory-theme/victory-theme";
12
+ import { OriginType } from "../victory-label/victory-label";
13
+
14
+ export interface VictoryClipContainerProps {
15
+ "aria-label"?: string;
16
+ children?: React.ReactElement | React.ReactElement[];
17
+ circleComponent?: React.ReactElement;
18
+ className?: string;
19
+ clipHeight?: number;
20
+ clipId?: number | string;
21
+ clipPadding?: BlockProps;
22
+ clipPathComponent?: React.ReactElement;
23
+ clipWidth?: number;
24
+ events?: React.DOMAttributes<any>;
25
+ groupComponent?: React.ReactElement;
26
+ origin?: OriginType;
27
+ polar?: boolean;
28
+ radius?: number;
29
+ rectComponent?: React.ReactElement;
30
+ translateX?: number;
31
+ translateY?: number;
32
+ }
33
+
34
+ export class VictoryClipContainer extends React.Component<VictoryClipContainerProps> {
12
35
  static displayName = "VictoryClipContainer";
13
36
  static role = "container";
14
37
  static propTypes = {
@@ -50,8 +73,9 @@ export default class VictoryClipContainer extends React.Component {
50
73
  clipPathComponent: <ClipPath />,
51
74
  groupComponent: <g />
52
75
  };
76
+ private clipId: VictoryClipContainerProps["clipId"];
53
77
 
54
- constructor(props) {
78
+ constructor(props: VictoryClipContainerProps) {
55
79
  super(props);
56
80
  this.clipId =
57
81
  !isObject(props) || props.clipId === undefined