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

@vx/responsive

Package Overview
Dependencies
Maintainers
3
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.192 to 0.0.193-alpha.0

lib/components/ParentSize.d.ts

95

esm/components/ParentSize.js

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

import _pt from "prop-types";
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); }

@@ -9,4 +11,5 @@

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; }
import debounce from 'lodash/debounce';
import PropTypes from 'prop-types';
import React from 'react';

@@ -24,2 +27,29 @@ import ResizeObserver from 'resize-observer-polyfill';

_this = _React$Component.call(this, props) || this;
_defineProperty(_assertThisInitialized(_this), "animationFrameID", void 0);
_defineProperty(_assertThisInitialized(_this), "resizeObserver", void 0);
_defineProperty(_assertThisInitialized(_this), "target", null);
_defineProperty(_assertThisInitialized(_this), "resize", function (_ref) {
var width = _ref.width,
height = _ref.height,
top = _ref.top,
left = _ref.left;
_this.setState(function () {
return {
width: width,
height: height,
top: top,
left: left
};
});
});
_defineProperty(_assertThisInitialized(_this), "setTarget", function (ref) {
_this.target = ref;
});
_this.state = {

@@ -31,4 +61,3 @@ width: 0,

};
_this.resize = debounce(_this.resize.bind(_assertThisInitialized(_this)), props.debounceTime);
_this.setTarget = _this.setTarget.bind(_assertThisInitialized(_this));
_this.resize = debounce(_this.resize, props.debounceTime);
_this.animationFrameID = null;

@@ -43,3 +72,3 @@ return _this;

this.ro = new ResizeObserver(function (entries
this.resizeObserver = new ResizeObserver(function (entries
/** , observer */

@@ -67,29 +96,10 @@ ) {

});
this.ro.observe(this.target);
if (this.target) this.resizeObserver.observe(this.target);
};
_proto.componentWillUnmount = function componentWillUnmount() {
window.cancelAnimationFrame(this.animationFrameID);
this.ro.disconnect();
if (this.animationFrameID) window.cancelAnimationFrame(this.animationFrameID);
if (this.resizeObserver) this.resizeObserver.disconnect();
};
_proto.resize = function resize(_ref) {
var width = _ref.width,
height = _ref.height,
top = _ref.top,
left = _ref.left;
this.setState(function () {
return {
width: width,
height: height,
top: top,
left: left
};
});
};
_proto.setTarget = function setTarget(ref) {
this.target = ref;
};
_proto.render = function render() {

@@ -100,9 +110,7 @@ var _this$props = this.props,

debounceTime = _this$props.debounceTime,
restProps = _objectWithoutPropertiesLoose(_this$props, ["className", "children", "debounceTime"]);
parentSizeStyles = _this$props.parentSizeStyles,
restProps = _objectWithoutPropertiesLoose(_this$props, ["className", "children", "debounceTime", "parentSizeStyles"]);
return React.createElement("div", _extends({
style: {
width: '100%',
height: '100%'
},
style: parentSizeStyles,
ref: this.setTarget,

@@ -119,10 +127,17 @@ className: className

export { ParentSize as default };
ParentSize.defaultProps = {
debounceTime: 300
};
ParentSize.propTypes = {
className: PropTypes.string,
children: PropTypes.func.isRequired,
debounceTime: PropTypes.number
};
_defineProperty(ParentSize, "propTypes", {
className: _pt.string,
debounceTime: _pt.number,
parentSizeStyles: _pt.any,
children: _pt.func.isRequired
});
_defineProperty(ParentSize, "defaultProps", {
debounceTime: 300,
parentSizeStyles: {
width: '100%',
height: '100%'
}
});
export { ParentSize as default };

@@ -0,12 +1,3 @@

import _pt from "prop-types";
import React from 'react';
import PropTypes from 'prop-types';
ResponsiveSVG.propTypes = {
children: PropTypes.any,
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
xOrigin: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
yOrigin: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
preserveAspectRatio: PropTypes.string,
innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
};
export default function ResponsiveSVG(_ref) {

@@ -36,2 +27,11 @@ var children = _ref.children,

}, children));
}
}
ResponsiveSVG.propTypes = {
children: _pt.node,
width: _pt.oneOfType([_pt.number, _pt.string]),
height: _pt.oneOfType([_pt.number, _pt.string]),
xOrigin: _pt.oneOfType([_pt.number, _pt.string]),
yOrigin: _pt.oneOfType([_pt.number, _pt.string]),
preserveAspectRatio: _pt.string,
innerRef: _pt.oneOfType([_pt.string, _pt.func, _pt.object])
};

@@ -7,8 +7,11 @@ 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); }

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; }
import React from 'react';
import PropTypes from 'prop-types';
import debounce from 'lodash/debounce';
import ResizeObserver from 'resize-observer-polyfill';
export default function withParentSize(BaseComponent) {
var WrappedComponent =
var _class, _temp;
return _temp = _class =
/*#__PURE__*/

@@ -22,2 +25,21 @@ function (_React$Component) {

_this = _React$Component.call(this, props) || this;
_defineProperty(_assertThisInitialized(_this), "animationFrameID", void 0);
_defineProperty(_assertThisInitialized(_this), "resizeObserver", void 0);
_defineProperty(_assertThisInitialized(_this), "container", null);
_defineProperty(_assertThisInitialized(_this), "debouncedResize", void 0);
_defineProperty(_assertThisInitialized(_this), "resize", function (_ref) {
var width = _ref.width,
height = _ref.height;
_this.setState({
parentWidth: width,
parentHeight: height
});
});
_this.state = {

@@ -28,3 +50,3 @@ parentWidth: null,

_this.animationFrameID = null;
_this.debouncedResize = debounce(_this.resize.bind(_assertThisInitialized(_this)), props.debounceTime).bind(_assertThisInitialized(_this));
_this.debouncedResize = debounce(_this.resize, props.debounceTime);
return _this;

@@ -38,3 +60,3 @@ }

this.ro = new ResizeObserver(function (entries
this.resizeObserver = new ResizeObserver(function (entries
/** , observer */

@@ -54,19 +76,10 @@ ) {

});
this.ro.observe(this.container);
if (this.container) this.resizeObserver.observe(this.container);
};
_proto.componentWillUnmount = function componentWillUnmount() {
window.cancelAnimationFrame(this.animationFrameID);
this.ro.disconnect();
if (this.animationFrameID) window.cancelAnimationFrame(this.animationFrameID);
if (this.resizeObserver) this.resizeObserver.disconnect();
};
_proto.resize = function resize(_ref) {
var width = _ref.width,
height = _ref.height;
this.setState({
parentWidth: width,
parentHeight: height
});
};
_proto.render = function render() {

@@ -93,11 +106,5 @@ var _this3 = this;

return WrappedComponent;
}(React.Component);
WrappedComponent.propTypes = {
debounceTime: PropTypes.number
};
WrappedComponent.defaultProps = {
}(React.Component), _defineProperty(_class, "defaultProps", {
debounceTime: 300
};
return WrappedComponent;
}), _temp;
}

@@ -7,7 +7,10 @@ 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); }

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; }
import debounce from 'lodash/debounce';
import React from 'react';
import PropTypes from 'prop-types';
export default function withScreenSize(BaseComponent) {
var WrappedComponent =
var _class, _temp;
return _temp = _class =
/*#__PURE__*/

@@ -21,2 +24,18 @@ function (_React$Component) {

_this = _React$Component.call(this, props) || this;
_defineProperty(_assertThisInitialized(_this), "handleResize", void 0);
_defineProperty(_assertThisInitialized(_this), "resize", function ()
/** event */
{
_this.setState(function ()
/** prevState, props */
{
return {
screenWidth: window.innerWidth,
screenHeight: window.innerHeight
};
});
});
_this.state = {

@@ -26,3 +45,3 @@ screenWidth: null,

};
_this.handleResize = debounce(_this.resize.bind(_assertThisInitialized(_this)), props.windowResizeDebounceTime).bind(_assertThisInitialized(_this));
_this.handleResize = debounce(_this.resize, props.windowResizeDebounceTime);
return _this;

@@ -42,15 +61,2 @@ }

_proto.resize = function resize()
/** event */
{
this.setState(function ()
/** prevState, props */
{
return {
screenWidth: window.innerWidth,
screenHeight: window.innerHeight
};
});
};
_proto.render = function render() {

@@ -68,11 +74,5 @@ var _this$state = this.state,

return WrappedComponent;
}(React.Component);
WrappedComponent.propTypes = {
windowResizeDebounceTime: PropTypes.number
};
WrappedComponent.defaultProps = {
}(React.Component), _defineProperty(_class, "defaultProps", {
windowResizeDebounceTime: 300
};
return WrappedComponent;
}), _temp;
}

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

var _propTypes = _interopRequireDefault(require("prop-types"));
var _debounce = _interopRequireDefault(require("lodash/debounce"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));

@@ -25,2 +25,4 @@

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 ParentSize =

@@ -35,2 +37,29 @@ /*#__PURE__*/

_this = _React$Component.call(this, props) || this;
_defineProperty(_assertThisInitialized(_this), "animationFrameID", void 0);
_defineProperty(_assertThisInitialized(_this), "resizeObserver", void 0);
_defineProperty(_assertThisInitialized(_this), "target", null);
_defineProperty(_assertThisInitialized(_this), "resize", function (_ref) {
var width = _ref.width,
height = _ref.height,
top = _ref.top,
left = _ref.left;
_this.setState(function () {
return {
width: width,
height: height,
top: top,
left: left
};
});
});
_defineProperty(_assertThisInitialized(_this), "setTarget", function (ref) {
_this.target = ref;
});
_this.state = {

@@ -42,4 +71,3 @@ width: 0,

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

@@ -54,3 +82,3 @@ return _this;

this.ro = new _resizeObserverPolyfill.default(function (entries
this.resizeObserver = new _resizeObserverPolyfill.default(function (entries
/** , observer */

@@ -78,29 +106,10 @@ ) {

});
this.ro.observe(this.target);
if (this.target) this.resizeObserver.observe(this.target);
};
_proto.componentWillUnmount = function componentWillUnmount() {
window.cancelAnimationFrame(this.animationFrameID);
this.ro.disconnect();
if (this.animationFrameID) window.cancelAnimationFrame(this.animationFrameID);
if (this.resizeObserver) this.resizeObserver.disconnect();
};
_proto.resize = function resize(_ref) {
var width = _ref.width,
height = _ref.height,
top = _ref.top,
left = _ref.left;
this.setState(function () {
return {
width: width,
height: height,
top: top,
left: left
};
});
};
_proto.setTarget = function setTarget(ref) {
this.target = ref;
};
_proto.render = function render() {

@@ -111,9 +120,7 @@ var _this$props = this.props,

debounceTime = _this$props.debounceTime,
restProps = _objectWithoutPropertiesLoose(_this$props, ["className", "children", "debounceTime"]);
parentSizeStyles = _this$props.parentSizeStyles,
restProps = _objectWithoutPropertiesLoose(_this$props, ["className", "children", "debounceTime", "parentSizeStyles"]);
return _react.default.createElement("div", _extends({
style: {
width: '100%',
height: '100%'
},
style: parentSizeStyles,
ref: this.setTarget,

@@ -131,9 +138,16 @@ className: className

exports.default = ParentSize;
ParentSize.defaultProps = {
debounceTime: 300
};
ParentSize.propTypes = {
_defineProperty(ParentSize, "propTypes", {
className: _propTypes.default.string,
children: _propTypes.default.func.isRequired,
debounceTime: _propTypes.default.number
};
debounceTime: _propTypes.default.number,
parentSizeStyles: _propTypes.default.any,
children: _propTypes.default.func.isRequired
});
_defineProperty(ParentSize, "defaultProps", {
debounceTime: 300,
parentSizeStyles: {
width: '100%',
height: '100%'
}
});

@@ -6,18 +6,8 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
ResponsiveSVG.propTypes = {
children: _propTypes.default.any,
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,
innerRef: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
};
function ResponsiveSVG(_ref) {

@@ -47,2 +37,12 @@ var children = _ref.children,

}, children));
}
}
ResponsiveSVG.propTypes = {
children: _propTypes.default.node,
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,
innerRef: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func, _propTypes.default.object])
};

@@ -8,4 +8,2 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
var _debounce = _interopRequireDefault(require("lodash/debounce"));

@@ -23,4 +21,8 @@

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 withParentSize(BaseComponent) {
var WrappedComponent =
var _class, _temp;
return _temp = _class =
/*#__PURE__*/

@@ -34,2 +36,21 @@ function (_React$Component) {

_this = _React$Component.call(this, props) || this;
_defineProperty(_assertThisInitialized(_this), "animationFrameID", void 0);
_defineProperty(_assertThisInitialized(_this), "resizeObserver", void 0);
_defineProperty(_assertThisInitialized(_this), "container", null);
_defineProperty(_assertThisInitialized(_this), "debouncedResize", void 0);
_defineProperty(_assertThisInitialized(_this), "resize", function (_ref) {
var width = _ref.width,
height = _ref.height;
_this.setState({
parentWidth: width,
parentHeight: height
});
});
_this.state = {

@@ -40,3 +61,3 @@ parentWidth: null,

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

@@ -50,3 +71,3 @@ }

this.ro = new _resizeObserverPolyfill.default(function (entries
this.resizeObserver = new _resizeObserverPolyfill.default(function (entries
/** , observer */

@@ -66,19 +87,10 @@ ) {

});
this.ro.observe(this.container);
if (this.container) this.resizeObserver.observe(this.container);
};
_proto.componentWillUnmount = function componentWillUnmount() {
window.cancelAnimationFrame(this.animationFrameID);
this.ro.disconnect();
if (this.animationFrameID) window.cancelAnimationFrame(this.animationFrameID);
if (this.resizeObserver) this.resizeObserver.disconnect();
};
_proto.resize = function resize(_ref) {
var width = _ref.width,
height = _ref.height;
this.setState({
parentWidth: width,
parentHeight: height
});
};
_proto.render = function render() {

@@ -105,11 +117,5 @@ var _this3 = this;

return WrappedComponent;
}(_react.default.Component);
WrappedComponent.propTypes = {
debounceTime: _propTypes.default.number
};
WrappedComponent.defaultProps = {
}(_react.default.Component), _defineProperty(_class, "defaultProps", {
debounceTime: 300
};
return WrappedComponent;
}), _temp;
}

@@ -10,4 +10,2 @@ "use strict";

var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -21,4 +19,8 @@

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 withScreenSize(BaseComponent) {
var WrappedComponent =
var _class, _temp;
return _temp = _class =
/*#__PURE__*/

@@ -32,2 +34,18 @@ function (_React$Component) {

_this = _React$Component.call(this, props) || this;
_defineProperty(_assertThisInitialized(_this), "handleResize", void 0);
_defineProperty(_assertThisInitialized(_this), "resize", function ()
/** event */
{
_this.setState(function ()
/** prevState, props */
{
return {
screenWidth: window.innerWidth,
screenHeight: window.innerHeight
};
});
});
_this.state = {

@@ -37,3 +55,3 @@ screenWidth: null,

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

@@ -53,15 +71,2 @@ }

_proto.resize = function resize()
/** event */
{
this.setState(function ()
/** prevState, props */
{
return {
screenWidth: window.innerWidth,
screenHeight: window.innerHeight
};
});
};
_proto.render = function render() {

@@ -79,11 +84,5 @@ var _this$state = this.state,

return WrappedComponent;
}(_react.default.Component);
WrappedComponent.propTypes = {
windowResizeDebounceTime: _propTypes.default.number
};
WrappedComponent.defaultProps = {
}(_react.default.Component), _defineProperty(_class, "defaultProps", {
windowResizeDebounceTime: 300
};
return WrappedComponent;
}), _temp;
}
{
"name": "@vx/responsive",
"version": "0.0.192",
"version": "0.0.193-alpha.0",
"description": "vx responsive svg",

@@ -8,2 +8,3 @@ "sideEffects": false,

"module": "esm/index.js",
"types": "lib/index.d.ts",
"files": [

@@ -34,5 +35,7 @@ "lib",

"dependencies": {
"@types/lodash": "^4.14.146",
"@types/react": "*",
"lodash": "^4.17.10",
"prop-types": "^15.6.1",
"resize-observer-polyfill": "1.5.0"
"resize-observer-polyfill": "1.5.1"
},

@@ -45,3 +48,3 @@ "peerDependencies": {

},
"gitHead": "101db6e89d7e8a4966dfafba5a782297110f7844"
"gitHead": "8fb99e77e64fa9c319c0addc2a3fbf61e64885cc"
}
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