react-sticky-table
Advanced tools
Comparing version 5.1.2 to 5.1.3
@@ -26,3 +26,9 @@ (function (global, factory) { | ||
it('should render children properly', function () { | ||
var cell = (0, _enzyme.mount)(_react["default"].createElement(_index.Cell, null, _react["default"].createElement("span", null), _react["default"].createElement("span", null))); | ||
var cell = (0, _enzyme.mount)( | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement("span", null), | ||
/*#__PURE__*/ | ||
_react["default"].createElement("span", null))); | ||
(0, _chai.expect)(cell.find(_index.Cell).find('span')).to.have.length(2); | ||
@@ -29,0 +35,0 @@ }); |
@@ -26,30 +26,102 @@ (function (global, factory) { | ||
it('should render the correct number of children', function () { | ||
var table = (0, _enzyme.mount)(_react["default"].createElement(_index.StickyTable, { | ||
var table = (0, _enzyme.mount)( | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.StickyTable, { | ||
leftStickyColumnCount: 1 | ||
}, _react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "header 1"), _react["default"].createElement(_index.Cell, null, "header 2")), _react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "column 1 cell"), _react["default"].createElement(_index.Cell, null, "column 2 cell")))); | ||
}, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 1"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 2")), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "column 1 cell"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "column 2 cell")))); | ||
(0, _chai.expect)(table.find(_index.Cell)).to.have.length(4); | ||
}); | ||
it('shouldn\'t render columns when opting out', function () { | ||
var table = (0, _enzyme.mount)(_react["default"].createElement(_index.StickyTable, { | ||
var table = (0, _enzyme.mount)( | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.StickyTable, { | ||
leftStickyColumnCount: 0 | ||
}, _react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "header 1"), _react["default"].createElement(_index.Cell, null, "header 2")), _react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "column 1 cell"), _react["default"].createElement(_index.Cell, null, "column 2 cell")))); | ||
}, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 1"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 2")), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "column 1 cell"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "column 2 cell")))); | ||
(0, _chai.expect)(table.find(_index.Cell)).to.have.length(4); | ||
}); | ||
it('should render the correct number of leftStickyColumnCount', function () { | ||
var table = (0, _enzyme.mount)(_react["default"].createElement(_index.StickyTable, { | ||
var table = (0, _enzyme.mount)( | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.StickyTable, { | ||
leftStickyColumnCount: 3 | ||
}, _react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "header 1"), _react["default"].createElement(_index.Cell, null, "header 2"), _react["default"].createElement(_index.Cell, null, "header 3"), _react["default"].createElement(_index.Cell, null, "header 4")), _react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "column 1 cell"), _react["default"].createElement(_index.Cell, null, "column 2 cell"), _react["default"].createElement(_index.Cell, null, "column 3 cell"), _react["default"].createElement(_index.Cell, null, "column 4 cell")))); | ||
}, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 1"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 2"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 3"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 4")), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "column 1 cell"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "column 2 cell"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "column 3 cell"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "column 4 cell")))); | ||
(0, _chai.expect)(table.find(_index.Cell)).to.have.length(8); | ||
}); | ||
it('shouldn\'t render headers when opting out', function () { | ||
var table = (0, _enzyme.mount)(_react["default"].createElement(_index.StickyTable, { | ||
var table = (0, _enzyme.mount)( | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.StickyTable, { | ||
leftStickyColumnCount: 1, | ||
stickyHeaderCount: 0 | ||
}, _react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "header 1"), _react["default"].createElement(_index.Cell, null, "header 2")), _react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "column 1 cell"), _react["default"].createElement(_index.Cell, null, "column 2 cell")))); | ||
}, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 1"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 2")), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "column 1 cell"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "column 2 cell")))); | ||
(0, _chai.expect)(table.find(_index.Cell)).to.have.length(4); | ||
}); | ||
it('should support sibling components and arrays', function () { | ||
var table = (0, _enzyme.mount)(_react["default"].createElement(_index.StickyTable, { | ||
var table = (0, _enzyme.mount)( | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.StickyTable, { | ||
leftStickyColumnCount: 1 | ||
}, _react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "header 1"), [_react["default"].createElement(_index.Cell, { | ||
}, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 1"), [ | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, { | ||
key: 1 | ||
@@ -56,0 +128,0 @@ }, "header 2")]))); |
@@ -26,3 +26,9 @@ (function (global, factory) { | ||
it('should render children properly', function () { | ||
var row = (0, _enzyme.mount)(_react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "header 1"), _react["default"].createElement(_index.Cell, null, "header 2"))); | ||
var row = (0, _enzyme.mount)( | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 1"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 2"))); | ||
(0, _chai.expect)(row.find(_index.Cell)).to.have.length(2); | ||
@@ -29,0 +35,0 @@ }); |
@@ -26,3 +26,11 @@ (function (global, factory) { | ||
it('should render children properly', function () { | ||
var table = (0, _enzyme.mount)(_react["default"].createElement(_index.Table, null, _react["default"].createElement(_index.Row, null, _react["default"].createElement(_index.Cell, null, "header 1"), _react["default"].createElement(_index.Cell, null, "header 2")))); | ||
var table = (0, _enzyme.mount)( | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Table, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Row, null, | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 1"), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(_index.Cell, null, "header 2")))); | ||
(0, _chai.expect)(table.find(_index.Row)).to.have.length(1); | ||
@@ -29,0 +37,0 @@ (0, _chai.expect)(table.find(_index.Cell)).to.have.length(2); |
@@ -23,7 +23,9 @@ (function (global, factory) { | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } | ||
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; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
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 _typeof(obj) { "@babel/helpers - typeof"; 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); } | ||
@@ -36,8 +38,12 @@ 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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
@@ -51,11 +57,15 @@ | ||
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 _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function () { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } 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 _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
@@ -120,19 +130,27 @@ 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 Table = (0, _styledComponents["default"])('div').attrs({ | ||
className: 'sticky-table-table' | ||
var Table = (0, _styledComponents["default"])('div').attrs(function () { | ||
return { | ||
className: 'sticky-table-table' | ||
}; | ||
})(_templateObject()); | ||
_exports.Table = Table; | ||
Table.displayName = 'Table'; | ||
var Cell = (0, _styledComponents["default"])('div').attrs({ | ||
className: 'sticky-table-cell' | ||
var Cell = (0, _styledComponents["default"])('div').attrs(function () { | ||
return { | ||
className: 'sticky-table-cell' | ||
}; | ||
})(_templateObject2()); | ||
_exports.Cell = Cell; | ||
Cell.displayName = 'Cell'; | ||
var Row = (0, _styledComponents["default"])('div').attrs({ | ||
className: 'sticky-table-row' | ||
var Row = (0, _styledComponents["default"])('div').attrs(function () { | ||
return { | ||
className: 'sticky-table-row' | ||
}; | ||
})(_templateObject3()); | ||
_exports.Row = Row; | ||
Row.displayName = 'Row'; | ||
var Wrapper = (0, _styledComponents["default"])('div').attrs({ | ||
className: 'sticky-table' | ||
var Wrapper = (0, _styledComponents["default"])('div').attrs(function () { | ||
return { | ||
className: 'sticky-table' | ||
}; | ||
})(_templateObject4(), Row, function (props) { | ||
@@ -210,5 +228,5 @@ return (props.stickyFooterCount || 0) + 1; | ||
var _super = _createSuper(StickyTable); | ||
function StickyTable() { | ||
var _getPrototypeOf2; | ||
var _this; | ||
@@ -222,3 +240,3 @@ | ||
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(StickyTable)).call.apply(_getPrototypeOf2, [this].concat(args))); | ||
_this = _super.call.apply(_super, [this].concat(args)); | ||
@@ -286,2 +304,3 @@ _defineProperty(_assertThisInitialized(_this), "state", { | ||
tableNode = this.tableNode; | ||
var rowNodes = tableNode.querySelectorAll('.sticky-table-row'); | ||
var cellNodes = tableNode.querySelectorAll('.sticky-table-cell'); | ||
@@ -294,15 +313,37 @@ [['header', 'height', 'stickyHeaderCount'], ['footer', 'height', 'stickyFooterCount'], ['leftColumn', 'width', 'leftStickyColumnCount'], ['rightColumn', 'width', 'rightStickyColumnCount']].forEach(function (_ref) { | ||
var insets = [0]; | ||
var count = props[countPropKey]; | ||
var netInset = 0; //HINT we only want this loop for the second sticky and up | ||
var insets = []; | ||
for (s = 1; s < count; s++) { | ||
var node = stickyKey === 'header' || stickyKey === 'leftColumn' ? cellNodes[0] : cellNodes[cellNodes.length - 1]; | ||
if (props[countPropKey] > 1) { | ||
insets = [0]; | ||
var count = props[countPropKey]; | ||
var netInset = 0; // HINT we only want this loop for the second sticky and up | ||
if (node) { | ||
var boundingRect = node.getBoundingClientRect(); | ||
netInset += boundingRect[sizeKey]; | ||
for (s = 1; s < count; s++) { | ||
var node = undefined; | ||
switch (stickyKey) { | ||
case 'header': | ||
node = rowNodes[s - 1].childNodes[0]; | ||
break; | ||
case 'footer': | ||
node = rowNodes[rowNodes.length - s].childNodes[0]; | ||
break; | ||
case 'leftColumn': | ||
node = cellNodes[s - 1]; | ||
break; | ||
case 'rightColumn': | ||
node = cellNodes[cellNodes.length - s]; | ||
break; | ||
} | ||
if (node) { | ||
var boundingRect = node.getBoundingClientRect(); | ||
netInset += boundingRect[sizeKey]; | ||
} | ||
insets.push(netInset); | ||
} | ||
insets.push(netInset); | ||
} | ||
@@ -331,10 +372,15 @@ | ||
return _react["default"].createElement(Wrapper, _extends({ | ||
ref: wrapperRef, | ||
leftStickyColumnCount: leftStickyColumnCount, | ||
stickyHeaderCount: stickyHeaderCount, | ||
stickyInsets: this.state.stickyInsets | ||
}, restProps), _react["default"].createElement(Table, { | ||
ref: this.setTableNodeRef | ||
}, children)); | ||
return ( | ||
/*#__PURE__*/ | ||
_react["default"].createElement(Wrapper, _extends({ | ||
ref: wrapperRef, | ||
leftStickyColumnCount: leftStickyColumnCount, | ||
stickyHeaderCount: stickyHeaderCount, | ||
stickyInsets: this.state.stickyInsets | ||
}, restProps), | ||
/*#__PURE__*/ | ||
_react["default"].createElement(Table, { | ||
ref: this.setTableNodeRef | ||
}, children)) | ||
); | ||
} | ||
@@ -341,0 +387,0 @@ }]); |
{ | ||
"name": "react-sticky-table", | ||
"description": "Dynamically sized fixed header and columns for tables", | ||
"version": "5.1.2", | ||
"version": "5.1.3", | ||
"author": "Henrybuilt", | ||
@@ -6,0 +6,0 @@ "bugs": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
6268652
9677
2