Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

victory-create-container

Package Overview
Dependencies
Maintainers
16
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

victory-create-container - npm Package Compare versions

Comparing version 36.9.1 to 36.9.2-next.0

17

CHANGELOG.md
# victory-create-container
## 36.9.2-next.0
### Patch Changes
- 6e34169a5: Replace lodash isFunction with native code
- Updated dependencies [3f2da66e3]
- Updated dependencies [c13308624]
- Updated dependencies [cf42d6e4e]
- Updated dependencies [f6f7cc515]
- Updated dependencies [6e34169a5]
- victory-core@36.9.2-next.0
- victory-brush-container@36.9.2-next.0
- victory-cursor-container@36.9.2-next.0
- victory-selection-container@36.9.2-next.0
- victory-voronoi-container@36.9.2-next.0
- victory-zoom-container@36.9.2-next.0
## 36.9.1

@@ -4,0 +21,0 @@

0

es/create-container.d.ts

@@ -0,0 +0,0 @@ import React from "react";

206

es/create-container.js

@@ -1,2 +0,1 @@

import _isFunction from "lodash/isFunction";
import _isEmpty from "lodash/isEmpty";

@@ -8,50 +7,3 @@ import _flow from "lodash/flow";

import _toPairs from "lodash/toPairs";
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
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."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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; }
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; }
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; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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); }; }
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); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
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; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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."); }
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); }
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; }
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; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import { VictoryContainer, Log } from "victory-core";
import { Helpers, VictoryContainer, Log } from "victory-core";
import { voronoiContainerMixin } from "victory-voronoi-container";

@@ -62,3 +14,2 @@ import { zoomContainerMixin } from "victory-zoom-container";

import { cursorContainerMixin } from "victory-cursor-container";
function ensureArray(thing) {

@@ -70,13 +21,10 @@ if (!thing) {

}
return thing;
}
var combineEventHandlers = function (eventHandlersArray) {
const combineEventHandlers = eventHandlersArray => {
// takes an array of event handler objects and produces one eventHandlers object
// creates a custom combinedHandler() for events with multiple conflicting handlers
return eventHandlersArray.reduce(function (localHandlers, finalHandlers) {
_forOwn(localHandlers, function (localHandler, eventName) {
var existingHandler = finalHandlers[eventName];
return eventHandlersArray.reduce((localHandlers, finalHandlers) => {
_forOwn(localHandlers, (localHandler, eventName) => {
const existingHandler = finalHandlers[eventName];
if (existingHandler) {

@@ -87,4 +35,4 @@ // create new handler for event that concats the existing handler's mutations with new ones

// sometimes handlers return undefined; use empty array instead, for concat()
var existingMutations = ensureArray(existingHandler.apply(void 0, arguments));
var localMutations = ensureArray(localHandler.apply(void 0, arguments));
const existingMutations = ensureArray(existingHandler(...arguments));
const localMutations = ensureArray(localHandler(...arguments));
return existingMutations.concat(localMutations);

@@ -96,33 +44,21 @@ };

});
return finalHandlers;
});
};
var combineDefaultEvents = function (defaultEvents) {
const combineDefaultEvents = defaultEvents => {
// takes a defaultEvents array and returns one equal or lesser length,
// by combining any events that have the same target
var eventsByTarget = _groupBy(defaultEvents, "target");
var events = _toPairs(eventsByTarget).map(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
target = _ref2[0],
eventsArray = _ref2[1];
var newEventsArray = eventsArray.filter(Boolean);
const eventsByTarget = _groupBy(defaultEvents, "target");
const events = _toPairs(eventsByTarget).map(_ref => {
let [target, eventsArray] = _ref;
const newEventsArray = eventsArray.filter(Boolean);
return _isEmpty(newEventsArray) ? null : {
target: target,
eventHandlers: combineEventHandlers(eventsArray.map(function (event) {
return event.eventHandlers;
})) // note: does not currently handle eventKey or childName
target,
eventHandlers: combineEventHandlers(eventsArray.map(event => event.eventHandlers))
// note: does not currently handle eventKey or childName
};
});
return events.filter(Boolean);
};
export var combineContainerMixins = function (mixins, Container) {
var _class;
export const combineContainerMixins = (mixins, Container) => {
// similar to Object.assign(A, B), this function will decide conflicts in favor mixinB.

@@ -132,77 +68,53 @@ // this applies to propTypes and defaultProps.

// defaultEvents attempts to resolve any conflicts between A and B's defaultEvents.
var Classes = mixins.map(function (mixin) {
return mixin(Container);
});
var instances = Classes.map(function (Class) {
return new Class();
});
var NaiveCombinedContainer = _flow(mixins)(Container);
var displayType = Classes.map(function (Class) {
var match = Class.displayName.match(/Victory(.*)Container/);
const Classes = mixins.map(mixin => mixin(Container));
const instances = Classes.map(Class => new Class());
const NaiveCombinedContainer = _flow(mixins)(Container);
const displayType = Classes.map(Class => {
const match = Class.displayName.match(/Victory(.*)Container/);
return match[1] || "";
}).join("");
return _class = /*#__PURE__*/function (_NaiveCombinedContain) {
_inherits(VictoryCombinedContainer, _NaiveCombinedContain);
var _super = _createSuper(VictoryCombinedContainer);
function VictoryCombinedContainer() {
_classCallCheck(this, VictoryCombinedContainer);
return _super.apply(this, arguments);
return class VictoryCombinedContainer extends NaiveCombinedContainer {
static displayName = `Victory${displayType}Container`;
static propTypes = Classes.reduce((propTypes, Class) => ({
...propTypes,
...Class.propTypes
}), {});
static defaultProps = Classes.reduce((defaultProps, Class) => ({
...defaultProps,
...Class.defaultProps
}), {});
static defaultEvents = props => {
return combineDefaultEvents(Classes.reduce((defaultEvents, Class) => {
const events = Helpers.isFunction(Class.defaultEvents) ? Class.defaultEvents(props) : Class.defaultEvents;
return [...defaultEvents, ...events];
}, []));
};
getChildren(props) {
return instances.reduce((children, instance) => instance.getChildren({
...props,
children
}), props.children);
}
_createClass(VictoryCombinedContainer, [{
key: "getChildren",
value: function getChildren(props) {
return instances.reduce(function (children, instance) {
return instance.getChildren(_objectSpread(_objectSpread({}, props), {}, {
children: children
}));
}, props.children);
}
}]);
return VictoryCombinedContainer;
}(NaiveCombinedContainer), _class.displayName = "Victory".concat(displayType, "Container"), _class.propTypes = Classes.reduce(function (propTypes, Class) {
return _objectSpread(_objectSpread({}, propTypes), Class.propTypes);
}, {}), _class.defaultProps = Classes.reduce(function (defaultProps, Class) {
return _objectSpread(_objectSpread({}, defaultProps), Class.defaultProps);
}, {}), _class.defaultEvents = function (props) {
return combineDefaultEvents(Classes.reduce(function (defaultEvents, Class) {
var events = _isFunction(Class.defaultEvents) ? Class.defaultEvents(props) : Class.defaultEvents;
return [].concat(_toConsumableArray(defaultEvents), _toConsumableArray(events));
}, []));
}, _class;
};
};
var checkBehaviorName = function (behavior, behaviors) {
const checkBehaviorName = (behavior, behaviors) => {
if (behavior && !_includes(behaviors, behavior)) {
Log.warn("\"".concat(behavior, "\" is not a valid behavior. Choose from [").concat(behaviors.join(", "), "]."));
Log.warn(`"${behavior}" is not a valid behavior. Choose from [${behaviors.join(", ")}].`);
}
};
export var makeCreateContainerFunction = function (mixinMap, Container) {
return function (behaviorA, behaviorB) {
var behaviors = Object.keys(mixinMap);
checkBehaviorName(behaviorA, behaviors);
checkBehaviorName(behaviorB, behaviors);
if (arguments.length <= 2 ? 0 : arguments.length - 2) {
Log.warn("too many arguments given to createContainer (maximum accepted: 2).");
}
var firstMixins = mixinMap[behaviorA];
var secondMixins = mixinMap[behaviorB] || [];
if (!firstMixins) {
return Container;
}
return combineContainerMixins([].concat(_toConsumableArray(firstMixins), _toConsumableArray(secondMixins)), Container);
};
export const makeCreateContainerFunction = (mixinMap, Container) => function (behaviorA, behaviorB) {
const behaviors = Object.keys(mixinMap);
checkBehaviorName(behaviorA, behaviors);
checkBehaviorName(behaviorB, behaviors);
if (arguments.length <= 2 ? 0 : arguments.length - 2) {
Log.warn("too many arguments given to createContainer (maximum accepted: 2).");
}
const firstMixins = mixinMap[behaviorA];
const secondMixins = mixinMap[behaviorB] || [];
if (!firstMixins) {
return Container;
}
return combineContainerMixins([...firstMixins, ...secondMixins], Container);
};
export var createContainer = makeCreateContainerFunction({
export const createContainer = makeCreateContainerFunction({
zoom: [zoomContainerMixin],

@@ -209,0 +121,0 @@ voronoi: [voronoiContainerMixin],

export * from "./create-container";
//# sourceMappingURL=index.d.ts.map

@@ -0,0 +0,0 @@ import React from "react";

@@ -7,77 +7,15 @@ "use strict";

exports.makeCreateContainerFunction = exports.createContainer = exports.combineContainerMixins = void 0;
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
var _flow2 = _interopRequireDefault(require("lodash/flow"));
var _includes2 = _interopRequireDefault(require("lodash/includes"));
var _forOwn2 = _interopRequireDefault(require("lodash/forOwn"));
var _groupBy2 = _interopRequireDefault(require("lodash/groupBy"));
var _toPairs2 = _interopRequireDefault(require("lodash/toPairs"));
var _victoryCore = require("victory-core");
var _victoryVoronoiContainer = require("victory-voronoi-container");
var _victoryZoomContainer = require("victory-zoom-container");
var _victorySelectionContainer = require("victory-selection-container");
var _victoryBrushContainer = require("victory-brush-container");
var _victoryCursorContainer = require("victory-cursor-container");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
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."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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; }
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; }
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; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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); }; }
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); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
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; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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."); }
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); }
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; }
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; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function ensureArray(thing) {

@@ -89,13 +27,10 @@ if (!thing) {

}
return thing;
}
var combineEventHandlers = function (eventHandlersArray) {
const combineEventHandlers = eventHandlersArray => {
// takes an array of event handler objects and produces one eventHandlers object
// creates a custom combinedHandler() for events with multiple conflicting handlers
return eventHandlersArray.reduce(function (localHandlers, finalHandlers) {
(0, _forOwn2.default)(localHandlers, function (localHandler, eventName) {
var existingHandler = finalHandlers[eventName];
return eventHandlersArray.reduce((localHandlers, finalHandlers) => {
(0, _forOwn2.default)(localHandlers, (localHandler, eventName) => {
const existingHandler = finalHandlers[eventName];
if (existingHandler) {

@@ -106,4 +41,4 @@ // create new handler for event that concats the existing handler's mutations with new ones

// sometimes handlers return undefined; use empty array instead, for concat()
var existingMutations = ensureArray(existingHandler.apply(void 0, arguments));
var localMutations = ensureArray(localHandler.apply(void 0, arguments));
const existingMutations = ensureArray(existingHandler(...arguments));
const localMutations = ensureArray(localHandler(...arguments));
return existingMutations.concat(localMutations);

@@ -118,19 +53,13 @@ };

};
var combineDefaultEvents = function (defaultEvents) {
const combineDefaultEvents = defaultEvents => {
// takes a defaultEvents array and returns one equal or lesser length,
// by combining any events that have the same target
var eventsByTarget = (0, _groupBy2.default)(defaultEvents, "target");
var events = (0, _toPairs2.default)(eventsByTarget).map(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
target = _ref2[0],
eventsArray = _ref2[1];
var newEventsArray = eventsArray.filter(Boolean);
const eventsByTarget = (0, _groupBy2.default)(defaultEvents, "target");
const events = (0, _toPairs2.default)(eventsByTarget).map(_ref => {
let [target, eventsArray] = _ref;
const newEventsArray = eventsArray.filter(Boolean);
return (0, _isEmpty2.default)(newEventsArray) ? null : {
target: target,
eventHandlers: combineEventHandlers(eventsArray.map(function (event) {
return event.eventHandlers;
})) // note: does not currently handle eventKey or childName
target,
eventHandlers: combineEventHandlers(eventsArray.map(event => event.eventHandlers))
// note: does not currently handle eventKey or childName
};

@@ -140,6 +69,3 @@ });

};
var combineContainerMixins = function (mixins, Container) {
var _class;
const combineContainerMixins = (mixins, Container) => {
// similar to Object.assign(A, B), this function will decide conflicts in favor mixinB.

@@ -149,79 +75,55 @@ // this applies to propTypes and defaultProps.

// defaultEvents attempts to resolve any conflicts between A and B's defaultEvents.
var Classes = mixins.map(function (mixin) {
return mixin(Container);
});
var instances = Classes.map(function (Class) {
return new Class();
});
var NaiveCombinedContainer = (0, _flow2.default)(mixins)(Container);
var displayType = Classes.map(function (Class) {
var match = Class.displayName.match(/Victory(.*)Container/);
const Classes = mixins.map(mixin => mixin(Container));
const instances = Classes.map(Class => new Class());
const NaiveCombinedContainer = (0, _flow2.default)(mixins)(Container);
const displayType = Classes.map(Class => {
const match = Class.displayName.match(/Victory(.*)Container/);
return match[1] || "";
}).join("");
return _class = /*#__PURE__*/function (_NaiveCombinedContain) {
_inherits(VictoryCombinedContainer, _NaiveCombinedContain);
var _super = _createSuper(VictoryCombinedContainer);
function VictoryCombinedContainer() {
_classCallCheck(this, VictoryCombinedContainer);
return _super.apply(this, arguments);
return class VictoryCombinedContainer extends NaiveCombinedContainer {
static displayName = `Victory${displayType}Container`;
static propTypes = Classes.reduce((propTypes, Class) => ({
...propTypes,
...Class.propTypes
}), {});
static defaultProps = Classes.reduce((defaultProps, Class) => ({
...defaultProps,
...Class.defaultProps
}), {});
static defaultEvents = props => {
return combineDefaultEvents(Classes.reduce((defaultEvents, Class) => {
const events = _victoryCore.Helpers.isFunction(Class.defaultEvents) ? Class.defaultEvents(props) : Class.defaultEvents;
return [...defaultEvents, ...events];
}, []));
};
getChildren(props) {
return instances.reduce((children, instance) => instance.getChildren({
...props,
children
}), props.children);
}
_createClass(VictoryCombinedContainer, [{
key: "getChildren",
value: function getChildren(props) {
return instances.reduce(function (children, instance) {
return instance.getChildren(_objectSpread(_objectSpread({}, props), {}, {
children: children
}));
}, props.children);
}
}]);
return VictoryCombinedContainer;
}(NaiveCombinedContainer), _class.displayName = "Victory".concat(displayType, "Container"), _class.propTypes = Classes.reduce(function (propTypes, Class) {
return _objectSpread(_objectSpread({}, propTypes), Class.propTypes);
}, {}), _class.defaultProps = Classes.reduce(function (defaultProps, Class) {
return _objectSpread(_objectSpread({}, defaultProps), Class.defaultProps);
}, {}), _class.defaultEvents = function (props) {
return combineDefaultEvents(Classes.reduce(function (defaultEvents, Class) {
var events = (0, _isFunction2.default)(Class.defaultEvents) ? Class.defaultEvents(props) : Class.defaultEvents;
return [].concat(_toConsumableArray(defaultEvents), _toConsumableArray(events));
}, []));
}, _class;
};
};
exports.combineContainerMixins = combineContainerMixins;
var checkBehaviorName = function (behavior, behaviors) {
const checkBehaviorName = (behavior, behaviors) => {
if (behavior && !(0, _includes2.default)(behaviors, behavior)) {
_victoryCore.Log.warn("\"".concat(behavior, "\" is not a valid behavior. Choose from [").concat(behaviors.join(", "), "]."));
_victoryCore.Log.warn(`"${behavior}" is not a valid behavior. Choose from [${behaviors.join(", ")}].`);
}
};
var makeCreateContainerFunction = function (mixinMap, Container) {
return function (behaviorA, behaviorB) {
var behaviors = Object.keys(mixinMap);
checkBehaviorName(behaviorA, behaviors);
checkBehaviorName(behaviorB, behaviors);
if (arguments.length <= 2 ? 0 : arguments.length - 2) {
_victoryCore.Log.warn("too many arguments given to createContainer (maximum accepted: 2).");
}
var firstMixins = mixinMap[behaviorA];
var secondMixins = mixinMap[behaviorB] || [];
if (!firstMixins) {
return Container;
}
return combineContainerMixins([].concat(_toConsumableArray(firstMixins), _toConsumableArray(secondMixins)), Container);
};
const makeCreateContainerFunction = (mixinMap, Container) => function (behaviorA, behaviorB) {
const behaviors = Object.keys(mixinMap);
checkBehaviorName(behaviorA, behaviors);
checkBehaviorName(behaviorB, behaviors);
if (arguments.length <= 2 ? 0 : arguments.length - 2) {
_victoryCore.Log.warn("too many arguments given to createContainer (maximum accepted: 2).");
}
const firstMixins = mixinMap[behaviorA];
const secondMixins = mixinMap[behaviorB] || [];
if (!firstMixins) {
return Container;
}
return combineContainerMixins([...firstMixins, ...secondMixins], Container);
};
exports.makeCreateContainerFunction = makeCreateContainerFunction;
var createContainer = makeCreateContainerFunction({
const createContainer = exports.createContainer = makeCreateContainerFunction({
zoom: [_victoryZoomContainer.zoomContainerMixin],

@@ -232,3 +134,2 @@ voronoi: [_victoryVoronoiContainer.voronoiContainerMixin],

brush: [_victoryBrushContainer.brushContainerMixin]
}, _victoryCore.VictoryContainer);
exports.createContainer = createContainer;
}, _victoryCore.VictoryContainer);
export * from "./create-container";
//# sourceMappingURL=index.d.ts.map

@@ -6,5 +6,3 @@ "use strict";

});
var _createContainer = require("./create-container");
Object.keys(_createContainer).forEach(function (key) {

@@ -11,0 +9,0 @@ if (key === "default" || key === "__esModule") return;

{
"name": "victory-create-container",
"version": "36.9.1",
"version": "36.9.2-next.0",
"description": "Container Helper for Victory",

@@ -24,8 +24,8 @@ "keywords": [

"lodash": "^4.17.19",
"victory-brush-container": "^36.9.1",
"victory-core": "^36.9.1",
"victory-cursor-container": "^36.9.1",
"victory-selection-container": "^36.9.1",
"victory-voronoi-container": "^36.9.1",
"victory-zoom-container": "^36.9.1"
"victory-brush-container": "^36.9.2-next.0",
"victory-core": "^36.9.2-next.0",
"victory-cursor-container": "^36.9.2-next.0",
"victory-selection-container": "^36.9.2-next.0",
"victory-voronoi-container": "^36.9.2-next.0",
"victory-zoom-container": "^36.9.2-next.0"
},

@@ -35,5 +35,2 @@ "peerDependencies": {

},
"publishConfig": {
"provenance": true
},
"wireit": {

@@ -291,3 +288,3 @@ "### THESE WIREIT CONFIGS ARE GENERATED ####": {},

"jest": {
"command": "nps jest:pkg",
"command": "jest --passWithNoTests",
"files": [

@@ -301,5 +298,10 @@ "src/**/*.test.*",

"dependencies": [
"build:lib:cjs",
"../victory-vendor:build:lib:cjs",
"../victory-voronoi:build:lib:cjs"
"../victory-brush-container:build",
"../victory-core:build",
"../victory-cursor-container:build",
"../victory-selection-container:build",
"../victory-voronoi-container:build",
"../victory-zoom-container:build",
"../victory-vendor:build",
"../victory-voronoi:build"
],

@@ -306,0 +308,0 @@ "packageLocks": [

import React from "react";
import {
toPairs,
groupBy,
forOwn,
includes,
flow,
isEmpty,
isFunction,
} from "lodash";
import { VictoryContainer, Log } from "victory-core";
import { toPairs, groupBy, forOwn, includes, flow, isEmpty } from "lodash";
import { Helpers, VictoryContainer, Log } from "victory-core";
import { voronoiContainerMixin } from "victory-voronoi-container";

@@ -111,3 +103,3 @@ import { zoomContainerMixin } from "victory-zoom-container";

Classes.reduce((defaultEvents, Class) => {
const events = isFunction(Class.defaultEvents)
const events = Helpers.isFunction(Class.defaultEvents)
? Class.defaultEvents(props)

@@ -114,0 +106,0 @@ : Class.defaultEvents;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc