victory-create-container 36.9.2-next.0 → 36.9.2-next.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.
@@ -1,116 +1,202 @@
1
1
  import _isEmpty from "lodash/isEmpty";
2
2
  import _flow from "lodash/flow";
3
- import _includes from "lodash/includes";
4
3
  import _forOwn from "lodash/forOwn";
5
4
  import _groupBy from "lodash/groupBy";
6
5
  import _toPairs from "lodash/toPairs";
6
+
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+
9
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+
13
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
14
+
15
+ 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; }
16
+
17
+ 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; }
18
+
19
+ 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; }
20
+
21
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
22
+
23
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
24
+
25
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
26
+
27
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
28
+
29
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
30
+
31
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
32
+
33
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
34
+
35
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
36
+
37
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
38
+
39
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
40
+
41
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
42
+
43
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
44
+
45
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
46
+
47
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
48
+
49
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
50
+
51
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
52
+
7
53
  import { Helpers, VictoryContainer, Log } from "victory-core";
8
54
  import { voronoiContainerMixin } from "victory-voronoi-container";
9
55
  import { zoomContainerMixin } from "victory-zoom-container";
10
56
  import { selectionContainerMixin } from "victory-selection-container";
11
57
  import { brushContainerMixin } from "victory-brush-container";
12
58
  import { cursorContainerMixin } from "victory-cursor-container";
59
+
13
60
  function ensureArray(thing) {
14
61
  if (!thing) {
15
62
  return [];
16
63
  } else if (!Array.isArray(thing)) {
17
64
  return [thing];
18
65
  }
66
+
19
67
  return thing;
20
68
  }
21
- const combineEventHandlers = eventHandlersArray => {
69
+
70
+ var combineEventHandlers = function (eventHandlersArray) {
22
71
  // takes an array of event handler objects and produces one eventHandlers object
23
72
  // creates a custom combinedHandler() for events with multiple conflicting handlers
24
- return eventHandlersArray.reduce((localHandlers, finalHandlers) => {
25
- _forOwn(localHandlers, (localHandler, eventName) => {
26
- const existingHandler = finalHandlers[eventName];
73
+ return eventHandlersArray.reduce(function (localHandlers, finalHandlers) {
74
+ _forOwn(localHandlers, function (localHandler, eventName) {
75
+ var existingHandler = finalHandlers[eventName];
76
+
27
77
  if (existingHandler) {
28
78
  // create new handler for event that concats the existing handler's mutations with new ones
29
79
  finalHandlers[eventName] = function combinedHandler() {
30
80
  // named for debug clarity
31
81
  // sometimes handlers return undefined; use empty array instead, for concat()
32
- const existingMutations = ensureArray(existingHandler(...arguments));
33
- const localMutations = ensureArray(localHandler(...arguments));
82
+ var existingMutations = ensureArray(existingHandler.apply(void 0, arguments));
83
+ var localMutations = ensureArray(localHandler.apply(void 0, arguments));
34
84
  return existingMutations.concat(localMutations);
35
85
  };
36
86
  } else {
37
87
  finalHandlers[eventName] = localHandler;
38
88
  }
39
89
  });
90
+
40
91
  return finalHandlers;
41
92
  });
42
93
  };
43
- const combineDefaultEvents = defaultEvents => {
94
+
95
+ var combineDefaultEvents = function (defaultEvents) {
44
96
  // takes a defaultEvents array and returns one equal or lesser length,
45
97
  // by combining any events that have the same target
46
- const eventsByTarget = _groupBy(defaultEvents, "target");
47
- const events = _toPairs(eventsByTarget).map(_ref => {
48
- let [target, eventsArray] = _ref;
49
- const newEventsArray = eventsArray.filter(Boolean);
98
+ var eventsByTarget = _groupBy(defaultEvents, "target");
99
+
100
+ var events = _toPairs(eventsByTarget).map(function (_ref) {
101
+ var _ref2 = _slicedToArray(_ref, 2),
102
+ target = _ref2[0],
103
+ eventsArray = _ref2[1];
104
+
105
+ var newEventsArray = eventsArray.filter(Boolean);
50
106
  return _isEmpty(newEventsArray) ? null : {
51
- target,
52
- eventHandlers: combineEventHandlers(eventsArray.map(event => event.eventHandlers))
53
- // note: does not currently handle eventKey or childName
107
+ target: target,
108
+ eventHandlers: combineEventHandlers(eventsArray.map(function (event) {
109
+ return event.eventHandlers;
110
+ })) // note: does not currently handle eventKey or childName
111
+
54
112
  };
55
113
  });
114
+
56
115
  return events.filter(Boolean);
57
116
  };
58
- export const combineContainerMixins = (mixins, Container) => {
117
+
118
+ export var combineContainerMixins = function (mixins, Container) {
119
+ var _class;
120
+
59
121
  // similar to Object.assign(A, B), this function will decide conflicts in favor mixinB.
60
122
  // this applies to propTypes and defaultProps.
61
123
  // getChildren will call A's getChildren() and pass the resulting children to B's.
62
124
  // defaultEvents attempts to resolve any conflicts between A and B's defaultEvents.
63
- const Classes = mixins.map(mixin => mixin(Container));
64
- const instances = Classes.map(Class => new Class());
65
- const NaiveCombinedContainer = _flow(mixins)(Container);
66
- const displayType = Classes.map(Class => {
67
- const match = Class.displayName.match(/Victory(.*)Container/);
125
+ var Classes = mixins.map(function (mixin) {
126
+ return mixin(Container);
127
+ });
128
+ var instances = Classes.map(function (Class) {
129
+ return new Class();
130
+ });
131
+
132
+ var NaiveCombinedContainer = _flow(mixins)(Container);
133
+
134
+ var displayType = Classes.map(function (Class) {
135
+ var match = Class.displayName.match(/Victory(.*)Container/);
68
136
  return match[1] || "";
69
137
  }).join("");
70
- return class VictoryCombinedContainer extends NaiveCombinedContainer {
71
- static displayName = `Victory${displayType}Container`;
72
- static propTypes = Classes.reduce((propTypes, Class) => ({
73
- ...propTypes,
74
- ...Class.propTypes
75
- }), {});
76
- static defaultProps = Classes.reduce((defaultProps, Class) => ({
77
- ...defaultProps,
78
- ...Class.defaultProps
79
- }), {});
80
- static defaultEvents = props => {
81
- return combineDefaultEvents(Classes.reduce((defaultEvents, Class) => {
82
- const events = Helpers.isFunction(Class.defaultEvents) ? Class.defaultEvents(props) : Class.defaultEvents;
83
- return [...defaultEvents, ...events];
84
- }, []));
85
- };
86
- getChildren(props) {
87
- return instances.reduce((children, instance) => instance.getChildren({
88
- ...props,
89
- children
90
- }), props.children);
138
+ return _class = /*#__PURE__*/function (_NaiveCombinedContain) {
139
+ _inherits(VictoryCombinedContainer, _NaiveCombinedContain);
140
+
141
+ var _super = _createSuper(VictoryCombinedContainer);
142
+
143
+ function VictoryCombinedContainer() {
144
+ _classCallCheck(this, VictoryCombinedContainer);
145
+
146
+ return _super.apply(this, arguments);
91
147
  }
92
- };
148
+
149
+ _createClass(VictoryCombinedContainer, [{
150
+ key: "getChildren",
151
+ value: function getChildren(props) {
152
+ return instances.reduce(function (children, instance) {
153
+ return instance.getChildren(_objectSpread(_objectSpread({}, props), {}, {
154
+ children: children
155
+ }));
156
+ }, props.children);
157
+ }
158
+ }]);
159
+
160
+ return VictoryCombinedContainer;
161
+ }(NaiveCombinedContainer), _class.displayName = "Victory".concat(displayType, "Container"), _class.propTypes = Classes.reduce(function (propTypes, Class) {
162
+ return _objectSpread(_objectSpread({}, propTypes), Class.propTypes);
163
+ }, {}), _class.defaultProps = Classes.reduce(function (defaultProps, Class) {
164
+ return _objectSpread(_objectSpread({}, defaultProps), Class.defaultProps);
165
+ }, {}), _class.defaultEvents = function (props) {
166
+ return combineDefaultEvents(Classes.reduce(function (defaultEvents, Class) {
167
+ var events = Helpers.isFunction(Class.defaultEvents) ? Class.defaultEvents(props) : Class.defaultEvents;
168
+ return [].concat(_toConsumableArray(defaultEvents), _toConsumableArray(events));
169
+ }, []));
170
+ }, _class;
93
171
  };
94
- const checkBehaviorName = (behavior, behaviors) => {
95
- if (behavior && !_includes(behaviors, behavior)) {
96
- Log.warn(`"${behavior}" is not a valid behavior. Choose from [${behaviors.join(", ")}].`);
172
+
173
+ var checkBehaviorName = function (behavior, behaviors) {
174
+ if (behavior && !behaviors.includes(behavior)) {
175
+ Log.warn("\"".concat(behavior, "\" is not a valid behavior. Choose from [").concat(behaviors.join(", "), "]."));
97
176
  }
98
177
  };
99
- export const makeCreateContainerFunction = (mixinMap, Container) => function (behaviorA, behaviorB) {
100
- const behaviors = Object.keys(mixinMap);
101
- checkBehaviorName(behaviorA, behaviors);
102
- checkBehaviorName(behaviorB, behaviors);
103
- if (arguments.length <= 2 ? 0 : arguments.length - 2) {
104
- Log.warn("too many arguments given to createContainer (maximum accepted: 2).");
105
- }
106
- const firstMixins = mixinMap[behaviorA];
107
- const secondMixins = mixinMap[behaviorB] || [];
108
- if (!firstMixins) {
109
- return Container;
110
- }
111
- return combineContainerMixins([...firstMixins, ...secondMixins], Container);
178
+
179
+ export var makeCreateContainerFunction = function (mixinMap, Container) {
180
+ return function (behaviorA, behaviorB) {
181
+ var behaviors = Object.keys(mixinMap);
182
+ checkBehaviorName(behaviorA, behaviors);
183
+ checkBehaviorName(behaviorB, behaviors);
184
+
185
+ if (arguments.length <= 2 ? 0 : arguments.length - 2) {
186
+ Log.warn("too many arguments given to createContainer (maximum accepted: 2).");
187
+ }
188
+
189
+ var firstMixins = mixinMap[behaviorA];
190
+ var secondMixins = mixinMap[behaviorB] || [];
191
+
192
+ if (!firstMixins) {
193
+ return Container;
194
+ }
195
+
196
+ return combineContainerMixins([].concat(_toConsumableArray(firstMixins), _toConsumableArray(secondMixins)), Container);
197
+ };
112
198
  };
113
- export const createContainer = makeCreateContainerFunction({
199
+ export var createContainer = makeCreateContainerFunction({
114
200
  zoom: [zoomContainerMixin],
115
201
  voronoi: [voronoiContainerMixin],
116
202
  selection: [selectionContainerMixin],
@@ -4,40 +4,101 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.makeCreateContainerFunction = exports.createContainer = exports.combineContainerMixins = void 0;
7
+
7
8
  var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
9
+
8
10
  var _flow2 = _interopRequireDefault(require("lodash/flow"));
9
- var _includes2 = _interopRequireDefault(require("lodash/includes"));
11
+
10
12
  var _forOwn2 = _interopRequireDefault(require("lodash/forOwn"));
13
+
11
14
  var _groupBy2 = _interopRequireDefault(require("lodash/groupBy"));
15
+
12
16
  var _toPairs2 = _interopRequireDefault(require("lodash/toPairs"));
17
+
13
18
  var _victoryCore = require("victory-core");
19
+
14
20
  var _victoryVoronoiContainer = require("victory-voronoi-container");
21
+
15
22
  var _victoryZoomContainer = require("victory-zoom-container");
23
+
16
24
  var _victorySelectionContainer = require("victory-selection-container");
25
+
17
26
  var _victoryBrushContainer = require("victory-brush-container");
27
+
18
28
  var _victoryCursorContainer = require("victory-cursor-container");
29
+
19
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
32
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
33
+
34
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
35
+
36
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
37
+
38
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
39
+
40
+ 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; }
41
+
42
+ 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; }
43
+
44
+ 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; }
45
+
46
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
47
+
48
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
49
+
50
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
51
+
52
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
53
+
54
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
55
+
56
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
57
+
58
+ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
59
+
60
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
61
+
62
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
63
+
64
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
65
+
66
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
67
+
68
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
69
+
70
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
71
+
72
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
73
+
74
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
75
+
76
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
77
+
20
78
  function ensureArray(thing) {
21
79
  if (!thing) {
22
80
  return [];
23
81
  } else if (!Array.isArray(thing)) {
24
82
  return [thing];
25
83
  }
84
+
26
85
  return thing;
27
86
  }
28
- const combineEventHandlers = eventHandlersArray => {
87
+
88
+ var combineEventHandlers = function (eventHandlersArray) {
29
89
  // takes an array of event handler objects and produces one eventHandlers object
30
90
  // creates a custom combinedHandler() for events with multiple conflicting handlers
31
- return eventHandlersArray.reduce((localHandlers, finalHandlers) => {
32
- (0, _forOwn2.default)(localHandlers, (localHandler, eventName) => {
33
- const existingHandler = finalHandlers[eventName];
91
+ return eventHandlersArray.reduce(function (localHandlers, finalHandlers) {
92
+ (0, _forOwn2.default)(localHandlers, function (localHandler, eventName) {
93
+ var existingHandler = finalHandlers[eventName];
94
+
34
95
  if (existingHandler) {
35
96
  // create new handler for event that concats the existing handler's mutations with new ones
36
97
  finalHandlers[eventName] = function combinedHandler() {
37
98
  // named for debug clarity
38
99
  // sometimes handlers return undefined; use empty array instead, for concat()
39
- const existingMutations = ensureArray(existingHandler(...arguments));
40
- const localMutations = ensureArray(localHandler(...arguments));
100
+ var existingMutations = ensureArray(existingHandler.apply(void 0, arguments));
101
+ var localMutations = ensureArray(localHandler.apply(void 0, arguments));
41
102
  return existingMutations.concat(localMutations);
42
103
  };
43
104
  } else {
@@ -47,82 +108,116 @@ const combineEventHandlers = eventHandlersArray => {
47
108
  return finalHandlers;
48
109
  });
49
110
  };
50
- const combineDefaultEvents = defaultEvents => {
111
+
112
+ var combineDefaultEvents = function (defaultEvents) {
51
113
  // takes a defaultEvents array and returns one equal or lesser length,
52
114
  // by combining any events that have the same target
53
- const eventsByTarget = (0, _groupBy2.default)(defaultEvents, "target");
54
- const events = (0, _toPairs2.default)(eventsByTarget).map(_ref => {
55
- let [target, eventsArray] = _ref;
56
- const newEventsArray = eventsArray.filter(Boolean);
115
+ var eventsByTarget = (0, _groupBy2.default)(defaultEvents, "target");
116
+ var events = (0, _toPairs2.default)(eventsByTarget).map(function (_ref) {
117
+ var _ref2 = _slicedToArray(_ref, 2),
118
+ target = _ref2[0],
119
+ eventsArray = _ref2[1];
120
+
121
+ var newEventsArray = eventsArray.filter(Boolean);
57
122
  return (0, _isEmpty2.default)(newEventsArray) ? null : {
58
- target,
59
- eventHandlers: combineEventHandlers(eventsArray.map(event => event.eventHandlers))
60
- // note: does not currently handle eventKey or childName
123
+ target: target,
124
+ eventHandlers: combineEventHandlers(eventsArray.map(function (event) {
125
+ return event.eventHandlers;
126
+ })) // note: does not currently handle eventKey or childName
127
+
61
128
  };
62
129
  });
63
130
  return events.filter(Boolean);
64
131
  };
65
- const combineContainerMixins = (mixins, Container) => {
132
+
133
+ var combineContainerMixins = function (mixins, Container) {
134
+ var _class;
135
+
66
136
  // similar to Object.assign(A, B), this function will decide conflicts in favor mixinB.
67
137
  // this applies to propTypes and defaultProps.
68
138
  // getChildren will call A's getChildren() and pass the resulting children to B's.
69
139
  // defaultEvents attempts to resolve any conflicts between A and B's defaultEvents.
70
- const Classes = mixins.map(mixin => mixin(Container));
71
- const instances = Classes.map(Class => new Class());
72
- const NaiveCombinedContainer = (0, _flow2.default)(mixins)(Container);
73
- const displayType = Classes.map(Class => {
74
- const match = Class.displayName.match(/Victory(.*)Container/);
140
+ var Classes = mixins.map(function (mixin) {
141
+ return mixin(Container);
142
+ });
143
+ var instances = Classes.map(function (Class) {
144
+ return new Class();
145
+ });
146
+ var NaiveCombinedContainer = (0, _flow2.default)(mixins)(Container);
147
+ var displayType = Classes.map(function (Class) {
148
+ var match = Class.displayName.match(/Victory(.*)Container/);
75
149
  return match[1] || "";
76
150
  }).join("");
77
- return class VictoryCombinedContainer extends NaiveCombinedContainer {
78
- static displayName = `Victory${displayType}Container`;
79
- static propTypes = Classes.reduce((propTypes, Class) => ({
80
- ...propTypes,
81
- ...Class.propTypes
82
- }), {});
83
- static defaultProps = Classes.reduce((defaultProps, Class) => ({
84
- ...defaultProps,
85
- ...Class.defaultProps
86
- }), {});
87
- static defaultEvents = props => {
88
- return combineDefaultEvents(Classes.reduce((defaultEvents, Class) => {
89
- const events = _victoryCore.Helpers.isFunction(Class.defaultEvents) ? Class.defaultEvents(props) : Class.defaultEvents;
90
- return [...defaultEvents, ...events];
91
- }, []));
92
- };
93
- getChildren(props) {
94
- return instances.reduce((children, instance) => instance.getChildren({
95
- ...props,
96
- children
97
- }), props.children);
151
+ return _class = /*#__PURE__*/function (_NaiveCombinedContain) {
152
+ _inherits(VictoryCombinedContainer, _NaiveCombinedContain);
153
+
154
+ var _super = _createSuper(VictoryCombinedContainer);
155
+
156
+ function VictoryCombinedContainer() {
157
+ _classCallCheck(this, VictoryCombinedContainer);
158
+
159
+ return _super.apply(this, arguments);
98
160
  }
99
- };
161
+
162
+ _createClass(VictoryCombinedContainer, [{
163
+ key: "getChildren",
164
+ value: function getChildren(props) {
165
+ return instances.reduce(function (children, instance) {
166
+ return instance.getChildren(_objectSpread(_objectSpread({}, props), {}, {
167
+ children: children
168
+ }));
169
+ }, props.children);
170
+ }
171
+ }]);
172
+
173
+ return VictoryCombinedContainer;
174
+ }(NaiveCombinedContainer), _class.displayName = "Victory".concat(displayType, "Container"), _class.propTypes = Classes.reduce(function (propTypes, Class) {
175
+ return _objectSpread(_objectSpread({}, propTypes), Class.propTypes);
176
+ }, {}), _class.defaultProps = Classes.reduce(function (defaultProps, Class) {
177
+ return _objectSpread(_objectSpread({}, defaultProps), Class.defaultProps);
178
+ }, {}), _class.defaultEvents = function (props) {
179
+ return combineDefaultEvents(Classes.reduce(function (defaultEvents, Class) {
180
+ var events = _victoryCore.Helpers.isFunction(Class.defaultEvents) ? Class.defaultEvents(props) : Class.defaultEvents;
181
+ return [].concat(_toConsumableArray(defaultEvents), _toConsumableArray(events));
182
+ }, []));
183
+ }, _class;
100
184
  };
185
+
101
186
  exports.combineContainerMixins = combineContainerMixins;
102
- const checkBehaviorName = (behavior, behaviors) => {
103
- if (behavior && !(0, _includes2.default)(behaviors, behavior)) {
104
- _victoryCore.Log.warn(`"${behavior}" is not a valid behavior. Choose from [${behaviors.join(", ")}].`);
187
+
188
+ var checkBehaviorName = function (behavior, behaviors) {
189
+ if (behavior && !behaviors.includes(behavior)) {
190
+ _victoryCore.Log.warn("\"".concat(behavior, "\" is not a valid behavior. Choose from [").concat(behaviors.join(", "), "]."));
105
191
  }
106
192
  };
107
- const makeCreateContainerFunction = (mixinMap, Container) => function (behaviorA, behaviorB) {
108
- const behaviors = Object.keys(mixinMap);
109
- checkBehaviorName(behaviorA, behaviors);
110
- checkBehaviorName(behaviorB, behaviors);
111
- if (arguments.length <= 2 ? 0 : arguments.length - 2) {
112
- _victoryCore.Log.warn("too many arguments given to createContainer (maximum accepted: 2).");
113
- }
114
- const firstMixins = mixinMap[behaviorA];
115
- const secondMixins = mixinMap[behaviorB] || [];
116
- if (!firstMixins) {
117
- return Container;
118
- }
119
- return combineContainerMixins([...firstMixins, ...secondMixins], Container);
193
+
194
+ var makeCreateContainerFunction = function (mixinMap, Container) {
195
+ return function (behaviorA, behaviorB) {
196
+ var behaviors = Object.keys(mixinMap);
197
+ checkBehaviorName(behaviorA, behaviors);
198
+ checkBehaviorName(behaviorB, behaviors);
199
+
200
+ if (arguments.length <= 2 ? 0 : arguments.length - 2) {
201
+ _victoryCore.Log.warn("too many arguments given to createContainer (maximum accepted: 2).");
202
+ }
203
+
204
+ var firstMixins = mixinMap[behaviorA];
205
+ var secondMixins = mixinMap[behaviorB] || [];
206
+
207
+ if (!firstMixins) {
208
+ return Container;
209
+ }
210
+
211
+ return combineContainerMixins([].concat(_toConsumableArray(firstMixins), _toConsumableArray(secondMixins)), Container);
212
+ };
120
213
  };
214
+
121
215
  exports.makeCreateContainerFunction = makeCreateContainerFunction;
122
- const createContainer = exports.createContainer = makeCreateContainerFunction({
216
+ var createContainer = makeCreateContainerFunction({
123
217
  zoom: [_victoryZoomContainer.zoomContainerMixin],
124
218
  voronoi: [_victoryVoronoiContainer.voronoiContainerMixin],
125
219
  selection: [_victorySelectionContainer.selectionContainerMixin],
126
220
  cursor: [_victoryCursorContainer.cursorContainerMixin],
127
221
  brush: [_victoryBrushContainer.brushContainerMixin]
128
- }, _victoryCore.VictoryContainer);
222
+ }, _victoryCore.VictoryContainer);
223
+ exports.createContainer = createContainer;
package/lib/index.js CHANGED
@@ -3,7 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+
6
7
  var _createContainer = require("./create-container");
8
+
7
9
  Object.keys(_createContainer).forEach(function (key) {
8
10
  if (key === "default" || key === "__esModule") return;
9
11
  if (key in exports && exports[key] === _createContainer[key]) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-create-container",
3
- "version": "36.9.2-next.0",
3
+ "version": "36.9.2-next.3",
4
4
  "description": "Container Helper for Victory",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -21,12 +21,12 @@
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
23
  "lodash": "^4.17.19",
24
- "victory-brush-container": "^36.9.2-next.0",
25
- "victory-core": "^36.9.2-next.0",
26
- "victory-cursor-container": "^36.9.2-next.0",
27
- "victory-selection-container": "^36.9.2-next.0",
28
- "victory-voronoi-container": "^36.9.2-next.0",
29
- "victory-zoom-container": "^36.9.2-next.0"
24
+ "victory-brush-container": "^36.9.2-next.3",
25
+ "victory-core": "^36.9.2-next.3",
26
+ "victory-cursor-container": "^36.9.2-next.3",
27
+ "victory-selection-container": "^36.9.2-next.3",
28
+ "victory-voronoi-container": "^36.9.2-next.3",
29
+ "victory-zoom-container": "^36.9.2-next.3"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=16.6.0"