victory-core 14.1.1 → 15.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.md +6 -1
  3. package/dist/victory-core.js +12641 -12203
  4. package/dist/victory-core.min.js +9 -9
  5. package/lib/index.js +27 -7
  6. package/lib/victory-animation/victory-animation.js +15 -13
  7. package/lib/victory-clip-container/victory-clip-container.js +7 -8
  8. package/lib/victory-container/victory-container.js +30 -31
  9. package/lib/victory-label/victory-label.js +59 -43
  10. package/lib/victory-legend/victory-legend.js +113 -63
  11. package/lib/victory-portal/portal.js +3 -2
  12. package/lib/victory-portal/victory-portal.js +4 -3
  13. package/lib/victory-primitives/area.js +26 -24
  14. package/lib/victory-primitives/bar.js +23 -16
  15. package/lib/victory-primitives/candle.js +16 -17
  16. package/lib/victory-primitives/clip-path.js +20 -14
  17. package/lib/victory-primitives/common-props.js +16 -0
  18. package/lib/victory-primitives/curve.js +22 -21
  19. package/lib/victory-primitives/error-bar.js +17 -19
  20. package/lib/victory-primitives/flyout.js +31 -16
  21. package/lib/victory-primitives/line.js +17 -19
  22. package/lib/victory-primitives/path-helpers.js +1 -0
  23. package/lib/victory-primitives/point.js +21 -17
  24. package/lib/victory-primitives/slice.js +18 -16
  25. package/lib/victory-primitives/voronoi.js +25 -21
  26. package/lib/victory-shared-events/victory-shared-events.js +25 -21
  27. package/lib/victory-tooltip/victory-tooltip.js +34 -28
  28. package/lib/victory-transition/victory-transition.js +27 -23
  29. package/lib/victory-util/add-events.js +54 -2
  30. package/lib/victory-util/collection.js +4 -0
  31. package/lib/victory-util/data.js +9 -8
  32. package/lib/victory-util/default-transitions.js +13 -12
  33. package/lib/victory-util/domain.js +1 -0
  34. package/lib/victory-util/events.js +3 -1
  35. package/lib/victory-util/helpers.js +4 -2
  36. package/lib/victory-util/prop-types.js +36 -49
  37. package/lib/victory-util/scale.js +1 -0
  38. package/lib/victory-util/textsize.js +1 -0
  39. package/lib/victory-util/transitions.js +137 -133
  40. package/package.json +16 -14
  41. package/src/index.js +26 -7
  42. package/src/victory-animation/victory-animation.js +27 -25
  43. package/src/victory-clip-container/victory-clip-container.js +18 -19
  44. package/src/victory-container/victory-container.js +43 -44
  45. package/src/victory-label/victory-label.js +72 -56
  46. package/src/victory-legend/victory-legend.js +116 -66
  47. package/src/victory-portal/portal.js +3 -2
  48. package/src/victory-portal/victory-portal.js +6 -5
  49. package/src/victory-primitives/area.js +22 -20
  50. package/src/victory-primitives/bar.js +28 -21
  51. package/src/victory-primitives/candle.js +23 -24
  52. package/src/victory-primitives/clip-path.js +13 -7
  53. package/src/victory-primitives/common-props.js +17 -0
  54. package/src/victory-primitives/curve.js +20 -19
  55. package/src/victory-primitives/error-bar.js +23 -25
  56. package/src/victory-primitives/flyout.js +34 -19
  57. package/src/victory-primitives/line.js +20 -22
  58. package/src/victory-primitives/path-helpers.js +7 -6
  59. package/src/victory-primitives/point.js +19 -15
  60. package/src/victory-primitives/slice.js +17 -15
  61. package/src/victory-primitives/voronoi.js +20 -16
  62. package/src/victory-shared-events/victory-shared-events.js +38 -34
  63. package/src/victory-tooltip/victory-tooltip.js +54 -48
  64. package/src/victory-transition/victory-transition.js +27 -23
  65. package/src/victory-util/add-events.js +56 -4
  66. package/src/victory-util/collection.js +4 -0
  67. package/src/victory-util/data.js +11 -10
  68. package/src/victory-util/default-transitions.js +33 -31
  69. package/src/victory-util/domain.js +2 -1
  70. package/src/victory-util/events.js +7 -5
  71. package/src/victory-util/helpers.js +6 -4
  72. package/src/victory-util/prop-types.js +40 -53
  73. package/src/victory-util/scale.js +6 -5
  74. package/src/victory-util/selection.js +7 -7
  75. package/src/victory-util/textsize.js +3 -2
  76. package/src/victory-util/transitions.js +11 -6
  77. package/lib/victory-primitives/index.js +0 -15
  78. package/lib/victory-util/index.js +0 -32
  79. package/src/victory-primitives/index.js +0 -16
  80. package/src/victory-util/index.js +0 -33
@@ -1,138 +1,30 @@
1
- Object.defineProperty(exports,"__esModule",{value:true});var _identity2=require("lodash/identity");var _identity3=_interopRequireDefault(_identity2);var _defaults2=require("lodash/defaults");var _defaults3=_interopRequireDefault(_defaults2);var _assign2=require("lodash/assign");var _assign3=_interopRequireDefault(_assign2);exports.
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
- getInitialTransitionState=getInitialTransitionState;exports.
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
1
+ Object.defineProperty(exports,"__esModule",{value:true});var _identity2=require("lodash/identity");var _identity3=_interopRequireDefault(_identity2);var _defaults2=require("lodash/defaults");var _defaults3=_interopRequireDefault(_defaults2);var _assign2=require("lodash/assign");var _assign3=_interopRequireDefault(_assign2);
132
2
 
3
+ var _react=require("react");var _react2=_interopRequireDefault(_react);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}
133
4
 
5
+ function getDatumKey(datum,idx){
6
+ return(datum.key||idx).toString();
7
+ }
134
8
 
9
+ function getKeyedData(data){
10
+ return data.reduce(function(keyedData,datum,idx){
11
+ var key=getDatumKey(datum,idx);
12
+ keyedData[key]=datum;
13
+ return keyedData;
14
+ },{});
15
+ }
135
16
 
17
+ function getKeyedDataDifference(a,b){
18
+ var hasDifference=false;
19
+ var difference=Object.keys(a).reduce(function(_difference,key){
20
+ if(!(key in b)){
21
+ hasDifference=true;
22
+ _difference[key]=true;
23
+ }
24
+ return _difference;
25
+ },{});
26
+ return hasDifference&&difference;
27
+ }
136
28
 
137
29
 
138
30
 
@@ -147,9 +39,22 @@ getInitialTransitionState=getInitialTransitionState;exports.
147
39
 
148
40
 
149
41
 
42
+ function getNodeTransitions(oldData,nextData){
43
+ var oldDataKeyed=oldData&&getKeyedData(oldData);
44
+ var nextDataKeyed=nextData&&getKeyedData(nextData);
150
45
 
46
+ return{
47
+ entering:oldDataKeyed&&getKeyedDataDifference(nextDataKeyed,oldDataKeyed),
48
+ exiting:nextDataKeyed&&getKeyedDataDifference(oldDataKeyed,nextDataKeyed)};
151
49
 
50
+ }
152
51
 
52
+ function getChildData(child){
53
+ if(child.type&&child.type.getData){
54
+ return child.type.getData(child.props);
55
+ }
56
+ return child.props&&child.props.data||false;
57
+ }
153
58
 
154
59
 
155
60
 
@@ -167,52 +72,147 @@ getInitialTransitionState=getInitialTransitionState;exports.
167
72
 
168
73
 
169
74
 
75
+ function getInitialTransitionState(oldChildren,nextChildren){
76
+ var nodesWillExit=false;
77
+ var nodesWillEnter=false;
170
78
 
79
+ var getTransition=function getTransition(oldChild,newChild){
80
+ if(!newChild||oldChild.type!==newChild.type){
81
+ return{};
82
+ }var _ref=
171
83
 
172
84
 
85
+ getNodeTransitions(getChildData(oldChild),getChildData(newChild))||{},entering=_ref.entering,exiting=_ref.exiting;
173
86
 
87
+ nodesWillExit=nodesWillExit||!!exiting;
88
+ nodesWillEnter=nodesWillEnter||!!entering;
174
89
 
90
+ return{entering:entering||false,exiting:exiting||false};
91
+ };
175
92
 
93
+ var getTransitionsFromChildren=function getTransitionsFromChildren(old,next){
94
+ return old.map(function(child,idx){
95
+ if(child&&child.props&&child.props.children){
96
+ return getTransitionsFromChildren(
97
+ _react2.default.Children.toArray(old[idx].props.children),
98
+ _react2.default.Children.toArray(next[idx].props.children));
176
99
 
100
+ }
177
101
 
102
+ return getTransition(child,next[idx]);
103
+ });
104
+ };
178
105
 
106
+ var childrenTransitions=getTransitionsFromChildren(
107
+ _react2.default.Children.toArray(oldChildren),
108
+ _react2.default.Children.toArray(nextChildren));
179
109
 
110
+ return{
111
+ nodesWillExit:nodesWillExit,
112
+ nodesWillEnter:nodesWillEnter,
113
+ childrenTransitions:childrenTransitions,
180
114
 
181
115
 
182
116
 
183
117
 
184
118
 
119
+ nodesShouldEnter:false};
185
120
 
121
+ }
186
122
 
123
+ function getInitialChildProps(animate,data){
124
+ var after=animate.onEnter&&animate.onEnter.after?animate.onEnter.after:_identity3.default;
125
+ return{
126
+ data:data.map(function(datum){return(0,_assign3.default)({},datum,after(datum));})};
187
127
 
128
+ }
188
129
 
130
+ function getChildBeforeLoad(animate,child,data,cb){
131
+ animate=(0,_assign3.default)({},animate,{onEnd:cb});
132
+ if(animate&&animate.onLoad&&!animate.onLoad.duration){
133
+ return{animate:animate,data:data};
134
+ }
135
+ var before=animate.onLoad&&animate.onLoad.before?animate.onLoad.before:_identity3.default;
189
136
 
137
+ data=data.map(function(datum){
138
+ return(0,_assign3.default)({},datum,before(datum));
139
+ });
190
140
 
141
+ return{animate:animate,data:data,clipWidth:0};
142
+ }
191
143
 
144
+ function getChildOnLoad(animate,data,cb){
145
+ animate=(0,_assign3.default)({},animate,{onEnd:cb});
146
+ if(animate&&animate.onLoad&&!animate.onLoad.duration){
147
+ return{animate:animate,data:data};
148
+ }
149
+ var after=animate.onLoad&&animate.onLoad.after?animate.onLoad.after:_identity3.default;
192
150
 
151
+ data=data.map(function(datum){
152
+ return(0,_assign3.default)({},datum,after(datum));
153
+ });
193
154
 
155
+ return{animate:animate,data:data};
156
+ }
194
157
 
158
+ function getChildPropsOnExit(animate,child,data,exitingNodes,cb){
195
159
 
196
160
 
161
+ var onExit=animate&&animate.onExit;
162
+ animate=(0,_assign3.default)({},animate,onExit);
197
163
 
164
+ if(exitingNodes){
198
165
 
199
166
 
167
+ animate.onEnd=cb;
168
+ var before=animate.onExit&&animate.onExit.before?animate.onExit.before:_identity3.default;
200
169
 
170
+ data=data.map(function(datum,idx){
171
+ var key=(datum.key||idx).toString();
172
+ return exitingNodes[key]?(0,_assign3.default)({},datum,before(datum)):datum;
173
+ });
174
+ }
201
175
 
176
+ return{animate:animate,data:data};
177
+ }
202
178
 
179
+ function getChildPropsBeforeEnter(animate,child,data,enteringNodes,cb){
180
+ if(enteringNodes){
203
181
 
204
182
 
183
+ animate=(0,_assign3.default)({},animate,{onEnd:cb});
184
+ var before=animate.onEnter&&animate.onEnter.before?animate.onEnter.before:_identity3.default;
205
185
 
206
186
 
207
187
 
188
+ data=data.map(function(datum,idx){
189
+ var key=(datum.key||idx).toString();
190
+ return enteringNodes[key]?(0,_assign3.default)({},datum,before(datum)):datum;
191
+ });
192
+ }
208
193
 
194
+ return{animate:animate,data:data};
195
+ }
209
196
 
197
+ function getChildPropsOnEnter(animate,data,enteringNodes,cb){
210
198
 
211
199
 
200
+ var onEnter=animate&&animate.onEnter;
201
+ animate=(0,_assign3.default)({},animate,onEnter);
212
202
 
203
+ if(enteringNodes){
213
204
 
214
205
 
215
206
 
207
+ animate.onEnd=cb;
208
+ var after=animate.onEnter&&animate.onEnter.after?animate.onEnter.after:_identity3.default;
209
+ data=data.map(function(datum,idx){
210
+ var key=getDatumKey(datum,idx);
211
+ return enteringNodes[key]?(0,_assign3.default)({},datum,after(datum)):datum;
212
+ });
213
+ }
214
+ return{animate:animate,data:data};
215
+ }
216
216
 
217
217
 
218
218
 
@@ -232,7 +232,7 @@ getInitialTransitionState=getInitialTransitionState;exports.
232
232
 
233
233
 
234
234
 
235
- getTransitionPropsFactory=getTransitionPropsFactory;var _react=require("react");var _react2=_interopRequireDefault(_react);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function getDatumKey(datum,idx){return(datum.key||idx).toString();}function getKeyedData(data){return data.reduce(function(keyedData,datum,idx){var key=getDatumKey(datum,idx);keyedData[key]=datum;return keyedData;},{});}function getKeyedDataDifference(a,b){var hasDifference=false;var difference=Object.keys(a).reduce(function(_difference,key){if(!(key in b)){hasDifference=true;_difference[key]=true;}return _difference;},{});return hasDifference&&difference;}function getNodeTransitions(oldData,nextData){var oldDataKeyed=oldData&&getKeyedData(oldData);var nextDataKeyed=nextData&&getKeyedData(nextData);return{entering:oldDataKeyed&&getKeyedDataDifference(nextDataKeyed,oldDataKeyed),exiting:nextDataKeyed&&getKeyedDataDifference(oldDataKeyed,nextDataKeyed)};}function getChildData(child){if(child.type&&child.type.getData){return child.type.getData(child.props);}return child.props&&child.props.data||false;}function getInitialTransitionState(oldChildren,nextChildren){var nodesWillExit=false;var nodesWillEnter=false;var getTransition=function getTransition(oldChild,newChild){if(!newChild||oldChild.type!==newChild.type){return{};}var _ref=getNodeTransitions(getChildData(oldChild),getChildData(newChild))||{},entering=_ref.entering,exiting=_ref.exiting;nodesWillExit=nodesWillExit||!!exiting;nodesWillEnter=nodesWillEnter||!!entering;return{entering:entering||false,exiting:exiting||false};};var getTransitionsFromChildren=function getTransitionsFromChildren(old,next){return old.map(function(child,idx){if(child&&child.props&&child.props.children){return getTransitionsFromChildren(_react2.default.Children.toArray(old[idx].props.children),_react2.default.Children.toArray(next[idx].props.children));}return getTransition(child,next[idx]);});};var childrenTransitions=getTransitionsFromChildren(_react2.default.Children.toArray(oldChildren),_react2.default.Children.toArray(nextChildren));return{nodesWillExit:nodesWillExit,nodesWillEnter:nodesWillEnter,childrenTransitions:childrenTransitions,nodesShouldEnter:false};}function getInitialChildProps(animate,data){var after=animate.onEnter&&animate.onEnter.after?animate.onEnter.after:_identity3.default;return{data:data.map(function(datum){return(0,_assign3.default)({},datum,after(datum));})};}function getChildBeforeLoad(animate,child,data,cb){animate=(0,_assign3.default)({},animate,{onEnd:cb});if(animate&&animate.onLoad&&!animate.onLoad.duration){return{animate:animate,data:data};}var before=animate.onLoad&&animate.onLoad.before?animate.onLoad.before:_identity3.default;data=data.map(function(datum){return(0,_assign3.default)({},datum,before(datum));});return{animate:animate,data:data,clipWidth:0};}function getChildOnLoad(animate,data,cb){animate=(0,_assign3.default)({},animate,{onEnd:cb});if(animate&&animate.onLoad&&!animate.onLoad.duration){return{animate:animate,data:data};}var after=animate.onLoad&&animate.onLoad.after?animate.onLoad.after:_identity3.default;data=data.map(function(datum){return(0,_assign3.default)({},datum,after(datum));});return{animate:animate,data:data};}function getChildPropsOnExit(animate,child,data,exitingNodes,cb){var onExit=animate&&animate.onExit;animate=(0,_assign3.default)({},animate,onExit);if(exitingNodes){(function(){animate.onEnd=cb;var before=animate.onExit&&animate.onExit.before?animate.onExit.before:_identity3.default;data=data.map(function(datum,idx){var key=(datum.key||idx).toString();return exitingNodes[key]?(0,_assign3.default)({},datum,before(datum)):datum;});})();}return{animate:animate,data:data};}function getChildPropsBeforeEnter(animate,child,data,enteringNodes,cb){if(enteringNodes){(function(){animate=(0,_assign3.default)({},animate,{onEnd:cb});var before=animate.onEnter&&animate.onEnter.before?animate.onEnter.before:_identity3.default;data=data.map(function(datum,idx){var key=(datum.key||idx).toString();return enteringNodes[key]?(0,_assign3.default)({},datum,before(datum)):datum;});})();}return{animate:animate,data:data};}function getChildPropsOnEnter(animate,data,enteringNodes,cb){var onEnter=animate&&animate.onEnter;animate=(0,_assign3.default)({},animate,onEnter);if(enteringNodes){(function(){animate.onEnd=cb;var after=animate.onEnter&&animate.onEnter.after?animate.onEnter.after:_identity3.default;data=data.map(function(datum,idx){var key=getDatumKey(datum,idx);return enteringNodes[key]?(0,_assign3.default)({},datum,after(datum)):datum;});})();}return{animate:animate,data:data};}function getTransitionPropsFactory(props,state,setState){
235
+ function getTransitionPropsFactory(props,state,setState){
236
236
  var nodesWillExit=state&&state.nodesWillExit;
237
237
  var nodesWillEnter=state&&state.nodesWillEnter;
238
238
  var nodesShouldEnter=state&&state.nodesShouldEnter;
@@ -338,4 +338,8 @@ return getInitialChildProps(animate,data);
338
338
  }
339
339
  return{animate:animate,data:data};
340
340
  };
341
- }
341
+ }exports.default=
342
+
343
+ {
344
+ getInitialTransitionState:getInitialTransitionState,
345
+ getTransitionPropsFactory:getTransitionPropsFactory};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-core",
3
- "version": "14.1.1",
3
+ "version": "15.2.0",
4
4
  "description": "Victory Core",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -17,7 +17,6 @@
17
17
  "npm": ">=2.0.0"
18
18
  },
19
19
  "scripts": {
20
- "postinstall": "cd lib || builder run npm:postinstall",
21
20
  "preversion": "builder run npm:preversion",
22
21
  "postversion": "builder run npm:postversion",
23
22
  "postpublish": "builder run npm:postpublish",
@@ -31,21 +30,21 @@
31
30
  "d3-scale": "^1.0.0",
32
31
  "d3-shape": "^1.0.0",
33
32
  "d3-timer": "^1.0.0",
34
- "lodash": "^4.12.0"
33
+ "lodash": "^4.17.4"
35
34
  },
36
35
  "devDependencies": {
37
- "builder-victory-component-dev": "^3.1.0",
38
- "chai": "^3.2.0",
39
- "enzyme": "^2.3.0",
40
- "mocha": "^2.2.5",
41
- "react": "~15.1.0",
42
- "react-addons-test-utils": "~15.1.0",
43
- "react-dom": "~15.1.0",
44
- "react-router": "^2.4.0",
45
- "sinon": "^1.17.2",
36
+ "builder-victory-component-dev": "^4.0.2",
37
+ "chai": "^3.5.0",
38
+ "enzyme": "^2.4.1",
39
+ "mocha": "^3.0.2",
40
+ "prop-types": "^15.5.8",
41
+ "react": "^15.5.4",
42
+ "react-addons-test-utils": "^15.5.1",
43
+ "react-dom": "^15.5.4",
44
+ "sinon": "^1.17.5",
46
45
  "sinon-chai": "^2.8.0",
47
- "builder": "^3.1.0",
48
- "builder-victory-component": "^3.1.0"
46
+ "builder": "^3.2.1",
47
+ "builder-victory-component": "^4.0.2"
49
48
  },
50
49
  "publishr": {
51
50
  "dependencies": [
@@ -53,6 +52,9 @@
53
52
  ],
54
53
  "files": {
55
54
  ".npmignore": ".npmignore.publishr"
55
+ },
56
+ "scripts": {
57
+ "postinstall": ""
56
58
  }
57
59
  },
58
60
  "_publishr": [
package/src/index.js CHANGED
@@ -9,10 +9,29 @@ export { default as VictoryLegend } from "./victory-legend/victory-legend";
9
9
  export { default as VictoryTooltip } from "./victory-tooltip/victory-tooltip";
10
10
  export { default as VictoryPortal } from "./victory-portal/victory-portal";
11
11
  export { default as Portal } from "./victory-portal/portal";
12
- export {
13
- Area, Bar, Candle, ClipPath, Curve, ErrorBar, Line, Point, Slice, Voronoi, Flyout
14
- } from "./victory-primitives/index";
15
- export {
16
- addEvents, Collection, Data, DefaultTransitions, Domain, Events, Helpers, Log,
17
- PropTypes, Scale, Style, TextSize, Timer, Transitions, Selection
18
- } from "./victory-util/index";
12
+ export { default as Area } from "./victory-primitives/area";
13
+ export { default as Bar } from "./victory-primitives/bar";
14
+ export { default as Candle } from "./victory-primitives/candle";
15
+ export { default as ClipPath } from "./victory-primitives/clip-path";
16
+ export { default as Curve } from "./victory-primitives/curve";
17
+ export { default as ErrorBar } from "./victory-primitives/error-bar";
18
+ export { default as Line } from "./victory-primitives/line";
19
+ export { default as Point } from "./victory-primitives/point";
20
+ export { default as Slice } from "./victory-primitives/slice";
21
+ export { default as Voronoi } from "./victory-primitives/voronoi";
22
+ export { default as Flyout } from "./victory-primitives/flyout";
23
+ export { default as addEvents } from "./victory-util/add-events";
24
+ export { default as Collection } from "./victory-util/collection";
25
+ export { default as Data } from "./victory-util/data";
26
+ export { default as DefaultTransitions } from "./victory-util/default-transitions";
27
+ export { default as Domain } from "./victory-util/domain";
28
+ export { default as Events } from "./victory-util/events";
29
+ export { default as Helpers } from "./victory-util/helpers";
30
+ export { default as Log } from "./victory-util/log";
31
+ export { default as PropTypes } from "./victory-util/prop-types";
32
+ export { default as Scale } from "./victory-util/scale";
33
+ export { default as Selection } from "./victory-util/selection";
34
+ export { default as Style } from "./victory-util/style";
35
+ export { default as TextSize } from "./victory-util/textsize";
36
+ export { default as Timer } from "./victory-util/timer";
37
+ export { default as Transitions } from "./victory-util/transitions";
@@ -1,4 +1,6 @@
1
+ /*global setTimeout:false */
1
2
  import React from "react";
3
+ import PropTypes from "prop-types";
2
4
  import * as d3Ease from "d3-ease";
3
5
  import { victoryInterpolator } from "./util";
4
6
  import Timer from "../victory-util/timer";
@@ -7,9 +9,14 @@ export default class VictoryAnimation extends React.Component {
7
9
  static displayName = "VictoryAnimation";
8
10
 
9
11
  static propTypes = {
10
- children: React.PropTypes.func,
11
- duration: React.PropTypes.number,
12
- easing: React.PropTypes.oneOf([
12
+ children: PropTypes.func,
13
+ data: PropTypes.oneOfType([
14
+ PropTypes.object,
15
+ PropTypes.array
16
+ ]),
17
+ delay: PropTypes.number,
18
+ duration: PropTypes.number,
19
+ easing: PropTypes.oneOf([
13
20
  "back", "backIn", "backOut", "backInOut",
14
21
  "bounce", "bounceIn", "bounceOut", "bounceInOut",
15
22
  "circle", "circleIn", "circleOut", "circleInOut",
@@ -21,23 +28,18 @@ export default class VictoryAnimation extends React.Component {
21
28
  "quad", "quadIn", "quadOut", "quadInOut",
22
29
  "sin", "sinIn", "sinOut", "sinInOut"
23
30
  ]),
24
- delay: React.PropTypes.number,
25
- onEnd: React.PropTypes.func,
26
- data: React.PropTypes.oneOfType([
27
- React.PropTypes.object,
28
- React.PropTypes.array
29
- ])
31
+ onEnd: PropTypes.func
30
32
  };
31
33
 
32
34
  static defaultProps = {
33
- duration: 1000,
34
- easing: "quadInOut",
35
+ data: {},
35
36
  delay: 0,
36
- data: {}
37
+ duration: 1000,
38
+ easing: "quadInOut"
37
39
  };
38
40
 
39
41
  static contextTypes = {
40
- getTimer: React.PropTypes.func
42
+ getTimer: PropTypes.func
41
43
  };
42
44
 
43
45
  constructor(props) {
@@ -57,23 +59,13 @@ export default class VictoryAnimation extends React.Component {
57
59
  /* build easing function */
58
60
  this.ease = d3Ease[this.toNewName(this.props.easing)];
59
61
  /*
60
- unlike React.createClass({}), there is no autobinding of this in ES6 classes
62
+ There is no autobinding of this in ES6 classes
61
63
  so we bind functionToBeRunEachFrame to current instance of victory animation class
62
64
  */
63
65
  this.functionToBeRunEachFrame = this.functionToBeRunEachFrame.bind(this);
64
66
  this.getTimer = this.getTimer.bind(this);
65
67
  }
66
68
 
67
- getTimer() {
68
- if (this.context.getTimer) {
69
- return this.context.getTimer();
70
- }
71
- if (!this.timer) {
72
- this.timer = new Timer();
73
- }
74
- return this.timer;
75
- }
76
-
77
69
  componentDidMount() {
78
70
  // Length check prevents us from triggering `onEnd` in `traverseQueue`.
79
71
  if (this.queue.length) {
@@ -109,6 +101,16 @@ export default class VictoryAnimation extends React.Component {
109
101
  }
110
102
  }
111
103
 
104
+ getTimer() {
105
+ if (this.context.getTimer) {
106
+ return this.context.getTimer();
107
+ }
108
+ if (!this.timer) {
109
+ this.timer = new Timer();
110
+ }
111
+ return this.timer;
112
+ }
113
+
112
114
  toNewName(ease) {
113
115
  // d3-ease changed the naming scheme for ease from "linear" -> "easeLinear" etc.
114
116
  const capitalize = (s) => s && s[0].toUpperCase() + s.slice(1);
@@ -124,7 +126,7 @@ export default class VictoryAnimation extends React.Component {
124
126
  this.interpolator = victoryInterpolator(this.state.data, data);
125
127
  /* reset step to zero */
126
128
  if (this.props.delay) {
127
- setTimeout(() => { // eslint-disable-line no-undef
129
+ setTimeout(() => {
128
130
  this.loopID = this.getTimer().subscribe(
129
131
  this.functionToBeRunEachFrame, this.props.duration
130
132
  );
@@ -1,30 +1,29 @@
1
- import React, { PropTypes } from "react";
1
+ import React from "react";
2
+ import PropTypes from "prop-types";
2
3
  import { defaults, isFunction } from "lodash";
3
- import { ClipPath } from "../victory-primitives/index";
4
+ import ClipPath from "../victory-primitives/clip-path";
4
5
 
5
6
  export default class VictoryClipContainer extends React.Component {
6
7
  static displayName = "VictoryClipContainer";
7
8
  static role = "container";
8
9
  static propTypes = {
10
+ children: PropTypes.oneOfType([
11
+ PropTypes.arrayOf(PropTypes.node),
12
+ PropTypes.node
13
+ ]),
9
14
  className: PropTypes.string,
10
- style: PropTypes.object,
15
+ clipHeight: PropTypes.number,
11
16
  clipPadding: PropTypes.shape({
12
- top: PropTypes.number,
13
- bottom: PropTypes.number,
14
- left: PropTypes.number,
15
- right: PropTypes.number
17
+ top: PropTypes.number, bottom: PropTypes.number,
18
+ left: PropTypes.number, right: PropTypes.number
16
19
  }),
17
- clipHeight: PropTypes.number,
20
+ clipPathComponent: PropTypes.element,
18
21
  clipWidth: PropTypes.number,
19
22
  events: PropTypes.object,
20
- children: React.PropTypes.oneOfType([
21
- React.PropTypes.arrayOf(React.PropTypes.node),
22
- React.PropTypes.node
23
- ]),
24
- clipPathComponent: PropTypes.element,
23
+ style: PropTypes.object,
24
+ transform: PropTypes.string,
25
25
  translateX: PropTypes.number,
26
- translateY: PropTypes.number,
27
- transform: PropTypes.string
26
+ translateY: PropTypes.number
28
27
  }
29
28
 
30
29
  static defaultProps = {
@@ -33,7 +32,7 @@ export default class VictoryClipContainer extends React.Component {
33
32
 
34
33
  constructor(props) {
35
34
  super(props);
36
- this.clipId = Math.round(Math.random() * 10000);
35
+ this.clipId = Math.round(Math.random() * 10000); // eslint-disable-line no-magic-numbers
37
36
  }
38
37
 
39
38
  // Overridden in victory-core-native
@@ -82,7 +81,7 @@ export default class VictoryClipContainer extends React.Component {
82
81
  }
83
82
 
84
83
  getClipValue(props, axis) {
85
- const clipValues = {x: props.clipWidth, y: props.clipHeight};
84
+ const clipValues = { x: props.clipWidth, y: props.clipHeight };
86
85
  if (clipValues[axis] !== undefined) {
87
86
  return clipValues[axis];
88
87
  }
@@ -91,7 +90,7 @@ export default class VictoryClipContainer extends React.Component {
91
90
  }
92
91
 
93
92
  getTranslateValue(props, axis) {
94
- const translateValues = {x: props.translateX, y: props.translateY};
93
+ const translateValues = { x: props.translateX, y: props.translateY };
95
94
  if (translateValues[axis] !== undefined) {
96
95
  return translateValues[axis];
97
96
  }
@@ -115,7 +114,7 @@ export default class VictoryClipContainer extends React.Component {
115
114
  }
116
115
  const translateX = this.getTranslateValue(this.props, "x");
117
116
  const translateY = this.getTranslateValue(this.props, "y");
118
- const clipProps = defaults({}, this.props, {clipHeight, clipWidth, translateX, translateY});
117
+ const clipProps = defaults({}, this.props, { clipHeight, clipWidth, translateX, translateY });
119
118
  return this.renderClippedGroup(clipProps, this.clipId);
120
119
  }
121
120
  }