react-simple-collapsible-element
Advanced tools
Comparing version 2.0.10 to 2.0.11
@@ -1,1 +0,123 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _react=require('react'),_react2=_interopRequireDefault(_react),_propTypes=require('prop-types'),_propTypes2=_interopRequireDefault(_propTypes),_Content=require('./Content'),_Content2=_interopRequireDefault(_Content),_Title=require('./Title'),_Title2=_interopRequireDefault(_Title),_util=require('./util');function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function renderNestedElements(a,b,c,d){var e=!!(4<arguments.length&&arguments[4]!==void 0)&&arguments[4],f=5<arguments.length&&arguments[5]!==void 0?arguments[5]:'';if(!Array.isArray(a))throw new Error('nested elements must be an array');return a.map(function(a,g){var h=a.titleStyle||{},i=a.contentStyle||{};return Array.isArray(a.content)?_react2.default.createElement('div',{key:g},_react2.default.createElement(_Title2.default,{onCollapse:d,titleStyle:h,index:b+'-'+g,text:a.title,active:(0,_util.checkIfActive)(c,b,e),activeTitleStyle:a.activeTitleStyle,customTransition:f,isNested:!0}),renderNestedElements(a.content,b+'-'+g,c,d,e,f)):_react2.default.createElement('div',{key:g},_react2.default.createElement(_Title2.default,{titleStyle:h,onCollapse:d,index:b+'-'+g,text:a.title,active:(0,_util.checkIfActive)(c,b,e),activeTitleStyle:a.activeTitleStyle,customTransition:f,isNested:!0}),_react2.default.createElement(_Content2.default,{contentStyle:i,index:b+'-'+g,active:(0,_util.checkIfActive)(c,b+'-'+g,e),text:a.content,activeContentStyle:a.activeContentStyle,customTransition:f}))})}var CollapsePane=function(a){var b=a.index,c=a.items,d=a.currentActiveIndex,e=a.onCollapse,f=a.keepOpen,g=a.customTransition,h=c.titleStyle||{},i=c.contentStyle||{};return _react2.default.createElement('div',null,_react2.default.createElement(_Title2.default,{titleStyle:h,index:b,onCollapse:e,text:c.title,customTransition:g}),Array.isArray(c.content)?renderNestedElements(c.content,b,d,e,f,g):_react2.default.createElement(_Content2.default,{active:(0,_util.checkIfActive)(d,b,f),text:c.content,contentStyle:i,activeContentStyle:c.activeContentStyle,customTransition:g}))};CollapsePane.propTypes={index:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]).isRequired,items:_propTypes2.default.shape({title:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.element]),content:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.element,_propTypes2.default.array])}).isRequired,currentActiveIndex:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number,_propTypes2.default.array]),keepOpen:_propTypes2.default.bool,customTransition:_propTypes2.default.string,onCollapse:_propTypes2.default.func},CollapsePane.defaultProps={currentActiveIndex:void 0,keepOpen:!1,customTransition:'',onCollapse:function a(){}},exports.default=CollapsePane; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: !0 }); | ||
var _react = require("react"), | ||
_react2 = _interopRequireDefault(_react), | ||
_propTypes = require("prop-types"), | ||
_propTypes2 = _interopRequireDefault(_propTypes), | ||
_Content = require("./Content"), | ||
_Content2 = _interopRequireDefault(_Content), | ||
_Title = require("./Title"), | ||
_Title2 = _interopRequireDefault(_Title), | ||
_util = require("./util"); | ||
function _interopRequireDefault(a) { | ||
return a && a.__esModule ? a : { default: a }; | ||
} | ||
function renderNestedElements(a, b, c, d) { | ||
var e = !!(4 < arguments.length && arguments[4] !== void 0) && arguments[4], | ||
f = 5 < arguments.length && arguments[5] !== void 0 ? arguments[5] : ""; | ||
if (!Array.isArray(a)) throw new Error("nested elements must be an array"); | ||
return a.map(function(a, g) { | ||
var h = a.titleStyle || {}, | ||
i = a.contentStyle || {}; | ||
return Array.isArray(a.content) // eslint-disable-next-line | ||
? _react2.default.createElement( | ||
"div", | ||
{ key: g }, | ||
_react2.default.createElement(_Title2.default, { | ||
onCollapse: d, | ||
titleStyle: h, | ||
index: b + "-" + g, | ||
text: a.title, | ||
active: (0, _util.checkIfActive)(c, b, e), | ||
activeTitleStyle: a.activeTitleStyle, | ||
customTransition: f, | ||
isNested: !0 | ||
}), | ||
renderNestedElements(a.content, b + "-" + g, c, d, e, f) | ||
) // eslint-disable-next-line | ||
: _react2.default.createElement( | ||
"div", | ||
{ key: g }, | ||
_react2.default.createElement(_Title2.default, { | ||
titleStyle: h, | ||
onCollapse: d, | ||
index: b + "-" + g, | ||
text: a.title, | ||
active: (0, _util.checkIfActive)(c, b, e), | ||
activeTitleStyle: a.activeTitleStyle, | ||
customTransition: f, | ||
isNested: !0 | ||
}), | ||
_react2.default.createElement(_Content2.default, { | ||
contentStyle: i, | ||
index: b + "-" + g, | ||
active: (0, _util.checkIfActive)(c, b + "-" + g, e), | ||
text: a.content, | ||
activeContentStyle: a.activeContentStyle, | ||
customTransition: f | ||
}) | ||
); | ||
}); | ||
} // eslint-disable-next-line | ||
var CollapsePane = function(a) { | ||
var b = a.index, | ||
c = a.items, | ||
d = a.currentActiveIndex, | ||
e = a.onCollapse, | ||
f = a.keepOpen, | ||
g = a.customTransition, | ||
h = c.titleStyle || {}, | ||
i = c.contentStyle || {}; | ||
return _react2.default.createElement( | ||
"div", | ||
null, | ||
_react2.default.createElement(_Title2.default, { | ||
titleStyle: h, | ||
index: b, | ||
onCollapse: e, | ||
text: c.title, | ||
customTransition: g | ||
}), | ||
Array.isArray(c.content) | ||
? renderNestedElements(c.content, b, d, e, f, g) | ||
: _react2.default.createElement(_Content2.default, { | ||
active: (0, _util.checkIfActive)(d, b, f), | ||
text: c.content, | ||
contentStyle: i, | ||
activeContentStyle: c.activeContentStyle, | ||
customTransition: g | ||
}) | ||
); | ||
}; | ||
(CollapsePane.propTypes = { | ||
index: _propTypes2.default.oneOfType([ | ||
_propTypes2.default.string, | ||
_propTypes2.default.number | ||
]).isRequired, | ||
items: _propTypes2.default.shape({ | ||
title: _propTypes2.default.oneOfType([ | ||
_propTypes2.default.string, | ||
_propTypes2.default.element | ||
]), | ||
content: _propTypes2.default.oneOfType([ | ||
_propTypes2.default.string, | ||
_propTypes2.default.element, | ||
_propTypes2.default.array | ||
]) | ||
}).isRequired, | ||
currentActiveIndex: _propTypes2.default.oneOfType([ | ||
_propTypes2.default.string, | ||
_propTypes2.default.number, | ||
_propTypes2.default.array | ||
]), | ||
keepOpen: _propTypes2.default.bool, | ||
customTransition: _propTypes2.default.string, | ||
onCollapse: _propTypes2.default.func | ||
}), | ||
(CollapsePane.defaultProps = { | ||
currentActiveIndex: void 0, | ||
keepOpen: !1, | ||
customTransition: "", | ||
onCollapse: function a() {} | ||
}), | ||
(exports.default = CollapsePane); |
@@ -1,1 +0,151 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_react=require('react'),_react2=_interopRequireDefault(_react),_propTypes=require('prop-types'),_propTypes2=_interopRequireDefault(_propTypes),_CollapseContainer=require('./CollapseContainer'),_CollapseContainer2=_interopRequireDefault(_CollapseContainer),_CollapsePane=require('./CollapsePane'),_CollapsePane2=_interopRequireDefault(_CollapsePane);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _toConsumableArray(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function _inherits(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}var Collapsible=function(a){function b(a){var c=a.keepOpen;_classCallCheck(this,b);var d=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));return d.state={currentActiveIndex:c?[]:''},d.onCollapse=d.onCollapse.bind(d),d}return _inherits(b,a),_createClass(b,[{key:'onCollapse',value:function c(a){var b=this.props.keepOpen;b?this.keepOpenCollapse(a):this.defaultCollapse(a)}},{key:'keepOpenCollapse',value:function c(a){var b=this.state.currentActiveIndex;0>b.indexOf(a.toString())?this.setState({currentActiveIndex:[a.toString()].concat(_toConsumableArray(b))}):this.setState({currentActiveIndex:b.filter(function(b){return 0>b.indexOf(a.toString())})})}},{key:'defaultCollapse',value:function c(a){var b=this.state.currentActiveIndex;b.toString()===a.toString()&&1<a.length?this.setState({currentActiveIndex:a.slice(0,a.length-2)}):b.toString()===a.toString()?this.setState({currentActiveIndex:''}):this.setState({currentActiveIndex:a})}},{key:'render',value:function f(){var a=this,b=this.props,c=b.data,d=b.keepOpen,e=b.customTransition;return _react2.default.createElement('div',null,_react2.default.createElement(_CollapseContainer2.default,{currentActiveIndex:this.state.currentActiveIndex,onCollapse:function c(b){return a.onCollapse(b)}},c.map(function(a,b){return _react2.default.createElement(_CollapsePane2.default,{key:'collapse-pane-'+b,items:a,index:b,keepOpen:d,customTransition:e})})))}}]),b}(_react.Component);Collapsible.propTypes={data:_propTypes2.default.arrayOf(_propTypes2.default.object).isRequired,keepOpen:_propTypes2.default.bool,customTransition:_propTypes2.default.string},Collapsible.defaultProps={keepOpen:!1,customTransition:void 0},exports.default=Collapsible; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: !0 }); | ||
var _createClass = (function() { | ||
function a(a, b) { | ||
for (var c, d = 0; d < b.length; d++) | ||
(c = b[d]), | ||
(c.enumerable = c.enumerable || !1), | ||
(c.configurable = !0), | ||
"value" in c && (c.writable = !0), | ||
Object.defineProperty(a, c.key, c); | ||
} | ||
return function(b, c, d) { | ||
return c && a(b.prototype, c), d && a(b, d), b; | ||
}; | ||
})(), | ||
_react = require("react"), | ||
_react2 = _interopRequireDefault(_react), | ||
_propTypes = require("prop-types"), | ||
_propTypes2 = _interopRequireDefault(_propTypes), | ||
_CollapseContainer = require("./CollapseContainer"), | ||
_CollapseContainer2 = _interopRequireDefault(_CollapseContainer), | ||
_CollapsePane = require("./CollapsePane"), | ||
_CollapsePane2 = _interopRequireDefault(_CollapsePane); | ||
function _interopRequireDefault(a) { | ||
return a && a.__esModule ? a : { default: a }; | ||
} | ||
function _toConsumableArray(a) { | ||
if (Array.isArray(a)) { | ||
for (var b = 0, c = Array(a.length); b < a.length; b++) c[b] = a[b]; | ||
return c; | ||
} | ||
return Array.from(a); | ||
} | ||
function _classCallCheck(a, b) { | ||
if (!(a instanceof b)) | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function _possibleConstructorReturn(a, b) { | ||
if (!a) | ||
throw new ReferenceError( | ||
"this hasn't been initialised - super() hasn't been called" | ||
); | ||
return b && ("object" == typeof b || "function" == typeof b) ? b : a; | ||
} | ||
function _inherits(a, b) { | ||
if ("function" != typeof b && null !== b) | ||
throw new TypeError( | ||
"Super expression must either be null or a function, not " + typeof b | ||
); | ||
(a.prototype = Object.create(b && b.prototype, { | ||
constructor: { value: a, enumerable: !1, writable: !0, configurable: !0 } | ||
})), | ||
b && | ||
(Object.setPrototypeOf ? Object.setPrototypeOf(a, b) : (a.__proto__ = b)); | ||
} // eslint-disable-next-line | ||
var Collapsible = (function(a) { | ||
function b(a) { | ||
var c = a.keepOpen; | ||
_classCallCheck(this, b); | ||
var d = _possibleConstructorReturn( | ||
this, | ||
(b.__proto__ || Object.getPrototypeOf(b)).call(this) | ||
); | ||
return ( | ||
(d.state = { currentActiveIndex: c ? [] : "" }), | ||
(d.onCollapse = d.onCollapse.bind(d)), | ||
d | ||
); | ||
} | ||
return ( | ||
_inherits(b, a), | ||
_createClass(b, [ | ||
{ | ||
key: "onCollapse", | ||
value: function c(a) { | ||
var b = this.props.keepOpen; | ||
b ? this.keepOpenCollapse(a) : this.defaultCollapse(a); | ||
} | ||
}, | ||
{ | ||
key: "keepOpenCollapse", | ||
value: function c(a) { | ||
var b = this.state.currentActiveIndex; | ||
0 > b.indexOf(a.toString()) | ||
? this.setState({ | ||
currentActiveIndex: [a.toString()].concat(_toConsumableArray(b)) | ||
}) | ||
: this.setState({ | ||
currentActiveIndex: b.filter(function(b) { | ||
return 0 > b.indexOf(a.toString()); | ||
}) | ||
}); | ||
} | ||
}, | ||
{ | ||
key: "defaultCollapse", | ||
value: function c(a) { | ||
var b = this.state.currentActiveIndex; | ||
b.toString() === a.toString() && 1 < a.length | ||
? this.setState({ currentActiveIndex: a.slice(0, a.length - 2) }) | ||
: b.toString() === a.toString() | ||
? this.setState({ currentActiveIndex: "" }) | ||
: this.setState({ currentActiveIndex: a }); | ||
} | ||
}, | ||
{ | ||
key: "render", | ||
value: function f() { | ||
var a = this, | ||
b = this.props, | ||
c = b.data, | ||
d = b.keepOpen, | ||
e = b.customTransition; | ||
return _react2.default.createElement( | ||
"div", | ||
null, | ||
_react2.default.createElement( | ||
_CollapseContainer2.default, | ||
{ | ||
currentActiveIndex: this.state.currentActiveIndex, | ||
onCollapse: function c(b) { | ||
return a.onCollapse(b); | ||
} | ||
}, | ||
c.map(function(a, b) { | ||
return _react2.default.createElement( | ||
_CollapsePane2.default, // eslint-disable-next-line | ||
{ | ||
key: "collapse-pane-" + b, | ||
items: a, | ||
index: b, | ||
keepOpen: d, | ||
customTransition: e | ||
} | ||
); | ||
}) | ||
) | ||
); | ||
} | ||
} | ||
]), | ||
b | ||
); | ||
})(_react.Component); | ||
(Collapsible.propTypes = { | ||
data: _propTypes2.default.arrayOf(_propTypes2.default.object).isRequired, | ||
keepOpen: _propTypes2.default.bool, | ||
customTransition: _propTypes2.default.string | ||
}), | ||
(Collapsible.defaultProps = { keepOpen: !1, customTransition: void 0 }), | ||
(exports.default = Collapsible); |
@@ -1,1 +0,133 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_react=require('react'),_react2=_interopRequireDefault(_react),_propTypes=require('prop-types'),_propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function _inherits(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}/* eslint-disable react/no-did-mount-set-state *//* eslint-disable react/no-did-update-set-state */var Content=function(a){function b(){_classCallCheck(this,b);var a=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));return a.contentRef=_react2.default.createRef(),a.state={height:0},a}return _inherits(b,a),_createClass(b,[{key:'componentDidMount',value:function a(){this.setState({height:this.contentRef.current.scrollHeight})}},{key:'componentDidUpdate',value:function b(){var a=this.state.height;this.contentRef.current.scrollHeight!==a&&this.setState({height:this.contentRef.current.scrollHeight})}},{key:'render',value:function i(){var a=this.props,b=a.text,c=a.active,d=a.contentStyle,e=a.activeContentStyle,f=a.customTransition,g='string'==typeof d?d:'',h=g?{}:d;return _react2.default.createElement('div',{style:_extends({},h,{height:c?this.state.height:0,transition:f||'height .3s ease-out',overflow:'hidden'}),ref:this.contentRef,className:c&&e?g+' '+e:g},b)}}]),b}(_react2.default.PureComponent);Content.propTypes={text:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number,_propTypes2.default.element]).isRequired,active:_propTypes2.default.bool,contentStyle:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.object]),activeContentStyle:_propTypes2.default.string,customTransition:_propTypes2.default.string},Content.defaultProps={active:!1,contentStyle:void 0,activeContentStyle:void 0,customTransition:''},exports.default=Content; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: !0 }); | ||
var _extends = | ||
Object.assign || | ||
function(a) { | ||
for (var b, c = 1; c < arguments.length; c++) | ||
for (var d in ((b = arguments[c]), b)) | ||
Object.prototype.hasOwnProperty.call(b, d) && (a[d] = b[d]); | ||
return a; | ||
}, | ||
_createClass = (function() { | ||
function a(a, b) { | ||
for (var c, d = 0; d < b.length; d++) | ||
(c = b[d]), | ||
(c.enumerable = c.enumerable || !1), | ||
(c.configurable = !0), | ||
"value" in c && (c.writable = !0), | ||
Object.defineProperty(a, c.key, c); | ||
} | ||
return function(b, c, d) { | ||
return c && a(b.prototype, c), d && a(b, d), b; | ||
}; | ||
})(), | ||
_react = require("react"), | ||
_react2 = _interopRequireDefault(_react), | ||
_propTypes = require("prop-types"), | ||
_propTypes2 = _interopRequireDefault(_propTypes); | ||
function _interopRequireDefault(a) { | ||
return a && a.__esModule ? a : { default: a }; | ||
} | ||
function _classCallCheck(a, b) { | ||
if (!(a instanceof b)) | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function _possibleConstructorReturn(a, b) { | ||
if (!a) | ||
throw new ReferenceError( | ||
"this hasn't been initialised - super() hasn't been called" | ||
); | ||
return b && ("object" == typeof b || "function" == typeof b) ? b : a; | ||
} | ||
function _inherits(a, b) { | ||
if ("function" != typeof b && null !== b) | ||
throw new TypeError( | ||
"Super expression must either be null or a function, not " + typeof b | ||
); | ||
(a.prototype = Object.create(b && b.prototype, { | ||
constructor: { value: a, enumerable: !1, writable: !0, configurable: !0 } | ||
})), | ||
b && | ||
(Object.setPrototypeOf ? Object.setPrototypeOf(a, b) : (a.__proto__ = b)); | ||
} // eslint-disable-next-line | ||
/* eslint-disable react/no-did-mount-set-state */ /* eslint-disable react/no-did-update-set-state */ var Content = (function( | ||
a | ||
) { | ||
function b() { | ||
_classCallCheck(this, b); | ||
var a = _possibleConstructorReturn( | ||
this, | ||
(b.__proto__ || Object.getPrototypeOf(b)).call(this) | ||
); | ||
return ( | ||
(a.contentRef = _react2.default.createRef()), (a.state = { height: 0 }), a | ||
); | ||
} | ||
return ( | ||
_inherits(b, a), | ||
_createClass(b, [ | ||
{ | ||
key: "componentDidMount", | ||
value: function a() { | ||
this.setState({ height: this.contentRef.current.scrollHeight }); | ||
} | ||
}, | ||
{ | ||
key: "componentDidUpdate", | ||
value: function b() { | ||
var a = this.state.height; | ||
this.contentRef.current.scrollHeight !== a && | ||
this.setState({ height: this.contentRef.current.scrollHeight }); | ||
} | ||
}, | ||
{ | ||
key: "render", | ||
value: function i() { | ||
var a = this.props, | ||
b = a.text, | ||
c = a.active, | ||
d = a.contentStyle, | ||
e = a.activeContentStyle, | ||
f = a.customTransition, | ||
g = "string" == typeof d ? d : "", | ||
h = g ? {} : d; | ||
return _react2.default.createElement( | ||
"div", | ||
{ | ||
style: _extends({}, h, { | ||
height: c ? this.state.height : 0, | ||
transition: f || "height .3s ease-out", | ||
overflow: "hidden" | ||
}), | ||
ref: this.contentRef, | ||
className: c && e ? g + " " + e : g | ||
}, | ||
b | ||
); | ||
} | ||
} | ||
]), | ||
b | ||
); | ||
})(_react2.default.PureComponent); | ||
(Content.propTypes = { | ||
text: _propTypes2.default.oneOfType([ | ||
_propTypes2.default.string, | ||
_propTypes2.default.number, | ||
_propTypes2.default.element | ||
]).isRequired, | ||
active: _propTypes2.default.bool, | ||
contentStyle: _propTypes2.default.oneOfType([ | ||
_propTypes2.default.string, | ||
_propTypes2.default.object | ||
]), | ||
activeContentStyle: _propTypes2.default.string, | ||
customTransition: _propTypes2.default.string | ||
}), | ||
(Content.defaultProps = { | ||
active: !1, | ||
contentStyle: void 0, | ||
activeContentStyle: void 0, | ||
customTransition: "" | ||
}), | ||
(exports.default = Content); |
@@ -1,1 +0,150 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _extends=Object.assign||function(a){for(var b,c=1;c<arguments.length;c++)for(var d in b=arguments[c],b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=b[d]);return a},_createClass=function(){function a(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,'value'in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}return function(b,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),_react=require('react'),_react2=_interopRequireDefault(_react),_propTypes=require('prop-types'),_propTypes2=_interopRequireDefault(_propTypes);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError('Cannot call a class as a function')}function _possibleConstructorReturn(a,b){if(!a)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return b&&('object'==typeof b||'function'==typeof b)?b:a}function _inherits(a,b){if('function'!=typeof b&&null!==b)throw new TypeError('Super expression must either be null or a function, not '+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}/* eslint-disable react/no-did-mount-set-state *//* eslint-disable react/no-did-update-set-state */var Title=function(a){function b(){_classCallCheck(this,b);var a=_possibleConstructorReturn(this,(b.__proto__||Object.getPrototypeOf(b)).call(this));return a.titleRef=_react2.default.createRef(),a.state={height:0},a}return _inherits(b,a),_createClass(b,[{key:'componentDidMount',value:function a(){this.setState({height:this.titleRef.current.scrollHeight})}},{key:'componentDidUpdate',value:function b(){var a=this.state.height;this.titleRef.current.scrollHeight!==a&&this.setState({height:this.titleRef.current.scrollHeight})}},{key:'render',value:function l(){var a=this.props,b=a.index,c=a.text,d=a.onCollapse,e=a.isNested,f=a.active,g=a.titleStyle,h=a.activeTitleStyle,i=a.customTransition,j='string'==typeof g?g:'',k=j?{}:g;return _react2.default.createElement('div',{role:'presentation',onKeyPress:function a(){return d(b)},onClick:function a(){return d(b)},style:_extends({},k,{height:e&&!f?0:this.state.height,transition:i||'height .3s ease-out',overflow:'hidden'}),ref:this.titleRef,className:(!e||f)&&h?j+' '+h:j},c)}}]),b}(_react2.default.PureComponent);Title.propTypes={text:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number,_propTypes2.default.element]).isRequired,onCollapse:_propTypes2.default.func.isRequired,isNested:_propTypes2.default.bool,index:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.number]).isRequired,active:_propTypes2.default.bool,titleStyle:_propTypes2.default.oneOfType([_propTypes2.default.string,_propTypes2.default.object]),activeTitleStyle:_propTypes2.default.string,customTransition:_propTypes2.default.string},Title.defaultProps={active:!1,isNested:!1,titleStyle:void 0,activeTitleStyle:void 0,customTransition:''},exports.default=Title; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: !0 }); | ||
var _extends = | ||
Object.assign || | ||
function(a) { | ||
for (var b, c = 1; c < arguments.length; c++) | ||
for (var d in ((b = arguments[c]), b)) | ||
Object.prototype.hasOwnProperty.call(b, d) && (a[d] = b[d]); | ||
return a; | ||
}, | ||
_createClass = (function() { | ||
function a(a, b) { | ||
for (var c, d = 0; d < b.length; d++) | ||
(c = b[d]), | ||
(c.enumerable = c.enumerable || !1), | ||
(c.configurable = !0), | ||
"value" in c && (c.writable = !0), | ||
Object.defineProperty(a, c.key, c); | ||
} | ||
return function(b, c, d) { | ||
return c && a(b.prototype, c), d && a(b, d), b; | ||
}; | ||
})(), | ||
_react = require("react"), | ||
_react2 = _interopRequireDefault(_react), | ||
_propTypes = require("prop-types"), | ||
_propTypes2 = _interopRequireDefault(_propTypes); | ||
function _interopRequireDefault(a) { | ||
return a && a.__esModule ? a : { default: a }; | ||
} | ||
function _classCallCheck(a, b) { | ||
if (!(a instanceof b)) | ||
throw new TypeError("Cannot call a class as a function"); | ||
} | ||
function _possibleConstructorReturn(a, b) { | ||
if (!a) | ||
throw new ReferenceError( | ||
"this hasn't been initialised - super() hasn't been called" | ||
); | ||
return b && ("object" == typeof b || "function" == typeof b) ? b : a; | ||
} | ||
function _inherits(a, b) { | ||
if ("function" != typeof b && null !== b) | ||
throw new TypeError( | ||
"Super expression must either be null or a function, not " + typeof b | ||
); | ||
(a.prototype = Object.create(b && b.prototype, { | ||
constructor: { value: a, enumerable: !1, writable: !0, configurable: !0 } | ||
})), | ||
b && | ||
(Object.setPrototypeOf ? Object.setPrototypeOf(a, b) : (a.__proto__ = b)); | ||
} // eslint-disable-next-line | ||
/* eslint-disable react/no-did-mount-set-state */ /* eslint-disable react/no-did-update-set-state */ var Title = (function( | ||
a | ||
) { | ||
function b() { | ||
_classCallCheck(this, b); | ||
var a = _possibleConstructorReturn( | ||
this, | ||
(b.__proto__ || Object.getPrototypeOf(b)).call(this) | ||
); | ||
return ( | ||
(a.titleRef = _react2.default.createRef()), (a.state = { height: 0 }), a | ||
); | ||
} | ||
return ( | ||
_inherits(b, a), | ||
_createClass(b, [ | ||
{ | ||
key: "componentDidMount", | ||
value: function a() { | ||
this.setState({ height: this.titleRef.current.scrollHeight }); | ||
} | ||
}, | ||
{ | ||
key: "componentDidUpdate", | ||
value: function b() { | ||
var a = this.state.height; | ||
this.titleRef.current.scrollHeight !== a && | ||
this.setState({ height: this.titleRef.current.scrollHeight }); | ||
} | ||
}, | ||
{ | ||
key: "render", | ||
value: function l() { | ||
var a = this.props, | ||
b = a.index, | ||
c = a.text, | ||
d = a.onCollapse, | ||
e = a.isNested, | ||
f = a.active, | ||
g = a.titleStyle, | ||
h = a.activeTitleStyle, | ||
i = a.customTransition, | ||
j = "string" == typeof g ? g : "", | ||
k = j ? {} : g; | ||
return _react2.default.createElement( | ||
"div", | ||
{ | ||
role: "presentation", | ||
onKeyPress: function a() { | ||
return d(b); | ||
}, | ||
onClick: function a() { | ||
return d(b); | ||
}, | ||
style: _extends({}, k, { | ||
height: e && !f ? 0 : this.state.height, | ||
transition: i || "height .3s ease-out", | ||
overflow: "hidden" | ||
}), | ||
ref: this.titleRef, | ||
className: (!e || f) && h ? j + " " + h : j | ||
}, | ||
c | ||
); | ||
} | ||
} | ||
]), | ||
b | ||
); | ||
})(_react2.default.PureComponent); | ||
(Title.propTypes = { | ||
text: _propTypes2.default.oneOfType([ | ||
_propTypes2.default.string, | ||
_propTypes2.default.number, | ||
_propTypes2.default.element | ||
]).isRequired, | ||
onCollapse: _propTypes2.default.func.isRequired, | ||
isNested: _propTypes2.default.bool, | ||
index: _propTypes2.default.oneOfType([ | ||
_propTypes2.default.string, | ||
_propTypes2.default.number | ||
]).isRequired, | ||
active: _propTypes2.default.bool, | ||
titleStyle: _propTypes2.default.oneOfType([ | ||
_propTypes2.default.string, | ||
_propTypes2.default.object | ||
]), | ||
activeTitleStyle: _propTypes2.default.string, | ||
customTransition: _propTypes2.default.string | ||
}), | ||
(Title.defaultProps = { | ||
active: !1, | ||
isNested: !1, | ||
titleStyle: void 0, | ||
activeTitleStyle: void 0, | ||
customTransition: "" | ||
}), | ||
(exports.default = Title); |
{ | ||
"name": "react-simple-collapsible-element", | ||
"version": "2.0.10", | ||
"version": "2.0.11", | ||
"description": "simple react collapsible supports nested elements", | ||
@@ -13,2 +13,3 @@ "main": "index.js", | ||
"lint": "eslint ./ --fix --ext .jsx --ext .js", | ||
"lint:fix": "eslint ./ --fix --ext .jsx --ext .js --fix", | ||
"test:watch": "jest --watch", | ||
@@ -21,2 +22,7 @@ "test:coverage": "jest --coverage", | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "pretty-quick --staged && npm run test" | ||
} | ||
}, | ||
"jest": { | ||
@@ -40,3 +46,3 @@ "setupFiles": [ | ||
"devDependencies": { | ||
"babel-cli": "^6.5.2", | ||
"babel-cli": "^6.26.0", | ||
"babel-core": "^6.17.0", | ||
@@ -57,3 +63,6 @@ "babel-eslint": "^8.0.1", | ||
"eslint-plugin-react": "^7.4.0", | ||
"husky": "^1.2.0", | ||
"jest": "^23.6.0", | ||
"prettier": "^1.15.2", | ||
"pretty-quick": "^1.8.0", | ||
"react": "^16.0.0", | ||
@@ -60,0 +69,0 @@ "react-dom": "^16.0.0", |
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
24822
558
2
24