victory-create-container 31.0.0 → 31.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-create-container",
3
- "version": "31.0.0",
3
+ "version": "31.2.0",
4
4
  "description": "Container Helper for Victory",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -20,12 +20,12 @@
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
22
  "lodash": "^4.17.5",
23
- "victory-brush-container": "^31.0.0",
24
- "victory-core": "^31.0.0",
25
- "victory-cursor-container": "^31.0.0",
26
- "victory-selection-container": "^31.0.0",
27
- "victory-voronoi-container": "^31.0.0",
28
- "victory-zoom-container": "^31.0.0"
23
+ "victory-brush-container": "^31.2.0",
24
+ "victory-core": "^31.2.0",
25
+ "victory-cursor-container": "^31.2.0",
26
+ "victory-selection-container": "^31.2.0",
27
+ "victory-voronoi-container": "^31.2.0",
28
+ "victory-zoom-container": "^31.2.0"
29
29
  },
30
30
  "scripts": {
31
31
  "version": "nps build-libs && nps build-dists"
@@ -24,7 +24,8 @@ const combineEventHandlers = (eventHandlersArray) => {
24
24
  const existingHandler = finalHandlers[eventName];
25
25
  if (existingHandler) {
26
26
  // create new handler for event that concats the existing handler's mutations with new ones
27
- finalHandlers[eventName] = function combinedHandler(...params) { // named for debug clarity
27
+ finalHandlers[eventName] = function combinedHandler(...params) {
28
+ // named for debug clarity
28
29
  // sometimes handlers return undefined; use empty array instead, for concat()
29
30
  const existingMutations = ensureArray(existingHandler(...params));
30
31
  const localMutations = ensureArray(localHandler(...params));
@@ -42,16 +43,16 @@ const combineDefaultEvents = (defaultEvents) => {
42
43
  // takes a defaultEvents array and returns one equal or lesser length,
43
44
  // by combining any events that have the same target
44
45
  const eventsByTarget = groupBy(defaultEvents, "target");
45
- const events = toPairs(eventsByTarget).map(
46
- ([target, eventsArray]) => {
47
- eventsArray = eventsArray.filter(Boolean);
48
- return isEmpty(eventsArray) ? null : {
49
- target,
50
- eventHandlers: combineEventHandlers(eventsArray.map((event) => event.eventHandlers))
51
- // note: does not currently handle eventKey or childName
52
- };
53
- }
54
- );
46
+ const events = toPairs(eventsByTarget).map(([target, eventsArray]) => {
47
+ eventsArray = eventsArray.filter(Boolean);
48
+ return isEmpty(eventsArray)
49
+ ? null
50
+ : {
51
+ target,
52
+ eventHandlers: combineEventHandlers(eventsArray.map((event) => event.eventHandlers))
53
+ // note: does not currently handle eventKey or childName
54
+ };
55
+ });
55
56
  return events.filter(Boolean);
56
57
  };
57
58
 
@@ -73,24 +74,23 @@ const combineContainerMixins = (mixins, Container) => {
73
74
  return class VictoryCombinedContainer extends NaiveCombinedContainer {
74
75
  static displayName = `Victory${displayType}Container`;
75
76
 
76
- static propTypes =
77
- Classes.reduce(
78
- (propTypes, Class) => ({ ...propTypes, ...Class.propTypes }),
79
- {}
80
- );
77
+ static propTypes = Classes.reduce(
78
+ (propTypes, Class) => ({ ...propTypes, ...Class.propTypes }),
79
+ {}
80
+ );
81
81
 
82
- static defaultProps =
83
- Classes.reduce(
84
- (defaultProps, Class) => ({ ...defaultProps, ...Class.defaultProps }),
85
- {}
86
- );
82
+ static defaultProps = Classes.reduce(
83
+ (defaultProps, Class) => ({ ...defaultProps, ...Class.defaultProps }),
84
+ {}
85
+ );
87
86
 
88
87
  static defaultEvents = (props) => {
89
88
  return combineDefaultEvents(
90
89
  Classes.reduce((defaultEvents, Class) => {
91
- const events = isFunction(Class.defaultEvents) ?
92
- Class.defaultEvents(props) : Class.defaultEvents;
93
- return ([...defaultEvents, ...events]);
90
+ const events = isFunction(Class.defaultEvents)
91
+ ? Class.defaultEvents(props)
92
+ : Class.defaultEvents;
93
+ return [...defaultEvents, ...events];
94
94
  }, [])
95
95
  );
96
96
  };
@@ -106,13 +106,12 @@ const combineContainerMixins = (mixins, Container) => {
106
106
 
107
107
  const checkBehaviorName = (behavior, behaviors) => {
108
108
  if (behavior && !includes(behaviors, behavior)) {
109
- Log.warn(
110
- `"${behavior}" is not a valid behavior. Choose from [${behaviors.join(", ")}].`
111
- );
109
+ Log.warn(`"${behavior}" is not a valid behavior. Choose from [${behaviors.join(", ")}].`);
112
110
  }
113
111
  };
114
112
 
115
- const makeCreateContainerFunction = (mixinMap, Container) => (behaviorA, behaviorB, ...invalid) => { // eslint-disable-line
113
+ const makeCreateContainerFunction = (mixinMap, Container) => (behaviorA, behaviorB, ...invalid) => {
114
+ // eslint-disable-line
116
115
  const behaviors = Object.keys(mixinMap);
117
116
 
118
117
  checkBehaviorName(behaviorA, behaviors);
@@ -132,13 +131,15 @@ const makeCreateContainerFunction = (mixinMap, Container) => (behaviorA, behavio
132
131
  return combineContainerMixins([...firstMixins, ...secondMixins], Container);
133
132
  };
134
133
 
135
- const createContainer = makeCreateContainerFunction({
136
- zoom: [zoomContainerMixin],
137
- voronoi: [voronoiContainerMixin],
138
- selection: [selectionContainerMixin],
139
- cursor: [cursorContainerMixin],
140
- brush: [brushContainerMixin]
141
- }, VictoryContainer);
134
+ const createContainer = makeCreateContainerFunction(
135
+ {
136
+ zoom: [zoomContainerMixin],
137
+ voronoi: [voronoiContainerMixin],
138
+ selection: [selectionContainerMixin],
139
+ cursor: [cursorContainerMixin],
140
+ brush: [brushContainerMixin]
141
+ },
142
+ VictoryContainer
143
+ );
142
144
 
143
145
  export { createContainer, makeCreateContainerFunction, combineContainerMixins };
144
-
package/src/index.js CHANGED
@@ -1,3 +1,5 @@
1
1
  export {
2
- combineContainerMixins, makeCreateContainerFunction, createContainer
2
+ combineContainerMixins,
3
+ makeCreateContainerFunction,
4
+ createContainer
3
5
  } from "./create-container";