victory-core 36.5.0 → 36.5.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 (364) hide show
  1. package/dist/victory-core.js +13817 -10827
  2. package/dist/victory-core.min.js +1 -1
  3. package/es/index.d.ts +7 -27
  4. package/es/index.js +7 -53
  5. package/es/{types.d.ts → types/callbacks.d.ts} +12 -8
  6. package/es/types/callbacks.js +2 -0
  7. package/es/types/prop-types.d.ts +130 -0
  8. package/es/types/prop-types.js +2 -0
  9. package/es/victory-accessible-group/victory-accessible-group.d.ts +1 -0
  10. package/es/victory-accessible-group/victory-accessible-group.js +2 -1
  11. package/es/victory-animation/util.d.ts +2 -1
  12. package/es/victory-animation/util.js +6 -4
  13. package/es/victory-animation/victory-animation.d.ts +1 -0
  14. package/es/victory-animation/victory-animation.js +2 -1
  15. package/es/victory-clip-container/victory-clip-container.d.ts +6 -5
  16. package/es/victory-clip-container/victory-clip-container.js +2 -1
  17. package/es/victory-container/victory-container.d.ts +8 -7
  18. package/es/victory-container/victory-container.js +2 -1
  19. package/es/victory-label/victory-label.d.ts +3 -2
  20. package/es/victory-label/victory-label.js +4 -4
  21. package/es/victory-portal/portal-context.d.ts +1 -0
  22. package/es/victory-portal/portal-context.js +2 -1
  23. package/es/victory-portal/portal.d.ts +3 -2
  24. package/es/victory-portal/portal.js +2 -1
  25. package/es/victory-portal/victory-portal.d.ts +1 -0
  26. package/es/victory-portal/victory-portal.js +2 -1
  27. package/es/victory-primitives/arc.d.ts +31 -2
  28. package/es/victory-primitives/arc.js +3 -2
  29. package/es/victory-primitives/background.d.ts +31 -2
  30. package/es/victory-primitives/background.js +3 -2
  31. package/es/victory-primitives/border.d.ts +28 -2
  32. package/es/victory-primitives/border.js +3 -2
  33. package/es/victory-primitives/circle.d.ts +1 -0
  34. package/es/victory-primitives/circle.js +2 -1
  35. package/es/victory-primitives/clip-path.d.ts +2 -1
  36. package/es/victory-primitives/clip-path.js +2 -1
  37. package/es/victory-primitives/index.d.ts +1 -0
  38. package/es/victory-primitives/index.js +2 -1
  39. package/es/victory-primitives/line-segment.d.ts +29 -2
  40. package/es/victory-primitives/line-segment.js +3 -2
  41. package/es/victory-primitives/line.d.ts +1 -0
  42. package/es/victory-primitives/line.js +2 -1
  43. package/es/victory-primitives/path.d.ts +1 -0
  44. package/es/victory-primitives/path.js +2 -1
  45. package/es/victory-primitives/point.d.ts +30 -2
  46. package/es/victory-primitives/point.js +3 -2
  47. package/es/victory-primitives/rect.d.ts +1 -0
  48. package/es/victory-primitives/rect.js +2 -1
  49. package/es/victory-primitives/text.d.ts +2 -1
  50. package/es/victory-primitives/text.js +2 -1
  51. package/es/victory-primitives/tspan.d.ts +2 -1
  52. package/es/victory-primitives/tspan.js +2 -1
  53. package/es/victory-primitives/types.d.ts +2 -1
  54. package/es/victory-primitives/types.js +2 -1
  55. package/es/victory-primitives/whisker.d.ts +37 -2
  56. package/es/victory-primitives/whisker.js +3 -2
  57. package/es/victory-state/defaults.d.ts +3 -0
  58. package/es/victory-state/defaults.js +3 -0
  59. package/es/victory-state/helpers/get-axis-data.d.ts +3 -0
  60. package/es/victory-state/helpers/get-axis-data.js +15 -0
  61. package/es/victory-state/helpers/get-data.d.ts +15 -0
  62. package/es/victory-state/helpers/get-data.js +88 -0
  63. package/es/victory-state/helpers/get-domain.d.ts +6 -0
  64. package/es/victory-state/helpers/get-domain.js +68 -0
  65. package/es/victory-state/helpers/get-range.d.ts +6 -0
  66. package/es/victory-state/helpers/get-range.js +37 -0
  67. package/es/victory-state/helpers/get-scale.d.ts +6 -0
  68. package/es/victory-state/helpers/get-scale.js +59 -0
  69. package/es/victory-state/index.d.ts +3 -0
  70. package/es/victory-state/index.js +3 -0
  71. package/es/victory-state/types.d.ts +24 -0
  72. package/es/victory-state/types.js +2 -0
  73. package/es/victory-state/victory-provider.d.ts +19 -0
  74. package/es/victory-state/victory-provider.js +118 -0
  75. package/es/victory-theme/grayscale.d.ts +2 -1
  76. package/es/victory-theme/grayscale.js +2 -1
  77. package/es/victory-theme/material.d.ts +2 -1
  78. package/es/victory-theme/material.js +2 -1
  79. package/{lib/victory-theme/victory-theme-definition.d.ts → es/victory-theme/types.d.ts} +3 -8
  80. package/es/victory-theme/types.js +2 -0
  81. package/es/victory-theme/victory-theme.d.ts +4 -3
  82. package/es/victory-theme/victory-theme.js +3 -2
  83. package/es/victory-transition/victory-transition.d.ts +1 -0
  84. package/es/victory-transition/victory-transition.js +2 -1
  85. package/es/victory-util/add-events.d.ts +106 -0
  86. package/es/victory-util/add-events.js +40 -33
  87. package/es/victory-util/axis.d.ts +51 -0
  88. package/es/victory-util/axis.js +9 -7
  89. package/es/victory-util/collection.d.ts +9 -0
  90. package/es/victory-util/collection.js +6 -4
  91. package/es/victory-util/common-props.d.ts +84 -0
  92. package/es/victory-util/common-props.js +29 -12
  93. package/es/victory-util/data.d.ts +75 -0
  94. package/es/victory-util/data.js +2 -1
  95. package/es/victory-util/default-transitions.d.ts +5 -0
  96. package/es/victory-util/default-transitions.js +2 -1
  97. package/es/victory-util/domain.d.ts +91 -0
  98. package/es/victory-util/domain.js +6 -2
  99. package/es/victory-util/events.d.ts +65 -0
  100. package/es/victory-util/events.js +13 -8
  101. package/es/victory-util/helpers.d.ts +61 -0
  102. package/es/victory-util/helpers.js +8 -4
  103. package/es/victory-util/hooks/index.d.ts +3 -0
  104. package/es/victory-util/hooks/index.js +2 -1
  105. package/es/victory-util/hooks/use-animation-state.js +4 -3
  106. package/es/victory-util/hooks/use-previous-props.d.ts +2 -0
  107. package/es/victory-util/hooks/use-previous-props.js +4 -3
  108. package/es/victory-util/immutable.d.ts +12 -0
  109. package/es/victory-util/immutable.js +5 -4
  110. package/es/victory-util/index.d.ts +29 -0
  111. package/es/victory-util/index.js +48 -0
  112. package/es/victory-util/label-helpers.d.ts +27 -0
  113. package/es/victory-util/label-helpers.js +2 -1
  114. package/es/victory-util/line-helpers.d.ts +5 -0
  115. package/es/victory-util/line-helpers.js +24 -6
  116. package/es/victory-util/log.d.ts +2 -0
  117. package/es/victory-util/log.js +2 -1
  118. package/es/victory-util/point-path-helpers.d.ts +1 -0
  119. package/es/victory-util/point-path-helpers.js +2 -1
  120. package/es/victory-util/prop-types.d.ts +51 -0
  121. package/es/victory-util/prop-types.js +35 -44
  122. package/es/victory-util/scale.d.ts +10 -0
  123. package/es/victory-util/scale.js +14 -6
  124. package/es/victory-util/selection.d.ts +25 -23
  125. package/es/victory-util/selection.js +25 -14
  126. package/es/victory-util/style.d.ts +19 -0
  127. package/es/victory-util/style.js +2 -1
  128. package/es/victory-util/textsize.d.ts +37 -8
  129. package/es/victory-util/textsize.js +9 -6
  130. package/es/victory-util/timer-context.d.ts +1 -0
  131. package/es/victory-util/timer-context.js +2 -1
  132. package/es/victory-util/timer.d.ts +3 -2
  133. package/es/victory-util/timer.js +2 -1
  134. package/es/victory-util/transitions.d.ts +49 -0
  135. package/es/victory-util/transitions.js +5 -4
  136. package/es/victory-util/type-helpers.d.ts +10 -0
  137. package/es/victory-util/type-helpers.js +28 -0
  138. package/es/victory-util/user-props.d.ts +21 -0
  139. package/es/victory-util/user-props.js +6 -5
  140. package/es/victory-util/with-container.d.ts +5 -0
  141. package/es/victory-util/with-container.js +32 -0
  142. package/es/victory-util/wrapper.d.ts +38 -0
  143. package/es/victory-util/wrapper.js +4 -3
  144. package/lib/index.d.ts +7 -27
  145. package/lib/index.js +58 -147
  146. package/lib/{types.d.ts → types/callbacks.d.ts} +12 -8
  147. package/lib/types/callbacks.js +2 -0
  148. package/lib/types/prop-types.d.ts +130 -0
  149. package/lib/types/prop-types.js +2 -0
  150. package/lib/victory-accessible-group/victory-accessible-group.d.ts +1 -0
  151. package/lib/victory-accessible-group/victory-accessible-group.js +2 -1
  152. package/lib/victory-animation/util.d.ts +2 -1
  153. package/lib/victory-animation/util.js +6 -4
  154. package/lib/victory-animation/victory-animation.d.ts +1 -0
  155. package/lib/victory-animation/victory-animation.js +2 -1
  156. package/lib/victory-clip-container/victory-clip-container.d.ts +6 -5
  157. package/lib/victory-clip-container/victory-clip-container.js +2 -1
  158. package/lib/victory-container/victory-container.d.ts +8 -7
  159. package/lib/victory-container/victory-container.js +2 -1
  160. package/lib/victory-label/victory-label.d.ts +3 -2
  161. package/lib/victory-label/victory-label.js +4 -4
  162. package/lib/victory-portal/portal-context.d.ts +1 -0
  163. package/lib/victory-portal/portal-context.js +2 -1
  164. package/lib/victory-portal/portal.d.ts +3 -2
  165. package/lib/victory-portal/portal.js +2 -1
  166. package/lib/victory-portal/victory-portal.d.ts +1 -0
  167. package/lib/victory-portal/victory-portal.js +2 -1
  168. package/lib/victory-primitives/arc.d.ts +31 -2
  169. package/lib/victory-primitives/arc.js +4 -3
  170. package/lib/victory-primitives/background.d.ts +31 -2
  171. package/lib/victory-primitives/background.js +4 -3
  172. package/lib/victory-primitives/border.d.ts +28 -2
  173. package/lib/victory-primitives/border.js +4 -3
  174. package/lib/victory-primitives/circle.d.ts +1 -0
  175. package/lib/victory-primitives/circle.js +2 -1
  176. package/lib/victory-primitives/clip-path.d.ts +2 -1
  177. package/lib/victory-primitives/clip-path.js +2 -1
  178. package/lib/victory-primitives/index.d.ts +1 -0
  179. package/lib/victory-primitives/index.js +2 -1
  180. package/lib/victory-primitives/line-segment.d.ts +29 -2
  181. package/lib/victory-primitives/line-segment.js +4 -3
  182. package/lib/victory-primitives/line.d.ts +1 -0
  183. package/lib/victory-primitives/line.js +2 -1
  184. package/lib/victory-primitives/path.d.ts +1 -0
  185. package/lib/victory-primitives/path.js +2 -1
  186. package/lib/victory-primitives/point.d.ts +30 -2
  187. package/lib/victory-primitives/point.js +4 -3
  188. package/lib/victory-primitives/rect.d.ts +1 -0
  189. package/lib/victory-primitives/rect.js +2 -1
  190. package/lib/victory-primitives/text.d.ts +2 -1
  191. package/lib/victory-primitives/text.js +2 -1
  192. package/lib/victory-primitives/tspan.d.ts +2 -1
  193. package/lib/victory-primitives/tspan.js +2 -1
  194. package/lib/victory-primitives/types.d.ts +2 -1
  195. package/lib/victory-primitives/types.js +2 -1
  196. package/lib/victory-primitives/whisker.d.ts +37 -2
  197. package/lib/victory-primitives/whisker.js +4 -3
  198. package/lib/victory-state/defaults.d.ts +3 -0
  199. package/lib/victory-state/defaults.js +11 -0
  200. package/lib/victory-state/helpers/get-axis-data.d.ts +3 -0
  201. package/lib/victory-state/helpers/get-axis-data.js +23 -0
  202. package/lib/victory-state/helpers/get-data.d.ts +15 -0
  203. package/lib/victory-state/helpers/get-data.js +99 -0
  204. package/lib/victory-state/helpers/get-domain.d.ts +6 -0
  205. package/lib/victory-state/helpers/get-domain.js +82 -0
  206. package/lib/victory-state/helpers/get-range.d.ts +6 -0
  207. package/lib/victory-state/helpers/get-range.js +46 -0
  208. package/lib/victory-state/helpers/get-scale.d.ts +6 -0
  209. package/lib/victory-state/helpers/get-scale.js +74 -0
  210. package/lib/victory-state/index.d.ts +3 -0
  211. package/lib/victory-state/index.js +32 -0
  212. package/lib/victory-state/types.d.ts +24 -0
  213. package/lib/victory-state/types.js +2 -0
  214. package/lib/victory-state/victory-provider.d.ts +19 -0
  215. package/lib/victory-state/victory-provider.js +144 -0
  216. package/lib/victory-theme/grayscale.d.ts +2 -1
  217. package/lib/victory-theme/grayscale.js +2 -1
  218. package/lib/victory-theme/material.d.ts +2 -1
  219. package/lib/victory-theme/material.js +2 -1
  220. package/{es/victory-theme/victory-theme-definition.d.ts → lib/victory-theme/types.d.ts} +3 -8
  221. package/lib/victory-theme/types.js +2 -0
  222. package/lib/victory-theme/victory-theme.d.ts +4 -3
  223. package/lib/victory-theme/victory-theme.js +6 -5
  224. package/lib/victory-transition/victory-transition.d.ts +1 -0
  225. package/lib/victory-transition/victory-transition.js +2 -1
  226. package/lib/victory-util/add-events.d.ts +106 -0
  227. package/lib/victory-util/add-events.js +40 -36
  228. package/lib/victory-util/axis.d.ts +51 -0
  229. package/lib/victory-util/axis.js +8 -6
  230. package/lib/victory-util/collection.d.ts +9 -0
  231. package/lib/victory-util/collection.js +6 -4
  232. package/lib/victory-util/common-props.d.ts +84 -0
  233. package/lib/victory-util/common-props.js +27 -12
  234. package/lib/victory-util/data.d.ts +75 -0
  235. package/lib/victory-util/data.js +2 -1
  236. package/lib/victory-util/default-transitions.d.ts +5 -0
  237. package/lib/victory-util/default-transitions.js +2 -1
  238. package/lib/victory-util/domain.d.ts +91 -0
  239. package/lib/victory-util/domain.js +6 -2
  240. package/lib/victory-util/events.d.ts +65 -0
  241. package/lib/victory-util/events.js +13 -9
  242. package/lib/victory-util/helpers.d.ts +61 -0
  243. package/lib/victory-util/helpers.js +8 -4
  244. package/lib/victory-util/hooks/index.d.ts +3 -0
  245. package/lib/victory-util/hooks/index.js +2 -1
  246. package/lib/victory-util/hooks/use-animation-state.js +4 -3
  247. package/lib/victory-util/hooks/use-previous-props.d.ts +2 -0
  248. package/lib/victory-util/hooks/use-previous-props.js +5 -6
  249. package/lib/victory-util/immutable.d.ts +12 -0
  250. package/lib/victory-util/immutable.js +5 -4
  251. package/lib/victory-util/index.d.ts +29 -0
  252. package/lib/victory-util/index.js +181 -0
  253. package/lib/victory-util/label-helpers.d.ts +27 -0
  254. package/lib/victory-util/label-helpers.js +2 -1
  255. package/lib/victory-util/line-helpers.d.ts +5 -0
  256. package/lib/victory-util/line-helpers.js +28 -7
  257. package/lib/victory-util/log.d.ts +2 -0
  258. package/lib/victory-util/log.js +2 -1
  259. package/lib/victory-util/point-path-helpers.d.ts +1 -0
  260. package/lib/victory-util/point-path-helpers.js +2 -1
  261. package/lib/victory-util/prop-types.d.ts +51 -0
  262. package/lib/victory-util/prop-types.js +36 -44
  263. package/lib/victory-util/scale.d.ts +10 -0
  264. package/lib/victory-util/scale.js +14 -5
  265. package/lib/victory-util/selection.d.ts +25 -23
  266. package/lib/victory-util/selection.js +25 -19
  267. package/lib/victory-util/style.d.ts +19 -0
  268. package/lib/victory-util/style.js +2 -1
  269. package/lib/victory-util/textsize.d.ts +37 -8
  270. package/lib/victory-util/textsize.js +9 -6
  271. package/lib/victory-util/timer-context.d.ts +1 -0
  272. package/lib/victory-util/timer-context.js +2 -1
  273. package/lib/victory-util/timer.d.ts +3 -2
  274. package/lib/victory-util/timer.js +2 -1
  275. package/lib/victory-util/transitions.d.ts +49 -0
  276. package/lib/victory-util/transitions.js +5 -4
  277. package/lib/victory-util/type-helpers.d.ts +10 -0
  278. package/lib/victory-util/type-helpers.js +45 -0
  279. package/lib/victory-util/user-props.d.ts +21 -0
  280. package/lib/victory-util/user-props.js +6 -5
  281. package/lib/victory-util/with-container.d.ts +5 -0
  282. package/lib/victory-util/with-container.js +44 -0
  283. package/lib/victory-util/wrapper.d.ts +38 -0
  284. package/lib/victory-util/wrapper.js +4 -3
  285. package/package.json +3 -3
  286. package/src/index.ts +9 -31
  287. package/src/{types.ts → types/callbacks.ts} +21 -13
  288. package/src/types/prop-types.ts +195 -0
  289. package/src/victory-accessible-group/victory-accessible-group.tsx +3 -3
  290. package/src/victory-animation/util.ts +3 -2
  291. package/src/victory-animation/victory-animation.tsx +13 -13
  292. package/src/victory-clip-container/victory-clip-container.tsx +23 -23
  293. package/src/victory-container/victory-container.tsx +19 -19
  294. package/src/victory-label/victory-label.tsx +41 -39
  295. package/src/victory-portal/portal.tsx +1 -1
  296. package/src/victory-portal/victory-portal.tsx +3 -3
  297. package/src/victory-primitives/arc.tsx +8 -6
  298. package/src/victory-primitives/background.tsx +8 -6
  299. package/src/victory-primitives/border.tsx +8 -6
  300. package/src/victory-primitives/clip-path.tsx +3 -3
  301. package/src/victory-primitives/line-segment.tsx +8 -6
  302. package/src/victory-primitives/point.tsx +10 -8
  303. package/src/victory-primitives/text.tsx +2 -2
  304. package/src/victory-primitives/tspan.tsx +1 -1
  305. package/src/victory-primitives/types.ts +1 -1
  306. package/src/victory-primitives/whisker.tsx +15 -13
  307. package/src/victory-state/defaults.ts +2 -0
  308. package/src/victory-state/helpers/get-axis-data.ts +14 -0
  309. package/src/victory-state/helpers/get-data.ts +79 -0
  310. package/src/victory-state/helpers/get-domain.ts +62 -0
  311. package/src/victory-state/helpers/get-range.ts +39 -0
  312. package/src/victory-state/helpers/get-scale.ts +64 -0
  313. package/src/victory-state/index.ts +2 -0
  314. package/src/victory-state/types.ts +32 -0
  315. package/src/victory-state/victory-provider.tsx +116 -0
  316. package/src/victory-theme/grayscale.tsx +62 -62
  317. package/src/victory-theme/material.tsx +67 -67
  318. package/src/victory-theme/{victory-theme-definition.ts → types.ts} +10 -14
  319. package/src/victory-theme/victory-theme.tsx +1 -1
  320. package/src/victory-transition/victory-transition.tsx +19 -19
  321. package/src/victory-util/{add-events.js → add-events.tsx} +136 -59
  322. package/src/victory-util/{axis.js → axis.tsx} +17 -18
  323. package/src/victory-util/{collection.js → collection.tsx} +14 -10
  324. package/src/victory-util/common-props.tsx +307 -0
  325. package/src/victory-util/{data.js → data.ts} +14 -10
  326. package/src/victory-util/{default-transitions.js → default-transitions.ts} +20 -18
  327. package/src/victory-util/{domain.js → domain.ts} +26 -23
  328. package/src/victory-util/{events.js → events.ts} +82 -31
  329. package/src/victory-util/{helpers.js → helpers.ts} +41 -22
  330. package/src/victory-util/hooks/{index.js → index.ts} +0 -0
  331. package/src/victory-util/hooks/use-animation-state.js +12 -12
  332. package/src/victory-util/hooks/use-previous-props.ts +9 -0
  333. package/src/victory-util/{immutable.js → immutable.ts} +14 -10
  334. package/src/victory-util/index.ts +28 -0
  335. package/src/victory-util/{label-helpers.js → label-helpers.ts} +7 -7
  336. package/src/victory-util/line-helpers.ts +104 -0
  337. package/src/victory-util/{log.js → log.ts} +1 -1
  338. package/src/victory-util/{prop-types.js → prop-types.ts} +103 -101
  339. package/src/victory-util/{scale.js → scale.ts} +29 -16
  340. package/src/victory-util/selection.ts +158 -0
  341. package/src/victory-util/{style.js → style.ts} +3 -3
  342. package/src/victory-util/{textsize.js → textsize.ts} +32 -17
  343. package/src/victory-util/timer-context.ts +1 -1
  344. package/src/victory-util/timer.ts +5 -10
  345. package/src/victory-util/{transitions.js → transitions.ts} +50 -22
  346. package/src/victory-util/type-helpers.ts +50 -0
  347. package/src/victory-util/{user-props.js → user-props.ts} +16 -11
  348. package/src/victory-util/with-container.tsx +41 -0
  349. package/src/victory-util/{wrapper.js → wrapper.tsx} +38 -33
  350. package/es/types.js +0 -1
  351. package/es/victory-theme/victory-theme-definition.js +0 -1
  352. package/es/victory-util/types.d.ts +0 -188
  353. package/es/victory-util/types.js +0 -1
  354. package/lib/types.js +0 -1
  355. package/lib/victory-theme/victory-theme-definition.js +0 -1
  356. package/lib/victory-util/types.d.ts +0 -188
  357. package/lib/victory-util/types.js +0 -1
  358. package/src/victory-util/common-props.js +0 -197
  359. package/src/victory-util/hooks/use-previous-props.js +0 -9
  360. package/src/victory-util/line-helpers.js +0 -54
  361. package/src/victory-util/selection.d.ts +0 -23
  362. package/src/victory-util/selection.js +0 -98
  363. package/src/victory-util/textsize.d.ts +0 -8
  364. package/src/victory-util/types.ts +0 -247
@@ -52,7 +52,7 @@ export class VictoryTransition extends React.Component<
52
52
  static propTypes = {
53
53
  animate: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
54
54
  animationWhitelist: PropTypes.array,
55
- children: PropTypes.node
55
+ children: PropTypes.node,
56
56
  };
57
57
 
58
58
  static contextType = TimerContext;
@@ -64,7 +64,7 @@ export class VictoryTransition extends React.Component<
64
64
  super(props, context);
65
65
  this.state = {
66
66
  nodesShouldLoad: false,
67
- nodesDoneLoad: false
67
+ nodesDoneLoad: false,
68
68
  };
69
69
  const child = this.props.children;
70
70
  const polar = child.props.polar;
@@ -80,7 +80,7 @@ export class VictoryTransition extends React.Component<
80
80
  if (!isEqual(this.props, nextProps)) {
81
81
  this.timer.bypassAnimation();
82
82
  this.setState(this.getTransitionState(this.props, nextProps), () =>
83
- this.timer.resumeAnimation()
83
+ this.timer.resumeAnimation(),
84
84
  );
85
85
  }
86
86
  return true;
@@ -92,7 +92,7 @@ export class VictoryTransition extends React.Component<
92
92
 
93
93
  private getTransitionState(
94
94
  props: VictoryTransitionProps,
95
- nextProps: VictoryTransitionProps
95
+ nextProps: VictoryTransitionProps,
96
96
  ): VictoryTransitionState {
97
97
  const { animate } = props;
98
98
  if (!animate) {
@@ -108,7 +108,7 @@ export class VictoryTransition extends React.Component<
108
108
  nodesWillExit,
109
109
  nodesWillEnter,
110
110
  childrenTransitions,
111
- nodesShouldEnter
111
+ nodesShouldEnter,
112
112
  } = Transitions.getInitialTransitionState(oldChildren, nextChildren);
113
113
  return {
114
114
  nodesWillExit,
@@ -116,14 +116,14 @@ export class VictoryTransition extends React.Component<
116
116
  childrenTransitions,
117
117
  nodesShouldEnter,
118
118
  oldProps: nodesWillExit ? props : null,
119
- nextProps
119
+ nextProps,
120
120
  };
121
121
  }
122
122
  }
123
123
 
124
124
  private getDomainFromChildren(
125
125
  props: VictoryTransitionProps,
126
- axis: "x" | "y"
126
+ axis: "x" | "y",
127
127
  ) {
128
128
  const getChildDomains = (children) => {
129
129
  return children.reduce((memo, child) => {
@@ -133,7 +133,7 @@ export class VictoryTransition extends React.Component<
133
133
  return childDomain ? memo.concat(childDomain) : memo;
134
134
  } else if (child.props && child.props.children) {
135
135
  return memo.concat(
136
- getChildDomains(React.Children.toArray(child.props.children))
136
+ getChildDomains(React.Children.toArray(child.props.children)),
137
137
  );
138
138
  }
139
139
  return memo;
@@ -141,7 +141,7 @@ export class VictoryTransition extends React.Component<
141
141
  };
142
142
 
143
143
  const child = React.Children.toArray(
144
- props.children
144
+ props.children,
145
145
  )[0] as VictoryTransitionChild;
146
146
  const childProps: any = child.props || {};
147
147
  const domain = Array.isArray(childProps.domain)
@@ -155,7 +155,7 @@ export class VictoryTransition extends React.Component<
155
155
  ? [0, 1]
156
156
  : [
157
157
  Collection.getMinValue(childDomains),
158
- Collection.getMaxValue(childDomains)
158
+ Collection.getMaxValue(childDomains),
159
159
  ];
160
160
  }
161
161
  }
@@ -197,22 +197,22 @@ export class VictoryTransition extends React.Component<
197
197
  const getTransitionProps = this.props.animate?.getTransitions
198
198
  ? this.props.animate.getTransitions
199
199
  : Transitions.getTransitionPropsFactory(props, this.state, (newState) =>
200
- this.setState(newState)
200
+ this.setState(newState),
201
201
  );
202
202
  const child = React.Children.toArray(
203
- props.children
203
+ props.children,
204
204
  )[0] as VictoryTransitionChild;
205
205
  const transitionProps = getTransitionProps(child);
206
206
  this.transitionProps = transitionProps;
207
207
  const domain = {
208
208
  x: this.getDomainFromChildren(this.pickDomainProps(props), "x"),
209
- y: this.getDomainFromChildren(props, "y")
209
+ y: this.getDomainFromChildren(props, "y"),
210
210
  };
211
211
  const clipWidth = this.getClipWidth(props, child);
212
212
  const combinedProps = defaults(
213
213
  { domain, clipWidth },
214
214
  transitionProps,
215
- child.props
215
+ child.props,
216
216
  );
217
217
  const animationWhitelist = props.animationWhitelist || [];
218
218
  const whitelist = animationWhitelist.concat(["clipWidth"]);
@@ -225,7 +225,7 @@ export class VictoryTransition extends React.Component<
225
225
  if (child.props.groupComponent) {
226
226
  const groupComponent = this.continuous
227
227
  ? React.cloneElement(child.props.groupComponent, {
228
- clipWidth: newProps.clipWidth || 0
228
+ clipWidth: newProps.clipWidth || 0,
229
229
  })
230
230
  : child.props.groupComponent;
231
231
  return React.cloneElement(
@@ -233,8 +233,8 @@ export class VictoryTransition extends React.Component<
233
233
  defaults(
234
234
  { animate: null, animating: true, groupComponent },
235
235
  newProps,
236
- combinedProps
237
- )
236
+ combinedProps,
237
+ ),
238
238
  );
239
239
  }
240
240
  return React.cloneElement(
@@ -242,8 +242,8 @@ export class VictoryTransition extends React.Component<
242
242
  defaults(
243
243
  { animate: null, animating: true },
244
244
  newProps,
245
- combinedProps
246
- )
245
+ combinedProps,
246
+ ),
247
247
  );
248
248
  }}
249
249
  </VictoryAnimation>
@@ -1,19 +1,22 @@
1
1
  /*global window:false */
2
2
  import React from "react";
3
3
  import {
4
- defaults,
5
4
  assign,
6
- keys,
5
+ defaults,
6
+ difference,
7
+ isEmpty,
7
8
  isFunction,
9
+ isNil,
10
+ keys,
8
11
  pick,
9
12
  without,
10
- isEmpty,
11
- isNil,
12
- difference
13
13
  } from "lodash";
14
+ import type { ComponentEvent } from "./events";
14
15
  import * as Events from "./events";
15
16
  import isEqual from "react-fast-compare";
16
17
  import { VictoryTransition } from "../victory-transition/victory-transition";
18
+ import { VictoryCommonProps, VictoryDatableProps } from "./common-props";
19
+ import { VictoryLabelableProps } from "../types/prop-types";
17
20
 
18
21
  // DISCLAIMER:
19
22
  // This file is not currently tested, and it is first on the list of files
@@ -25,34 +28,104 @@ const datumHasXandY = (datum) => {
25
28
  };
26
29
 
27
30
  // used for checking state changes. Expected components can be passed in via options
28
- const defaultComponents = [
31
+ const defaultComponents: NonNullable<MixinOptions["components"]> = [
29
32
  { name: "parent", index: "parent" },
30
33
  { name: "data" },
31
- { name: "labels" }
34
+ { name: "labels" },
32
35
  ];
33
36
 
34
- export default (WrappedComponent, options) => {
35
- return class addEvents extends WrappedComponent {
36
- constructor(props) {
37
+ export type MixinOptions = {
38
+ components?: Array<{
39
+ name: string;
40
+ index?: string;
41
+ }>;
42
+ };
43
+
44
+ export interface EventMixinCommonProps
45
+ extends VictoryCommonProps,
46
+ VictoryDatableProps,
47
+ VictoryLabelableProps {}
48
+
49
+ /**
50
+ * These methods will be implemented by the Mixin,
51
+ * and are accessible to the Wrapped Component.
52
+ *
53
+ * To make your Wrapped Component type-safe, use "interface merging" like so:
54
+ * @example
55
+ * interface MyComponent extends EventsMixinClass<MyProps> {}
56
+ * class MyComponent extends React.Component<MyProps> { ... }
57
+ */
58
+ export interface EventsMixinClass<TProps> {
59
+ renderContainer(
60
+ component: React.ReactElement,
61
+ children: React.ReactElement[],
62
+ ): React.ReactElement;
63
+ cacheValues<TThis>(this: TThis, obj: Partial<TThis>): void;
64
+ getEventState: typeof Events.getEventState;
65
+ renderContinuousData(props: TProps);
66
+ animateComponent(props: TProps, defaultAnimationWhitelist);
67
+ }
68
+
69
+ /**
70
+ * These fields are calculated by the Mixin
71
+ */
72
+ export interface EventMixinCalculatedValues {
73
+ componentEvents: Array<ComponentEvent>;
74
+ getSharedEventState: (key: string, value: string) => unknown;
75
+ baseProps: Record<string, object>;
76
+ dataKeys: string[];
77
+ hasEvents: unknown;
78
+ events: unknown;
79
+ }
80
+
81
+ /**
82
+ * This represents the class itself, including static fields
83
+ */
84
+ export interface WrappedComponentClass<TProps> {
85
+ new (props: TProps): React.Component<TProps>;
86
+ getBaseProps?(props: TProps): EventMixinCalculatedValues["baseProps"];
87
+ role?: string;
88
+ expectedComponents?: string[];
89
+ }
90
+
91
+ export function addEvents<
92
+ TBase extends WrappedComponentClass<TProps>,
93
+ TProps extends EventMixinCommonProps,
94
+ >(WrappedComponent: TBase, options: MixinOptions = {}) {
95
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
96
+ interface AddEventsMixin extends EventMixinCalculatedValues {}
97
+
98
+ // @ts-expect-error "TS2545: A mixin class must have a constructor with a single rest parameter of type 'any[]'."
99
+ class AddEventsMixin
100
+ extends WrappedComponent
101
+ implements EventsMixinClass<TProps>
102
+ {
103
+ constructor(props: TProps) {
37
104
  super(props);
38
- const getScopedEvents = Events.getScopedEvents.bind(this);
39
- const boundGetEvents = Events.getEvents.bind(this);
40
- this.state = {};
41
- this.getEvents = (p, target, eventKey) => {
42
- return boundGetEvents(p, target, eventKey, getScopedEvents);
43
- };
44
- this.getEventState = Events.getEventState.bind(this);
45
- const calculatedValues = this.getCalculatedValues(props);
46
- this.cacheValues(calculatedValues);
47
- this.externalMutations = this.getExternalMutations(props);
48
- this.calculatedState = this.getStateChanges(props);
49
- this.globalEvents = {};
50
- this.prevGlobalEventKeys = [];
51
- this.boundGlobalEvents = {};
52
- }
53
105
 
54
- shouldComponentUpdate(nextProps) {
106
+ this.cacheValues(this.getCalculatedValues(props));
107
+ }
108
+ state = {};
109
+ getEventState = Events.getEventState.bind(this);
110
+ getScopedEvents = Events.getScopedEvents.bind(this);
111
+ getEvents = (p, target, eventKey) => {
112
+ return Events.getEvents.call(
113
+ this,
114
+ p,
115
+ target,
116
+ eventKey,
117
+ this.getScopedEvents,
118
+ );
119
+ };
120
+ externalMutations = this.getExternalMutations(this.props);
121
+ calculatedState = this.getStateChanges(this.props);
122
+ globalEvents = {};
123
+ prevGlobalEventKeys: string[] = [];
124
+ boundGlobalEvents = {};
125
+
126
+ shouldComponentUpdate(nextProps: TProps) {
55
127
  const externalMutations = this.getExternalMutations(nextProps);
128
+ // @ts-expect-error "Property 'animating' does not exist on type EventMixinCommonProps"
56
129
  const animating = this.props.animating || this.props.animate;
57
130
  const newMutation = !isEqual(externalMutations, this.externalMutations);
58
131
  if (animating || newMutation) {
@@ -85,12 +158,12 @@ export default (WrappedComponent, options) => {
85
158
  const globalEventKeys = keys(this.globalEvents);
86
159
  const removedGlobalEventKeys = difference(
87
160
  this.prevGlobalEventKeys,
88
- globalEventKeys
161
+ globalEventKeys,
89
162
  );
90
163
  removedGlobalEventKeys.forEach((key) => this.removeGlobalListener(key));
91
164
  const addedGlobalEventKeys = difference(
92
165
  globalEventKeys,
93
- this.prevGlobalEventKeys
166
+ this.prevGlobalEventKeys,
94
167
  );
95
168
  addedGlobalEventKeys.forEach((key) => this.addGlobalListener(key));
96
169
  this.prevGlobalEventKeys = globalEventKeys;
@@ -108,14 +181,14 @@ export default (WrappedComponent, options) => {
108
181
  this.boundGlobalEvents[key] = boundListener;
109
182
  window.addEventListener(
110
183
  Events.getGlobalEventNameFromKey(key),
111
- boundListener
184
+ boundListener,
112
185
  );
113
186
  }
114
187
 
115
188
  removeGlobalListener(key) {
116
189
  window.removeEventListener(
117
190
  Events.getGlobalEventNameFromKey(key),
118
- this.boundGlobalEvents[key]
191
+ this.boundGlobalEvents[key],
119
192
  );
120
193
  }
121
194
 
@@ -130,12 +203,11 @@ export default (WrappedComponent, options) => {
130
203
  const result = defaults(
131
204
  {},
132
205
  this.getEventState(key, type),
133
- this.getSharedEventState(key, type)
206
+ this.getSharedEventState(key, type),
134
207
  );
135
208
  return isEmpty(result) ? undefined : result;
136
209
  };
137
210
 
138
- options = options || {};
139
211
  const components = options.components || defaultComponents;
140
212
  const stateChanges = components
141
213
  .map((component) => {
@@ -163,7 +235,7 @@ export default (WrappedComponent, options) => {
163
235
  : memo;
164
236
  return memo;
165
237
  },
166
- []
238
+ [] as Array<() => void>,
167
239
  );
168
240
  const compiledCallbacks = callbacks.length
169
241
  ? () => {
@@ -174,7 +246,7 @@ export default (WrappedComponent, options) => {
174
246
  }
175
247
  }
176
248
 
177
- getCalculatedValues(props) {
249
+ getCalculatedValues(props): EventMixinCalculatedValues {
178
250
  const { sharedEvents } = props;
179
251
  const components = WrappedComponent.expectedComponents;
180
252
  const componentEvents = Events.getComponentEvents(props, components);
@@ -192,18 +264,18 @@ export default (WrappedComponent, options) => {
192
264
  baseProps,
193
265
  dataKeys,
194
266
  hasEvents,
195
- events
267
+ events,
196
268
  };
197
269
  }
198
270
 
199
- getExternalMutations(props) {
271
+ getExternalMutations(props: TProps) {
200
272
  const { sharedEvents, externalEventMutations } = props;
201
273
  return isEmpty(externalEventMutations) || sharedEvents
202
274
  ? undefined
203
275
  : Events.getExternalMutations(
204
276
  externalEventMutations,
205
277
  this.baseProps,
206
- this.state
278
+ this.state,
207
279
  );
208
280
  }
209
281
 
@@ -213,8 +285,9 @@ export default (WrappedComponent, options) => {
213
285
  });
214
286
  }
215
287
 
216
- getBaseProps(props, getSharedEventState) {
217
- getSharedEventState = getSharedEventState || this.getSharedEventState;
288
+ getBaseProps(props, getSharedEventState): this["baseProps"] {
289
+ getSharedEventState =
290
+ getSharedEventState || this.getSharedEventState.bind(this);
218
291
  const sharedParentState = getSharedEventState("parent", "parent");
219
292
  const parentState = this.getEventState("parent", "parent");
220
293
  const baseParentProps = defaults({}, parentState, sharedParentState);
@@ -224,7 +297,7 @@ export default (WrappedComponent, options) => {
224
297
  : {};
225
298
  const modifiedProps = defaults({}, parentProps, props);
226
299
 
227
- return isFunction(WrappedComponent.getBaseProps)
300
+ return typeof WrappedComponent.getBaseProps === "function"
228
301
  ? WrappedComponent.getBaseProps(modifiedProps)
229
302
  : {};
230
303
  }
@@ -259,13 +332,13 @@ export default (WrappedComponent, options) => {
259
332
  this.getSharedEventState(key, type),
260
333
  component.props,
261
334
  baseProps,
262
- { id }
335
+ { id },
263
336
  );
264
337
 
265
338
  const events = defaults(
266
339
  {},
267
340
  Events.getPartialEvents(baseEvents, key, componentProps),
268
- componentProps.events
341
+ componentProps.events,
269
342
  );
270
343
 
271
344
  return assign({}, componentProps, { events });
@@ -288,46 +361,48 @@ export default (WrappedComponent, options) => {
288
361
  return React.cloneElement(component, parentProps, children);
289
362
  }
290
363
 
291
- animateComponent(props, defaultAnimationWhitelist) {
364
+ animateComponent(props: TProps, defaultAnimationWhitelist: string[]) {
292
365
  const animationWhitelist =
293
- props.animate && props.animate.animationWhitelist
294
- ? props.animate.animationWhitelist
295
- : defaultAnimationWhitelist;
366
+ (typeof props.animate === "object" &&
367
+ props.animate?.animationWhitelist) ||
368
+ defaultAnimationWhitelist;
369
+
370
+ const Comp = this.constructor;
296
371
 
297
372
  return (
298
373
  <VictoryTransition
299
374
  animate={props.animate}
300
375
  animationWhitelist={animationWhitelist}
301
376
  >
302
- {React.createElement(this.constructor, props)}
377
+ <Comp {...props} />
303
378
  </VictoryTransition>
304
379
  );
305
380
  }
306
381
 
307
382
  // Used by `VictoryLine` and `VictoryArea`
308
- renderContinuousData(props) {
383
+ renderContinuousData(props: TProps) {
309
384
  const { dataComponent, labelComponent, groupComponent } = props;
310
385
  const dataKeys = without(this.dataKeys, "all");
311
386
  const labelComponents = dataKeys.reduce((memo, key) => {
312
387
  const labelProps = this.getComponentProps(
313
388
  labelComponent,
314
389
  "labels",
315
- key
390
+ key,
316
391
  );
317
392
  if (
318
393
  labelProps &&
319
394
  labelProps.text !== undefined &&
320
395
  labelProps.text !== null
321
396
  ) {
322
- memo = memo.concat(React.cloneElement(labelComponent, labelProps));
397
+ memo = memo.concat(React.cloneElement(labelComponent!, labelProps));
323
398
  }
324
399
  return memo;
325
- }, []);
400
+ }, [] as React.ReactElement[]);
326
401
 
327
402
  const dataProps = this.getComponentProps(dataComponent, "data", "all");
328
403
  const children = [
329
- React.cloneElement(dataComponent, dataProps),
330
- ...labelComponents
404
+ React.cloneElement(dataComponent!, dataProps),
405
+ ...labelComponents,
331
406
  ];
332
407
  return this.renderContainer(groupComponent, children);
333
408
  }
@@ -339,16 +414,16 @@ export default (WrappedComponent, options) => {
339
414
  const dataProps = this.getComponentProps(
340
415
  dataComponent,
341
416
  "data",
342
- index
417
+ index,
343
418
  );
344
419
  if (shouldRenderDatum(dataProps.datum)) {
345
420
  validDataComponents.push(
346
- React.cloneElement(dataComponent, dataProps)
421
+ React.cloneElement(dataComponent, dataProps),
347
422
  );
348
423
  }
349
424
  return validDataComponents;
350
425
  },
351
- []
426
+ [] as React.ReactElement[],
352
427
  );
353
428
 
354
429
  const labelComponents = this.dataKeys
@@ -356,7 +431,7 @@ export default (WrappedComponent, options) => {
356
431
  const labelProps = this.getComponentProps(
357
432
  labelComponent,
358
433
  "labels",
359
- index
434
+ index,
360
435
  );
361
436
  if (labelProps.text !== undefined && labelProps.text !== null) {
362
437
  return React.cloneElement(labelComponent, labelProps);
@@ -368,5 +443,7 @@ export default (WrappedComponent, options) => {
368
443
  const children = [...dataComponents, ...labelComponents];
369
444
  return this.renderContainer(groupComponent, children);
370
445
  }
371
- };
372
- };
446
+ }
447
+
448
+ return AddEventsMixin;
449
+ }
@@ -11,11 +11,12 @@ import {
11
11
  orderBy,
12
12
  values,
13
13
  includes,
14
- without
14
+ without,
15
15
  } from "lodash";
16
16
  import * as Collection from "./collection";
17
17
  import * as Domain from "./domain";
18
18
  import * as Helpers from "./helpers";
19
+ import { D3Scale } from "../types/prop-types";
19
20
 
20
21
  /**
21
22
  * Returns the axis (x or y) of a particular axis component
@@ -34,7 +35,7 @@ export function getAxis(props) {
34
35
  * @param {Function} predicate: a predicate function that will be called with each
35
36
  * @returns {Array} all axis components that pass the given predicate or []
36
37
  */
37
- export function findAxisComponents(childComponents, predicate) {
38
+ export function findAxisComponents(childComponents, predicate?) {
38
39
  predicate = predicate || identity;
39
40
  const findAxes = (children) => {
40
41
  return children.reduce((memo, child) => {
@@ -42,7 +43,7 @@ export function findAxisComponents(childComponents, predicate) {
42
43
  return memo.concat(child);
43
44
  } else if (child.props && child.props.children) {
44
45
  return memo.concat(
45
- findAxes(React.Children.toArray(child.props.children))
46
+ findAxes(React.Children.toArray(child.props.children)),
46
47
  );
47
48
  }
48
49
  return memo;
@@ -86,7 +87,7 @@ export function getAxisComponentsWithParent(childComponents, type) {
86
87
  return memo.concat(child);
87
88
  } else if (child.props && child.props.children) {
88
89
  const childAxis = findComponents(
89
- React.Children.toArray(child.props.children)
90
+ React.Children.toArray(child.props.children),
90
91
  );
91
92
  return childAxis.length > 0 ? memo.concat(child) : memo;
92
93
  }
@@ -110,7 +111,7 @@ export function getOrigin(domain) {
110
111
  : getSingleOrigin(domain.x),
111
112
  y: Collection.containsDates(domain.y)
112
113
  ? new Date(Math.min(...domain.y))
113
- : getSingleOrigin(domain.y)
114
+ : getSingleOrigin(domain.y),
114
115
  };
115
116
  }
116
117
 
@@ -201,9 +202,9 @@ function getTickArray(props) {
201
202
  ? tickValues.map((tick) => stringMap[tick])
202
203
  : range(1, tickValues.length + 1);
203
204
  }
204
- const tickArray = ticks ? uniq(ticks) : getTicksFromFormat(props);
205
- const buildTickArray = (arr) => {
206
- const newTickArray = [];
205
+ const tickArray = ticks ? uniq(ticks) : getTicksFromFormat();
206
+ const buildTickArray = (arr: number[]) => {
207
+ const newTickArray = [] as Array<{ value: number; index: number }>;
207
208
  const domain = (props.domain && props.domain[axis]) || props.domain;
208
209
  if (arr) {
209
210
  arr.forEach(function (t, index) {
@@ -214,13 +215,13 @@ function getTickArray(props) {
214
215
  ) {
215
216
  newTickArray.push({
216
217
  value: t,
217
- index
218
+ index,
218
219
  });
219
220
  }
220
221
  } else {
221
222
  newTickArray.push({
222
223
  value: t,
223
- index
224
+ index,
224
225
  });
225
226
  }
226
227
  });
@@ -248,11 +249,9 @@ export function getTickFormat(props, scale) {
248
249
  return defaultTickFormat || scaleTickFormat;
249
250
  } else if (tickFormat && Array.isArray(tickFormat)) {
250
251
  const tickArray = getTickArray(props);
251
- const tickArrayIndices = tickArray
252
- ? tickArray.map((v) => v.index)
253
- : undefined;
252
+ const tickArrayIndices = tickArray?.map((v) => v.index);
254
253
  const filteredTickFormat = tickFormat.filter((t, index) =>
255
- tickArrayIndices.includes(index)
254
+ tickArrayIndices?.includes(index),
256
255
  );
257
256
  return (x, index) => filteredTickFormat[index];
258
257
  } else if (tickFormat && isFunction(tickFormat)) {
@@ -267,7 +266,7 @@ export function getTickFormat(props, scale) {
267
266
  }
268
267
  }
269
268
 
270
- function downsampleTicks(ticks, tickCount) {
269
+ function downsampleTicks(ticks: number[], tickCount: number) {
271
270
  if (!tickCount || !Array.isArray(ticks) || ticks.length <= tickCount) {
272
271
  return ticks;
273
272
  }
@@ -275,7 +274,7 @@ function downsampleTicks(ticks, tickCount) {
275
274
  return ticks.filter((d, i) => i % k === 0);
276
275
  }
277
276
 
278
- export function getTicks(props, scale, filterZero) {
277
+ export function getTicks(props, scale: D3Scale, filterZero = false) {
279
278
  const { tickCount } = props;
280
279
  const tickArray = getTickArray(props);
281
280
  const tickValues = tickArray ? tickArray.map((v) => v.value) : undefined;
@@ -335,7 +334,7 @@ function getDomainFromData(props, axis) {
335
334
  }
336
335
 
337
336
  // exposed for use by VictoryChart
338
- export function getDomain(props, axis) {
337
+ export function getDomain(props, axis?) {
339
338
  const inherentAxis = getAxis(props);
340
339
  if (axis && axis !== inherentAxis) {
341
340
  return undefined;
@@ -382,6 +381,6 @@ export function modifyProps(props, fallbackProps) {
382
381
  return Helpers.modifyProps(
383
382
  assign({}, props, { theme }),
384
383
  fallbackProps,
385
- "axis"
384
+ "axis",
386
385
  );
387
386
  }
@@ -1,17 +1,15 @@
1
- /* eslint-disable no-use-before-define */
2
-
3
1
  function isNonEmptyArray(collection) {
4
2
  return Array.isArray(collection) && collection.length > 0;
5
3
  }
6
4
 
7
- export function containsStrings(collection) {
5
+ export function containsStrings<T>(collection: Array<T>) {
8
6
  return (
9
7
  Array.isArray(collection) &&
10
8
  collection.some((value) => typeof value === "string")
11
9
  );
12
10
  }
13
11
 
14
- export function containsDates(collection) {
12
+ export function containsDates(collection: Array<number | Date>): boolean {
15
13
  return (
16
14
  Array.isArray(collection) &&
17
15
  collection.some((value) => value instanceof Date)
@@ -40,16 +38,22 @@ export function removeUndefined(arr) {
40
38
  return arr.filter((el) => el !== undefined);
41
39
  }
42
40
 
43
- export function getMaxValue(arr, ...values) {
44
- const array = arr.concat(values);
41
+ export function getMaxValue(
42
+ arr: Array<number | Date>,
43
+ ...values: Array<number | Date>
44
+ ): number | Date {
45
+ const array = arr.concat(values) as number[];
45
46
  return containsDates(array)
46
- ? new Date(Math.max(...array))
47
+ ? new Date(Math.max(...array)) // Dates will be coerced to numbers
47
48
  : Math.max(...array);
48
49
  }
49
50
 
50
- export function getMinValue(arr, ...values) {
51
- const array = arr.concat(values);
51
+ export function getMinValue(
52
+ arr: Array<number | Date>,
53
+ ...values: Array<number | Date>
54
+ ): number | Date {
55
+ const array = arr.concat(values) as number[];
52
56
  return containsDates(array)
53
- ? new Date(Math.min(...array))
57
+ ? new Date(Math.min(...array)) // Dates will be coerced to numbers
54
58
  : Math.min(...array);
55
59
  }