victory-core 36.4.0 → 36.5.1
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.
- package/dist/victory-core.js +45735 -12154
- package/dist/victory-core.min.js +2 -1
- package/dist/victory-core.min.js.LICENSE.txt +19 -0
- package/es/index.d.ts +18 -941
- package/es/index.js +18 -73
- package/es/types/callbacks.d.ts +37 -0
- package/es/types/callbacks.js +2 -0
- package/es/types/prop-types.d.ts +130 -0
- package/es/types/prop-types.js +2 -0
- package/es/victory-accessible-group/victory-accessible-group.d.ts +26 -0
- package/es/victory-accessible-group/victory-accessible-group.js +9 -16
- package/es/victory-animation/util.d.ts +67 -0
- package/es/victory-animation/util.js +7 -4
- package/es/victory-animation/victory-animation.d.ts +70 -0
- package/es/victory-animation/victory-animation.js +60 -67
- package/es/victory-clip-container/victory-clip-container.d.ts +77 -0
- package/es/victory-clip-container/victory-clip-container.js +19 -23
- package/es/victory-container/victory-container.d.ts +100 -0
- package/es/victory-container/victory-container.js +32 -31
- package/es/victory-label/victory-label.d.ts +62 -0
- package/es/victory-label/victory-label.js +17 -10
- package/es/victory-portal/portal-context.d.ts +12 -0
- package/es/victory-portal/portal-context.js +3 -3
- package/es/victory-portal/portal.d.ts +29 -0
- package/es/victory-portal/portal.js +26 -33
- package/es/victory-portal/victory-portal.d.ts +32 -0
- package/es/victory-portal/victory-portal.js +24 -22
- package/es/victory-primitives/arc.d.ts +50 -0
- package/es/victory-primitives/arc.js +4 -5
- package/es/victory-primitives/background.d.ts +51 -0
- package/es/victory-primitives/background.js +5 -6
- package/es/victory-primitives/border.d.ts +44 -0
- package/es/victory-primitives/border.js +4 -5
- package/es/victory-primitives/circle.d.ts +3 -0
- package/es/victory-primitives/circle.js +11 -7
- package/es/victory-primitives/clip-path.d.ts +15 -0
- package/es/victory-primitives/clip-path.js +6 -5
- package/es/victory-primitives/index.d.ts +15 -0
- package/es/victory-primitives/index.js +15 -0
- package/es/victory-primitives/line-segment.d.ts +46 -0
- package/es/victory-primitives/line-segment.js +4 -5
- package/es/victory-primitives/line.d.ts +3 -0
- package/es/victory-primitives/line.js +11 -7
- package/es/victory-primitives/path.d.ts +3 -0
- package/es/victory-primitives/path.js +9 -5
- package/es/victory-primitives/point.d.ts +49 -0
- package/es/victory-primitives/point.js +10 -19
- package/es/victory-primitives/rect.d.ts +3 -0
- package/es/victory-primitives/rect.js +11 -7
- package/es/victory-primitives/text.d.ts +17 -0
- package/es/victory-primitives/text.js +7 -5
- package/es/victory-primitives/tspan.d.ts +3 -0
- package/es/victory-primitives/tspan.js +7 -5
- package/es/victory-primitives/types.d.ts +8 -0
- package/es/victory-primitives/types.js +2 -0
- package/es/victory-primitives/whisker.d.ts +59 -0
- package/es/victory-primitives/whisker.js +4 -5
- package/es/victory-state/defaults.d.ts +3 -0
- package/es/victory-state/defaults.js +3 -0
- package/es/victory-state/helpers/get-axis-data.d.ts +3 -0
- package/es/victory-state/helpers/get-axis-data.js +15 -0
- package/es/victory-state/helpers/get-data.d.ts +15 -0
- package/es/victory-state/helpers/get-data.js +88 -0
- package/es/victory-state/helpers/get-domain.d.ts +6 -0
- package/es/victory-state/helpers/get-domain.js +68 -0
- package/es/victory-state/helpers/get-range.d.ts +6 -0
- package/es/victory-state/helpers/get-range.js +37 -0
- package/es/victory-state/helpers/get-scale.d.ts +6 -0
- package/es/victory-state/helpers/get-scale.js +59 -0
- package/es/victory-state/index.d.ts +3 -0
- package/es/victory-state/index.js +3 -0
- package/es/victory-state/types.d.ts +24 -0
- package/es/victory-state/types.js +2 -0
- package/es/victory-state/victory-provider.d.ts +19 -0
- package/es/victory-state/victory-provider.js +118 -0
- package/es/victory-theme/grayscale.d.ts +3 -0
- package/es/victory-theme/grayscale.js +3 -2
- package/es/victory-theme/material.d.ts +3 -0
- package/es/victory-theme/material.js +3 -2
- package/es/victory-theme/types.d.ts +239 -0
- package/es/victory-theme/types.js +2 -0
- package/es/victory-theme/victory-theme.d.ts +6 -0
- package/es/victory-theme/victory-theme.js +8 -6
- package/es/victory-transition/victory-transition.d.ts +60 -0
- package/es/victory-transition/victory-transition.js +20 -23
- package/es/victory-util/add-events.d.ts +106 -0
- package/es/victory-util/add-events.js +45 -38
- package/es/victory-util/axis.d.ts +51 -0
- package/es/victory-util/axis.js +9 -8
- package/es/victory-util/collection.d.ts +9 -0
- package/es/victory-util/collection.js +6 -6
- package/es/victory-util/common-props.d.ts +84 -0
- package/es/victory-util/common-props.js +31 -14
- package/es/victory-util/data.d.ts +75 -0
- package/es/victory-util/data.js +2 -3
- package/es/victory-util/default-transitions.d.ts +5 -0
- package/es/victory-util/default-transitions.js +2 -2
- package/es/victory-util/domain.d.ts +91 -0
- package/es/victory-util/domain.js +6 -4
- package/es/victory-util/events.d.ts +65 -0
- package/es/victory-util/events.js +13 -8
- package/es/victory-util/helpers.d.ts +61 -0
- package/es/victory-util/helpers.js +8 -6
- package/es/victory-util/hooks/index.d.ts +3 -0
- package/es/victory-util/hooks/index.js +2 -1
- package/es/victory-util/hooks/use-animation-state.js +2 -1
- package/es/victory-util/hooks/use-previous-props.d.ts +2 -0
- package/es/victory-util/hooks/use-previous-props.js +4 -3
- package/es/victory-util/immutable.d.ts +12 -0
- package/es/victory-util/immutable.js +5 -5
- package/es/victory-util/index.d.ts +29 -0
- package/es/victory-util/index.js +48 -0
- package/es/victory-util/label-helpers.d.ts +27 -0
- package/es/victory-util/label-helpers.js +2 -3
- package/es/victory-util/line-helpers.d.ts +5 -0
- package/es/victory-util/line-helpers.js +24 -6
- package/es/victory-util/log.d.ts +2 -0
- package/es/victory-util/log.js +2 -2
- package/es/victory-util/point-path-helpers.d.ts +10 -0
- package/es/victory-util/point-path-helpers.js +60 -61
- package/es/victory-util/prop-types.d.ts +51 -0
- package/es/victory-util/prop-types.js +35 -44
- package/es/victory-util/scale.d.ts +10 -0
- package/es/victory-util/scale.js +14 -6
- package/es/victory-util/selection.d.ts +25 -0
- package/es/victory-util/selection.js +25 -16
- package/es/victory-util/style.d.ts +19 -0
- package/es/victory-util/style.js +2 -3
- package/es/victory-util/textsize.d.ts +37 -0
- package/es/victory-util/textsize.js +9 -6
- package/es/victory-util/timer-context.d.ts +12 -0
- package/es/victory-util/timer-context.js +2 -1
- package/es/victory-util/timer.d.ts +17 -0
- package/es/victory-util/timer.js +15 -9
- package/es/victory-util/transitions.d.ts +49 -0
- package/es/victory-util/transitions.js +5 -4
- package/es/victory-util/type-helpers.d.ts +10 -0
- package/es/victory-util/type-helpers.js +28 -0
- package/es/victory-util/user-props.d.ts +21 -0
- package/es/victory-util/user-props.js +17 -3
- package/es/victory-util/with-container.d.ts +5 -0
- package/es/victory-util/with-container.js +32 -0
- package/es/victory-util/wrapper.d.ts +38 -0
- package/es/victory-util/wrapper.js +4 -3
- package/lib/index.d.ts +18 -941
- package/lib/index.js +224 -311
- package/lib/types/callbacks.d.ts +37 -0
- package/lib/types/callbacks.js +2 -0
- package/lib/types/prop-types.d.ts +130 -0
- package/lib/types/prop-types.js +2 -0
- package/lib/victory-accessible-group/victory-accessible-group.d.ts +26 -0
- package/lib/victory-accessible-group/victory-accessible-group.js +10 -15
- package/lib/victory-animation/util.d.ts +67 -0
- package/lib/victory-animation/util.js +7 -4
- package/lib/victory-animation/victory-animation.d.ts +70 -0
- package/lib/victory-animation/victory-animation.js +61 -65
- package/lib/victory-clip-container/victory-clip-container.d.ts +77 -0
- package/lib/victory-clip-container/victory-clip-container.js +24 -24
- package/lib/victory-container/victory-container.d.ts +100 -0
- package/lib/victory-container/victory-container.js +35 -31
- package/lib/victory-label/victory-label.d.ts +62 -0
- package/lib/victory-label/victory-label.js +24 -15
- package/lib/victory-portal/portal-context.d.ts +12 -0
- package/lib/victory-portal/portal-context.js +3 -3
- package/lib/victory-portal/portal.d.ts +29 -0
- package/lib/victory-portal/portal.js +27 -31
- package/lib/victory-portal/victory-portal.d.ts +32 -0
- package/lib/victory-portal/victory-portal.js +25 -20
- package/lib/victory-primitives/arc.d.ts +50 -0
- package/lib/victory-primitives/arc.js +7 -7
- package/lib/victory-primitives/background.d.ts +51 -0
- package/lib/victory-primitives/background.js +9 -9
- package/lib/victory-primitives/border.d.ts +44 -0
- package/lib/victory-primitives/border.js +7 -7
- package/lib/victory-primitives/circle.d.ts +3 -0
- package/lib/victory-primitives/circle.js +12 -6
- package/lib/victory-primitives/clip-path.d.ts +15 -0
- package/lib/victory-primitives/clip-path.js +7 -4
- package/lib/victory-primitives/index.d.ts +15 -0
- package/lib/victory-primitives/index.js +188 -0
- package/lib/victory-primitives/line-segment.d.ts +46 -0
- package/lib/victory-primitives/line-segment.js +7 -7
- package/lib/victory-primitives/line.d.ts +3 -0
- package/lib/victory-primitives/line.js +12 -6
- package/lib/victory-primitives/path.d.ts +3 -0
- package/lib/victory-primitives/path.js +10 -4
- package/lib/victory-primitives/point.d.ts +49 -0
- package/lib/victory-primitives/point.js +15 -22
- package/lib/victory-primitives/rect.d.ts +3 -0
- package/lib/victory-primitives/rect.js +12 -6
- package/lib/victory-primitives/text.d.ts +17 -0
- package/lib/victory-primitives/text.js +8 -4
- package/lib/victory-primitives/tspan.d.ts +3 -0
- package/lib/victory-primitives/tspan.js +8 -4
- package/lib/victory-primitives/types.d.ts +8 -0
- package/lib/victory-primitives/types.js +2 -0
- package/lib/victory-primitives/whisker.d.ts +59 -0
- package/lib/victory-primitives/whisker.js +7 -7
- package/lib/victory-state/defaults.d.ts +3 -0
- package/lib/victory-state/defaults.js +11 -0
- package/lib/victory-state/helpers/get-axis-data.d.ts +3 -0
- package/lib/victory-state/helpers/get-axis-data.js +23 -0
- package/lib/victory-state/helpers/get-data.d.ts +15 -0
- package/lib/victory-state/helpers/get-data.js +99 -0
- package/lib/victory-state/helpers/get-domain.d.ts +6 -0
- package/lib/victory-state/helpers/get-domain.js +82 -0
- package/lib/victory-state/helpers/get-range.d.ts +6 -0
- package/lib/victory-state/helpers/get-range.js +46 -0
- package/lib/victory-state/helpers/get-scale.d.ts +6 -0
- package/lib/victory-state/helpers/get-scale.js +74 -0
- package/lib/victory-state/index.d.ts +3 -0
- package/lib/victory-state/index.js +32 -0
- package/lib/victory-state/types.d.ts +24 -0
- package/lib/victory-state/types.js +2 -0
- package/lib/victory-state/victory-provider.d.ts +19 -0
- package/lib/victory-state/victory-provider.js +146 -0
- package/lib/victory-theme/grayscale.d.ts +3 -0
- package/lib/victory-theme/grayscale.js +4 -3
- package/lib/victory-theme/material.d.ts +3 -0
- package/lib/victory-theme/material.js +4 -3
- package/lib/victory-theme/types.d.ts +239 -0
- package/lib/victory-theme/types.js +2 -0
- package/lib/victory-theme/victory-theme.d.ts +6 -0
- package/lib/victory-theme/victory-theme.js +23 -8
- package/lib/victory-transition/victory-transition.d.ts +60 -0
- package/lib/victory-transition/victory-transition.js +22 -23
- package/lib/victory-util/add-events.d.ts +106 -0
- package/lib/victory-util/add-events.js +49 -47
- package/lib/victory-util/axis.d.ts +51 -0
- package/lib/victory-util/axis.js +8 -6
- package/lib/victory-util/collection.d.ts +9 -0
- package/lib/victory-util/collection.js +6 -6
- package/lib/victory-util/common-props.d.ts +84 -0
- package/lib/victory-util/common-props.js +29 -14
- package/lib/victory-util/data.d.ts +75 -0
- package/lib/victory-util/data.js +2 -1
- package/lib/victory-util/default-transitions.d.ts +5 -0
- package/lib/victory-util/default-transitions.js +2 -2
- package/lib/victory-util/domain.d.ts +91 -0
- package/lib/victory-util/domain.js +6 -2
- package/lib/victory-util/events.d.ts +65 -0
- package/lib/victory-util/events.js +13 -9
- package/lib/victory-util/helpers.d.ts +61 -0
- package/lib/victory-util/helpers.js +8 -6
- package/lib/victory-util/hooks/index.d.ts +3 -0
- package/lib/victory-util/hooks/index.js +2 -1
- package/lib/victory-util/hooks/use-animation-state.js +2 -1
- package/lib/victory-util/hooks/use-previous-props.d.ts +2 -0
- package/lib/victory-util/hooks/use-previous-props.js +5 -6
- package/lib/victory-util/immutable.d.ts +12 -0
- package/lib/victory-util/immutable.js +5 -6
- package/lib/victory-util/index.d.ts +29 -0
- package/lib/victory-util/index.js +181 -0
- package/lib/victory-util/label-helpers.d.ts +27 -0
- package/lib/victory-util/label-helpers.js +2 -3
- package/lib/victory-util/line-helpers.d.ts +5 -0
- package/lib/victory-util/line-helpers.js +28 -7
- package/lib/victory-util/log.d.ts +2 -0
- package/lib/victory-util/log.js +2 -2
- package/lib/victory-util/point-path-helpers.d.ts +10 -0
- package/lib/victory-util/point-path-helpers.js +87 -73
- package/lib/victory-util/prop-types.d.ts +51 -0
- package/lib/victory-util/prop-types.js +36 -44
- package/lib/victory-util/scale.d.ts +10 -0
- package/lib/victory-util/scale.js +14 -5
- package/lib/victory-util/selection.d.ts +25 -0
- package/lib/victory-util/selection.js +25 -21
- package/lib/victory-util/style.d.ts +19 -0
- package/lib/victory-util/style.js +2 -3
- package/lib/victory-util/textsize.d.ts +37 -0
- package/lib/victory-util/textsize.js +9 -6
- package/lib/victory-util/timer-context.d.ts +12 -0
- package/lib/victory-util/timer-context.js +2 -1
- package/lib/victory-util/timer.d.ts +17 -0
- package/lib/victory-util/timer.js +15 -9
- package/lib/victory-util/transitions.d.ts +49 -0
- package/lib/victory-util/transitions.js +5 -4
- package/lib/victory-util/type-helpers.d.ts +10 -0
- package/lib/victory-util/type-helpers.js +45 -0
- package/lib/victory-util/user-props.d.ts +21 -0
- package/lib/victory-util/user-props.js +25 -4
- package/lib/victory-util/with-container.d.ts +5 -0
- package/lib/victory-util/with-container.js +44 -0
- package/lib/victory-util/wrapper.d.ts +38 -0
- package/lib/victory-util/wrapper.js +4 -3
- package/package.json +6 -6
- package/src/index.ts +17 -0
- package/src/types/callbacks.ts +53 -0
- package/src/types/prop-types.ts +195 -0
- package/src/victory-accessible-group/{victory-accessible-group.js → victory-accessible-group.tsx} +13 -6
- package/src/victory-animation/{util.js → util.ts} +6 -4
- package/src/victory-animation/{victory-animation.js → victory-animation.tsx} +100 -23
- package/src/victory-clip-container/{victory-clip-container.js → victory-clip-container.tsx} +55 -29
- package/src/victory-container/{victory-container.js → victory-container.tsx} +86 -42
- package/src/victory-label/{victory-label.js → victory-label.tsx} +112 -49
- package/src/victory-portal/portal-context.ts +14 -0
- package/src/victory-portal/{portal.js → portal.tsx} +24 -13
- package/src/victory-portal/{victory-portal.js → victory-portal.tsx} +24 -9
- package/src/victory-primitives/{arc.js → arc.tsx} +22 -10
- package/src/victory-primitives/{background.js → background.tsx} +24 -12
- package/src/victory-primitives/{border.js → border.tsx} +19 -10
- package/src/victory-primitives/{circle.js → circle.tsx} +4 -3
- package/src/victory-primitives/clip-path.tsx +25 -0
- package/src/victory-primitives/index.ts +14 -0
- package/src/victory-primitives/{line-segment.js → line-segment.tsx} +20 -10
- package/src/victory-primitives/{line.js → line.tsx} +4 -3
- package/src/victory-primitives/{path.js → path.tsx} +4 -3
- package/src/victory-primitives/{point.js → point.tsx} +33 -26
- package/src/victory-primitives/{rect.js → rect.tsx} +4 -2
- package/src/victory-primitives/{text.js → text.tsx} +10 -4
- package/src/victory-primitives/tspan.tsx +7 -0
- package/src/victory-primitives/types.ts +19 -0
- package/src/victory-primitives/{whisker.js → whisker.tsx} +34 -19
- package/src/victory-state/defaults.ts +2 -0
- package/src/victory-state/helpers/get-axis-data.ts +14 -0
- package/src/victory-state/helpers/get-data.ts +79 -0
- package/src/victory-state/helpers/get-domain.ts +62 -0
- package/src/victory-state/helpers/get-range.ts +39 -0
- package/src/victory-state/helpers/get-scale.ts +64 -0
- package/src/victory-state/index.ts +2 -0
- package/src/victory-state/types.ts +32 -0
- package/src/victory-state/victory-provider.tsx +121 -0
- package/src/victory-theme/{grayscale.js → grayscale.tsx} +63 -62
- package/src/victory-theme/{material.js → material.tsx} +68 -67
- package/src/victory-theme/types.ts +257 -0
- package/src/victory-theme/victory-theme.tsx +5 -0
- package/src/victory-transition/{victory-transition.js → victory-transition.tsx} +82 -33
- package/src/victory-util/{add-events.js → add-events.tsx} +143 -64
- package/src/victory-util/{axis.js → axis.tsx} +17 -19
- package/src/victory-util/{collection.js → collection.tsx} +14 -11
- package/src/victory-util/common-props.tsx +307 -0
- package/src/victory-util/{data.js → data.ts} +14 -11
- package/src/victory-util/{default-transitions.js → default-transitions.ts} +20 -19
- package/src/victory-util/{domain.js → domain.ts} +26 -24
- package/src/victory-util/{events.js → events.ts} +83 -32
- package/src/victory-util/{helpers.js → helpers.ts} +41 -23
- package/src/victory-util/hooks/{index.js → index.ts} +0 -0
- package/src/victory-util/hooks/use-animation-state.js +10 -10
- package/src/victory-util/hooks/use-previous-props.ts +9 -0
- package/src/victory-util/{immutable.js → immutable.ts} +14 -11
- package/src/victory-util/index.ts +28 -0
- package/src/victory-util/{label-helpers.js → label-helpers.ts} +7 -8
- package/src/victory-util/line-helpers.ts +104 -0
- package/src/victory-util/{log.js → log.ts} +1 -2
- package/src/victory-util/point-path-helpers.ts +119 -0
- package/src/victory-util/{prop-types.js → prop-types.ts} +103 -102
- package/src/victory-util/{scale.js → scale.ts} +29 -17
- package/src/victory-util/selection.ts +158 -0
- package/src/victory-util/{style.js → style.ts} +3 -4
- package/src/victory-util/{textsize.js → textsize.ts} +32 -17
- package/src/victory-util/{timer-context.js → timer-context.ts} +1 -1
- package/src/victory-util/{timer.js → timer.ts} +16 -6
- package/src/victory-util/{transitions.js → transitions.ts} +50 -23
- package/src/victory-util/type-helpers.ts +50 -0
- package/src/victory-util/{user-props.js → user-props.ts} +26 -8
- package/src/victory-util/with-container.tsx +41 -0
- package/src/victory-util/{wrapper.js → wrapper.tsx} +38 -34
- package/src/index.d.ts +0 -941
- package/src/index.js +0 -51
- package/src/victory-portal/portal-context.js +0 -10
- package/src/victory-primitives/clip-path.js +0 -18
- package/src/victory-primitives/tspan.js +0 -5
- package/src/victory-theme/victory-theme.js +0 -7
- package/src/victory-util/common-props.js +0 -197
- package/src/victory-util/hooks/use-previous-props.js +0 -9
- package/src/victory-util/line-helpers.js +0 -54
- package/src/victory-util/point-path-helpers.js +0 -121
- package/src/victory-util/selection.js +0 -99
|
@@ -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
|
-
|
|
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 = {
|
|
@@ -54,19 +131,24 @@ export default class VictoryAnimation extends React.Component {
|
|
|
54
131
|
"sin",
|
|
55
132
|
"sinIn",
|
|
56
133
|
"sinOut",
|
|
57
|
-
"sinInOut"
|
|
134
|
+
"sinInOut",
|
|
58
135
|
]),
|
|
59
|
-
onEnd: PropTypes.func
|
|
136
|
+
onEnd: PropTypes.func,
|
|
60
137
|
};
|
|
61
138
|
|
|
62
139
|
static defaultProps = {
|
|
63
140
|
data: {},
|
|
64
141
|
delay: 0,
|
|
65
142
|
duration: 1000,
|
|
66
|
-
easing: "quadInOut"
|
|
143
|
+
easing: "quadInOut",
|
|
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);
|
|
@@ -77,18 +159,13 @@ export default class VictoryAnimation extends React.Component {
|
|
|
77
159
|
: this.props.data,
|
|
78
160
|
animationInfo: {
|
|
79
161
|
progress: 0,
|
|
80
|
-
animating: false
|
|
81
|
-
}
|
|
162
|
+
animating: false,
|
|
163
|
+
},
|
|
82
164
|
};
|
|
83
165
|
this.interpolator = null;
|
|
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
|
|
|
@@ -114,8 +191,8 @@ export default class VictoryAnimation extends React.Component {
|
|
|
114
191
|
animationInfo: {
|
|
115
192
|
progress: 1,
|
|
116
193
|
animating: false,
|
|
117
|
-
terminating: true
|
|
118
|
-
}
|
|
194
|
+
terminating: true,
|
|
195
|
+
},
|
|
119
196
|
});
|
|
120
197
|
} else {
|
|
121
198
|
/* cancel existing loop if it exists */
|
|
@@ -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,12 +263,12 @@ 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,
|
|
193
|
-
terminating: true
|
|
194
|
-
}
|
|
270
|
+
terminating: true,
|
|
271
|
+
},
|
|
195
272
|
});
|
|
196
273
|
if (this.loopID) {
|
|
197
274
|
this.timer.unsubscribe(this.loopID);
|
|
@@ -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
|
-
animating: step < 1
|
|
213
|
-
}
|
|
289
|
+
animating: step < 1,
|
|
290
|
+
},
|
|
214
291
|
});
|
|
215
|
-
}
|
|
292
|
+
};
|
|
216
293
|
|
|
217
294
|
render() {
|
|
218
295
|
return this.props.children(this.state.data, this.state.animationInfo);
|
|
@@ -2,19 +2,43 @@ import React from "react";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import * as CustomPropTypes from "../victory-util/prop-types";
|
|
4
4
|
import * as Helpers from "../victory-util/helpers";
|
|
5
|
+
import * as UserProps from "../victory-util/user-props";
|
|
5
6
|
import { assign, defaults, isObject, uniqueId } from "lodash";
|
|
6
|
-
import ClipPath from "../victory-primitives/clip-path";
|
|
7
|
-
import Circle from "../victory-primitives/circle";
|
|
8
|
-
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";
|
|
9
10
|
|
|
10
|
-
|
|
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> {
|
|
11
35
|
static displayName = "VictoryClipContainer";
|
|
12
36
|
static role = "container";
|
|
13
37
|
static propTypes = {
|
|
14
38
|
"aria-label": PropTypes.string,
|
|
15
39
|
children: PropTypes.oneOfType([
|
|
16
40
|
PropTypes.arrayOf(PropTypes.node),
|
|
17
|
-
PropTypes.node
|
|
41
|
+
PropTypes.node,
|
|
18
42
|
]),
|
|
19
43
|
circleComponent: PropTypes.element,
|
|
20
44
|
className: PropTypes.string,
|
|
@@ -24,7 +48,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
24
48
|
top: PropTypes.number,
|
|
25
49
|
bottom: PropTypes.number,
|
|
26
50
|
left: PropTypes.number,
|
|
27
|
-
right: PropTypes.number
|
|
51
|
+
right: PropTypes.number,
|
|
28
52
|
}),
|
|
29
53
|
clipPathComponent: PropTypes.element,
|
|
30
54
|
clipWidth: CustomPropTypes.nonNegative,
|
|
@@ -32,7 +56,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
32
56
|
groupComponent: PropTypes.element,
|
|
33
57
|
origin: PropTypes.shape({
|
|
34
58
|
x: CustomPropTypes.nonNegative,
|
|
35
|
-
y: CustomPropTypes.nonNegative
|
|
59
|
+
y: CustomPropTypes.nonNegative,
|
|
36
60
|
}),
|
|
37
61
|
polar: PropTypes.bool,
|
|
38
62
|
radius: CustomPropTypes.nonNegative,
|
|
@@ -40,17 +64,18 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
40
64
|
tabIndex: PropTypes.number,
|
|
41
65
|
transform: PropTypes.string,
|
|
42
66
|
translateX: PropTypes.number,
|
|
43
|
-
translateY: PropTypes.number
|
|
67
|
+
translateY: PropTypes.number,
|
|
44
68
|
};
|
|
45
69
|
|
|
46
70
|
static defaultProps = {
|
|
47
71
|
circleComponent: <Circle />,
|
|
48
72
|
rectComponent: <Rect />,
|
|
49
73
|
clipPathComponent: <ClipPath />,
|
|
50
|
-
groupComponent: <g
|
|
74
|
+
groupComponent: <g />,
|
|
51
75
|
};
|
|
76
|
+
private clipId: VictoryClipContainerProps["clipId"];
|
|
52
77
|
|
|
53
|
-
constructor(props) {
|
|
78
|
+
constructor(props: VictoryClipContainerProps) {
|
|
54
79
|
super(props);
|
|
55
80
|
this.clipId =
|
|
56
81
|
!isObject(props) || props.clipId === undefined
|
|
@@ -65,7 +90,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
65
90
|
clipWidth = 0,
|
|
66
91
|
clipHeight = 0,
|
|
67
92
|
translateX = 0,
|
|
68
|
-
translateY = 0
|
|
93
|
+
translateY = 0,
|
|
69
94
|
} = props;
|
|
70
95
|
const clipPadding = Helpers.getPadding({ padding: props.clipPadding });
|
|
71
96
|
const radius = props.radius || Helpers.getRadius(props);
|
|
@@ -74,16 +99,17 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
74
99
|
y: (polar ? origin.y : translateY) - clipPadding.top,
|
|
75
100
|
width: Math.max(
|
|
76
101
|
(polar ? radius : clipWidth) + clipPadding.left + clipPadding.right,
|
|
77
|
-
0
|
|
102
|
+
0,
|
|
78
103
|
),
|
|
79
104
|
height: Math.max(
|
|
80
105
|
(polar ? radius : clipHeight) + clipPadding.top + clipPadding.bottom,
|
|
81
|
-
0
|
|
82
|
-
)
|
|
106
|
+
0,
|
|
107
|
+
),
|
|
83
108
|
};
|
|
84
109
|
}
|
|
85
110
|
|
|
86
111
|
renderClippedGroup(props, clipId) {
|
|
112
|
+
const userProps = UserProps.getSafeUserProps(props);
|
|
87
113
|
const {
|
|
88
114
|
style,
|
|
89
115
|
events,
|
|
@@ -91,7 +117,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
91
117
|
children,
|
|
92
118
|
className,
|
|
93
119
|
groupComponent,
|
|
94
|
-
tabIndex
|
|
120
|
+
tabIndex,
|
|
95
121
|
} = props;
|
|
96
122
|
const clipComponent = this.renderClipComponent(props, clipId);
|
|
97
123
|
const groupProps = assign(
|
|
@@ -100,14 +126,14 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
100
126
|
style,
|
|
101
127
|
transform,
|
|
102
128
|
key: `clipped-group-${clipId}`,
|
|
103
|
-
clipPath: `url(#${clipId})
|
|
129
|
+
clipPath: `url(#${clipId})`,
|
|
104
130
|
},
|
|
105
|
-
events
|
|
131
|
+
events,
|
|
106
132
|
);
|
|
107
133
|
return React.cloneElement(
|
|
108
134
|
groupComponent,
|
|
109
|
-
{ ...groupProps,
|
|
110
|
-
[clipComponent, ...React.Children.toArray(children)]
|
|
135
|
+
{ ...groupProps, tabIndex, ...userProps },
|
|
136
|
+
[clipComponent, ...React.Children.toArray(children)],
|
|
111
137
|
);
|
|
112
138
|
}
|
|
113
139
|
|
|
@@ -119,7 +145,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
119
145
|
children,
|
|
120
146
|
className,
|
|
121
147
|
groupComponent,
|
|
122
|
-
tabIndex
|
|
148
|
+
tabIndex,
|
|
123
149
|
} = props;
|
|
124
150
|
return React.cloneElement(
|
|
125
151
|
groupComponent,
|
|
@@ -129,11 +155,11 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
129
155
|
style,
|
|
130
156
|
transform,
|
|
131
157
|
"aria-label": props["aria-label"],
|
|
132
|
-
tabIndex
|
|
158
|
+
tabIndex,
|
|
133
159
|
},
|
|
134
|
-
events
|
|
160
|
+
events,
|
|
135
161
|
),
|
|
136
|
-
children
|
|
162
|
+
children,
|
|
137
163
|
);
|
|
138
164
|
}
|
|
139
165
|
|
|
@@ -147,10 +173,10 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
147
173
|
translateY = 0,
|
|
148
174
|
circleComponent,
|
|
149
175
|
rectComponent,
|
|
150
|
-
clipPathComponent
|
|
176
|
+
clipPathComponent,
|
|
151
177
|
} = props;
|
|
152
178
|
const { top, bottom, left, right } = Helpers.getPadding({
|
|
153
|
-
padding: props.clipPadding
|
|
179
|
+
padding: props.clipPadding,
|
|
154
180
|
});
|
|
155
181
|
let child;
|
|
156
182
|
if (polar) {
|
|
@@ -158,7 +184,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
158
184
|
const circleProps = {
|
|
159
185
|
r: Math.max(radius + left + right, radius + top + bottom, 0),
|
|
160
186
|
cx: origin.x - left,
|
|
161
|
-
cy: origin.y - top
|
|
187
|
+
cy: origin.y - top,
|
|
162
188
|
};
|
|
163
189
|
child = React.cloneElement(circleComponent, circleProps);
|
|
164
190
|
} else {
|
|
@@ -166,7 +192,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
166
192
|
x: translateX - left,
|
|
167
193
|
y: translateY - top,
|
|
168
194
|
width: Math.max(clipWidth + left + right, 0),
|
|
169
|
-
height: Math.max(clipHeight + top + bottom, 0)
|
|
195
|
+
height: Math.max(clipHeight + top + bottom, 0),
|
|
170
196
|
};
|
|
171
197
|
child = React.cloneElement(rectComponent, rectProps);
|
|
172
198
|
}
|
|
@@ -174,7 +200,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
174
200
|
return React.cloneElement(
|
|
175
201
|
clipPathComponent,
|
|
176
202
|
assign({ key: `clip-path-${clipId}` }, props, { clipId }),
|
|
177
|
-
child
|
|
203
|
+
child,
|
|
178
204
|
);
|
|
179
205
|
}
|
|
180
206
|
|
|
@@ -207,7 +233,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
207
233
|
clipHeight,
|
|
208
234
|
clipWidth,
|
|
209
235
|
translateX,
|
|
210
|
-
translateY
|
|
236
|
+
translateY,
|
|
211
237
|
});
|
|
212
238
|
return this.renderClippedGroup(clipProps, this.clipId);
|
|
213
239
|
}
|
|
@@ -2,13 +2,48 @@ import React from "react";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import * as CustomPropTypes from "../victory-util/prop-types";
|
|
4
4
|
import { assign, defaults, uniqueId, isObject, isFunction } from "lodash";
|
|
5
|
-
import Portal from "../victory-portal/portal";
|
|
6
|
-
import PortalContext from "../victory-portal/portal-context";
|
|
5
|
+
import { Portal } from "../victory-portal/portal";
|
|
6
|
+
import { PortalContext } from "../victory-portal/portal-context";
|
|
7
7
|
import TimerContext from "../victory-util/timer-context";
|
|
8
8
|
import * as Helpers from "../victory-util/helpers";
|
|
9
9
|
import * as UserProps from "../victory-util/user-props";
|
|
10
|
+
import { OriginType } from "../victory-label/victory-label";
|
|
11
|
+
import { D3Scale } from "../types/prop-types";
|
|
12
|
+
import { VictoryThemeDefinition } from "../victory-theme/types";
|
|
10
13
|
|
|
11
|
-
export
|
|
14
|
+
export interface VictoryContainerProps {
|
|
15
|
+
"aria-describedby"?: string;
|
|
16
|
+
"aria-labelledby"?: string;
|
|
17
|
+
children?: React.ReactElement | React.ReactElement[];
|
|
18
|
+
className?: string;
|
|
19
|
+
containerId?: number | string;
|
|
20
|
+
containerRef?: React.Ref<HTMLElement>;
|
|
21
|
+
desc?: string;
|
|
22
|
+
events?: React.DOMAttributes<any>;
|
|
23
|
+
height?: number;
|
|
24
|
+
name?: string;
|
|
25
|
+
origin?: OriginType;
|
|
26
|
+
ouiaId?: number | string;
|
|
27
|
+
ouiaSafe?: boolean;
|
|
28
|
+
ouiaType?: string;
|
|
29
|
+
polar?: boolean;
|
|
30
|
+
portalComponent?: React.ReactElement;
|
|
31
|
+
portalZIndex?: number;
|
|
32
|
+
preserveAspectRatio?: string;
|
|
33
|
+
responsive?: boolean;
|
|
34
|
+
role?: string;
|
|
35
|
+
scale?: {
|
|
36
|
+
x?: D3Scale;
|
|
37
|
+
y?: D3Scale;
|
|
38
|
+
};
|
|
39
|
+
style?: React.CSSProperties;
|
|
40
|
+
tabIndex?: number;
|
|
41
|
+
theme?: VictoryThemeDefinition;
|
|
42
|
+
title?: string;
|
|
43
|
+
width?: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class VictoryContainer extends React.Component<VictoryContainerProps> {
|
|
12
47
|
static displayName = "VictoryContainer";
|
|
13
48
|
static role = "container";
|
|
14
49
|
static propTypes = {
|
|
@@ -16,7 +51,7 @@ export default class VictoryContainer extends React.Component {
|
|
|
16
51
|
"aria-labelledby": PropTypes.string,
|
|
17
52
|
children: PropTypes.oneOfType([
|
|
18
53
|
PropTypes.arrayOf(PropTypes.node),
|
|
19
|
-
PropTypes.node
|
|
54
|
+
PropTypes.node,
|
|
20
55
|
]),
|
|
21
56
|
className: PropTypes.string,
|
|
22
57
|
containerId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
@@ -27,7 +62,7 @@ export default class VictoryContainer extends React.Component {
|
|
|
27
62
|
name: PropTypes.string,
|
|
28
63
|
origin: PropTypes.shape({
|
|
29
64
|
x: CustomPropTypes.nonNegative,
|
|
30
|
-
y: CustomPropTypes.nonNegative
|
|
65
|
+
y: CustomPropTypes.nonNegative,
|
|
31
66
|
}),
|
|
32
67
|
ouiaId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
33
68
|
ouiaSafe: PropTypes.bool,
|
|
@@ -42,7 +77,7 @@ export default class VictoryContainer extends React.Component {
|
|
|
42
77
|
tabIndex: PropTypes.number,
|
|
43
78
|
theme: PropTypes.object,
|
|
44
79
|
title: PropTypes.string,
|
|
45
|
-
width: CustomPropTypes.nonNegative
|
|
80
|
+
width: CustomPropTypes.nonNegative,
|
|
46
81
|
};
|
|
47
82
|
|
|
48
83
|
static defaultProps = {
|
|
@@ -50,38 +85,43 @@ export default class VictoryContainer extends React.Component {
|
|
|
50
85
|
portalComponent: <Portal />,
|
|
51
86
|
portalZIndex: 99,
|
|
52
87
|
responsive: true,
|
|
53
|
-
role: "img"
|
|
88
|
+
role: "img",
|
|
54
89
|
};
|
|
55
90
|
|
|
56
91
|
static contextType = TimerContext;
|
|
92
|
+
private containerId: VictoryContainerProps["containerId"];
|
|
93
|
+
// @ts-expect-error Ref will be initialized on mount
|
|
94
|
+
private portalRef: Portal;
|
|
95
|
+
// @ts-expect-error Ref will be initialized on mount
|
|
96
|
+
private containerRef: HTMLElement;
|
|
97
|
+
private shouldHandleWheel: boolean;
|
|
57
98
|
|
|
58
|
-
constructor(props) {
|
|
99
|
+
constructor(props: VictoryContainerProps) {
|
|
59
100
|
super(props);
|
|
60
101
|
this.containerId =
|
|
61
102
|
!isObject(props) || props.containerId === undefined
|
|
62
103
|
? uniqueId("victory-container-")
|
|
63
104
|
: props.containerId;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return portal;
|
|
67
|
-
};
|
|
68
|
-
this.portalUpdate = (key, el) => this.portalRef.portalUpdate(key, el);
|
|
69
|
-
this.portalRegister = () => this.portalRef.portalRegister();
|
|
70
|
-
this.portalDeregister = (key) => this.portalRef.portalDeregister(key);
|
|
71
|
-
|
|
72
|
-
this.saveContainerRef =
|
|
73
|
-
props && isFunction(props.containerRef)
|
|
74
|
-
? props.containerRef
|
|
75
|
-
: (container) => {
|
|
76
|
-
this.containerRef = container;
|
|
77
|
-
return container;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
this.shouldHandleWheel = props && props.events && props.events.onWheel;
|
|
81
|
-
if (this.shouldHandleWheel) {
|
|
82
|
-
this.handleWheel = (e) => e.preventDefault();
|
|
83
|
-
}
|
|
105
|
+
|
|
106
|
+
this.shouldHandleWheel = !!(props && props.events && props.events.onWheel);
|
|
84
107
|
}
|
|
108
|
+
savePortalRef = (portal) => {
|
|
109
|
+
this.portalRef = portal;
|
|
110
|
+
return portal;
|
|
111
|
+
};
|
|
112
|
+
portalUpdate = (key, el) => this.portalRef.portalUpdate(key, el);
|
|
113
|
+
portalRegister = () => this.portalRef.portalRegister();
|
|
114
|
+
portalDeregister = (key) => this.portalRef.portalDeregister(key);
|
|
115
|
+
|
|
116
|
+
saveContainerRef = (container: HTMLElement) => {
|
|
117
|
+
if (isFunction(this.props.containerRef)) {
|
|
118
|
+
this.props.containerRef(container);
|
|
119
|
+
}
|
|
120
|
+
this.containerRef = container;
|
|
121
|
+
return container;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
handleWheel = (e) => e.preventDefault();
|
|
85
125
|
|
|
86
126
|
componentDidMount() {
|
|
87
127
|
if (this.shouldHandleWheel && this.containerRef) {
|
|
@@ -111,7 +151,7 @@ export default class VictoryContainer extends React.Component {
|
|
|
111
151
|
return {
|
|
112
152
|
...(ouiaId && { "data-ouia-component-id": ouiaId }),
|
|
113
153
|
...(ouiaType && { "data-ouia-component-type": ouiaType }),
|
|
114
|
-
...(ouiaSafe !== undefined && { "data-ouia-safe": ouiaSafe })
|
|
154
|
+
...(ouiaSafe !== undefined && { "data-ouia-safe": ouiaSafe }),
|
|
115
155
|
};
|
|
116
156
|
}
|
|
117
157
|
|
|
@@ -124,19 +164,23 @@ export default class VictoryContainer extends React.Component {
|
|
|
124
164
|
width,
|
|
125
165
|
height,
|
|
126
166
|
portalZIndex,
|
|
127
|
-
responsive
|
|
167
|
+
responsive,
|
|
128
168
|
} = props;
|
|
129
169
|
const children = this.getChildren(props);
|
|
130
170
|
const dimensions = responsive
|
|
131
171
|
? { width: "100%", height: "100%" }
|
|
132
172
|
: { width, height };
|
|
133
173
|
const divStyle = assign(
|
|
134
|
-
{
|
|
135
|
-
|
|
174
|
+
{
|
|
175
|
+
pointerEvents: "none",
|
|
176
|
+
touchAction: "none",
|
|
177
|
+
position: "relative",
|
|
178
|
+
} as const,
|
|
179
|
+
dimensions,
|
|
136
180
|
);
|
|
137
181
|
const portalDivStyle = assign(
|
|
138
|
-
{ zIndex: portalZIndex, position: "absolute", top: 0, left: 0 },
|
|
139
|
-
dimensions
|
|
182
|
+
{ zIndex: portalZIndex, position: "absolute", top: 0, left: 0 } as const,
|
|
183
|
+
dimensions,
|
|
140
184
|
);
|
|
141
185
|
const svgStyle = assign({ pointerEvents: "all" }, dimensions);
|
|
142
186
|
const portalSvgStyle = assign({ overflow: "visible" }, dimensions);
|
|
@@ -145,14 +189,14 @@ export default class VictoryContainer extends React.Component {
|
|
|
145
189
|
height,
|
|
146
190
|
viewBox: svgProps.viewBox,
|
|
147
191
|
preserveAspectRatio: svgProps.preserveAspectRatio,
|
|
148
|
-
style: portalSvgStyle
|
|
192
|
+
style: portalSvgStyle,
|
|
149
193
|
};
|
|
150
194
|
return (
|
|
151
195
|
<PortalContext.Provider
|
|
152
196
|
value={{
|
|
153
197
|
portalUpdate: this.portalUpdate,
|
|
154
198
|
portalRegister: this.portalRegister,
|
|
155
|
-
portalDeregister: this.portalDeregister
|
|
199
|
+
portalDeregister: this.portalDeregister,
|
|
156
200
|
}}
|
|
157
201
|
>
|
|
158
202
|
<div
|
|
@@ -173,7 +217,7 @@ export default class VictoryContainer extends React.Component {
|
|
|
173
217
|
<div style={portalDivStyle}>
|
|
174
218
|
{React.cloneElement(portalComponent, {
|
|
175
219
|
...portalProps,
|
|
176
|
-
ref: this.savePortalRef
|
|
220
|
+
ref: this.savePortalRef,
|
|
177
221
|
})}
|
|
178
222
|
</div>
|
|
179
223
|
</div>
|
|
@@ -191,12 +235,12 @@ export default class VictoryContainer extends React.Component {
|
|
|
191
235
|
desc,
|
|
192
236
|
tabIndex,
|
|
193
237
|
preserveAspectRatio,
|
|
194
|
-
role
|
|
238
|
+
role,
|
|
195
239
|
} = this.props;
|
|
196
240
|
|
|
197
241
|
const style = responsive
|
|
198
242
|
? this.props.style
|
|
199
|
-
: Helpers.omit(this.props.style
|
|
243
|
+
: Helpers.omit(this.props.style!, ["height", "width"]);
|
|
200
244
|
|
|
201
245
|
const userProps = UserProps.getSafeUserProps(this.props);
|
|
202
246
|
|
|
@@ -209,7 +253,7 @@ export default class VictoryContainer extends React.Component {
|
|
|
209
253
|
"aria-labelledby":
|
|
210
254
|
[
|
|
211
255
|
title && this.getIdForElement("title"),
|
|
212
|
-
this.props["aria-labelledby"]
|
|
256
|
+
this.props["aria-labelledby"],
|
|
213
257
|
]
|
|
214
258
|
.filter(Boolean)
|
|
215
259
|
.join(" ") || undefined,
|
|
@@ -219,9 +263,9 @@ export default class VictoryContainer extends React.Component {
|
|
|
219
263
|
.join(" ") || undefined,
|
|
220
264
|
viewBox: responsive ? `0 0 ${width} ${height}` : undefined,
|
|
221
265
|
preserveAspectRatio: responsive ? preserveAspectRatio : undefined,
|
|
222
|
-
...userProps
|
|
266
|
+
...userProps,
|
|
223
267
|
},
|
|
224
|
-
events
|
|
268
|
+
events,
|
|
225
269
|
);
|
|
226
270
|
return this.renderContainer(this.props, svgProps, style);
|
|
227
271
|
}
|