New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

uxcore-collapse

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uxcore-collapse - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

src/Panel.js

3

HISTORY.md

@@ -5,2 +5,5 @@ # History

## 1.1.0
`UPGRADE` remove rc-collapse dep
## 1.0.1

@@ -7,0 +10,0 @@ `UPGRADE` upgrade to rc-collapse@1.4.3

5

package.json
{
"name": "uxcore-collapse",
"version": "1.0.1",
"version": "1.1.0",
"description": "uxcore-collapse component for uxcore.",

@@ -38,4 +38,3 @@ "repository": "https://github.com/uxcore/uxcore-collapse.git",

"classnames": "^2.1.2",
"object-assign": "^2.0.0",
"rc-collapse": "^1.4.0"
"object-assign": "^4.0.0"
},

@@ -42,0 +41,0 @@ "contributors": [],

@@ -1,31 +0,127 @@

/**
* Collapse Component for uxcore
* @author vicent.bian
*
* Copyright 2014-2015, Uxcore Team, Alinw.
* All rights reserved.
*/
import React from 'react';
import RcCollapse from 'rc-collapse';
const prefixCls = 'kuma-collapse';
import React, { PropTypes, createClass, Children } from 'react';
import CollapsePanel from './Panel';
class Collapse extends React.Component {
const Collapse = createClass({
statics: {
Panel: CollapsePanel,
},
constructor(props) {
super(props);
propTypes: {
prefixCls: PropTypes.string,
activeKey: PropTypes.oneOfType([
PropTypes.string,
PropTypes.arrayOf(PropTypes.string),
]),
defaultActiveKey: PropTypes.oneOfType([
PropTypes.string,
PropTypes.arrayOf(PropTypes.string),
]),
onChange: PropTypes.func,
accordion: PropTypes.bool,
},
getDefaultProps() {
return {
prefixCls: 'kuma-collapse',
onChange: () => {
},
accordion: false,
};
},
getInitialState() {
const { activeKey, accordion } = this.props;
let { defaultActiveKey } = this.props;
// If is not accordion mode, then, defaultActiveKey should be an array
if (!accordion) {
defaultActiveKey = defaultActiveKey || [];
}
render() {
return <RcCollapse {...this.props} />;
return {
activeKey: activeKey || defaultActiveKey,
};
},
componentWillReceiveProps(nextProps) {
if ('activeKey' in nextProps) {
this.setState({
activeKey: nextProps.activeKey,
});
}
}
},
Collapse.defaultProps = {
prefixCls: prefixCls
};
handleClickItem(key) {
return () => {
const activeKey = this._getActivityKey();
if (this.props.accordion) {
this.setState({
activeKey: key === activeKey ? null : key,
});
} else {
const index = activeKey.indexOf(key);
const isActive = index > -1;
if (isActive) {
// remove active state
activeKey.splice(index, 1);
} else {
activeKey.push(key);
}
Collapse.Panel = RcCollapse.Panel;
this.setState({activeKey: activeKey});
}
this.props.onChange(key);
};
},
Collapse.displayName = "Collapse";
_getActivityKey() {
let activeKey = this.state.activeKey;
const { accordion } = this.props;
if (accordion && Array.isArray(activeKey)) {
activeKey = activeKey[0];
}
export default Collapse;
if (!accordion && !Array.isArray(activeKey)) {
activeKey = activeKey ? [activeKey] : [];
}
return activeKey;
},
getItems() {
const activeKey = this._getActivityKey();
const { prefixCls, accordion } = this.props;
return Children.map(this.props.children, (child, index) => {
// If there is no key provide, use the panel order as default key
const key = child.key || index;
const header = child.props.header;
let isActive = false;
if (accordion) {
isActive = activeKey === key;
} else {
isActive = activeKey.indexOf(key) > -1;
}
const props = {
key,
header,
isActive,
prefixCls,
children: child.props.children,
onItemClick: this.handleClickItem(key).bind(this),
};
return <CollapsePanel {...props} />;
});
},
render() {
const prefixCls = this.props.prefixCls;
return (
<div className={prefixCls}>
{this.getItems()}
</div>
);
},
});
export default Collapse;
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