victory-stack 36.9.2-next.3 → 37.0.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.
@@ -1,63 +1,61 @@
1
1
  import _isEmpty from "lodash/isEmpty";
2
2
  import _defaults from "lodash/defaults";
3
-
4
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
-
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
-
8
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
-
10
3
  import React from "react";
11
4
  import { Helpers, Hooks, UserProps, VictoryContainer, VictoryTheme, Wrapper } from "victory-core";
12
5
  import { VictorySharedEvents } from "victory-shared-events";
13
6
  import { getChildren, useMemoizedProps } from "./helper-methods";
14
7
  import isEqual from "react-fast-compare";
15
- var fallbackProps = {
8
+ const fallbackProps = {
16
9
  width: 450,
17
10
  height: 300,
18
11
  padding: 50
19
12
  };
20
- var defaultProps = {
13
+ const defaultProps = {
21
14
  containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
22
15
  groupComponent: /*#__PURE__*/React.createElement("g", null),
23
16
  standalone: true,
24
17
  theme: VictoryTheme.grayscale,
25
18
  fillInMissingData: true
26
19
  };
27
-
28
- var VictoryStackBase = function (initialProps) {
29
- var role = VictoryStack.role;
30
- var propsWithDefaults = React.useMemo(function () {
31
- return _objectSpread(_objectSpread({}, defaultProps), initialProps);
32
- }, [initialProps]);
33
-
34
- var _Hooks$useAnimationSt = Hooks.useAnimationState(),
35
- setAnimationState = _Hooks$useAnimationSt.setAnimationState,
36
- getAnimationProps = _Hooks$useAnimationSt.getAnimationProps,
37
- getProps = _Hooks$useAnimationSt.getProps;
38
-
39
- var props = getProps(propsWithDefaults);
40
- var modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
41
- var eventKey = modifiedProps.eventKey,
42
- containerComponent = modifiedProps.containerComponent,
43
- standalone = modifiedProps.standalone,
44
- groupComponent = modifiedProps.groupComponent,
45
- externalEventMutations = modifiedProps.externalEventMutations,
46
- width = modifiedProps.width,
47
- height = modifiedProps.height,
48
- theme = modifiedProps.theme,
49
- polar = modifiedProps.polar,
50
- horizontal = modifiedProps.horizontal,
51
- name = modifiedProps.name;
52
- var childComponents = React.Children.toArray(modifiedProps.children);
53
- var calculatedProps = useMemoizedProps(modifiedProps);
54
- var domain = calculatedProps.domain,
55
- scale = calculatedProps.scale,
56
- style = calculatedProps.style;
57
- var newChildren = React.useMemo(function () {
58
- var children = getChildren(props, childComponents, calculatedProps);
59
- var orderedChildren = children.map(function (child, index) {
60
- var childProps = Object.assign({
20
+ const VictoryStackBase = initialProps => {
21
+ const {
22
+ role
23
+ } = VictoryStack;
24
+ const propsWithDefaults = React.useMemo(() => ({
25
+ ...defaultProps,
26
+ ...initialProps
27
+ }), [initialProps]);
28
+ const {
29
+ setAnimationState,
30
+ getAnimationProps,
31
+ getProps
32
+ } = Hooks.useAnimationState();
33
+ const props = getProps(propsWithDefaults);
34
+ const modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
35
+ const {
36
+ eventKey,
37
+ containerComponent,
38
+ standalone,
39
+ groupComponent,
40
+ externalEventMutations,
41
+ width,
42
+ height,
43
+ theme,
44
+ polar,
45
+ horizontal,
46
+ name
47
+ } = modifiedProps;
48
+ const childComponents = React.Children.toArray(modifiedProps.children);
49
+ const calculatedProps = useMemoizedProps(modifiedProps);
50
+ const {
51
+ domain,
52
+ scale,
53
+ style
54
+ } = calculatedProps;
55
+ const newChildren = React.useMemo(() => {
56
+ const children = getChildren(props, childComponents, calculatedProps);
57
+ const orderedChildren = children.map((child, index) => {
58
+ const childProps = Object.assign({
61
59
  animate: getAnimationProps(props, child, index)
62
60
  }, child.props);
63
61
  return /*#__PURE__*/React.cloneElement(child, childProps);
@@ -67,52 +65,45 @@ var VictoryStackBase = function (initialProps) {
67
65
  are rendered behind lower children. This looks nicer for stacked bars with cornerRadius, and
68
66
  areas with strokes
69
67
  */
70
-
71
68
  return orderedChildren.reverse();
72
69
  }, [props, childComponents, calculatedProps, getAnimationProps]);
73
- var containerProps = React.useMemo(function () {
70
+ const containerProps = React.useMemo(() => {
74
71
  if (standalone) {
75
72
  return {
76
- domain: domain,
77
- scale: scale,
78
- width: width,
79
- height: height,
80
- standalone: standalone,
81
- theme: theme,
73
+ domain,
74
+ scale,
75
+ width,
76
+ height,
77
+ standalone,
78
+ theme,
82
79
  style: style.parent,
83
- horizontal: horizontal,
84
- polar: polar,
85
- name: name
80
+ horizontal,
81
+ polar,
82
+ name
86
83
  };
87
84
  }
88
-
89
85
  return {};
90
86
  }, [standalone, domain, scale, width, height, theme, style, horizontal, polar, name]);
91
- var userProps = React.useMemo(function () {
92
- return UserProps.getSafeUserProps(propsWithDefaults);
93
- }, [propsWithDefaults]);
94
- var container = React.useMemo(function () {
87
+ const userProps = React.useMemo(() => UserProps.getSafeUserProps(propsWithDefaults), [propsWithDefaults]);
88
+ const container = React.useMemo(() => {
95
89
  if (standalone) {
96
- var defaultContainerProps = _defaults({}, containerComponent.props, containerProps, userProps);
97
-
90
+ const defaultContainerProps = _defaults({}, containerComponent.props, containerProps, userProps);
98
91
  return /*#__PURE__*/React.cloneElement(containerComponent, defaultContainerProps);
99
92
  }
100
-
101
93
  return /*#__PURE__*/React.cloneElement(groupComponent, userProps);
102
94
  }, [groupComponent, standalone, containerComponent, containerProps, userProps]);
103
- var events = React.useMemo(function () {
95
+ const events = React.useMemo(() => {
104
96
  return Wrapper.getAllEvents(props);
105
97
  }, [props]);
106
- var previousProps = Hooks.usePreviousProps(propsWithDefaults);
107
- React.useEffect(function () {
98
+ const previousProps = Hooks.usePreviousProps(propsWithDefaults);
99
+ React.useEffect(() => {
108
100
  // This is called before dismount to keep state in sync
109
- return function () {
101
+ return () => {
110
102
  if (propsWithDefaults.animate) {
111
103
  setAnimationState(previousProps, propsWithDefaults);
112
104
  }
113
105
  };
114
106
  }, [setAnimationState, previousProps, propsWithDefaults]);
115
-
116
107
  if (!_isEmpty(events)) {
117
108
  return /*#__PURE__*/React.createElement(VictorySharedEvents, {
118
109
  container: container,
@@ -121,14 +112,12 @@ var VictoryStackBase = function (initialProps) {
121
112
  externalEventMutations: externalEventMutations
122
113
  }, newChildren);
123
114
  }
124
-
125
115
  return /*#__PURE__*/React.cloneElement(container, container.props, newChildren);
126
116
  };
127
-
128
- var componentConfig = {
117
+ const componentConfig = {
129
118
  role: "stack",
130
119
  expectedComponents: ["groupComponent", "containerComponent", "labelComponent"],
131
- getChildren: getChildren
120
+ getChildren
132
121
  };
133
- export var VictoryStack = Object.assign( /*#__PURE__*/React.memo(VictoryStackBase, isEqual), componentConfig);
122
+ export const VictoryStack = Object.assign( /*#__PURE__*/React.memo(VictoryStackBase, isEqual), componentConfig);
134
123
  VictoryStack.displayName = "VictoryStack";
@@ -1,53 +1,53 @@
1
- export declare function getCalculatedProps(initialProps: any, childComponents: any): {
2
- datasets: any;
3
- categories: any;
4
- range: any;
5
- domain: {
6
- x: any;
7
- y: any;
8
- };
9
- horizontal: any;
10
- scale: {
11
- x: import("victory-core").D3Scale<any>;
12
- y: import("victory-core").D3Scale<any>;
13
- };
14
- style: any;
15
- colorScale: any;
16
- role: string;
17
- };
18
- export declare function useMemoizedProps(initialProps: any): {
19
- datasets: any;
20
- categories: any;
21
- range: any;
22
- domain: {
23
- x: any;
24
- y: any;
25
- };
26
- horizontal: any;
27
- scale: {
28
- x: import("victory-core").D3Scale<any>;
29
- y: import("victory-core").D3Scale<any>;
30
- };
31
- style: any;
32
- colorScale: any;
33
- role: string;
34
- };
35
- export declare function getChildProps(props: any, calculatedProps: any): {
36
- height: any;
37
- width: any;
38
- padding: {
39
- top: any;
40
- bottom: any;
41
- left: any;
42
- right: any;
43
- };
44
- standalone: boolean;
45
- theme: any;
46
- categories: any;
47
- domain: any;
48
- range: any;
49
- scale: any;
50
- horizontal: any;
51
- };
52
- export declare function getChildren(initialProps: any, childComponents: any, calculatedProps: any): any;
1
+ export declare function getCalculatedProps(initialProps: any, childComponents: any): {
2
+ datasets: any;
3
+ categories: any;
4
+ range: any;
5
+ domain: {
6
+ x: any;
7
+ y: any;
8
+ };
9
+ horizontal: any;
10
+ scale: {
11
+ x: import("victory-core").D3Scale<any>;
12
+ y: import("victory-core").D3Scale<any>;
13
+ };
14
+ style: any;
15
+ colorScale: any;
16
+ role: string;
17
+ };
18
+ export declare function useMemoizedProps(initialProps: any): {
19
+ datasets: any;
20
+ categories: any;
21
+ range: any;
22
+ domain: {
23
+ x: any;
24
+ y: any;
25
+ };
26
+ horizontal: any;
27
+ scale: {
28
+ x: import("victory-core").D3Scale<any>;
29
+ y: import("victory-core").D3Scale<any>;
30
+ };
31
+ style: any;
32
+ colorScale: any;
33
+ role: string;
34
+ };
35
+ export declare function getChildProps(props: any, calculatedProps: any): {
36
+ height: any;
37
+ width: any;
38
+ padding: {
39
+ top: any;
40
+ bottom: any;
41
+ left: any;
42
+ right: any;
43
+ };
44
+ standalone: boolean;
45
+ theme: any;
46
+ categories: any;
47
+ domain: any;
48
+ range: any;
49
+ scale: any;
50
+ horizontal: any;
51
+ };
52
+ export declare function getChildren(initialProps: any, childComponents: any, calculatedProps: any): any;
53
53
  //# sourceMappingURL=helper-methods.d.ts.map