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

@vx/responsive

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vx/responsive - npm Package Compare versions

Comparing version 0.0.179 to 0.0.182

154

build/components/ParentSize.js

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

'use strict';
"use strict";

@@ -6,46 +6,61 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = void 0;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _debounce = _interopRequireDefault(require("lodash/debounce"));
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _propTypes = _interopRequireDefault(require("prop-types"));
var _debounce = require('lodash/debounce');
var _react = _interopRequireDefault(require("react"));
var _debounce2 = _interopRequireDefault(_debounce);
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
var _propTypes = require('prop-types');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _propTypes2 = _interopRequireDefault(_propTypes);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _react = require('react');
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _react2 = _interopRequireDefault(_react);
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
var _resizeObserverPolyfill = require('resize-observer-polyfill');
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; }
var _resizeObserverPolyfill2 = _interopRequireDefault(_resizeObserverPolyfill);
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
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 _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var ParentSize = function (_React$Component) {
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
var ParentSize =
/*#__PURE__*/
function (_React$Component) {
_inherits(ParentSize, _React$Component);
function ParentSize(props) {
var _this;
_classCallCheck(this, ParentSize);
var _this = _possibleConstructorReturn(this, (ParentSize.__proto__ || Object.getPrototypeOf(ParentSize)).call(this, props));
_this = _possibleConstructorReturn(this, _getPrototypeOf(ParentSize).call(this, props));
_this.state = {
width: 0, height: 0, top: 0, left: 0
width: 0,
height: 0,
top: 0,
left: 0
};
_this.resize = (0, _debounce2.default)(_this.resize.bind(_this), props.debounceTime);
_this.setTarget = _this.setTarget.bind(_this);
_this.resize = (0, _debounce.default)(_this.resize.bind(_assertThisInitialized(_assertThisInitialized(_this))), props.debounceTime);
_this.setTarget = _this.setTarget.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.animationFrameID = null;

@@ -56,24 +71,7 @@ return _this;

_createClass(ParentSize, [{
key: 'componentDidMount',
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
this.ro = new _resizeObserverPolyfill2.default(function (entries, observer) {
var _loop = function _loop(entry) {
var _entry$contentRect = entry.contentRect,
left = _entry$contentRect.left,
top = _entry$contentRect.top,
width = _entry$contentRect.width,
height = _entry$contentRect.height;
_this2.animationFrameID = window.requestAnimationFrame(function () {
_this2.resize({
width: width,
height: height,
top: top,
left: left
});
});
};
this.ro = new _resizeObserverPolyfill.default(function (entries, observer) {
var _iteratorNormalCompletion = true;

@@ -84,6 +82,21 @@ var _didIteratorError = false;

try {
for (var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _loop = function _loop() {
var entry = _step.value;
var _entry$contentRect = entry.contentRect,
left = _entry$contentRect.left,
top = _entry$contentRect.top,
width = _entry$contentRect.width,
height = _entry$contentRect.height;
_this2.animationFrameID = window.requestAnimationFrame(function () {
_this2.resize({
width: width,
height: height,
top: top,
left: left
});
});
};
_loop(entry);
for (var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
_loop();
}

@@ -95,3 +108,3 @@ } catch (err) {

try {
if (!_iteratorNormalCompletion && _iterator.return) {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();

@@ -109,3 +122,3 @@ }

}, {
key: 'componentWillUnmount',
key: "componentWillUnmount",
value: function componentWillUnmount() {

@@ -116,3 +129,3 @@ window.cancelAnimationFrame(this.animationFrameID);

}, {
key: 'resize',
key: "resize",
value: function resize(_ref) {

@@ -123,3 +136,2 @@ var width = _ref.width,

left = _ref.left;
this.setState(function () {

@@ -135,3 +147,3 @@ return {

}, {
key: 'setTarget',
key: "setTarget",
value: function setTarget(ref) {

@@ -141,22 +153,21 @@ this.target = ref;

}, {
key: 'render',
key: "render",
value: function render() {
var _props = this.props,
className = _props.className,
children = _props.children,
debounceTime = _props.debounceTime,
restProps = _objectWithoutProperties(_props, ['className', 'children', 'debounceTime']);
var _this$props = this.props,
className = _this$props.className,
children = _this$props.children,
debounceTime = _this$props.debounceTime,
restProps = _objectWithoutProperties(_this$props, ["className", "children", "debounceTime"]);
return _react2.default.createElement(
'div',
_extends({
style: { width: '100%', height: '100%' },
ref: this.setTarget,
className: className
}, restProps),
children(_extends({}, this.state, {
ref: this.target,
resize: this.resize
}))
);
return _react.default.createElement("div", _extends({
style: {
width: '100%',
height: '100%'
},
ref: this.setTarget,
className: className
}, restProps), children(_objectSpread({}, this.state, {
ref: this.target,
resize: this.resize
})));
}

@@ -166,15 +177,12 @@ }]);

return ParentSize;
}(_react2.default.Component);
}(_react.default.Component);
exports.default = ParentSize;
ParentSize.defaultProps = {
debounceTime: 300
};
ParentSize.propTypes = {
className: _propTypes2.default.string,
children: _propTypes2.default.func.isRequired,
debounceTime: _propTypes2.default.number
className: _propTypes.default.string,
children: _propTypes.default.func.isRequired,
debounceTime: _propTypes.default.number
};

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

'use strict';
"use strict";

@@ -8,19 +8,15 @@ Object.defineProperty(exports, "__esModule", {

var _react = require('react');
var _react = _interopRequireDefault(require("react"));
var _react2 = _interopRequireDefault(_react);
var _propTypes = _interopRequireDefault(require("prop-types"));
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
ResponsiveSVG.propTypes = {
children: _propTypes2.default.func,
width: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
height: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
xOrigin: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
yOrigin: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
preserveAspectRatio: _propTypes2.default.string
children: _propTypes.default.func,
width: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
height: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
xOrigin: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
yOrigin: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
preserveAspectRatio: _propTypes.default.string
};

@@ -33,28 +29,19 @@

_ref$xOrigin = _ref.xOrigin,
xOrigin = _ref$xOrigin === undefined ? 0 : _ref$xOrigin,
xOrigin = _ref$xOrigin === void 0 ? 0 : _ref$xOrigin,
_ref$yOrigin = _ref.yOrigin,
yOrigin = _ref$yOrigin === undefined ? 0 : _ref$yOrigin,
yOrigin = _ref$yOrigin === void 0 ? 0 : _ref$yOrigin,
_ref$preserveAspectRa = _ref.preserveAspectRatio,
preserveAspectRatio = _ref$preserveAspectRa === undefined ? 'xMinYMin meet' : _ref$preserveAspectRa;
return _react2.default.createElement(
'div',
{
style: {
display: 'inline-block',
position: 'relative',
width: '100%',
verticalAlign: 'top',
overflow: 'hidden'
}
},
_react2.default.createElement(
'svg',
{
preserveAspectRatio: preserveAspectRatio,
viewBox: xOrigin + ' ' + yOrigin + ' ' + width + ' ' + height
},
children
)
);
preserveAspectRatio = _ref$preserveAspectRa === void 0 ? 'xMinYMin meet' : _ref$preserveAspectRa;
return _react.default.createElement("div", {
style: {
display: 'inline-block',
position: 'relative',
width: '100%',
verticalAlign: 'top',
overflow: 'hidden'
}
}, _react.default.createElement("svg", {
preserveAspectRatio: preserveAspectRatio,
viewBox: "".concat(xOrigin, " ").concat(yOrigin, " ").concat(width, " ").concat(height)
}, children));
}

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

'use strict';
"use strict";

@@ -6,38 +6,44 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = withParentSize;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = _interopRequireDefault(require("react"));
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _debounce = _interopRequireDefault(require("lodash/debounce"));
exports.default = withParentSize;
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
var _react = require('react');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _react2 = _interopRequireDefault(_react);
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _debounce = require('lodash/debounce');
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _debounce2 = _interopRequireDefault(_debounce);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _resizeObserverPolyfill = require('resize-observer-polyfill');
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); } }
var _resizeObserverPolyfill2 = _interopRequireDefault(_resizeObserverPolyfill);
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function withParentSize(BaseComponent) {
var WrappedComponent = function (_React$Component) {
var WrappedComponent =
/*#__PURE__*/
function (_React$Component) {
_inherits(WrappedComponent, _React$Component);
function WrappedComponent(props) {
var _this;
_classCallCheck(this, WrappedComponent);
var _this = _possibleConstructorReturn(this, (WrappedComponent.__proto__ || Object.getPrototypeOf(WrappedComponent)).call(this, props));
_this = _possibleConstructorReturn(this, _getPrototypeOf(WrappedComponent).call(this, props));
_this.state = {

@@ -47,5 +53,4 @@ parentWidth: null,

};
_this.animationFrameID = null;
_this.debouncedResize = (0, _debounce2.default)(_this.resize.bind(_this), props.debounceTime).bind(_this);
_this.debouncedResize = (0, _debounce.default)(_this.resize.bind(_assertThisInitialized(_assertThisInitialized(_this))), props.debounceTime).bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;

@@ -55,7 +60,7 @@ }

_createClass(WrappedComponent, [{
key: 'componentDidMount',
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
this.ro = new _resizeObserverPolyfill2.default(function (entries, observer) {
this.ro = new _resizeObserverPolyfill.default(function (entries, observer) {
entries.forEach(function (entry) {

@@ -65,3 +70,2 @@ var _entry$contentRect = entry.contentRect,

height = _entry$contentRect.height;
_this2.animationFrameID = window.requestAnimationFrame(function () {

@@ -78,3 +82,3 @@ _this2.debouncedResize({

}, {
key: 'componentWillUnmount',
key: "componentWillUnmount",
value: function componentWillUnmount() {

@@ -85,7 +89,6 @@ window.cancelAnimationFrame(this.animationFrameID);

}, {
key: 'resize',
key: "resize",
value: function resize(_ref) {
var width = _ref.width,
height = _ref.height;
this.setState({

@@ -97,23 +100,21 @@ parentWidth: width,

}, {
key: 'render',
key: "render",
value: function render() {
var _this3 = this;
var _state = this.state,
parentWidth = _state.parentWidth,
parentHeight = _state.parentHeight;
return _react2.default.createElement(
'div',
{
style: { width: '100%', height: '100%' },
ref: function ref(_ref2) {
_this3.container = _ref2;
}
var _this$state = this.state,
parentWidth = _this$state.parentWidth,
parentHeight = _this$state.parentHeight;
return _react.default.createElement("div", {
style: {
width: '100%',
height: '100%'
},
parentWidth !== null && parentHeight !== null && _react2.default.createElement(BaseComponent, _extends({
parentWidth: parentWidth,
parentHeight: parentHeight
}, this.props))
);
ref: function ref(_ref2) {
_this3.container = _ref2;
}
}, parentWidth !== null && parentHeight !== null && _react.default.createElement(BaseComponent, _extends({
parentWidth: parentWidth,
parentHeight: parentHeight
}, this.props)));
}

@@ -123,3 +124,3 @@ }]);

return WrappedComponent;
}(_react2.default.Component);
}(_react.default.Component);

@@ -129,4 +130,3 @@ WrappedComponent.defaultProps = {

};
return WrappedComponent;
}

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

'use strict';
"use strict";

@@ -6,34 +6,42 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = withScreenSize;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _debounce = _interopRequireDefault(require("lodash/debounce"));
var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = _interopRequireDefault(require("react"));
exports.default = withScreenSize;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _debounce = require('lodash/debounce');
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var _debounce2 = _interopRequireDefault(_debounce);
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _react = require('react');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _react2 = _interopRequireDefault(_react);
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function withScreenSize(BaseComponent) {
var WrappedComponent = function (_React$Component) {
var WrappedComponent =
/*#__PURE__*/
function (_React$Component) {
_inherits(WrappedComponent, _React$Component);
function WrappedComponent(props) {
var _this;
_classCallCheck(this, WrappedComponent);
var _this = _possibleConstructorReturn(this, (WrappedComponent.__proto__ || Object.getPrototypeOf(WrappedComponent)).call(this, props));
_this = _possibleConstructorReturn(this, _getPrototypeOf(WrappedComponent).call(this, props));
_this.state = {

@@ -43,4 +51,3 @@ screenWidth: null,

};
_this.handleResize = (0, _debounce2.default)(_this.resize.bind(_this), props.windowResizeDebounceTime).bind(_this);
_this.handleResize = (0, _debounce.default)(_this.resize.bind(_assertThisInitialized(_assertThisInitialized(_this))), props.windowResizeDebounceTime).bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;

@@ -50,3 +57,3 @@ }

_createClass(WrappedComponent, [{
key: 'componentDidMount',
key: "componentDidMount",
value: function componentDidMount() {

@@ -57,3 +64,3 @@ window.addEventListener('resize', this.handleResize, false);

}, {
key: 'componentWillUnmount',
key: "componentWillUnmount",
value: function componentWillUnmount() {

@@ -63,3 +70,3 @@ window.removeEventListener('resize', this.handleResize, false);

}, {
key: 'resize',
key: "resize",
value: function resize(event) {

@@ -74,10 +81,12 @@ this.setState(function (prevState, props) {

}, {
key: 'render',
key: "render",
value: function render() {
var _state = this.state,
screenWidth = _state.screenWidth,
screenHeight = _state.screenHeight;
var _this$state = this.state,
screenWidth = _this$state.screenWidth,
screenHeight = _this$state.screenHeight;
if (!screenWidth && !screenHeight) return null;
return _react2.default.createElement(BaseComponent, _extends({ screenWidth: screenWidth, screenHeight: screenHeight }, this.props));
return _react.default.createElement(BaseComponent, _extends({
screenWidth: screenWidth,
screenHeight: screenHeight
}, this.props));
}

@@ -87,3 +96,3 @@ }]);

return WrappedComponent;
}(_react2.default.Component);
}(_react.default.Component);

@@ -93,4 +102,3 @@ WrappedComponent.defaultProps = {

};
return WrappedComponent;
}

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

'use strict';
"use strict";

@@ -6,39 +6,35 @@ Object.defineProperty(exports, "__esModule", {

});
var _ScaleSVG = require('./components/ScaleSVG');
Object.defineProperty(exports, 'ScaleSVG', {
Object.defineProperty(exports, "ScaleSVG", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_ScaleSVG).default;
return _ScaleSVG.default;
}
});
var _ParentSize = require('./components/ParentSize');
Object.defineProperty(exports, 'ParentSize', {
Object.defineProperty(exports, "ParentSize", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_ParentSize).default;
return _ParentSize.default;
}
});
var _withParentSize = require('./enhancers/withParentSize');
Object.defineProperty(exports, 'withParentSize', {
Object.defineProperty(exports, "withParentSize", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_withParentSize).default;
return _withParentSize.default;
}
});
var _withScreenSize = require('./enhancers/withScreenSize');
Object.defineProperty(exports, 'withScreenSize', {
Object.defineProperty(exports, "withScreenSize", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_withScreenSize).default;
return _withScreenSize.default;
}
});
var _ScaleSVG = _interopRequireDefault(require("./components/ScaleSVG"));
var _ParentSize = _interopRequireDefault(require("./components/ParentSize"));
var _withParentSize = _interopRequireDefault(require("./enhancers/withParentSize"));
var _withScreenSize = _interopRequireDefault(require("./enhancers/withScreenSize"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -1,4 +0,4 @@

import React from 'react';
import PropTypes from 'prop-types';
import ResizeObserver from 'resize-observer-polyfill';
import React from 'react';

@@ -13,3 +13,2 @@ ResponsiveSVG.propTypes = {

};
function ResponsiveSVG(_ref) {

@@ -20,30 +19,178 @@ var children = _ref.children,

_ref$xOrigin = _ref.xOrigin,
xOrigin = _ref$xOrigin === undefined ? 0 : _ref$xOrigin,
xOrigin = _ref$xOrigin === void 0 ? 0 : _ref$xOrigin,
_ref$yOrigin = _ref.yOrigin,
yOrigin = _ref$yOrigin === undefined ? 0 : _ref$yOrigin,
yOrigin = _ref$yOrigin === void 0 ? 0 : _ref$yOrigin,
_ref$preserveAspectRa = _ref.preserveAspectRatio,
preserveAspectRatio = _ref$preserveAspectRa === undefined ? 'xMinYMin meet' : _ref$preserveAspectRa;
preserveAspectRatio = _ref$preserveAspectRa === void 0 ? 'xMinYMin meet' : _ref$preserveAspectRa;
return React.createElement("div", {
style: {
display: 'inline-block',
position: 'relative',
width: '100%',
verticalAlign: 'top',
overflow: 'hidden'
}
}, React.createElement("svg", {
preserveAspectRatio: preserveAspectRatio,
viewBox: "".concat(xOrigin, " ").concat(yOrigin, " ").concat(width, " ").concat(height)
}, children));
}
return React.createElement(
'div',
{
style: {
display: 'inline-block',
position: 'relative',
width: '100%',
verticalAlign: 'top',
overflow: 'hidden'
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);
return Constructor;
}
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 _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
},
React.createElement(
'svg',
{
preserveAspectRatio: preserveAspectRatio,
viewBox: xOrigin + ' ' + yOrigin + ' ' + width + ' ' + height
},
children
)
);
}
return target;
};
return _extends.apply(this, arguments);
}
function _objectSpread(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
}
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
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
/**

@@ -523,89 +670,21 @@ * Checks if `value` is the

var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var ParentSize =
/*#__PURE__*/
function (_React$Component) {
_inherits(ParentSize, _React$Component);
var createClass = 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);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var objectWithoutProperties = function (obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var ParentSize = function (_React$Component) {
inherits(ParentSize, _React$Component);
function ParentSize(props) {
classCallCheck(this, ParentSize);
var _this;
var _this = possibleConstructorReturn(this, (ParentSize.__proto__ || Object.getPrototypeOf(ParentSize)).call(this, props));
_classCallCheck(this, ParentSize);
_this = _possibleConstructorReturn(this, _getPrototypeOf(ParentSize).call(this, props));
_this.state = {
width: 0, height: 0, top: 0, left: 0
width: 0,
height: 0,
top: 0,
left: 0
};
_this.resize = debounce_1(_this.resize.bind(_this), props.debounceTime);
_this.setTarget = _this.setTarget.bind(_this);
_this.resize = debounce_1(_this.resize.bind(_assertThisInitialized(_assertThisInitialized(_this))), props.debounceTime);
_this.setTarget = _this.setTarget.bind(_assertThisInitialized(_assertThisInitialized(_this)));
_this.animationFrameID = null;

@@ -615,4 +694,4 @@ return _this;

createClass(ParentSize, [{
key: 'componentDidMount',
_createClass(ParentSize, [{
key: "componentDidMount",
value: function componentDidMount() {

@@ -622,19 +701,2 @@ var _this2 = this;

this.ro = new ResizeObserver(function (entries, observer) {
var _loop = function _loop(entry) {
var _entry$contentRect = entry.contentRect,
left = _entry$contentRect.left,
top = _entry$contentRect.top,
width = _entry$contentRect.width,
height = _entry$contentRect.height;
_this2.animationFrameID = window.requestAnimationFrame(function () {
_this2.resize({
width: width,
height: height,
top: top,
left: left
});
});
};
var _iteratorNormalCompletion = true;

@@ -645,6 +707,21 @@ var _didIteratorError = false;

try {
for (var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _loop = function _loop() {
var entry = _step.value;
var _entry$contentRect = entry.contentRect,
left = _entry$contentRect.left,
top = _entry$contentRect.top,
width = _entry$contentRect.width,
height = _entry$contentRect.height;
_this2.animationFrameID = window.requestAnimationFrame(function () {
_this2.resize({
width: width,
height: height,
top: top,
left: left
});
});
};
_loop(entry);
for (var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
_loop();
}

@@ -656,3 +733,3 @@ } catch (err) {

try {
if (!_iteratorNormalCompletion && _iterator.return) {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();

@@ -670,3 +747,3 @@ }

}, {
key: 'componentWillUnmount',
key: "componentWillUnmount",
value: function componentWillUnmount() {

@@ -677,3 +754,3 @@ window.cancelAnimationFrame(this.animationFrameID);

}, {
key: 'resize',
key: "resize",
value: function resize(_ref) {

@@ -684,3 +761,2 @@ var width = _ref.width,

left = _ref.left;
this.setState(function () {

@@ -696,3 +772,3 @@ return {

}, {
key: 'setTarget',
key: "setTarget",
value: function setTarget(ref) {

@@ -702,32 +778,29 @@ this.target = ref;

}, {
key: 'render',
key: "render",
value: function render() {
var _props = this.props,
className = _props.className,
children = _props.children,
debounceTime = _props.debounceTime,
restProps = objectWithoutProperties(_props, ['className', 'children', 'debounceTime']);
var _this$props = this.props,
className = _this$props.className,
children = _this$props.children,
debounceTime = _this$props.debounceTime,
restProps = _objectWithoutProperties(_this$props, ["className", "children", "debounceTime"]);
return React.createElement(
'div',
_extends({
style: { width: '100%', height: '100%' },
ref: this.setTarget,
className: className
}, restProps),
children(_extends({}, this.state, {
ref: this.target,
resize: this.resize
}))
);
return React.createElement("div", _extends({
style: {
width: '100%',
height: '100%'
},
ref: this.setTarget,
className: className
}, restProps), children(_objectSpread({}, this.state, {
ref: this.target,
resize: this.resize
})));
}
}]);
return ParentSize;
}(React.Component);
ParentSize.defaultProps = {
debounceTime: 300
};
ParentSize.propTypes = {

@@ -740,10 +813,13 @@ className: PropTypes.string,

function withParentSize(BaseComponent) {
var WrappedComponent = function (_React$Component) {
inherits(WrappedComponent, _React$Component);
var WrappedComponent =
/*#__PURE__*/
function (_React$Component) {
_inherits(WrappedComponent, _React$Component);
function WrappedComponent(props) {
classCallCheck(this, WrappedComponent);
var _this;
var _this = possibleConstructorReturn(this, (WrappedComponent.__proto__ || Object.getPrototypeOf(WrappedComponent)).call(this, props));
_classCallCheck(this, WrappedComponent);
_this = _possibleConstructorReturn(this, _getPrototypeOf(WrappedComponent).call(this, props));
_this.state = {

@@ -753,10 +829,9 @@ parentWidth: null,

};
_this.animationFrameID = null;
_this.debouncedResize = debounce_1(_this.resize.bind(_this), props.debounceTime).bind(_this);
_this.debouncedResize = debounce_1(_this.resize.bind(_assertThisInitialized(_assertThisInitialized(_this))), props.debounceTime).bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
createClass(WrappedComponent, [{
key: 'componentDidMount',
_createClass(WrappedComponent, [{
key: "componentDidMount",
value: function componentDidMount() {

@@ -770,3 +845,2 @@ var _this2 = this;

height = _entry$contentRect.height;
_this2.animationFrameID = window.requestAnimationFrame(function () {

@@ -783,3 +857,3 @@ _this2.debouncedResize({

}, {
key: 'componentWillUnmount',
key: "componentWillUnmount",
value: function componentWillUnmount() {

@@ -790,7 +864,6 @@ window.cancelAnimationFrame(this.animationFrameID);

}, {
key: 'resize',
key: "resize",
value: function resize(_ref) {
var width = _ref.width,
height = _ref.height;
this.setState({

@@ -802,25 +875,24 @@ parentWidth: width,

}, {
key: 'render',
key: "render",
value: function render() {
var _this3 = this;
var _state = this.state,
parentWidth = _state.parentWidth,
parentHeight = _state.parentHeight;
return React.createElement(
'div',
{
style: { width: '100%', height: '100%' },
ref: function ref(_ref2) {
_this3.container = _ref2;
}
var _this$state = this.state,
parentWidth = _this$state.parentWidth,
parentHeight = _this$state.parentHeight;
return React.createElement("div", {
style: {
width: '100%',
height: '100%'
},
parentWidth !== null && parentHeight !== null && React.createElement(BaseComponent, _extends({
parentWidth: parentWidth,
parentHeight: parentHeight
}, this.props))
);
ref: function ref(_ref2) {
_this3.container = _ref2;
}
}, parentWidth !== null && parentHeight !== null && React.createElement(BaseComponent, _extends({
parentWidth: parentWidth,
parentHeight: parentHeight
}, this.props)));
}
}]);
return WrappedComponent;

@@ -832,3 +904,2 @@ }(React.Component);

};
return WrappedComponent;

@@ -838,10 +909,13 @@ }

function withScreenSize(BaseComponent) {
var WrappedComponent = function (_React$Component) {
inherits(WrappedComponent, _React$Component);
var WrappedComponent =
/*#__PURE__*/
function (_React$Component) {
_inherits(WrappedComponent, _React$Component);
function WrappedComponent(props) {
classCallCheck(this, WrappedComponent);
var _this;
var _this = possibleConstructorReturn(this, (WrappedComponent.__proto__ || Object.getPrototypeOf(WrappedComponent)).call(this, props));
_classCallCheck(this, WrappedComponent);
_this = _possibleConstructorReturn(this, _getPrototypeOf(WrappedComponent).call(this, props));
_this.state = {

@@ -851,9 +925,8 @@ screenWidth: null,

};
_this.handleResize = debounce_1(_this.resize.bind(_this), props.windowResizeDebounceTime).bind(_this);
_this.handleResize = debounce_1(_this.resize.bind(_assertThisInitialized(_assertThisInitialized(_this))), props.windowResizeDebounceTime).bind(_assertThisInitialized(_assertThisInitialized(_this)));
return _this;
}
createClass(WrappedComponent, [{
key: 'componentDidMount',
_createClass(WrappedComponent, [{
key: "componentDidMount",
value: function componentDidMount() {

@@ -864,3 +937,3 @@ window.addEventListener('resize', this.handleResize, false);

}, {
key: 'componentWillUnmount',
key: "componentWillUnmount",
value: function componentWillUnmount() {

@@ -870,3 +943,3 @@ window.removeEventListener('resize', this.handleResize, false);

}, {
key: 'resize',
key: "resize",
value: function resize(event) {

@@ -881,12 +954,15 @@ this.setState(function (prevState, props) {

}, {
key: 'render',
key: "render",
value: function render() {
var _state = this.state,
screenWidth = _state.screenWidth,
screenHeight = _state.screenHeight;
var _this$state = this.state,
screenWidth = _this$state.screenWidth,
screenHeight = _this$state.screenHeight;
if (!screenWidth && !screenHeight) return null;
return React.createElement(BaseComponent, _extends({ screenWidth: screenWidth, screenHeight: screenHeight }, this.props));
return React.createElement(BaseComponent, _extends({
screenWidth: screenWidth,
screenHeight: screenHeight
}, this.props));
}
}]);
return WrappedComponent;

@@ -898,3 +974,2 @@ }(React.Component);

};
return WrappedComponent;

@@ -901,0 +976,0 @@ }

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("resize-observer-polyfill")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","resize-observer-polyfill"],t):t(e.vx=e.vx||{},e.React,e.PropTypes,null)}(this,function(e,l,t,i){"use strict";function n(e){var t=e.children,n=e.width,i=e.height,r=e.xOrigin,o=void 0===r?0:r,a=e.yOrigin,u=void 0===a?0:a,c=e.preserveAspectRatio,s=void 0===c?"xMinYMin meet":c;return l.createElement("div",{style:{display:"inline-block",position:"relative",width:"100%",verticalAlign:"top",overflow:"hidden"}},l.createElement("svg",{preserveAspectRatio:s,viewBox:o+" "+u+" "+n+" "+i},t))}l=l&&l.hasOwnProperty("default")?l.default:l,t=t&&t.hasOwnProperty("default")?t.default:t,i=i&&i.hasOwnProperty("default")?i.default:i,n.propTypes={children:t.func,width:t.oneOfType([t.number,t.string]),height:t.oneOfType([t.number,t.string]),xOrigin:t.oneOfType([t.number,t.string]),yOrigin:t.oneOfType([t.number,t.string]),preserveAspectRatio:t.string};var b=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},r="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},o="object"==typeof r&&r&&r.Object===Object&&r,a="object"==typeof self&&self&&self.Object===Object&&self,u=o||a||Function("return this")(),g=function(){return u.Date.now()},c=u.Symbol,s=Object.prototype,f=s.hasOwnProperty,h=s.toString,d=c?c.toStringTag:void 0;var p=function(e){var t=f.call(e,d),n=e[d];try{e[d]=void 0}catch(e){}var i=h.call(e);return t?e[d]=n:delete e[d],i},v=Object.prototype.toString;var y=function(e){return v.call(e)},m=c?c.toStringTag:void 0;var w=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":m&&m in Object(e)?p(e):y(e)};var O=function(e){return null!=e&&"object"==typeof e};var T=function(e){return"symbol"==typeof e||O(e)&&"[object Symbol]"==w(e)},j=/^\s+|\s+$/g,z=/^[-+]0x[0-9a-f]+$/i,P=/^0b[01]+$/i,_=/^0o[0-7]+$/i,x=parseInt;var S=function(e){if("number"==typeof e)return e;if(T(e))return NaN;if(b(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=b(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(j,"");var n=P.test(e);return n||_.test(e)?x(e.slice(2),n?2:8):z.test(e)?NaN:+e},k=Math.max,R=Math.min;var E=function(i,r,e){var o,a,u,c,s,l,f=0,h=!1,d=!1,t=!0;if("function"!=typeof i)throw new TypeError("Expected a function");function p(e){var t=o,n=a;return o=a=void 0,f=e,c=i.apply(n,t)}function v(e){var t=e-l;return void 0===l||r<=t||t<0||d&&u<=e-f}function y(){var e,t,n=g();if(v(n))return m(n);s=setTimeout(y,(t=r-((e=n)-l),d?R(t,u-(e-f)):t))}function m(e){return s=void 0,t&&o?p(e):(o=a=void 0,c)}function n(){var e,t=g(),n=v(t);if(o=arguments,a=this,l=t,n){if(void 0===s)return f=e=l,s=setTimeout(y,r),h?p(e):c;if(d)return s=setTimeout(y,r),p(l)}return void 0===s&&(s=setTimeout(y,r)),c}return r=S(r)||0,b(e)&&(h=!!e.leading,u=(d="maxWait"in e)?k(S(e.maxWait)||0,r):u,t="trailing"in e?!!e.trailing:t),n.cancel=function(){void 0!==s&&clearTimeout(s),o=l=a=s=void(f=0)},n.flush=function(){return void 0===s?c:m(g())},n},W=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},D=function(){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}}(),F=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},H=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},N=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},A=function(e){function n(e){W(this,n);var t=N(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.state={width:0,height:0,top:0,left:0},t.resize=E(t.resize.bind(t),e.debounceTime),t.setTarget=t.setTarget.bind(t),t.animationFrameID=null,t}return H(n,e),D(n,[{key:"componentDidMount",value:function(){var c=this;this.ro=new i(function(e,t){var n=function(e){var t=e.contentRect,n=t.left,i=t.top,r=t.width,o=t.height;c.animationFrameID=window.requestAnimationFrame(function(){c.resize({width:r,height:o,top:i,left:n})})},i=!0,r=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(i=(a=u.next()).done);i=!0){n(a.value)}}catch(e){r=!0,o=e}finally{try{!i&&u.return&&u.return()}finally{if(r)throw o}}}),this.ro.observe(this.target)}},{key:"componentWillUnmount",value:function(){window.cancelAnimationFrame(this.animationFrameID),this.ro.disconnect()}},{key:"resize",value:function(e){var t=e.width,n=e.height,i=e.top,r=e.left;this.setState(function(){return{width:t,height:n,top:i,left:r}})}},{key:"setTarget",value:function(e){this.target=e}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.children,i=(e.debounceTime,function(e,t){var n={};for(var i in e)0<=t.indexOf(i)||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n}(e,["className","children","debounceTime"]));return l.createElement("div",F({style:{width:"100%",height:"100%"},ref:this.setTarget,className:t},i),n(F({},this.state,{ref:this.target,resize:this.resize})))}}]),n}(l.Component);A.defaultProps={debounceTime:300},A.propTypes={className:t.string,children:t.func.isRequired,debounceTime:t.number},e.ScaleSVG=n,e.ParentSize=A,e.withParentSize=function(r){var e=function(e){function n(e){W(this,n);var t=N(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.state={parentWidth:null,parentHeight:null},t.animationFrameID=null,t.debouncedResize=E(t.resize.bind(t),e.debounceTime).bind(t),t}return H(n,e),D(n,[{key:"componentDidMount",value:function(){var r=this;this.ro=new i(function(e,t){e.forEach(function(e){var t=e.contentRect,n=t.width,i=t.height;r.animationFrameID=window.requestAnimationFrame(function(){r.debouncedResize({width:n,height:i})})})}),this.ro.observe(this.container)}},{key:"componentWillUnmount",value:function(){window.cancelAnimationFrame(this.animationFrameID),this.ro.disconnect()}},{key:"resize",value:function(e){var t=e.width,n=e.height;this.setState({parentWidth:t,parentHeight:n})}},{key:"render",value:function(){var t=this,e=this.state,n=e.parentWidth,i=e.parentHeight;return l.createElement("div",{style:{width:"100%",height:"100%"},ref:function(e){t.container=e}},null!==n&&null!==i&&l.createElement(r,F({parentWidth:n,parentHeight:i},this.props)))}}]),n}(l.Component);return e.defaultProps={debounceTime:300},e},e.withScreenSize=function(i){var e=function(e){function n(e){W(this,n);var t=N(this,(n.__proto__||Object.getPrototypeOf(n)).call(this,e));return t.state={screenWidth:null,screenHeight:null},t.handleResize=E(t.resize.bind(t),e.windowResizeDebounceTime).bind(t),t}return H(n,e),D(n,[{key:"componentDidMount",value:function(){window.addEventListener("resize",this.handleResize,!1),this.resize()}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize,!1)}},{key:"resize",value:function(e){this.setState(function(e,t){return{screenWidth:window.innerWidth,screenHeight:window.innerHeight}})}},{key:"render",value:function(){var e=this.state,t=e.screenWidth,n=e.screenHeight;return t||n?l.createElement(i,F({screenWidth:t,screenHeight:n},this.props)):null}}]),n}(l.Component);return e.defaultProps={windowResizeDebounceTime:300},e},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("prop-types"),require("resize-observer-polyfill"),require("react")):"function"==typeof define&&define.amd?define(["exports","prop-types","resize-observer-polyfill","react"],t):t(e.vx=e.vx||{},e.PropTypes,e.ResizeObserver,e.React)}(this,function(e,t,r,l){"use strict";function n(e){var t=e.children,n=e.width,r=e.height,i=e.xOrigin,o=void 0===i?0:i,a=e.yOrigin,u=void 0===a?0:a,c=e.preserveAspectRatio,s=void 0===c?"xMinYMin meet":c;return l.createElement("div",{style:{display:"inline-block",position:"relative",width:"100%",verticalAlign:"top",overflow:"hidden"}},l.createElement("svg",{preserveAspectRatio:s,viewBox:"".concat(o," ").concat(u," ").concat(n," ").concat(r)},t))}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&f(e,t)}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],0<=t.indexOf(n)||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],0<=t.indexOf(n)||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?p(e):t}t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r,l=l&&l.hasOwnProperty("default")?l.default:l,n.propTypes={children:t.func,width:t.oneOfType([t.number,t.string]),height:t.oneOfType([t.number,t.string]),xOrigin:t.oneOfType([t.number,t.string]),yOrigin:t.oneOfType([t.number,t.string]),preserveAspectRatio:t.string};var m=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},v="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},y="object"==typeof v&&v&&v.Object===Object&&v,b="object"==typeof self&&self&&self.Object===Object&&self,g=y||b||Function("return this")(),w=function(){return g.Date.now()},O=g.Symbol,j=Object.prototype,T=j.hasOwnProperty,z=j.toString,P=O?O.toStringTag:void 0;var S=function(e){var t=T.call(e,P),n=e[P];try{e[P]=void 0}catch(e){}var r=z.call(e);return t?e[P]=n:delete e[P],r},x=Object.prototype.toString;var k=function(e){return x.call(e)},E=O?O.toStringTag:void 0;var R=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":E&&E in Object(e)?S(e):k(e)};var W=function(e){return null!=e&&"object"==typeof e};var D=function(e){return"symbol"==typeof e||W(e)&&"[object Symbol]"==R(e)},F=/^\s+|\s+$/g,_=/^[-+]0x[0-9a-f]+$/i,H=/^0b[01]+$/i,N=/^0o[0-7]+$/i,A=parseInt;var I=function(e){if("number"==typeof e)return e;if(D(e))return NaN;if(m(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=m(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(F,"");var n=H.test(e);return n||N.test(e)?A(e.slice(2),n?2:8):_.test(e)?NaN:+e},M=Math.max,q=Math.min;var C=function(r,i,e){var o,a,u,c,s,l,f=0,h=!1,p=!1,t=!0;if("function"!=typeof r)throw new TypeError("Expected a function");function d(e){var t=o,n=a;return o=a=void 0,f=e,c=r.apply(n,t)}function v(e){var t=e-l;return void 0===l||i<=t||t<0||p&&u<=e-f}function y(){var e,t,n=w();if(v(n))return b(n);s=setTimeout(y,(t=i-((e=n)-l),p?q(t,u-(e-f)):t))}function b(e){return s=void 0,t&&o?d(e):(o=a=void 0,c)}function n(){var e,t=w(),n=v(t);if(o=arguments,a=this,l=t,n){if(void 0===s)return f=e=l,s=setTimeout(y,i),h?d(e):c;if(p)return s=setTimeout(y,i),d(l)}return void 0===s&&(s=setTimeout(y,i)),c}return i=I(i)||0,m(e)&&(h=!!e.leading,u=(p="maxWait"in e)?M(I(e.maxWait)||0,i):u,t="trailing"in e?!!e.trailing:t),n.cancel=function(){void 0!==s&&clearTimeout(s),o=l=a=s=void(f=0)},n.flush=function(){return void 0===s?c:b(w())},n},U=function(e){function n(e){var t;return o(this,n),(t=d(this,s(n).call(this,e))).state={width:0,height:0,top:0,left:0},t.resize=C(t.resize.bind(p(p(t))),e.debounceTime),t.setTarget=t.setTarget.bind(p(p(t))),t.animationFrameID=null,t}return c(n,l.Component),a(n,[{key:"componentDidMount",value:function(){var c=this;this.ro=new r(function(e,t){var n=!0,r=!1,i=void 0;try{for(var o,a=function(){var e=o.value.contentRect,t=e.left,n=e.top,r=e.width,i=e.height;c.animationFrameID=window.requestAnimationFrame(function(){c.resize({width:r,height:i,top:n,left:t})})},u=e[Symbol.iterator]();!(n=(o=u.next()).done);n=!0)a()}catch(e){r=!0,i=e}finally{try{n||null==u.return||u.return()}finally{if(r)throw i}}}),this.ro.observe(this.target)}},{key:"componentWillUnmount",value:function(){window.cancelAnimationFrame(this.animationFrameID),this.ro.disconnect()}},{key:"resize",value:function(e){var t=e.width,n=e.height,r=e.top,i=e.left;this.setState(function(){return{width:t,height:n,top:r,left:i}})}},{key:"setTarget",value:function(e){this.target=e}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.children,r=(e.debounceTime,h(e,["className","children","debounceTime"]));return l.createElement("div",u({style:{width:"100%",height:"100%"},ref:this.setTarget,className:t},r),n(function(i){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{},t=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),t.forEach(function(e){var t,n,r;t=i,r=o[n=e],n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r})}return i}({},this.state,{ref:this.target,resize:this.resize})))}}]),n}();U.defaultProps={debounceTime:300},U.propTypes={className:t.string,children:t.func.isRequired,debounceTime:t.number},e.ScaleSVG=n,e.ParentSize=U,e.withParentSize=function(i){var e=function(e){function n(e){var t;return o(this,n),(t=d(this,s(n).call(this,e))).state={parentWidth:null,parentHeight:null},t.animationFrameID=null,t.debouncedResize=C(t.resize.bind(p(p(t))),e.debounceTime).bind(p(p(t))),t}return c(n,l.Component),a(n,[{key:"componentDidMount",value:function(){var i=this;this.ro=new r(function(e,t){e.forEach(function(e){var t=e.contentRect,n=t.width,r=t.height;i.animationFrameID=window.requestAnimationFrame(function(){i.debouncedResize({width:n,height:r})})})}),this.ro.observe(this.container)}},{key:"componentWillUnmount",value:function(){window.cancelAnimationFrame(this.animationFrameID),this.ro.disconnect()}},{key:"resize",value:function(e){var t=e.width,n=e.height;this.setState({parentWidth:t,parentHeight:n})}},{key:"render",value:function(){var t=this,e=this.state,n=e.parentWidth,r=e.parentHeight;return l.createElement("div",{style:{width:"100%",height:"100%"},ref:function(e){t.container=e}},null!==n&&null!==r&&l.createElement(i,u({parentWidth:n,parentHeight:r},this.props)))}}]),n}();return e.defaultProps={debounceTime:300},e},e.withScreenSize=function(r){var e=function(e){function n(e){var t;return o(this,n),(t=d(this,s(n).call(this,e))).state={screenWidth:null,screenHeight:null},t.handleResize=C(t.resize.bind(p(p(t))),e.windowResizeDebounceTime).bind(p(p(t))),t}return c(n,l.Component),a(n,[{key:"componentDidMount",value:function(){window.addEventListener("resize",this.handleResize,!1),this.resize()}},{key:"componentWillUnmount",value:function(){window.removeEventListener("resize",this.handleResize,!1)}},{key:"resize",value:function(e){this.setState(function(e,t){return{screenWidth:window.innerWidth,screenHeight:window.innerHeight}})}},{key:"render",value:function(){var e=this.state,t=e.screenWidth,n=e.screenHeight;return t||n?l.createElement(r,u({screenWidth:t,screenHeight:n},this.props)):null}}]),n}();return e.defaultProps={windowResizeDebounceTime:300},e},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@vx/responsive",
"version": "0.0.179",
"version": "0.0.182",
"description": "vx responsive svg",

@@ -15,3 +15,3 @@ "sideEffects": false,

"build:dist": "rm -rf dist && mkdir dist && rollup -c",
"build:babel": "rm -rf build && mkdir build && babel src --out-dir build --ignore node_modules/ --presets stage-0,react,env --plugins lodash",
"build:babel": "rm -rf build && mkdir build && babel src --out-dir build --ignore node_modules/ --presets @babel/preset-react,@babel/preset-env --plugins lodash",
"prepublish": "npm run build",

@@ -38,10 +38,26 @@ "test": "jest"

"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-jest": "^21.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-external-helpers": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.4.2",
"babel-plugin-lodash": "^3.3.2",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"enzyme": "^3.1.0",

@@ -55,4 +71,4 @@ "enzyme-adapter-react-16": "^1.0.2",

"react-test-renderer": "^16.0.0",
"rollup": "^0.59.4",
"rollup-plugin-babel": "^3.0.4",
"rollup": "^0.67.4",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-commonjs": "^9.1.3",

@@ -59,0 +75,0 @@ "rollup-plugin-node-resolve": "^3.3.0",

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