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

react-height

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-height - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

434

build/react-height.js
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"));
module.exports = factory(require("React"));
else if(typeof define === 'function' && define.amd)
define(["react"], factory);
define(["React"], factory);
else if(typeof exports === 'object')
exports["ReactHeight"] = factory(require("react"));
exports["ReactHeight"] = factory(require("React"));
else
root["ReactHeight"] = factory(root["React"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_6__) {
})(window, function(__WEBPACK_EXTERNAL_MODULE__0__) {
return /******/ (function(modules) { // webpackBootstrap

@@ -46,16 +46,33 @@ /******/ // The module cache

/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules

@@ -76,2 +93,3 @@ /******/ __webpack_require__.n = function(module) {

/******/
/******/
/******/ // Load entry module and return exports

@@ -83,50 +101,72 @@ /******/ return __webpack_require__(__webpack_require__.s = 1);

/* 0 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
var _require = __webpack_require__(2),
ReactHeight = _require.ReactHeight;
ReactHeight.ReactHeight = ReactHeight;
module.exports = ReactHeight;
/***/ }),
/* 2 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReactHeight", function() { return ReactHeight; });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
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); }
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); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ReactHeight = undefined;
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; }
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; };
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; }
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; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _react = __webpack_require__(6);
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 _react2 = _interopRequireDefault(_react);
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var _propTypes = __webpack_require__(5);
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
var _propTypes2 = _interopRequireDefault(_propTypes);
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
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 _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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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 _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 _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; } /* eslint "react/no-did-mount-set-state":0 */
/* eslint "react/no-did-update-set-state":0 */
var getElementHeight = function getElementHeight(el) {
var getElementHeightDefault = function getElementHeightDefault(el) {
return el.clientHeight;
};
var ReactHeight = exports.ReactHeight = function (_PureComponent) {
var ReactHeight =
/*#__PURE__*/
function (_PureComponent) {
_inherits(ReactHeight, _PureComponent);
function ReactHeight(props) {
var _this;
_classCallCheck(this, ReactHeight);
var _this = _possibleConstructorReturn(this, (ReactHeight.__proto__ || Object.getPrototypeOf(ReactHeight)).call(this, props));
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactHeight).call(this, props));
_this.setWrapperRef = function (el) {
_defineProperty(_assertThisInitialized(_this), "setWrapperRef", function (el) {
_this.wrapper = el;
};
});

@@ -141,36 +181,56 @@ _this.state = {

_createClass(ReactHeight, [{
key: 'componentDidMount',
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
var height = this.props.getElementHeight(this.wrapper);
var getElementHeight = this.props.getElementHeight;
var height = getElementHeight(this.wrapper);
var dirty = false;
this.setState({
height: height,
dirty: dirty
}, function () {
var onHeightReady = _this2.props.onHeightReady;
var currentHeight = _this2.state.height;
onHeightReady(currentHeight);
});
} // eslint-disable-next-line react/no-deprecated
this.setState({ height: height, dirty: dirty }, function () {
return _this2.props.onHeightReady(_this2.state.height);
});
}
}, {
key: 'componentWillReceiveProps',
key: "componentWillReceiveProps",
value: function componentWillReceiveProps(_ref) {
var children = _ref.children,
dirty = _ref.dirty;
var oldChildren = this.props.children;
if (children !== this.props.children || dirty) {
this.setState({ dirty: true });
if (children !== oldChildren || dirty) {
this.setState({
dirty: true
});
}
}
}, {
key: 'componentDidUpdate',
key: "componentDidUpdate",
value: function componentDidUpdate() {
var _this3 = this;
var height = this.props.getElementHeight(this.wrapper);
var getElementHeight = this.props.getElementHeight;
var height = getElementHeight(this.wrapper);
var dirty = false;
var currentSavedHeight = this.state.height;
if (height === this.state.height) {
this.setState({ dirty: dirty });
if (height === currentSavedHeight) {
// eslint-disable-next-line react/no-did-update-set-state
this.setState({
dirty: dirty
});
} else {
this.setState({ height: height, dirty: dirty }, function () {
return _this3.props.onHeightReady(_this3.state.height);
// eslint-disable-next-line react/no-did-update-set-state
this.setState({
height: height,
dirty: dirty
}, function () {
var onHeightReady = _this3.props.onHeightReady;
var currentHeight = _this3.state.height;
onHeightReady(currentHeight);
});

@@ -180,15 +240,14 @@ }

}, {
key: 'render',
key: "render",
value: function render() {
var _props = this.props,
_onHeightReady = _props.onHeightReady,
_getElementHeight = _props.getElementHeight,
_dirty = _props.dirty,
hidden = _props.hidden,
children = _props.children,
props = _objectWithoutProperties(_props, ['onHeightReady', 'getElementHeight', 'dirty', 'hidden', 'children']);
var _this$props = this.props,
_onHeightReady = _this$props.onHeightReady,
_getElementHeight = _this$props.getElementHeight,
_dirty = _this$props.dirty,
hidden = _this$props.hidden,
children = _this$props.children,
props = _objectWithoutProperties(_this$props, ["onHeightReady", "getElementHeight", "dirty", "hidden", "children"]);
var dirty = this.state.dirty;
if (hidden && !dirty) {

@@ -199,18 +258,15 @@ return null;

if (hidden) {
return _react2.default.createElement(
'div',
{ style: { height: 0, overflow: 'hidden' } },
_react2.default.createElement(
'div',
_extends({ ref: this.setWrapperRef }, props),
children
)
);
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", {
style: {
height: 0,
overflow: 'hidden'
}
}, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", _extends({
ref: this.setWrapperRef
}, props), children));
}
return _react2.default.createElement(
'div',
_extends({ ref: this.setWrapperRef }, props),
children
);
return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("div", _extends({
ref: this.setWrapperRef
}, props), children);
}

@@ -220,240 +276,12 @@ }]);

return ReactHeight;
}(_react.PureComponent);
}(react__WEBPACK_IMPORTED_MODULE_0__["PureComponent"]);
ReactHeight.propTypes = {
children: _propTypes2.default.node.isRequired,
onHeightReady: _propTypes2.default.func.isRequired,
hidden: _propTypes2.default.bool,
dirty: _propTypes2.default.bool,
getElementHeight: _propTypes2.default.func
};
ReactHeight.defaultProps = {
_defineProperty(ReactHeight, "defaultProps", {
hidden: false,
dirty: true,
getElementHeight: getElementHeight
};
getElementHeight: getElementHeightDefault
});
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _require = __webpack_require__(0),
ReactHeight = _require.ReactHeight;
ReactHeight.ReactHeight = ReactHeight;
module.exports = ReactHeight;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
function makeEmptyFunction(arg) {
return function () {
return arg;
};
}
/**
* This function accepts and discards inputs; it has no side effects. This is
* primarily useful idiomatically for overridable function endpoints which
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
*/
var emptyFunction = function emptyFunction() {};
emptyFunction.thatReturns = makeEmptyFunction;
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
emptyFunction.thatReturnsThis = function () {
return this;
};
emptyFunction.thatReturnsArgument = function (arg) {
return arg;
};
module.exports = emptyFunction;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/
var validateFormat = function validateFormat(format) {};
if (false) {
validateFormat = function validateFormat(format) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
};
}
function invariant(condition, format, a, b, c, d, e, f) {
validateFormat(format);
if (!condition) {
var error;
if (format === undefined) {
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
} else {
var args = [a, b, c, d, e, f];
var argIndex = 0;
error = new Error(format.replace(/%s/g, function () {
return args[argIndex++];
}));
error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
}
module.exports = invariant;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
var emptyFunction = __webpack_require__(2);
var invariant = __webpack_require__(3);
module.exports = function() {
// Important!
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
function shim() {
invariant(
false,
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
'Use PropTypes.checkPropTypes() to call them. ' +
'Read more at http://fb.me/use-check-prop-types'
);
};
shim.isRequired = shim;
function getShim() {
return shim;
};
var ReactPropTypes = {
array: shim,
bool: shim,
func: shim,
number: shim,
object: shim,
string: shim,
symbol: shim,
any: shim,
arrayOf: getShim,
element: shim,
instanceOf: getShim,
node: shim,
objectOf: getShim,
oneOf: getShim,
oneOfType: getShim,
shape: getShim
};
ReactPropTypes.checkPropTypes = emptyFunction;
ReactPropTypes.PropTypes = ReactPropTypes;
return ReactPropTypes;
};
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
if (false) {
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
Symbol.for &&
Symbol.for('react.element')) ||
0xeac7;
var isValidElement = function(object) {
return typeof object === 'object' &&
object !== null &&
object.$$typeof === REACT_ELEMENT_TYPE;
};
// By explicitly using `prop-types` you are opting into new development behavior.
// http://fb.me/prop-types-in-prod
var throwOnDirectAccess = true;
module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess);
} else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = __webpack_require__(4)();
}
/***/ }),
/* 6 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_6__;
/***/ })
/******/ ]);
});

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactHeight=t(require("react")):e.ReactHeight=t(e.React)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.i=function(e){return e},t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e,t){var r={};for(var n in e)t.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n]);return r}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(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}function a(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)}Object.defineProperty(t,"__esModule",{value:!0}),t.ReactHeight=void 0;var c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},s=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),f=r(6),p=n(f),l=r(5),h=n(l),d=function(e){return e.clientHeight},y=t.ReactHeight=function(e){function t(e){i(this,t);var r=u(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.setWrapperRef=function(e){r.wrapper=e},r.state={dirty:e.dirty,height:0},r}return a(t,e),s(t,[{key:"componentDidMount",value:function(){var e=this,t=this.props.getElementHeight(this.wrapper);this.setState({height:t,dirty:!1},function(){return e.props.onHeightReady(e.state.height)})}},{key:"componentWillReceiveProps",value:function(e){var t=e.children,r=e.dirty;(t!==this.props.children||r)&&this.setState({dirty:!0})}},{key:"componentDidUpdate",value:function(){var e=this,t=this.props.getElementHeight(this.wrapper);t===this.state.height?this.setState({dirty:!1}):this.setState({height:t,dirty:!1},function(){return e.props.onHeightReady(e.state.height)})}},{key:"render",value:function(){var e=this.props,t=(e.onHeightReady,e.getElementHeight,e.dirty,e.hidden),r=e.children,n=o(e,["onHeightReady","getElementHeight","dirty","hidden","children"]),i=this.state.dirty;return t&&!i?null:t?p.default.createElement("div",{style:{height:0,overflow:"hidden"}},p.default.createElement("div",c({ref:this.setWrapperRef},n),r)):p.default.createElement("div",c({ref:this.setWrapperRef},n),r)}}]),t}(f.PureComponent);y.propTypes={children:h.default.node.isRequired,onHeightReady:h.default.func.isRequired,hidden:h.default.bool,dirty:h.default.bool,getElementHeight:h.default.func},y.defaultProps={hidden:!1,dirty:!0,getElementHeight:d}},function(e,t,r){"use strict";var n=r(0),o=n.ReactHeight;o.ReactHeight=o,e.exports=o},function(e,t,r){"use strict";function n(e){return function(){return e}}var o=function(){};o.thatReturns=n,o.thatReturnsFalse=n(!1),o.thatReturnsTrue=n(!0),o.thatReturnsNull=n(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,r){"use strict";function n(e,t,r,n,i,u,a,c){if(o(t),!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[r,n,i,u,a,c],p=0;s=new Error(t.replace(/%s/g,function(){return f[p++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}}var o=function(e){};e.exports=n},function(e,t,r){"use strict";var n=r(2),o=r(3);e.exports=function(){function e(){o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return r.checkPropTypes=n,r.PropTypes=r,r}},function(e,t,r){e.exports=r(4)()},function(t,r){t.exports=e}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("React")):"function"==typeof define&&define.amd?define(["React"],t):"object"==typeof exports?exports.ReactHeight=t(require("React")):e.ReactHeight=t(e.React)}(window,(function(e){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(t,r){t.exports=e},function(e,t,r){var n=r(2).ReactHeight;n.ReactHeight=n,e.exports=n},function(e,t,r){"use strict";r.r(t),r.d(t,"ReactHeight",(function(){return y}));var n=r(0),o=r.n(n);function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function c(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var y=function(e){function t(e){var r,n,o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n=this,o=f(t).call(this,e),r=!o||"object"!==i(o)&&"function"!=typeof o?l(n):o,s(l(r),"setWrapperRef",(function(e){r.wrapper=e})),r.state={dirty:e.dirty,height:0},r}var r,n,y;return function(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&&p(e,t)}(t,e),r=t,(n=[{key:"componentDidMount",value:function(){var e=this,t=(0,this.props.getElementHeight)(this.wrapper);this.setState({height:t,dirty:!1},(function(){(0,e.props.onHeightReady)(e.state.height)}))}},{key:"componentWillReceiveProps",value:function(e){var t=e.children,r=e.dirty;(t!==this.props.children||r)&&this.setState({dirty:!0})}},{key:"componentDidUpdate",value:function(){var e=this,t=(0,this.props.getElementHeight)(this.wrapper);t===this.state.height?this.setState({dirty:!1}):this.setState({height:t,dirty:!1},(function(){(0,e.props.onHeightReady)(e.state.height)}))}},{key:"render",value:function(){var e=this.props,t=(e.onHeightReady,e.getElementHeight,e.dirty,e.hidden),r=e.children,n=c(e,["onHeightReady","getElementHeight","dirty","hidden","children"]),i=this.state.dirty;return t&&!i?null:t?o.a.createElement("div",{style:{height:0,overflow:"hidden"}},o.a.createElement("div",u({ref:this.setWrapperRef},n),r)):o.a.createElement("div",u({ref:this.setWrapperRef},n),r)}}])&&a(r.prototype,n),y&&a(r,y),t}(n.PureComponent);s(y,"defaultProps",{hidden:!1,dirty:!0,getElementHeight:function(e){return e.clientHeight}})}])}));

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

'use strict';
"use strict";

@@ -3,0 +3,0 @@ var _require = require('./ReactHeight'),

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

'use strict';
"use strict";

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

});
exports.ReactHeight = undefined;
exports.ReactHeight = 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 _react = _interopRequireWildcard(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; }; }();
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
var _react = require('react');
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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 _propTypes = require('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); }
var _propTypes2 = _interopRequireDefault(_propTypes);
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; } /* eslint "react/no-did-mount-set-state":0 */
/* eslint "react/no-did-update-set-state":0 */
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var getElementHeight = function getElementHeight(el) {
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 _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return 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 _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
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 getElementHeightDefault = function getElementHeightDefault(el) {
return el.clientHeight;
};
var ReactHeight = exports.ReactHeight = function (_PureComponent) {
var ReactHeight =
/*#__PURE__*/
function (_PureComponent) {
_inherits(ReactHeight, _PureComponent);
function ReactHeight(props) {
var _this;
_classCallCheck(this, ReactHeight);
var _this = _possibleConstructorReturn(this, (ReactHeight.__proto__ || Object.getPrototypeOf(ReactHeight)).call(this, props));
_this = _possibleConstructorReturn(this, _getPrototypeOf(ReactHeight).call(this, props));
_this.setWrapperRef = function (el) {
_defineProperty(_assertThisInitialized(_this), "setWrapperRef", function (el) {
_this.wrapper = el;
};
});

@@ -56,36 +69,56 @@ _this.state = {

_createClass(ReactHeight, [{
key: 'componentDidMount',
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
var height = this.props.getElementHeight(this.wrapper);
var getElementHeight = this.props.getElementHeight;
var height = getElementHeight(this.wrapper);
var dirty = false;
this.setState({
height: height,
dirty: dirty
}, function () {
var onHeightReady = _this2.props.onHeightReady;
var currentHeight = _this2.state.height;
onHeightReady(currentHeight);
});
} // eslint-disable-next-line react/no-deprecated
this.setState({ height: height, dirty: dirty }, function () {
return _this2.props.onHeightReady(_this2.state.height);
});
}
}, {
key: 'componentWillReceiveProps',
key: "componentWillReceiveProps",
value: function componentWillReceiveProps(_ref) {
var children = _ref.children,
dirty = _ref.dirty;
var oldChildren = this.props.children;
if (children !== this.props.children || dirty) {
this.setState({ dirty: true });
if (children !== oldChildren || dirty) {
this.setState({
dirty: true
});
}
}
}, {
key: 'componentDidUpdate',
key: "componentDidUpdate",
value: function componentDidUpdate() {
var _this3 = this;
var height = this.props.getElementHeight(this.wrapper);
var getElementHeight = this.props.getElementHeight;
var height = getElementHeight(this.wrapper);
var dirty = false;
var currentSavedHeight = this.state.height;
if (height === this.state.height) {
this.setState({ dirty: dirty });
if (height === currentSavedHeight) {
// eslint-disable-next-line react/no-did-update-set-state
this.setState({
dirty: dirty
});
} else {
this.setState({ height: height, dirty: dirty }, function () {
return _this3.props.onHeightReady(_this3.state.height);
// eslint-disable-next-line react/no-did-update-set-state
this.setState({
height: height,
dirty: dirty
}, function () {
var onHeightReady = _this3.props.onHeightReady;
var currentHeight = _this3.state.height;
onHeightReady(currentHeight);
});

@@ -95,15 +128,14 @@ }

}, {
key: 'render',
key: "render",
value: function render() {
var _props = this.props,
_onHeightReady = _props.onHeightReady,
_getElementHeight = _props.getElementHeight,
_dirty = _props.dirty,
hidden = _props.hidden,
children = _props.children,
props = _objectWithoutProperties(_props, ['onHeightReady', 'getElementHeight', 'dirty', 'hidden', 'children']);
var _this$props = this.props,
_onHeightReady = _this$props.onHeightReady,
_getElementHeight = _this$props.getElementHeight,
_dirty = _this$props.dirty,
hidden = _this$props.hidden,
children = _this$props.children,
props = _objectWithoutProperties(_this$props, ["onHeightReady", "getElementHeight", "dirty", "hidden", "children"]);
var dirty = this.state.dirty;
if (hidden && !dirty) {

@@ -114,18 +146,15 @@ return null;

if (hidden) {
return _react2.default.createElement(
'div',
{ style: { height: 0, overflow: 'hidden' } },
_react2.default.createElement(
'div',
_extends({ ref: this.setWrapperRef }, props),
children
)
);
return _react["default"].createElement("div", {
style: {
height: 0,
overflow: 'hidden'
}
}, _react["default"].createElement("div", _extends({
ref: this.setWrapperRef
}, props), children));
}
return _react2.default.createElement(
'div',
_extends({ ref: this.setWrapperRef }, props),
children
);
return _react["default"].createElement("div", _extends({
ref: this.setWrapperRef
}, props), children);
}

@@ -137,13 +166,8 @@ }]);

ReactHeight.propTypes = {
children: _propTypes2.default.node.isRequired,
onHeightReady: _propTypes2.default.func.isRequired,
hidden: _propTypes2.default.bool,
dirty: _propTypes2.default.bool,
getElementHeight: _propTypes2.default.func
};
ReactHeight.defaultProps = {
exports.ReactHeight = ReactHeight;
_defineProperty(ReactHeight, "defaultProps", {
hidden: false,
dirty: true,
getElementHeight: getElementHeight
};
getElementHeight: getElementHeightDefault
});
{
"name": "react-height",
"version": "3.0.0",
"version": "3.0.1",
"description": "Component-wrapper to determine and report children elements height",
"main": "lib/index.js",
"config": {
"component": "ReactHeight",
"externals": {
"react": "React",
"react-dom": "ReactDOM"
},
"include": [
"https://unpkg.com/react/umd/react.production.min.js",
"https://unpkg.com/react-dom/umd/react-dom.production.min.js"
]
},
"scripts": {
"pregh-pages": "git fetch origin",
"gh-pages": "git checkout gh-pages && git rebase origin/master --force-rebase && npm run build && git add . && git commit --amend --no-edit && git push --force && git checkout master",
"build": "parallelshell -w \"npm run build:lib -s\" \"npm run build:ghPages -s\" \"npm run build:dist -s\" \"npm run build:min -s\"",
"prebuild": "rimraf lib example build",
"build:lib": "cross-env NODE_ENV=production babel src --out-dir lib --ignore src/example",
"build:ghPages": "cross-env NODE_ENV=production BUILD=ghPages webpack",
"build:dist": "cross-env NODE_ENV=production BUILD=dist webpack",
"build:min": "cross-env NODE_ENV=production BUILD=min webpack",
"prepublish": "parallelshell -w \"npm run build:lib -s\" \"npm run build:dist -s\" \"npm run build:min -s\"",
"start": "cross-env NODE_ENV=development webpack-dev-server",
"test": "cross-env NODE_ENV=test babel-node test",
"test:dev": "cross-env NODE_ENV=test babel-node test | tap-nyan",
"test:cov": "cross-env NODE_ENV=test babel-node node_modules/isparta/bin/isparta cover --report text --report html --report lcov --dir reports/coverage test",
"test:e2e": "cross-env NODE_ENV=development nightwatch-autorun",
"lint": "eslint --cache .",
"precommit": "npm run lint -s",
"prepush": "npm run test -s",
"postversion": "git push --follow-tags"
"build": "yarn lib && yarn dist",
"start": "NODE_ENV=development webpack-dev-server --config ./webpack/dev.config.js",
"predist": "rm -rf ./build",
"dist": "NODE_ENV=production webpack-cli --config ./webpack/dist.config.js && NODE_ENV=production webpack-cli --config ./webpack/min.config.js",
"preghPages": "yarn pub",
"ghPages": "gh-pages --dist ./pub --repo git@github.com:nkbt/react-height.git --user nik@butenko.me --branch gh-pages --message 'Publish examples' ",
"prelib": "rm -rf ./lib",
"lib": "NODE_ENV=production babel src --out-dir lib",
"lint": "eslint .",
"prepub": "rm -rf ./pub",
"pub": "NODE_ENV=production webpack-cli --config ./webpack/pub.config.js",
"test": "node test/Component-test.js",
"prepublishOnly": "yarn build",
"postversion": "git push --follow-tags",
"nuke": "rm -rf node_modules yarn.lock",
"postnuke": "yarn install",
"deps": "! depcheck --specials=bin,eslint --ignore-dirs=build,lib,pub | grep --invert-match 'No depcheck issue'"
},

@@ -46,38 +56,45 @@ "repository": {

},
"dependencies": {
"prop-types": "^15.5.8"
},
"devDependencies": {
"babel-cli": "6.24.1",
"babel-core": "6.24.1",
"babel-eslint": "7.2.2",
"babel-loader": "6.4.1",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-object-rest-spread": "6.23.0",
"babel-preset-es2015": "6.24.1",
"babel-preset-react": "6.24.1",
"codecov.io": "0.1.6",
"cross-env": "4.0.0",
"css-loader": "0.28.0",
"eslint": "3.19.0",
"eslint-plugin-babel": "4.1.1",
"eslint-plugin-react": "6.10.3",
"glob": "7.1.1",
"html-webpack-plugin": "2.28.0",
"husky": "0.13.3",
"isparta": "4.0.0",
"json-loader": "0.5.4",
"nightwatch-autorun": "3.1.0",
"parallelshell": "2.0.0",
"react": "15.5.4",
"react-dom": "15.5.4",
"rimraf": "2.6.1",
"sinon": "2.1.0",
"style-loader": "0.16.1",
"tap-nyan": "1.1.0",
"tap-xunit": "1.7.0",
"tape": "4.6.3",
"webpack": "2.4.1",
"webpack-dev-server": "2.4.2"
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"css-loader": "^3.2.0",
"depcheck": "^0.9.0",
"eslint": "^6.4.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.14.3",
"eslint-plugin-react-hooks": "^1.7.0",
"gh-pages": "^2.1.1",
"html-webpack-plugin": "^3.2.0",
"html-webpack-tags-plugin": "^2.0.17",
"mini-css-extract-plugin": "^0.8.0",
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"style-loader": "^1.0.0",
"tape": "^4.11.0",
"webpack": "^4.41.0",
"webpack-cli": "^3.3.9",
"webpack-dev-server": "^3.8.1"
},
"dependencies": {
"prop-types": "15.5.8"
}
"files": [
"build",
"lib",
"src",
"LICENSE",
"package.json",
"README.md"
]
}
# react-height [![npm](https://img.shields.io/npm/v/react-height.svg?style=flat-square)](https://www.npmjs.com/package/react-height)
[![Gitter](https://img.shields.io/gitter/room/nkbt/help.svg?style=flat-square)](https://gitter.im/nkbt/help)
[![CircleCI](https://img.shields.io/circleci/project/nkbt/react-height.svg?style=flat-square&label=nix-build)](https://circleci.com/gh/nkbt/react-height)
[![AppVeyor](https://img.shields.io/appveyor/ci/nkbt/react-height.svg?style=flat-square&label=win-build)](https://ci.appveyor.com/project/nkbt/react-height)
[![Coverage](https://img.shields.io/codecov/c/github/nkbt/react-height.svg?style=flat-square)](https://codecov.io/github/nkbt/react-height?branch=master)
[![CircleCI](https://img.shields.io/circleci/project/nkbt/react-height.svg?style=flat-square&label=build)](https://circleci.com/gh/nkbt/react-height)
[![Dependencies](https://img.shields.io/david/nkbt/react-height.svg?style=flat-square)](https://david-dm.org/nkbt/react-height)
[![Dev Dependencies](https://img.shields.io/david/dev/nkbt/react-height.svg?style=flat-square)](https://david-dm.org/nkbt/react-height#info=devDependencies)
React component that renders an Input, Textarea or other element with debounced onChange. Can be used as drop-in replacement for `<input type="text" />` or `<textarea />`
![React Height](./example/react-height.gif)
Component-wrapper to determine and report children elements height

@@ -17,6 +17,13 @@

- not based on specific browser APIs, so can be used in other environments too
- used as backend for [`react-collapse`](https://github.com/nkbt/react-collapse)
![React Height](src/example/react-height.gif)
## Demo
[https://nkbt.github.io/react-height](https://nkbt.github.io/react-height)
## Codepen demo
[https://codepen.io/nkbt/pen/NGzgGb](https://codepen.io/nkbt/pen/NGzgGb?editors=101)
## Installation

@@ -27,12 +34,15 @@

```sh
npm install --save react react-height
npm install --save react-height
```
Don't forget to manually install peer dependencies (`react`) if you use npm@3.
### yarn
```sh
yarn add react-height
```
### 1998 Script Tag:
```html
<script src="https://unpkg.com/react/dist/react.js"></script>
<script src="https://unpkg.com/react-height/build/react-height.min.js"></script>
<script src="https://unpkg.com/react/umd/react.production.min.js"></script>
<script src="https://unpkg.com/react-height/build/react-height.js"></script>
(Module exposed as `ReactHeight`)

@@ -42,10 +52,2 @@ ```

## Demo
[http://nkbt.github.io/react-height/example](http://nkbt.github.io/react-height/example)
## Codepen demo
[http://codepen.io/nkbt/pen/NGzgGb](http://codepen.io/nkbt/pen/NGzgGb?editors=101)
## Usage

@@ -63,11 +65,11 @@ ```js

#### `onHeightReady`: PropTypes.func.isRequired
### `onHeightReady`: PropTypes.func.isRequired
Callback, invoked when height is measured (and when it is changed).
#### `getElementHeight`: PropTypes.func
### `getElementHeight`: PropTypes.func
Function to measure your element. It receives the element as argument and defaults to `el => el.clientHeight`.
#### `children`: PropTypes.node.isRequired
### `children`: PropTypes.node.isRequired

@@ -86,3 +88,3 @@ One or multiple children with static, variable or dynamic height.

#### `hidden`: PropTypes.bool (default: false)
### `hidden`: PropTypes.bool (default: false)

@@ -97,3 +99,3 @@ ReactHeight can render to null as soon as height is measured.

#### Pass-through props
### Pass-through props

@@ -118,6 +120,5 @@ All other props are applied to a container that is being measured. So it is possible to pass `style` or `className`, for example.

Currently is being developed and tested with the latest stable `Node 7` on `OSX` and `Windows`.
Should be ok with Node 6, but not guaranteed.
Currently is being developed and tested with the latest stable `Node` on `OSX`.
To run example covering all `ReactHeight` features, use `npm start`, which will compile `src/example/Example.js`
To run example covering all `ReactHeight` features, use `yarn start`, which will compile `example/Example.js`

@@ -127,4 +128,4 @@ ```bash

cd react-height
npm install
npm start
yarn install
yarn start

@@ -138,9 +139,7 @@ # then

```bash
npm test
# to run ESLint check
yarn lint
# to run tests in watch mode for development
npm run test:dev
# to generate test coverage (./reports/coverage)
npm run test:cov
# to run tests
yarn test
```

@@ -147,0 +146,0 @@

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

'use strict';

@@ -3,0 +2,0 @@ const {ReactHeight} = require('./ReactHeight');

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

/* eslint "react/no-did-mount-set-state":0 */
/* eslint "react/no-did-update-set-state":0 */
import React, {PureComponent} from 'react';

@@ -9,3 +5,3 @@ import PropTypes from 'prop-types';

const getElementHeight = el => el.clientHeight;
const getElementHeightDefault = el => el.clientHeight;

@@ -26,3 +22,3 @@

dirty: true,
getElementHeight
getElementHeight: getElementHeightDefault
};

@@ -41,11 +37,18 @@

componentDidMount() {
const height = this.props.getElementHeight(this.wrapper);
const {getElementHeight} = this.props;
const height = getElementHeight(this.wrapper);
const dirty = false;
this.setState({height, dirty}, () => this.props.onHeightReady(this.state.height));
this.setState({height, dirty}, () => {
const {onHeightReady} = this.props;
const {height: currentHeight} = this.state;
onHeightReady(currentHeight);
});
}
// eslint-disable-next-line react/no-deprecated
componentWillReceiveProps({children, dirty}) {
if (children !== this.props.children || dirty) {
const {children: oldChildren} = this.props;
if (children !== oldChildren || dirty) {
this.setState({dirty: true});

@@ -57,9 +60,18 @@ }

componentDidUpdate() {
const height = this.props.getElementHeight(this.wrapper);
const {getElementHeight} = this.props;
const height = getElementHeight(this.wrapper);
const dirty = false;
if (height === this.state.height) {
const {height: currentSavedHeight} = this.state;
if (height === currentSavedHeight) {
// eslint-disable-next-line react/no-did-update-set-state
this.setState({dirty});
} else {
this.setState({height, dirty}, () => this.props.onHeightReady(this.state.height));
// eslint-disable-next-line react/no-did-update-set-state
this.setState({height, dirty}, () => {
const {onHeightReady} = this.props;
const {height: currentHeight} = this.state;
onHeightReady(currentHeight);
});
}

@@ -66,0 +78,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