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

rc-tabs

Package Overview
Dependencies
Maintainers
1
Versions
228
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rc-tabs - npm Package Compare versions

Comparing version 8.1.0 to 8.1.1

131

es/Tabs.js

@@ -32,10 +32,3 @@ import _defineProperty from 'babel-runtime/helpers/defineProperty';

_this.render = _this.render.bind(_this);
_this.componentWillReceiveProps = _this.componentWillReceiveProps.bind(_this);
_this.onTabClick = _this.onTabClick.bind(_this);
_this.onNavKeyDown = _this.onNavKeyDown.bind(_this);
_this.setActiveKey = _this.setActiveKey.bind(_this);
_this.getNextActiveKey = _this.getNextActiveKey.bind(_this);
_this.onTabClick = _this.onTabClick.bind(_this);
_this.onTabClick = _this.onTabClick.bind(_this);
_initialiseProps.call(_this);

@@ -67,63 +60,2 @@ var activeKey = void 0;

}, {
key: 'onTabClick',
value: function onTabClick(activeKey) {
if (this.tabBar.props.onTabClick) {
this.tabBar.props.onTabClick(activeKey);
}
this.setActiveKey(activeKey);
}
}, {
key: 'onNavKeyDown',
value: function onNavKeyDown(e) {
var eventKeyCode = e.keyCode;
if (eventKeyCode === KeyCode.RIGHT || eventKeyCode === KeyCode.DOWN) {
e.preventDefault();
var nextKey = this.getNextActiveKey(true);
this.onTabClick(nextKey);
} else if (eventKeyCode === KeyCode.LEFT || eventKeyCode === KeyCode.UP) {
e.preventDefault();
var previousKey = this.getNextActiveKey(false);
this.onTabClick(previousKey);
}
}
}, {
key: 'setActiveKey',
value: function setActiveKey(activeKey) {
if (this.state.activeKey !== activeKey) {
if (!('activeKey' in this.props)) {
this.setState({
activeKey: activeKey
});
}
this.props.onChange(activeKey);
}
}
}, {
key: 'getNextActiveKey',
value: function getNextActiveKey(next) {
var activeKey = this.state.activeKey;
var children = [];
React.Children.forEach(this.props.children, function (c) {
if (c && !c.props.disabled) {
if (next) {
children.push(c);
} else {
children.unshift(c);
}
}
});
var length = children.length;
var ret = length && children[0].key;
children.forEach(function (child, i) {
if (child.key === activeKey) {
if (i === length - 1) {
ret = children[0].key;
} else {
ret = children[i + 1].key;
}
}
});
return ret;
}
}, {
key: 'render',

@@ -177,2 +109,63 @@ value: function render() {

var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.onTabClick = function (activeKey) {
if (_this2.tabBar.props.onTabClick) {
_this2.tabBar.props.onTabClick(activeKey);
}
_this2.setActiveKey(activeKey);
};
this.onNavKeyDown = function (e) {
var eventKeyCode = e.keyCode;
if (eventKeyCode === KeyCode.RIGHT || eventKeyCode === KeyCode.DOWN) {
e.preventDefault();
var nextKey = _this2.getNextActiveKey(true);
_this2.onTabClick(nextKey);
} else if (eventKeyCode === KeyCode.LEFT || eventKeyCode === KeyCode.UP) {
e.preventDefault();
var previousKey = _this2.getNextActiveKey(false);
_this2.onTabClick(previousKey);
}
};
this.setActiveKey = function (activeKey) {
if (_this2.state.activeKey !== activeKey) {
if (!('activeKey' in _this2.props)) {
_this2.setState({
activeKey: activeKey
});
}
_this2.props.onChange(activeKey);
}
};
this.getNextActiveKey = function (next) {
var activeKey = _this2.state.activeKey;
var children = [];
React.Children.forEach(_this2.props.children, function (c) {
if (c && !c.props.disabled) {
if (next) {
children.push(c);
} else {
children.unshift(c);
}
}
});
var length = children.length;
var ret = length && children[0].key;
children.forEach(function (child, i) {
if (child.key === activeKey) {
if (i === length - 1) {
ret = children[0].key;
} else {
ret = children[i + 1].key;
}
}
});
return ret;
};
};
export default Tabs;

@@ -179,0 +172,0 @@

@@ -69,10 +69,3 @@ 'use strict';

_this.render = _this.render.bind(_this);
_this.componentWillReceiveProps = _this.componentWillReceiveProps.bind(_this);
_this.onTabClick = _this.onTabClick.bind(_this);
_this.onNavKeyDown = _this.onNavKeyDown.bind(_this);
_this.setActiveKey = _this.setActiveKey.bind(_this);
_this.getNextActiveKey = _this.getNextActiveKey.bind(_this);
_this.onTabClick = _this.onTabClick.bind(_this);
_this.onTabClick = _this.onTabClick.bind(_this);
_initialiseProps.call(_this);

@@ -104,63 +97,2 @@ var activeKey = void 0;

}, {
key: 'onTabClick',
value: function onTabClick(activeKey) {
if (this.tabBar.props.onTabClick) {
this.tabBar.props.onTabClick(activeKey);
}
this.setActiveKey(activeKey);
}
}, {
key: 'onNavKeyDown',
value: function onNavKeyDown(e) {
var eventKeyCode = e.keyCode;
if (eventKeyCode === _KeyCode2['default'].RIGHT || eventKeyCode === _KeyCode2['default'].DOWN) {
e.preventDefault();
var nextKey = this.getNextActiveKey(true);
this.onTabClick(nextKey);
} else if (eventKeyCode === _KeyCode2['default'].LEFT || eventKeyCode === _KeyCode2['default'].UP) {
e.preventDefault();
var previousKey = this.getNextActiveKey(false);
this.onTabClick(previousKey);
}
}
}, {
key: 'setActiveKey',
value: function setActiveKey(activeKey) {
if (this.state.activeKey !== activeKey) {
if (!('activeKey' in this.props)) {
this.setState({
activeKey: activeKey
});
}
this.props.onChange(activeKey);
}
}
}, {
key: 'getNextActiveKey',
value: function getNextActiveKey(next) {
var activeKey = this.state.activeKey;
var children = [];
_react2['default'].Children.forEach(this.props.children, function (c) {
if (c && !c.props.disabled) {
if (next) {
children.push(c);
} else {
children.unshift(c);
}
}
});
var length = children.length;
var ret = length && children[0].key;
children.forEach(function (child, i) {
if (child.key === activeKey) {
if (i === length - 1) {
ret = children[0].key;
} else {
ret = children[i + 1].key;
}
}
});
return ret;
}
}, {
key: 'render',

@@ -213,2 +145,63 @@ value: function render() {

var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.onTabClick = function (activeKey) {
if (_this2.tabBar.props.onTabClick) {
_this2.tabBar.props.onTabClick(activeKey);
}
_this2.setActiveKey(activeKey);
};
this.onNavKeyDown = function (e) {
var eventKeyCode = e.keyCode;
if (eventKeyCode === _KeyCode2['default'].RIGHT || eventKeyCode === _KeyCode2['default'].DOWN) {
e.preventDefault();
var nextKey = _this2.getNextActiveKey(true);
_this2.onTabClick(nextKey);
} else if (eventKeyCode === _KeyCode2['default'].LEFT || eventKeyCode === _KeyCode2['default'].UP) {
e.preventDefault();
var previousKey = _this2.getNextActiveKey(false);
_this2.onTabClick(previousKey);
}
};
this.setActiveKey = function (activeKey) {
if (_this2.state.activeKey !== activeKey) {
if (!('activeKey' in _this2.props)) {
_this2.setState({
activeKey: activeKey
});
}
_this2.props.onChange(activeKey);
}
};
this.getNextActiveKey = function (next) {
var activeKey = _this2.state.activeKey;
var children = [];
_react2['default'].Children.forEach(_this2.props.children, function (c) {
if (c && !c.props.disabled) {
if (next) {
children.push(c);
} else {
children.unshift(c);
}
}
});
var length = children.length;
var ret = length && children[0].key;
children.forEach(function (child, i) {
if (child.key === activeKey) {
if (i === length - 1) {
ret = children[0].key;
} else {
ret = children[i + 1].key;
}
}
});
return ret;
};
};
exports['default'] = Tabs;

@@ -215,0 +208,0 @@

{
"name": "rc-tabs",
"version": "8.1.0",
"version": "8.1.1",
"description": "tabs ui component for react",

@@ -35,2 +35,3 @@ "keywords": [

"start": "rc-tools run server",
"start:preact": "cross-env DEMO_ENV=preact rc-tools run server",
"pub": "rc-tools run pub --babel-runtime",

@@ -57,2 +58,3 @@ "lint": "rc-tools run lint",

"coveralls": "^2.11.16",
"cross-env": "^5.0.1",
"enzyme": "^2.7.1",

@@ -70,3 +72,5 @@ "enzyme-to-json": "^1.5.0",

"react-router": "2.x",
"react-test-renderer": "^15.5.4"
"react-test-renderer": "^15.5.4",
"preact": "^8.2.1",
"preact-compat": "^3.16.0"
},

@@ -73,0 +77,0 @@ "pre-commit": [

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